From: Sascha Wildner Date: Thu, 14 Nov 2013 12:01:25 +0000 (+0100) Subject: ed(1): Sync with FreeBSD. X-Git-Tag: v3.9.0~1195 X-Git-Url: https://gitweb.dragonflybsd.org/~tuxillo/dragonfly.git/commitdiff_plain/18ccd94eadcf22f4964956900d3163ca451c9cde ed(1): Sync with FreeBSD. Plugs some memory leaks and bumps WARNS to 6, mainly. --- diff --git a/bin/ed/Makefile b/bin/ed/Makefile index 923f41d4e3..ec2ca2395a 100644 --- a/bin/ed/Makefile +++ b/bin/ed/Makefile @@ -1,14 +1,12 @@ -# $FreeBSD: src/bin/ed/Makefile,v 1.18.2.1 2001/12/13 09:58:12 ru Exp $ -# $DragonFly: src/bin/ed/Makefile,v 1.10 2008/11/03 00:25:44 pavalos Exp $ +# $FreeBSD: head/bin/ed/Makefile 235654 2012-05-19 17:55:49Z marcel $ PROG= ed SRCS= buf.c cbc.c glbl.c io.c main.c re.c sub.c undo.c LINKS= ${BINDIR}/ed ${BINDIR}/red MLINKS= ed.1 red.1 -WARNS?= 2 -.if exists(${.CURDIR}/../../secure) && !defined(NO_CRYPT) +.if !defined(NO_CRYPT) && !defined(NO_OPENSSL) CFLAGS+=-DDES DPADD= ${LIBCRYPTO} LDADD= -lcrypto diff --git a/bin/ed/POSIX b/bin/ed/POSIX index 54eb9e7e53..f9b1e06265 100644 --- a/bin/ed/POSIX +++ b/bin/ed/POSIX @@ -1,5 +1,4 @@ -$FreeBSD: src/bin/ed/POSIX,v 1.7.2.1 2000/07/17 10:42:48 sheldonh Exp $ -$DragonFly: src/bin/ed/POSIX,v 1.2 2003/06/17 04:22:49 dillon Exp $ +$FreeBSD: head/bin/ed/POSIX 222178 2011-05-22 14:03:46Z uqs $ This version of ed(1) is not strictly POSIX compliant, as described in the POSIX 1003.2 document. The following is a summary of the omissions, @@ -76,7 +75,7 @@ DEVIATIONS 2) Since the behavior of `u' (undo) within a `g' (global) command list is not specified by POSIX, it follows the behavior of the SunOS ed: undo forces a global command list to be executed only once, rather than - for each line matching a global pattern. In addtion, each instance of + for each line matching a global pattern. In addition, each instance of `u' within a global command undoes all previous commands (including undo's) in the command list. This seems the best way, since the alternatives are either too complicated to implement or too confusing @@ -84,7 +83,7 @@ DEVIATIONS The global/undo combination is useful for masking errors that would otherwise cause a script to fail. For instance, an ed script - to remove any occurences of either `censor1' or `censor2' might be + to remove any occurrences of either `censor1' or `censor2' might be written as: ed - file < @@ -36,10 +35,10 @@ #include "ed.h" -FILE *sfp; /* scratch file pointer */ -off_t sfseek; /* scratch file position */ -int seek_write; /* seek before writing */ -line_t buffer_head; /* incore buffer */ +static FILE *sfp; /* scratch file pointer */ +static off_t sfseek; /* scratch file position */ +static int seek_write; /* seek before writing */ +static line_t buffer_head; /* incore buffer */ /* get_sbuf_line: get a line of text from the scratch file; return pointer to the text */ @@ -95,6 +94,7 @@ put_sbuf_line(const char *cs) ; if (s - cs >= LINECHARS) { errmsg = "line too long"; + free(lp); return NULL; } len = s - cs; @@ -103,6 +103,7 @@ put_sbuf_line(const char *cs) if (fseeko(sfp, (off_t)0, SEEK_END) < 0) { fprintf(stderr, "%s\n", strerror(errno)); errmsg = "cannot seek temp file"; + free(lp); return NULL; } sfseek = ftello(sfp); @@ -113,6 +114,7 @@ put_sbuf_line(const char *cs) sfseek = -1; fprintf(stderr, "%s\n", strerror(errno)); errmsg = "cannot write temp file"; + free(lp); return NULL; } lp->len = len; @@ -183,10 +185,7 @@ get_addressed_line_node(long n) return lp; } - -extern int newline_added; - -char sfn[15] = ""; /* scratch file name */ +static char sfn[15] = ""; /* scratch file name */ /* open_sbuf: open scratch file */ int @@ -242,7 +241,7 @@ quit(int n) } -unsigned char ctab[256]; /* character translation table */ +static unsigned char ctab[256]; /* character translation table */ /* init_buffers: open scratch buffer; initialize line queue */ void diff --git a/bin/ed/cbc.c b/bin/ed/cbc.c index ad83713573..cebf225245 100644 --- a/bin/ed/cbc.c +++ b/bin/ed/cbc.c @@ -33,8 +33,7 @@ * from: @(#)bdes.c 5.5 (Berkeley) 6/27/91 * * @(#)cbc.c,v 1.2 1994/02/01 00:34:36 alm Exp - * $FreeBSD: src/bin/ed/cbc.c,v 1.20 2004/04/06 20:06:47 markm Exp $ - * $DragonFly: src/bin/ed/cbc.c,v 1.10 2007/04/06 23:36:54 pavalos Exp $ + * $FreeBSD: head/bin/ed/cbc.c 248656 2013-03-23 19:04:57Z jmg $ */ #include @@ -57,9 +56,10 @@ #define MEMZERO(dest,len) memset((dest), 0, (len)) /* Hide the calls to the primitive encryption routines. */ -#define DES_XFORM(buf) \ - DES_ecb_encrypt(buf, buf, &schedule, \ +#define DES_XFORM(buf) \ + DES_ecb_encrypt(buf, buf, &schedule, \ inverse ? DES_DECRYPT : DES_ENCRYPT); + /* * read/write - no error checking */ @@ -70,29 +70,22 @@ * global variables and related macros */ -enum { /* encrypt, decrypt, authenticate */ - MODE_ENCRYPT, MODE_DECRYPT, MODE_AUTHENTICATE -} mode = MODE_ENCRYPT; - #ifdef DES -DES_cblock ivec; /* initialization vector */ -DES_cblock pvec; /* padding vector */ -#endif +static DES_cblock ivec; /* initialization vector */ +static DES_cblock pvec; /* padding vector */ -char bits[] = { /* used to extract bits from a char */ +static char bits[] = { /* used to extract bits from a char */ '\200', '\100', '\040', '\020', '\010', '\004', '\002', '\001' }; -int pflag; /* 1 to preserve parity bits */ +static int pflag; /* 1 to preserve parity bits */ -#ifdef DES -DES_key_schedule schedule; /* expanded DES key */ -#endif - -char des_buf[8]; /* shared buffer for get_des_char/put_des_char */ -int des_ct = 0; /* count for get_des_char/put_des_char */ -int des_n = 0; /* index for put_des_char/get_des_char */ +static DES_key_schedule schedule; /* expanded DES key */ +static unsigned char des_buf[8];/* shared buffer for get_des_char/put_des_char */ +static int des_ct = 0; /* count for get_des_char/put_des_char */ +static int des_n = 0; /* index for put_des_char/get_des_char */ +#endif /* init_des_cipher: initialize DES */ void @@ -122,7 +115,7 @@ get_des_char(FILE *fp) des_n = 0; des_ct = cbc_decode(des_buf, fp); } - return (des_ct > 0) ? (unsigned char)des_buf[des_n++] : EOF; + return (des_ct > 0) ? des_buf[des_n++] : EOF; #else return (getc(fp)); #endif @@ -138,7 +131,7 @@ put_des_char(int c, FILE *fp) des_ct = cbc_encode(des_buf, des_n, fp); des_n = 0; } - return (des_ct >= 0) ? (des_buf[des_n++] = (char)c) : EOF; + return (des_ct >= 0) ? (des_buf[des_n++] = c) : EOF; #else return (fputc(c, fp)); #endif @@ -167,8 +160,8 @@ flush_des_file(FILE *fp) int get_keyword(void) { - char *p; /* used to obtain the key */ - DES_cblock msgbuf; /* I/O buffer */ + char *p; /* used to obtain the key */ + DES_cblock msgbuf; /* I/O buffer */ /* * get the key @@ -230,24 +223,24 @@ hex_to_binary(int c, int radix) /* * convert the key to a bit pattern * obuf bit pattern - * inbuf the key itself + * kbuf the key itself */ void -expand_des_key(char *obuf, char *inbuf) +expand_des_key(char *obuf, char *kbuf) { - int i, j; /* counter in a for loop */ + int i, j; /* counter in a for loop */ int nbuf[64]; /* used for hex/key translation */ /* * leading '0x' or '0X' == hex key */ - if (inbuf[0] == '0' && (inbuf[1] == 'x' || inbuf[1] == 'X')) { - inbuf = &inbuf[2]; + if (kbuf[0] == '0' && (kbuf[1] == 'x' || kbuf[1] == 'X')) { + kbuf = &kbuf[2]; /* * now translate it, bombing on any illegal hex digit */ - for (i = 0; inbuf[i] && i < 16; i++) - if ((nbuf[i] = hex_to_binary((int) inbuf[i], 16)) == -1) + for (i = 0; kbuf[i] && i < 16; i++) + if ((nbuf[i] = hex_to_binary((int) kbuf[i], 16)) == -1) des_error("bad hex digit in key"); while (i < 16) nbuf[i++] = 0; @@ -261,13 +254,13 @@ expand_des_key(char *obuf, char *inbuf) /* * leading '0b' or '0B' == binary key */ - if (inbuf[0] == '0' && (inbuf[1] == 'b' || inbuf[1] == 'B')) { - inbuf = &inbuf[2]; + if (kbuf[0] == '0' && (kbuf[1] == 'b' || kbuf[1] == 'B')) { + kbuf = &kbuf[2]; /* * now translate it, bombing on any illegal binary digit */ - for (i = 0; inbuf[i] && i < 16; i++) - if ((nbuf[i] = hex_to_binary((int) inbuf[i], 2)) == -1) + for (i = 0; kbuf[i] && i < 16; i++) + if ((nbuf[i] = hex_to_binary((int) kbuf[i], 2)) == -1) des_error("bad binary digit in key"); while (i < 64) nbuf[i++] = 0; @@ -281,7 +274,7 @@ expand_des_key(char *obuf, char *inbuf) /* * no special leader -- ASCII */ - strncpy(obuf, inbuf, 8); + strncpy(obuf, kbuf, 8); } /***************** @@ -299,10 +292,10 @@ expand_des_key(char *obuf, char *inbuf) * DES ignores the low order bit of each character. */ void -set_des_key(DES_cblock *buf) /* key block */ +set_des_key(DES_cblock *buf) /* key block */ { - int i, j; /* counter in a for loop */ - int par; /* parity counter */ + int i, j; /* counter in a for loop */ + int par; /* parity counter */ /* * if the parity is not preserved, flip it @@ -329,7 +322,7 @@ set_des_key(DES_cblock *buf) /* key block */ * This encrypts using the Cipher Block Chaining mode of DES */ int -cbc_encode(char *msgbuf, int n, FILE *fp) +cbc_encode(unsigned char *msgbuf, int n, FILE *fp) { int inverse = 0; /* 0 to encrypt, 1 to decrypt */ @@ -367,22 +360,22 @@ cbc_encode(char *msgbuf, int n, FILE *fp) * fp input file descriptor */ int -cbc_decode(char *msgbuf, FILE *fp) +cbc_decode(unsigned char *msgbuf, FILE *fp) { - DES_cblock inbuf; /* temp buffer for initialization vector */ - int n; /* number of bytes actually read */ - int c; /* used to test for EOF */ + DES_cblock tbuf; /* temp buffer for initialization vector */ + int n; /* number of bytes actually read */ + int c; /* used to test for EOF */ int inverse = 1; /* 0 to encrypt, 1 to decrypt */ if ((n = READ(msgbuf, 8, fp)) == 8) { /* * do the transformation */ - MEMCPY(inbuf, msgbuf, 8); + MEMCPY(tbuf, msgbuf, 8); DES_XFORM((DES_cblock *)msgbuf); for (c = 0; c < 8; c++) msgbuf[c] ^= ivec[c]; - MEMCPY(ivec, inbuf, 8); + MEMCPY(ivec, tbuf, 8); /* * if the last one, handle it specially */ diff --git a/bin/ed/ed.1 b/bin/ed/ed.1 index 6894c768e3..482081fc8c 100644 --- a/bin/ed/ed.1 +++ b/bin/ed/ed.1 @@ -1,5 +1,4 @@ -.\" $FreeBSD: src/bin/ed/ed.1,v 1.35 2005/01/16 16:41:56 ru Exp $ -.\" $DragonFly: src/bin/ed/ed.1,v 1.6 2007/10/20 17:56:46 swildner Exp $ +.\" $FreeBSD: head/bin/ed/ed.1 250582 2013-05-12 22:22:12Z joel $ .Dd July 3, 2004 .Dt ED 1 .Os @@ -232,7 +231,7 @@ The current line (address) in the buffer. The last line in the buffer. .It n The -.Em n Ns th, +.Em n Ns th line in the buffer where .Em n @@ -651,7 +650,7 @@ The mark is not cleared until the line is deleted or otherwise modified. .It (.,.)l Print the addressed lines unambiguously. -If a single line fills for than one screen (as might be the case +If a single line fills more than one screen (as might be the case when viewing a binary file, for instance), a .Dq Li --More-- prompt is printed on the last line. @@ -915,10 +914,10 @@ Print the addressed line, and sets the current address to that line. .El .Sh FILES -.Bl -tag -width /tmp/ed.* -compact -.It /tmp/ed.* +.Bl -tag -width ".Pa /tmp/ed.*" -compact +.It Pa /tmp/ed.* buffer file -.It ed.hup +.It Pa ed.hup the file to which .Nm attempts to write the buffer if the terminal hangs up diff --git a/bin/ed/ed.h b/bin/ed/ed.h index 78f26977ef..596d2918bb 100644 --- a/bin/ed/ed.h +++ b/bin/ed/ed.h @@ -25,8 +25,7 @@ * SUCH DAMAGE. * * @(#)ed.h,v 1.5 1994/02/01 00:34:39 alm Exp - * $FreeBSD: src/bin/ed/ed.h,v 1.20 2005/01/10 08:39:22 imp Exp $ - * $DragonFly: src/bin/ed/ed.h,v 1.9 2007/04/06 23:36:54 pavalos Exp $ + * $FreeBSD: head/bin/ed/ed.h 241737 2012-10-19 14:49:42Z ed $ */ #include @@ -193,8 +192,8 @@ void add_line_node(line_t *); int append_lines(long); int apply_subst_template(const char *, regmatch_t *, int, int); int build_active_list(int); -int cbc_decode(char *, FILE *); -int cbc_encode(char *, int, FILE *); +int cbc_decode(unsigned char *, FILE *); +int cbc_encode(unsigned char *, int, FILE *); int check_addr_range(long, long); void clear_active_list(void); void clear_undo_stack(void); @@ -248,12 +247,12 @@ int search_and_replace(pattern_t *, int, int); int set_active_node(line_t *); void signal_hup(int); void signal_int(int); -char *strip_escapes(const char *); +char *strip_escapes(char *); 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(const char *, const char *, long, long); +long write_file(char *, const char *, long, long); long write_stream(FILE *, long, long); /* global buffers */ @@ -278,3 +277,9 @@ extern int lineno; extern long second_addr; extern long u_addr_last; extern long u_current_addr; +extern long rows; +extern int cols; +extern int newline_added; +extern int des; +extern int scripted; +extern int patlock; diff --git a/bin/ed/glbl.c b/bin/ed/glbl.c index 1219b09c1d..31b39b951e 100644 --- a/bin/ed/glbl.c +++ b/bin/ed/glbl.c @@ -26,8 +26,7 @@ * SUCH DAMAGE. * * @(#)glob.c,v 1.1 1994/02/01 00:34:40 alm Exp - * $FreeBSD: src/bin/ed/glbl.c,v 1.13 2002/06/30 05:13:53 obrien Exp $ - * $DragonFly: src/bin/ed/glbl.c,v 1.4 2007/04/06 23:36:54 pavalos Exp $ + * $FreeBSD: head/bin/ed/glbl.c 241720 2012-10-19 05:43:38Z ed $ */ #include @@ -137,11 +136,11 @@ exec_global(int interact, int 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) */ +static line_t **active_list; /* list of lines active in a global command */ +static long active_last; /* index of last active line in active_list */ +static long active_size; /* size of active_list */ +static long active_ptr; /* active_list index (non-decreasing) */ +static long active_ndx; /* active_list index (modulo active_last) */ /* set_active_node: add a line node to the global-active list */ int diff --git a/bin/ed/io.c b/bin/ed/io.c index d638d4f988..9cccf8dbaa 100644 --- a/bin/ed/io.c +++ b/bin/ed/io.c @@ -25,15 +25,11 @@ * SUCH DAMAGE. * * @(#)io.c,v 1.1 1994/02/01 00:34:41 alm Exp - * $FreeBSD: src/bin/ed/io.c,v 1.14 2003/01/01 18:48:39 schweikh Exp $ - * $DragonFly: src/bin/ed/io.c,v 1.6 2007/04/06 23:36:54 pavalos Exp $ + * $FreeBSD: head/bin/ed/io.c 241737 2012-10-19 14:49:42Z ed $ */ #include "ed.h" - -extern int scripted; - /* read_file: read a named file/pipe into the buffer; return line count */ long read_file(char *fn, long n) @@ -54,15 +50,13 @@ read_file(char *fn, long n) errmsg = "cannot close input file"; return ERR; } - fprintf(stdout, !scripted ? "%lu\n" : "", size); + if (!scripted) + fprintf(stdout, "%lu\n", size); return current_addr - n; } - -extern int des; - -char *sbuf; /* file i/o buffer */ -int sbufsz; /* file i/o buffer size */ +static char *sbuf; /* file i/o buffer */ +static 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 */ @@ -145,7 +139,7 @@ get_stream_line(FILE *fp) /* write_file: write a range of lines to a named file/pipe; return line count */ long -write_file(const char *fn, const char *mode, long n, long m) +write_file(char *fn, const char *mode, long n, long m) { FILE *fp; long size; @@ -162,7 +156,8 @@ write_file(const char *fn, const char *mode, long n, long m) errmsg = "cannot close output file"; return ERR; } - fprintf(stdout, !scripted ? "%lu\n" : "", size); + if (!scripted) + fprintf(stdout, "%lu\n", size); return n ? m - n + 1 : 0; } @@ -297,9 +292,6 @@ get_tty_line(void) #define ESCAPES "\a\b\f\n\r\t\v\\" #define ESCCHARS "abfnrtv\\" -extern int rows; -extern int cols; - /* put_tty_line: print text to stdout */ int put_tty_line(const char *s, int l, long n, int gflag) diff --git a/bin/ed/main.c b/bin/ed/main.c index 2c2f1ea5ee..669b9c12fe 100644 --- a/bin/ed/main.c +++ b/bin/ed/main.c @@ -27,8 +27,7 @@ * * @(#) Copyright (c) 1993 Andrew Moore, Talke Studio. All rights reserved. * @(#)main.c,v 1.1 1994/02/01 00:34:42 alm Exp - * $FreeBSD: src/bin/ed/main.c,v 1.29 2006/08/17 23:00:33 imp Exp $ - * $DragonFly: src/bin/ed/main.c,v 1.9 2007/04/06 23:36:54 pavalos Exp $ + * $FreeBSD: head/bin/ed/main.c 241720 2012-10-19 05:43:38Z ed $ */ /* @@ -60,52 +59,47 @@ #ifdef _POSIX_SOURCE -sigjmp_buf env; +static sigjmp_buf env; #else -jmp_buf env; +static jmp_buf env; #endif /* static buffers */ char stdinbuf[1]; /* stdin buffer */ -char *shcmd; /* shell command buffer */ -int shcmdsz; /* shell command buffer size */ -int shcmdi; /* shell command buffer index */ +static char *shcmd; /* shell command buffer */ +static int shcmdsz; /* shell command buffer size */ +static int shcmdi; /* shell command buffer index */ char *ibuf; /* ed command-line buffer */ int ibufsz; /* ed command-line buffer size */ char *ibufp; /* pointer to ed command-line buffer */ /* global flags */ int des = 0; /* if set, use crypt(3) for i/o */ -int garrulous = 0; /* if set, print all error messages */ +static int garrulous = 0; /* if set, print all error messages */ int isbinary; /* if set, buffer contains ASCII NULs */ int isglobal; /* if set, doing a global command */ int modified; /* if set, buffer modified since last write */ int mutex = 0; /* if set, signals set "sigflags" */ -int red = 0; /* if set, restrict shell/directory access */ +static int red = 0; /* if set, restrict shell/directory access */ int scripted = 0; /* if set, suppress diagnostics */ int sigflags = 0; /* if set, signals received while mutex set */ -int sigactive = 0; /* if set, signal handlers are enabled */ +static int sigactive = 0; /* if set, signal handlers are enabled */ -char old_filename[PATH_MAX] = ""; /* default filename */ +static char old_filename[PATH_MAX] = ""; /* default filename */ long current_addr; /* current address in editor buffer */ long addr_last; /* last address in editor buffer */ int lineno; /* script line number */ -const char *prompt; /* command-line prompt */ -const char *dps = "*"; /* default command-line prompt */ +static const char *prompt; /* command-line prompt */ +static const char *dps = "*"; /* default command-line prompt */ -const char usage[] = "usage: %s [-] [-sx] [-p string] [file]\n"; +static const char *usage = "usage: %s [-] [-sx] [-p string] [file]\n"; /* ed: line editor */ int -main(int argc, char *argv[]) +main(volatile int argc, char ** volatile argv) { int c, n; long status = 0; -#if __GNUC__ - /* Avoid longjmp clobbering */ - (void) &argc; - (void) &argv; -#endif setlocale(LC_ALL, ""); @@ -191,9 +185,10 @@ top: fputs("?\n", stderr); errmsg = "warning: file modified"; if (!isatty(0)) { - fprintf(stderr, garrulous ? - "script, line %d: %s\n" : - "", lineno, errmsg); + if (garrulous) + fprintf(stderr, + "script, line %d: %s\n", + lineno, errmsg); quit(2); } clearerr(stdin); @@ -224,27 +219,26 @@ top: fputs("?\n", stderr); /* give warning */ errmsg = "warning: file modified"; if (!isatty(0)) { - fprintf(stderr, garrulous ? - "script, line %d: %s\n" : - "", lineno, errmsg); + if (garrulous) + fprintf(stderr, "script, line %d: %s\n", + lineno, errmsg); quit(2); } break; case FATAL: - if (!isatty(0)) - fprintf(stderr, garrulous ? - "script, line %d: %s\n" : "", - lineno, errmsg); - else - fprintf(stderr, garrulous ? "%s\n" : "", - errmsg); + if (!isatty(0)) { + if (garrulous) + fprintf(stderr, "script, line %d: %s\n", + lineno, errmsg); + } else if (garrulous) + fprintf(stderr, "%s\n", errmsg); quit(3); default: fputs("?\n", stderr); if (!isatty(0)) { - fprintf(stderr, garrulous ? - "script, line %d: %s\n" : "", - lineno, errmsg); + if (garrulous) + fprintf(stderr, "script, line %d: %s\n", + lineno, errmsg); quit(2); } break; @@ -253,7 +247,8 @@ top: /*NOTREACHED*/ } -long first_addr, second_addr, addr_cnt; +long first_addr, second_addr; +static long addr_cnt; /* extract_addr_range: get line addresses from the command buffer until an illegal address is seen; return status */ @@ -1240,8 +1235,8 @@ display_lines(long from, long to, int gflag) #define MAXMARK 26 /* max number of marks */ -line_t *mark[MAXMARK]; /* line markers */ -int markno; /* line marker count */ +static line_t *mark[MAXMARK]; /* line markers */ +static int markno; /* line marker count */ /* mark_line_node: set a line node mark */ int @@ -1311,7 +1306,7 @@ has_trailing_escape(char *s, char *t) /* strip_escapes: return copy of escaped string of at most length PATH_MAX */ char * -strip_escapes(const char *s) +strip_escapes(char *s) { static char *file = NULL; static int filesz = 0; diff --git a/bin/ed/re.c b/bin/ed/re.c index 7205bacdc1..f80943bce3 100644 --- a/bin/ed/re.c +++ b/bin/ed/re.c @@ -26,15 +26,11 @@ * SUCH DAMAGE. * * @(#)re.c,v 1.6 1994/02/01 00:34:43 alm Exp - * $FreeBSD: src/bin/ed/re.c,v 1.20 2003/07/20 10:24:09 ru Exp $ - * $DragonFly: src/bin/ed/re.c,v 1.4 2007/04/06 23:36:54 pavalos Exp $ + * $FreeBSD: head/bin/ed/re.c 252374 2013-06-29 15:49:26Z kientzle $ */ #include "ed.h" - -extern int patlock; - const char *errmsg = ""; /* get_compiled_pattern: return pointer to compiled pattern from command @@ -93,7 +89,7 @@ extract_pattern(int delimiter) default: break; case '[': - if ((nd = parse_char_class(++nd)) == NULL) { + if ((nd = parse_char_class(nd + 1)) == NULL) { errmsg = "unbalanced brackets ([])"; return NULL; } diff --git a/bin/ed/sub.c b/bin/ed/sub.c index 26a725ad28..cda3e3d4e7 100644 --- a/bin/ed/sub.c +++ b/bin/ed/sub.c @@ -26,16 +26,15 @@ * SUCH DAMAGE. * * @(#)sub.c,v 1.1 1994/02/01 00:34:44 alm Exp - * $FreeBSD: src/bin/ed/sub.c,v 1.15 2002/06/30 05:13:53 obrien Exp $ - * $DragonFly: src/bin/ed/sub.c,v 1.4 2007/04/06 23:36:54 pavalos Exp $ + * $FreeBSD: head/bin/ed/sub.c 241720 2012-10-19 05:43:38Z ed $ */ #include "ed.h" -char *rhbuf; /* rhs substitution buffer */ -int rhbufsz; /* rhs substitution buffer size */ -int rhbufi; /* rhs substitution buffer index */ +static char *rhbuf; /* rhs substitution buffer */ +static int rhbufsz; /* rhs substitution buffer size */ +static int rhbufi; /* rhs substitution buffer index */ /* extract_subst_tail: extract substitution tail from the command buffer */ int @@ -106,8 +105,8 @@ extract_subst_template(void) } -char *rbuf; /* substitute_matching_text buffer */ -int rbufsz; /* substitute_matching_text buffer size */ +static char *rbuf; /* substitute_matching_text buffer */ +static int rbufsz; /* substitute_matching_text buffer size */ /* search_and_replace: for each line in a range, change text matching a pattern according to a substitution template; return status */ diff --git a/bin/ed/test/Makefile b/bin/ed/test/Makefile index 2b08fbdb69..e695f37eda 100644 --- a/bin/ed/test/Makefile +++ b/bin/ed/test/Makefile @@ -1,5 +1,4 @@ -# $FreeBSD: src/bin/ed/test/Makefile,v 1.9 1999/08/27 23:14:17 peter Exp $ -# $DragonFly: src/bin/ed/test/Makefile,v 1.2 2003/06/17 04:22:50 dillon Exp $ +# $FreeBSD: head/bin/ed/test/Makefile 50471 1999-08-27 23:15:48Z peter $ SHELL= /bin/sh ED= ${.OBJDIR}/ed diff --git a/bin/ed/test/README b/bin/ed/test/README index c96f282113..6c427824f1 100644 --- a/bin/ed/test/README +++ b/bin/ed/test/README @@ -1,5 +1,4 @@ -# $FreeBSD: src/bin/ed/test/README,v 1.7 1999/08/27 23:14:17 peter Exp $ -# $DragonFly: src/bin/ed/test/README,v 1.2 2003/06/17 04:22:50 dillon Exp $ +# $FreeBSD: head/bin/ed/test/README 50471 1999-08-27 23:15:48Z peter $ The files in this directory with suffixes `.t', `.d', `.r' and `.err' are used for testing ed. To run the tests, set the ED variable in the Makefile diff --git a/bin/ed/test/ckscripts.sh b/bin/ed/test/ckscripts.sh index 80d2038620..92bba6b9a1 100644 --- a/bin/ed/test/ckscripts.sh +++ b/bin/ed/test/ckscripts.sh @@ -3,8 +3,7 @@ # and compares their output against the .r files, which contain # the correct output # -# $FreeBSD: src/bin/ed/test/ckscripts.sh,v 1.6 1999/08/27 23:14:18 peter Exp $ -# $DragonFly: src/bin/ed/test/ckscripts.sh,v 1.2 2003/06/17 04:22:50 dillon Exp $ +# $FreeBSD: head/bin/ed/test/ckscripts.sh 50471 1999-08-27 23:15:48Z peter $ PATH="/bin:/usr/bin:/usr/local/bin/:." ED=$1 diff --git a/bin/ed/test/mkscripts.sh b/bin/ed/test/mkscripts.sh index 74e9839546..abbfd25569 100644 --- a/bin/ed/test/mkscripts.sh +++ b/bin/ed/test/mkscripts.sh @@ -1,8 +1,7 @@ #!/bin/sh - # This script generates ed test scripts (.ed) from .t files # -# $FreeBSD: src/bin/ed/test/mkscripts.sh,v 1.6 1999/08/27 23:14:20 peter Exp $ -# $DragonFly: src/bin/ed/test/mkscripts.sh,v 1.2 2003/06/17 04:22:50 dillon Exp $ +# $FreeBSD: head/bin/ed/test/mkscripts.sh 50471 1999-08-27 23:15:48Z peter $ PATH="/bin:/usr/bin:/usr/local/bin/:." ED=$1 diff --git a/bin/ed/undo.c b/bin/ed/undo.c index 08475b366e..60c437819d 100644 --- a/bin/ed/undo.c +++ b/bin/ed/undo.c @@ -25,17 +25,16 @@ * SUCH DAMAGE. * * @(#)undo.c,v 1.1 1994/02/01 00:34:44 alm Exp - * $FreeBSD: src/bin/ed/undo.c,v 1.12 2002/06/30 05:13:53 obrien Exp $ - * $DragonFly: src/bin/ed/undo.c,v 1.4 2007/04/06 23:36:54 pavalos Exp $ + * $FreeBSD: head/bin/ed/undo.c 241720 2012-10-19 05:43:38Z ed $ */ #include "ed.h" #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 */ +static undo_t *ustack = NULL; /* undo stack */ +static long usize = 0; /* stack size variable */ +static long u_p = 0; /* undo stack pointer */ /* push_undo_stack: return pointer to initialized undo node */ undo_t *