diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2002-03-24 22:17:05 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2002-03-24 22:17:05 +0000 |
commit | 70b13be27496e17515c76f70f0b9576e3879861d (patch) | |
tree | dce90f1115e9864b9a58427acf51b0992f53383e /bin/ed | |
parent | 6a39dd6efa87824d9c9032ab61f7692387a83d3c (diff) |
Kill unneeded longs; fixes some minor 64 bit issues. deraadt@ OK
Diffstat (limited to 'bin/ed')
-rw-r--r-- | bin/ed/buf.c | 12 | ||||
-rw-r--r-- | bin/ed/ed.h | 63 | ||||
-rw-r--r-- | bin/ed/glbl.c | 18 | ||||
-rw-r--r-- | bin/ed/io.c | 36 | ||||
-rw-r--r-- | bin/ed/main.c | 74 | ||||
-rw-r--r-- | bin/ed/sub.c | 12 | ||||
-rw-r--r-- | bin/ed/undo.c | 22 |
7 files changed, 119 insertions, 118 deletions
diff --git a/bin/ed/buf.c b/bin/ed/buf.c index 145f7d5801d..eca020a1c1f 100644 --- a/bin/ed/buf.c +++ b/bin/ed/buf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: buf.c,v 1.11 2001/01/16 03:04:45 deraadt Exp $ */ +/* $OpenBSD: buf.c,v 1.12 2002/03/24 22:17:04 millert Exp $ */ /* $NetBSD: buf.c,v 1.15 1995/04/23 10:07:28 cgd Exp $ */ /* buf.c: This file contains the scratch-file buffer rountines for the @@ -33,7 +33,7 @@ #if 0 static char *rcsid = "@(#)buf.c,v 1.4 1994/02/01 00:34:35 alm Exp"; #else -static char rcsid[] = "$OpenBSD: buf.c,v 1.11 2001/01/16 03:04:45 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: buf.c,v 1.12 2002/03/24 22:17:04 millert Exp $"; #endif #endif /* not lint */ @@ -147,12 +147,12 @@ add_line_node(lp) /* get_line_node_addr: return line number of pointer */ -long +int get_line_node_addr(lp) line_t *lp; { line_t *cp = &buffer_head; - long n = 0; + int n = 0; while (cp != lp && (cp = cp->q_forw) != &buffer_head) n++; @@ -167,10 +167,10 @@ get_line_node_addr(lp) /* get_addressed_line_node: return pointer to a line node in the editor buffer */ line_t * get_addressed_line_node(n) - long n; + int n; { static line_t *lp = &buffer_head; - static long on = 0; + static int on = 0; SPL1(); if (n > on) { diff --git a/bin/ed/ed.h b/bin/ed/ed.h index d8226f1bf55..98b2d42d164 100644 --- a/bin/ed/ed.h +++ b/bin/ed/ed.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ed.h,v 1.9 2002/02/17 19:42:19 millert Exp $ */ +/* $OpenBSD: ed.h,v 1.10 2002/03/24 22:17:04 millert Exp $ */ /* $NetBSD: ed.h,v 1.23 1995/03/21 09:04:40 cgd Exp $ */ /* ed.h: type and constant definitions for the ed editor. */ @@ -112,14 +112,15 @@ if (--mutex == 0) { \ if (sigflags & (1 << (SIGINT - 1))) handle_int(SIGINT); \ } -/* STRTOL: convert a string to long */ -#define STRTOL(i, p) { \ - if (((i = strtol(p, &p, 10)) == LONG_MIN || i == LONG_MAX) && \ - errno == ERANGE) { \ +/* STRTOI: convert a string to int */ +#define STRTOI(i, p) { \ + long l = strtol(p, &p, 10); \ + if (l <= INT_MIN || l >= INT_MAX) { \ seterrmsg("number out of range"); \ i = 0; \ return ERR; \ - } \ + } else \ + i = (int)l; \ } #if defined(sun) || defined(NO_REALLOC_NULL) @@ -192,38 +193,38 @@ if ((i) > (n)) { \ /* Local Function Declarations */ void add_line_node(line_t *); -int append_lines(long); +int append_lines(int); int apply_subst_template(char *, regmatch_t *, int, int); int build_active_list(int); int cbc_decode(char *, FILE *); int cbc_encode(char *, int, FILE *); -int check_addr_range(long, long); +int check_addr_range(int, int); void clear_active_list(void); void clear_undo_stack(void); int close_sbuf(void); -int copy_lines(long); -int delete_lines(long, long); +int copy_lines(int); +int delete_lines(int, int); void des_error(char *); -int display_lines(long, long, int); +int display_lines(int, int, int); line_t *dup_line_node(line_t *); int exec_command(void); -long exec_global(int, int); +int exec_global(int, int); void expand_des_key(char *, char *); int extract_addr_range(void); char *extract_pattern(int); -int extract_subst_tail(int *, long *); +int extract_subst_tail(int *, int *); char *extract_subst_template(void); -int filter_lines(long, long, char *); +int filter_lines(int, int, char *); int flush_des_file(FILE *); -line_t *get_addressed_line_node(long); +line_t *get_addressed_line_node(int); pattern_t *get_compiled_pattern(void); int get_des_char(FILE *); char *get_extended_line(int *, int); char *get_filename(void); int get_keyword(void); -long get_line_node_addr(line_t *); -long get_matching_node_addr(pattern_t *, int); -long get_marked_node_addr(int); +int get_line_node_addr(line_t *); +int get_matching_node_addr(pattern_t *, int); +int get_marked_node_addr(int); char *get_sbuf_line(line_t *); int get_shell_command(void); int get_stream_line(FILE *); @@ -236,22 +237,22 @@ int hex_to_binary(int, int); void init_buffers(void); void init_des_cipher(void); int is_legal_filename(char *); -int join_lines(long, long); +int join_lines(int, int); int mark_line_node(line_t *, int); -int move_lines(long); +int move_lines(int); line_t *next_active_node(void); -long next_addr(void); +int next_addr(void); int open_sbuf(void); char *parse_char_class(char *); int pop_undo_stack(void); -undo_t *push_undo_stack(int, long, long); +undo_t *push_undo_stack(int, int, int); int put_des_char(int, FILE *); char *put_sbuf_line(char *); int put_stream_line(FILE *, char *, int); -int put_tty_line(char *, int, long, int); +int put_tty_line(char *, int, int, int); void quit(int); -long read_file(char *, long); -long read_stream(FILE *, long); +int read_file(char *, int); +int read_stream(FILE *, int); int search_and_replace(pattern_t *, int, int); int set_active_node(line_t *); void set_des_key(char *); @@ -263,8 +264,8 @@ int substitute_matching_text(pattern_t *, line_t *, int, int); char *translit_text(char *, int, int, int); void unmark_line_node(line_t *); void unset_active_nodes(line_t *, line_t *); -long write_file(char *, char *, long, long); -long write_stream(FILE *, long, long); +int write_file(char *, char *, int, int); +int write_stream(FILE *, int, int); /* global buffers */ extern char stdinbuf[]; @@ -280,12 +281,12 @@ extern int mutex; extern int sigflags; /* global vars */ -extern long addr_last; -extern long current_addr; +extern int addr_last; +extern int current_addr; extern char errmsg[MAXPATHLEN + 40]; -extern long first_addr; +extern int first_addr; extern int lineno; -extern long second_addr; +extern int second_addr; #ifdef sun extern char *sys_errlist[]; #endif diff --git a/bin/ed/glbl.c b/bin/ed/glbl.c index 38af91c1c30..383ad45289a 100644 --- a/bin/ed/glbl.c +++ b/bin/ed/glbl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: glbl.c,v 1.8 2001/01/16 03:04:45 deraadt Exp $ */ +/* $OpenBSD: glbl.c,v 1.9 2002/03/24 22:17:04 millert Exp $ */ /* $NetBSD: glbl.c,v 1.2 1995/03/21 09:04:41 cgd Exp $ */ /* glob.c: This file contains the global command routines for the ed line @@ -33,7 +33,7 @@ #if 0 static char *rcsid = "@(#)glob.c,v 1.1 1994/02/01 00:34:40 alm Exp"; #else -static char rcsid[] = "$OpenBSD: glbl.c,v 1.8 2001/01/16 03:04:45 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: glbl.c,v 1.9 2002/03/24 22:17:04 millert Exp $"; #endif #endif /* not lint */ @@ -50,7 +50,7 @@ build_active_list(isgcmd) { pattern_t *pat; line_t *lp; - long n; + int n; char *s; char delimiter; @@ -78,7 +78,7 @@ build_active_list(isgcmd) /* exec_global: apply command list in the command buffer to the active lines in a range; return command status */ -long +int exec_global(interact, gflag) int interact; int gflag; @@ -147,10 +147,10 @@ exec_global(interact, gflag) line_t **active_list; /* list of lines active in a global command */ -long active_last; /* index of last active line in active_list */ -long active_size; /* size of active_list */ -long active_ptr; /* active_list index (non-decreasing) */ -long active_ndx; /* active_list index (modulo active_last) */ +int active_last; /* index of last active line in active_list */ +int active_size; /* size of active_list */ +int active_ptr; /* active_list index (non-decreasing) */ +int active_ndx; /* active_list index (modulo active_last) */ /* set_active_node: add a line node to the global-active list */ int @@ -197,7 +197,7 @@ unset_active_nodes(np, mp) line_t *np, *mp; { line_t *lp; - long i; + int i; for (lp = np; lp != mp; lp = lp->q_forw) for (i = 0; i < active_last; i++) diff --git a/bin/ed/io.c b/bin/ed/io.c index e2fd66cc7ac..ef013cca87b 100644 --- a/bin/ed/io.c +++ b/bin/ed/io.c @@ -1,4 +1,4 @@ -/* $OpenBSD: io.c,v 1.9 2002/01/16 18:44:21 mpech Exp $ */ +/* $OpenBSD: io.c,v 1.10 2002/03/24 22:17:04 millert Exp $ */ /* $NetBSD: io.c,v 1.2 1995/03/21 09:04:43 cgd Exp $ */ /* io.c: This file contains the i/o routines for the ed line editor */ @@ -32,7 +32,7 @@ #if 0 static char *rcsid = "@(#)io.c,v 1.1 1994/02/01 00:34:41 alm Exp"; #else -static char rcsid[] = "$OpenBSD: io.c,v 1.9 2002/01/16 18:44:21 mpech Exp $"; +static char rcsid[] = "$OpenBSD: io.c,v 1.10 2002/03/24 22:17:04 millert Exp $"; #endif #endif /* not lint */ @@ -42,13 +42,13 @@ static char rcsid[] = "$OpenBSD: io.c,v 1.9 2002/01/16 18:44:21 mpech Exp $"; extern int scripted; /* read_file: read a named file/pipe into the buffer; return line count */ -long +int read_file(fn, n) char *fn; - long n; + int n; { FILE *fp; - long size; + int size; fp = (*fn == '!') ? popen(fn + 1, "r") : fopen(strip_escapes(fn), "r"); @@ -75,14 +75,14 @@ int sbufsz; /* file i/o buffer size */ int newline_added; /* if set, newline appended to input file */ /* read_stream: read a stream into the editor buffer; return status */ -long +int read_stream(fp, n) FILE *fp; - long n; + int n; { line_t *lp = get_addressed_line_node(n); undo_t *up = NULL; - unsigned long size = 0; + unsigned int size = 0; int o_newline_added = newline_added; int o_isbinary = isbinary; int appended = (n == addr_last); @@ -156,15 +156,15 @@ get_stream_line(fp) /* write_file: write a range of lines to a named file/pipe; return line count */ -long +int write_file(fn, mode, n, m) char *fn; char *mode; - long n; - long m; + int n; + int m; { FILE *fp; - long size; + int size; fp = (*fn == '!') ? popen(fn+1, "w") : fopen(strip_escapes(fn), mode); if (fp == NULL) { @@ -184,14 +184,14 @@ write_file(fn, mode, n, m) /* write_stream: write a range of lines to a stream; return status */ -long +int write_stream(fp, n, m) FILE *fp; - long n; - long m; + int n; + int m; { line_t *lp = get_addressed_line_node(n); - unsigned long size = 0; + unsigned int size = 0; char *s; int len; @@ -329,7 +329,7 @@ int put_tty_line(s, l, n, gflag) char *s; int l; - long n; + int n; int gflag; { int col = 0; @@ -339,7 +339,7 @@ put_tty_line(s, l, n, gflag) char *cp; if (gflag & GNP) { - printf("%ld\t", n); + printf("%d\t", n); col = 8; } for (; l--; s++) { diff --git a/bin/ed/main.c b/bin/ed/main.c index b8efb8aaf5e..7fa68e17dc2 100644 --- a/bin/ed/main.c +++ b/bin/ed/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.25 2002/01/16 01:28:54 millert Exp $ */ +/* $OpenBSD: main.c,v 1.26 2002/03/24 22:17:04 millert Exp $ */ /* $NetBSD: main.c,v 1.3 1995/03/21 09:04:44 cgd Exp $ */ /* main.c: This file contains the main control and user-interface routines @@ -39,7 +39,7 @@ char *copyright = #if 0 static char *rcsid = "@(#)main.c,v 1.1 1994/02/01 00:34:42 alm Exp"; #else -static char rcsid[] = "$OpenBSD: main.c,v 1.25 2002/01/16 01:28:54 millert Exp $"; +static char rcsid[] = "$OpenBSD: main.c,v 1.26 2002/03/24 22:17:04 millert Exp $"; #endif #endif /* not lint */ @@ -99,8 +99,8 @@ int sigactive = 0; /* if set, signal handlers are enabled */ int interactive = 0; /* if set, we are in interactive mode */ char old_filename[MAXPATHLEN] = ""; /* default filename */ -long current_addr; /* current address in editor buffer */ -long addr_last; /* last address in editor buffer */ +int current_addr; /* current address in editor buffer */ +int addr_last; /* last address in editor buffer */ int lineno; /* script line number */ char *prompt; /* command-line prompt */ char *dps = "*"; /* default command-line prompt */ @@ -122,7 +122,7 @@ main(argc, argv) char ** volatile argv; { int c, n; - long status = 0; + int status = 0; home = getenv("HOME"); @@ -283,14 +283,14 @@ top: /*NOTREACHED*/ } -long first_addr, second_addr, addr_cnt; +int first_addr, second_addr, addr_cnt; /* extract_addr_range: get line addresses from the command buffer until an illegal address is seen; return status */ int extract_addr_range() { - long addr; + int addr; addr_cnt = 0; first_addr = second_addr = current_addr; @@ -325,12 +325,12 @@ extract_addr_range() /* next_addr: return the next line address in the command buffer */ -long +int next_addr() { char *hd; - long addr = current_addr; - long n; + int addr = current_addr; + int n; int first = 1; int c; @@ -345,7 +345,7 @@ next_addr() ibufp++; SKIP_BLANKS(); if (isdigit(*ibufp)) { - STRTOL(n, ibufp); + STRTOI(n, ibufp); addr += (c == '-' || c == '^') ? -n : n; } else if (!isspace(c)) addr += (c == '-' || c == '^') ? -1 : 1; @@ -354,7 +354,7 @@ next_addr() case '3': case '4': case '5': case '6': case '7': case '8': case '9': MUST_BE_FIRST(); - STRTOL(addr, ibufp); + STRTOI(addr, ibufp); break; case '.': case '$': @@ -405,7 +405,7 @@ next_addr() /* GET_THIRD_ADDR: get a legal address from the command buffer */ #define GET_THIRD_ADDR(addr) \ do { \ - long ol1, ol2; \ + int ol1, ol2; \ \ ol1 = first_addr; \ ol2 = second_addr; \ @@ -427,7 +427,7 @@ next_addr() /* GET_THIRD_ADDR: get a legal address from the command buffer */ #define GET_THIRD_ADDR(addr) \ do { \ - long ol1, ol2; \ + int ol1, ol2; \ \ ol1 = first_addr; \ ol2 = second_addr; \ @@ -488,18 +488,18 @@ volatile sig_atomic_t cols = 72; /* wrap column */ int exec_command() { - extern long u_current_addr; - extern long u_addr_last; + extern int u_current_addr; + extern int u_addr_last; static pattern_t *pat = NULL; static int sgflag = 0; - static long sgnum = 0; + static int sgnum = 0; pattern_t *tpat; char *fnp; int gflag = 0; int sflags = 0; - long addr = 0; + int addr = 0; int n = 0; int c; @@ -744,7 +744,7 @@ exec_command() break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': - STRTOL(sgnum, ibufp); + STRTOI(sgnum, ibufp); sflags |= SGF; sgflag &= ~GSG; /* override GSG */ break; @@ -888,7 +888,7 @@ exec_command() #endif return ERR; else if ('0' < *ibufp && *ibufp <= '9') - STRTOL(rows, ibufp); + STRTOI(rows, ibufp); GET_COMMAND_SUFFIX(); if (display_lines(second_addr, min(addr_last, second_addr + rows), gflag) < 0) @@ -897,7 +897,7 @@ exec_command() break; case '=': GET_COMMAND_SUFFIX(); - printf("%ld\n", addr_cnt ? second_addr : addr_last); + printf("%d\n", addr_cnt ? second_addr : addr_last); break; case '!': if (addr_cnt > 0) { @@ -931,7 +931,7 @@ exec_command() /* check_addr_range: return status of address range check */ int check_addr_range(n, m) - long n, m; + int n, m; { if (addr_cnt == 0) { first_addr = n; @@ -949,13 +949,13 @@ check_addr_range(n, m) /* get_matching_node_addr: return the address of the next line matching a pattern in a given direction. wrap around begin/end of editor buffer if necessary */ -long +int get_matching_node_addr(pat, dir) pattern_t *pat; int dir; { char *s; - long n = current_addr; + int n = current_addr; line_t *lp; if (!pat) return ERR; @@ -1085,7 +1085,7 @@ get_shell_command() single period is read or EOF; return status */ int append_lines(n) - long n; + int n; { int l; char *lp = ibuf; @@ -1135,8 +1135,8 @@ append_lines(n) /* join_lines: replace a range of lines with the joined text of those lines */ int join_lines(from, to) - long from; - long to; + int from; + int to; { static char *buf = NULL; static int n; @@ -1174,11 +1174,11 @@ join_lines(from, to) /* move_lines: move a range of lines */ int move_lines(addr) - long addr; + int addr; { line_t *b1, *a1, *b2, *a2; - long n = INC_MOD(second_addr, addr_last); - long p = first_addr - 1; + int n = INC_MOD(second_addr, addr_last); + int p = first_addr - 1; int done = (addr == first_addr - 1 || addr == second_addr); SPL1(); @@ -1219,12 +1219,12 @@ move_lines(addr) /* copy_lines: copy a range of lines; return status */ int copy_lines(addr) - long addr; + int addr; { line_t *lp, *np = get_addressed_line_node(first_addr); undo_t *up = NULL; - long n = second_addr - first_addr + 1; - long m = 0; + int n = second_addr - first_addr + 1; + int m = 0; current_addr = addr; if (first_addr <= addr && addr < second_addr) { @@ -1256,7 +1256,7 @@ copy_lines(addr) /* delete_lines: delete a range of lines */ int delete_lines(from, to) - long from, to; + int from, to; { line_t *n, *p; @@ -1282,8 +1282,8 @@ delete_lines(from, to) /* display_lines: print a range of lines to stdout */ int display_lines(from, to, gflag) - long from; - long to; + int from; + int to; int gflag; { line_t *bp; @@ -1328,7 +1328,7 @@ mark_line_node(lp, n) /* get_marked_node_addr: return address of a marked line */ -long +int get_marked_node_addr(n) int n; { diff --git a/bin/ed/sub.c b/bin/ed/sub.c index ff42c91a024..ac5b8ca561e 100644 --- a/bin/ed/sub.c +++ b/bin/ed/sub.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sub.c,v 1.7 2001/01/16 03:04:46 deraadt Exp $ */ +/* $OpenBSD: sub.c,v 1.8 2002/03/24 22:17:04 millert Exp $ */ /* $NetBSD: sub.c,v 1.4 1995/03/21 09:04:50 cgd Exp $ */ /* sub.c: This file contains the substitution routines for the ed @@ -33,7 +33,7 @@ #if 0 static char *rcsid = "@(#)sub.c,v 1.1 1994/02/01 00:34:44 alm Exp"; #else -static char rcsid[] = "$OpenBSD: sub.c,v 1.7 2001/01/16 03:04:46 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: sub.c,v 1.8 2002/03/24 22:17:04 millert Exp $"; #endif #endif /* not lint */ @@ -48,7 +48,7 @@ int rhbufi; /* rhs substitution buffer index */ int extract_subst_tail(flagp, np) int *flagp; - long *np; + int *np; { char delimiter; @@ -65,7 +65,7 @@ extract_subst_tail(flagp, np) } else if (*ibufp == delimiter) ibufp++; if ('1' <= *ibufp && *ibufp <= '9') { - STRTOL(*np, ibufp); + STRTOI(*np, ibufp); return 0; } else if (*ibufp == 'g') { ibufp++; @@ -129,8 +129,8 @@ search_and_replace(pat, gflag, kth) undo_t *up; char *txt; char *eot; - long lc; - long xa = current_addr; + int lc; + int xa = current_addr; int nsubs = 0; line_t *lp; int len; diff --git a/bin/ed/undo.c b/bin/ed/undo.c index 652e022ffec..a82e0bc8e55 100644 --- a/bin/ed/undo.c +++ b/bin/ed/undo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: undo.c,v 1.5 2001/01/16 03:04:46 deraadt Exp $ */ +/* $OpenBSD: undo.c,v 1.6 2002/03/24 22:17:04 millert Exp $ */ /* $NetBSD: undo.c,v 1.2 1995/03/21 09:04:52 cgd Exp $ */ /* undo.c: This file contains the undo routines for the ed line editor */ @@ -32,7 +32,7 @@ #if 0 static char *rcsid = "@(#)undo.c,v 1.1 1994/02/01 00:34:44 alm Exp"; #else -static char rcsid[] = "$OpenBSD: undo.c,v 1.5 2001/01/16 03:04:46 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: undo.c,v 1.6 2002/03/24 22:17:04 millert Exp $"; #endif #endif /* not lint */ @@ -41,15 +41,15 @@ static char rcsid[] = "$OpenBSD: undo.c,v 1.5 2001/01/16 03:04:46 deraadt Exp $" #define USIZE 100 /* undo stack size */ undo_t *ustack = NULL; /* undo stack */ -long usize = 0; /* stack size variable */ -long u_p = 0; /* undo stack pointer */ +int usize = 0; /* stack size variable */ +int u_p = 0; /* undo stack pointer */ /* push_undo_stack: return pointer to intialized undo node */ undo_t * push_undo_stack(type, from, to) int type; - long from; - long to; + int from; + int to; { undo_t *t; @@ -88,16 +88,16 @@ push_undo_stack(type, from, to) } -long u_current_addr = -1; /* if >= 0, undo enabled */ -long u_addr_last = -1; /* if >= 0, undo enabled */ +int u_current_addr = -1; /* if >= 0, undo enabled */ +int u_addr_last = -1; /* if >= 0, undo enabled */ /* pop_undo_stack: undo last change to the editor buffer */ int pop_undo_stack() { - long n; - long o_current_addr = current_addr; - long o_addr_last = addr_last; + int n; + int o_current_addr = current_addr; + int o_addr_last = addr_last; if (u_current_addr == -1 || u_addr_last == -1) { seterrmsg("nothing to undo"); |