[Midnightbsd-cvs] src [11344] trunk/bin/ed: sync with freebsd
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Thu Jul 5 15:08:22 EDT 2018
Revision: 11344
http://svnweb.midnightbsd.org/src/?rev=11344
Author: laffer1
Date: 2018-07-05 15:08:21 -0400 (Thu, 05 Jul 2018)
Log Message:
-----------
sync with freebsd
Modified Paths:
--------------
trunk/bin/ed/Makefile
trunk/bin/ed/buf.c
trunk/bin/ed/cbc.c
trunk/bin/ed/glbl.c
trunk/bin/ed/io.c
trunk/bin/ed/main.c
trunk/bin/ed/re.c
trunk/bin/ed/sub.c
trunk/bin/ed/undo.c
Modified: trunk/bin/ed/Makefile
===================================================================
--- trunk/bin/ed/Makefile 2018-07-05 19:06:56 UTC (rev 11343)
+++ trunk/bin/ed/Makefile 2018-07-05 19:08:21 UTC (rev 11344)
@@ -1,4 +1,5 @@
# $MidnightBSD$
+# $FreeBSD: stable/10/bin/ed/Makefile 235654 2012-05-19 17:55:49Z marcel $
.include <bsd.own.mk>
@@ -7,12 +8,12 @@
LINKS= ${BINDIR}/ed ${BINDIR}/red
MLINKS= ed.1 red.1
-.if !defined(RELEASE_CRUNCH)
-.if ${MK_OPENSSL} != "no"
+.if !defined(RELEASE_CRUNCH) && \
+ ${MK_OPENSSL} != "no" && \
+ ${MK_ED_CRYPTO} != "no"
CFLAGS+=-DDES
DPADD= ${LIBCRYPTO}
LDADD= -lcrypto
.endif
-.endif
.include <bsd.prog.mk>
Modified: trunk/bin/ed/buf.c
===================================================================
--- trunk/bin/ed/buf.c 2018-07-05 19:06:56 UTC (rev 11343)
+++ trunk/bin/ed/buf.c 2018-07-05 19:08:21 UTC (rev 11344)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* buf.c: This file contains the scratch-file buffer routines for the
ed line editor. */
/*-
@@ -25,9 +26,9 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-/* $FreeBSD: src/bin/ed/buf.c,v 1.22 2002/06/30 05:13:53 obrien Exp $ */
+
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD: src/bin/ed/buf.c,v 1.2 2006/07/07 15:55:59 laffer1 Exp $");
+__FBSDID("$FreeBSD: stable/10/bin/ed/buf.c 241737 2012-10-19 14:49:42Z ed $");
#include <sys/file.h>
#include <sys/stat.h>
@@ -35,10 +36,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 */
@@ -185,11 +186,8 @@
return lp;
}
+static char sfn[15] = ""; /* scratch file name */
-extern int newline_added;
-
-char sfn[15] = ""; /* scratch file name */
-
/* open_sbuf: open scratch file */
int
open_sbuf(void)
@@ -244,7 +242,7 @@
}
-unsigned char ctab[256]; /* character translation table */
+static unsigned char ctab[256]; /* character translation table */
/* init_buffers: open scratch buffer; initialize line queue */
void
Modified: trunk/bin/ed/cbc.c
===================================================================
--- trunk/bin/ed/cbc.c 2018-07-05 19:06:56 UTC (rev 11343)
+++ trunk/bin/ed/cbc.c 2018-07-05 19:08:21 UTC (rev 11344)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* cbc.c: This file contains the encryption routines for the ed line editor */
/*-
* Copyright (c) 1993 The Regents of the University of California.
@@ -30,10 +31,9 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-/* $FreeBSD: src/bin/ed/cbc.c,v 1.20 2004/04/06 20:06:47 markm Exp $ */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD");
+__FBSDID("$FreeBSD: stable/10/bin/ed/cbc.c 301233 2016-06-03 03:20:54Z pfg $");
#include <sys/types.h>
#include <errno.h>
@@ -69,36 +69,28 @@
* 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 */
+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
-unsigned 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 */
-
/* init_des_cipher: initialize DES */
void
init_des_cipher(void)
{
#ifdef DES
- int i;
-
des_ct = des_n = 0;
/* initialize the initialization vector */
@@ -105,8 +97,7 @@
MEMZERO(ivec, 8);
/* initialize the padding vector */
- for (i = 0; i < 8; i++)
- pvec[i] = (char) (arc4random() % 256);
+ arc4random_buf(pvec, sizeof(pvec));
#endif
}
@@ -171,7 +162,7 @@
/*
* get the key
*/
- if (*(p = getpass("Enter key: "))) {
+ if ((p = getpass("Enter key: ")) != NULL && *p != '\0') {
/*
* copy it, nul-padded, into the key area
@@ -244,7 +235,7 @@
/*
* now translate it, bombing on any illegal hex digit
*/
- for (i = 0; kbuf[i] && i < 16; i++)
+ for (i = 0; i < 16 && kbuf[i]; i++)
if ((nbuf[i] = hex_to_binary((int) kbuf[i], 16)) == -1)
des_error("bad hex digit in key");
while (i < 16)
@@ -264,7 +255,7 @@
/*
* now translate it, bombing on any illegal binary digit
*/
- for (i = 0; kbuf[i] && i < 16; i++)
+ for (i = 0; i < 16 && kbuf[i]; i++)
if ((nbuf[i] = hex_to_binary((int) kbuf[i], 2)) == -1)
des_error("bad binary digit in key");
while (i < 64)
Modified: trunk/bin/ed/glbl.c
===================================================================
--- trunk/bin/ed/glbl.c 2018-07-05 19:06:56 UTC (rev 11343)
+++ trunk/bin/ed/glbl.c 2018-07-05 19:08:21 UTC (rev 11344)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* glob.c: This file contains the global command routines for the ed line
editor */
/*-
@@ -25,9 +26,9 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-/* $FreeBSD: src/bin/ed/glbl.c,v 1.13 2002/06/30 05:13:53 obrien Exp $ */
+
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/bin/ed/glbl.c 241720 2012-10-19 05:43:38Z ed $");
#include <sys/types.h>
#include <sys/ioctl.h>
@@ -135,11 +136,11 @@
}
-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
Modified: trunk/bin/ed/io.c
===================================================================
--- trunk/bin/ed/io.c 2018-07-05 19:06:56 UTC (rev 11343)
+++ trunk/bin/ed/io.c 2018-07-05 19:08:21 UTC (rev 11344)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* io.c: This file contains the i/o routines for the ed line editor */
/*-
* Copyright (c) 1993 Andrew Moore, Talke Studio.
@@ -24,15 +25,12 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-/* $FreeBSD: src/bin/ed/io.c,v 1.14 2003/01/01 18:48:39 schweikh Exp $ */
+
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD: src/bin/ed/io.c,v 1.2 2006/07/19 13:39:36 laffer1 Exp $");
+__FBSDID("$FreeBSD: stable/10/bin/ed/io.c 301155 2016-06-01 17:47:34Z truckman $");
#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)
@@ -39,30 +37,31 @@
{
FILE *fp;
long size;
+ int cs;
-
fp = (*fn == '!') ? popen(fn + 1, "r") : fopen(strip_escapes(fn), "r");
if (fp == NULL) {
fprintf(stderr, "%s: %s\n", fn, strerror(errno));
errmsg = "cannot open input file";
return ERR;
- } else if ((size = read_stream(fp, n)) < 0)
- return ERR;
- else if (((*fn == '!') ? pclose(fp) : fclose(fp)) < 0) {
+ }
+ if ((size = read_stream(fp, n)) < 0) {
fprintf(stderr, "%s: %s\n", fn, strerror(errno));
+ errmsg = "error reading input file";
+ }
+ if ((cs = (*fn == '!') ? pclose(fp) : fclose(fp)) < 0) {
+ fprintf(stderr, "%s: %s\n", fn, strerror(errno));
errmsg = "cannot close input file";
+ }
+ if (size < 0 || cs < 0)
return ERR;
- }
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 */
@@ -149,6 +148,7 @@
{
FILE *fp;
long size;
+ int cs;
fp = (*fn == '!') ? popen(fn+1, "w") : fopen(strip_escapes(fn), mode);
if (fp == NULL) {
@@ -155,13 +155,17 @@
fprintf(stderr, "%s: %s\n", fn, strerror(errno));
errmsg = "cannot open output file";
return ERR;
- } else if ((size = write_stream(fp, n, m)) < 0)
- return ERR;
- else if (((*fn == '!') ? pclose(fp) : fclose(fp)) < 0) {
+ }
+ if ((size = write_stream(fp, n, m)) < 0) {
fprintf(stderr, "%s: %s\n", fn, strerror(errno));
+ errmsg = "error writing output file";
+ }
+ if ((cs = (*fn == '!') ? pclose(fp) : fclose(fp)) < 0) {
+ fprintf(stderr, "%s: %s\n", fn, strerror(errno));
errmsg = "cannot close output file";
+ }
+ if (size < 0 || cs < 0)
return ERR;
- }
if (!scripted)
fprintf(stdout, "%lu\n", size);
return n ? m - n + 1 : 0;
@@ -298,9 +302,6 @@
#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)
Modified: trunk/bin/ed/main.c
===================================================================
--- trunk/bin/ed/main.c 2018-07-05 19:06:56 UTC (rev 11343)
+++ trunk/bin/ed/main.c 2018-07-05 19:08:21 UTC (rev 11344)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* main.c: This file contains the main control and user-interface routines
for the ed line editor. */
/*-
@@ -25,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-/*$FreeBSD: src/bin/ed/main.c,v 1.28 2005/02/09 17:37:37 ru Exp $ */
+
#ifndef lint
#if 0
static const char copyright[] =
@@ -35,7 +36,7 @@
#endif /* not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD: src/bin/ed/main.c,v 1.3 2008/06/30 03:04:11 laffer1 Exp $");
+__FBSDID("$FreeBSD: stable/10/bin/ed/main.c 292754 2015-12-26 18:37:01Z pfg $");
/*
* CREDITS
@@ -66,16 +67,16 @@
#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 */
@@ -82,24 +83,24 @@
/* 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
@@ -254,7 +255,8 @@
/*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 */
@@ -504,7 +506,8 @@
return ERR;
else if (open_sbuf() < 0)
return FATAL;
- if (*fnp && *fnp != '!') strcpy(old_filename, fnp);
+ if (*fnp && *fnp != '!')
+ strlcpy(old_filename, fnp, PATH_MAX);
#ifdef BACKWARDS
if (*fnp == '\0' && *old_filename == '\0') {
errmsg = "no current filename";
@@ -531,7 +534,8 @@
return ERR;
}
GET_COMMAND_SUFFIX();
- if (*fnp) strcpy(old_filename, fnp);
+ if (*fnp)
+ strlcpy(old_filename, fnp, PATH_MAX);
printf("%s\n", strip_escapes(old_filename));
break;
case 'g':
@@ -662,7 +666,7 @@
GET_COMMAND_SUFFIX();
if (!isglobal) clear_undo_stack();
if (*old_filename == '\0' && *fnp != '!')
- strcpy(old_filename, fnp);
+ strlcpy(old_filename, fnp, PATH_MAX);
#ifdef BACKWARDS
if (*fnp == '\0' && *old_filename == '\0') {
errmsg = "no current filename";
@@ -796,7 +800,7 @@
return ERR;
GET_COMMAND_SUFFIX();
if (*old_filename == '\0' && *fnp != '!')
- strcpy(old_filename, fnp);
+ strlcpy(old_filename, fnp, PATH_MAX);
#ifdef BACKWARDS
if (*fnp == '\0' && *old_filename == '\0') {
errmsg = "no current filename";
@@ -1241,8 +1245,8 @@
#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
Modified: trunk/bin/ed/re.c
===================================================================
--- trunk/bin/ed/re.c 2018-07-05 19:06:56 UTC (rev 11343)
+++ trunk/bin/ed/re.c 2018-07-05 19:08:21 UTC (rev 11344)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* re.c: This file contains the regular expression interface routines for
the ed line editor. */
/*-
@@ -25,15 +26,12 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-/* $FreeBSD: src/bin/ed/re.c,v 1.20 2003/07/20 10:24:09 ru Exp $ */
+
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/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
@@ -92,7 +90,7 @@
default:
break;
case '[':
- if ((nd = parse_char_class(++nd)) == NULL) {
+ if ((nd = parse_char_class(nd + 1)) == NULL) {
errmsg = "unbalanced brackets ([])";
return NULL;
}
Modified: trunk/bin/ed/sub.c
===================================================================
--- trunk/bin/ed/sub.c 2018-07-05 19:06:56 UTC (rev 11343)
+++ trunk/bin/ed/sub.c 2018-07-05 19:08:21 UTC (rev 11344)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* sub.c: This file contains the substitution routines for the ed
line editor */
/*-
@@ -25,17 +26,16 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-/* $FreeBSD: src/bin/ed/sub.c,v 1.15 2002/06/30 05:13:53 obrien Exp $ */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/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 +106,8 @@
}
-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 */
Modified: trunk/bin/ed/undo.c
===================================================================
--- trunk/bin/ed/undo.c 2018-07-05 19:06:56 UTC (rev 11343)
+++ trunk/bin/ed/undo.c 2018-07-05 19:08:21 UTC (rev 11344)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* undo.c: This file contains the undo routines for the ed line editor */
/*-
* Copyright (c) 1993 Andrew Moore, Talke Studio.
@@ -26,15 +27,15 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/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 *
More information about the Midnightbsd-cvs
mailing list