diff options
Diffstat (limited to 'lib-src')
-rw-r--r-- | lib-src/ChangeLog | 121 | ||||
-rw-r--r-- | lib-src/Makefile.in | 6 | ||||
-rw-r--r-- | lib-src/ebrowse.c | 263 | ||||
-rw-r--r-- | lib-src/emacsclient.c | 180 | ||||
-rw-r--r-- | lib-src/etags.c | 16 | ||||
-rw-r--r-- | lib-src/fakemail.c | 49 | ||||
-rw-r--r-- | lib-src/make-docfile.c | 72 | ||||
-rw-r--r-- | lib-src/makefile.w32-in | 10 | ||||
-rw-r--r-- | lib-src/movemail.c | 74 | ||||
-rw-r--r-- | lib-src/pop.c | 9 | ||||
-rw-r--r-- | lib-src/profile.c | 4 | ||||
-rw-r--r-- | lib-src/test-distrib.c | 9 | ||||
-rw-r--r-- | lib-src/update-game-score.c | 50 |
13 files changed, 481 insertions, 382 deletions
diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog index 01352adf4e3..4b50b2dddeb 100644 --- a/lib-src/ChangeLog +++ b/lib-src/ChangeLog @@ -1,3 +1,118 @@ +2011-03-03 Drake Wilson <drake@begriffli.ch> (tiny change) + + * emacsclient.c (longopts): Add quiet. + (decode_options): Handle q/quiet. + (print_help_and_exit): Add q/quiet. + (main): Suppress some messages if quiet option is used. + +2011-02-26 Eli Zaretskii <eliz@gnu.org> + + * Makefile.in (fakemail${EXEEXT}): Depend on lib/ignore-value.h. + + * emacsclient.c (xstrdup) [WINDOWSNT]: Function added back. + (w32_getenv): Use xstrdup to return all values in malloc'ed + storage. + +2011-02-26 Paul Eggert <eggert@cs.ucla.edu> + + * ebrowse.c (parse_qualified_param_ident_or_type): Make it clear + to reader (and to the compiler) that the loop always executes at + least once. This prevents a warning with recent GCC. + (BROWSE_STRUCT): Remove unused macro. + + * fakemail.c: Include <ignore-value.h>. + (put_line): Explicitly ignore fwrite return value, for benefit of + recent glibc + gcc. + (close_the_streams): Diagnose output errors instead of merely + exiting with nonzero status. + (my_fclose, main): Diagnose input errors, and exit with nonzero status. + Formerly, input errors were silently ignored. + + * ebrowse.c (putstr): Rename from PUTSTR and turn into a function. + All callers changed. This is cleaner, and avoids GCC warnings about + passing NULL to fputs. + (insert_keyword): Rename parameter to avoid shadowing diagnostic. + +2011-02-25 Paul Eggert <eggert@cs.ucla.edu> + + * emacsclient.c (main): Avoid dangling 'if'. + (xstrdup): Remove; no longer needed. + (get_current_dir_name, w32_getenv, get_server_config, find_tty): + (set_local_socket, main): + Use const char *, not char *, for pointers that are not assigned + through. + (IF_LINT): New macro. + (set_local_socket, main): Use it to suppress warnings with + GCC -Wuninitialized. + + * emacsclient.c: Redo local variables to avoid shadowing problems. + (message, socket_status, start_daemon_and_retry_set_socket): + Rename locals. + (main): Move decl of "i". + + * etags.c (ISUPPER): Move to inside the only #ifdef where it's used. + This avoids an unused-macro warning with some GCC settings. + + * make-docfile.c (write_globals): Change char * to char const * + to avoid a GCC "assignment discards qualifiers" diagnostic + in some configurations. + (scan_c_file): Refactor local variable decls to make their scope + more accurate and to avoid a GCC -Wuninitialized diagnostic. + +2011-02-22 Eli Zaretskii <eliz@gnu.org> + + * etags.c (canonicalize_filename, ISUPPER): Fix last change. + + * makefile.w32-in ($(BLD)/ebrowse.$(O), $(BLD)/pop.$(O)): Depend + on ../lib/min-max.h. + +2011-02-22 Paul Eggert <eggert@cs.ucla.edu> + + etags: Downcase drive letters, for consistency with Emacs proper. + * etags.c (upcase): Remove; no longer used. + (canonicalize_filename): Downcase drive letters. + + Assume S_ISLNK etc. work, since gnulib supports this. + * etags.c (S_ISREG): Remove. + +2011-02-22 Paul Eggert <eggert@cs.ucla.edu> + + Assume S_ISLNK etc. work, since gnulib supports this. + * etags.c (S_ISREG): Remove. + +2011-02-22 Juanma Barranquero <lekktu@gmail.com> + + * makefile.w32-in (obj): Remove filemode.o. + +2011-02-21 Paul Eggert <eggert@cs.ucla.edu> + + New file "lib/min-max.h". + * ebrowse.c (min, max): Define them by including <min-max.h> + instead of defining it ourselves. + * pop.c (min): Likewise. + * Makefile.in (ebrowse${EXEEXT}, pop.o): Depend on min-max.h. + + * movemail.c (popmail): Report fchown failure instead of ignoring it. + But if the file already has the right ownership, don't worry about it. + + * make-docfile.c (input_buffer): Rename variables to avoid shadowing. + * test-distrib.c (buf): Make this local, to avoid shadowing. + + * movemail.c (main, pop_retr): Rename locals to avoid shadowing. + (progname, sfi, sfo, ibuffer, obuffer): Remove unused vars. + (DONE): Remove unused macro. + (DIRECTORY_SEP, IS_DIRECTORY_SEP, IS_FROM_LINE): + Define these macros only in the contexts that need them. + * pop.c (index): Remove unused macro. + (KPOP_PORT): Define only if KERBEROS is defined. + + 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-21 Eli Zaretskii <eliz@gnu.org> * makefile.w32-in ($(BLD)/ctags.$(O), $(BLD)/emacsclient.$(O)) @@ -39,7 +154,7 @@ 2011-02-05 Paul Eggert <eggert@cs.ucla.edu> - * emacsclient.c: conform to C89 pointer rules + * emacsclient.c: Conform to C89 pointer rules. (file_name_absolute_p): Accept const char *, not const unsigned char *, to satisfy C89 rules. @@ -197,7 +312,7 @@ * test-distrib.c (cool_read): * movemail.c (main, concat): * make-docfile.c (scan_file, write_c_args): - * emacsclient.c (get_server_config): Fix -Wconversion warning. + * emacsclient.c (get_server_config): Fix -Wconversion warning. (egetenv): Move conditional definition earlier. (progname): Use const. * sorted-doc.c (xstrdup): Use const. @@ -557,7 +672,7 @@ autoconf, not cpp. (ALL_CFLAGS): Use them as make variables. -2010-04-07 Christoph <cschol2112@googlemail.com> (tiny change) +2010-04-07 Christoph Scholtes <cschol2112@googlemail.com> * makefile.w32-in (OTHER_PLATFORM_SUPPORT): Use parenthesis for macros for nmake compatibility. diff --git a/lib-src/Makefile.in b/lib-src/Makefile.in index 96975613104..d622233efb4 100644 --- a/lib-src/Makefile.in +++ b/lib-src/Makefile.in @@ -325,7 +325,7 @@ etags${EXEEXT}: ${srcdir}/etags.c $(REGEXPDEPS) ../src/config.h -DVERSION="\"${version}\"" ${srcdir}/etags.c \ $(REGEXPOBJ) $(LOADLIBES) -o etags -ebrowse${EXEEXT}: ${srcdir}/ebrowse.c ../src/config.h +ebrowse${EXEEXT}: ${srcdir}/ebrowse.c ${srcdir}/../lib/min-max.h ../src/config.h $(CC) ${ALL_CFLAGS} -DVERSION="\"${version}\"" \ ${srcdir}/ebrowse.c $(LOADLIBES) -o ebrowse @@ -350,10 +350,10 @@ movemail${EXEEXT}: movemail.o pop.o movemail.o: ${srcdir}/movemail.c ../src/config.h $(CC) -c ${CPP_CFLAGS} ${MOVE_FLAGS} ${srcdir}/movemail.c -pop.o: ${srcdir}/pop.c ../src/config.h +pop.o: ${srcdir}/pop.c ${srcdir}/../lib/min-max.h ../src/config.h $(CC) -c ${CPP_CFLAGS} ${MOVE_FLAGS} ${srcdir}/pop.c -fakemail${EXEEXT}: ${srcdir}/fakemail.c ../src/config.h +fakemail${EXEEXT}: ${srcdir}/fakemail.c ${srcdir}/../lib/ignore-value.h ../src/config.h $(CC) ${ALL_CFLAGS} ${srcdir}/fakemail.c $(LOADLIBES) -o fakemail emacsclient${EXEEXT}: ${srcdir}/emacsclient.c ../src/config.h diff --git a/lib-src/ebrowse.c b/lib-src/ebrowse.c index 59a1dde7634..113b6fdfe40 100644 --- a/lib-src/ebrowse.c +++ b/lib-src/ebrowse.c @@ -41,12 +41,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #define streq(X, Y) (*(X) == *(Y) && strcmp ((X) + 1, (Y) + 1) == 0) -/* The ubiquitous `max' and `min' macros. */ - -#ifndef max -#define max(X, Y) ((X) > (Y) ? (X) : (Y)) -#define min(X, Y) ((X) < (Y) ? (X) : (Y)) -#endif +#include <min-max.h> /* Files are read in chunks of this number of bytes. */ @@ -82,7 +77,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #define TREE_HEADER_STRUCT "[ebrowse-hs " #define TREE_STRUCT "[ebrowse-ts " #define MEMBER_STRUCT "[ebrowse-ms " -#define BROWSE_STRUCT "[ebrowse-bs " #define CLASS_STRUCT "[ebrowse-cs " /* The name of the symbol table entry for global functions, variables, @@ -465,59 +459,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 +479,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 +491,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 +506,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 +522,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 +539,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 +553,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 +594,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 +634,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 +684,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 +732,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 +774,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 +792,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 +823,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 +862,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 +933,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 +957,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 +972,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 +987,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 +1004,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 +1018,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 +1042,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 +1070,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 +1091,7 @@ enter_namespace (char *name) /* Leave the current namespace. */ -void +static void leave_namespace (void) { assert (namespace_sp > 0); @@ -1156,22 +1107,23 @@ leave_namespace (void) /* Write string S to the output file FP in a Lisp-readable form. If S is null, write out `()'. */ -#define PUTSTR(s, fp) \ - do { \ - if (!s) \ - { \ - putc ('(', fp); \ - putc (')', fp); \ - putc (' ', fp); \ - } \ - else \ - { \ - putc ('"', fp); \ - fputs (s, fp); \ - putc ('"', fp); \ - putc (' ', fp); \ - } \ - } while (0) +static inline void +putstr (const char *s, FILE *fp) +{ + if (!s) + { + putc ('(', fp); + putc (')', fp); + putc (' ', fp); + } + else + { + putc ('"', fp); + fputs (s, fp); + putc ('"', fp); + putc (' ', fp); + } +} /* A dynamically allocated buffer for constructing a scope name. */ @@ -1182,7 +1134,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 +1150,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 +1184,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 +1206,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; @@ -1264,16 +1216,16 @@ dump_members (FILE *fp, struct member *m) for (n = 0; m; m = m->next, ++n) { fputs (MEMBER_STRUCT, fp); - PUTSTR (m->name, fp); - PUTSTR (NULL, fp); /* FIXME? scope for globals */ + putstr (m->name, fp); + putstr (NULL, fp); /* FIXME? scope for globals */ fprintf (fp, "%u ", (unsigned) m->flags); - PUTSTR (m->filename, fp); - PUTSTR (m->regexp, fp); + putstr (m->filename, fp); + putstr (m->regexp, fp); fprintf (fp, "%u ", (unsigned) m->pos); fprintf (fp, "%u ", (unsigned) m->vis); putc (' ', fp); - PUTSTR (m->def_filename, fp); - PUTSTR (m->def_regexp, fp); + putstr (m->def_filename, fp); + putstr (m->def_regexp, fp); fprintf (fp, "%u", (unsigned) m->def_pos); putc (']', fp); putc ('\n', fp); @@ -1287,24 +1239,24 @@ 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); - PUTSTR (root->name, fp); + putstr (root->name, fp); /* Print scope, if any. */ if (root->namesp) - PUTSTR (sym_scope (root), fp); + putstr (sym_scope (root), fp); else - PUTSTR (NULL, fp); + putstr (NULL, fp); /* Print flags. */ fprintf (fp, "%u", root->flags); - PUTSTR (root->filename, fp); - PUTSTR (root->regexp, fp); + putstr (root->filename, fp); + putstr (root->regexp, fp); fprintf (fp, "%u", (unsigned) root->pos); - PUTSTR (root->sfilename, fp); + putstr (root->sfilename, fp); putc (']', fp); putc ('\n', fp); } @@ -1313,7 +1265,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 +1312,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; @@ -1371,7 +1323,7 @@ dump_roots (FILE *fp) if (!f_append) { fputs (TREE_HEADER_STRUCT, fp); - PUTSTR (EBROWSE_FILE_VERSION, fp); + putstr (EBROWSE_FILE_VERSION, fp); putc ('\"', fp); if (!f_structs) @@ -1434,7 +1386,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 +1457,7 @@ process_pp_line (void) /* Value is the next token from the input buffer. */ -int +static int yylex (void) { int c; @@ -1927,7 +1879,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 +1930,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 +2047,7 @@ token_string (int t) /* Reinitialize the scanner for a new input file. */ -void +static void re_init_scanner (void) { in = inbuffer; @@ -2110,11 +2062,11 @@ re_init_scanner (void) } -/* Insert a keyword NAME with token value TK into the keyword hash +/* Insert a keyword NAME with token value TKV into the keyword hash table. */ -void -insert_keyword (const char *name, int tk) +static void +insert_keyword (const char *name, int tkv) { const char *s; unsigned h = 0; @@ -2125,7 +2077,7 @@ insert_keyword (const char *name, int tk) h %= KEYWORD_TABLE_SIZE; k->name = name; - k->tk = tk; + k->tk = tkv; k->next = keyword_table[h]; keyword_table[h] = k; } @@ -2134,7 +2086,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 +2230,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 +2241,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 +2284,7 @@ skip_matching (void) } } -void +static void skip_initializer (void) { for (;;) @@ -2359,7 +2311,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 +2348,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 +2361,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 +2474,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 +2489,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 +2698,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 +2759,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 +2789,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 +2879,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,14 +2944,16 @@ 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; static char *id = NULL; static int id_size = 0; - while (LOOKING_AT (IDENT)) + assert (LOOKING_AT (IDENT)); + + do { int len = strlen (yytext) + 1; if (len > id_size) @@ -3022,6 +2976,7 @@ parse_qualified_param_ident_or_type (char **last_id) else break; } + while (LOOKING_AT (IDENT)); } @@ -3034,7 +2989,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 +3086,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 +3129,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 +3283,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 +3401,7 @@ globals (int start_flags) /* Parse the current input file. */ -void +static void yyparse (void) { while (globals (0) == 0) @@ -3462,7 +3417,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 +3452,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 +3511,7 @@ Usage: ebrowse [options] {files}\n\ --version display version info\n\ " -void +static void usage (int error) { puts (USAGE); @@ -3571,7 +3526,7 @@ usage (int error) # define VERSION "21" #endif -void +static void version (void) { /* Makes it easier to update automatically. */ @@ -3587,7 +3542,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 +3597,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 3670e68e3b3..abc9aee37c1 100644 --- a/lib-src/emacsclient.c +++ b/lib-src/emacsclient.c @@ -112,6 +112,13 @@ char *(getcwd) (char *, size_t); /* Additional space when allocating buffers for filenames, etc. */ #define EXTRA_SPACE 100 +/* Use this to suppress gcc's `...may be used before initialized' warnings. */ +#ifdef lint +# define IF_LINT(Code) Code +#else +# define IF_LINT(Code) /* empty */ +#endif + /* Name used to invoke this program. */ const char *progname; @@ -122,6 +129,9 @@ char **main_argv; /* Nonzero means don't wait for a response from Emacs. --no-wait. */ int nowait = 0; +/* Nonzero means don't print messages for successful operations. --quiet. */ +int quiet = 0; + /* Nonzero means args are expressions to be evaluated. --eval. */ int eval = 0; @@ -150,13 +160,14 @@ 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[] = { { "no-wait", no_argument, NULL, 'n' }, + { "quiet", no_argument, NULL, 'q' }, { "eval", no_argument, NULL, 'e' }, { "help", no_argument, NULL, 'H' }, { "version", no_argument, NULL, 'V' }, @@ -178,7 +189,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); @@ -190,20 +201,6 @@ xmalloc (unsigned int size) return result; } -/* Like strdup but get a fatal error if memory is exhausted. */ - -char * -xstrdup (const char *s) -{ - char *result = strdup (s); - if (result == NULL) - { - perror ("strdup"); - exit (EXIT_FAILURE); - } - return result; -} - /* From sysdep.c */ #if !defined (HAVE_GET_CURRENT_DIR_NAME) || defined (BROKEN_GET_CURRENT_DIR_NAME) @@ -233,7 +230,7 @@ char* get_current_dir_name (void) { char *buf; - char *pwd; + const char *pwd; struct stat dotstat, pwdstat; /* If PWD is accurate, use it instead of calling getwd. PWD is sometimes a nicer name, and using it may avoid a fatal error if a @@ -300,6 +297,20 @@ get_current_dir_name (void) #ifdef WINDOWSNT +/* Like strdup but get a fatal error if memory is exhausted. */ + +char * +xstrdup (const char *s) +{ + char *result = strdup (s); + if (result == NULL) + { + perror ("strdup"); + exit (EXIT_FAILURE); + } + return result; +} + #define REG_ROOT "SOFTWARE\\GNU\\Emacs" /* Retrieve an environment variable from the Emacs subkeys of the registry. @@ -335,9 +346,11 @@ w32_get_resource (HKEY predefined, char *key, LPDWORD type) /* getenv wrapper for Windows - This is needed to duplicate Emacs's behavior, which is to look for environment - variables in the registry if they don't appear in the environment. -*/ + Value is allocated on the heap, and can be free'd. + + This is needed to duplicate Emacs's behavior, which is to look for + environment variables in the registry if they don't appear in the + environment. */ char * w32_getenv (char *envvar) { @@ -345,8 +358,9 @@ w32_getenv (char *envvar) DWORD dwType; if (value = getenv (envvar)) - /* Found in the environment. */ - return value; + /* Found in the environment. strdup it, because values returned + by getenv cannot be free'd. */ + return xstrdup (value); if (! (value = w32_get_resource (HKEY_CURRENT_USER, envvar, &dwType)) && ! (value = w32_get_resource (HKEY_LOCAL_MACHINE, envvar, &dwType))) @@ -473,14 +487,14 @@ ttyname (int fd) /* Display a normal or error message. On Windows, use a message box if compiled as a Windows app. */ -void -message (int is_error, const char *message, ...) +static void +message (int is_error, const char *format, ...) { char msg[2048]; va_list args; - va_start (args, message); - vsprintf (msg, message, args); + va_start (args, format); + vsprintf (msg, format, args); va_end (args); #ifdef WINDOWSNT @@ -504,7 +518,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"); @@ -513,9 +527,9 @@ decode_options (int argc, char **argv) { int opt = getopt_long_only (argc, argv, #ifndef NO_SOCKETS_IN_FILE_SYSTEM - "VHnea:s:f:d:tc", + "VHneqa:s:f:d:tc", #else - "VHnea:f:d:tc", + "VHneqa:f:d:tc", #endif longopts, 0); @@ -559,6 +573,10 @@ decode_options (int argc, char **argv) eval = 1; break; + case 'q': + quiet = 1; + break; + case 'V': message (FALSE, "emacsclient %s\n", VERSION); exit (EXIT_SUCCESS); @@ -630,7 +648,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 @@ -650,6 +668,7 @@ The following OPTIONS are accepted:\n\ use the current Emacs frame\n\ -e, --eval Evaluate the FILE arguments as ELisp expressions\n\ -n, --no-wait Don't wait for the server to return\n\ +-q, --quiet Don't display messages on success\n\ -d DISPLAY, --display=DISPLAY\n\ Visit the file in the given display\n\ --parent-id=ID Open in parent window ID, via XEmbed\n" @@ -675,7 +694,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 +737,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 +761,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 +800,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 +841,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 +872,7 @@ unquote_argument (char *str) } -int +static int file_name_absolute_p (const char *filename) { /* Sanity check, it shouldn't happen. */ @@ -907,7 +926,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]; @@ -918,7 +937,7 @@ get_server_config (struct sockaddr_in *server, char *authentication) config = fopen (server_file, "rb"); else { - char *home = egetenv ("HOME"); + const char *home = egetenv ("HOME"); if (home) { @@ -965,7 +984,7 @@ get_server_config (struct sockaddr_in *server, char *authentication) return TRUE; } -HSOCKET +static HSOCKET set_tcp_socket (void) { HSOCKET s; @@ -976,7 +995,7 @@ set_tcp_socket (void) if (! get_server_config (&server, auth_string)) return INVALID_SOCKET; - if (server.sin_addr.s_addr != inet_addr ("127.0.0.1")) + if (server.sin_addr.s_addr != inet_addr ("127.0.0.1") && !quiet) message (FALSE, "%s: connected to remote socket at %s\n", progname, inet_ntoa (server.sin_addr)); @@ -1024,11 +1043,11 @@ 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 -find_tty (char **tty_type, char **tty_name, int noabort) +static int +find_tty (const char **tty_type, const char **tty_name, int noabort) { - char *type = egetenv ("TERM"); - char *name = ttyname (fileno (stdout)); + const char *type = egetenv ("TERM"); + const char *name = ttyname (fileno (stdout)); if (!name) { @@ -1080,11 +1099,11 @@ find_tty (char **tty_type, char **tty_name, int noabort) 0 - success: none of the above */ static int -socket_status (char *socket_name) +socket_status (char *name) { struct stat statbfr; - if (stat (socket_name, &statbfr) == -1) + if (stat (name, &statbfr) == -1) return 2; if (statbfr.st_uid != geteuid ()) @@ -1097,7 +1116,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 +1131,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 +1157,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 +1181,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 +1201,7 @@ init_signals (void) } -HSOCKET +static HSOCKET set_local_socket (void) { HSOCKET s; @@ -1205,7 +1224,7 @@ set_local_socket (void) int default_sock = !socket_name; int saved_errno = 0; const char *server_name = "server"; - const char *tmpdir; + const char *tmpdir IF_LINT ( = NULL); if (socket_name && !strchr (socket_name, '/') && !strchr (socket_name, '\\')) @@ -1260,10 +1279,10 @@ set_local_socket (void) associated with the name. This is reminiscent of the logic that init_editfns uses to set the global Vuser_full_name. */ - char *user_name = (char *) egetenv ("LOGNAME"); + const char *user_name = egetenv ("LOGNAME"); if (!user_name) - user_name = (char *) egetenv ("USER"); + user_name = egetenv ("USER"); if (user_name) { @@ -1331,7 +1350,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 +1466,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 @@ -1483,8 +1502,8 @@ start_daemon_and_retry_set_socket (void) else { char emacs[] = "emacs"; - char daemon[] = "--daemon"; - char *d_argv[] = {emacs, daemon, 0 }; + char daemon_option[] = "--daemon"; + char *d_argv[] = {emacs, daemon_option, 0 }; if (socket_name != NULL) { /* Pass --daemon=socket_name as argument. */ @@ -1504,10 +1523,12 @@ start_daemon_and_retry_set_socket (void) int main (int argc, char **argv) { - int i, rl, needlf = 0; + int rl, needlf = 0; char *cwd, *str; char string[BUFSIZ+1]; - int null_socket_name, null_server_file, start_daemon_if_needed; + int null_socket_name IF_LINT ( = 0); + int null_server_file IF_LINT ( = 0); + int start_daemon_if_needed; int exit_status = EXIT_SUCCESS; main_argv = argv; @@ -1543,21 +1564,21 @@ main (int argc, char **argv) null_server_file = (server_file == NULL); } - if ((emacs_socket = set_socket (alternate_editor - || start_daemon_if_needed)) == INVALID_SOCKET) - if (start_daemon_if_needed) - { - /* Reset socket_name and server_file if they were NULL - before the set_socket call. */ - if (null_socket_name) - socket_name = NULL; - if (null_server_file) - server_file = NULL; - - start_daemon_and_retry_set_socket (); - } - else - fail (); + emacs_socket = set_socket (alternate_editor || start_daemon_if_needed); + if (emacs_socket == INVALID_SOCKET) + { + if (! start_daemon_if_needed) + fail (); + + /* Reset socket_name and server_file if they were NULL + before the set_socket call. */ + if (null_socket_name) + socket_name = NULL; + if (null_server_file) + server_file = NULL; + + start_daemon_and_retry_set_socket (); + } cwd = get_current_dir_name (); if (cwd == 0) @@ -1615,7 +1636,7 @@ main (int argc, char **argv) frame is available. */ if (tty || (current_frame && !eval)) { - char *tty_type, *tty_name; + const char *tty_type, *tty_name; if (find_tty (&tty_type, &tty_name, !tty)) { @@ -1635,6 +1656,7 @@ main (int argc, char **argv) if ((argc - optind > 0)) { + int i; for (i = optind; i < argc; i++) { @@ -1699,7 +1721,7 @@ main (int argc, char **argv) send_to_emacs (emacs_socket, "\n"); /* Wait for an answer. */ - if (!eval && !tty && !nowait) + if (!eval && !tty && !nowait && !quiet) { printf ("Waiting for Emacs..."); needlf = 2; @@ -1722,7 +1744,7 @@ main (int argc, char **argv) if (rl <= 0) break; - + string[rl] = '\0'; p = string + strlen (string) - 1; diff --git a/lib-src/etags.c b/lib-src/etags.c index 9471c0fe29f..385e4cc9721 100644 --- a/lib-src/etags.c +++ b/lib-src/etags.c @@ -190,10 +190,6 @@ char pot_etags_version[] = "@(#) pot revision number is 17.38.1.4"; # define assert(x) ((void) 0) #endif -#if !defined (S_ISREG) && defined (S_IFREG) -# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) -#endif - #ifdef NO_LONG_OPTIONS /* define this if you don't have GNU getopt */ # define NO_LONG_OPTIONS TRUE # define getopt_long(argc,argv,optstr,lopts,lind) getopt (argc, argv, optstr) @@ -243,7 +239,6 @@ If you want regular expression support, you should delete this notice and #define ISLOWER(c) islower (CHAR(c)) #define lowcase(c) tolower (CHAR(c)) -#define upcase(c) toupper (CHAR(c)) /* @@ -5327,7 +5322,7 @@ prolog_skip_comment (linebuffer *plb, FILE *inf) */ static int prolog_pr (char *s, char *last) - + /* Name of last clause. */ { int pos; @@ -5484,7 +5479,7 @@ Erlang_functions (FILE *inf) */ static int erlang_func (char *s, char *last) - + /* Name of last clause. */ { int pos; @@ -6642,7 +6637,7 @@ filename_is_absolute (char *fn) ); } -/* Upcase DOS drive letter and collapse separators into single slashes. +/* Downcase DOS drive letter and collapse separators into single slashes. Works in place. */ static void canonicalize_filename (register char *fn) @@ -6652,8 +6647,9 @@ canonicalize_filename (register char *fn) #ifdef DOS_NT /* Canonicalize drive letter case. */ - if (fn[0] != '\0' && fn[1] == ':' && ISLOWER (fn[0])) - fn[0] = upcase (fn[0]); +# define ISUPPER(c) isupper (CHAR(c)) + if (fn[0] != '\0' && fn[1] == ':' && ISUPPER (fn[0])) + fn[0] = lowcase (fn[0]); sep = '\\'; #endif diff --git a/lib-src/fakemail.c b/lib-src/fakemail.c index 4289e009e44..780a104b405 100644 --- a/lib-src/fakemail.c +++ b/lib-src/fakemail.c @@ -62,6 +62,8 @@ main () /* This is to declare cuserid. */ #include <unistd.h> + +#include <ignore-value.h> /* Type definitions */ @@ -198,7 +200,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 +210,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 +245,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 +270,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 +287,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 +343,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 +387,7 @@ make_file_preface (void) return result; } -void +static void write_line_list (register line_list the_list, FILE *the_stream) { for ( ; @@ -398,20 +400,20 @@ write_line_list (register line_list the_list, FILE *the_stream) return; } -int +static int close_the_streams (void) { register stream_list rem; for (rem = the_streams; rem != ((stream_list) NULL); rem = rem->rest_streams) - no_problems = (no_problems && - ((*rem->action) (rem->handle) == 0)); + if (no_problems && (*rem->action) (rem->handle) != 0) + error ("output error", NULL); the_streams = ((stream_list) NULL); 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,15 +424,17 @@ add_a_stream (FILE *the_stream, int (*closing_action) (FILE *)) return; } -int +static int my_fclose (FILE *the_file) { putc ('\n', the_file); fflush (the_file); + if (ferror (the_file)) + return EOF; return fclose (the_file); } -boolean +static boolean open_a_file (char *name) { FILE *the_stream = fopen (name, "a"); @@ -445,7 +449,7 @@ open_a_file (char *name) return false; } -void +static void put_string (char *s) { register stream_list rem; @@ -456,7 +460,7 @@ put_string (char *s) return; } -void +static void put_line (const char *string) { register stream_list rem; @@ -496,7 +500,7 @@ put_line (const char *string) } } /* Output that much, then break the line. */ - fwrite (s, 1, breakpos - s, rem->handle); + ignore_value (fwrite (s, 1, breakpos - s, rem->handle)); column = 8; /* Skip whitespace and prepare to print more addresses. */ @@ -516,7 +520,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 +556,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 +587,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 +619,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 +673,7 @@ read_header (void) return the_header->next; } -void +static void write_header (header the_header) { register header old = the_header; @@ -729,6 +733,9 @@ main (int argc, char **argv) put_string (buf); } + if (no_problems && (ferror (stdin) || fclose (stdin) != 0)) + error ("input error", NULL); + exit (close_the_streams ()); } diff --git a/lib-src/make-docfile.c b/lib-src/make-docfile.c index 1f370555051..f900ea42e91 100644 --- a/lib-src/make-docfile.c +++ b/lib-src/make-docfile.c @@ -66,12 +66,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #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 input_buffer[128]; /* Some state during the execution of `read_c_string_or_comment'. */ struct rcsoc_state @@ -388,14 +388,14 @@ 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; struct rcsoc_state state; state.in_file = infile; - state.buf_ptr = (printflag < 0 ? buf : 0); + state.buf_ptr = (printflag < 0 ? input_buffer : 0); state.out_file = (printflag > 0 ? outfile : 0); state.pending_spaces = 0; state.pending_newlines = 0; @@ -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,14 +610,14 @@ compare_globals (const void *a, const void *b) return strcmp (ga->name, gb->name); } -void +static void write_globals (void) { int i; qsort (globals, num_globals, sizeof (struct global), compare_globals); for (i = 0; i < num_globals; ++i) { - char *type; + char const *type; switch (globals[i].type) { @@ -652,18 +652,14 @@ 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; register int c; register int commas; - register int defunflag; - register int defvarperbufferflag; - register int defvarflag; int minargs, maxargs; int extension = filename[strlen (filename) - 1]; - enum global_type type; if (extension == 'o') filename[strlen (filename) - 1] = 'c'; @@ -693,6 +689,10 @@ scan_c_file (char *filename, const char *mode) while (!feof (infile)) { int doc_keyword = 0; + int defunflag = 0; + int defvarperbufferflag = 0; + int defvarflag = 0; + enum global_type type = INVALID; if (c != '\n' && c != '\r') { @@ -726,7 +726,6 @@ scan_c_file (char *filename, const char *mode) continue; defvarflag = 1; - defunflag = 0; c = getc (infile); defvarperbufferflag = (c == 'P'); @@ -738,8 +737,6 @@ scan_c_file (char *filename, const char *mode) type = LISP_OBJECT; else if (c == 'B') type = BOOLEAN; - else - type = INVALID; } c = getc (infile); @@ -758,8 +755,6 @@ scan_c_file (char *filename, const char *mode) continue; c = getc (infile); defunflag = c == 'U'; - defvarflag = 0; - defvarperbufferflag = 0; } else continue; @@ -795,15 +790,15 @@ scan_c_file (char *filename, const char *mode) /* Read in the identifier. */ do { - buf[i++] = c; + input_buffer[i++] = c; c = getc (infile); } while (! (c == ',' || c == ' ' || c == '\t' || c == '\n' || c == '\r')); - buf[i] = '\0'; + input_buffer[i] = '\0'; name = xmalloc (i + 1); - memcpy (name, buf, i + 1); + memcpy (name, input_buffer, i + 1); add_global (type, name); continue; } @@ -888,7 +883,7 @@ scan_c_file (char *filename, const char *mode) putc (037, outfile); putc (defvarflag ? 'V' : 'F', outfile); - fprintf (outfile, "%s\n", buf); + fprintf (outfile, "%s\n", input_buffer); if (comment) getc (infile); /* Skip past `*' */ @@ -931,11 +926,12 @@ scan_c_file (char *filename, const char *mode) *p = '\0'; /* Output them. */ fprintf (outfile, "\n\n"); - write_c_args (outfile, buf, argbuf, minargs, maxargs); + write_c_args (outfile, input_buffer, argbuf, minargs, maxargs); } else if (defunflag && maxargs == -1 && !saw_usage) /* The DOC should provide the usage form. */ - fprintf (stderr, "Missing `usage' for function `%s'.\n", buf); + fprintf (stderr, "Missing `usage' for function `%s'.\n", + input_buffer); } } eof: @@ -979,7 +975,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 +984,7 @@ skip_white (FILE *infile) ungetc (c, infile); } -void +static void read_lisp_symbol (FILE *infile, char *buffer) { char c; @@ -1016,7 +1012,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/makefile.w32-in b/lib-src/makefile.w32-in index bc7b1b27baf..f09ede06900 100644 --- a/lib-src/makefile.w32-in +++ b/lib-src/makefile.w32-in @@ -135,7 +135,7 @@ obj = dosfns.o msdos.o \ cm.o term.o terminal.o xfaces.o \ emacs.o keyboard.o macros.o keymap.o sysdep.o \ buffer.o filelock.o insdel.o marker.o \ - minibuf.o fileio.o dired.o filemode.o \ + minibuf.o fileio.o dired.o \ cmds.o casetab.o casefiddle.o indent.o search.o regex.o undo.o \ alloc.o data.o doc.o editfns.o callint.o \ eval.o floatfns.o fns.o print.o lread.o \ @@ -381,6 +381,13 @@ $(BLD)/ctags.$(O) : \ $(SRC)/ntlib.h \ $(EMACS_ROOT)/lib/getopt.h +$(BLD)/ebrowse.$(O) : \ + $(SRC)/ebrowse.c \ + $(EMACS_ROOT)/lib/min-max.h \ + $(EMACS_ROOT)/src/s/ms-w32.h \ + $(EMACS_ROOT)/src/m/intel386.h \ + $(EMACS_ROOT)/lib-src/../src/config.h + $(BLD)/emacsclient.$(O) : \ $(SRC)/emacsclient.c \ $(EMACS_ROOT)/nt/inc/sys/stat.h \ @@ -447,6 +454,7 @@ $(BLD)/ntlib.$(O) : \ $(BLD)/pop.$(O) : \ $(SRC)/pop.c \ $(SRC)/pop.h \ + $(EMACS_ROOT)/lib/min-max.h \ $(SRC)/ntlib.h $(BLD)/profile.$(O) : \ diff --git a/lib-src/movemail.c b/lib-src/movemail.c index 682aa10aa39..4a894c1cba1 100644 --- a/lib-src/movemail.c +++ b/lib-src/movemail.c @@ -80,13 +80,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #undef access #endif /* MSDOS */ -#ifndef DIRECTORY_SEP -#define DIRECTORY_SEP '/' -#endif -#ifndef IS_DIRECTORY_SEP -#define IS_DIRECTORY_SEP(_c_) ((_c_) == DIRECTORY_SEP) -#endif - #ifdef WINDOWSNT #include "ntlib.h" #undef access @@ -161,7 +154,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) @@ -169,7 +162,7 @@ main (int argc, char **argv) char *inname, *outname; int indesc, outdesc; ssize_t nread; - int status; + int wait_status; int c, preserve_mail = 0; #ifndef MAIL_USE_SYSTEM_LOCK @@ -269,6 +262,13 @@ main (int argc, char **argv) if (! spool_name) #endif { + #ifndef DIRECTORY_SEP + #define DIRECTORY_SEP '/' + #endif + #ifndef IS_DIRECTORY_SEP + #define IS_DIRECTORY_SEP(_c_) ((_c_) == DIRECTORY_SEP) + #endif + /* Use a lock file named after our first argument with .lock appended: If it exists, the mail file is locked. */ /* Note: this locking mechanism is *required* by the mailer @@ -527,11 +527,11 @@ main (int argc, char **argv) exit (EXIT_SUCCESS); } - wait (&status); - if (!WIFEXITED (status)) + wait (&wait_status); + if (!WIFEXITED (wait_status)) exit (EXIT_FAILURE); - else if (WRETCODE (status) != 0) - exit (WRETCODE (status)); + else if (WRETCODE (wait_status) != 0) + exit (WRETCODE (wait_status)); #if !defined (MAIL_USE_MMDF) && !defined (MAIL_USE_SYSTEM_LOCK) #ifdef MAIL_USE_MAILLOCK @@ -670,14 +670,8 @@ xmalloc (unsigned int size) #define NOTOK (-1) #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 Errmsg[200]; /* POP errors, at least, can exceed the original length of 80. */ /* @@ -736,7 +730,18 @@ popmail (char *mailbox, char *outfile, int preserve, char *password, int reverse error ("Error in open: %s, %s", strerror (errno), outfile); return EXIT_FAILURE; } - fchown (mbfi, getuid (), -1); + + if (fchown (mbfi, getuid (), -1) != 0) + { + int fchown_errno = errno; + struct stat st; + if (fstat (mbfi, &st) != 0 || st.st_uid != getuid ()) + { + pop_close (server); + error ("Error in fchown: %s, %s", strerror (fchown_errno), outfile); + return EXIT_FAILURE; + } + } if ((mbf = fdopen (mbfi, "wb")) == NULL) { @@ -828,10 +833,10 @@ pop_retr (popserver server, int msgno, FILE *arg) if (pop_retrieve_first (server, msgno, &line)) { - char *error = concat ("Error from POP server: ", pop_error, ""); - strncpy (Errmsg, error, sizeof (Errmsg)); + char *msg = concat ("Error from POP server: ", pop_error, ""); + strncpy (Errmsg, msg, sizeof (Errmsg)); Errmsg[sizeof (Errmsg)-1] = '\0'; - free(error); + free (msg); return (NOTOK); } @@ -850,27 +855,26 @@ pop_retr (popserver server, int msgno, FILE *arg) if (ret) { - char *error = concat ("Error from POP server: ", pop_error, ""); - strncpy (Errmsg, error, sizeof (Errmsg)); + char *msg = concat ("Error from POP server: ", pop_error, ""); + strncpy (Errmsg, msg, sizeof (Errmsg)); Errmsg[sizeof (Errmsg)-1] = '\0'; - free(error); + free (msg); return (NOTOK); } return (OK); } -/* Do this as a macro instead of using strcmp to save on execution time. */ -#define IS_FROM_LINE(a) ((a[0] == 'F') \ - && (a[1] == 'r') \ - && (a[2] == 'o') \ - && (a[3] == 'm') \ - && (a[4] == ' ')) - static int mbx_write (char *line, int len, FILE *mbf) { #ifdef MOVEMAIL_QUOTE_POP_FROM_LINES + /* Do this as a macro instead of using strcmp to save on execution time. */ + # define IS_FROM_LINE(a) ((a[0] == 'F') \ + && (a[1] == 'r') \ + && (a[2] == 'o') \ + && (a[3] == 'm') \ + && (a[4] == ' ')) if (IS_FROM_LINE (line)) { if (fputc ('>', mbf) == EOF) diff --git a/lib-src/pop.c b/lib-src/pop.c index a3fda09d44f..426b39bd1fb 100644 --- a/lib-src/pop.c +++ b/lib-src/pop.c @@ -67,7 +67,6 @@ extern struct servent *hes_getservbyname (/* char *, char * */); #include <stdio.h> #ifdef STDC_HEADERS #include <string.h> -#define index strchr #endif #include <unistd.h> @@ -91,6 +90,8 @@ extern struct servent *hes_getservbyname (/* char *, char * */); # endif #endif /* KERBEROS */ +#include <min-max.h> + #ifdef KERBEROS #ifndef KERBEROS5 extern int krb_sendauth (/* long, int, KTEXT, char *, char *, char *, @@ -122,19 +123,15 @@ static char *find_crlf (char *, int); to be bigger than the original value of 80 */ #define POP_PORT 110 -#define KPOP_PORT 1109 #define POP_SERVICE "pop3" /* we don't want the POP2 port! */ #ifdef KERBEROS +#define KPOP_PORT 1109 #define KPOP_SERVICE "kpop" /* never used: look for 20060515 to see why */ #endif char pop_error[ERROR_MAX]; int pop_debug = 0; -#ifndef min -#define min(a,b) (((a) < (b)) ? (a) : (b)) -#endif - /* * Function: pop_open (char *host, char *username, char *password, * int flags) diff --git a/lib-src/profile.c b/lib-src/profile.c index 9ce9993f4b1..086d8cc3e9d 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 <seconds>.<micro-seconds> 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 acfb147325b..5ad19201118 100644 --- a/lib-src/test-distrib.c +++ b/lib-src/test-distrib.c @@ -26,18 +26,16 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ /* 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]; - /* 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; @@ -57,6 +55,7 @@ int main (int argc, char **argv) { int fd; + char buf[300]; if (argc != 2) { diff --git a/lib-src/update-game-score.c b/lib-src/update-game-score.c index 9466bf7b149..70b79a64f91 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 <http://www.gnu.org/licenses/>. */ 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; |