summaryrefslogtreecommitdiff
path: root/bin/ed
diff options
context:
space:
mode:
authorSimon J. Gerraty <sjg@FreeBSD.org>2012-11-04 02:52:03 +0000
committerSimon J. Gerraty <sjg@FreeBSD.org>2012-11-04 02:52:03 +0000
commit23090366f729c56cab62de74c7a51792357e98a9 (patch)
treec511c885796e28ec571b5267e8f11f3b103d35e9 /bin/ed
parent7750ad47a9a7dbc83f87158464170c8640723293 (diff)
parent22ff74b2f44234d31540b1f7fd6c91489c37cad3 (diff)
downloadsrc-test-23090366f729c56cab62de74c7a51792357e98a9.tar.gz
src-test-23090366f729c56cab62de74c7a51792357e98a9.zip
Sync from head
Notes
Notes: svn path=/projects/bmake/; revision=242545
Diffstat (limited to 'bin/ed')
-rw-r--r--bin/ed/buf.c15
-rw-r--r--bin/ed/cbc.c20
-rw-r--r--bin/ed/ed.h6
-rw-r--r--bin/ed/glbl.c10
-rw-r--r--bin/ed/io.c13
-rw-r--r--bin/ed/main.c31
-rw-r--r--bin/ed/re.c3
-rw-r--r--bin/ed/sub.c10
-rw-r--r--bin/ed/undo.c6
9 files changed, 51 insertions, 63 deletions
diff --git a/bin/ed/buf.c b/bin/ed/buf.c
index b4b78a5565b5a..6d8a6ed4f5591 100644
--- a/bin/ed/buf.c
+++ b/bin/ed/buf.c
@@ -35,10 +35,10 @@ __FBSDID("$FreeBSD$");
#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,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
@@ -244,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 52e99998d67c9..08e48cd0544da 100644
--- a/bin/ed/cbc.c
+++ b/bin/ed/cbc.c
@@ -68,28 +68,24 @@ __FBSDID("$FreeBSD$");
* 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 */
+static DES_cblock ivec; /* initialization vector */
+static DES_cblock pvec; /* padding vector */
#endif
-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 */
#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 */
+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 */
/* init_des_cipher: initialize DES */
void
diff --git a/bin/ed/ed.h b/bin/ed/ed.h
index 2021232c04909..8cb8cec731ef2 100644
--- a/bin/ed/ed.h
+++ b/bin/ed/ed.h
@@ -277,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 11dcc19fcc859..5524700983e8a 100644
--- a/bin/ed/glbl.c
+++ b/bin/ed/glbl.c
@@ -135,11 +135,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 63fe10c489eb4..cf2e95906c1fb 100644
--- a/bin/ed/io.c
+++ b/bin/ed/io.c
@@ -30,9 +30,6 @@ __FBSDID("$FreeBSD$");
#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)
@@ -58,11 +55,8 @@ read_file(char *fn, long n)
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 */
@@ -298,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 f414d40f17d2b..98bb300fe623d 100644
--- a/bin/ed/main.c
+++ b/bin/ed/main.c
@@ -66,40 +66,40 @@ __FBSDID("$FreeBSD$");
#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
@@ -254,7 +254,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 */
@@ -1241,8 +1242,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
diff --git a/bin/ed/re.c b/bin/ed/re.c
index f89ecf94cd6b5..08a330de3f878 100644
--- a/bin/ed/re.c
+++ b/bin/ed/re.c
@@ -31,9 +31,6 @@ __FBSDID("$FreeBSD$");
#include "ed.h"
-
-extern int patlock;
-
const char *errmsg = "";
/* get_compiled_pattern: return pointer to compiled pattern from command
diff --git a/bin/ed/sub.c b/bin/ed/sub.c
index 1c44328cc79c6..d12a5c9e14028 100644
--- a/bin/ed/sub.c
+++ b/bin/ed/sub.c
@@ -32,9 +32,9 @@ __FBSDID("$FreeBSD$");
#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
@@ -105,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/undo.c b/bin/ed/undo.c
index 6a8ca9e90137b..603e39f1ca530 100644
--- a/bin/ed/undo.c
+++ b/bin/ed/undo.c
@@ -32,9 +32,9 @@ __FBSDID("$FreeBSD$");
#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 *