-/* $OpenBSD: buf.c,v 1.21 2015/07/28 17:46:52 deraadt Exp $ */
+/* $OpenBSD: buf.c,v 1.22 2015/10/09 19:47:02 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 routines for the
#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 */
extern int newline_added;
#define SCRATCH_TEMPLATE "/tmp/ed.XXXXXXXXXX"
-char sfn[sizeof(SCRATCH_TEMPLATE)+1] = ""; /* scratch file name */
+static char sfn[sizeof(SCRATCH_TEMPLATE)+1] = ""; /* scratch file name */
/* open_sbuf: open scratch file */
int
}
-unsigned char ctab[256]; /* character translation table */
+static unsigned char ctab[256]; /* character translation table */
/* init_buffers: open scratch buffer; initialize line queue */
void
!cat
hello, world
EOF */
- setbuffer(stdin, stdinbuf, 1);
+ setvbuf(stdin, NULL, _IONBF, 0);
if (open_sbuf() < 0)
quit(2);
REQUE(&buffer_head, &buffer_head);
-/* $OpenBSD: ed.h,v 1.18 2015/10/04 15:23:24 millert Exp $ */
+/* $OpenBSD: ed.h,v 1.19 2015/10/09 19:47:02 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. */
int write_stream(FILE *, int, int);
/* global buffers */
-extern char stdinbuf[];
extern char *ibuf;
extern char *ibufp;
extern int ibufsz;
-/* $OpenBSD: glbl.c,v 1.15 2015/10/04 15:23:24 millert Exp $ */
+/* $OpenBSD: glbl.c,v 1.16 2015/10/09 19:47:02 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
}
-line_t **active_list; /* list of lines active in a global command */
-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) */
+static line_t **active_list; /* list of lines active in a global command */
+static int active_last; /* index of last active line in active_list */
+static int active_size; /* size of active_list */
+static int active_ptr; /* active_list index (non-decreasing) */
+static int active_ndx; /* active_list index (modulo active_last) */
/* set_active_node: add a line node to the global-active list */
int
-/* $OpenBSD: io.c,v 1.16 2014/04/14 22:12:01 tedu Exp $ */
+/* $OpenBSD: io.c,v 1.17 2015/10/09 19:47:02 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 */
}
-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 */
-/* $OpenBSD: main.c,v 1.50 2015/10/09 01:37:06 deraadt Exp $ */
+/* $OpenBSD: main.c,v 1.51 2015/10/09 19:47:02 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
sigjmp_buf env;
/* 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 */
+static char old_filename[PATH_MAX]; /* default filename */
+
+/* global buffers */
char *ibuf; /* ed command-line buffer */
int ibufsz; /* ed command-line buffer size */
char *ibufp; /* pointer to ed command-line buffer */
/* if set, signal handlers are enabled */
volatile sig_atomic_t sigactive = 0;
-char old_filename[PATH_MAX] = ""; /* default filename */
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 */
+static char *prompt; /* command-line prompt */
+static char *dps = "*"; /* default command-line prompt */
-const char usage[] = "usage: %s [-] [-s] [-p string] [file]\n";
+static const char usage[] = "usage: %s [-] [-s] [-p string] [file]\n";
-char *home; /* home directory */
+static char *home; /* home directory */
void
seterrmsg(char *s)
#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
-/* $OpenBSD: sub.c,v 1.12 2015/10/04 15:23:24 millert Exp $ */
+/* $OpenBSD: sub.c,v 1.13 2015/10/09 19:47:02 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
#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
}
-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 */
-/* $OpenBSD: undo.c,v 1.12 2014/05/18 16:36:42 espie Exp $ */
+/* $OpenBSD: undo.c,v 1.13 2015/10/09 19:47:02 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 */
#define USIZE 100 /* undo stack size */
-undo_t *ustack = NULL; /* undo stack */
-int usize = 0; /* stack size variable */
-int u_p = 0; /* undo stack pointer */
+static undo_t *ustack = NULL; /* undo stack */
+static int usize = 0; /* stack size variable */
+static int u_p = 0; /* undo stack pointer */
/* push_undo_stack: return pointer to initialized undo node */
undo_t *