From: tobias Date: Fri, 9 Oct 2015 20:27:28 +0000 (+0000) Subject: Define functions as static when they are not used outside their own c-files. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=7aba22276a69ef3179bfb97f9e9482a1ff5c2384;p=openbsd Define functions as static when they are not used outside their own c-files. ok millert@ --- diff --git a/bin/ed/ed.h b/bin/ed/ed.h index aa1685e0a01..459688f8980 100644 --- a/bin/ed/ed.h +++ b/bin/ed/ed.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ed.h,v 1.19 2015/10/09 19:47:02 millert Exp $ */ +/* $OpenBSD: ed.h,v 1.20 2015/10/09 20:27:28 tobias 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. */ @@ -150,66 +150,40 @@ if ((i) > (n)) { \ /* Local Function Declarations */ void add_line_node(line_t *); -int append_lines(int); -int apply_subst_template(char *, regmatch_t *, int, int); int build_active_list(int); -int check_addr_range(int, int); void clear_active_list(void); void clear_undo_stack(void); int close_sbuf(void); -int copy_lines(int); int delete_lines(int, int); int display_lines(int, int, int); -line_t *dup_line_node(line_t *); int exec_command(void); int exec_global(int, int); int extract_addr_range(void); -char *extract_pattern(int); int extract_subst_tail(int *, int *); -char *extract_subst_template(void); line_t *get_addressed_line_node(int); regex_t *get_compiled_pattern(void); char *get_extended_line(int *, int); -char *get_filename(void); int get_line_node_addr(line_t *); -int get_matching_node_addr(regex_t *, int); -int get_marked_node_addr(int); char *get_sbuf_line(line_t *); -int get_shell_command(void); -int get_stream_line(FILE *); int get_tty_line(void); void handle_hup(int); void handle_int(int); -void handle_winch(int); int has_trailing_escape(char *, char *); void init_buffers(void); -int join_lines(int, int); -int mark_line_node(line_t *, int); -int move_lines(int); -line_t *next_active_node(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, int, int); char *put_sbuf_line(char *); -int put_stream_line(FILE *, char *, int); int put_tty_line(char *, int, int, int); void quit(int); int read_file(char *, int); -int read_stream(FILE *, int); int search_and_replace(regex_t *, int, int); -int set_active_node(line_t *); void seterrmsg(char *); -void signal_hup(int); -void signal_int(int); char *strip_escapes(char *); -int substitute_matching_text(regex_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 *); int write_file(char *, char *, int, int); -int write_stream(FILE *, int, int); /* global buffers */ extern char *ibuf; diff --git a/bin/ed/glbl.c b/bin/ed/glbl.c index 65ec7c9a686..28fe7c3b9c2 100644 --- a/bin/ed/glbl.c +++ b/bin/ed/glbl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: glbl.c,v 1.16 2015/10/09 19:47:02 millert Exp $ */ +/* $OpenBSD: glbl.c,v 1.17 2015/10/09 20:27:28 tobias 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 @@ -34,6 +34,8 @@ #include "ed.h" +static int set_active_node(line_t *); +static line_t *next_active_node(void); /* build_active_list: add line matching a pattern to the global-active list */ int @@ -142,7 +144,7 @@ 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 +static int set_active_node(line_t *lp) { if (active_last + 1 > active_size) { @@ -183,7 +185,7 @@ unset_active_nodes(line_t *np, line_t *mp) /* next_active_node: return the next global-active line node */ -line_t * +static line_t * next_active_node(void) { while (active_ptr < active_last && active_list[active_ptr] == NULL) diff --git a/bin/ed/io.c b/bin/ed/io.c index d83bd1af47e..6c464c666e5 100644 --- a/bin/ed/io.c +++ b/bin/ed/io.c @@ -1,4 +1,4 @@ -/* $OpenBSD: io.c,v 1.17 2015/10/09 19:47:02 millert Exp $ */ +/* $OpenBSD: io.c,v 1.18 2015/10/09 20:27:28 tobias 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 */ @@ -30,6 +30,10 @@ #include "ed.h" +static int read_stream(FILE *, int); +static int get_stream_line(FILE *); +static int write_stream(FILE *, int, int); +static int put_stream_line(FILE *, char *, int); extern int scripted; @@ -63,7 +67,7 @@ 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 */ -int +static int read_stream(FILE *fp, int n) { line_t *lp = get_addressed_line_node(n); @@ -107,7 +111,7 @@ read_stream(FILE *fp, int n) } /* get_stream_line: read a line of text from a stream; return line length */ -int +static int get_stream_line(FILE *fp) { int c; @@ -160,7 +164,7 @@ write_file(char *fn, char *mode, int n, int m) /* write_stream: write a range of lines to a stream; return status */ -int +static int write_stream(FILE *fp, int n, int m) { line_t *lp = get_addressed_line_node(n); @@ -183,7 +187,7 @@ write_stream(FILE *fp, int n, int m) /* put_stream_line: write a line of text to a stream; return status */ -int +static int put_stream_line(FILE *fp, char *s, int len) { while (len--) { diff --git a/bin/ed/main.c b/bin/ed/main.c index 923f00a4c79..14e60082b91 100644 --- a/bin/ed/main.c +++ b/bin/ed/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.51 2015/10/09 19:47:02 millert Exp $ */ +/* $OpenBSD: main.c,v 1.52 2015/10/09 20:27:28 tobias 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 @@ -52,6 +52,22 @@ #include "ed.h" +void signal_hup(int); +void signal_int(int); +void handle_winch(int); + +static int next_addr(void); +static int check_addr_range(int, int); +static int get_matching_node_addr(regex_t *, int); +static char *get_filename(void); +static int get_shell_command(void); +static int append_lines(int); +static int join_lines(int, int); +static int move_lines(int); +static int copy_lines(int); +static int mark_line_node(line_t *, int); +static int get_marked_node_addr(int); +static line_t *dup_line_node(line_t *); sigjmp_buf env; @@ -298,7 +314,7 @@ extract_addr_range(void) /* next_addr: return the next line address in the command buffer */ -int +static int next_addr(void) { char *hd; @@ -896,7 +912,7 @@ exec_command(void) /* check_addr_range: return status of address range check */ -int +static int check_addr_range(int n, int m) { if (addr_cnt == 0) { @@ -915,7 +931,7 @@ check_addr_range(int n, int 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 */ -int +static int get_matching_node_addr(regex_t *pat, int dir) { char *s; @@ -940,7 +956,7 @@ get_matching_node_addr(regex_t *pat, int dir) /* get_filename: return pointer to copy of filename in the command buffer */ -char * +static char * get_filename(void) { static char *file = NULL; @@ -981,7 +997,7 @@ get_filename(void) /* get_shell_command: read a shell command from stdin; return substitution status */ -int +static int get_shell_command(void) { static char *buf = NULL; @@ -1044,7 +1060,7 @@ get_shell_command(void) /* append_lines: insert text from stdin to after line n; stop when either a single period is read or EOF; return status */ -int +static int append_lines(int n) { int l; @@ -1093,7 +1109,7 @@ append_lines(int n) /* join_lines: replace a range of lines with the joined text of those lines */ -int +static int join_lines(int from, int to) { static char *buf = NULL; @@ -1130,7 +1146,7 @@ join_lines(int from, int to) /* move_lines: move a range of lines */ -int +static int move_lines(int addr) { line_t *b1, *a1, *b2, *a2; @@ -1174,7 +1190,7 @@ move_lines(int addr) /* copy_lines: copy a range of lines; return status */ -int +static int copy_lines(int addr) { line_t *lp, *np = get_addressed_line_node(first_addr); @@ -1264,7 +1280,7 @@ static line_t *mark[MAXMARK]; /* line markers */ static int markno; /* line marker count */ /* mark_line_node: set a line node mark */ -int +static int mark_line_node(line_t *lp, int n) { if (!islower(n)) { @@ -1278,7 +1294,7 @@ mark_line_node(line_t *lp, int n) /* get_marked_node_addr: return address of a marked line */ -int +static int get_marked_node_addr(int n) { if (!islower(n)) { @@ -1304,7 +1320,7 @@ unmark_line_node(line_t *lp) /* dup_line_node: return a pointer to a copy of a line node */ -line_t * +static line_t * dup_line_node(line_t *lp) { line_t *np; diff --git a/bin/ed/re.c b/bin/ed/re.c index 29bba37f4f3..7db4096dd73 100644 --- a/bin/ed/re.c +++ b/bin/ed/re.c @@ -1,4 +1,4 @@ -/* $OpenBSD: re.c,v 1.14 2015/10/04 15:23:24 millert Exp $ */ +/* $OpenBSD: re.c,v 1.15 2015/10/09 20:27:28 tobias Exp $ */ /* $NetBSD: re.c,v 1.14 1995/03/21 09:04:48 cgd Exp $ */ /* re.c: This file contains the regular expression interface routines for @@ -31,6 +31,8 @@ #include "ed.h" +static char *extract_pattern(int); +static char *parse_char_class(char *); extern int patlock; @@ -76,7 +78,7 @@ get_compiled_pattern(void) /* extract_pattern: copy a pattern string from the command buffer; return pointer to the copy */ -char * +static char * extract_pattern(int delimiter) { static char *lhbuf = NULL; /* buffer */ @@ -112,7 +114,7 @@ extract_pattern(int delimiter) /* parse_char_class: expand a POSIX character class */ -char * +static char * parse_char_class(char *s) { int c, d; diff --git a/bin/ed/sub.c b/bin/ed/sub.c index 18d5b701bb2..b1f64aafe39 100644 --- a/bin/ed/sub.c +++ b/bin/ed/sub.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sub.c,v 1.13 2015/10/09 19:47:02 millert Exp $ */ +/* $OpenBSD: sub.c,v 1.14 2015/10/09 20:27:28 tobias 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 @@ -31,6 +31,9 @@ #include "ed.h" +static char *extract_subst_template(void); +static int substitute_matching_text(regex_t *, line_t *, int, int); +static int apply_subst_template(char *, regmatch_t *, int, int); static char *rhbuf; /* rhs substitution buffer */ static int rhbufsz; /* rhs substitution buffer size */ @@ -68,7 +71,7 @@ extract_subst_tail(int *flagp, int *np) /* extract_subst_template: return pointer to copy of substitution template in the command buffer */ -char * +static char * extract_subst_template(void) { int n = 0; @@ -164,7 +167,7 @@ search_and_replace(regex_t *pat, int gflag, int kth) /* substitute_matching_text: replace text matched by a pattern according to a substitution template; return pointer to the modified text */ -int +static int substitute_matching_text(regex_t *pat, line_t *lp, int gflag, int kth) { int off = 0; @@ -221,7 +224,7 @@ substitute_matching_text(regex_t *pat, line_t *lp, int gflag, int kth) /* apply_subst_template: modify text according to a substitution template; return offset to end of modified text */ -int +static int apply_subst_template(char *boln, regmatch_t *rm, int off, int re_nsub) { int j = 0;