From b23b5a5b7dca39b708015979ed8c25901390ac14 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 21 Feb 2011 10:06:25 -0800 Subject: [PATCH] Declare file-scope functions and variables static if not exported. This is more consistent, and is nicer with gcc -Wstrict-prototypes. * ebrowse.c, emacsclient.c, fakemail.c, make-docfile.c, movemail.c: * profile.c, test-distrib.c, update-game-score.c: Declare non-'main' functions and variables to be static. * ebrowse.c: Omit redundant function prototypes. --- lib-src/ChangeLog | 9 ++ lib-src/ebrowse.c | 185 ++++++++++++++---------------------- lib-src/emacsclient.c | 48 +++++----- lib-src/fakemail.c | 36 +++---- lib-src/make-docfile.c | 42 ++++---- lib-src/movemail.c | 14 +-- lib-src/profile.c | 4 +- lib-src/test-distrib.c | 8 +- lib-src/update-game-score.c | 50 +++++----- 9 files changed, 181 insertions(+), 215 deletions(-) diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog index c2abbc1192..698e7b60a7 100644 --- a/lib-src/ChangeLog +++ b/lib-src/ChangeLog @@ -1,3 +1,12 @@ +2011-02-21 Paul Eggert + + Declare file-scope functions and variables static if not exported. + This is more consistent, and is nicer with gcc -Wstrict-prototypes. + * ebrowse.c, emacsclient.c, fakemail.c, make-docfile.c, movemail.c: + * profile.c, test-distrib.c, update-game-score.c: + Declare non-'main' functions and variables to be static. + * ebrowse.c: Omit redundant function prototypes. + 2011-02-20 Juanma Barranquero * makefile.w32-in (obj): Remove md5.o. diff --git a/lib-src/ebrowse.c b/lib-src/ebrowse.c index 59a1dde763..2cb656ae53 100644 --- a/lib-src/ebrowse.c +++ b/lib-src/ebrowse.c @@ -465,59 +465,16 @@ struct search_path *search_path_tail; /* Function prototypes. */ -int yylex (void); -void yyparse (void); -void re_init_parser (void); -const char *token_string (int); -char *matching_regexp (void); -void init_sym (void); -struct sym *add_sym (const char *, struct sym *); -void add_link (struct sym *, struct sym *); -void add_member_defn (struct sym *, char *, char *, - int, unsigned, int, int, int); -void add_member_decl (struct sym *, char *, char *, int, - unsigned, int, int, int, int); -void dump_roots (FILE *); -void *xmalloc (int); -void xfree (void *); -void add_global_defn (char *, char *, int, unsigned, int, int, int); -void add_global_decl (char *, char *, int, unsigned, int, int, int); -void add_define (char *, char *, int); -void mark_inherited_virtual (void); -void leave_namespace (void); -void enter_namespace (char *); -void register_namespace_alias (char *, struct link *); -void insert_keyword (const char *, int); -void re_init_scanner (void); -void init_scanner (void); -void process_file (char *); -void add_search_path (char *); -FILE *open_file (char *); -int process_pp_line (void); -int dump_members (FILE *, struct member *); -void dump_sym (FILE *, struct sym *); -int dump_tree (FILE *, struct sym *); -struct member *find_member (struct sym *, char *, int, int, unsigned); -struct member *add_member (struct sym *, char *, int, int, unsigned); -void mark_virtual (struct sym *); -struct sym *make_namespace (char *, struct sym *); -char *sym_scope (struct sym *); -char *sym_scope_1 (struct sym *); -int skip_to (int); -void skip_matching (void); -void member (struct sym *, int); -void class_body (struct sym *, int); -void class_definition (struct sym *, int, int, int); -void declaration (int); -unsigned parm_list (int *); -char *operator_name (int *); -struct sym *parse_classname (void); -struct sym *parse_qualified_ident_or_type (char **); -void parse_qualified_param_ident_or_type (char **); -int globals (int); -void yyerror (const char *, const char *); -void usage (int) NO_RETURN; -void version (void) NO_RETURN; +static char *matching_regexp (void); +static struct sym *add_sym (const char *, struct sym *); +static void add_global_defn (char *, char *, int, unsigned, int, int, int); +static void add_global_decl (char *, char *, int, unsigned, int, int, int); +static struct member *add_member (struct sym *, char *, int, int, unsigned); +static void class_definition (struct sym *, int, int, int); +static char *operator_name (int *); +static void parse_qualified_param_ident_or_type (char **); +static void usage (int) NO_RETURN; +static void version (void) NO_RETURN; @@ -528,7 +485,7 @@ void version (void) NO_RETURN; /* Print an error in a printf-like style with the current input file name and line number. */ -void +static void yyerror (const char *format, const char *s) { fprintf (stderr, "%s:%d: ", filename, yyline); @@ -540,7 +497,7 @@ yyerror (const char *format, const char *s) /* Like malloc but print an error and exit if not enough memory is available. */ -void * +static void * xmalloc (int nbytes) { void *p = malloc (nbytes); @@ -555,7 +512,7 @@ xmalloc (int nbytes) /* Like realloc but print an error and exit if out of memory. */ -void * +static void * xrealloc (void *p, int sz) { p = realloc (p, sz); @@ -571,7 +528,7 @@ xrealloc (void *p, int sz) /* Like strdup, but print an error and exit if not enough memory is available.. If S is null, return null. */ -char * +static char * xstrdup (char *s) { if (s) @@ -588,7 +545,7 @@ xstrdup (char *s) /* Initialize the symbol table. This currently only sets up the special symbol for globals (`*Globals*'). */ -void +static void init_sym (void) { global_symbols = add_sym (GLOBALS_NAME, NULL); @@ -602,7 +559,7 @@ init_sym (void) If a symbol for NAME already exists, return that. Otherwise create a new symbol and set it to default values. */ -struct sym * +static struct sym * add_sym (const char *name, struct sym *nested_in_class) { struct sym *sym; @@ -643,7 +600,7 @@ add_sym (const char *name, struct sym *nested_in_class) /* Add links between superclass SUPER and subclass SUB. */ -void +static void add_link (struct sym *super, struct sym *sub) { struct link *lnk, *lnk2, *p, *prev; @@ -683,7 +640,7 @@ add_link (struct sym *super, struct sym *sub) parameter types of functions. Value is a pointer to the member found or null if not found. */ -struct member * +static struct member * find_member (struct sym *cls, char *name, int var, int sc, unsigned int hash) { struct member **list; @@ -733,7 +690,7 @@ find_member (struct sym *cls, char *name, int var, int sc, unsigned int hash) a bit set giving additional information about the member (see the F_* defines). */ -void +static void add_member_decl (struct sym *cls, char *name, char *regexp, int pos, unsigned int hash, int var, int sc, int vis, int flags) { struct member *m; @@ -781,7 +738,7 @@ add_member_decl (struct sym *cls, char *name, char *regexp, int pos, unsigned in a bit set giving additional information about the member (see the F_* defines). */ -void +static void add_member_defn (struct sym *cls, char *name, char *regexp, int pos, unsigned int hash, int var, int sc, int flags) { struct member *m; @@ -823,7 +780,7 @@ add_member_defn (struct sym *cls, char *name, char *regexp, int pos, unsigned in REGEXP is a regular expression matching the define in the source, if it is non-null. POS is the position in the file. */ -void +static void add_define (char *name, char *regexp, int pos) { add_global_defn (name, regexp, pos, 0, 1, SC_FRIEND, F_DEFINE); @@ -841,7 +798,7 @@ add_define (char *name, char *regexp, int pos) a bit set giving additional information about the member (see the F_* defines). */ -void +static void add_global_defn (char *name, char *regexp, int pos, unsigned int hash, int var, int sc, int flags) { int i; @@ -872,7 +829,7 @@ add_global_defn (char *name, char *regexp, int pos, unsigned int hash, int var, a bit set giving additional information about the member (see the F_* defines). */ -void +static void add_global_decl (char *name, char *regexp, int pos, unsigned int hash, int var, int sc, int flags) { /* Add declaration only if not already declared. Header files must @@ -911,7 +868,7 @@ add_global_decl (char *name, char *regexp, int pos, unsigned int hash, int var, member. HASH is a hash code for the parameter types of a function. Value is a pointer to the member's structure. */ -struct member * +static struct member * add_member (struct sym *cls, char *name, int var, int sc, unsigned int hash) { struct member *m = (struct member *) xmalloc (sizeof *m + strlen (name)); @@ -982,7 +939,7 @@ add_member (struct sym *cls, char *name, int var, int sc, unsigned int hash) recursively, marking functions as virtual that are declared virtual in base classes. */ -void +static void mark_virtual (struct sym *r) { struct link *p; @@ -1006,7 +963,7 @@ mark_virtual (struct sym *r) /* For all roots of the class tree, mark functions as virtual that are virtual because of a virtual declaration in a base class. */ -void +static void mark_inherited_virtual (void) { struct sym *r; @@ -1021,7 +978,7 @@ mark_inherited_virtual (void) /* Create and return a symbol for a namespace with name NAME. */ -struct sym * +static struct sym * make_namespace (char *name, struct sym *context) { struct sym *s = (struct sym *) xmalloc (sizeof *s + strlen (name)); @@ -1036,7 +993,7 @@ make_namespace (char *name, struct sym *context) /* Find the symbol for namespace NAME. If not found, retrun NULL */ -struct sym * +static struct sym * check_namespace (char *name, struct sym *context) { struct sym *p = NULL; @@ -1053,7 +1010,7 @@ check_namespace (char *name, struct sym *context) /* Find the symbol for namespace NAME. If not found, add a new symbol for NAME to all_namespaces. */ -struct sym * +static struct sym * find_namespace (char *name, struct sym *context) { struct sym *p = check_namespace (name, context); @@ -1067,7 +1024,7 @@ find_namespace (char *name, struct sym *context) /* Find namespace alias with name NAME. If not found return NULL. */ -struct link * +static struct link * check_namespace_alias (char *name) { struct link *p = NULL; @@ -1091,7 +1048,7 @@ check_namespace_alias (char *name) /* Register the name NEW_NAME as an alias for namespace list OLD_NAME. */ -void +static void register_namespace_alias (char *new_name, struct link *old_name) { unsigned h; @@ -1119,7 +1076,7 @@ register_namespace_alias (char *new_name, struct link *old_name) /* Enter namespace with name NAME. */ -void +static void enter_namespace (char *name) { struct sym *p = find_namespace (name, current_namespace); @@ -1140,7 +1097,7 @@ enter_namespace (char *name) /* Leave the current namespace. */ -void +static void leave_namespace (void) { assert (namespace_sp > 0); @@ -1182,7 +1139,7 @@ int scope_buffer_len; /* Make sure scope_buffer has enough room to add LEN chars to it. */ -void +static void ensure_scope_buffer_room (int len) { if (scope_buffer_len + len >= scope_buffer_size) @@ -1198,7 +1155,7 @@ ensure_scope_buffer_room (int len) namespaces to scope_buffer. Value is a pointer to the complete scope name constructed. */ -char * +static char * sym_scope_1 (struct sym *p) { int len; @@ -1232,7 +1189,7 @@ sym_scope_1 (struct sym *p) /* Return the scope of symbol P in printed representation, i.e. as it would appear in a C*+ source file. */ -char * +static char * sym_scope (struct sym *p) { if (!scope_buffer) @@ -1254,7 +1211,7 @@ sym_scope (struct sym *p) /* Dump the list of members M to file FP. Value is the length of the list. */ -int +static int dump_members (FILE *fp, struct member *m) { int n; @@ -1287,7 +1244,7 @@ dump_members (FILE *fp, struct member *m) /* Dump class ROOT to stream FP. */ -void +static void dump_sym (FILE *fp, struct sym *root) { fputs (CLASS_STRUCT, fp); @@ -1313,7 +1270,7 @@ dump_sym (FILE *fp, struct sym *root) /* Dump class ROOT and its subclasses to file FP. Value is the number of classes written. */ -int +static int dump_tree (FILE *fp, struct sym *root) { struct link *lk; @@ -1360,7 +1317,7 @@ dump_tree (FILE *fp, struct sym *root) /* Dump the entire class tree to file FP. */ -void +static void dump_roots (FILE *fp) { int i, n = 0; @@ -1434,7 +1391,7 @@ do { \ /* Process a preprocessor line. Value is the next character from the input buffer not consumed. */ -int +static int process_pp_line (void) { int in_comment = 0, in_string = 0; @@ -1505,7 +1462,7 @@ process_pp_line (void) /* Value is the next token from the input buffer. */ -int +static int yylex (void) { int c; @@ -1927,7 +1884,7 @@ static char *matching_regexp_buffer, *matching_regexp_end_buf; position in the input buffer, or maybe a bit more if that string is shorter than min_regexp. */ -char * +static char * matching_regexp (void) { char *p; @@ -1978,7 +1935,7 @@ matching_regexp (void) /* Return a printable representation of token T. */ -const char * +static const char * token_string (int t) { static char b[3]; @@ -2095,7 +2052,7 @@ token_string (int t) /* Reinitialize the scanner for a new input file. */ -void +static void re_init_scanner (void) { in = inbuffer; @@ -2113,7 +2070,7 @@ re_init_scanner (void) /* Insert a keyword NAME with token value TK into the keyword hash table. */ -void +static void insert_keyword (const char *name, int tk) { const char *s; @@ -2134,7 +2091,7 @@ insert_keyword (const char *name, int tk) /* Initialize the scanner for the first file. This sets up the character class vectors and fills the keyword hash table. */ -void +static void init_scanner (void) { int i; @@ -2278,7 +2235,7 @@ init_scanner (void) /* Skip forward until a given token TOKEN or YYEOF is seen and return the current lookahead token after skipping. */ -int +static int skip_to (int token) { while (!LOOKING_AT2 (YYEOF, token)) @@ -2289,7 +2246,7 @@ skip_to (int token) /* Skip over pairs of tokens (parentheses, square brackets, angle brackets, curly brackets) matching the current lookahead. */ -void +static void skip_matching (void) { int open, close, n; @@ -2332,7 +2289,7 @@ skip_matching (void) } } -void +static void skip_initializer (void) { for (;;) @@ -2359,7 +2316,7 @@ skip_initializer (void) /* Build qualified namespace alias (A::B::c) and return it. */ -struct link * +static struct link * match_qualified_namespace_alias (void) { struct link *head = NULL; @@ -2396,7 +2353,7 @@ match_qualified_namespace_alias (void) /* Re-initialize the parser by resetting the lookahead token. */ -void +static void re_init_parser (void) { tk = -1; @@ -2409,7 +2366,7 @@ re_init_parser (void) Returns a hash code for the parameter types. This value is used to distinguish between overloaded functions. */ -unsigned +static unsigned parm_list (int *flags) { unsigned hash = 0; @@ -2522,7 +2479,7 @@ parm_list (int *flags) /* Print position info to stdout. */ -void +static void print_info (void) { if (info_position >= 0 && BUFFER_POS () <= info_position) @@ -2537,7 +2494,7 @@ print_info (void) the access specifier for the member (private, protected, public). */ -void +static void member (struct sym *cls, int vis) { char *id = NULL; @@ -2746,7 +2703,7 @@ member (struct sym *cls, int vis) /* Parse the body of class CLS. TAG is the tag of the class (struct, union, class). */ -void +static void class_body (struct sym *cls, int tag) { int vis = tag == CLASS ? PRIVATE : PUBLIC; @@ -2807,7 +2764,7 @@ class_body (struct sym *cls, int tag) qualified ident has the form `X<..>::Y<...>::T<...>. Returns a symbol for that class. */ -struct sym * +static struct sym * parse_classname (void) { struct sym *last_class = NULL; @@ -2837,7 +2794,7 @@ parse_classname (void) implicitly static operator has been parsed. Value is a pointer to a static buffer holding the constructed operator name string. */ -char * +static char * operator_name (int *sc) { static int id_size = 0; @@ -2927,7 +2884,7 @@ operator_name (int *sc) `X::Y::z'. This IDENT is returned in LAST_ID. Value is the symbol structure for the ident. */ -struct sym * +static struct sym * parse_qualified_ident_or_type (char **last_id) { struct sym *cls = NULL; @@ -2992,7 +2949,7 @@ parse_qualified_ident_or_type (char **last_id) `X::Y::z'. This IDENT is returned in LAST_ID. Value is the symbol structure for the ident. */ -void +static void parse_qualified_param_ident_or_type (char **last_id) { struct sym *cls = NULL; @@ -3034,7 +2991,7 @@ parse_qualified_param_ident_or_type (char **last_id) Current lookahead is the class name. */ -void +static void class_definition (struct sym *containing, int tag, int flags, int nested) { struct sym *current; @@ -3131,7 +3088,7 @@ class_definition (struct sym *containing, int tag, int flags, int nested) the storage class of *ID. FLAGS is a bit set giving additional information about the member (see the F_* defines). */ -void +static void add_declarator (struct sym **cls, char **id, int flags, int sc) { if (LOOKING_AT2 (';', ',')) @@ -3174,7 +3131,7 @@ add_declarator (struct sym **cls, char **id, int flags, int sc) /* Parse a declaration. */ -void +static void declaration (int flags) { char *id = NULL; @@ -3328,7 +3285,7 @@ declaration (int flags) parsing in an `extern "C"' block. Value is 1 if EOF is reached, 0 otherwise. */ -int +static int globals (int start_flags) { int anonymous; @@ -3446,7 +3403,7 @@ globals (int start_flags) /* Parse the current input file. */ -void +static void yyparse (void) { while (globals (0) == 0) @@ -3462,7 +3419,7 @@ yyparse (void) /* Add the list of paths PATH_LIST to the current search path for input files. */ -void +static void add_search_path (char *path_list) { while (*path_list) @@ -3497,7 +3454,7 @@ add_search_path (char *path_list) opened. Try to find FILE in search_path first, then try the unchanged file name. */ -FILE * +static FILE * open_file (char *file) { FILE *fp = NULL; @@ -3556,7 +3513,7 @@ Usage: ebrowse [options] {files}\n\ --version display version info\n\ " -void +static void usage (int error) { puts (USAGE); @@ -3571,7 +3528,7 @@ usage (int error) # define VERSION "21" #endif -void +static void version (void) { /* Makes it easier to update automatically. */ @@ -3587,7 +3544,7 @@ version (void) /* Parse one input file FILE, adding classes and members to the symbol table. */ -void +static void process_file (char *file) { FILE *fp; @@ -3642,7 +3599,7 @@ process_file (char *file) containing its contents without the terminating newline. Value is null when EOF is reached. */ -char * +static char * read_line (FILE *fp) { static char *buffer; diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c index 3670e68e3b..8d5f048263 100644 --- a/lib-src/emacsclient.c +++ b/lib-src/emacsclient.c @@ -150,8 +150,8 @@ const char *server_file = NULL; /* PID of the Emacs server process. */ int emacs_pid = 0; -void print_help_and_exit (void) NO_RETURN; -void fail (void) NO_RETURN; +static void print_help_and_exit (void) NO_RETURN; +static void fail (void) NO_RETURN; struct option longopts[] = @@ -178,7 +178,7 @@ struct option longopts[] = /* Like malloc but get fatal error if memory is exhausted. */ -long * +static long * xmalloc (unsigned int size) { long *result = (long *) malloc (size); @@ -192,7 +192,7 @@ xmalloc (unsigned int size) /* Like strdup but get a fatal error if memory is exhausted. */ -char * +static char * xstrdup (const char *s) { char *result = strdup (s); @@ -473,7 +473,7 @@ ttyname (int fd) /* Display a normal or error message. On Windows, use a message box if compiled as a Windows app. */ -void +static void message (int is_error, const char *message, ...) { char msg[2048]; @@ -504,7 +504,7 @@ message (int is_error, const char *message, ...) /* Decode the options from argv and argc. The global variable `optind' will say how many arguments we used up. */ -void +static void decode_options (int argc, char **argv) { alternate_editor = egetenv ("ALTERNATE_EDITOR"); @@ -630,7 +630,7 @@ an empty string"); } -void +static void print_help_and_exit (void) { /* Spaces and tabs are significant in this message; they're chosen so the @@ -675,7 +675,7 @@ Report bugs with M-x report-emacs-bug.\n", progname); defined-- exit with an errorcode. Uses argv, but gets it from the global variable main_argv. */ -void +static void fail (void) { if (alternate_editor) @@ -718,7 +718,7 @@ HSOCKET emacs_socket = 0; /* On Windows, the socket library was historically separate from the standard C library, so errors are handled differently. */ -void +static void sock_err_message (const char *function_name) { #ifdef WINDOWSNT @@ -742,7 +742,7 @@ sock_err_message (const char *function_name) - the data ends in "\n", or - the buffer is full (but this shouldn't happen) Otherwise, we just accumulate it. */ -void +static void send_to_emacs (HSOCKET s, const char *data) { while (data) @@ -781,7 +781,7 @@ send_to_emacs (HSOCKET s, const char *data) return value never contains a space. Does not change the string. Outputs the result to S. */ -void +static void quote_argument (HSOCKET s, const char *str) { char *copy = (char *) xmalloc (strlen (str) * 2 + 1); @@ -822,7 +822,7 @@ quote_argument (HSOCKET s, const char *str) /* The inverse of quote_argument. Removes quoting in string STR by modifying the string in place. Returns STR. */ -char * +static char * unquote_argument (char *str) { char *p, *q; @@ -853,7 +853,7 @@ unquote_argument (char *str) } -int +static int file_name_absolute_p (const char *filename) { /* Sanity check, it shouldn't happen. */ @@ -907,7 +907,7 @@ initialize_sockets (void) * Read the information needed to set up a TCP comm channel with * the Emacs server: host, port, and authentication string. */ -int +static int get_server_config (struct sockaddr_in *server, char *authentication) { char dotted[32]; @@ -965,7 +965,7 @@ get_server_config (struct sockaddr_in *server, char *authentication) return TRUE; } -HSOCKET +static HSOCKET set_tcp_socket (void) { HSOCKET s; @@ -1024,7 +1024,7 @@ strprefix (const char *prefix, const char *string) and the name in TTY_NAME, and return 1. Otherwise, fail if NOABORT is zero, or return 0 if NOABORT is non-zero. */ -int +static int find_tty (char **tty_type, char **tty_name, int noabort) { char *type = egetenv ("TERM"); @@ -1097,7 +1097,7 @@ socket_status (char *socket_name) /* A signal handler that passes the signal to the Emacs process. Useful for SIGWINCH. */ -SIGTYPE +static SIGTYPE pass_signal_to_emacs (int signalnum) { int old_errno = errno; @@ -1112,7 +1112,7 @@ pass_signal_to_emacs (int signalnum) /* Signal handler for SIGCONT; notify the Emacs process that it can now resume our tty frame. */ -SIGTYPE +static SIGTYPE handle_sigcont (int signalnum) { int old_errno = errno; @@ -1138,7 +1138,7 @@ handle_sigcont (int signalnum) reality, we may get a SIGTSTP on C-z. Handling this signal and notifying Emacs about it should get things under control again. */ -SIGTYPE +static SIGTYPE handle_sigtstp (int signalnum) { int old_errno = errno; @@ -1162,7 +1162,7 @@ handle_sigtstp (int signalnum) /* Set up signal handlers before opening a frame on the current tty. */ -void +static void init_signals (void) { /* Set up signal handlers. */ @@ -1182,7 +1182,7 @@ init_signals (void) } -HSOCKET +static HSOCKET set_local_socket (void) { HSOCKET s; @@ -1331,7 +1331,7 @@ To start the server in Emacs, type \"M-x server-start\".\n", } #endif /* ! NO_SOCKETS_IN_FILE_SYSTEM */ -HSOCKET +static HSOCKET set_socket (int no_exit_if_error) { HSOCKET s; @@ -1447,7 +1447,7 @@ w32_give_focus (void) /* Start the emacs daemon and try to connect to it. */ -void +static void start_daemon_and_retry_set_socket (void) { #ifndef WINDOWSNT @@ -1722,7 +1722,7 @@ main (int argc, char **argv) if (rl <= 0) break; - + string[rl] = '\0'; p = string + strlen (string) - 1; diff --git a/lib-src/fakemail.c b/lib-src/fakemail.c index 4289e009e4..26375a6165 100644 --- a/lib-src/fakemail.c +++ b/lib-src/fakemail.c @@ -198,7 +198,7 @@ xrealloc (long int *ptr, int size) /* Initialize a linebuffer for use */ -void +static void init_linebuffer (struct linebuffer *linebuffer) { linebuffer->size = INITIAL_LINE_SIZE; @@ -208,7 +208,7 @@ init_linebuffer (struct linebuffer *linebuffer) /* Read a line of text from `stream' into `linebuffer'. Return the length of the line. */ -long +static long readline (struct linebuffer *linebuffer, FILE *stream) { char *buffer = linebuffer->buffer; @@ -243,7 +243,7 @@ readline (struct linebuffer *linebuffer, FILE *stream) If there is no keyword, return NULL and don't alter *REST. */ -char * +static char * get_keyword (register char *field, char **rest) { static char keyword[KEYWORD_SIZE]; @@ -268,7 +268,7 @@ get_keyword (register char *field, char **rest) /* Nonzero if the string FIELD starts with a colon-terminated keyword. */ -boolean +static boolean has_keyword (char *field) { char *ignored; @@ -285,7 +285,7 @@ has_keyword (char *field) We don't pay attention to overflowing WHERE; the caller has to make it big enough. */ -char * +static char * add_field (line_list the_list, register char *field, register char *where) { register char c; @@ -341,7 +341,7 @@ add_field (line_list the_list, register char *field, register char *where) return where; } -line_list +static line_list make_file_preface (void) { char *the_string, *temp; @@ -385,7 +385,7 @@ make_file_preface (void) return result; } -void +static void write_line_list (register line_list the_list, FILE *the_stream) { for ( ; @@ -398,7 +398,7 @@ write_line_list (register line_list the_list, FILE *the_stream) return; } -int +static int close_the_streams (void) { register stream_list rem; @@ -411,7 +411,7 @@ close_the_streams (void) return (no_problems ? EXIT_SUCCESS : EXIT_FAILURE); } -void +static void add_a_stream (FILE *the_stream, int (*closing_action) (FILE *)) { stream_list old = the_streams; @@ -422,7 +422,7 @@ add_a_stream (FILE *the_stream, int (*closing_action) (FILE *)) return; } -int +static int my_fclose (FILE *the_file) { putc ('\n', the_file); @@ -430,7 +430,7 @@ my_fclose (FILE *the_file) return fclose (the_file); } -boolean +static boolean open_a_file (char *name) { FILE *the_stream = fopen (name, "a"); @@ -445,7 +445,7 @@ open_a_file (char *name) return false; } -void +static void put_string (char *s) { register stream_list rem; @@ -456,7 +456,7 @@ put_string (char *s) return; } -void +static void put_line (const char *string) { register stream_list rem; @@ -516,7 +516,7 @@ put_line (const char *string) the header name), and THE_LIST holds the continuation lines if any. Call open_a_file for each file. */ -void +static void setup_files (register line_list the_list, register char *field) { register char *start; @@ -552,7 +552,7 @@ setup_files (register line_list the_list, register char *field) /* Compute the total size of all recipient names stored in THE_HEADER. The result says how big to make the buffer to pass to parse_header. */ -int +static int args_size (header the_header) { register header old = the_header; @@ -583,7 +583,7 @@ args_size (header the_header) Also, if the header has any FCC fields, call setup_files for each one. */ -void +static void parse_header (header the_header, register char *where) { register header old = the_header; @@ -615,7 +615,7 @@ parse_header (header the_header, register char *where) one for each line in that field. Continuation lines are grouped in the headers they continue. */ -header +static header read_header (void) { register header the_header = ((header) NULL); @@ -669,7 +669,7 @@ read_header (void) return the_header->next; } -void +static void write_header (header the_header) { register header old = the_header; diff --git a/lib-src/make-docfile.c b/lib-src/make-docfile.c index 93994c1ed3..4dd6e8efb1 100644 --- a/lib-src/make-docfile.c +++ b/lib-src/make-docfile.c @@ -66,12 +66,12 @@ along with GNU Emacs. If not, see . */ #define IS_DIRECTORY_SEP(_c_) ((_c_) == DIRECTORY_SEP) #endif -int scan_file (char *filename); -int scan_lisp_file (const char *filename, const char *mode); -int scan_c_file (char *filename, const char *mode); -void fatal (const char *s1, const char *s2) NO_RETURN; -void start_globals (void); -void write_globals (void); +static int scan_file (char *filename); +static int scan_lisp_file (const char *filename, const char *mode); +static int scan_c_file (char *filename, const char *mode); +static void fatal (const char *s1, const char *s2) NO_RETURN; +static void start_globals (void); +static void write_globals (void); #ifdef MSDOS /* s/msdos.h defines this as sys_chdir, but we're not linking with the @@ -93,7 +93,7 @@ int generate_globals; /* Print error message. `s1' is printf control string, `s2' is arg for it. */ /* VARARGS1 */ -void +static void error (const char *s1, const char *s2) { fprintf (stderr, "%s: ", progname); @@ -104,7 +104,7 @@ error (const char *s1, const char *s2) /* Print error message and exit. */ /* VARARGS1 */ -void +static void fatal (const char *s1, const char *s2) { error (s1, s2); @@ -113,7 +113,7 @@ fatal (const char *s1, const char *s2) /* Like malloc but get fatal error if memory is exhausted. */ -void * +static void * xmalloc (unsigned int size) { void *result = (void *) malloc (size); @@ -124,7 +124,7 @@ xmalloc (unsigned int size) /* Like realloc but get fatal error if memory is exhausted. */ -void * +static void * xrealloc (void *arg, unsigned int size) { void *result = (void *) realloc (arg, size); @@ -212,7 +212,7 @@ main (int argc, char **argv) } /* Add a source file name boundary marker in the output file. */ -void +static void put_filename (char *filename) { char *tmp; @@ -231,7 +231,7 @@ put_filename (char *filename) /* Read file FILENAME and output its doc strings to outfile. */ /* Return 1 if file is not found, 0 if it is found. */ -int +static int scan_file (char *filename) { @@ -247,7 +247,7 @@ scan_file (char *filename) return scan_c_file (filename, READ_TEXT); } -void +static void start_globals (void) { fprintf (outfile, "/* This file was auto-generated by make-docfile. */\n"); @@ -255,7 +255,7 @@ start_globals (void) fprintf (outfile, "struct emacs_globals {\n"); } -char buf[128]; +static char buf[128]; /* Some state during the execution of `read_c_string_or_comment'. */ struct rcsoc_state @@ -388,7 +388,7 @@ scan_keyword_or_put_char (int ch, struct rcsoc_state *state) at the beginning of a line will be removed, and *SAW_USAGE set to true if any were encountered. */ -int +static int read_c_string_or_comment (FILE *infile, int printflag, int comment, int *saw_usage) { register int c; @@ -476,7 +476,7 @@ read_c_string_or_comment (FILE *infile, int printflag, int comment, int *saw_usa /* Write to file OUT the argument names of function FUNC, whose text is in BUF. MINARGS and MAXARGS are the minimum and maximum number of arguments. */ -void +static void write_c_args (FILE *out, char *func, char *buf, int minargs, int maxargs) { register char *p; @@ -610,7 +610,7 @@ compare_globals (const void *a, const void *b) return strcmp (ga->name, gb->name); } -void +static void write_globals (void) { int i; @@ -652,7 +652,7 @@ write_globals (void) Looks for DEFUN constructs such as are defined in ../src/lisp.h. Accepts any word starting DEF... so it finds DEFSIMPLE and DEFPRED. */ -int +static int scan_c_file (char *filename, const char *mode) { FILE *infile; @@ -979,7 +979,7 @@ scan_c_file (char *filename, const char *mode) An entry is output only if DOCSTRING has \ newline just after the opening " */ -void +static void skip_white (FILE *infile) { char c = ' '; @@ -988,7 +988,7 @@ skip_white (FILE *infile) ungetc (c, infile); } -void +static void read_lisp_symbol (FILE *infile, char *buffer) { char c; @@ -1016,7 +1016,7 @@ read_lisp_symbol (FILE *infile, char *buffer) skip_white (infile); } -int +static int scan_lisp_file (const char *filename, const char *mode) { FILE *infile; diff --git a/lib-src/movemail.c b/lib-src/movemail.c index 682aa10aa3..a63e858613 100644 --- a/lib-src/movemail.c +++ b/lib-src/movemail.c @@ -161,7 +161,7 @@ static int mbx_delimit_end (FILE *mbf); #endif /* Nonzero means this is name of a lock file to delete on fatal error. */ -char *delete_lockname; +static char *delete_lockname; int main (int argc, char **argv) @@ -672,12 +672,12 @@ xmalloc (unsigned int size) #define OK 0 #define DONE 1 -char *progname; -FILE *sfi; -FILE *sfo; -char ibuffer[BUFSIZ]; -char obuffer[BUFSIZ]; -char Errmsg[200]; /* POP errors, at least, can exceed +static char *progname; +static FILE *sfi; +static FILE *sfo; +static char ibuffer[BUFSIZ]; +static char obuffer[BUFSIZ]; +static char Errmsg[200]; /* POP errors, at least, can exceed the original length of 80. */ /* diff --git a/lib-src/profile.c b/lib-src/profile.c index 9ce9993f4b..086d8cc3e9 100644 --- a/lib-src/profile.c +++ b/lib-src/profile.c @@ -38,7 +38,7 @@ static char time_string[30]; /* Reset the stopwatch to zero. */ -void +static void reset_watch (void) { EMACS_GET_TIME (TV1); @@ -49,7 +49,7 @@ reset_watch (void) is returned as a string with the format . If reset_watch was not called yet, exit. */ -char * +static char * get_time (void) { if (watch_not_started) diff --git a/lib-src/test-distrib.c b/lib-src/test-distrib.c index acfb147325..c27f0e35b0 100644 --- a/lib-src/test-distrib.c +++ b/lib-src/test-distrib.c @@ -26,18 +26,18 @@ along with GNU Emacs. If not, see . */ /* Break string in two parts to avoid buggy C compilers that ignore characters after nulls in strings. */ -char string1[] = "Testing distribution of nonprinting chars:\n\ +static char string1[] = "Testing distribution of nonprinting chars:\n\ Should be 0177: \177 Should be 0377: \377 Should be 0212: \212.\n\ Should be 0000: "; -char string2[] = ".\n\ +static char string2[] = ".\n\ This file is read by the `test-distribution' program.\n\ If you change it, you will make that program fail.\n"; -char buf[300]; +static char buf[300]; /* Like `read' but keeps trying until it gets SIZE bytes or reaches eof. */ -int +static int cool_read (int fd, char *buf, size_t size) { ssize_t num; diff --git a/lib-src/update-game-score.c b/lib-src/update-game-score.c index 9466bf7b14..70b79a64f9 100644 --- a/lib-src/update-game-score.c +++ b/lib-src/update-game-score.c @@ -57,7 +57,7 @@ along with GNU Emacs. If not, see . */ extern char *optarg; extern int optind, opterr; -int usage (int err) NO_RETURN; +static int usage (int err) NO_RETURN; #define MAX_ATTEMPTS 5 #define MAX_SCORES 200 @@ -68,7 +68,7 @@ int usage (int err) NO_RETURN; #define difftime(t1, t0) (double)((t1) - (t0)) #endif -int +static int usage (int err) { fprintf (stdout, "Usage: update-game-score [-m MAX ] [ -r ] game/scorefile SCORE DATA\n"); @@ -80,8 +80,8 @@ usage (int err) exit (err); } -int lock_file (const char *filename, void **state); -int unlock_file (const char *filename, void *state); +static int lock_file (const char *filename, void **state); +static int unlock_file (const char *filename, void *state); struct score_entry { @@ -90,24 +90,24 @@ struct score_entry char *data; }; -int read_scores (const char *filename, struct score_entry **scores, - int *count); -int push_score (struct score_entry **scores, int *count, - int newscore, char *username, char *newdata); -void sort_scores (struct score_entry *scores, int count, int reverse); -int write_scores (const char *filename, const struct score_entry *scores, - int count); +static int read_scores (const char *filename, struct score_entry **scores, + int *count); +static int push_score (struct score_entry **scores, int *count, + int newscore, char *username, char *newdata); +static void sort_scores (struct score_entry *scores, int count, int reverse); +static int write_scores (const char *filename, + const struct score_entry *scores, int count); -void lose (const char *msg) NO_RETURN; +static void lose (const char *msg) NO_RETURN; -void +static void lose (const char *msg) { fprintf (stderr, "%s\n", msg); exit (EXIT_FAILURE); } -void lose_syserr (const char *msg) NO_RETURN; +static void lose_syserr (const char *msg) NO_RETURN; /* Taken from sysdep.c. */ #ifndef HAVE_STRERROR @@ -126,14 +126,14 @@ strerror (errnum) #endif /* not WINDOWSNT */ #endif /* ! HAVE_STRERROR */ -void +static void lose_syserr (const char *msg) { fprintf (stderr, "%s: %s\n", msg, strerror (errno)); exit (EXIT_FAILURE); } -char * +static char * get_user_id (void) { char *name; @@ -154,7 +154,7 @@ get_user_id (void) return buf->pw_name; } -const char * +static const char * get_prefix (int running_suid, const char *user_prefix) { if (!running_suid && user_prefix == NULL) @@ -258,7 +258,7 @@ main (int argc, char **argv) exit (EXIT_SUCCESS); } -int +static int read_score (FILE *f, struct score_entry *score) { int c; @@ -342,7 +342,7 @@ read_score (FILE *f, struct score_entry *score) return 0; } -int +static int read_scores (const char *filename, struct score_entry **scores, int *count) { int readval, scorecount, cursize; @@ -375,7 +375,7 @@ read_scores (const char *filename, struct score_entry **scores, int *count) return 0; } -int +static int score_compare (const void *a, const void *b) { const struct score_entry *sa = (const struct score_entry *) a; @@ -383,7 +383,7 @@ score_compare (const void *a, const void *b) return (sb->score > sa->score) - (sb->score < sa->score); } -int +static int score_compare_reverse (const void *a, const void *b) { const struct score_entry *sa = (const struct score_entry *) a; @@ -407,14 +407,14 @@ push_score (struct score_entry **scores, int *count, int newscore, char *usernam return 0; } -void +static void sort_scores (struct score_entry *scores, int count, int reverse) { qsort (scores, count, sizeof (struct score_entry), reverse ? score_compare_reverse : score_compare); } -int +static int write_scores (const char *filename, const struct score_entry *scores, int count) { FILE *f; @@ -443,7 +443,7 @@ write_scores (const char *filename, const struct score_entry *scores, int count) return 0; } -int +static int lock_file (const char *filename, void **state) { int fd; @@ -484,7 +484,7 @@ lock_file (const char *filename, void **state) return 0; } -int +static int unlock_file (const char *filename, void *state) { char *lockpath = (char *) state; -- 2.20.1