aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src
diff options
context:
space:
mode:
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/ChangeLog121
-rw-r--r--lib-src/Makefile.in6
-rw-r--r--lib-src/ebrowse.c263
-rw-r--r--lib-src/emacsclient.c180
-rw-r--r--lib-src/etags.c16
-rw-r--r--lib-src/fakemail.c49
-rw-r--r--lib-src/make-docfile.c72
-rw-r--r--lib-src/makefile.w32-in10
-rw-r--r--lib-src/movemail.c74
-rw-r--r--lib-src/pop.c9
-rw-r--r--lib-src/profile.c4
-rw-r--r--lib-src/test-distrib.c9
-rw-r--r--lib-src/update-game-score.c50
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 @@
12011-03-03 Drake Wilson <drake@begriffli.ch> (tiny change)
2
3 * emacsclient.c (longopts): Add quiet.
4 (decode_options): Handle q/quiet.
5 (print_help_and_exit): Add q/quiet.
6 (main): Suppress some messages if quiet option is used.
7
82011-02-26 Eli Zaretskii <eliz@gnu.org>
9
10 * Makefile.in (fakemail${EXEEXT}): Depend on lib/ignore-value.h.
11
12 * emacsclient.c (xstrdup) [WINDOWSNT]: Function added back.
13 (w32_getenv): Use xstrdup to return all values in malloc'ed
14 storage.
15
162011-02-26 Paul Eggert <eggert@cs.ucla.edu>
17
18 * ebrowse.c (parse_qualified_param_ident_or_type): Make it clear
19 to reader (and to the compiler) that the loop always executes at
20 least once. This prevents a warning with recent GCC.
21 (BROWSE_STRUCT): Remove unused macro.
22
23 * fakemail.c: Include <ignore-value.h>.
24 (put_line): Explicitly ignore fwrite return value, for benefit of
25 recent glibc + gcc.
26 (close_the_streams): Diagnose output errors instead of merely
27 exiting with nonzero status.
28 (my_fclose, main): Diagnose input errors, and exit with nonzero status.
29 Formerly, input errors were silently ignored.
30
31 * ebrowse.c (putstr): Rename from PUTSTR and turn into a function.
32 All callers changed. This is cleaner, and avoids GCC warnings about
33 passing NULL to fputs.
34 (insert_keyword): Rename parameter to avoid shadowing diagnostic.
35
362011-02-25 Paul Eggert <eggert@cs.ucla.edu>
37
38 * emacsclient.c (main): Avoid dangling 'if'.
39 (xstrdup): Remove; no longer needed.
40 (get_current_dir_name, w32_getenv, get_server_config, find_tty):
41 (set_local_socket, main):
42 Use const char *, not char *, for pointers that are not assigned
43 through.
44 (IF_LINT): New macro.
45 (set_local_socket, main): Use it to suppress warnings with
46 GCC -Wuninitialized.
47
48 * emacsclient.c: Redo local variables to avoid shadowing problems.
49 (message, socket_status, start_daemon_and_retry_set_socket):
50 Rename locals.
51 (main): Move decl of "i".
52
53 * etags.c (ISUPPER): Move to inside the only #ifdef where it's used.
54 This avoids an unused-macro warning with some GCC settings.
55
56 * make-docfile.c (write_globals): Change char * to char const *
57 to avoid a GCC "assignment discards qualifiers" diagnostic
58 in some configurations.
59 (scan_c_file): Refactor local variable decls to make their scope
60 more accurate and to avoid a GCC -Wuninitialized diagnostic.
61
622011-02-22 Eli Zaretskii <eliz@gnu.org>
63
64 * etags.c (canonicalize_filename, ISUPPER): Fix last change.
65
66 * makefile.w32-in ($(BLD)/ebrowse.$(O), $(BLD)/pop.$(O)): Depend
67 on ../lib/min-max.h.
68
692011-02-22 Paul Eggert <eggert@cs.ucla.edu>
70
71 etags: Downcase drive letters, for consistency with Emacs proper.
72 * etags.c (upcase): Remove; no longer used.
73 (canonicalize_filename): Downcase drive letters.
74
75 Assume S_ISLNK etc. work, since gnulib supports this.
76 * etags.c (S_ISREG): Remove.
77
782011-02-22 Paul Eggert <eggert@cs.ucla.edu>
79
80 Assume S_ISLNK etc. work, since gnulib supports this.
81 * etags.c (S_ISREG): Remove.
82
832011-02-22 Juanma Barranquero <lekktu@gmail.com>
84
85 * makefile.w32-in (obj): Remove filemode.o.
86
872011-02-21 Paul Eggert <eggert@cs.ucla.edu>
88
89 New file "lib/min-max.h".
90 * ebrowse.c (min, max): Define them by including <min-max.h>
91 instead of defining it ourselves.
92 * pop.c (min): Likewise.
93 * Makefile.in (ebrowse${EXEEXT}, pop.o): Depend on min-max.h.
94
95 * movemail.c (popmail): Report fchown failure instead of ignoring it.
96 But if the file already has the right ownership, don't worry about it.
97
98 * make-docfile.c (input_buffer): Rename variables to avoid shadowing.
99 * test-distrib.c (buf): Make this local, to avoid shadowing.
100
101 * movemail.c (main, pop_retr): Rename locals to avoid shadowing.
102 (progname, sfi, sfo, ibuffer, obuffer): Remove unused vars.
103 (DONE): Remove unused macro.
104 (DIRECTORY_SEP, IS_DIRECTORY_SEP, IS_FROM_LINE):
105 Define these macros only in the contexts that need them.
106 * pop.c (index): Remove unused macro.
107 (KPOP_PORT): Define only if KERBEROS is defined.
108
109 Declare file-scope functions and variables static if not exported.
110 This is more consistent, and is nicer with gcc -Wstrict-prototypes.
111 * ebrowse.c, emacsclient.c, fakemail.c, make-docfile.c, movemail.c:
112 * profile.c, test-distrib.c, update-game-score.c:
113 Declare non-'main' functions and variables to be static.
114 * ebrowse.c: Omit redundant function prototypes.
115
12011-02-21 Eli Zaretskii <eliz@gnu.org> 1162011-02-21 Eli Zaretskii <eliz@gnu.org>
2 117
3 * makefile.w32-in ($(BLD)/ctags.$(O), $(BLD)/emacsclient.$(O)) 118 * makefile.w32-in ($(BLD)/ctags.$(O), $(BLD)/emacsclient.$(O))
@@ -39,7 +154,7 @@
39 154
402011-02-05 Paul Eggert <eggert@cs.ucla.edu> 1552011-02-05 Paul Eggert <eggert@cs.ucla.edu>
41 156
42 * emacsclient.c: conform to C89 pointer rules 157 * emacsclient.c: Conform to C89 pointer rules.
43 (file_name_absolute_p): Accept const char *, not const unsigned 158 (file_name_absolute_p): Accept const char *, not const unsigned
44 char *, to satisfy C89 rules. 159 char *, to satisfy C89 rules.
45 160
@@ -197,7 +312,7 @@
197 * test-distrib.c (cool_read): 312 * test-distrib.c (cool_read):
198 * movemail.c (main, concat): 313 * movemail.c (main, concat):
199 * make-docfile.c (scan_file, write_c_args): 314 * make-docfile.c (scan_file, write_c_args):
200 * emacsclient.c (get_server_config): Fix -Wconversion warning. 315 * emacsclient.c (get_server_config): Fix -Wconversion warning.
201 (egetenv): Move conditional definition earlier. 316 (egetenv): Move conditional definition earlier.
202 (progname): Use const. 317 (progname): Use const.
203 * sorted-doc.c (xstrdup): Use const. 318 * sorted-doc.c (xstrdup): Use const.
@@ -557,7 +672,7 @@
557 autoconf, not cpp. 672 autoconf, not cpp.
558 (ALL_CFLAGS): Use them as make variables. 673 (ALL_CFLAGS): Use them as make variables.
559 674
5602010-04-07 Christoph <cschol2112@googlemail.com> (tiny change) 6752010-04-07 Christoph Scholtes <cschol2112@googlemail.com>
561 676
562 * makefile.w32-in (OTHER_PLATFORM_SUPPORT): Use parenthesis 677 * makefile.w32-in (OTHER_PLATFORM_SUPPORT): Use parenthesis
563 for macros for nmake compatibility. 678 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
325 -DVERSION="\"${version}\"" ${srcdir}/etags.c \ 325 -DVERSION="\"${version}\"" ${srcdir}/etags.c \
326 $(REGEXPOBJ) $(LOADLIBES) -o etags 326 $(REGEXPOBJ) $(LOADLIBES) -o etags
327 327
328ebrowse${EXEEXT}: ${srcdir}/ebrowse.c ../src/config.h 328ebrowse${EXEEXT}: ${srcdir}/ebrowse.c ${srcdir}/../lib/min-max.h ../src/config.h
329 $(CC) ${ALL_CFLAGS} -DVERSION="\"${version}\"" \ 329 $(CC) ${ALL_CFLAGS} -DVERSION="\"${version}\"" \
330 ${srcdir}/ebrowse.c $(LOADLIBES) -o ebrowse 330 ${srcdir}/ebrowse.c $(LOADLIBES) -o ebrowse
331 331
@@ -350,10 +350,10 @@ movemail${EXEEXT}: movemail.o pop.o
350movemail.o: ${srcdir}/movemail.c ../src/config.h 350movemail.o: ${srcdir}/movemail.c ../src/config.h
351 $(CC) -c ${CPP_CFLAGS} ${MOVE_FLAGS} ${srcdir}/movemail.c 351 $(CC) -c ${CPP_CFLAGS} ${MOVE_FLAGS} ${srcdir}/movemail.c
352 352
353pop.o: ${srcdir}/pop.c ../src/config.h 353pop.o: ${srcdir}/pop.c ${srcdir}/../lib/min-max.h ../src/config.h
354 $(CC) -c ${CPP_CFLAGS} ${MOVE_FLAGS} ${srcdir}/pop.c 354 $(CC) -c ${CPP_CFLAGS} ${MOVE_FLAGS} ${srcdir}/pop.c
355 355
356fakemail${EXEEXT}: ${srcdir}/fakemail.c ../src/config.h 356fakemail${EXEEXT}: ${srcdir}/fakemail.c ${srcdir}/../lib/ignore-value.h ../src/config.h
357 $(CC) ${ALL_CFLAGS} ${srcdir}/fakemail.c $(LOADLIBES) -o fakemail 357 $(CC) ${ALL_CFLAGS} ${srcdir}/fakemail.c $(LOADLIBES) -o fakemail
358 358
359emacsclient${EXEEXT}: ${srcdir}/emacsclient.c ../src/config.h 359emacsclient${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/>. */
41 41
42#define streq(X, Y) (*(X) == *(Y) && strcmp ((X) + 1, (Y) + 1) == 0) 42#define streq(X, Y) (*(X) == *(Y) && strcmp ((X) + 1, (Y) + 1) == 0)
43 43
44/* The ubiquitous `max' and `min' macros. */ 44#include <min-max.h>
45
46#ifndef max
47#define max(X, Y) ((X) > (Y) ? (X) : (Y))
48#define min(X, Y) ((X) < (Y) ? (X) : (Y))
49#endif
50 45
51/* Files are read in chunks of this number of bytes. */ 46/* Files are read in chunks of this number of bytes. */
52 47
@@ -82,7 +77,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
82#define TREE_HEADER_STRUCT "[ebrowse-hs " 77#define TREE_HEADER_STRUCT "[ebrowse-hs "
83#define TREE_STRUCT "[ebrowse-ts " 78#define TREE_STRUCT "[ebrowse-ts "
84#define MEMBER_STRUCT "[ebrowse-ms " 79#define MEMBER_STRUCT "[ebrowse-ms "
85#define BROWSE_STRUCT "[ebrowse-bs "
86#define CLASS_STRUCT "[ebrowse-cs " 80#define CLASS_STRUCT "[ebrowse-cs "
87 81
88/* The name of the symbol table entry for global functions, variables, 82/* The name of the symbol table entry for global functions, variables,
@@ -465,59 +459,16 @@ struct search_path *search_path_tail;
465 459
466/* Function prototypes. */ 460/* Function prototypes. */
467 461
468int yylex (void); 462static char *matching_regexp (void);
469void yyparse (void); 463static struct sym *add_sym (const char *, struct sym *);
470void re_init_parser (void); 464static void add_global_defn (char *, char *, int, unsigned, int, int, int);
471const char *token_string (int); 465static void add_global_decl (char *, char *, int, unsigned, int, int, int);
472char *matching_regexp (void); 466static struct member *add_member (struct sym *, char *, int, int, unsigned);
473void init_sym (void); 467static void class_definition (struct sym *, int, int, int);
474struct sym *add_sym (const char *, struct sym *); 468static char *operator_name (int *);
475void add_link (struct sym *, struct sym *); 469static void parse_qualified_param_ident_or_type (char **);
476void add_member_defn (struct sym *, char *, char *, 470static void usage (int) NO_RETURN;
477 int, unsigned, int, int, int); 471static void version (void) NO_RETURN;
478void add_member_decl (struct sym *, char *, char *, int,
479 unsigned, int, int, int, int);
480void dump_roots (FILE *);
481void *xmalloc (int);
482void xfree (void *);
483void add_global_defn (char *, char *, int, unsigned, int, int, int);
484void add_global_decl (char *, char *, int, unsigned, int, int, int);
485void add_define (char *, char *, int);
486void mark_inherited_virtual (void);
487void leave_namespace (void);
488void enter_namespace (char *);
489void register_namespace_alias (char *, struct link *);
490void insert_keyword (const char *, int);
491void re_init_scanner (void);
492void init_scanner (void);
493void process_file (char *);
494void add_search_path (char *);
495FILE *open_file (char *);
496int process_pp_line (void);
497int dump_members (FILE *, struct member *);
498void dump_sym (FILE *, struct sym *);
499int dump_tree (FILE *, struct sym *);
500struct member *find_member (struct sym *, char *, int, int, unsigned);
501struct member *add_member (struct sym *, char *, int, int, unsigned);
502void mark_virtual (struct sym *);
503struct sym *make_namespace (char *, struct sym *);
504char *sym_scope (struct sym *);
505char *sym_scope_1 (struct sym *);
506int skip_to (int);
507void skip_matching (void);
508void member (struct sym *, int);
509void class_body (struct sym *, int);
510void class_definition (struct sym *, int, int, int);
511void declaration (int);
512unsigned parm_list (int *);
513char *operator_name (int *);
514struct sym *parse_classname (void);
515struct sym *parse_qualified_ident_or_type (char **);
516void parse_qualified_param_ident_or_type (char **);
517int globals (int);
518void yyerror (const char *, const char *);
519void usage (int) NO_RETURN;
520void version (void) NO_RETURN;
521 472
522 473
523 474
@@ -528,7 +479,7 @@ void version (void) NO_RETURN;
528/* Print an error in a printf-like style with the current input file 479/* Print an error in a printf-like style with the current input file
529 name and line number. */ 480 name and line number. */
530 481
531void 482static void
532yyerror (const char *format, const char *s) 483yyerror (const char *format, const char *s)
533{ 484{
534 fprintf (stderr, "%s:%d: ", filename, yyline); 485 fprintf (stderr, "%s:%d: ", filename, yyline);
@@ -540,7 +491,7 @@ yyerror (const char *format, const char *s)
540/* Like malloc but print an error and exit if not enough memory is 491/* Like malloc but print an error and exit if not enough memory is
541 available. */ 492 available. */
542 493
543void * 494static void *
544xmalloc (int nbytes) 495xmalloc (int nbytes)
545{ 496{
546 void *p = malloc (nbytes); 497 void *p = malloc (nbytes);
@@ -555,7 +506,7 @@ xmalloc (int nbytes)
555 506
556/* Like realloc but print an error and exit if out of memory. */ 507/* Like realloc but print an error and exit if out of memory. */
557 508
558void * 509static void *
559xrealloc (void *p, int sz) 510xrealloc (void *p, int sz)
560{ 511{
561 p = realloc (p, sz); 512 p = realloc (p, sz);
@@ -571,7 +522,7 @@ xrealloc (void *p, int sz)
571/* Like strdup, but print an error and exit if not enough memory is 522/* Like strdup, but print an error and exit if not enough memory is
572 available.. If S is null, return null. */ 523 available.. If S is null, return null. */
573 524
574char * 525static char *
575xstrdup (char *s) 526xstrdup (char *s)
576{ 527{
577 if (s) 528 if (s)
@@ -588,7 +539,7 @@ xstrdup (char *s)
588/* Initialize the symbol table. This currently only sets up the 539/* Initialize the symbol table. This currently only sets up the
589 special symbol for globals (`*Globals*'). */ 540 special symbol for globals (`*Globals*'). */
590 541
591void 542static void
592init_sym (void) 543init_sym (void)
593{ 544{
594 global_symbols = add_sym (GLOBALS_NAME, NULL); 545 global_symbols = add_sym (GLOBALS_NAME, NULL);
@@ -602,7 +553,7 @@ init_sym (void)
602 If a symbol for NAME already exists, return that. Otherwise 553 If a symbol for NAME already exists, return that. Otherwise
603 create a new symbol and set it to default values. */ 554 create a new symbol and set it to default values. */
604 555
605struct sym * 556static struct sym *
606add_sym (const char *name, struct sym *nested_in_class) 557add_sym (const char *name, struct sym *nested_in_class)
607{ 558{
608 struct sym *sym; 559 struct sym *sym;
@@ -643,7 +594,7 @@ add_sym (const char *name, struct sym *nested_in_class)
643 594
644/* Add links between superclass SUPER and subclass SUB. */ 595/* Add links between superclass SUPER and subclass SUB. */
645 596
646void 597static void
647add_link (struct sym *super, struct sym *sub) 598add_link (struct sym *super, struct sym *sub)
648{ 599{
649 struct link *lnk, *lnk2, *p, *prev; 600 struct link *lnk, *lnk2, *p, *prev;
@@ -683,7 +634,7 @@ add_link (struct sym *super, struct sym *sub)
683 parameter types of functions. Value is a pointer to the member 634 parameter types of functions. Value is a pointer to the member
684 found or null if not found. */ 635 found or null if not found. */
685 636
686struct member * 637static struct member *
687find_member (struct sym *cls, char *name, int var, int sc, unsigned int hash) 638find_member (struct sym *cls, char *name, int var, int sc, unsigned int hash)
688{ 639{
689 struct member **list; 640 struct member **list;
@@ -733,7 +684,7 @@ find_member (struct sym *cls, char *name, int var, int sc, unsigned int hash)
733 a bit set giving additional information about the member (see the 684 a bit set giving additional information about the member (see the
734 F_* defines). */ 685 F_* defines). */
735 686
736void 687static void
737add_member_decl (struct sym *cls, char *name, char *regexp, int pos, unsigned int hash, int var, int sc, int vis, int flags) 688add_member_decl (struct sym *cls, char *name, char *regexp, int pos, unsigned int hash, int var, int sc, int vis, int flags)
738{ 689{
739 struct member *m; 690 struct member *m;
@@ -781,7 +732,7 @@ add_member_decl (struct sym *cls, char *name, char *regexp, int pos, unsigned in
781 a bit set giving additional information about the member (see the 732 a bit set giving additional information about the member (see the
782 F_* defines). */ 733 F_* defines). */
783 734
784void 735static void
785add_member_defn (struct sym *cls, char *name, char *regexp, int pos, unsigned int hash, int var, int sc, int flags) 736add_member_defn (struct sym *cls, char *name, char *regexp, int pos, unsigned int hash, int var, int sc, int flags)
786{ 737{
787 struct member *m; 738 struct member *m;
@@ -823,7 +774,7 @@ add_member_defn (struct sym *cls, char *name, char *regexp, int pos, unsigned in
823 REGEXP is a regular expression matching the define in the source, 774 REGEXP is a regular expression matching the define in the source,
824 if it is non-null. POS is the position in the file. */ 775 if it is non-null. POS is the position in the file. */
825 776
826void 777static void
827add_define (char *name, char *regexp, int pos) 778add_define (char *name, char *regexp, int pos)
828{ 779{
829 add_global_defn (name, regexp, pos, 0, 1, SC_FRIEND, F_DEFINE); 780 add_global_defn (name, regexp, pos, 0, 1, SC_FRIEND, F_DEFINE);
@@ -841,7 +792,7 @@ add_define (char *name, char *regexp, int pos)
841 a bit set giving additional information about the member (see the 792 a bit set giving additional information about the member (see the
842 F_* defines). */ 793 F_* defines). */
843 794
844void 795static void
845add_global_defn (char *name, char *regexp, int pos, unsigned int hash, int var, int sc, int flags) 796add_global_defn (char *name, char *regexp, int pos, unsigned int hash, int var, int sc, int flags)
846{ 797{
847 int i; 798 int i;
@@ -872,7 +823,7 @@ add_global_defn (char *name, char *regexp, int pos, unsigned int hash, int var,
872 a bit set giving additional information about the member (see the 823 a bit set giving additional information about the member (see the
873 F_* defines). */ 824 F_* defines). */
874 825
875void 826static void
876add_global_decl (char *name, char *regexp, int pos, unsigned int hash, int var, int sc, int flags) 827add_global_decl (char *name, char *regexp, int pos, unsigned int hash, int var, int sc, int flags)
877{ 828{
878 /* Add declaration only if not already declared. Header files must 829 /* 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,
911 member. HASH is a hash code for the parameter types of a function. 862 member. HASH is a hash code for the parameter types of a function.
912 Value is a pointer to the member's structure. */ 863 Value is a pointer to the member's structure. */
913 864
914struct member * 865static struct member *
915add_member (struct sym *cls, char *name, int var, int sc, unsigned int hash) 866add_member (struct sym *cls, char *name, int var, int sc, unsigned int hash)
916{ 867{
917 struct member *m = (struct member *) xmalloc (sizeof *m + strlen (name)); 868 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)
982 recursively, marking functions as virtual that are declared virtual 933 recursively, marking functions as virtual that are declared virtual
983 in base classes. */ 934 in base classes. */
984 935
985void 936static void
986mark_virtual (struct sym *r) 937mark_virtual (struct sym *r)
987{ 938{
988 struct link *p; 939 struct link *p;
@@ -1006,7 +957,7 @@ mark_virtual (struct sym *r)
1006/* For all roots of the class tree, mark functions as virtual that 957/* For all roots of the class tree, mark functions as virtual that
1007 are virtual because of a virtual declaration in a base class. */ 958 are virtual because of a virtual declaration in a base class. */
1008 959
1009void 960static void
1010mark_inherited_virtual (void) 961mark_inherited_virtual (void)
1011{ 962{
1012 struct sym *r; 963 struct sym *r;
@@ -1021,7 +972,7 @@ mark_inherited_virtual (void)
1021 972
1022/* Create and return a symbol for a namespace with name NAME. */ 973/* Create and return a symbol for a namespace with name NAME. */
1023 974
1024struct sym * 975static struct sym *
1025make_namespace (char *name, struct sym *context) 976make_namespace (char *name, struct sym *context)
1026{ 977{
1027 struct sym *s = (struct sym *) xmalloc (sizeof *s + strlen (name)); 978 struct sym *s = (struct sym *) xmalloc (sizeof *s + strlen (name));
@@ -1036,7 +987,7 @@ make_namespace (char *name, struct sym *context)
1036 987
1037/* Find the symbol for namespace NAME. If not found, retrun NULL */ 988/* Find the symbol for namespace NAME. If not found, retrun NULL */
1038 989
1039struct sym * 990static struct sym *
1040check_namespace (char *name, struct sym *context) 991check_namespace (char *name, struct sym *context)
1041{ 992{
1042 struct sym *p = NULL; 993 struct sym *p = NULL;
@@ -1053,7 +1004,7 @@ check_namespace (char *name, struct sym *context)
1053/* Find the symbol for namespace NAME. If not found, add a new symbol 1004/* Find the symbol for namespace NAME. If not found, add a new symbol
1054 for NAME to all_namespaces. */ 1005 for NAME to all_namespaces. */
1055 1006
1056struct sym * 1007static struct sym *
1057find_namespace (char *name, struct sym *context) 1008find_namespace (char *name, struct sym *context)
1058{ 1009{
1059 struct sym *p = check_namespace (name, context); 1010 struct sym *p = check_namespace (name, context);
@@ -1067,7 +1018,7 @@ find_namespace (char *name, struct sym *context)
1067 1018
1068/* Find namespace alias with name NAME. If not found return NULL. */ 1019/* Find namespace alias with name NAME. If not found return NULL. */
1069 1020
1070struct link * 1021static struct link *
1071check_namespace_alias (char *name) 1022check_namespace_alias (char *name)
1072{ 1023{
1073 struct link *p = NULL; 1024 struct link *p = NULL;
@@ -1091,7 +1042,7 @@ check_namespace_alias (char *name)
1091 1042
1092/* Register the name NEW_NAME as an alias for namespace list OLD_NAME. */ 1043/* Register the name NEW_NAME as an alias for namespace list OLD_NAME. */
1093 1044
1094void 1045static void
1095register_namespace_alias (char *new_name, struct link *old_name) 1046register_namespace_alias (char *new_name, struct link *old_name)
1096{ 1047{
1097 unsigned h; 1048 unsigned h;
@@ -1119,7 +1070,7 @@ register_namespace_alias (char *new_name, struct link *old_name)
1119 1070
1120/* Enter namespace with name NAME. */ 1071/* Enter namespace with name NAME. */
1121 1072
1122void 1073static void
1123enter_namespace (char *name) 1074enter_namespace (char *name)
1124{ 1075{
1125 struct sym *p = find_namespace (name, current_namespace); 1076 struct sym *p = find_namespace (name, current_namespace);
@@ -1140,7 +1091,7 @@ enter_namespace (char *name)
1140 1091
1141/* Leave the current namespace. */ 1092/* Leave the current namespace. */
1142 1093
1143void 1094static void
1144leave_namespace (void) 1095leave_namespace (void)
1145{ 1096{
1146 assert (namespace_sp > 0); 1097 assert (namespace_sp > 0);
@@ -1156,22 +1107,23 @@ leave_namespace (void)
1156/* Write string S to the output file FP in a Lisp-readable form. 1107/* Write string S to the output file FP in a Lisp-readable form.
1157 If S is null, write out `()'. */ 1108 If S is null, write out `()'. */
1158 1109
1159#define PUTSTR(s, fp) \ 1110static inline void
1160 do { \ 1111putstr (const char *s, FILE *fp)
1161 if (!s) \ 1112{
1162 { \ 1113 if (!s)
1163 putc ('(', fp); \ 1114 {
1164 putc (')', fp); \ 1115 putc ('(', fp);
1165 putc (' ', fp); \ 1116 putc (')', fp);
1166 } \ 1117 putc (' ', fp);
1167 else \ 1118 }
1168 { \ 1119 else
1169 putc ('"', fp); \ 1120 {
1170 fputs (s, fp); \ 1121 putc ('"', fp);
1171 putc ('"', fp); \ 1122 fputs (s, fp);
1172 putc (' ', fp); \ 1123 putc ('"', fp);
1173 } \ 1124 putc (' ', fp);
1174 } while (0) 1125 }
1126}
1175 1127
1176/* A dynamically allocated buffer for constructing a scope name. */ 1128/* A dynamically allocated buffer for constructing a scope name. */
1177 1129
@@ -1182,7 +1134,7 @@ int scope_buffer_len;
1182 1134
1183/* Make sure scope_buffer has enough room to add LEN chars to it. */ 1135/* Make sure scope_buffer has enough room to add LEN chars to it. */
1184 1136
1185void 1137static void
1186ensure_scope_buffer_room (int len) 1138ensure_scope_buffer_room (int len)
1187{ 1139{
1188 if (scope_buffer_len + len >= scope_buffer_size) 1140 if (scope_buffer_len + len >= scope_buffer_size)
@@ -1198,7 +1150,7 @@ ensure_scope_buffer_room (int len)
1198 namespaces to scope_buffer. Value is a pointer to the complete 1150 namespaces to scope_buffer. Value is a pointer to the complete
1199 scope name constructed. */ 1151 scope name constructed. */
1200 1152
1201char * 1153static char *
1202sym_scope_1 (struct sym *p) 1154sym_scope_1 (struct sym *p)
1203{ 1155{
1204 int len; 1156 int len;
@@ -1232,7 +1184,7 @@ sym_scope_1 (struct sym *p)
1232/* Return the scope of symbol P in printed representation, i.e. 1184/* Return the scope of symbol P in printed representation, i.e.
1233 as it would appear in a C*+ source file. */ 1185 as it would appear in a C*+ source file. */
1234 1186
1235char * 1187static char *
1236sym_scope (struct sym *p) 1188sym_scope (struct sym *p)
1237{ 1189{
1238 if (!scope_buffer) 1190 if (!scope_buffer)
@@ -1254,7 +1206,7 @@ sym_scope (struct sym *p)
1254/* Dump the list of members M to file FP. Value is the length of the 1206/* Dump the list of members M to file FP. Value is the length of the
1255 list. */ 1207 list. */
1256 1208
1257int 1209static int
1258dump_members (FILE *fp, struct member *m) 1210dump_members (FILE *fp, struct member *m)
1259{ 1211{
1260 int n; 1212 int n;
@@ -1264,16 +1216,16 @@ dump_members (FILE *fp, struct member *m)
1264 for (n = 0; m; m = m->next, ++n) 1216 for (n = 0; m; m = m->next, ++n)
1265 { 1217 {
1266 fputs (MEMBER_STRUCT, fp); 1218 fputs (MEMBER_STRUCT, fp);
1267 PUTSTR (m->name, fp); 1219 putstr (m->name, fp);
1268 PUTSTR (NULL, fp); /* FIXME? scope for globals */ 1220 putstr (NULL, fp); /* FIXME? scope for globals */
1269 fprintf (fp, "%u ", (unsigned) m->flags); 1221 fprintf (fp, "%u ", (unsigned) m->flags);
1270 PUTSTR (m->filename, fp); 1222 putstr (m->filename, fp);
1271 PUTSTR (m->regexp, fp); 1223 putstr (m->regexp, fp);
1272 fprintf (fp, "%u ", (unsigned) m->pos); 1224 fprintf (fp, "%u ", (unsigned) m->pos);
1273 fprintf (fp, "%u ", (unsigned) m->vis); 1225 fprintf (fp, "%u ", (unsigned) m->vis);
1274 putc (' ', fp); 1226 putc (' ', fp);
1275 PUTSTR (m->def_filename, fp); 1227 putstr (m->def_filename, fp);
1276 PUTSTR (m->def_regexp, fp); 1228 putstr (m->def_regexp, fp);
1277 fprintf (fp, "%u", (unsigned) m->def_pos); 1229 fprintf (fp, "%u", (unsigned) m->def_pos);
1278 putc (']', fp); 1230 putc (']', fp);
1279 putc ('\n', fp); 1231 putc ('\n', fp);
@@ -1287,24 +1239,24 @@ dump_members (FILE *fp, struct member *m)
1287 1239
1288/* Dump class ROOT to stream FP. */ 1240/* Dump class ROOT to stream FP. */
1289 1241
1290void 1242static void
1291dump_sym (FILE *fp, struct sym *root) 1243dump_sym (FILE *fp, struct sym *root)
1292{ 1244{
1293 fputs (CLASS_STRUCT, fp); 1245 fputs (CLASS_STRUCT, fp);
1294 PUTSTR (root->name, fp); 1246 putstr (root->name, fp);
1295 1247
1296 /* Print scope, if any. */ 1248 /* Print scope, if any. */
1297 if (root->namesp) 1249 if (root->namesp)
1298 PUTSTR (sym_scope (root), fp); 1250 putstr (sym_scope (root), fp);
1299 else 1251 else
1300 PUTSTR (NULL, fp); 1252 putstr (NULL, fp);
1301 1253
1302 /* Print flags. */ 1254 /* Print flags. */
1303 fprintf (fp, "%u", root->flags); 1255 fprintf (fp, "%u", root->flags);
1304 PUTSTR (root->filename, fp); 1256 putstr (root->filename, fp);
1305 PUTSTR (root->regexp, fp); 1257 putstr (root->regexp, fp);
1306 fprintf (fp, "%u", (unsigned) root->pos); 1258 fprintf (fp, "%u", (unsigned) root->pos);
1307 PUTSTR (root->sfilename, fp); 1259 putstr (root->sfilename, fp);
1308 putc (']', fp); 1260 putc (']', fp);
1309 putc ('\n', fp); 1261 putc ('\n', fp);
1310} 1262}
@@ -1313,7 +1265,7 @@ dump_sym (FILE *fp, struct sym *root)
1313/* Dump class ROOT and its subclasses to file FP. Value is the 1265/* Dump class ROOT and its subclasses to file FP. Value is the
1314 number of classes written. */ 1266 number of classes written. */
1315 1267
1316int 1268static int
1317dump_tree (FILE *fp, struct sym *root) 1269dump_tree (FILE *fp, struct sym *root)
1318{ 1270{
1319 struct link *lk; 1271 struct link *lk;
@@ -1360,7 +1312,7 @@ dump_tree (FILE *fp, struct sym *root)
1360 1312
1361/* Dump the entire class tree to file FP. */ 1313/* Dump the entire class tree to file FP. */
1362 1314
1363void 1315static void
1364dump_roots (FILE *fp) 1316dump_roots (FILE *fp)
1365{ 1317{
1366 int i, n = 0; 1318 int i, n = 0;
@@ -1371,7 +1323,7 @@ dump_roots (FILE *fp)
1371 if (!f_append) 1323 if (!f_append)
1372 { 1324 {
1373 fputs (TREE_HEADER_STRUCT, fp); 1325 fputs (TREE_HEADER_STRUCT, fp);
1374 PUTSTR (EBROWSE_FILE_VERSION, fp); 1326 putstr (EBROWSE_FILE_VERSION, fp);
1375 1327
1376 putc ('\"', fp); 1328 putc ('\"', fp);
1377 if (!f_structs) 1329 if (!f_structs)
@@ -1434,7 +1386,7 @@ do { \
1434/* Process a preprocessor line. Value is the next character from the 1386/* Process a preprocessor line. Value is the next character from the
1435 input buffer not consumed. */ 1387 input buffer not consumed. */
1436 1388
1437int 1389static int
1438process_pp_line (void) 1390process_pp_line (void)
1439{ 1391{
1440 int in_comment = 0, in_string = 0; 1392 int in_comment = 0, in_string = 0;
@@ -1505,7 +1457,7 @@ process_pp_line (void)
1505 1457
1506/* Value is the next token from the input buffer. */ 1458/* Value is the next token from the input buffer. */
1507 1459
1508int 1460static int
1509yylex (void) 1461yylex (void)
1510{ 1462{
1511 int c; 1463 int c;
@@ -1927,7 +1879,7 @@ static char *matching_regexp_buffer, *matching_regexp_end_buf;
1927 position in the input buffer, or maybe a bit more if that string is 1879 position in the input buffer, or maybe a bit more if that string is
1928 shorter than min_regexp. */ 1880 shorter than min_regexp. */
1929 1881
1930char * 1882static char *
1931matching_regexp (void) 1883matching_regexp (void)
1932{ 1884{
1933 char *p; 1885 char *p;
@@ -1978,7 +1930,7 @@ matching_regexp (void)
1978 1930
1979/* Return a printable representation of token T. */ 1931/* Return a printable representation of token T. */
1980 1932
1981const char * 1933static const char *
1982token_string (int t) 1934token_string (int t)
1983{ 1935{
1984 static char b[3]; 1936 static char b[3];
@@ -2095,7 +2047,7 @@ token_string (int t)
2095 2047
2096/* Reinitialize the scanner for a new input file. */ 2048/* Reinitialize the scanner for a new input file. */
2097 2049
2098void 2050static void
2099re_init_scanner (void) 2051re_init_scanner (void)
2100{ 2052{
2101 in = inbuffer; 2053 in = inbuffer;
@@ -2110,11 +2062,11 @@ re_init_scanner (void)
2110} 2062}
2111 2063
2112 2064
2113/* Insert a keyword NAME with token value TK into the keyword hash 2065/* Insert a keyword NAME with token value TKV into the keyword hash
2114 table. */ 2066 table. */
2115 2067
2116void 2068static void
2117insert_keyword (const char *name, int tk) 2069insert_keyword (const char *name, int tkv)
2118{ 2070{
2119 const char *s; 2071 const char *s;
2120 unsigned h = 0; 2072 unsigned h = 0;
@@ -2125,7 +2077,7 @@ insert_keyword (const char *name, int tk)
2125 2077
2126 h %= KEYWORD_TABLE_SIZE; 2078 h %= KEYWORD_TABLE_SIZE;
2127 k->name = name; 2079 k->name = name;
2128 k->tk = tk; 2080 k->tk = tkv;
2129 k->next = keyword_table[h]; 2081 k->next = keyword_table[h];
2130 keyword_table[h] = k; 2082 keyword_table[h] = k;
2131} 2083}
@@ -2134,7 +2086,7 @@ insert_keyword (const char *name, int tk)
2134/* Initialize the scanner for the first file. This sets up the 2086/* Initialize the scanner for the first file. This sets up the
2135 character class vectors and fills the keyword hash table. */ 2087 character class vectors and fills the keyword hash table. */
2136 2088
2137void 2089static void
2138init_scanner (void) 2090init_scanner (void)
2139{ 2091{
2140 int i; 2092 int i;
@@ -2278,7 +2230,7 @@ init_scanner (void)
2278/* Skip forward until a given token TOKEN or YYEOF is seen and return 2230/* Skip forward until a given token TOKEN or YYEOF is seen and return
2279 the current lookahead token after skipping. */ 2231 the current lookahead token after skipping. */
2280 2232
2281int 2233static int
2282skip_to (int token) 2234skip_to (int token)
2283{ 2235{
2284 while (!LOOKING_AT2 (YYEOF, token)) 2236 while (!LOOKING_AT2 (YYEOF, token))
@@ -2289,7 +2241,7 @@ skip_to (int token)
2289/* Skip over pairs of tokens (parentheses, square brackets, 2241/* Skip over pairs of tokens (parentheses, square brackets,
2290 angle brackets, curly brackets) matching the current lookahead. */ 2242 angle brackets, curly brackets) matching the current lookahead. */
2291 2243
2292void 2244static void
2293skip_matching (void) 2245skip_matching (void)
2294{ 2246{
2295 int open, close, n; 2247 int open, close, n;
@@ -2332,7 +2284,7 @@ skip_matching (void)
2332 } 2284 }
2333} 2285}
2334 2286
2335void 2287static void
2336skip_initializer (void) 2288skip_initializer (void)
2337{ 2289{
2338 for (;;) 2290 for (;;)
@@ -2359,7 +2311,7 @@ skip_initializer (void)
2359 2311
2360/* Build qualified namespace alias (A::B::c) and return it. */ 2312/* Build qualified namespace alias (A::B::c) and return it. */
2361 2313
2362struct link * 2314static struct link *
2363match_qualified_namespace_alias (void) 2315match_qualified_namespace_alias (void)
2364{ 2316{
2365 struct link *head = NULL; 2317 struct link *head = NULL;
@@ -2396,7 +2348,7 @@ match_qualified_namespace_alias (void)
2396 2348
2397/* Re-initialize the parser by resetting the lookahead token. */ 2349/* Re-initialize the parser by resetting the lookahead token. */
2398 2350
2399void 2351static void
2400re_init_parser (void) 2352re_init_parser (void)
2401{ 2353{
2402 tk = -1; 2354 tk = -1;
@@ -2409,7 +2361,7 @@ re_init_parser (void)
2409 Returns a hash code for the parameter types. This value is used to 2361 Returns a hash code for the parameter types. This value is used to
2410 distinguish between overloaded functions. */ 2362 distinguish between overloaded functions. */
2411 2363
2412unsigned 2364static unsigned
2413parm_list (int *flags) 2365parm_list (int *flags)
2414{ 2366{
2415 unsigned hash = 0; 2367 unsigned hash = 0;
@@ -2522,7 +2474,7 @@ parm_list (int *flags)
2522 2474
2523/* Print position info to stdout. */ 2475/* Print position info to stdout. */
2524 2476
2525void 2477static void
2526print_info (void) 2478print_info (void)
2527{ 2479{
2528 if (info_position >= 0 && BUFFER_POS () <= info_position) 2480 if (info_position >= 0 && BUFFER_POS () <= info_position)
@@ -2537,7 +2489,7 @@ print_info (void)
2537 the access specifier for the member (private, protected, 2489 the access specifier for the member (private, protected,
2538 public). */ 2490 public). */
2539 2491
2540void 2492static void
2541member (struct sym *cls, int vis) 2493member (struct sym *cls, int vis)
2542{ 2494{
2543 char *id = NULL; 2495 char *id = NULL;
@@ -2746,7 +2698,7 @@ member (struct sym *cls, int vis)
2746/* Parse the body of class CLS. TAG is the tag of the class (struct, 2698/* Parse the body of class CLS. TAG is the tag of the class (struct,
2747 union, class). */ 2699 union, class). */
2748 2700
2749void 2701static void
2750class_body (struct sym *cls, int tag) 2702class_body (struct sym *cls, int tag)
2751{ 2703{
2752 int vis = tag == CLASS ? PRIVATE : PUBLIC; 2704 int vis = tag == CLASS ? PRIVATE : PUBLIC;
@@ -2807,7 +2759,7 @@ class_body (struct sym *cls, int tag)
2807 qualified ident has the form `X<..>::Y<...>::T<...>. Returns a 2759 qualified ident has the form `X<..>::Y<...>::T<...>. Returns a
2808 symbol for that class. */ 2760 symbol for that class. */
2809 2761
2810struct sym * 2762static struct sym *
2811parse_classname (void) 2763parse_classname (void)
2812{ 2764{
2813 struct sym *last_class = NULL; 2765 struct sym *last_class = NULL;
@@ -2837,7 +2789,7 @@ parse_classname (void)
2837 implicitly static operator has been parsed. Value is a pointer to 2789 implicitly static operator has been parsed. Value is a pointer to
2838 a static buffer holding the constructed operator name string. */ 2790 a static buffer holding the constructed operator name string. */
2839 2791
2840char * 2792static char *
2841operator_name (int *sc) 2793operator_name (int *sc)
2842{ 2794{
2843 static int id_size = 0; 2795 static int id_size = 0;
@@ -2927,7 +2879,7 @@ operator_name (int *sc)
2927 `X::Y::z'. This IDENT is returned in LAST_ID. Value is the 2879 `X::Y::z'. This IDENT is returned in LAST_ID. Value is the
2928 symbol structure for the ident. */ 2880 symbol structure for the ident. */
2929 2881
2930struct sym * 2882static struct sym *
2931parse_qualified_ident_or_type (char **last_id) 2883parse_qualified_ident_or_type (char **last_id)
2932{ 2884{
2933 struct sym *cls = NULL; 2885 struct sym *cls = NULL;
@@ -2992,14 +2944,16 @@ parse_qualified_ident_or_type (char **last_id)
2992 `X::Y::z'. This IDENT is returned in LAST_ID. Value is the 2944 `X::Y::z'. This IDENT is returned in LAST_ID. Value is the
2993 symbol structure for the ident. */ 2945 symbol structure for the ident. */
2994 2946
2995void 2947static void
2996parse_qualified_param_ident_or_type (char **last_id) 2948parse_qualified_param_ident_or_type (char **last_id)
2997{ 2949{
2998 struct sym *cls = NULL; 2950 struct sym *cls = NULL;
2999 static char *id = NULL; 2951 static char *id = NULL;
3000 static int id_size = 0; 2952 static int id_size = 0;
3001 2953
3002 while (LOOKING_AT (IDENT)) 2954 assert (LOOKING_AT (IDENT));
2955
2956 do
3003 { 2957 {
3004 int len = strlen (yytext) + 1; 2958 int len = strlen (yytext) + 1;
3005 if (len > id_size) 2959 if (len > id_size)
@@ -3022,6 +2976,7 @@ parse_qualified_param_ident_or_type (char **last_id)
3022 else 2976 else
3023 break; 2977 break;
3024 } 2978 }
2979 while (LOOKING_AT (IDENT));
3025} 2980}
3026 2981
3027 2982
@@ -3034,7 +2989,7 @@ parse_qualified_param_ident_or_type (char **last_id)
3034 2989
3035 Current lookahead is the class name. */ 2990 Current lookahead is the class name. */
3036 2991
3037void 2992static void
3038class_definition (struct sym *containing, int tag, int flags, int nested) 2993class_definition (struct sym *containing, int tag, int flags, int nested)
3039{ 2994{
3040 struct sym *current; 2995 struct sym *current;
@@ -3131,7 +3086,7 @@ class_definition (struct sym *containing, int tag, int flags, int nested)
3131 the storage class of *ID. FLAGS is a bit set giving additional 3086 the storage class of *ID. FLAGS is a bit set giving additional
3132 information about the member (see the F_* defines). */ 3087 information about the member (see the F_* defines). */
3133 3088
3134void 3089static void
3135add_declarator (struct sym **cls, char **id, int flags, int sc) 3090add_declarator (struct sym **cls, char **id, int flags, int sc)
3136{ 3091{
3137 if (LOOKING_AT2 (';', ',')) 3092 if (LOOKING_AT2 (';', ','))
@@ -3174,7 +3129,7 @@ add_declarator (struct sym **cls, char **id, int flags, int sc)
3174 3129
3175/* Parse a declaration. */ 3130/* Parse a declaration. */
3176 3131
3177void 3132static void
3178declaration (int flags) 3133declaration (int flags)
3179{ 3134{
3180 char *id = NULL; 3135 char *id = NULL;
@@ -3328,7 +3283,7 @@ declaration (int flags)
3328 parsing in an `extern "C"' block. Value is 1 if EOF is reached, 0 3283 parsing in an `extern "C"' block. Value is 1 if EOF is reached, 0
3329 otherwise. */ 3284 otherwise. */
3330 3285
3331int 3286static int
3332globals (int start_flags) 3287globals (int start_flags)
3333{ 3288{
3334 int anonymous; 3289 int anonymous;
@@ -3446,7 +3401,7 @@ globals (int start_flags)
3446 3401
3447/* Parse the current input file. */ 3402/* Parse the current input file. */
3448 3403
3449void 3404static void
3450yyparse (void) 3405yyparse (void)
3451{ 3406{
3452 while (globals (0) == 0) 3407 while (globals (0) == 0)
@@ -3462,7 +3417,7 @@ yyparse (void)
3462/* Add the list of paths PATH_LIST to the current search path for 3417/* Add the list of paths PATH_LIST to the current search path for
3463 input files. */ 3418 input files. */
3464 3419
3465void 3420static void
3466add_search_path (char *path_list) 3421add_search_path (char *path_list)
3467{ 3422{
3468 while (*path_list) 3423 while (*path_list)
@@ -3497,7 +3452,7 @@ add_search_path (char *path_list)
3497 opened. Try to find FILE in search_path first, then try the 3452 opened. Try to find FILE in search_path first, then try the
3498 unchanged file name. */ 3453 unchanged file name. */
3499 3454
3500FILE * 3455static FILE *
3501open_file (char *file) 3456open_file (char *file)
3502{ 3457{
3503 FILE *fp = NULL; 3458 FILE *fp = NULL;
@@ -3556,7 +3511,7 @@ Usage: ebrowse [options] {files}\n\
3556 --version display version info\n\ 3511 --version display version info\n\
3557" 3512"
3558 3513
3559void 3514static void
3560usage (int error) 3515usage (int error)
3561{ 3516{
3562 puts (USAGE); 3517 puts (USAGE);
@@ -3571,7 +3526,7 @@ usage (int error)
3571# define VERSION "21" 3526# define VERSION "21"
3572#endif 3527#endif
3573 3528
3574void 3529static void
3575version (void) 3530version (void)
3576{ 3531{
3577 /* Makes it easier to update automatically. */ 3532 /* Makes it easier to update automatically. */
@@ -3587,7 +3542,7 @@ version (void)
3587/* Parse one input file FILE, adding classes and members to the symbol 3542/* Parse one input file FILE, adding classes and members to the symbol
3588 table. */ 3543 table. */
3589 3544
3590void 3545static void
3591process_file (char *file) 3546process_file (char *file)
3592{ 3547{
3593 FILE *fp; 3548 FILE *fp;
@@ -3642,7 +3597,7 @@ process_file (char *file)
3642 containing its contents without the terminating newline. Value 3597 containing its contents without the terminating newline. Value
3643 is null when EOF is reached. */ 3598 is null when EOF is reached. */
3644 3599
3645char * 3600static char *
3646read_line (FILE *fp) 3601read_line (FILE *fp)
3647{ 3602{
3648 static char *buffer; 3603 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);
112/* Additional space when allocating buffers for filenames, etc. */ 112/* Additional space when allocating buffers for filenames, etc. */
113#define EXTRA_SPACE 100 113#define EXTRA_SPACE 100
114 114
115/* Use this to suppress gcc's `...may be used before initialized' warnings. */
116#ifdef lint
117# define IF_LINT(Code) Code
118#else
119# define IF_LINT(Code) /* empty */
120#endif
121
115 122
116/* Name used to invoke this program. */ 123/* Name used to invoke this program. */
117const char *progname; 124const char *progname;
@@ -122,6 +129,9 @@ char **main_argv;
122/* Nonzero means don't wait for a response from Emacs. --no-wait. */ 129/* Nonzero means don't wait for a response from Emacs. --no-wait. */
123int nowait = 0; 130int nowait = 0;
124 131
132/* Nonzero means don't print messages for successful operations. --quiet. */
133int quiet = 0;
134
125/* Nonzero means args are expressions to be evaluated. --eval. */ 135/* Nonzero means args are expressions to be evaluated. --eval. */
126int eval = 0; 136int eval = 0;
127 137
@@ -150,13 +160,14 @@ const char *server_file = NULL;
150/* PID of the Emacs server process. */ 160/* PID of the Emacs server process. */
151int emacs_pid = 0; 161int emacs_pid = 0;
152 162
153void print_help_and_exit (void) NO_RETURN; 163static void print_help_and_exit (void) NO_RETURN;
154void fail (void) NO_RETURN; 164static void fail (void) NO_RETURN;
155 165
156 166
157struct option longopts[] = 167struct option longopts[] =
158{ 168{
159 { "no-wait", no_argument, NULL, 'n' }, 169 { "no-wait", no_argument, NULL, 'n' },
170 { "quiet", no_argument, NULL, 'q' },
160 { "eval", no_argument, NULL, 'e' }, 171 { "eval", no_argument, NULL, 'e' },
161 { "help", no_argument, NULL, 'H' }, 172 { "help", no_argument, NULL, 'H' },
162 { "version", no_argument, NULL, 'V' }, 173 { "version", no_argument, NULL, 'V' },
@@ -178,7 +189,7 @@ struct option longopts[] =
178 189
179/* Like malloc but get fatal error if memory is exhausted. */ 190/* Like malloc but get fatal error if memory is exhausted. */
180 191
181long * 192static long *
182xmalloc (unsigned int size) 193xmalloc (unsigned int size)
183{ 194{
184 long *result = (long *) malloc (size); 195 long *result = (long *) malloc (size);
@@ -190,20 +201,6 @@ xmalloc (unsigned int size)
190 return result; 201 return result;
191} 202}
192 203
193/* Like strdup but get a fatal error if memory is exhausted. */
194
195char *
196xstrdup (const char *s)
197{
198 char *result = strdup (s);
199 if (result == NULL)
200 {
201 perror ("strdup");
202 exit (EXIT_FAILURE);
203 }
204 return result;
205}
206
207/* From sysdep.c */ 204/* From sysdep.c */
208#if !defined (HAVE_GET_CURRENT_DIR_NAME) || defined (BROKEN_GET_CURRENT_DIR_NAME) 205#if !defined (HAVE_GET_CURRENT_DIR_NAME) || defined (BROKEN_GET_CURRENT_DIR_NAME)
209 206
@@ -233,7 +230,7 @@ char*
233get_current_dir_name (void) 230get_current_dir_name (void)
234{ 231{
235 char *buf; 232 char *buf;
236 char *pwd; 233 const char *pwd;
237 struct stat dotstat, pwdstat; 234 struct stat dotstat, pwdstat;
238 /* If PWD is accurate, use it instead of calling getwd. PWD is 235 /* If PWD is accurate, use it instead of calling getwd. PWD is
239 sometimes a nicer name, and using it may avoid a fatal error if a 236 sometimes a nicer name, and using it may avoid a fatal error if a
@@ -300,6 +297,20 @@ get_current_dir_name (void)
300 297
301#ifdef WINDOWSNT 298#ifdef WINDOWSNT
302 299
300/* Like strdup but get a fatal error if memory is exhausted. */
301
302char *
303xstrdup (const char *s)
304{
305 char *result = strdup (s);
306 if (result == NULL)
307 {
308 perror ("strdup");
309 exit (EXIT_FAILURE);
310 }
311 return result;
312}
313
303#define REG_ROOT "SOFTWARE\\GNU\\Emacs" 314#define REG_ROOT "SOFTWARE\\GNU\\Emacs"
304 315
305/* Retrieve an environment variable from the Emacs subkeys of the registry. 316/* Retrieve an environment variable from the Emacs subkeys of the registry.
@@ -335,9 +346,11 @@ w32_get_resource (HKEY predefined, char *key, LPDWORD type)
335/* 346/*
336 getenv wrapper for Windows 347 getenv wrapper for Windows
337 348
338 This is needed to duplicate Emacs's behavior, which is to look for environment 349 Value is allocated on the heap, and can be free'd.
339 variables in the registry if they don't appear in the environment. 350
340*/ 351 This is needed to duplicate Emacs's behavior, which is to look for
352 environment variables in the registry if they don't appear in the
353 environment. */
341char * 354char *
342w32_getenv (char *envvar) 355w32_getenv (char *envvar)
343{ 356{
@@ -345,8 +358,9 @@ w32_getenv (char *envvar)
345 DWORD dwType; 358 DWORD dwType;
346 359
347 if (value = getenv (envvar)) 360 if (value = getenv (envvar))
348 /* Found in the environment. */ 361 /* Found in the environment. strdup it, because values returned
349 return value; 362 by getenv cannot be free'd. */
363 return xstrdup (value);
350 364
351 if (! (value = w32_get_resource (HKEY_CURRENT_USER, envvar, &dwType)) && 365 if (! (value = w32_get_resource (HKEY_CURRENT_USER, envvar, &dwType)) &&
352 ! (value = w32_get_resource (HKEY_LOCAL_MACHINE, envvar, &dwType))) 366 ! (value = w32_get_resource (HKEY_LOCAL_MACHINE, envvar, &dwType)))
@@ -473,14 +487,14 @@ ttyname (int fd)
473 487
474/* Display a normal or error message. 488/* Display a normal or error message.
475 On Windows, use a message box if compiled as a Windows app. */ 489 On Windows, use a message box if compiled as a Windows app. */
476void 490static void
477message (int is_error, const char *message, ...) 491message (int is_error, const char *format, ...)
478{ 492{
479 char msg[2048]; 493 char msg[2048];
480 va_list args; 494 va_list args;
481 495
482 va_start (args, message); 496 va_start (args, format);
483 vsprintf (msg, message, args); 497 vsprintf (msg, format, args);
484 va_end (args); 498 va_end (args);
485 499
486#ifdef WINDOWSNT 500#ifdef WINDOWSNT
@@ -504,7 +518,7 @@ message (int is_error, const char *message, ...)
504/* Decode the options from argv and argc. 518/* Decode the options from argv and argc.
505 The global variable `optind' will say how many arguments we used up. */ 519 The global variable `optind' will say how many arguments we used up. */
506 520
507void 521static void
508decode_options (int argc, char **argv) 522decode_options (int argc, char **argv)
509{ 523{
510 alternate_editor = egetenv ("ALTERNATE_EDITOR"); 524 alternate_editor = egetenv ("ALTERNATE_EDITOR");
@@ -513,9 +527,9 @@ decode_options (int argc, char **argv)
513 { 527 {
514 int opt = getopt_long_only (argc, argv, 528 int opt = getopt_long_only (argc, argv,
515#ifndef NO_SOCKETS_IN_FILE_SYSTEM 529#ifndef NO_SOCKETS_IN_FILE_SYSTEM
516 "VHnea:s:f:d:tc", 530 "VHneqa:s:f:d:tc",
517#else 531#else
518 "VHnea:f:d:tc", 532 "VHneqa:f:d:tc",
519#endif 533#endif
520 longopts, 0); 534 longopts, 0);
521 535
@@ -559,6 +573,10 @@ decode_options (int argc, char **argv)
559 eval = 1; 573 eval = 1;
560 break; 574 break;
561 575
576 case 'q':
577 quiet = 1;
578 break;
579
562 case 'V': 580 case 'V':
563 message (FALSE, "emacsclient %s\n", VERSION); 581 message (FALSE, "emacsclient %s\n", VERSION);
564 exit (EXIT_SUCCESS); 582 exit (EXIT_SUCCESS);
@@ -630,7 +648,7 @@ an empty string");
630} 648}
631 649
632 650
633void 651static void
634print_help_and_exit (void) 652print_help_and_exit (void)
635{ 653{
636 /* Spaces and tabs are significant in this message; they're chosen so the 654 /* Spaces and tabs are significant in this message; they're chosen so the
@@ -650,6 +668,7 @@ The following OPTIONS are accepted:\n\
650 use the current Emacs frame\n\ 668 use the current Emacs frame\n\
651-e, --eval Evaluate the FILE arguments as ELisp expressions\n\ 669-e, --eval Evaluate the FILE arguments as ELisp expressions\n\
652-n, --no-wait Don't wait for the server to return\n\ 670-n, --no-wait Don't wait for the server to return\n\
671-q, --quiet Don't display messages on success\n\
653-d DISPLAY, --display=DISPLAY\n\ 672-d DISPLAY, --display=DISPLAY\n\
654 Visit the file in the given display\n\ 673 Visit the file in the given display\n\
655--parent-id=ID Open in parent window ID, via XEmbed\n" 674--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);
675 defined-- exit with an errorcode. 694 defined-- exit with an errorcode.
676 Uses argv, but gets it from the global variable main_argv. 695 Uses argv, but gets it from the global variable main_argv.
677*/ 696*/
678void 697static void
679fail (void) 698fail (void)
680{ 699{
681 if (alternate_editor) 700 if (alternate_editor)
@@ -718,7 +737,7 @@ HSOCKET emacs_socket = 0;
718 737
719/* On Windows, the socket library was historically separate from the standard 738/* On Windows, the socket library was historically separate from the standard
720 C library, so errors are handled differently. */ 739 C library, so errors are handled differently. */
721void 740static void
722sock_err_message (const char *function_name) 741sock_err_message (const char *function_name)
723{ 742{
724#ifdef WINDOWSNT 743#ifdef WINDOWSNT
@@ -742,7 +761,7 @@ sock_err_message (const char *function_name)
742 - the data ends in "\n", or 761 - the data ends in "\n", or
743 - the buffer is full (but this shouldn't happen) 762 - the buffer is full (but this shouldn't happen)
744 Otherwise, we just accumulate it. */ 763 Otherwise, we just accumulate it. */
745void 764static void
746send_to_emacs (HSOCKET s, const char *data) 765send_to_emacs (HSOCKET s, const char *data)
747{ 766{
748 while (data) 767 while (data)
@@ -781,7 +800,7 @@ send_to_emacs (HSOCKET s, const char *data)
781 return value never contains a space. 800 return value never contains a space.
782 801
783 Does not change the string. Outputs the result to S. */ 802 Does not change the string. Outputs the result to S. */
784void 803static void
785quote_argument (HSOCKET s, const char *str) 804quote_argument (HSOCKET s, const char *str)
786{ 805{
787 char *copy = (char *) xmalloc (strlen (str) * 2 + 1); 806 char *copy = (char *) xmalloc (strlen (str) * 2 + 1);
@@ -822,7 +841,7 @@ quote_argument (HSOCKET s, const char *str)
822/* The inverse of quote_argument. Removes quoting in string STR by 841/* The inverse of quote_argument. Removes quoting in string STR by
823 modifying the string in place. Returns STR. */ 842 modifying the string in place. Returns STR. */
824 843
825char * 844static char *
826unquote_argument (char *str) 845unquote_argument (char *str)
827{ 846{
828 char *p, *q; 847 char *p, *q;
@@ -853,7 +872,7 @@ unquote_argument (char *str)
853} 872}
854 873
855 874
856int 875static int
857file_name_absolute_p (const char *filename) 876file_name_absolute_p (const char *filename)
858{ 877{
859 /* Sanity check, it shouldn't happen. */ 878 /* Sanity check, it shouldn't happen. */
@@ -907,7 +926,7 @@ initialize_sockets (void)
907 * Read the information needed to set up a TCP comm channel with 926 * Read the information needed to set up a TCP comm channel with
908 * the Emacs server: host, port, and authentication string. 927 * the Emacs server: host, port, and authentication string.
909 */ 928 */
910int 929static int
911get_server_config (struct sockaddr_in *server, char *authentication) 930get_server_config (struct sockaddr_in *server, char *authentication)
912{ 931{
913 char dotted[32]; 932 char dotted[32];
@@ -918,7 +937,7 @@ get_server_config (struct sockaddr_in *server, char *authentication)
918 config = fopen (server_file, "rb"); 937 config = fopen (server_file, "rb");
919 else 938 else
920 { 939 {
921 char *home = egetenv ("HOME"); 940 const char *home = egetenv ("HOME");
922 941
923 if (home) 942 if (home)
924 { 943 {
@@ -965,7 +984,7 @@ get_server_config (struct sockaddr_in *server, char *authentication)
965 return TRUE; 984 return TRUE;
966} 985}
967 986
968HSOCKET 987static HSOCKET
969set_tcp_socket (void) 988set_tcp_socket (void)
970{ 989{
971 HSOCKET s; 990 HSOCKET s;
@@ -976,7 +995,7 @@ set_tcp_socket (void)
976 if (! get_server_config (&server, auth_string)) 995 if (! get_server_config (&server, auth_string))
977 return INVALID_SOCKET; 996 return INVALID_SOCKET;
978 997
979 if (server.sin_addr.s_addr != inet_addr ("127.0.0.1")) 998 if (server.sin_addr.s_addr != inet_addr ("127.0.0.1") && !quiet)
980 message (FALSE, "%s: connected to remote socket at %s\n", 999 message (FALSE, "%s: connected to remote socket at %s\n",
981 progname, inet_ntoa (server.sin_addr)); 1000 progname, inet_ntoa (server.sin_addr));
982 1001
@@ -1024,11 +1043,11 @@ strprefix (const char *prefix, const char *string)
1024 and the name in TTY_NAME, and return 1. Otherwise, fail if NOABORT 1043 and the name in TTY_NAME, and return 1. Otherwise, fail if NOABORT
1025 is zero, or return 0 if NOABORT is non-zero. */ 1044 is zero, or return 0 if NOABORT is non-zero. */
1026 1045
1027int 1046static int
1028find_tty (char **tty_type, char **tty_name, int noabort) 1047find_tty (const char **tty_type, const char **tty_name, int noabort)
1029{ 1048{
1030 char *type = egetenv ("TERM"); 1049 const char *type = egetenv ("TERM");
1031 char *name = ttyname (fileno (stdout)); 1050 const char *name = ttyname (fileno (stdout));
1032 1051
1033 if (!name) 1052 if (!name)
1034 { 1053 {
@@ -1080,11 +1099,11 @@ find_tty (char **tty_type, char **tty_name, int noabort)
1080 0 - success: none of the above */ 1099 0 - success: none of the above */
1081 1100
1082static int 1101static int
1083socket_status (char *socket_name) 1102socket_status (char *name)
1084{ 1103{
1085 struct stat statbfr; 1104 struct stat statbfr;
1086 1105
1087 if (stat (socket_name, &statbfr) == -1) 1106 if (stat (name, &statbfr) == -1)
1088 return 2; 1107 return 2;
1089 1108
1090 if (statbfr.st_uid != geteuid ()) 1109 if (statbfr.st_uid != geteuid ())
@@ -1097,7 +1116,7 @@ socket_status (char *socket_name)
1097/* A signal handler that passes the signal to the Emacs process. 1116/* A signal handler that passes the signal to the Emacs process.
1098 Useful for SIGWINCH. */ 1117 Useful for SIGWINCH. */
1099 1118
1100SIGTYPE 1119static SIGTYPE
1101pass_signal_to_emacs (int signalnum) 1120pass_signal_to_emacs (int signalnum)
1102{ 1121{
1103 int old_errno = errno; 1122 int old_errno = errno;
@@ -1112,7 +1131,7 @@ pass_signal_to_emacs (int signalnum)
1112/* Signal handler for SIGCONT; notify the Emacs process that it can 1131/* Signal handler for SIGCONT; notify the Emacs process that it can
1113 now resume our tty frame. */ 1132 now resume our tty frame. */
1114 1133
1115SIGTYPE 1134static SIGTYPE
1116handle_sigcont (int signalnum) 1135handle_sigcont (int signalnum)
1117{ 1136{
1118 int old_errno = errno; 1137 int old_errno = errno;
@@ -1138,7 +1157,7 @@ handle_sigcont (int signalnum)
1138 reality, we may get a SIGTSTP on C-z. Handling this signal and 1157 reality, we may get a SIGTSTP on C-z. Handling this signal and
1139 notifying Emacs about it should get things under control again. */ 1158 notifying Emacs about it should get things under control again. */
1140 1159
1141SIGTYPE 1160static SIGTYPE
1142handle_sigtstp (int signalnum) 1161handle_sigtstp (int signalnum)
1143{ 1162{
1144 int old_errno = errno; 1163 int old_errno = errno;
@@ -1162,7 +1181,7 @@ handle_sigtstp (int signalnum)
1162 1181
1163/* Set up signal handlers before opening a frame on the current tty. */ 1182/* Set up signal handlers before opening a frame on the current tty. */
1164 1183
1165void 1184static void
1166init_signals (void) 1185init_signals (void)
1167{ 1186{
1168 /* Set up signal handlers. */ 1187 /* Set up signal handlers. */
@@ -1182,7 +1201,7 @@ init_signals (void)
1182} 1201}
1183 1202
1184 1203
1185HSOCKET 1204static HSOCKET
1186set_local_socket (void) 1205set_local_socket (void)
1187{ 1206{
1188 HSOCKET s; 1207 HSOCKET s;
@@ -1205,7 +1224,7 @@ set_local_socket (void)
1205 int default_sock = !socket_name; 1224 int default_sock = !socket_name;
1206 int saved_errno = 0; 1225 int saved_errno = 0;
1207 const char *server_name = "server"; 1226 const char *server_name = "server";
1208 const char *tmpdir; 1227 const char *tmpdir IF_LINT ( = NULL);
1209 1228
1210 if (socket_name && !strchr (socket_name, '/') 1229 if (socket_name && !strchr (socket_name, '/')
1211 && !strchr (socket_name, '\\')) 1230 && !strchr (socket_name, '\\'))
@@ -1260,10 +1279,10 @@ set_local_socket (void)
1260 associated with the name. This is reminiscent of the logic 1279 associated with the name. This is reminiscent of the logic
1261 that init_editfns uses to set the global Vuser_full_name. */ 1280 that init_editfns uses to set the global Vuser_full_name. */
1262 1281
1263 char *user_name = (char *) egetenv ("LOGNAME"); 1282 const char *user_name = egetenv ("LOGNAME");
1264 1283
1265 if (!user_name) 1284 if (!user_name)
1266 user_name = (char *) egetenv ("USER"); 1285 user_name = egetenv ("USER");
1267 1286
1268 if (user_name) 1287 if (user_name)
1269 { 1288 {
@@ -1331,7 +1350,7 @@ To start the server in Emacs, type \"M-x server-start\".\n",
1331} 1350}
1332#endif /* ! NO_SOCKETS_IN_FILE_SYSTEM */ 1351#endif /* ! NO_SOCKETS_IN_FILE_SYSTEM */
1333 1352
1334HSOCKET 1353static HSOCKET
1335set_socket (int no_exit_if_error) 1354set_socket (int no_exit_if_error)
1336{ 1355{
1337 HSOCKET s; 1356 HSOCKET s;
@@ -1447,7 +1466,7 @@ w32_give_focus (void)
1447 1466
1448/* Start the emacs daemon and try to connect to it. */ 1467/* Start the emacs daemon and try to connect to it. */
1449 1468
1450void 1469static void
1451start_daemon_and_retry_set_socket (void) 1470start_daemon_and_retry_set_socket (void)
1452{ 1471{
1453#ifndef WINDOWSNT 1472#ifndef WINDOWSNT
@@ -1483,8 +1502,8 @@ start_daemon_and_retry_set_socket (void)
1483 else 1502 else
1484 { 1503 {
1485 char emacs[] = "emacs"; 1504 char emacs[] = "emacs";
1486 char daemon[] = "--daemon"; 1505 char daemon_option[] = "--daemon";
1487 char *d_argv[] = {emacs, daemon, 0 }; 1506 char *d_argv[] = {emacs, daemon_option, 0 };
1488 if (socket_name != NULL) 1507 if (socket_name != NULL)
1489 { 1508 {
1490 /* Pass --daemon=socket_name as argument. */ 1509 /* Pass --daemon=socket_name as argument. */
@@ -1504,10 +1523,12 @@ start_daemon_and_retry_set_socket (void)
1504int 1523int
1505main (int argc, char **argv) 1524main (int argc, char **argv)
1506{ 1525{
1507 int i, rl, needlf = 0; 1526 int rl, needlf = 0;
1508 char *cwd, *str; 1527 char *cwd, *str;
1509 char string[BUFSIZ+1]; 1528 char string[BUFSIZ+1];
1510 int null_socket_name, null_server_file, start_daemon_if_needed; 1529 int null_socket_name IF_LINT ( = 0);
1530 int null_server_file IF_LINT ( = 0);
1531 int start_daemon_if_needed;
1511 int exit_status = EXIT_SUCCESS; 1532 int exit_status = EXIT_SUCCESS;
1512 1533
1513 main_argv = argv; 1534 main_argv = argv;
@@ -1543,21 +1564,21 @@ main (int argc, char **argv)
1543 null_server_file = (server_file == NULL); 1564 null_server_file = (server_file == NULL);
1544 } 1565 }
1545 1566
1546 if ((emacs_socket = set_socket (alternate_editor 1567 emacs_socket = set_socket (alternate_editor || start_daemon_if_needed);
1547 || start_daemon_if_needed)) == INVALID_SOCKET) 1568 if (emacs_socket == INVALID_SOCKET)
1548 if (start_daemon_if_needed) 1569 {
1549 { 1570 if (! start_daemon_if_needed)
1550 /* Reset socket_name and server_file if they were NULL 1571 fail ();
1551 before the set_socket call. */ 1572
1552 if (null_socket_name) 1573 /* Reset socket_name and server_file if they were NULL
1553 socket_name = NULL; 1574 before the set_socket call. */
1554 if (null_server_file) 1575 if (null_socket_name)
1555 server_file = NULL; 1576 socket_name = NULL;
1556 1577 if (null_server_file)
1557 start_daemon_and_retry_set_socket (); 1578 server_file = NULL;
1558 } 1579
1559 else 1580 start_daemon_and_retry_set_socket ();
1560 fail (); 1581 }
1561 1582
1562 cwd = get_current_dir_name (); 1583 cwd = get_current_dir_name ();
1563 if (cwd == 0) 1584 if (cwd == 0)
@@ -1615,7 +1636,7 @@ main (int argc, char **argv)
1615 frame is available. */ 1636 frame is available. */
1616 if (tty || (current_frame && !eval)) 1637 if (tty || (current_frame && !eval))
1617 { 1638 {
1618 char *tty_type, *tty_name; 1639 const char *tty_type, *tty_name;
1619 1640
1620 if (find_tty (&tty_type, &tty_name, !tty)) 1641 if (find_tty (&tty_type, &tty_name, !tty))
1621 { 1642 {
@@ -1635,6 +1656,7 @@ main (int argc, char **argv)
1635 1656
1636 if ((argc - optind > 0)) 1657 if ((argc - optind > 0))
1637 { 1658 {
1659 int i;
1638 for (i = optind; i < argc; i++) 1660 for (i = optind; i < argc; i++)
1639 { 1661 {
1640 1662
@@ -1699,7 +1721,7 @@ main (int argc, char **argv)
1699 send_to_emacs (emacs_socket, "\n"); 1721 send_to_emacs (emacs_socket, "\n");
1700 1722
1701 /* Wait for an answer. */ 1723 /* Wait for an answer. */
1702 if (!eval && !tty && !nowait) 1724 if (!eval && !tty && !nowait && !quiet)
1703 { 1725 {
1704 printf ("Waiting for Emacs..."); 1726 printf ("Waiting for Emacs...");
1705 needlf = 2; 1727 needlf = 2;
@@ -1722,7 +1744,7 @@ main (int argc, char **argv)
1722 1744
1723 if (rl <= 0) 1745 if (rl <= 0)
1724 break; 1746 break;
1725 1747
1726 string[rl] = '\0'; 1748 string[rl] = '\0';
1727 1749
1728 p = string + strlen (string) - 1; 1750 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";
190# define assert(x) ((void) 0) 190# define assert(x) ((void) 0)
191#endif 191#endif
192 192
193#if !defined (S_ISREG) && defined (S_IFREG)
194# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
195#endif
196
197#ifdef NO_LONG_OPTIONS /* define this if you don't have GNU getopt */ 193#ifdef NO_LONG_OPTIONS /* define this if you don't have GNU getopt */
198# define NO_LONG_OPTIONS TRUE 194# define NO_LONG_OPTIONS TRUE
199# define getopt_long(argc,argv,optstr,lopts,lind) getopt (argc, argv, optstr) 195# 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
243#define ISLOWER(c) islower (CHAR(c)) 239#define ISLOWER(c) islower (CHAR(c))
244 240
245#define lowcase(c) tolower (CHAR(c)) 241#define lowcase(c) tolower (CHAR(c))
246#define upcase(c) toupper (CHAR(c))
247 242
248 243
249/* 244/*
@@ -5327,7 +5322,7 @@ prolog_skip_comment (linebuffer *plb, FILE *inf)
5327 */ 5322 */
5328static int 5323static int
5329prolog_pr (char *s, char *last) 5324prolog_pr (char *s, char *last)
5330 5325
5331 /* Name of last clause. */ 5326 /* Name of last clause. */
5332{ 5327{
5333 int pos; 5328 int pos;
@@ -5484,7 +5479,7 @@ Erlang_functions (FILE *inf)
5484 */ 5479 */
5485static int 5480static int
5486erlang_func (char *s, char *last) 5481erlang_func (char *s, char *last)
5487 5482
5488 /* Name of last clause. */ 5483 /* Name of last clause. */
5489{ 5484{
5490 int pos; 5485 int pos;
@@ -6642,7 +6637,7 @@ filename_is_absolute (char *fn)
6642 ); 6637 );
6643} 6638}
6644 6639
6645/* Upcase DOS drive letter and collapse separators into single slashes. 6640/* Downcase DOS drive letter and collapse separators into single slashes.
6646 Works in place. */ 6641 Works in place. */
6647static void 6642static void
6648canonicalize_filename (register char *fn) 6643canonicalize_filename (register char *fn)
@@ -6652,8 +6647,9 @@ canonicalize_filename (register char *fn)
6652 6647
6653#ifdef DOS_NT 6648#ifdef DOS_NT
6654 /* Canonicalize drive letter case. */ 6649 /* Canonicalize drive letter case. */
6655 if (fn[0] != '\0' && fn[1] == ':' && ISLOWER (fn[0])) 6650# define ISUPPER(c) isupper (CHAR(c))
6656 fn[0] = upcase (fn[0]); 6651 if (fn[0] != '\0' && fn[1] == ':' && ISUPPER (fn[0]))
6652 fn[0] = lowcase (fn[0]);
6657 6653
6658 sep = '\\'; 6654 sep = '\\';
6659#endif 6655#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 ()
62 62
63/* This is to declare cuserid. */ 63/* This is to declare cuserid. */
64#include <unistd.h> 64#include <unistd.h>
65
66#include <ignore-value.h>
65 67
66/* Type definitions */ 68/* Type definitions */
67 69
@@ -198,7 +200,7 @@ xrealloc (long int *ptr, int size)
198 200
199/* Initialize a linebuffer for use */ 201/* Initialize a linebuffer for use */
200 202
201void 203static void
202init_linebuffer (struct linebuffer *linebuffer) 204init_linebuffer (struct linebuffer *linebuffer)
203{ 205{
204 linebuffer->size = INITIAL_LINE_SIZE; 206 linebuffer->size = INITIAL_LINE_SIZE;
@@ -208,7 +210,7 @@ init_linebuffer (struct linebuffer *linebuffer)
208/* Read a line of text from `stream' into `linebuffer'. 210/* Read a line of text from `stream' into `linebuffer'.
209 Return the length of the line. */ 211 Return the length of the line. */
210 212
211long 213static long
212readline (struct linebuffer *linebuffer, FILE *stream) 214readline (struct linebuffer *linebuffer, FILE *stream)
213{ 215{
214 char *buffer = linebuffer->buffer; 216 char *buffer = linebuffer->buffer;
@@ -243,7 +245,7 @@ readline (struct linebuffer *linebuffer, FILE *stream)
243 245
244 If there is no keyword, return NULL and don't alter *REST. */ 246 If there is no keyword, return NULL and don't alter *REST. */
245 247
246char * 248static char *
247get_keyword (register char *field, char **rest) 249get_keyword (register char *field, char **rest)
248{ 250{
249 static char keyword[KEYWORD_SIZE]; 251 static char keyword[KEYWORD_SIZE];
@@ -268,7 +270,7 @@ get_keyword (register char *field, char **rest)
268 270
269/* Nonzero if the string FIELD starts with a colon-terminated keyword. */ 271/* Nonzero if the string FIELD starts with a colon-terminated keyword. */
270 272
271boolean 273static boolean
272has_keyword (char *field) 274has_keyword (char *field)
273{ 275{
274 char *ignored; 276 char *ignored;
@@ -285,7 +287,7 @@ has_keyword (char *field)
285 We don't pay attention to overflowing WHERE; 287 We don't pay attention to overflowing WHERE;
286 the caller has to make it big enough. */ 288 the caller has to make it big enough. */
287 289
288char * 290static char *
289add_field (line_list the_list, register char *field, register char *where) 291add_field (line_list the_list, register char *field, register char *where)
290{ 292{
291 register char c; 293 register char c;
@@ -341,7 +343,7 @@ add_field (line_list the_list, register char *field, register char *where)
341 return where; 343 return where;
342} 344}
343 345
344line_list 346static line_list
345make_file_preface (void) 347make_file_preface (void)
346{ 348{
347 char *the_string, *temp; 349 char *the_string, *temp;
@@ -385,7 +387,7 @@ make_file_preface (void)
385 return result; 387 return result;
386} 388}
387 389
388void 390static void
389write_line_list (register line_list the_list, FILE *the_stream) 391write_line_list (register line_list the_list, FILE *the_stream)
390{ 392{
391 for ( ; 393 for ( ;
@@ -398,20 +400,20 @@ write_line_list (register line_list the_list, FILE *the_stream)
398 return; 400 return;
399} 401}
400 402
401int 403static int
402close_the_streams (void) 404close_the_streams (void)
403{ 405{
404 register stream_list rem; 406 register stream_list rem;
405 for (rem = the_streams; 407 for (rem = the_streams;
406 rem != ((stream_list) NULL); 408 rem != ((stream_list) NULL);
407 rem = rem->rest_streams) 409 rem = rem->rest_streams)
408 no_problems = (no_problems && 410 if (no_problems && (*rem->action) (rem->handle) != 0)
409 ((*rem->action) (rem->handle) == 0)); 411 error ("output error", NULL);
410 the_streams = ((stream_list) NULL); 412 the_streams = ((stream_list) NULL);
411 return (no_problems ? EXIT_SUCCESS : EXIT_FAILURE); 413 return (no_problems ? EXIT_SUCCESS : EXIT_FAILURE);
412} 414}
413 415
414void 416static void
415add_a_stream (FILE *the_stream, int (*closing_action) (FILE *)) 417add_a_stream (FILE *the_stream, int (*closing_action) (FILE *))
416{ 418{
417 stream_list old = the_streams; 419 stream_list old = the_streams;
@@ -422,15 +424,17 @@ add_a_stream (FILE *the_stream, int (*closing_action) (FILE *))
422 return; 424 return;
423} 425}
424 426
425int 427static int
426my_fclose (FILE *the_file) 428my_fclose (FILE *the_file)
427{ 429{
428 putc ('\n', the_file); 430 putc ('\n', the_file);
429 fflush (the_file); 431 fflush (the_file);
432 if (ferror (the_file))
433 return EOF;
430 return fclose (the_file); 434 return fclose (the_file);
431} 435}
432 436
433boolean 437static boolean
434open_a_file (char *name) 438open_a_file (char *name)
435{ 439{
436 FILE *the_stream = fopen (name, "a"); 440 FILE *the_stream = fopen (name, "a");
@@ -445,7 +449,7 @@ open_a_file (char *name)
445 return false; 449 return false;
446} 450}
447 451
448void 452static void
449put_string (char *s) 453put_string (char *s)
450{ 454{
451 register stream_list rem; 455 register stream_list rem;
@@ -456,7 +460,7 @@ put_string (char *s)
456 return; 460 return;
457} 461}
458 462
459void 463static void
460put_line (const char *string) 464put_line (const char *string)
461{ 465{
462 register stream_list rem; 466 register stream_list rem;
@@ -496,7 +500,7 @@ put_line (const char *string)
496 } 500 }
497 } 501 }
498 /* Output that much, then break the line. */ 502 /* Output that much, then break the line. */
499 fwrite (s, 1, breakpos - s, rem->handle); 503 ignore_value (fwrite (s, 1, breakpos - s, rem->handle));
500 column = 8; 504 column = 8;
501 505
502 /* Skip whitespace and prepare to print more addresses. */ 506 /* Skip whitespace and prepare to print more addresses. */
@@ -516,7 +520,7 @@ put_line (const char *string)
516 the header name), and THE_LIST holds the continuation lines if any. 520 the header name), and THE_LIST holds the continuation lines if any.
517 Call open_a_file for each file. */ 521 Call open_a_file for each file. */
518 522
519void 523static void
520setup_files (register line_list the_list, register char *field) 524setup_files (register line_list the_list, register char *field)
521{ 525{
522 register char *start; 526 register char *start;
@@ -552,7 +556,7 @@ setup_files (register line_list the_list, register char *field)
552/* Compute the total size of all recipient names stored in THE_HEADER. 556/* Compute the total size of all recipient names stored in THE_HEADER.
553 The result says how big to make the buffer to pass to parse_header. */ 557 The result says how big to make the buffer to pass to parse_header. */
554 558
555int 559static int
556args_size (header the_header) 560args_size (header the_header)
557{ 561{
558 register header old = the_header; 562 register header old = the_header;
@@ -583,7 +587,7 @@ args_size (header the_header)
583 587
584 Also, if the header has any FCC fields, call setup_files for each one. */ 588 Also, if the header has any FCC fields, call setup_files for each one. */
585 589
586void 590static void
587parse_header (header the_header, register char *where) 591parse_header (header the_header, register char *where)
588{ 592{
589 register header old = the_header; 593 register header old = the_header;
@@ -615,7 +619,7 @@ parse_header (header the_header, register char *where)
615 one for each line in that field. 619 one for each line in that field.
616 Continuation lines are grouped in the headers they continue. */ 620 Continuation lines are grouped in the headers they continue. */
617 621
618header 622static header
619read_header (void) 623read_header (void)
620{ 624{
621 register header the_header = ((header) NULL); 625 register header the_header = ((header) NULL);
@@ -669,7 +673,7 @@ read_header (void)
669 return the_header->next; 673 return the_header->next;
670} 674}
671 675
672void 676static void
673write_header (header the_header) 677write_header (header the_header)
674{ 678{
675 register header old = the_header; 679 register header old = the_header;
@@ -729,6 +733,9 @@ main (int argc, char **argv)
729 put_string (buf); 733 put_string (buf);
730 } 734 }
731 735
736 if (no_problems && (ferror (stdin) || fclose (stdin) != 0))
737 error ("input error", NULL);
738
732 exit (close_the_streams ()); 739 exit (close_the_streams ());
733} 740}
734 741
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/>. */
66#define IS_DIRECTORY_SEP(_c_) ((_c_) == DIRECTORY_SEP) 66#define IS_DIRECTORY_SEP(_c_) ((_c_) == DIRECTORY_SEP)
67#endif 67#endif
68 68
69int scan_file (char *filename); 69static int scan_file (char *filename);
70int scan_lisp_file (const char *filename, const char *mode); 70static int scan_lisp_file (const char *filename, const char *mode);
71int scan_c_file (char *filename, const char *mode); 71static int scan_c_file (char *filename, const char *mode);
72void fatal (const char *s1, const char *s2) NO_RETURN; 72static void fatal (const char *s1, const char *s2) NO_RETURN;
73void start_globals (void); 73static void start_globals (void);
74void write_globals (void); 74static void write_globals (void);
75 75
76#ifdef MSDOS 76#ifdef MSDOS
77/* s/msdos.h defines this as sys_chdir, but we're not linking with the 77/* s/msdos.h defines this as sys_chdir, but we're not linking with the
@@ -93,7 +93,7 @@ int generate_globals;
93/* Print error message. `s1' is printf control string, `s2' is arg for it. */ 93/* Print error message. `s1' is printf control string, `s2' is arg for it. */
94 94
95/* VARARGS1 */ 95/* VARARGS1 */
96void 96static void
97error (const char *s1, const char *s2) 97error (const char *s1, const char *s2)
98{ 98{
99 fprintf (stderr, "%s: ", progname); 99 fprintf (stderr, "%s: ", progname);
@@ -104,7 +104,7 @@ error (const char *s1, const char *s2)
104/* Print error message and exit. */ 104/* Print error message and exit. */
105 105
106/* VARARGS1 */ 106/* VARARGS1 */
107void 107static void
108fatal (const char *s1, const char *s2) 108fatal (const char *s1, const char *s2)
109{ 109{
110 error (s1, s2); 110 error (s1, s2);
@@ -113,7 +113,7 @@ fatal (const char *s1, const char *s2)
113 113
114/* Like malloc but get fatal error if memory is exhausted. */ 114/* Like malloc but get fatal error if memory is exhausted. */
115 115
116void * 116static void *
117xmalloc (unsigned int size) 117xmalloc (unsigned int size)
118{ 118{
119 void *result = (void *) malloc (size); 119 void *result = (void *) malloc (size);
@@ -124,7 +124,7 @@ xmalloc (unsigned int size)
124 124
125/* Like realloc but get fatal error if memory is exhausted. */ 125/* Like realloc but get fatal error if memory is exhausted. */
126 126
127void * 127static void *
128xrealloc (void *arg, unsigned int size) 128xrealloc (void *arg, unsigned int size)
129{ 129{
130 void *result = (void *) realloc (arg, size); 130 void *result = (void *) realloc (arg, size);
@@ -212,7 +212,7 @@ main (int argc, char **argv)
212} 212}
213 213
214/* Add a source file name boundary marker in the output file. */ 214/* Add a source file name boundary marker in the output file. */
215void 215static void
216put_filename (char *filename) 216put_filename (char *filename)
217{ 217{
218 char *tmp; 218 char *tmp;
@@ -231,7 +231,7 @@ put_filename (char *filename)
231/* Read file FILENAME and output its doc strings to outfile. */ 231/* Read file FILENAME and output its doc strings to outfile. */
232/* Return 1 if file is not found, 0 if it is found. */ 232/* Return 1 if file is not found, 0 if it is found. */
233 233
234int 234static int
235scan_file (char *filename) 235scan_file (char *filename)
236{ 236{
237 237
@@ -247,7 +247,7 @@ scan_file (char *filename)
247 return scan_c_file (filename, READ_TEXT); 247 return scan_c_file (filename, READ_TEXT);
248} 248}
249 249
250void 250static void
251start_globals (void) 251start_globals (void)
252{ 252{
253 fprintf (outfile, "/* This file was auto-generated by make-docfile. */\n"); 253 fprintf (outfile, "/* This file was auto-generated by make-docfile. */\n");
@@ -255,7 +255,7 @@ start_globals (void)
255 fprintf (outfile, "struct emacs_globals {\n"); 255 fprintf (outfile, "struct emacs_globals {\n");
256} 256}
257 257
258char buf[128]; 258static char input_buffer[128];
259 259
260/* Some state during the execution of `read_c_string_or_comment'. */ 260/* Some state during the execution of `read_c_string_or_comment'. */
261struct rcsoc_state 261struct rcsoc_state
@@ -388,14 +388,14 @@ scan_keyword_or_put_char (int ch, struct rcsoc_state *state)
388 at the beginning of a line will be removed, and *SAW_USAGE set to 388 at the beginning of a line will be removed, and *SAW_USAGE set to
389 true if any were encountered. */ 389 true if any were encountered. */
390 390
391int 391static int
392read_c_string_or_comment (FILE *infile, int printflag, int comment, int *saw_usage) 392read_c_string_or_comment (FILE *infile, int printflag, int comment, int *saw_usage)
393{ 393{
394 register int c; 394 register int c;
395 struct rcsoc_state state; 395 struct rcsoc_state state;
396 396
397 state.in_file = infile; 397 state.in_file = infile;
398 state.buf_ptr = (printflag < 0 ? buf : 0); 398 state.buf_ptr = (printflag < 0 ? input_buffer : 0);
399 state.out_file = (printflag > 0 ? outfile : 0); 399 state.out_file = (printflag > 0 ? outfile : 0);
400 state.pending_spaces = 0; 400 state.pending_spaces = 0;
401 state.pending_newlines = 0; 401 state.pending_newlines = 0;
@@ -476,7 +476,7 @@ read_c_string_or_comment (FILE *infile, int printflag, int comment, int *saw_usa
476/* Write to file OUT the argument names of function FUNC, whose text is in BUF. 476/* Write to file OUT the argument names of function FUNC, whose text is in BUF.
477 MINARGS and MAXARGS are the minimum and maximum number of arguments. */ 477 MINARGS and MAXARGS are the minimum and maximum number of arguments. */
478 478
479void 479static void
480write_c_args (FILE *out, char *func, char *buf, int minargs, int maxargs) 480write_c_args (FILE *out, char *func, char *buf, int minargs, int maxargs)
481{ 481{
482 register char *p; 482 register char *p;
@@ -610,14 +610,14 @@ compare_globals (const void *a, const void *b)
610 return strcmp (ga->name, gb->name); 610 return strcmp (ga->name, gb->name);
611} 611}
612 612
613void 613static void
614write_globals (void) 614write_globals (void)
615{ 615{
616 int i; 616 int i;
617 qsort (globals, num_globals, sizeof (struct global), compare_globals); 617 qsort (globals, num_globals, sizeof (struct global), compare_globals);
618 for (i = 0; i < num_globals; ++i) 618 for (i = 0; i < num_globals; ++i)
619 { 619 {
620 char *type; 620 char const *type;
621 621
622 switch (globals[i].type) 622 switch (globals[i].type)
623 { 623 {
@@ -652,18 +652,14 @@ write_globals (void)
652 Looks for DEFUN constructs such as are defined in ../src/lisp.h. 652 Looks for DEFUN constructs such as are defined in ../src/lisp.h.
653 Accepts any word starting DEF... so it finds DEFSIMPLE and DEFPRED. */ 653 Accepts any word starting DEF... so it finds DEFSIMPLE and DEFPRED. */
654 654
655int 655static int
656scan_c_file (char *filename, const char *mode) 656scan_c_file (char *filename, const char *mode)
657{ 657{
658 FILE *infile; 658 FILE *infile;
659 register int c; 659 register int c;
660 register int commas; 660 register int commas;
661 register int defunflag;
662 register int defvarperbufferflag;
663 register int defvarflag;
664 int minargs, maxargs; 661 int minargs, maxargs;
665 int extension = filename[strlen (filename) - 1]; 662 int extension = filename[strlen (filename) - 1];
666 enum global_type type;
667 663
668 if (extension == 'o') 664 if (extension == 'o')
669 filename[strlen (filename) - 1] = 'c'; 665 filename[strlen (filename) - 1] = 'c';
@@ -693,6 +689,10 @@ scan_c_file (char *filename, const char *mode)
693 while (!feof (infile)) 689 while (!feof (infile))
694 { 690 {
695 int doc_keyword = 0; 691 int doc_keyword = 0;
692 int defunflag = 0;
693 int defvarperbufferflag = 0;
694 int defvarflag = 0;
695 enum global_type type = INVALID;
696 696
697 if (c != '\n' && c != '\r') 697 if (c != '\n' && c != '\r')
698 { 698 {
@@ -726,7 +726,6 @@ scan_c_file (char *filename, const char *mode)
726 continue; 726 continue;
727 727
728 defvarflag = 1; 728 defvarflag = 1;
729 defunflag = 0;
730 729
731 c = getc (infile); 730 c = getc (infile);
732 defvarperbufferflag = (c == 'P'); 731 defvarperbufferflag = (c == 'P');
@@ -738,8 +737,6 @@ scan_c_file (char *filename, const char *mode)
738 type = LISP_OBJECT; 737 type = LISP_OBJECT;
739 else if (c == 'B') 738 else if (c == 'B')
740 type = BOOLEAN; 739 type = BOOLEAN;
741 else
742 type = INVALID;
743 } 740 }
744 741
745 c = getc (infile); 742 c = getc (infile);
@@ -758,8 +755,6 @@ scan_c_file (char *filename, const char *mode)
758 continue; 755 continue;
759 c = getc (infile); 756 c = getc (infile);
760 defunflag = c == 'U'; 757 defunflag = c == 'U';
761 defvarflag = 0;
762 defvarperbufferflag = 0;
763 } 758 }
764 else continue; 759 else continue;
765 760
@@ -795,15 +790,15 @@ scan_c_file (char *filename, const char *mode)
795 /* Read in the identifier. */ 790 /* Read in the identifier. */
796 do 791 do
797 { 792 {
798 buf[i++] = c; 793 input_buffer[i++] = c;
799 c = getc (infile); 794 c = getc (infile);
800 } 795 }
801 while (! (c == ',' || c == ' ' || c == '\t' || 796 while (! (c == ',' || c == ' ' || c == '\t' ||
802 c == '\n' || c == '\r')); 797 c == '\n' || c == '\r'));
803 buf[i] = '\0'; 798 input_buffer[i] = '\0';
804 799
805 name = xmalloc (i + 1); 800 name = xmalloc (i + 1);
806 memcpy (name, buf, i + 1); 801 memcpy (name, input_buffer, i + 1);
807 add_global (type, name); 802 add_global (type, name);
808 continue; 803 continue;
809 } 804 }
@@ -888,7 +883,7 @@ scan_c_file (char *filename, const char *mode)
888 883
889 putc (037, outfile); 884 putc (037, outfile);
890 putc (defvarflag ? 'V' : 'F', outfile); 885 putc (defvarflag ? 'V' : 'F', outfile);
891 fprintf (outfile, "%s\n", buf); 886 fprintf (outfile, "%s\n", input_buffer);
892 887
893 if (comment) 888 if (comment)
894 getc (infile); /* Skip past `*' */ 889 getc (infile); /* Skip past `*' */
@@ -931,11 +926,12 @@ scan_c_file (char *filename, const char *mode)
931 *p = '\0'; 926 *p = '\0';
932 /* Output them. */ 927 /* Output them. */
933 fprintf (outfile, "\n\n"); 928 fprintf (outfile, "\n\n");
934 write_c_args (outfile, buf, argbuf, minargs, maxargs); 929 write_c_args (outfile, input_buffer, argbuf, minargs, maxargs);
935 } 930 }
936 else if (defunflag && maxargs == -1 && !saw_usage) 931 else if (defunflag && maxargs == -1 && !saw_usage)
937 /* The DOC should provide the usage form. */ 932 /* The DOC should provide the usage form. */
938 fprintf (stderr, "Missing `usage' for function `%s'.\n", buf); 933 fprintf (stderr, "Missing `usage' for function `%s'.\n",
934 input_buffer);
939 } 935 }
940 } 936 }
941 eof: 937 eof:
@@ -979,7 +975,7 @@ scan_c_file (char *filename, const char *mode)
979 An entry is output only if DOCSTRING has \ newline just after the opening " 975 An entry is output only if DOCSTRING has \ newline just after the opening "
980 */ 976 */
981 977
982void 978static void
983skip_white (FILE *infile) 979skip_white (FILE *infile)
984{ 980{
985 char c = ' '; 981 char c = ' ';
@@ -988,7 +984,7 @@ skip_white (FILE *infile)
988 ungetc (c, infile); 984 ungetc (c, infile);
989} 985}
990 986
991void 987static void
992read_lisp_symbol (FILE *infile, char *buffer) 988read_lisp_symbol (FILE *infile, char *buffer)
993{ 989{
994 char c; 990 char c;
@@ -1016,7 +1012,7 @@ read_lisp_symbol (FILE *infile, char *buffer)
1016 skip_white (infile); 1012 skip_white (infile);
1017} 1013}
1018 1014
1019int 1015static int
1020scan_lisp_file (const char *filename, const char *mode) 1016scan_lisp_file (const char *filename, const char *mode)
1021{ 1017{
1022 FILE *infile; 1018 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 \
135 cm.o term.o terminal.o xfaces.o \ 135 cm.o term.o terminal.o xfaces.o \
136 emacs.o keyboard.o macros.o keymap.o sysdep.o \ 136 emacs.o keyboard.o macros.o keymap.o sysdep.o \
137 buffer.o filelock.o insdel.o marker.o \ 137 buffer.o filelock.o insdel.o marker.o \
138 minibuf.o fileio.o dired.o filemode.o \ 138 minibuf.o fileio.o dired.o \
139 cmds.o casetab.o casefiddle.o indent.o search.o regex.o undo.o \ 139 cmds.o casetab.o casefiddle.o indent.o search.o regex.o undo.o \
140 alloc.o data.o doc.o editfns.o callint.o \ 140 alloc.o data.o doc.o editfns.o callint.o \
141 eval.o floatfns.o fns.o print.o lread.o \ 141 eval.o floatfns.o fns.o print.o lread.o \
@@ -381,6 +381,13 @@ $(BLD)/ctags.$(O) : \
381 $(SRC)/ntlib.h \ 381 $(SRC)/ntlib.h \
382 $(EMACS_ROOT)/lib/getopt.h 382 $(EMACS_ROOT)/lib/getopt.h
383 383
384$(BLD)/ebrowse.$(O) : \
385 $(SRC)/ebrowse.c \
386 $(EMACS_ROOT)/lib/min-max.h \
387 $(EMACS_ROOT)/src/s/ms-w32.h \
388 $(EMACS_ROOT)/src/m/intel386.h \
389 $(EMACS_ROOT)/lib-src/../src/config.h
390
384$(BLD)/emacsclient.$(O) : \ 391$(BLD)/emacsclient.$(O) : \
385 $(SRC)/emacsclient.c \ 392 $(SRC)/emacsclient.c \
386 $(EMACS_ROOT)/nt/inc/sys/stat.h \ 393 $(EMACS_ROOT)/nt/inc/sys/stat.h \
@@ -447,6 +454,7 @@ $(BLD)/ntlib.$(O) : \
447$(BLD)/pop.$(O) : \ 454$(BLD)/pop.$(O) : \
448 $(SRC)/pop.c \ 455 $(SRC)/pop.c \
449 $(SRC)/pop.h \ 456 $(SRC)/pop.h \
457 $(EMACS_ROOT)/lib/min-max.h \
450 $(SRC)/ntlib.h 458 $(SRC)/ntlib.h
451 459
452$(BLD)/profile.$(O) : \ 460$(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/>. */
80#undef access 80#undef access
81#endif /* MSDOS */ 81#endif /* MSDOS */
82 82
83#ifndef DIRECTORY_SEP
84#define DIRECTORY_SEP '/'
85#endif
86#ifndef IS_DIRECTORY_SEP
87#define IS_DIRECTORY_SEP(_c_) ((_c_) == DIRECTORY_SEP)
88#endif
89
90#ifdef WINDOWSNT 83#ifdef WINDOWSNT
91#include "ntlib.h" 84#include "ntlib.h"
92#undef access 85#undef access
@@ -161,7 +154,7 @@ static int mbx_delimit_end (FILE *mbf);
161#endif 154#endif
162 155
163/* Nonzero means this is name of a lock file to delete on fatal error. */ 156/* Nonzero means this is name of a lock file to delete on fatal error. */
164char *delete_lockname; 157static char *delete_lockname;
165 158
166int 159int
167main (int argc, char **argv) 160main (int argc, char **argv)
@@ -169,7 +162,7 @@ main (int argc, char **argv)
169 char *inname, *outname; 162 char *inname, *outname;
170 int indesc, outdesc; 163 int indesc, outdesc;
171 ssize_t nread; 164 ssize_t nread;
172 int status; 165 int wait_status;
173 int c, preserve_mail = 0; 166 int c, preserve_mail = 0;
174 167
175#ifndef MAIL_USE_SYSTEM_LOCK 168#ifndef MAIL_USE_SYSTEM_LOCK
@@ -269,6 +262,13 @@ main (int argc, char **argv)
269 if (! spool_name) 262 if (! spool_name)
270#endif 263#endif
271 { 264 {
265 #ifndef DIRECTORY_SEP
266 #define DIRECTORY_SEP '/'
267 #endif
268 #ifndef IS_DIRECTORY_SEP
269 #define IS_DIRECTORY_SEP(_c_) ((_c_) == DIRECTORY_SEP)
270 #endif
271
272 /* Use a lock file named after our first argument with .lock appended: 272 /* Use a lock file named after our first argument with .lock appended:
273 If it exists, the mail file is locked. */ 273 If it exists, the mail file is locked. */
274 /* Note: this locking mechanism is *required* by the mailer 274 /* Note: this locking mechanism is *required* by the mailer
@@ -527,11 +527,11 @@ main (int argc, char **argv)
527 exit (EXIT_SUCCESS); 527 exit (EXIT_SUCCESS);
528 } 528 }
529 529
530 wait (&status); 530 wait (&wait_status);
531 if (!WIFEXITED (status)) 531 if (!WIFEXITED (wait_status))
532 exit (EXIT_FAILURE); 532 exit (EXIT_FAILURE);
533 else if (WRETCODE (status) != 0) 533 else if (WRETCODE (wait_status) != 0)
534 exit (WRETCODE (status)); 534 exit (WRETCODE (wait_status));
535 535
536#if !defined (MAIL_USE_MMDF) && !defined (MAIL_USE_SYSTEM_LOCK) 536#if !defined (MAIL_USE_MMDF) && !defined (MAIL_USE_SYSTEM_LOCK)
537#ifdef MAIL_USE_MAILLOCK 537#ifdef MAIL_USE_MAILLOCK
@@ -670,14 +670,8 @@ xmalloc (unsigned int size)
670 670
671#define NOTOK (-1) 671#define NOTOK (-1)
672#define OK 0 672#define OK 0
673#define DONE 1 673
674 674static char Errmsg[200]; /* POP errors, at least, can exceed
675char *progname;
676FILE *sfi;
677FILE *sfo;
678char ibuffer[BUFSIZ];
679char obuffer[BUFSIZ];
680char Errmsg[200]; /* POP errors, at least, can exceed
681 the original length of 80. */ 675 the original length of 80. */
682 676
683/* 677/*
@@ -736,7 +730,18 @@ popmail (char *mailbox, char *outfile, int preserve, char *password, int reverse
736 error ("Error in open: %s, %s", strerror (errno), outfile); 730 error ("Error in open: %s, %s", strerror (errno), outfile);
737 return EXIT_FAILURE; 731 return EXIT_FAILURE;
738 } 732 }
739 fchown (mbfi, getuid (), -1); 733
734 if (fchown (mbfi, getuid (), -1) != 0)
735 {
736 int fchown_errno = errno;
737 struct stat st;
738 if (fstat (mbfi, &st) != 0 || st.st_uid != getuid ())
739 {
740 pop_close (server);
741 error ("Error in fchown: %s, %s", strerror (fchown_errno), outfile);
742 return EXIT_FAILURE;
743 }
744 }
740 745
741 if ((mbf = fdopen (mbfi, "wb")) == NULL) 746 if ((mbf = fdopen (mbfi, "wb")) == NULL)
742 { 747 {
@@ -828,10 +833,10 @@ pop_retr (popserver server, int msgno, FILE *arg)
828 833
829 if (pop_retrieve_first (server, msgno, &line)) 834 if (pop_retrieve_first (server, msgno, &line))
830 { 835 {
831 char *error = concat ("Error from POP server: ", pop_error, ""); 836 char *msg = concat ("Error from POP server: ", pop_error, "");
832 strncpy (Errmsg, error, sizeof (Errmsg)); 837 strncpy (Errmsg, msg, sizeof (Errmsg));
833 Errmsg[sizeof (Errmsg)-1] = '\0'; 838 Errmsg[sizeof (Errmsg)-1] = '\0';
834 free(error); 839 free (msg);
835 return (NOTOK); 840 return (NOTOK);
836 } 841 }
837 842
@@ -850,27 +855,26 @@ pop_retr (popserver server, int msgno, FILE *arg)
850 855
851 if (ret) 856 if (ret)
852 { 857 {
853 char *error = concat ("Error from POP server: ", pop_error, ""); 858 char *msg = concat ("Error from POP server: ", pop_error, "");
854 strncpy (Errmsg, error, sizeof (Errmsg)); 859 strncpy (Errmsg, msg, sizeof (Errmsg));
855 Errmsg[sizeof (Errmsg)-1] = '\0'; 860 Errmsg[sizeof (Errmsg)-1] = '\0';
856 free(error); 861 free (msg);
857 return (NOTOK); 862 return (NOTOK);
858 } 863 }
859 864
860 return (OK); 865 return (OK);
861} 866}
862 867
863/* Do this as a macro instead of using strcmp to save on execution time. */
864#define IS_FROM_LINE(a) ((a[0] == 'F') \
865 && (a[1] == 'r') \
866 && (a[2] == 'o') \
867 && (a[3] == 'm') \
868 && (a[4] == ' '))
869
870static int 868static int
871mbx_write (char *line, int len, FILE *mbf) 869mbx_write (char *line, int len, FILE *mbf)
872{ 870{
873#ifdef MOVEMAIL_QUOTE_POP_FROM_LINES 871#ifdef MOVEMAIL_QUOTE_POP_FROM_LINES
872 /* Do this as a macro instead of using strcmp to save on execution time. */
873 # define IS_FROM_LINE(a) ((a[0] == 'F') \
874 && (a[1] == 'r') \
875 && (a[2] == 'o') \
876 && (a[3] == 'm') \
877 && (a[4] == ' '))
874 if (IS_FROM_LINE (line)) 878 if (IS_FROM_LINE (line))
875 { 879 {
876 if (fputc ('>', mbf) == EOF) 880 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 * */);
67#include <stdio.h> 67#include <stdio.h>
68#ifdef STDC_HEADERS 68#ifdef STDC_HEADERS
69#include <string.h> 69#include <string.h>
70#define index strchr
71#endif 70#endif
72#include <unistd.h> 71#include <unistd.h>
73 72
@@ -91,6 +90,8 @@ extern struct servent *hes_getservbyname (/* char *, char * */);
91# endif 90# endif
92#endif /* KERBEROS */ 91#endif /* KERBEROS */
93 92
93#include <min-max.h>
94
94#ifdef KERBEROS 95#ifdef KERBEROS
95#ifndef KERBEROS5 96#ifndef KERBEROS5
96extern int krb_sendauth (/* long, int, KTEXT, char *, char *, char *, 97extern int krb_sendauth (/* long, int, KTEXT, char *, char *, char *,
@@ -122,19 +123,15 @@ static char *find_crlf (char *, int);
122 to be bigger than the original 123 to be bigger than the original
123 value of 80 */ 124 value of 80 */
124#define POP_PORT 110 125#define POP_PORT 110
125#define KPOP_PORT 1109
126#define POP_SERVICE "pop3" /* we don't want the POP2 port! */ 126#define POP_SERVICE "pop3" /* we don't want the POP2 port! */
127#ifdef KERBEROS 127#ifdef KERBEROS
128#define KPOP_PORT 1109
128#define KPOP_SERVICE "kpop" /* never used: look for 20060515 to see why */ 129#define KPOP_SERVICE "kpop" /* never used: look for 20060515 to see why */
129#endif 130#endif
130 131
131char pop_error[ERROR_MAX]; 132char pop_error[ERROR_MAX];
132int pop_debug = 0; 133int pop_debug = 0;
133 134
134#ifndef min
135#define min(a,b) (((a) < (b)) ? (a) : (b))
136#endif
137
138/* 135/*
139 * Function: pop_open (char *host, char *username, char *password, 136 * Function: pop_open (char *host, char *username, char *password,
140 * int flags) 137 * 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];
38 38
39/* Reset the stopwatch to zero. */ 39/* Reset the stopwatch to zero. */
40 40
41void 41static void
42reset_watch (void) 42reset_watch (void)
43{ 43{
44 EMACS_GET_TIME (TV1); 44 EMACS_GET_TIME (TV1);
@@ -49,7 +49,7 @@ reset_watch (void)
49 is returned as a string with the format <seconds>.<micro-seconds> 49 is returned as a string with the format <seconds>.<micro-seconds>
50 If reset_watch was not called yet, exit. */ 50 If reset_watch was not called yet, exit. */
51 51
52char * 52static char *
53get_time (void) 53get_time (void)
54{ 54{
55 if (watch_not_started) 55 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/>. */
26/* Break string in two parts to avoid buggy C compilers that ignore characters 26/* Break string in two parts to avoid buggy C compilers that ignore characters
27 after nulls in strings. */ 27 after nulls in strings. */
28 28
29char string1[] = "Testing distribution of nonprinting chars:\n\ 29static char string1[] = "Testing distribution of nonprinting chars:\n\
30Should be 0177: \177 Should be 0377: \377 Should be 0212: \212.\n\ 30Should be 0177: \177 Should be 0377: \377 Should be 0212: \212.\n\
31Should be 0000: "; 31Should be 0000: ";
32 32
33char string2[] = ".\n\ 33static char string2[] = ".\n\
34This file is read by the `test-distribution' program.\n\ 34This file is read by the `test-distribution' program.\n\
35If you change it, you will make that program fail.\n"; 35If you change it, you will make that program fail.\n";
36 36
37char buf[300];
38
39/* Like `read' but keeps trying until it gets SIZE bytes or reaches eof. */ 37/* Like `read' but keeps trying until it gets SIZE bytes or reaches eof. */
40int 38static int
41cool_read (int fd, char *buf, size_t size) 39cool_read (int fd, char *buf, size_t size)
42{ 40{
43 ssize_t num; 41 ssize_t num;
@@ -57,6 +55,7 @@ int
57main (int argc, char **argv) 55main (int argc, char **argv)
58{ 56{
59 int fd; 57 int fd;
58 char buf[300];
60 59
61 if (argc != 2) 60 if (argc != 2)
62 { 61 {
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/>. */
57extern char *optarg; 57extern char *optarg;
58extern int optind, opterr; 58extern int optind, opterr;
59 59
60int usage (int err) NO_RETURN; 60static int usage (int err) NO_RETURN;
61 61
62#define MAX_ATTEMPTS 5 62#define MAX_ATTEMPTS 5
63#define MAX_SCORES 200 63#define MAX_SCORES 200
@@ -68,7 +68,7 @@ int usage (int err) NO_RETURN;
68#define difftime(t1, t0) (double)((t1) - (t0)) 68#define difftime(t1, t0) (double)((t1) - (t0))
69#endif 69#endif
70 70
71int 71static int
72usage (int err) 72usage (int err)
73{ 73{
74 fprintf (stdout, "Usage: update-game-score [-m MAX ] [ -r ] game/scorefile SCORE DATA\n"); 74 fprintf (stdout, "Usage: update-game-score [-m MAX ] [ -r ] game/scorefile SCORE DATA\n");
@@ -80,8 +80,8 @@ usage (int err)
80 exit (err); 80 exit (err);
81} 81}
82 82
83int lock_file (const char *filename, void **state); 83static int lock_file (const char *filename, void **state);
84int unlock_file (const char *filename, void *state); 84static int unlock_file (const char *filename, void *state);
85 85
86struct score_entry 86struct score_entry
87{ 87{
@@ -90,24 +90,24 @@ struct score_entry
90 char *data; 90 char *data;
91}; 91};
92 92
93int read_scores (const char *filename, struct score_entry **scores, 93static int read_scores (const char *filename, struct score_entry **scores,
94 int *count); 94 int *count);
95int push_score (struct score_entry **scores, int *count, 95static int push_score (struct score_entry **scores, int *count,
96 int newscore, char *username, char *newdata); 96 int newscore, char *username, char *newdata);
97void sort_scores (struct score_entry *scores, int count, int reverse); 97static void sort_scores (struct score_entry *scores, int count, int reverse);
98int write_scores (const char *filename, const struct score_entry *scores, 98static int write_scores (const char *filename,
99 int count); 99 const struct score_entry *scores, int count);
100 100
101void lose (const char *msg) NO_RETURN; 101static void lose (const char *msg) NO_RETURN;
102 102
103void 103static void
104lose (const char *msg) 104lose (const char *msg)
105{ 105{
106 fprintf (stderr, "%s\n", msg); 106 fprintf (stderr, "%s\n", msg);
107 exit (EXIT_FAILURE); 107 exit (EXIT_FAILURE);
108} 108}
109 109
110void lose_syserr (const char *msg) NO_RETURN; 110static void lose_syserr (const char *msg) NO_RETURN;
111 111
112/* Taken from sysdep.c. */ 112/* Taken from sysdep.c. */
113#ifndef HAVE_STRERROR 113#ifndef HAVE_STRERROR
@@ -126,14 +126,14 @@ strerror (errnum)
126#endif /* not WINDOWSNT */ 126#endif /* not WINDOWSNT */
127#endif /* ! HAVE_STRERROR */ 127#endif /* ! HAVE_STRERROR */
128 128
129void 129static void
130lose_syserr (const char *msg) 130lose_syserr (const char *msg)
131{ 131{
132 fprintf (stderr, "%s: %s\n", msg, strerror (errno)); 132 fprintf (stderr, "%s: %s\n", msg, strerror (errno));
133 exit (EXIT_FAILURE); 133 exit (EXIT_FAILURE);
134} 134}
135 135
136char * 136static char *
137get_user_id (void) 137get_user_id (void)
138{ 138{
139 char *name; 139 char *name;
@@ -154,7 +154,7 @@ get_user_id (void)
154 return buf->pw_name; 154 return buf->pw_name;
155} 155}
156 156
157const char * 157static const char *
158get_prefix (int running_suid, const char *user_prefix) 158get_prefix (int running_suid, const char *user_prefix)
159{ 159{
160 if (!running_suid && user_prefix == NULL) 160 if (!running_suid && user_prefix == NULL)
@@ -258,7 +258,7 @@ main (int argc, char **argv)
258 exit (EXIT_SUCCESS); 258 exit (EXIT_SUCCESS);
259} 259}
260 260
261int 261static int
262read_score (FILE *f, struct score_entry *score) 262read_score (FILE *f, struct score_entry *score)
263{ 263{
264 int c; 264 int c;
@@ -342,7 +342,7 @@ read_score (FILE *f, struct score_entry *score)
342 return 0; 342 return 0;
343} 343}
344 344
345int 345static int
346read_scores (const char *filename, struct score_entry **scores, int *count) 346read_scores (const char *filename, struct score_entry **scores, int *count)
347{ 347{
348 int readval, scorecount, cursize; 348 int readval, scorecount, cursize;
@@ -375,7 +375,7 @@ read_scores (const char *filename, struct score_entry **scores, int *count)
375 return 0; 375 return 0;
376} 376}
377 377
378int 378static int
379score_compare (const void *a, const void *b) 379score_compare (const void *a, const void *b)
380{ 380{
381 const struct score_entry *sa = (const struct score_entry *) a; 381 const struct score_entry *sa = (const struct score_entry *) a;
@@ -383,7 +383,7 @@ score_compare (const void *a, const void *b)
383 return (sb->score > sa->score) - (sb->score < sa->score); 383 return (sb->score > sa->score) - (sb->score < sa->score);
384} 384}
385 385
386int 386static int
387score_compare_reverse (const void *a, const void *b) 387score_compare_reverse (const void *a, const void *b)
388{ 388{
389 const struct score_entry *sa = (const struct score_entry *) a; 389 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
407 return 0; 407 return 0;
408} 408}
409 409
410void 410static void
411sort_scores (struct score_entry *scores, int count, int reverse) 411sort_scores (struct score_entry *scores, int count, int reverse)
412{ 412{
413 qsort (scores, count, sizeof (struct score_entry), 413 qsort (scores, count, sizeof (struct score_entry),
414 reverse ? score_compare_reverse : score_compare); 414 reverse ? score_compare_reverse : score_compare);
415} 415}
416 416
417int 417static int
418write_scores (const char *filename, const struct score_entry *scores, int count) 418write_scores (const char *filename, const struct score_entry *scores, int count)
419{ 419{
420 FILE *f; 420 FILE *f;
@@ -443,7 +443,7 @@ write_scores (const char *filename, const struct score_entry *scores, int count)
443 return 0; 443 return 0;
444} 444}
445 445
446int 446static int
447lock_file (const char *filename, void **state) 447lock_file (const char *filename, void **state)
448{ 448{
449 int fd; 449 int fd;
@@ -484,7 +484,7 @@ lock_file (const char *filename, void **state)
484 return 0; 484 return 0;
485} 485}
486 486
487int 487static int
488unlock_file (const char *filename, void *state) 488unlock_file (const char *filename, void *state)
489{ 489{
490 char *lockpath = (char *) state; 490 char *lockpath = (char *) state;