aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src
diff options
context:
space:
mode:
authorKenichi Handa2012-07-17 07:25:00 +0900
committerKenichi Handa2012-07-17 07:25:00 +0900
commit69c41c4070c86baac11a627e9c3d366420aeb7cc (patch)
treee07fda92570b5e4f264c9a7869b57960940008f0 /lib-src
parent8c536f15bf95916d56bb50495d22b7da7e09fff9 (diff)
parent758e556a7ab8f61c007e34310ba399a9aaf15362 (diff)
downloademacs-69c41c4070c86baac11a627e9c3d366420aeb7cc.tar.gz
emacs-69c41c4070c86baac11a627e9c3d366420aeb7cc.zip
merge trunk
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/ChangeLog177
-rw-r--r--lib-src/Makefile.in34
-rw-r--r--lib-src/ebrowse.c8
-rw-r--r--lib-src/emacsclient.c89
-rw-r--r--lib-src/etags.c129
-rw-r--r--lib-src/hexl.c4
-rw-r--r--lib-src/make-docfile.c109
-rw-r--r--lib-src/makefile.w32-in173
-rw-r--r--lib-src/movemail.c97
-rw-r--r--lib-src/pop.c79
-rw-r--r--lib-src/profile.c39
-rw-r--r--lib-src/update-game-score.c28
-rwxr-xr-xlib-src/vcdiff114
13 files changed, 497 insertions, 583 deletions
diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog
index 5a5a04a770e..4f4d2b50a00 100644
--- a/lib-src/ChangeLog
+++ b/lib-src/ChangeLog
@@ -1,3 +1,180 @@
12012-07-12 Paul Eggert <eggert@cs.ucla.edu>
2
3 * movemail.c: Add missing 'defined'.
4 Suggested by Sven Joachim in
5 <http://lists.gnu.org/archive/html/emacs-devel/2012-07/msg00218.html>.
6
72012-07-11 Paul Eggert <eggert@cs.ucla.edu>
8
9 Port 'movemail' again to Solaris and similar hosts.
10 See Susan Cragin's report in
11 <http://lists.gnu.org/archive/html/emacs-devel/2012-07/msg00199.html>.
12 * movemail.c (xmalloc): Also define if !DISABLE_DIRECT_ACCESS &&
13 !MAIL_USE_MMDF && !MAIL_USE_SYSTEM_LOCK. Move up, so it doesn't
14 need a forward declaration.
15 (main): Rewrite to avoid no-longer-present function 'concat', if
16 !DISABLE_DIRECT_ACCESS && !MAIL_USE_MMDF && !MAIL_USE_SYSTEM_LOCK.
17
18 Assume strerror.
19 * emacsclient.c, movemail.c, update-game-score.c (strerror)
20 [!HAVE_STRERROR]: Remove.
21
222012-07-10 Paul Eggert <eggert@cs.ucla.edu>
23
24 EMACS_TIME simplification (Bug#11875).
25 * profile.c (TV2): Remove no-longer-needed static var.
26
27 Simplify by avoiding confusing use of strncpy etc.
28 * etags.c (write_classname, C_entries):
29 Use sprintf rather than strncpy or strncat.
30 * etags.c (consider_token, C_entries, HTML_labels, Prolog_functions)
31 (Erlang_functions, substitute, readline_internal, savenstr):
32 * movemail.c (mail_spool_name):
33 Use memcpy rather than strncpy or strncat when either will do.
34 * make-docfile.c (write_c_args):
35 Use memcmp rather than strncmp when either will do.
36 * movemail.c (pop_retr):
37 * pop.c (pop_stat, pop_list, pop_multi_first, pop_last)
38 (socket_connection, pop_getline, sendline, getok):
39 Use snprintf rather than strncpy or strncat.
40 * movemail.c (concat): Remove; no longer needed.
41 (xmalloc): Define only if needed, now that concat has gone away.
42 Return void *. All uses changed.
43
442012-07-09 Paul Eggert <eggert@cs.ucla.edu>
45
46 Add GCC-style 'const' attribute to functions that can use it.
47 * etags.c (number_len): Add ATTRIBUTE_CONST.
48
492012-07-09 Juanma Barranquero <lekktu@gmail.com>
50
51 * emacsclient.c (w32_execvp): Declare execvp to silence the compiler.
52
532012-07-09 Juanma Barranquero <lekktu@gmail.com>
54
55 * makefile.w32-in ($(BLD)/test-distrib.exe): Use LIB_SRC, not SRC.
56 (LIB_SRC, NT_INC, GNU_LIB, MS_W32_H, CONFIG_H, INTTYPES_H, NTLIB_H)
57 (SYSTIME_H): New macros.
58 (SRC): Redefine to point to src/, not current directory.
59 ($(BLD)/ctags.$(O), $(BLD)/ebrowse.$(O), $(BLD)/emacsclient.$(O))
60 ($(BLD)/etags.$(O), $(BLD)/hexl.$(O), $(BLD)/make-docfile.$(O))
61 ($(BLD)/movemail.$(O), $(BLD)/ntlib.$(O), $(BLD)/pop.$(O))
62 ($(BLD)/profile.$(O), $(BLD)/test-distrib.$(O)): Update dependencies.
63 ($(BLD)/regex.$(O)): New dependency.
64
652012-07-09 Juanma Barranquero <lekktu@gmail.com>
66
67 * makefile.w32-in (ALL): Add profile.exe.
68 (PROFILEOBJS): New macro.
69 ($(BLD)/profile.exe): New target.
70 (install): Copy profile.exe.
71 ($(BLD)/alloca.$(O), $(BLD)/tcp.$(O)): Remove, obsolete.
72
732012-07-07 Juanma Barranquero <lekktu@gmail.com>
74
75 * makefile.w32-in ($(BLD)/ctags.$(O), $(BLD)/etags.$(O)):
76 Update dependencies.
77
782012-07-06 Paul Eggert <eggert@cs.ucla.edu>
79
80 Use c_strcasecmp for ASCII case-insensitive comparison (Bug#11786).
81 * etags.c: Include c-strcase.h.
82 (etags_strcasecmp, etags_strncasecmp): Remove.
83 All uses replaced with c_strcasecmp and c_strncasecmp.
84
852012-07-06 Andreas Schwab <schwab@linux-m68k.org>
86
87 * make-docfile.c (write_globals): Warn about duplicate function
88 definitions with differing signatures.
89
902012-07-03 Paul Eggert <eggert@cs.ucla.edu>
91
92 * make-docfile.c (scan_c_file): Suppress GCC warning.
93
942012-06-29 Tom Tromey <tromey@redhat.com>
95
96 * make-docfile.c (enum global_type) <FUNCTION>: New constant.
97 (struct global) <value>: New field.
98 (add_global): Add 'value' argument.
99 (compare_globals): Sort functions at the end.
100 (close_emacs_globals): New function.
101 (write_globals): Handle functions.
102 (scan_c_file): Call add_global for DEFUN.
103
1042012-06-30 Juanma Barranquero <lekktu@gmail.com>
105
106 * makefile.w32-in (CTAGS_CFLAGS): Remove EMACS_NAME;
107 already defined in ETAGS_CFLAGS.
108
1092012-06-27 Glenn Morris <rgm@gnu.org>
110
111 * makefile.w32-in (lisp2): Remove paths.el.
112
1132012-06-26 Paul Eggert <eggert@cs.ucla.edu>
114
115 Clean out last vestiges of the old HAVE_CONFIG_H stuff.
116 * Makefile.in (BASE_CFLAGS):
117 * makefile.w32-in (LOCAL_FLAGS): Remove -DHAVE_CONFIG_H.
118 * etags.c, hexl.c, pop.c: Include <config.h> unconditionally.
119 * etags.c (DOS_NT):
120 * pop.c (MAIL_USE_POP, h_errno):
121 Remove code that was conditioned on !HAVE_CONFIG_H.
122
1232012-06-25 Dmitry Antipov <dmantipov@yandex.ru>
124
125 * etags.c (etags_strcasecmp, etags_strncasecmp): Define to
126 library functions strcasecmp and strncasecmp if available.
127
1282012-06-24 Paul Eggert <eggert@cs.ucla.edu>
129
130 Switch from NO_RETURN to C11's _Noreturn (Bug#11750).
131 * ebrowse.c (usage, version):
132 * emacsclient.c (print_help_and_exit, fail):
133 * etags.c (suggest_asking_for_help, fatal, pfatal):
134 * hexl.c (usage):
135 * make-docfile.c (fatal):
136 * movemail.c (fatal, pfatal_with_name, pfatal_and_delete):
137 * update-game-score.c (usage):
138 * ebrowse.c (usage, version):
139 * emacsclient.c (print_help_and_exit, fail):
140 Use _Noreturn rather than NO_RETURN.
141 No need for separate decl merely because of _Noreturn.
142
1432012-06-24 Samuel Bronson <naesten@gmail.com> (tiny change)
144
145 * emacsclient.c (set_local_socket): Fix compiler warning (Bug#7838).
146
1472012-06-22 Paul Eggert <eggert@cs.ucla.edu>
148
149 Support higher-resolution time stamps (Bug#9000).
150 * Makefile.in (LIB_CLOCK_GETTIME): New macro.
151 (profile${EXEEXT}): Use it.
152 * profile.c: Include inttypes.h, intprops.h.
153 (time_string): Size conservatively; do not guess size.
154 (get_time): Now prints nanoseconds.
155 (gettimeofday): Remove replacement function; gnulib now does this.
156
1572012-06-08 Andreas Schwab <schwab@linux-m68k.org>
158
159 * make-docfile.c (search_lisp_doc_at_eol): Unget last read
160 character.
161
1622012-06-06 Glenn Morris <rgm@gnu.org>
163
164 * Makefile.in (STAMP_INST_SCRIPTS, STAMP_SCRIPTS, insrcdir)
165 (stamp-rcs2log, stamp-grep-changelog): Remove.
166 (all, clean): Remove references to stamps.
167
168 * vcdiff: Remove file.
169 * Makefile.in (SCRIPTS, STAMP_SCRIPTS): Remove vcdiff.
170 (stamp-vcdiff): Remove.
171
1722012-06-05 Glenn Morris <rgm@gnu.org>
173
174 * makefile.w32-in ($(BLD)/getdate.$(O), $(BLD)/leditcfns.$(O)):
175 ($(BLD)/make-path.$(O), $(BLD)/qsort.$(O)):
176 ($(BLD)/timer.$(O)): Remove cruft.
177
12012-06-03 Glenn Morris <rgm@gnu.org> 1782012-06-03 Glenn Morris <rgm@gnu.org>
2 179
3 * rcs-checkin: Remove file. 180 * rcs-checkin: Remove file.
diff --git a/lib-src/Makefile.in b/lib-src/Makefile.in
index f3fd640576b..fe727c65730 100644
--- a/lib-src/Makefile.in
+++ b/lib-src/Makefile.in
@@ -118,7 +118,6 @@ INSTALLABLES = etags${EXEEXT} ctags${EXEEXT} emacsclient${EXEEXT} \
118 ebrowse${EXEEXT} 118 ebrowse${EXEEXT}
119 119
120INSTALLABLE_SCRIPTS = grep-changelog 120INSTALLABLE_SCRIPTS = grep-changelog
121STAMP_INST_SCRIPTS = stamp-grep-changelog
122 121
123# Things that Emacs runs internally, or during the build process, 122# Things that Emacs runs internally, or during the build process,
124# which should not be installed in bindir. 123# which should not be installed in bindir.
@@ -129,8 +128,7 @@ DONT_INSTALL= test-distrib${EXEEXT} make-docfile${EXEEXT}
129 128
130# Like UTILITIES, but they're not system-dependent, and should not be 129# Like UTILITIES, but they're not system-dependent, and should not be
131# deleted by the distclean target. 130# deleted by the distclean target.
132SCRIPTS= rcs2log vcdiff 131SCRIPTS= rcs2log
133STAMP_SCRIPTS= stamp-rcs2log stamp-vcdiff
134 132
135# All files that are created by the linker, i.e., whose names end in ${EXEEXT}. 133# All files that are created by the linker, i.e., whose names end in ${EXEEXT}.
136EXE_FILES = ${INSTALLABLES} ${UTILITIES} ${DONT_INSTALL} 134EXE_FILES = ${INSTALLABLES} ${UTILITIES} ${DONT_INSTALL}
@@ -161,6 +159,8 @@ LIBHESIOD=@LIBHESIOD@
161LIBRESOLV=@LIBRESOLV@ 159LIBRESOLV=@LIBRESOLV@
162## -llockfile if HAVE_LIBLOCKFILE or -lmail if HAVE_LIBMAIL 160## -llockfile if HAVE_LIBLOCKFILE or -lmail if HAVE_LIBMAIL
163LIBS_MAIL=@LIBS_MAIL@ 161LIBS_MAIL=@LIBS_MAIL@
162## empty or -lrt or -lposix4 if HAVE_CLOCK_GETTIME
163LIB_CLOCK_GETTIME = @LIB_CLOCK_GETTIME@
164 164
165## Extra libraries to use when linking movemail. 165## Extra libraries to use when linking movemail.
166LIBS_MOVE = $(LIBS_MAIL) $(KRB4LIB) $(DESLIB) $(KRB5LIB) $(CRYPTOLIB) \ 166LIBS_MOVE = $(LIBS_MAIL) $(KRB4LIB) $(DESLIB) $(KRB5LIB) $(CRYPTOLIB) \
@@ -169,40 +169,20 @@ LIBS_MOVE = $(LIBS_MAIL) $(KRB4LIB) $(DESLIB) $(KRB5LIB) $(CRYPTOLIB) \
169## Some systems define this to request special libraries. 169## Some systems define this to request special libraries.
170LIBS_SYSTEM = @LIBS_SYSTEM@ 170LIBS_SYSTEM = @LIBS_SYSTEM@
171 171
172# Those files shared with other GNU utilities need HAVE_CONFIG_H
173# defined before they know they can take advantage of the information
174# in ../src/config.h.
175BASE_CFLAGS = $(C_SWITCH_SYSTEM) $(C_SWITCH_MACHINE) \ 172BASE_CFLAGS = $(C_SWITCH_SYSTEM) $(C_SWITCH_MACHINE) \
176 $(WARN_CFLAGS) $(WERROR_CFLAGS) \ 173 $(WARN_CFLAGS) $(WERROR_CFLAGS) \
177 -DHAVE_CONFIG_H -I. -I../src -I../lib \ 174 -I. -I../src -I../lib \
178 -I${srcdir} -I${srcdir}/../src -I${srcdir}/../lib 175 -I${srcdir} -I${srcdir}/../src -I${srcdir}/../lib
179 176
180ALL_CFLAGS = ${BASE_CFLAGS} ${PROFILING_CFLAGS} ${LDFLAGS} ${CPPFLAGS} ${CFLAGS} 177ALL_CFLAGS = ${BASE_CFLAGS} ${PROFILING_CFLAGS} ${LDFLAGS} ${CPPFLAGS} ${CFLAGS}
181LINK_CFLAGS = ${BASE_CFLAGS} ${LDFLAGS} ${CFLAGS} 178LINK_CFLAGS = ${BASE_CFLAGS} ${LDFLAGS} ${CFLAGS}
182CPP_CFLAGS = ${BASE_CFLAGS} ${PROFILING_CFLAGS} ${CPPFLAGS} ${CFLAGS} 179CPP_CFLAGS = ${BASE_CFLAGS} ${PROFILING_CFLAGS} ${CPPFLAGS} ${CFLAGS}
183 180
184all: ${EXE_FILES} ${SCRIPTS} ${INSTALLABLE_SCRIPTS} ${STAMP_INST_SCRIPTS} ${STAMP_SCRIPTS} 181all: ${EXE_FILES} ${SCRIPTS} ${INSTALLABLE_SCRIPTS}
185 182
186LOADLIBES = ../lib/libgnu.a $(LIBS_SYSTEM) 183LOADLIBES = ../lib/libgnu.a $(LIBS_SYSTEM)
187$(EXE_FILES): ../lib/libgnu.a 184$(EXE_FILES): ../lib/libgnu.a
188 185
189## These targets copy the scripts into the build directory so that
190## they can be run from there in an uninstalled Emacs.
191## Nothing to do if pwd = srcdir.
192insrcdir=[ "`/bin/pwd`" = "`cd $(srcdir) && /bin/pwd`" ]
193
194stamp-rcs2log: $(srcdir)/rcs2log
195 $(insrcdir) || cp -p $(srcdir)/rcs2log rcs2log
196 touch $@
197
198stamp-grep-changelog: $(srcdir)/grep-changelog
199 $(insrcdir) || cp -p $(srcdir)/grep-changelog grep-changelog
200 touch $@
201
202stamp-vcdiff: $(srcdir)/vcdiff
203 $(insrcdir) || cp -p $(srcdir)/vcdiff vcdiff
204 touch $@
205
206## Only used if we need blessmail, but no harm in always defining. 186## Only used if we need blessmail, but no harm in always defining.
207## This makes the actual blessmail executable. 187## This makes the actual blessmail executable.
208blessmail: 188blessmail:
@@ -277,7 +257,6 @@ mostlyclean:
277 257
278clean: mostlyclean 258clean: mostlyclean
279 -rm -f ${EXE_FILES} 259 -rm -f ${EXE_FILES}
280 -rm -f ${STAMP_INST_SCRIPTS} ${STAMP_SCRIPTS}
281 260
282distclean: clean 261distclean: clean
283 -rm -f TAGS 262 -rm -f TAGS
@@ -329,7 +308,8 @@ ctags${EXEEXT}: etags${EXEEXT}
329 regex.o $(LOADLIBES) -o ctags 308 regex.o $(LOADLIBES) -o ctags
330 309
331profile${EXEEXT}: ${srcdir}/profile.c ../src/config.h 310profile${EXEEXT}: ${srcdir}/profile.c ../src/config.h
332 $(CC) ${ALL_CFLAGS} ${srcdir}/profile.c $(LOADLIBES) -o profile 311 $(CC) ${ALL_CFLAGS} ${srcdir}/profile.c \
312 $(LOADLIBES) $(LIB_CLOCK_GETTIME) -o profile
333 313
334make-docfile${EXEEXT}: ${srcdir}/make-docfile.c ../src/config.h 314make-docfile${EXEEXT}: ${srcdir}/make-docfile.c ../src/config.h
335 $(CC) ${ALL_CFLAGS} ${srcdir}/make-docfile.c $(LOADLIBES) \ 315 $(CC) ${ALL_CFLAGS} ${srcdir}/make-docfile.c $(LOADLIBES) \
diff --git a/lib-src/ebrowse.c b/lib-src/ebrowse.c
index a1fe10b863a..1c43bc6a4f1 100644
--- a/lib-src/ebrowse.c
+++ b/lib-src/ebrowse.c
@@ -463,10 +463,6 @@ static struct member *add_member (struct sym *, char *, int, int, unsigned);
463static void class_definition (struct sym *, int, int, int); 463static void class_definition (struct sym *, int, int, int);
464static char *operator_name (int *); 464static char *operator_name (int *);
465static void parse_qualified_param_ident_or_type (char **); 465static void parse_qualified_param_ident_or_type (char **);
466static void usage (int) NO_RETURN;
467static void version (void) NO_RETURN;
468
469
470 466
471/*********************************************************************** 467/***********************************************************************
472 Utilities 468 Utilities
@@ -3507,7 +3503,7 @@ Usage: ebrowse [options] {files}\n\
3507 --version display version info\n\ 3503 --version display version info\n\
3508" 3504"
3509 3505
3510static void 3506static _Noreturn void
3511usage (int error) 3507usage (int error)
3512{ 3508{
3513 puts (USAGE); 3509 puts (USAGE);
@@ -3522,7 +3518,7 @@ usage (int error)
3522# define VERSION "21" 3518# define VERSION "21"
3523#endif 3519#endif
3524 3520
3525static void 3521static _Noreturn void
3526version (void) 3522version (void)
3527{ 3523{
3528 /* Makes it easier to update automatically. */ 3524 /* Makes it easier to update automatically. */
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c
index 29504445407..0ba6535b79d 100644
--- a/lib-src/emacsclient.c
+++ b/lib-src/emacsclient.c
@@ -21,7 +21,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
21 21
22#ifdef WINDOWSNT 22#ifdef WINDOWSNT
23 23
24/* config.h defines these, which disables sockets altogether! */ 24/* ms-w32.h defines these, which disables sockets altogether! */
25# undef _WINSOCKAPI_ 25# undef _WINSOCKAPI_
26# undef _WINSOCK_H 26# undef _WINSOCK_H
27 27
@@ -169,8 +169,7 @@ int emacs_pid = 0;
169 be used for the new frame */ 169 be used for the new frame */
170const char *frame_parameters = NULL; 170const char *frame_parameters = NULL;
171 171
172static void print_help_and_exit (void) NO_RETURN; 172static _Noreturn void print_help_and_exit (void);
173static void fail (void) NO_RETURN;
174 173
175 174
176struct option longopts[] = 175struct option longopts[] =
@@ -452,19 +451,19 @@ w32_window_app (void)
452 return window_app; 451 return window_app;
453} 452}
454 453
455/* 454/* execvp wrapper for Windows. Quotes arguments with embedded spaces.
456 execvp wrapper for Windows. Quotes arguments with embedded spaces.
457 455
458 This is necessary due to the broken implementation of exec* routines in 456 This is necessary due to the broken implementation of exec* routines in
459 the Microsoft libraries: they concatenate the arguments together without 457 the Microsoft libraries: they concatenate the arguments together without
460 quoting special characters, and pass the result to CreateProcess, with 458 quoting special characters, and pass the result to CreateProcess, with
461 predictably bad results. By contrast, POSIX execvp passes the arguments 459 predictably bad results. By contrast, POSIX execvp passes the arguments
462 directly into the argv array of the child process. 460 directly into the argv array of the child process. */
463*/ 461
464int 462int
465w32_execvp (const char *path, char **argv) 463w32_execvp (const char *path, char **argv)
466{ 464{
467 int i; 465 int i;
466 extern int execvp (const char*, char **);
468 467
469 /* Required to allow a .BAT script as alternate editor. */ 468 /* Required to allow a .BAT script as alternate editor. */
470 argv[0] = (char *) alternate_editor; 469 argv[0] = (char *) alternate_editor;
@@ -670,7 +669,7 @@ an empty string");
670} 669}
671 670
672 671
673static void 672static _Noreturn void
674print_help_and_exit (void) 673print_help_and_exit (void)
675{ 674{
676 /* Spaces and tabs are significant in this message; they're chosen so the 675 /* Spaces and tabs are significant in this message; they're chosen so the
@@ -713,12 +712,11 @@ Report bugs with M-x report-emacs-bug.\n", progname);
713 exit (EXIT_SUCCESS); 712 exit (EXIT_SUCCESS);
714} 713}
715 714
716/* 715/* Try to run a different command, or --if no alternate editor is
717 Try to run a different command, or --if no alternate editor is 716 defined-- exit with an errorcode.
718 defined-- exit with an errorcode. 717 Uses argv, but gets it from the global variable main_argv. */
719 Uses argv, but gets it from the global variable main_argv. 718
720*/ 719static _Noreturn void
721static void
722fail (void) 720fail (void)
723{ 721{
724 if (alternate_editor) 722 if (alternate_editor)
@@ -751,16 +749,15 @@ main (int argc, char **argv)
751#define AUTH_KEY_LENGTH 64 749#define AUTH_KEY_LENGTH 64
752#define SEND_BUFFER_SIZE 4096 750#define SEND_BUFFER_SIZE 4096
753 751
754extern char *strerror (int);
755
756/* Buffer to accumulate data to send in TCP connections. */ 752/* Buffer to accumulate data to send in TCP connections. */
757char send_buffer[SEND_BUFFER_SIZE + 1]; 753char send_buffer[SEND_BUFFER_SIZE + 1];
758int sblen = 0; /* Fill pointer for the send buffer. */ 754int sblen = 0; /* Fill pointer for the send buffer. */
759/* Socket used to communicate with the Emacs server process. */ 755/* Socket used to communicate with the Emacs server process. */
760HSOCKET emacs_socket = 0; 756HSOCKET emacs_socket = 0;
761 757
762/* On Windows, the socket library was historically separate from the standard 758/* On Windows, the socket library was historically separate from the
763 C library, so errors are handled differently. */ 759 standard C library, so errors are handled differently. */
760
764static void 761static void
765sock_err_message (const char *function_name) 762sock_err_message (const char *function_name)
766{ 763{
@@ -865,7 +862,7 @@ quote_argument (HSOCKET s, const char *str)
865 862
866 863
867/* The inverse of quote_argument. Removes quoting in string STR by 864/* The inverse of quote_argument. Removes quoting in string STR by
868 modifying the string in place. Returns STR. */ 865 modifying the string in place. Returns STR. */
869 866
870static char * 867static char *
871unquote_argument (char *str) 868unquote_argument (char *str)
@@ -948,10 +945,9 @@ initialize_sockets (void)
948#endif /* WINDOWSNT */ 945#endif /* WINDOWSNT */
949 946
950 947
951/* 948/* Read the information needed to set up a TCP comm channel with
952 * Read the information needed to set up a TCP comm channel with 949 the Emacs server: host, port, and authentication string. */
953 * the Emacs server: host, port, and authentication string. 950
954 */
955static int 951static int
956get_server_config (const char *config_file, struct sockaddr_in *server, 952get_server_config (const char *config_file, struct sockaddr_in *server,
957 char *authentication) 953 char *authentication)
@@ -1032,18 +1028,14 @@ set_tcp_socket (const char *local_server_file)
1032 message (FALSE, "%s: connected to remote socket at %s\n", 1028 message (FALSE, "%s: connected to remote socket at %s\n",
1033 progname, inet_ntoa (server.sin_addr)); 1029 progname, inet_ntoa (server.sin_addr));
1034 1030
1035 /* 1031 /* Open up an AF_INET socket. */
1036 * Open up an AF_INET socket
1037 */
1038 if ((s = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) 1032 if ((s = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0)
1039 { 1033 {
1040 sock_err_message ("socket"); 1034 sock_err_message ("socket");
1041 return INVALID_SOCKET; 1035 return INVALID_SOCKET;
1042 } 1036 }
1043 1037
1044 /* 1038 /* Set up the socket. */
1045 * Set up the socket
1046 */
1047 if (connect (s, (struct sockaddr *) &server, sizeof server) < 0) 1039 if (connect (s, (struct sockaddr *) &server, sizeof server) < 0)
1048 { 1040 {
1049 sock_err_message ("connect"); 1041 sock_err_message ("connect");
@@ -1052,9 +1044,7 @@ set_tcp_socket (const char *local_server_file)
1052 1044
1053 setsockopt (s, SOL_SOCKET, SO_LINGER, (char *) &l_arg, sizeof l_arg); 1045 setsockopt (s, SOL_SOCKET, SO_LINGER, (char *) &l_arg, sizeof l_arg);
1054 1046
1055 /* 1047 /* Send the authentication. */
1056 * Send the authentication
1057 */
1058 auth_string[AUTH_KEY_LENGTH] = '\0'; 1048 auth_string[AUTH_KEY_LENGTH] = '\0';
1059 1049
1060 send_to_emacs (s, "-auth "); 1050 send_to_emacs (s, "-auth ");
@@ -1188,7 +1178,7 @@ handle_sigcont (int signalnum)
1188 going to sleep. Normally the suspend is initiated by Emacs via 1178 going to sleep. Normally the suspend is initiated by Emacs via
1189 server-handle-suspend-tty, but if the server gets out of sync with 1179 server-handle-suspend-tty, but if the server gets out of sync with
1190 reality, we may get a SIGTSTP on C-z. Handling this signal and 1180 reality, we may get a SIGTSTP on C-z. Handling this signal and
1191 notifying Emacs about it should get things under control again. */ 1181 notifying Emacs about it should get things under control again. */
1192 1182
1193static void 1183static void
1194handle_sigtstp (int signalnum) 1184handle_sigtstp (int signalnum)
@@ -1240,10 +1230,7 @@ set_local_socket (const char *local_socket_name)
1240 HSOCKET s; 1230 HSOCKET s;
1241 struct sockaddr_un server; 1231 struct sockaddr_un server;
1242 1232
1243 /* 1233 /* Open up an AF_UNIX socket in this person's home directory. */
1244 * Open up an AF_UNIX socket in this person's home directory
1245 */
1246
1247 if ((s = socket (AF_UNIX, SOCK_STREAM, 0)) < 0) 1234 if ((s = socket (AF_UNIX, SOCK_STREAM, 0)) < 0)
1248 { 1235 {
1249 message (TRUE, "%s: socket: %s\n", progname, strerror (errno)); 1236 message (TRUE, "%s: socket: %s\n", progname, strerror (errno));
@@ -1278,7 +1265,7 @@ set_local_socket (const char *local_socket_name)
1278 if (n > 0) 1265 if (n > 0)
1279 { 1266 {
1280 tmpdir = tmpdir_storage = xmalloc (n); 1267 tmpdir = tmpdir_storage = xmalloc (n);
1281 confstr (_CS_DARWIN_USER_TEMP_DIR, tmpdir, n); 1268 confstr (_CS_DARWIN_USER_TEMP_DIR, tmpdir_storage, n);
1282 } 1269 }
1283 else 1270 else
1284#endif 1271#endif
@@ -1477,10 +1464,9 @@ w32_find_emacs_process (HWND hWnd, LPARAM lParam)
1477 return FALSE; 1464 return FALSE;
1478} 1465}
1479 1466
1480/* 1467/* Search for a window of class "Emacs" and owned by a process with
1481 * Search for a window of class "Emacs" and owned by a process with 1468 process id = emacs_pid. If found, allow it to grab the focus. */
1482 * process id = emacs_pid. If found, allow it to grab the focus. 1469
1483 */
1484void 1470void
1485w32_give_focus (void) 1471w32_give_focus (void)
1486{ 1472{
@@ -1862,22 +1848,3 @@ main (int argc, char **argv)
1862} 1848}
1863 1849
1864#endif /* HAVE_SOCKETS && HAVE_INET_SOCKETS */ 1850#endif /* HAVE_SOCKETS && HAVE_INET_SOCKETS */
1865
1866
1867#ifndef HAVE_STRERROR
1868char *
1869strerror (errnum)
1870 int errnum;
1871{
1872 extern char *sys_errlist[];
1873 extern int sys_nerr;
1874
1875 if (errnum >= 0 && errnum < sys_nerr)
1876 return sys_errlist[errnum];
1877 return (char *) "Unknown error";
1878}
1879
1880#endif /* ! HAVE_STRERROR */
1881
1882
1883/* emacsclient.c ends here */
diff --git a/lib-src/etags.c b/lib-src/etags.c
index 7d2a5a90999..69200b790fb 100644
--- a/lib-src/etags.c
+++ b/lib-src/etags.c
@@ -91,9 +91,7 @@ char pot_etags_version[] = "@(#) pot revision number is 17.38.1.4";
91# define NDEBUG /* disable assert */ 91# define NDEBUG /* disable assert */
92#endif 92#endif
93 93
94#ifdef HAVE_CONFIG_H 94#include <config.h>
95# include <config.h>
96#endif /* !HAVE_CONFIG_H */
97 95
98#ifndef _GNU_SOURCE 96#ifndef _GNU_SOURCE
99# define _GNU_SOURCE 1 /* enables some compiler checks on GNU */ 97# define _GNU_SOURCE 1 /* enables some compiler checks on GNU */
@@ -113,10 +111,6 @@ char pot_etags_version[] = "@(#) pot revision number is 17.38.1.4";
113# include <fcntl.h> 111# include <fcntl.h>
114# include <sys/param.h> 112# include <sys/param.h>
115# include <io.h> 113# include <io.h>
116# ifndef HAVE_CONFIG_H
117# define DOS_NT
118# include <sys/config.h>
119# endif
120#else 114#else
121# define MSDOS FALSE 115# define MSDOS FALSE
122#endif /* MSDOS */ 116#endif /* MSDOS */
@@ -150,6 +144,7 @@ char pot_etags_version[] = "@(#) pot revision number is 17.38.1.4";
150#include <errno.h> 144#include <errno.h>
151#include <sys/types.h> 145#include <sys/types.h>
152#include <sys/stat.h> 146#include <sys/stat.h>
147#include <c-strcase.h>
153 148
154#include <assert.h> 149#include <assert.h>
155#ifdef NDEBUG 150#ifdef NDEBUG
@@ -167,14 +162,6 @@ char pot_etags_version[] = "@(#) pot revision number is 17.38.1.4";
167# include <getopt.h> 162# include <getopt.h>
168#endif /* NO_LONG_OPTIONS */ 163#endif /* NO_LONG_OPTIONS */
169 164
170#ifndef HAVE_CONFIG_H /* this is a standalone compilation */
171# ifdef __CYGWIN__ /* compiling on Cygwin */
172 !!! NOTICE !!!
173 the regex.h distributed with Cygwin is not compatible with etags, alas!
174If you want regular expression support, you should delete this notice and
175 arrange to use the GNU regex.h and regex.c.
176# endif
177#endif
178#include <regex.h> 165#include <regex.h>
179 166
180/* Define CTAGS to make the program "ctags" compatible with the usual one. 167/* Define CTAGS to make the program "ctags" compatible with the usual one.
@@ -188,9 +175,9 @@ If you want regular expression support, you should delete this notice and
188#endif 175#endif
189 176
190#define streq(s,t) (assert ((s)!=NULL || (t)!=NULL), !strcmp (s, t)) 177#define streq(s,t) (assert ((s)!=NULL || (t)!=NULL), !strcmp (s, t))
191#define strcaseeq(s,t) (assert ((s)!=NULL && (t)!=NULL), !etags_strcasecmp (s, t)) 178#define strcaseeq(s,t) (assert ((s)!=NULL && (t)!=NULL), !c_strcasecmp (s, t))
192#define strneq(s,t,n) (assert ((s)!=NULL || (t)!=NULL), !strncmp (s, t, n)) 179#define strneq(s,t,n) (assert ((s)!=NULL || (t)!=NULL), !strncmp (s, t, n))
193#define strncaseeq(s,t,n) (assert ((s)!=NULL && (t)!=NULL), !etags_strncasecmp (s, t, n)) 180#define strncaseeq(s,t,n) (assert ((s)!=NULL && (t)!=NULL), !c_strncasecmp (s, t, n))
194 181
195#define CHARS 256 /* 2^sizeof(char) */ 182#define CHARS 256 /* 2^sizeof(char) */
196#define CHAR(x) ((unsigned int)(x) & (CHARS - 1)) 183#define CHAR(x) ((unsigned int)(x) & (CHARS - 1))
@@ -366,9 +353,9 @@ static void analyse_regex (char *);
366static void free_regexps (void); 353static void free_regexps (void);
367static void regex_tag_multiline (void); 354static void regex_tag_multiline (void);
368static void error (const char *, ...) ATTRIBUTE_FORMAT_PRINTF (1, 2); 355static void error (const char *, ...) ATTRIBUTE_FORMAT_PRINTF (1, 2);
369static void suggest_asking_for_help (void) NO_RETURN; 356static _Noreturn void suggest_asking_for_help (void);
370void fatal (const char *, const char *) NO_RETURN; 357_Noreturn void fatal (const char *, const char *);
371static void pfatal (const char *) NO_RETURN; 358static _Noreturn void pfatal (const char *);
372static void add_node (node *, node **); 359static void add_node (node *, node **);
373 360
374static void init (void); 361static void init (void);
@@ -389,8 +376,6 @@ static char *savenstr (const char *, int);
389static char *savestr (const char *); 376static char *savestr (const char *);
390static char *etags_strchr (const char *, int); 377static char *etags_strchr (const char *, int);
391static char *etags_strrchr (const char *, int); 378static char *etags_strrchr (const char *, int);
392static int etags_strcasecmp (const char *, const char *);
393static int etags_strncasecmp (const char *, const char *, int);
394static char *etags_getcwd (void); 379static char *etags_getcwd (void);
395static char *relative_filename (char *, char *); 380static char *relative_filename (char *, char *);
396static char *absolute_filename (char *, char *); 381static char *absolute_filename (char *, char *);
@@ -2138,7 +2123,7 @@ invalidate_nodes (fdesc *badfdp, node **npp)
2138 2123
2139 2124
2140static int total_size_of_entries (node *); 2125static int total_size_of_entries (node *);
2141static int number_len (long); 2126static int number_len (long) ATTRIBUTE_CONST;
2142 2127
2143/* Length of a non-negative number's decimal representation. */ 2128/* Length of a non-negative number's decimal representation. */
2144static int 2129static int
@@ -2657,17 +2642,11 @@ write_classname (linebuffer *cn, const char *qualifier)
2657 } 2642 }
2658 for (i = 1; i < cstack.nl; i++) 2643 for (i = 1; i < cstack.nl; i++)
2659 { 2644 {
2660 char *s; 2645 char *s = cstack.cname[i];
2661 int slen;
2662
2663 s = cstack.cname[i];
2664 if (s == NULL) 2646 if (s == NULL)
2665 continue; 2647 continue;
2666 slen = strlen (s); 2648 linebuffer_setlen (cn, len + qlen + strlen (s));
2667 len += slen + qlen; 2649 len += sprintf (cn->buffer + len, "%s%s", qualifier, s);
2668 linebuffer_setlen (cn, len);
2669 strncat (cn->buffer, qualifier, qlen);
2670 strncat (cn->buffer, s, slen);
2671 } 2650 }
2672} 2651}
2673 2652
@@ -2882,7 +2861,7 @@ consider_token (register char *str, register int len, register int c, int *c_ext
2882 fvdef = fvnone; 2861 fvdef = fvnone;
2883 objdef = omethodtag; 2862 objdef = omethodtag;
2884 linebuffer_setlen (&token_name, len); 2863 linebuffer_setlen (&token_name, len);
2885 strncpy (token_name.buffer, str, len); 2864 memcpy (token_name.buffer, str, len);
2886 token_name.buffer[len] = '\0'; 2865 token_name.buffer[len] = '\0';
2887 return TRUE; 2866 return TRUE;
2888 } 2867 }
@@ -2894,10 +2873,11 @@ consider_token (register char *str, register int len, register int c, int *c_ext
2894 case omethodparm: 2873 case omethodparm:
2895 if (parlev == 0) 2874 if (parlev == 0)
2896 { 2875 {
2876 int oldlen = token_name.len;
2897 fvdef = fvnone; 2877 fvdef = fvnone;
2898 objdef = omethodtag; 2878 objdef = omethodtag;
2899 linebuffer_setlen (&token_name, token_name.len + len); 2879 linebuffer_setlen (&token_name, oldlen + len);
2900 strncat (token_name.buffer, str, len); 2880 memcpy (token_name.buffer + oldlen, str, len);
2901 return TRUE; 2881 return TRUE;
2902 } 2882 }
2903 return FALSE; 2883 return FALSE;
@@ -3326,12 +3306,12 @@ C_entries (int c_ext, FILE *inf)
3326 && nestlev > 0 && definedef == dnone) 3306 && nestlev > 0 && definedef == dnone)
3327 /* in struct body */ 3307 /* in struct body */
3328 { 3308 {
3309 int len;
3329 write_classname (&token_name, qualifier); 3310 write_classname (&token_name, qualifier);
3330 linebuffer_setlen (&token_name, 3311 len = token_name.len;
3331 token_name.len+qlen+toklen); 3312 linebuffer_setlen (&token_name, len+qlen+toklen);
3332 strcat (token_name.buffer, qualifier); 3313 sprintf (token_name.buffer + len, "%s%.*s",
3333 strncat (token_name.buffer, 3314 qualifier, toklen, newlb.buffer + tokoff);
3334 newlb.buffer + tokoff, toklen);
3335 token.named = TRUE; 3315 token.named = TRUE;
3336 } 3316 }
3337 else if (objdef == ocatseen) 3317 else if (objdef == ocatseen)
@@ -3339,11 +3319,8 @@ C_entries (int c_ext, FILE *inf)
3339 { 3319 {
3340 int len = strlen (objtag) + 2 + toklen; 3320 int len = strlen (objtag) + 2 + toklen;
3341 linebuffer_setlen (&token_name, len); 3321 linebuffer_setlen (&token_name, len);
3342 strcpy (token_name.buffer, objtag); 3322 sprintf (token_name.buffer, "%s(%.*s)",
3343 strcat (token_name.buffer, "("); 3323 objtag, toklen, newlb.buffer + tokoff);
3344 strncat (token_name.buffer,
3345 newlb.buffer + tokoff, toklen);
3346 strcat (token_name.buffer, ")");
3347 token.named = TRUE; 3324 token.named = TRUE;
3348 } 3325 }
3349 else if (objdef == omethodtag 3326 else if (objdef == omethodtag
@@ -3367,8 +3344,8 @@ C_entries (int c_ext, FILE *inf)
3367 len -= 1; 3344 len -= 1;
3368 } 3345 }
3369 linebuffer_setlen (&token_name, len); 3346 linebuffer_setlen (&token_name, len);
3370 strncpy (token_name.buffer, 3347 memcpy (token_name.buffer,
3371 newlb.buffer + off, len); 3348 newlb.buffer + off, len);
3372 token_name.buffer[len] = '\0'; 3349 token_name.buffer[len] = '\0';
3373 if (defun) 3350 if (defun)
3374 while (--len >= 0) 3351 while (--len >= 0)
@@ -3379,8 +3356,8 @@ C_entries (int c_ext, FILE *inf)
3379 else 3356 else
3380 { 3357 {
3381 linebuffer_setlen (&token_name, toklen); 3358 linebuffer_setlen (&token_name, toklen);
3382 strncpy (token_name.buffer, 3359 memcpy (token_name.buffer,
3383 newlb.buffer + tokoff, toklen); 3360 newlb.buffer + tokoff, toklen);
3384 token_name.buffer[toklen] = '\0'; 3361 token_name.buffer[toklen] = '\0';
3385 /* Name macros and members. */ 3362 /* Name macros and members. */
3386 token.named = (structdef == stagseen 3363 token.named = (structdef == stagseen
@@ -5176,7 +5153,7 @@ HTML_labels (FILE *inf)
5176 for (end = dbp; *end != '\0' && intoken (*end); end++) 5153 for (end = dbp; *end != '\0' && intoken (*end); end++)
5177 continue; 5154 continue;
5178 linebuffer_setlen (&token_name, end - dbp); 5155 linebuffer_setlen (&token_name, end - dbp);
5179 strncpy (token_name.buffer, dbp, end - dbp); 5156 memcpy (token_name.buffer, dbp, end - dbp);
5180 token_name.buffer[end - dbp] = '\0'; 5157 token_name.buffer[end - dbp] = '\0';
5181 5158
5182 dbp = end; 5159 dbp = end;
@@ -5276,7 +5253,7 @@ Prolog_functions (FILE *inf)
5276 else if (len + 1 > allocated) 5253 else if (len + 1 > allocated)
5277 xrnew (last, len + 1, char); 5254 xrnew (last, len + 1, char);
5278 allocated = len + 1; 5255 allocated = len + 1;
5279 strncpy (last, cp, len); 5256 memcpy (last, cp, len);
5280 last[len] = '\0'; 5257 last[len] = '\0';
5281 } 5258 }
5282 } 5259 }
@@ -5449,7 +5426,7 @@ Erlang_functions (FILE *inf)
5449 else if (len + 1 > allocated) 5426 else if (len + 1 > allocated)
5450 xrnew (last, len + 1, char); 5427 xrnew (last, len + 1, char);
5451 allocated = len + 1; 5428 allocated = len + 1;
5452 strncpy (last, cp, len); 5429 memcpy (last, cp, len);
5453 last[len] = '\0'; 5430 last[len] = '\0';
5454 } 5431 }
5455 } 5432 }
@@ -5832,7 +5809,7 @@ substitute (char *in, char *out, struct re_registers *regs)
5832 { 5809 {
5833 dig = *out - '0'; 5810 dig = *out - '0';
5834 diglen = regs->end[dig] - regs->start[dig]; 5811 diglen = regs->end[dig] - regs->start[dig];
5835 strncpy (t, in + regs->start[dig], diglen); 5812 memcpy (t, in + regs->start[dig], diglen);
5836 t += diglen; 5813 t += diglen;
5837 } 5814 }
5838 else 5815 else
@@ -6055,7 +6032,7 @@ readline_internal (linebuffer *lbp, register FILE *stream)
6055 filebuf.size *= 2; 6032 filebuf.size *= 2;
6056 xrnew (filebuf.buffer, filebuf.size, char); 6033 xrnew (filebuf.buffer, filebuf.size, char);
6057 } 6034 }
6058 strncpy (filebuf.buffer + filebuf.len, lbp->buffer, lbp->len); 6035 memcpy (filebuf.buffer + filebuf.len, lbp->buffer, lbp->len);
6059 filebuf.len += lbp->len; 6036 filebuf.len += lbp->len;
6060 filebuf.buffer[filebuf.len++] = '\n'; 6037 filebuf.buffer[filebuf.len++] = '\n';
6061 filebuf.buffer[filebuf.len] = '\0'; 6038 filebuf.buffer[filebuf.len] = '\0';
@@ -6278,7 +6255,7 @@ savenstr (const char *cp, int len)
6278 register char *dp; 6255 register char *dp;
6279 6256
6280 dp = xnew (len + 1, char); 6257 dp = xnew (len + 1, char);
6281 strncpy (dp, cp, len); 6258 memcpy (dp, cp, len);
6282 dp[len] = '\0'; 6259 dp[len] = '\0';
6283 return dp; 6260 return dp;
6284} 6261}
@@ -6320,48 +6297,6 @@ etags_strchr (register const char *sp, register int c)
6320 return NULL; 6297 return NULL;
6321} 6298}
6322 6299
6323/*
6324 * Compare two strings, ignoring case for alphabetic characters.
6325 *
6326 * Same as BSD's strcasecmp, included for portability.
6327 */
6328static int
6329etags_strcasecmp (register const char *s1, register const char *s2)
6330{
6331 while (*s1 != '\0'
6332 && (ISALPHA (*s1) && ISALPHA (*s2)
6333 ? lowcase (*s1) == lowcase (*s2)
6334 : *s1 == *s2))
6335 s1++, s2++;
6336
6337 return (ISALPHA (*s1) && ISALPHA (*s2)
6338 ? lowcase (*s1) - lowcase (*s2)
6339 : *s1 - *s2);
6340}
6341
6342/*
6343 * Compare two strings, ignoring case for alphabetic characters.
6344 * Stop after a given number of characters
6345 *
6346 * Same as BSD's strncasecmp, included for portability.
6347 */
6348static int
6349etags_strncasecmp (register const char *s1, register const char *s2, register int n)
6350{
6351 while (*s1 != '\0' && n-- > 0
6352 && (ISALPHA (*s1) && ISALPHA (*s2)
6353 ? lowcase (*s1) == lowcase (*s2)
6354 : *s1 == *s2))
6355 s1++, s2++;
6356
6357 if (n < 0)
6358 return 0;
6359 else
6360 return (ISALPHA (*s1) && ISALPHA (*s2)
6361 ? lowcase (*s1) - lowcase (*s2)
6362 : *s1 - *s2);
6363}
6364
6365/* Skip spaces (end of string is not space), return new pointer. */ 6300/* Skip spaces (end of string is not space), return new pointer. */
6366static char * 6301static char *
6367skip_spaces (char *cp) 6302skip_spaces (char *cp)
diff --git a/lib-src/hexl.c b/lib-src/hexl.c
index f8fb11f8218..08da0075269 100644
--- a/lib-src/hexl.c
+++ b/lib-src/hexl.c
@@ -20,9 +20,7 @@ You should have received a copy of the GNU General Public License
20along with this program. If not, see <http://www.gnu.org/licenses/>. */ 20along with this program. If not, see <http://www.gnu.org/licenses/>. */
21 21
22 22
23#ifdef HAVE_CONFIG_H
24#include <config.h> 23#include <config.h>
25#endif
26 24
27#include <stdio.h> 25#include <stdio.h>
28#include <ctype.h> 26#include <ctype.h>
@@ -48,7 +46,7 @@ int base = DEFAULT_BASE, un_flag = FALSE, iso_flag = FALSE, endian = 1;
48int group_by = DEFAULT_GROUPING; 46int group_by = DEFAULT_GROUPING;
49char *progname; 47char *progname;
50 48
51void usage (void) NO_RETURN; 49_Noreturn void usage (void);
52 50
53int 51int
54main (int argc, char **argv) 52main (int argc, char **argv)
diff --git a/lib-src/make-docfile.c b/lib-src/make-docfile.c
index 1314a7b6829..bd87b5b6524 100644
--- a/lib-src/make-docfile.c
+++ b/lib-src/make-docfile.c
@@ -76,7 +76,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
76static int scan_file (char *filename); 76static int scan_file (char *filename);
77static int scan_lisp_file (const char *filename, const char *mode); 77static int scan_lisp_file (const char *filename, const char *mode);
78static int scan_c_file (char *filename, const char *mode); 78static int scan_c_file (char *filename, const char *mode);
79static void fatal (const char *s1, const char *s2) NO_RETURN;
80static void start_globals (void); 79static void start_globals (void);
81static void write_globals (void); 80static void write_globals (void);
82 81
@@ -111,7 +110,7 @@ error (const char *s1, const char *s2)
111/* Print error message and exit. */ 110/* Print error message and exit. */
112 111
113/* VARARGS1 */ 112/* VARARGS1 */
114static void 113static _Noreturn void
115fatal (const char *s1, const char *s2) 114fatal (const char *s1, const char *s2)
116{ 115{
117 error (s1, s2); 116 error (s1, s2);
@@ -542,7 +541,7 @@ write_c_args (FILE *out, char *func, char *buf, int minargs, int maxargs)
542 541
543 /* In C code, `default' is a reserved word, so we spell it 542 /* In C code, `default' is a reserved word, so we spell it
544 `defalt'; demangle that here. */ 543 `defalt'; demangle that here. */
545 if (ident_length == 6 && strncmp (ident_start, "defalt", 6) == 0) 544 if (ident_length == 6 && memcmp (ident_start, "defalt", 6) == 0)
546 fprintf (out, "DEFAULT"); 545 fprintf (out, "DEFAULT");
547 else 546 else
548 while (ident_length-- > 0) 547 while (ident_length-- > 0)
@@ -565,6 +564,7 @@ write_c_args (FILE *out, char *func, char *buf, int minargs, int maxargs)
565/* The types of globals. */ 564/* The types of globals. */
566enum global_type 565enum global_type
567{ 566{
567 FUNCTION,
568 EMACS_INTEGER, 568 EMACS_INTEGER,
569 BOOLEAN, 569 BOOLEAN,
570 LISP_OBJECT, 570 LISP_OBJECT,
@@ -576,6 +576,7 @@ struct global
576{ 576{
577 enum global_type type; 577 enum global_type type;
578 char *name; 578 char *name;
579 int value;
579}; 580};
580 581
581/* All the variable names we saw while scanning C sources in `-g' 582/* All the variable names we saw while scanning C sources in `-g'
@@ -585,7 +586,7 @@ int num_globals_allocated;
585struct global *globals; 586struct global *globals;
586 587
587static void 588static void
588add_global (enum global_type type, char *name) 589add_global (enum global_type type, char *name, int value)
589{ 590{
590 /* Ignore the one non-symbol that can occur. */ 591 /* Ignore the one non-symbol that can occur. */
591 if (strcmp (name, "...")) 592 if (strcmp (name, "..."))
@@ -606,6 +607,7 @@ add_global (enum global_type type, char *name)
606 607
607 globals[num_globals - 1].type = type; 608 globals[num_globals - 1].type = type;
608 globals[num_globals - 1].name = name; 609 globals[num_globals - 1].name = name;
610 globals[num_globals - 1].value = value;
609 } 611 }
610} 612}
611 613
@@ -614,13 +616,29 @@ compare_globals (const void *a, const void *b)
614{ 616{
615 const struct global *ga = a; 617 const struct global *ga = a;
616 const struct global *gb = b; 618 const struct global *gb = b;
619
620 if (ga->type == FUNCTION)
621 {
622 if (gb->type != FUNCTION)
623 return 1;
624 }
625 else if (gb->type == FUNCTION)
626 return -1;
627
617 return strcmp (ga->name, gb->name); 628 return strcmp (ga->name, gb->name);
618} 629}
619 630
620static void 631static void
632close_emacs_globals (void)
633{
634 fprintf (outfile, "};\n");
635 fprintf (outfile, "extern struct emacs_globals globals;\n");
636}
637
638static void
621write_globals (void) 639write_globals (void)
622{ 640{
623 int i; 641 int i, seen_defun = 0;
624 qsort (globals, num_globals, sizeof (struct global), compare_globals); 642 qsort (globals, num_globals, sizeof (struct global), compare_globals);
625 for (i = 0; i < num_globals; ++i) 643 for (i = 0; i < num_globals; ++i)
626 { 644 {
@@ -637,20 +655,55 @@ write_globals (void)
637 case LISP_OBJECT: 655 case LISP_OBJECT:
638 type = "Lisp_Object"; 656 type = "Lisp_Object";
639 break; 657 break;
658 case FUNCTION:
659 if (!seen_defun)
660 {
661 close_emacs_globals ();
662 fprintf (outfile, "\n");
663 seen_defun = 1;
664 }
665 break;
640 default: 666 default:
641 fatal ("not a recognized DEFVAR_", 0); 667 fatal ("not a recognized DEFVAR_", 0);
642 } 668 }
643 669
644 fprintf (outfile, " %s f_%s;\n", type, globals[i].name); 670 if (globals[i].type != FUNCTION)
645 fprintf (outfile, "#define %s globals.f_%s\n", 671 {
646 globals[i].name, globals[i].name); 672 fprintf (outfile, " %s f_%s;\n", type, globals[i].name);
673 fprintf (outfile, "#define %s globals.f_%s\n",
674 globals[i].name, globals[i].name);
675 }
676 else
677 {
678 /* It would be nice to have a cleaner way to deal with these
679 special hacks. */
680 if (strcmp (globals[i].name, "Fthrow") == 0
681 || strcmp (globals[i].name, "Ftop_level") == 0
682 || strcmp (globals[i].name, "Fkill_emacs") == 0)
683 fprintf (outfile, "_Noreturn ");
684 fprintf (outfile, "EXFUN (%s, ", globals[i].name);
685 if (globals[i].value == -1)
686 fprintf (outfile, "MANY");
687 else if (globals[i].value == -2)
688 fprintf (outfile, "UNEVALLED");
689 else
690 fprintf (outfile, "%d", globals[i].value);
691 fprintf (outfile, ");\n");
692 }
693
647 while (i + 1 < num_globals 694 while (i + 1 < num_globals
648 && !strcmp (globals[i].name, globals[i + 1].name)) 695 && !strcmp (globals[i].name, globals[i + 1].name))
649 ++i; 696 {
697 if (globals[i].type == FUNCTION
698 && globals[i].value != globals[i + 1].value)
699 error ("function '%s' defined twice with differing signatures",
700 globals[i].name);
701 ++i;
702 }
650 } 703 }
651 704
652 fprintf (outfile, "};\n"); 705 if (!seen_defun)
653 fprintf (outfile, "extern struct emacs_globals globals;\n"); 706 close_emacs_globals ();
654} 707}
655 708
656 709
@@ -700,6 +753,7 @@ scan_c_file (char *filename, const char *mode)
700 int defvarperbufferflag = 0; 753 int defvarperbufferflag = 0;
701 int defvarflag = 0; 754 int defvarflag = 0;
702 enum global_type type = INVALID; 755 enum global_type type = INVALID;
756 char *name IF_LINT (= 0);
703 757
704 if (c != '\n' && c != '\r') 758 if (c != '\n' && c != '\r')
705 { 759 {
@@ -765,8 +819,9 @@ scan_c_file (char *filename, const char *mode)
765 } 819 }
766 else continue; 820 else continue;
767 821
768 if (generate_globals && (!defvarflag || defvarperbufferflag 822 if (generate_globals
769 || type == INVALID)) 823 && (!defvarflag || defvarperbufferflag || type == INVALID)
824 && !defunflag)
770 continue; 825 continue;
771 826
772 while (c != '(') 827 while (c != '(')
@@ -785,7 +840,6 @@ scan_c_file (char *filename, const char *mode)
785 if (generate_globals) 840 if (generate_globals)
786 { 841 {
787 int i = 0; 842 int i = 0;
788 char *name;
789 843
790 /* Skip "," and whitespace. */ 844 /* Skip "," and whitespace. */
791 do 845 do
@@ -806,8 +860,12 @@ scan_c_file (char *filename, const char *mode)
806 860
807 name = xmalloc (i + 1); 861 name = xmalloc (i + 1);
808 memcpy (name, input_buffer, i + 1); 862 memcpy (name, input_buffer, i + 1);
809 add_global (type, name); 863
810 continue; 864 if (!defunflag)
865 {
866 add_global (type, name, 0);
867 continue;
868 }
811 } 869 }
812 870
813 /* DEFVAR_LISP ("name", addr, "doc") 871 /* DEFVAR_LISP ("name", addr, "doc")
@@ -815,7 +873,7 @@ scan_c_file (char *filename, const char *mode)
815 DEFVAR_LISP ("name", addr, doc: /\* doc *\/) */ 873 DEFVAR_LISP ("name", addr, doc: /\* doc *\/) */
816 874
817 if (defunflag) 875 if (defunflag)
818 commas = 5; 876 commas = generate_globals ? 4 : 5;
819 else if (defvarperbufferflag) 877 else if (defvarperbufferflag)
820 commas = 3; 878 commas = 3;
821 else if (defvarflag) 879 else if (defvarflag)
@@ -842,7 +900,12 @@ scan_c_file (char *filename, const char *mode)
842 scanned = fscanf (infile, "%d", &minargs); 900 scanned = fscanf (infile, "%d", &minargs);
843 else /* Pick up maxargs. */ 901 else /* Pick up maxargs. */
844 if (c == 'M' || c == 'U') /* MANY || UNEVALLED */ 902 if (c == 'M' || c == 'U') /* MANY || UNEVALLED */
845 maxargs = -1; 903 {
904 if (generate_globals)
905 maxargs = (c == 'M') ? -1 : -2;
906 else
907 maxargs = -1;
908 }
846 else 909 else
847 scanned = fscanf (infile, "%d", &maxargs); 910 scanned = fscanf (infile, "%d", &maxargs);
848 if (scanned < 0) 911 if (scanned < 0)
@@ -855,6 +918,12 @@ scan_c_file (char *filename, const char *mode)
855 c = getc (infile); 918 c = getc (infile);
856 } 919 }
857 920
921 if (generate_globals)
922 {
923 add_global (FUNCTION, name, maxargs);
924 continue;
925 }
926
858 while (c == ' ' || c == '\n' || c == '\r' || c == '\t') 927 while (c == ' ' || c == '\n' || c == '\r' || c == '\t')
859 c = getc (infile); 928 c = getc (infile);
860 929
@@ -1025,7 +1094,7 @@ search_lisp_doc_at_eol (FILE *infile)
1025 char c = 0, c1 = 0, c2 = 0; 1094 char c = 0, c1 = 0, c2 = 0;
1026 1095
1027 /* Skip until the end of line; remember two previous chars. */ 1096 /* Skip until the end of line; remember two previous chars. */
1028 while (c != '\n' && c != '\r' && c >= 0) 1097 while (c != '\n' && c != '\r' && c != EOF)
1029 { 1098 {
1030 c2 = c1; 1099 c2 = c1;
1031 c1 = c; 1100 c1 = c;
@@ -1040,6 +1109,8 @@ search_lisp_doc_at_eol (FILE *infile)
1040 fprintf (stderr, "## non-docstring in %s (%s)\n", 1109 fprintf (stderr, "## non-docstring in %s (%s)\n",
1041 buffer, filename); 1110 buffer, filename);
1042#endif 1111#endif
1112 if (c != EOF)
1113 ungetc (c, infile);
1043 return 0; 1114 return 0;
1044 } 1115 }
1045 return 1; 1116 return 1;
diff --git a/lib-src/makefile.w32-in b/lib-src/makefile.w32-in
index b727288351a..4b2b523ea34 100644
--- a/lib-src/makefile.w32-in
+++ b/lib-src/makefile.w32-in
@@ -19,12 +19,12 @@
19 19
20ALL = $(BLD)/test-distrib.exe $(BLD)/make-docfile.exe $(BLD)/hexl.exe\ 20ALL = $(BLD)/test-distrib.exe $(BLD)/make-docfile.exe $(BLD)/hexl.exe\
21 $(BLD)/ctags.exe $(BLD)/etags.exe $(BLD)/movemail.exe $(BLD)/ebrowse.exe\ 21 $(BLD)/ctags.exe $(BLD)/etags.exe $(BLD)/movemail.exe $(BLD)/ebrowse.exe\
22 $(BLD)/emacsclient.exe $(BLD)/emacsclientw.exe 22 $(BLD)/emacsclient.exe $(BLD)/emacsclientw.exe $(BLD)/profile.exe
23 23
24.PHONY: make-docfile 24.PHONY: make-docfile
25 25
26LOCAL_FLAGS = -DWINDOWSNT -DDOS_NT -DNO_LDAV=1 \ 26LOCAL_FLAGS = -DWINDOWSNT -DDOS_NT -DNO_LDAV=1 \
27 -DNO_ARCHIVES=1 -DHAVE_CONFIG_H=1 -I../lib \ 27 -DNO_ARCHIVES=1 -I../lib \
28 -I../nt/inc -I../src $(EMACS_EXTRA_C_FLAGS) 28 -I../nt/inc -I../src $(EMACS_EXTRA_C_FLAGS)
29 29
30LIBS = $(BASE_LIBS) $(ADVAPI32) 30LIBS = $(BASE_LIBS) $(ADVAPI32)
@@ -38,7 +38,7 @@ $(BLD)/hexl.exe: $(BLD)/hexl.$(O)
38 $(LINK) $(LINK_OUT)$@ $(LINK_FLAGS) $(BLD)/hexl.$(O) $(LIBS) 38 $(LINK) $(LINK_OUT)$@ $(LINK_FLAGS) $(BLD)/hexl.$(O) $(LIBS)
39$(BLD)/test-distrib.exe: $(BLD)/test-distrib.$(O) 39$(BLD)/test-distrib.exe: $(BLD)/test-distrib.$(O)
40 $(LINK) $(LINK_OUT)$@ $(LINK_FLAGS) $(BLD)/test-distrib.$(O) $(LIBS) 40 $(LINK) $(LINK_OUT)$@ $(LINK_FLAGS) $(BLD)/test-distrib.$(O) $(LIBS)
41 "$(BLD)/test-distrib.exe" "$(SRC)/testfile" 41 "$(BLD)/test-distrib.exe" "$(LIB_SRC)/testfile"
42 42
43MOVEMAILOBJS = $(BLD)/movemail.$(O) \ 43MOVEMAILOBJS = $(BLD)/movemail.$(O) \
44 $(BLD)/pop.$(O) \ 44 $(BLD)/pop.$(O) \
@@ -106,10 +106,16 @@ ctags.c: etags.c
106 - $(DEL) ctags.c 106 - $(DEL) ctags.c
107 $(CP) etags.c ctags.c 107 $(CP) etags.c ctags.c
108 108
109CTAGS_CFLAGS = -DCTAGS $(ETAGS_CFLAGS) -DEMACS_NAME="\"GNU Emacs\"" 109CTAGS_CFLAGS = -DCTAGS $(ETAGS_CFLAGS)
110$(BLD)/ctags.$(O): ctags.c 110$(BLD)/ctags.$(O): ctags.c
111 $(CC) $(CFLAGS) $(CTAGS_CFLAGS) $(CC_OUT)$@ ctags.c 111 $(CC) $(CFLAGS) $(CTAGS_CFLAGS) $(CC_OUT)$@ ctags.c
112 112
113PROFILEOBJS = $(BLD)/profile.$(O) \
114 ../lib/$(BLD)/libgnu.$(A) \
115 $(BLD)/ntlib.$(O)
116$(BLD)/profile.exe: $(PROFILEOBJS)
117 $(LINK) $(LINK_OUT)$@ $(LINK_FLAGS) $(PROFILEOBJS) $(LIBS)
118
113# 119#
114# From ..\src\Makefile.in 120# From ..\src\Makefile.in
115# It doesn't matter if the real name is *.obj for the files in this list, 121# It doesn't matter if the real name is *.obj for the files in this list,
@@ -236,7 +242,6 @@ lisp2 = \
236 $(lispsource)language/georgian.el \ 242 $(lispsource)language/georgian.el \
237 $(lispsource)language/khmer.el \ 243 $(lispsource)language/khmer.el \
238 $(lispsource)language/burmese.el \ 244 $(lispsource)language/burmese.el \
239 $(lispsource)paths.el \
240 $(lispsource)register.elc \ 245 $(lispsource)register.elc \
241 $(lispsource)replace.elc \ 246 $(lispsource)replace.elc \
242 $(lispsource)simple.elc \ 247 $(lispsource)simple.elc \
@@ -307,6 +312,7 @@ install: $(INSTALL_FILES)
307 $(CP) $(BLD)/movemail.exe $(INSTALL_DIR)/bin 312 $(CP) $(BLD)/movemail.exe $(INSTALL_DIR)/bin
308 $(CP) $(BLD)/emacsclient.exe $(INSTALL_DIR)/bin 313 $(CP) $(BLD)/emacsclient.exe $(INSTALL_DIR)/bin
309 $(CP) $(BLD)/emacsclientw.exe $(INSTALL_DIR)/bin 314 $(CP) $(BLD)/emacsclientw.exe $(INSTALL_DIR)/bin
315 $(CP) $(BLD)/profile.exe $(INSTALL_DIR)/bin
310 - mkdir "$(INSTALL_DIR)/etc" 316 - mkdir "$(INSTALL_DIR)/etc"
311 $(CP) $(DOC) $(INSTALL_DIR)/etc 317 $(CP) $(DOC) $(INSTALL_DIR)/etc
312 318
@@ -349,105 +355,108 @@ TAGS: $(BLD)/etags.exe *.c *.h
349### DEPENDENCIES ### 355### DEPENDENCIES ###
350 356
351EMACS_ROOT = .. 357EMACS_ROOT = ..
352SRC = . 358LIB_SRC = .
353 359SRC = $(EMACS_ROOT)/src
354$(BLD)/alloca.$(O) : \ 360NT_INC = $(EMACS_ROOT)/nt/inc
355 $(SRC)/alloca.c \ 361GNU_LIB = $(EMACS_ROOT)/lib
356 $(EMACS_ROOT)/src/s/ms-w32.h \ 362
357 $(EMACS_ROOT)/src/config.h \ 363MS_W32_H = $(SRC)/s/ms-w32.h \
358 $(EMACS_ROOT)/src/blockinput.h 364 $(NT_INC)/sys/stat.h
365CONFIG_H = $(SRC)/config.h \
366 $(MS_W32_H)
367INTTYPES_H = $(NT_INC)/inttypes.h \
368 $(NT_INC)/stdint.h
369NTLIB_H = $(LIB_SRC)/ntlib.h \
370 $(NT_INC)/pwd.h
371SYSTIME_H = $(SRC)/systime.h \
372 $(NT_INC)/sys/time.h \
373 $(GNU_LIB)/timespec.h
359 374
360$(BLD)/ctags.$(O) : \ 375$(BLD)/ctags.$(O) : \
361 $(SRC)/ctags.c \ 376 $(LIB_SRC)/ctags.c \
362 $(EMACS_ROOT)/nt/inc/sys/param.h \ 377 $(SRC)/regex.h \
363 $(EMACS_ROOT)/nt/inc/sys/stat.h \ 378 $(NT_INC)/sys/stat.h \
364 $(EMACS_ROOT)/src/s/ms-w32.h \ 379 $(NT_INC)/unistd.h \
365 $(EMACS_ROOT)/lib-src/../src/config.h \ 380 $(GNU_LIB)/c-strcase.h \
366 $(SRC)/ntlib.h \ 381 $(GNU_LIB)/getopt.h \
367 $(EMACS_ROOT)/lib/getopt.h 382 $(CONFIG_H)
368 383
369$(BLD)/ebrowse.$(O) : \ 384$(BLD)/ebrowse.$(O) : \
370 $(SRC)/ebrowse.c \ 385 $(LIB_SRC)/ebrowse.c \
371 $(EMACS_ROOT)/lib/min-max.h \ 386 $(GNU_LIB)/getopt.h \
372 $(EMACS_ROOT)/src/s/ms-w32.h \ 387 $(GNU_LIB)/min-max.h \
373 $(EMACS_ROOT)/lib-src/../src/config.h 388 $(CONFIG_H)
374 389
375$(BLD)/emacsclient.$(O) : \ 390$(BLD)/emacsclient.$(O) : \
376 $(SRC)/emacsclient.c \ 391 $(LIB_SRC)/emacsclient.c \
377 $(EMACS_ROOT)/nt/inc/sys/stat.h \ 392 $(NT_INC)/pwd.h \
378 $(EMACS_ROOT)/src/s/ms-w32.h \ 393 $(NT_INC)/sys/stat.h \
379 $(EMACS_ROOT)/lib-src/../src/config.h 394 $(NT_INC)/unistd.h \
395 $(GNU_LIB)/getopt.h \
396 $(CONFIG_H)
380 397
381$(BLD)/etags.$(O) : \ 398$(BLD)/etags.$(O) : \
382 $(SRC)/etags.c \ 399 $(LIB_SRC)/etags.c \
383 $(EMACS_ROOT)/nt/inc/sys/param.h \ 400 $(SRC)/regex.h \
384 $(EMACS_ROOT)/nt/inc/sys/stat.h \ 401 $(NT_INC)/sys/stat.h \
385 $(EMACS_ROOT)/src/s/ms-w32.h \ 402 $(NT_INC)/unistd.h \
386 $(EMACS_ROOT)/lib-src/../src/config.h \ 403 $(GNU_LIB)/c-strcase.h \
387 $(SRC)/ntlib.h \ 404 $(GNU_LIB)/getopt.h \
388 $(EMACS_ROOT)/lib/getopt.h 405 $(CONFIG_H)
389
390$(BLD)/getdate.$(O) : \
391 $(SRC)/getdate.c \
392 $(EMACS_ROOT)/src/s/ms-w32.h \
393 $(EMACS_ROOT)/src/config.h \
394 $(MSTOOLS_SYS)/types.h
395 406
396$(BLD)/hexl.$(O) : \ 407$(BLD)/hexl.$(O) : \
397 $(SRC)/hexl.c 408 $(LIB_SRC)/hexl.c \
398 409 $(CONFIG_H)
399$(BLD)/leditcfns.$(O) : \
400 $(SRC)/leditcfns.c
401 410
402$(BLD)/make-docfile.$(O) : \ 411$(BLD)/make-docfile.$(O) : \
403 $(SRC)/make-docfile.c \ 412 $(LIB_SRC)/make-docfile.c \
404 $(EMACS_ROOT)/src/config.h 413 $(NT_INC)/unistd.h \
405 414 $(CONFIG_H)
406$(BLD)/make-path.$(O) : \
407 $(SRC)/make-path.c
408 415
409$(BLD)/movemail.$(O) : \ 416$(BLD)/movemail.$(O) : \
410 $(SRC)/movemail.c \ 417 $(LIB_SRC)/movemail.c \
411 $(EMACS_ROOT)/src/s/ms-w32.h \ 418 $(LIB_SRC)/pop.h \
412 $(EMACS_ROOT)/lib-src/../src/config.h \ 419 $(SRC)/syswait.h \
413 $(EMACS_ROOT)/nt/inc/sys/file.h \ 420 $(NT_INC)/pwd.h \
414 $(EMACS_ROOT)/nt/inc/sys/stat.h \ 421 $(NT_INC)/sys/file.h \
415 $(EMACS_ROOT)/lib-src/../src/syswait.h \ 422 $(NT_INC)/sys/stat.h \
416 $(EMACS_ROOT)/nt/inc/pwd.h \ 423 $(NT_INC)/unistd.h \
417 $(SRC)/ntlib.h 424 $(GNU_LIB)/getopt.h \
418 $(CC) $(CFLAGS) -DUSG $(CC_OUT)$@ movemail.c 425 $(CONFIG_H) \
426 $(NTLIB_H)
419 427
420$(BLD)/ntlib.$(O) : \ 428$(BLD)/ntlib.$(O) : \
421 $(SRC)/ntlib.c \ 429 $(LIB_SRC)/ntlib.c \
422 $(SRC)/ntlib.h \ 430 $(NT_INC)/sys/stat.h \
423 $(EMACS_ROOT)/nt/inc/sys/stat.h \ 431 $(NTLIB_H)
424 $(EMACS_ROOT)/nt/inc/pwd.h
425 432
426$(BLD)/pop.$(O) : \ 433$(BLD)/pop.$(O) : \
427 $(SRC)/pop.c \ 434 $(LIB_SRC)/pop.c \
428 $(SRC)/pop.h \ 435 $(LIB_SRC)/pop.h \
429 $(EMACS_ROOT)/lib/min-max.h \ 436 $(NT_INC)/netdb.h \
430 $(SRC)/ntlib.h 437 $(NT_INC)/pwd.h \
438 $(NT_INC)/unistd.h \
439 $(GNU_LIB)/min-max.h \
440 $(CONFIG_H) \
441 $(NTLIB_H)
431 442
432$(BLD)/profile.$(O) : \ 443$(BLD)/profile.$(O) : \
433 $(SRC)/profile.c \ 444 $(LIB_SRC)/profile.c \
434 $(EMACS_ROOT)/src/s/ms-w32.h \ 445 $(GNU_LIB)/intprops.h \
435 $(EMACS_ROOT)/lib-src/../src/config.h \ 446 $(CONFIG_H) \
436 $(EMACS_ROOT)/lib-src/../src/systime.h 447 $(INTTYPES_H) \
437 448 $(SYSTIME_H)
438$(BLD)/qsort.$(O) : \ 449
439 $(SRC)/qsort.c 450$(BLD)/regex.$(O) : \
440 451 $(SRC)/regex.c \
441$(BLD)/tcp.$(O) : \ 452 $(SRC)/regex.h \
442 $(SRC)/tcp.c 453 $(NT_INC)/unistd.h \
454 $(CONFIG_H)
443 455
444$(BLD)/test-distrib.$(O) : \ 456$(BLD)/test-distrib.$(O) : \
445 $(SRC)/test-distrib.c 457 $(LIB_SRC)/test-distrib.c \
446 458 $(NT_INC)/unistd.h \
447$(BLD)/timer.$(O) : \ 459 $(CONFIG_H)
448 $(SRC)/timer.c \
449 $(EMACS_ROOT)/src/s/ms-w32.h \
450 $(EMACS_ROOT)/lib-src/../src/config.h
451 460
452# The following dependencies are for supporting parallel builds, where 461# The following dependencies are for supporting parallel builds, where
453# we must make sure $(BLD) exists before any compilation starts. 462# we must make sure $(BLD) exists before any compilation starts.
diff --git a/lib-src/movemail.c b/lib-src/movemail.c
index 9d19df32814..d157aa8c0b9 100644
--- a/lib-src/movemail.c
+++ b/lib-src/movemail.c
@@ -133,16 +133,10 @@ static char *mail_spool_name (char *);
133#endif 133#endif
134#endif 134#endif
135 135
136#ifndef HAVE_STRERROR 136static _Noreturn void fatal (const char *s1, const char *s2, const char *s3);
137char *strerror (int);
138#endif
139
140static void fatal (const char *s1, const char *s2, const char *s3) NO_RETURN;
141static void error (const char *s1, const char *s2, const char *s3); 137static void error (const char *s1, const char *s2, const char *s3);
142static void pfatal_with_name (char *name) NO_RETURN; 138static _Noreturn void pfatal_with_name (char *name);
143static void pfatal_and_delete (char *name) NO_RETURN; 139static _Noreturn void pfatal_and_delete (char *name);
144static char *concat (const char *s1, const char *s2, const char *s3);
145static long *xmalloc (unsigned int size);
146#ifdef MAIL_USE_POP 140#ifdef MAIL_USE_POP
147static int popmail (char *mailbox, char *outfile, int preserve, char *password, int reverse_order); 141static int popmail (char *mailbox, char *outfile, int preserve, char *password, int reverse_order);
148static int pop_retr (popserver server, int msgno, FILE *arg); 142static int pop_retr (popserver server, int msgno, FILE *arg);
@@ -151,6 +145,21 @@ static int mbx_delimit_begin (FILE *mbf);
151static int mbx_delimit_end (FILE *mbf); 145static int mbx_delimit_end (FILE *mbf);
152#endif 146#endif
153 147
148#if (defined MAIL_USE_MAILLOCK \
149 || (!defined DISABLE_DIRECT_ACCESS && !defined MAIL_USE_MMDF \
150 && !defined MAIL_USE_SYSTEM_LOCK))
151/* Like malloc but get fatal error if memory is exhausted. */
152
153static void *
154xmalloc (size_t size)
155{
156 void *result = malloc (size);
157 if (!result)
158 fatal ("virtual memory exhausted", 0, 0);
159 return result;
160}
161#endif
162
154/* Nonzero means this is name of a lock file to delete on fatal error. */ 163/* Nonzero means this is name of a lock file to delete on fatal error. */
155static char *delete_lockname; 164static char *delete_lockname;
156 165
@@ -168,7 +177,7 @@ main (int argc, char **argv)
168 int tem; 177 int tem;
169 char *lockname; 178 char *lockname;
170 char *tempname; 179 char *tempname;
171 size_t inname_dirlen; 180 size_t inname_len, inname_dirlen;
172 int desc; 181 int desc;
173#endif /* not MAIL_USE_SYSTEM_LOCK */ 182#endif /* not MAIL_USE_SYSTEM_LOCK */
174 183
@@ -296,12 +305,15 @@ main (int argc, char **argv)
296 should define MAIL_USE_SYSTEM_LOCK but does not, send a bug report 305 should define MAIL_USE_SYSTEM_LOCK but does not, send a bug report
297 to bug-gnu-emacs@prep.ai.mit.edu so we can fix it. */ 306 to bug-gnu-emacs@prep.ai.mit.edu so we can fix it. */
298 307
299 lockname = concat (inname, ".lock", ""); 308 inname_len = strlen (inname);
300 for (inname_dirlen = strlen (inname); 309 lockname = xmalloc (inname_len + sizeof ".lock");
310 strcpy (lockname, inname);
311 strcpy (lockname + inname_len, ".lock");
312 for (inname_dirlen = inname_len;
301 inname_dirlen && !IS_DIRECTORY_SEP (inname[inname_dirlen - 1]); 313 inname_dirlen && !IS_DIRECTORY_SEP (inname[inname_dirlen - 1]);
302 inname_dirlen--) 314 inname_dirlen--)
303 continue; 315 continue;
304 tempname = (char *) xmalloc (inname_dirlen + sizeof "EXXXXXX"); 316 tempname = xmalloc (inname_dirlen + sizeof "EXXXXXX");
305 317
306 while (1) 318 while (1)
307 { 319 {
@@ -583,8 +595,8 @@ mail_spool_name (char *inname)
583 if (stat (MAILDIR, &stat1) < 0) 595 if (stat (MAILDIR, &stat1) < 0)
584 return NULL; 596 return NULL;
585 597
586 indir = (char *) xmalloc (fname - inname + 1); 598 indir = xmalloc (fname - inname + 1);
587 strncpy (indir, inname, fname - inname); 599 memcpy (indir, inname, fname - inname);
588 indir[fname-inname] = '\0'; 600 indir[fname-inname] = '\0';
589 601
590 602
@@ -643,33 +655,6 @@ pfatal_and_delete (char *name)
643 unlink (name); 655 unlink (name);
644 fatal ("%s for %s", s, name); 656 fatal ("%s for %s", s, name);
645} 657}
646
647/* Return a newly-allocated string whose contents concatenate those of s1, s2, s3. */
648
649static char *
650concat (const char *s1, const char *s2, const char *s3)
651{
652 size_t len1 = strlen (s1), len2 = strlen (s2), len3 = strlen (s3);
653 char *result = (char *) xmalloc (len1 + len2 + len3 + 1);
654
655 strcpy (result, s1);
656 strcpy (result + len1, s2);
657 strcpy (result + len1 + len2, s3);
658 *(result + len1 + len2 + len3) = 0;
659
660 return result;
661}
662
663/* Like malloc but get fatal error if memory is exhausted. */
664
665static long *
666xmalloc (unsigned int size)
667{
668 long *result = (long *) malloc (size);
669 if (!result)
670 fatal ("virtual memory exhausted", 0, 0);
671 return result;
672}
673 658
674/* This is the guts of the interface to the Post Office Protocol. */ 659/* This is the guts of the interface to the Post Office Protocol. */
675 660
@@ -851,10 +836,7 @@ pop_retr (popserver server, int msgno, FILE *arg)
851 836
852 if (pop_retrieve_first (server, msgno, &line)) 837 if (pop_retrieve_first (server, msgno, &line))
853 { 838 {
854 char *msg = concat ("Error from POP server: ", pop_error, ""); 839 snprintf (Errmsg, sizeof Errmsg, "Error from POP server: %s", pop_error);
855 strncpy (Errmsg, msg, sizeof (Errmsg));
856 Errmsg[sizeof (Errmsg)-1] = '\0';
857 free (msg);
858 return (NOTOK); 840 return (NOTOK);
859 } 841 }
860 842
@@ -873,10 +855,7 @@ pop_retr (popserver server, int msgno, FILE *arg)
873 855
874 if (ret) 856 if (ret)
875 { 857 {
876 char *msg = concat ("Error from POP server: ", pop_error, ""); 858 snprintf (Errmsg, sizeof Errmsg, "Error from POP server: %s", pop_error);
877 strncpy (Errmsg, msg, sizeof (Errmsg));
878 Errmsg[sizeof (Errmsg)-1] = '\0';
879 free (msg);
880 return (NOTOK); 859 return (NOTOK);
881 } 860 }
882 861
@@ -939,21 +918,3 @@ mbx_delimit_end (FILE *mbf)
939} 918}
940 919
941#endif /* MAIL_USE_POP */ 920#endif /* MAIL_USE_POP */
942
943#ifndef HAVE_STRERROR
944char *
945strerror (errnum)
946 int errnum;
947{
948 extern char *sys_errlist[];
949 extern int sys_nerr;
950
951 if (errnum >= 0 && errnum < sys_nerr)
952 return sys_errlist[errnum];
953 return (char *) "Unknown error";
954}
955
956#endif /* ! HAVE_STRERROR */
957
958
959/* movemail.c ends here */
diff --git a/lib-src/pop.c b/lib-src/pop.c
index c4c7f2b4e2f..74054e0e1b1 100644
--- a/lib-src/pop.c
+++ b/lib-src/pop.c
@@ -21,11 +21,7 @@ You should have received a copy of the GNU General Public License
21along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ 21along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
22 22
23 23
24#ifdef HAVE_CONFIG_H
25#include <config.h> 24#include <config.h>
26#else
27#define MAIL_USE_POP
28#endif
29 25
30#ifdef MAIL_USE_POP 26#ifdef MAIL_USE_POP
31 27
@@ -101,7 +97,7 @@ extern char *krb_realmofhost (/* char * */);
101#endif /* KERBEROS */ 97#endif /* KERBEROS */
102 98
103#ifndef WINDOWSNT 99#ifndef WINDOWSNT
104#if !defined (HAVE_H_ERRNO) || !defined (HAVE_CONFIG_H) 100#ifndef HAVE_H_ERRNO
105extern int h_errno; 101extern int h_errno;
106#endif 102#endif
107#endif 103#endif
@@ -344,10 +340,7 @@ pop_stat (popserver server, int *count, int *size)
344 if (strncmp (fromserver, "+OK ", 4)) 340 if (strncmp (fromserver, "+OK ", 4))
345 { 341 {
346 if (0 == strncmp (fromserver, "-ERR", 4)) 342 if (0 == strncmp (fromserver, "-ERR", 4))
347 { 343 snprintf (pop_error, ERROR_MAX, "%s", fromserver);
348 strncpy (pop_error, fromserver, ERROR_MAX);
349 pop_error[ERROR_MAX-1] = '\0';
350 }
351 else 344 else
352 { 345 {
353 strcpy (pop_error, 346 strcpy (pop_error,
@@ -448,10 +441,7 @@ pop_list (popserver server, int message, int **IDs, int **sizes)
448 if (strncmp (fromserver, "+OK ", 4)) 441 if (strncmp (fromserver, "+OK ", 4))
449 { 442 {
450 if (! strncmp (fromserver, "-ERR", 4)) 443 if (! strncmp (fromserver, "-ERR", 4))
451 { 444 snprintf (pop_error, ERROR_MAX, "%s", fromserver);
452 strncpy (pop_error, fromserver, ERROR_MAX);
453 pop_error[ERROR_MAX-1] = '\0';
454 }
455 else 445 else
456 { 446 {
457 strcpy (pop_error, 447 strcpy (pop_error,
@@ -690,8 +680,7 @@ pop_multi_first (popserver server, const char *command, char **response)
690 680
691 if (0 == strncmp (*response, "-ERR", 4)) 681 if (0 == strncmp (*response, "-ERR", 4))
692 { 682 {
693 strncpy (pop_error, *response, ERROR_MAX); 683 snprintf (pop_error, ERROR_MAX, "%s", *response);
694 pop_error[ERROR_MAX-1] = '\0';
695 return (-1); 684 return (-1);
696 } 685 }
697 else if (0 == strncmp (*response, "+OK", 3)) 686 else if (0 == strncmp (*response, "+OK", 3))
@@ -864,8 +853,7 @@ pop_last (popserver server)
864 853
865 if (! strncmp (fromserver, "-ERR", 4)) 854 if (! strncmp (fromserver, "-ERR", 4))
866 { 855 {
867 strncpy (pop_error, fromserver, ERROR_MAX); 856 snprintf (pop_error, ERROR_MAX, "%s", fromserver);
868 pop_error[ERROR_MAX-1] = '\0';
869 return (-1); 857 return (-1);
870 } 858 }
871 else if (strncmp (fromserver, "+OK ", 4)) 859 else if (strncmp (fromserver, "+OK ", 4))
@@ -1065,9 +1053,8 @@ socket_connection (char *host, int flags)
1065 sock = socket (PF_INET, SOCK_STREAM, 0); 1053 sock = socket (PF_INET, SOCK_STREAM, 0);
1066 if (sock < 0) 1054 if (sock < 0)
1067 { 1055 {
1068 strcpy (pop_error, POP_SOCKET_ERROR); 1056 snprintf (pop_error, ERROR_MAX, "%s%s",
1069 strncat (pop_error, strerror (errno), 1057 POP_SOCKET_ERROR, strerror (errno));
1070 ERROR_MAX - sizeof (POP_SOCKET_ERROR));
1071 return (-1); 1058 return (-1);
1072 1059
1073 } 1060 }
@@ -1143,9 +1130,7 @@ socket_connection (char *host, int flags)
1143 if (! connect_ok) 1130 if (! connect_ok)
1144 { 1131 {
1145 CLOSESOCKET (sock); 1132 CLOSESOCKET (sock);
1146 strcpy (pop_error, CONNECT_ERROR); 1133 snprintf (pop_error, ERROR_MAX, "%s%s", CONNECT_ERROR, strerror (errno));
1147 strncat (pop_error, strerror (errno),
1148 ERROR_MAX - sizeof (CONNECT_ERROR));
1149 return (-1); 1134 return (-1);
1150 1135
1151 } 1136 }
@@ -1163,9 +1148,8 @@ socket_connection (char *host, int flags)
1163 krb5_auth_con_free (kcontext, auth_context); 1148 krb5_auth_con_free (kcontext, auth_context);
1164 if (kcontext) 1149 if (kcontext)
1165 krb5_free_context (kcontext); 1150 krb5_free_context (kcontext);
1166 strcpy (pop_error, KRB_ERROR); 1151 snprintf (pop_error, ERROR_MAX, "%s%s",
1167 strncat (pop_error, error_message (rem), 1152 KRB_ERROR, error_message (rem));
1168 ERROR_MAX - sizeof (KRB_ERROR));
1169 CLOSESOCKET (sock); 1153 CLOSESOCKET (sock);
1170 return (-1); 1154 return (-1);
1171 } 1155 }
@@ -1203,30 +1187,19 @@ socket_connection (char *host, int flags)
1203 krb5_free_principal (kcontext, server); 1187 krb5_free_principal (kcontext, server);
1204 if (rem) 1188 if (rem)
1205 { 1189 {
1206 strcpy (pop_error, KRB_ERROR); 1190 int pop_error_len = snprintf (pop_error, ERROR_MAX, "%s%s",
1207 strncat (pop_error, error_message (rem), 1191 KRB_ERROR, error_message (rem));
1208 ERROR_MAX - sizeof (KRB_ERROR));
1209#if defined HAVE_KRB5_ERROR_TEXT 1192#if defined HAVE_KRB5_ERROR_TEXT
1210 if (err_ret && err_ret->text.length) 1193 if (err_ret && err_ret->text.length)
1211 { 1194 {
1212 strncat (pop_error, " [server says '", 1195 int errlen = err_ret->text.length;
1213 ERROR_MAX - strlen (pop_error) - 1); 1196 snprintf (pop_error + pop_error_len, ERROR_MAX - pop_error_len,
1214 strncat (pop_error, err_ret->text.data, 1197 " [server says '.*%s']", errlen, err_ret->text.data);
1215 min (ERROR_MAX - strlen (pop_error) - 1,
1216 err_ret->text.length));
1217 strncat (pop_error, "']",
1218 ERROR_MAX - strlen (pop_error) - 1);
1219 } 1198 }
1220#elif defined HAVE_KRB5_ERROR_E_TEXT 1199#elif defined HAVE_KRB5_ERROR_E_TEXT
1221 if (err_ret && err_ret->e_text && strlen (*err_ret->e_text)) 1200 if (err_ret && err_ret->e_text && **err_ret->e_text)
1222 { 1201 snprintf (pop_error + pop_error_len, ERRMAX - pop_error_len,
1223 strncat (pop_error, " [server says '", 1202 " [server says '%s']", *err_ret->e_text);
1224 ERROR_MAX - strlen (pop_error) - 1);
1225 strncat (pop_error, *err_ret->e_text,
1226 ERROR_MAX - strlen (pop_error) - 1);
1227 strncat (pop_error, "']",
1228 ERROR_MAX - strlen (pop_error) - 1);
1229 }
1230#endif 1203#endif
1231 if (err_ret) 1204 if (err_ret)
1232 krb5_free_error (kcontext, err_ret); 1205 krb5_free_error (kcontext, err_ret);
@@ -1247,9 +1220,7 @@ socket_connection (char *host, int flags)
1247 free ((char *) ticket); 1220 free ((char *) ticket);
1248 if (rem != KSUCCESS) 1221 if (rem != KSUCCESS)
1249 { 1222 {
1250 strcpy (pop_error, KRB_ERROR); 1223 snprintf (pop_error, ERROR_MAX, "%s%s", KRB_ERROR, krb_err_txt[rem]);
1251 strncat (pop_error, krb_err_txt[rem],
1252 ERROR_MAX - sizeof (KRB_ERROR));
1253 CLOSESOCKET (sock); 1224 CLOSESOCKET (sock);
1254 return (-1); 1225 return (-1);
1255 } 1226 }
@@ -1354,9 +1325,8 @@ pop_getline (popserver server, char **line)
1354 server->buffer_size - server->data - 1, 0); 1325 server->buffer_size - server->data - 1, 0);
1355 if (ret < 0) 1326 if (ret < 0)
1356 { 1327 {
1357 strcpy (pop_error, GETLINE_ERROR); 1328 snprintf (pop_error, ERROR_MAX, "%s%s",
1358 strncat (pop_error, strerror (errno), 1329 GETLINE_ERROR, strerror (errno));
1359 ERROR_MAX - sizeof (GETLINE_ERROR));
1360 pop_trash (server); 1330 pop_trash (server);
1361 return (-1); 1331 return (-1);
1362 } 1332 }
@@ -1440,9 +1410,7 @@ sendline (popserver server, const char *line)
1440 if (ret < 0) 1410 if (ret < 0)
1441 { 1411 {
1442 pop_trash (server); 1412 pop_trash (server);
1443 strcpy (pop_error, SENDLINE_ERROR); 1413 snprintf (pop_error, ERROR_MAX, "%s%s", SENDLINE_ERROR, strerror (errno));
1444 strncat (pop_error, strerror (errno),
1445 ERROR_MAX - sizeof (SENDLINE_ERROR));
1446 return (ret); 1414 return (ret);
1447 } 1415 }
1448 1416
@@ -1504,8 +1472,7 @@ getok (popserver server)
1504 return (0); 1472 return (0);
1505 else if (! strncmp (fromline, "-ERR", 4)) 1473 else if (! strncmp (fromline, "-ERR", 4))
1506 { 1474 {
1507 strncpy (pop_error, fromline, ERROR_MAX); 1475 snprintf (pop_error, ERROR_MAX, "%s", fromline);
1508 pop_error[ERROR_MAX-1] = '\0';
1509 return (-1); 1476 return (-1);
1510 } 1477 }
1511 else 1478 else
diff --git a/lib-src/profile.c b/lib-src/profile.c
index 8ed4f318974..d21f2c28e58 100644
--- a/lib-src/profile.c
+++ b/lib-src/profile.c
@@ -20,7 +20,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
20 20
21 21
22/** 22/**
23 ** To be run as an emacs process. Input string that starts with: 23 ** To be run as an emacs subprocess. Input string that starts with:
24 ** 'z' -- resets the watch (to zero). 24 ** 'z' -- resets the watch (to zero).
25 ** 'p' -- return time (on stdout) as string with format <sec>.<micro-sec> 25 ** 'p' -- return time (on stdout) as string with format <sec>.<micro-sec>
26 ** 'q' -- exit. 26 ** 'q' -- exit.
@@ -29,53 +29,42 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
29 ** operations: reset_watch, get_time 29 ** operations: reset_watch, get_time
30 */ 30 */
31#include <config.h> 31#include <config.h>
32
33#include <inttypes.h>
32#include <stdio.h> 34#include <stdio.h>
35
36#include <intprops.h>
33#include <systime.h> 37#include <systime.h>
34 38
35static EMACS_TIME TV1, TV2; 39static EMACS_TIME TV1;
36static int watch_not_started = 1; /* flag */ 40static int watch_not_started = 1; /* flag */
37static char time_string[30]; 41static char time_string[INT_STRLEN_BOUND (uintmax_t) + sizeof "."
42 + LOG10_EMACS_TIME_RESOLUTION];
38 43
39/* Reset the stopwatch to zero. */ 44/* Reset the stopwatch to zero. */
40 45
41static void 46static void
42reset_watch (void) 47reset_watch (void)
43{ 48{
44 EMACS_GET_TIME (TV1); 49 TV1 = current_emacs_time ();
45 watch_not_started = 0; 50 watch_not_started = 0;
46} 51}
47 52
48/* This call returns the time since the last reset_watch call. The time 53/* This call returns the time since the last reset_watch call. The time
49 is returned as a string with the format <seconds>.<micro-seconds> 54 is returned as a string with the format <seconds>.<nanoseconds>
50 If reset_watch was not called yet, exit. */ 55 If reset_watch was not called yet, exit. */
51 56
52static char * 57static char *
53get_time (void) 58get_time (void)
54{ 59{
60 EMACS_TIME TV2 = sub_emacs_time (current_emacs_time (), TV1);
61 uintmax_t s = EMACS_SECS (TV2);
62 int ns = EMACS_NSECS (TV2);
55 if (watch_not_started) 63 if (watch_not_started)
56 exit (EXIT_FAILURE); /* call reset_watch first ! */ 64 exit (EXIT_FAILURE); /* call reset_watch first ! */
57 EMACS_GET_TIME (TV2); 65 sprintf (time_string, "%"PRIuMAX".%0*d", s, LOG10_EMACS_TIME_RESOLUTION, ns);
58 EMACS_SUB_TIME (TV2, TV2, TV1);
59 sprintf (time_string, "%lu.%06lu", (unsigned long)EMACS_SECS (TV2), (unsigned long)EMACS_USECS (TV2));
60 return time_string; 66 return time_string;
61} 67}
62
63#if ! defined (HAVE_GETTIMEOFDAY) && defined (HAVE_TIMEVAL)
64
65/* ARGSUSED */
66gettimeofday (tp, tzp)
67 struct timeval *tp;
68 struct timezone *tzp;
69{
70 extern long time ();
71
72 tp->tv_sec = time ((long *)0);
73 tp->tv_usec = 0;
74 if (tzp != 0)
75 tzp->tz_minuteswest = -1;
76}
77
78#endif
79 68
80int 69int
81main (void) 70main (void)
diff --git a/lib-src/update-game-score.c b/lib-src/update-game-score.c
index e0c940510be..40397536fad 100644
--- a/lib-src/update-game-score.c
+++ b/lib-src/update-game-score.c
@@ -48,8 +48,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
48#include <sys/stat.h> 48#include <sys/stat.h>
49#include <getopt.h> 49#include <getopt.h>
50 50
51static int usage (int err) NO_RETURN;
52
53#define MAX_ATTEMPTS 5 51#define MAX_ATTEMPTS 5
54#define MAX_SCORES 200 52#define MAX_SCORES 200
55#define MAX_DATA_LEN 1024 53#define MAX_DATA_LEN 1024
@@ -59,7 +57,7 @@ static int usage (int err) NO_RETURN;
59#define difftime(t1, t0) (double)((t1) - (t0)) 57#define difftime(t1, t0) (double)((t1) - (t0))
60#endif 58#endif
61 59
62static int 60static _Noreturn void
63usage (int err) 61usage (int err)
64{ 62{
65 fprintf (stdout, "Usage: update-game-score [-m MAX] [-r] [-d DIR] game/scorefile SCORE DATA\n"); 63 fprintf (stdout, "Usage: update-game-score [-m MAX] [-r] [-d DIR] game/scorefile SCORE DATA\n");
@@ -89,34 +87,14 @@ static void sort_scores (struct score_entry *scores, int count, int reverse);
89static int write_scores (const char *filename, 87static int write_scores (const char *filename,
90 const struct score_entry *scores, int count); 88 const struct score_entry *scores, int count);
91 89
92static void lose (const char *msg) NO_RETURN; 90static _Noreturn void
93
94static void
95lose (const char *msg) 91lose (const char *msg)
96{ 92{
97 fprintf (stderr, "%s\n", msg); 93 fprintf (stderr, "%s\n", msg);
98 exit (EXIT_FAILURE); 94 exit (EXIT_FAILURE);
99} 95}
100 96
101static void lose_syserr (const char *msg) NO_RETURN; 97static _Noreturn void
102
103/* Taken from sysdep.c. */
104#ifndef HAVE_STRERROR
105#ifndef WINDOWSNT
106char *
107strerror (int errnum)
108{
109 extern char *sys_errlist[];
110 extern int sys_nerr;
111
112 if (errnum >= 0 && errnum < sys_nerr)
113 return sys_errlist[errnum];
114 return (char *) "Unknown error";
115}
116#endif /* not WINDOWSNT */
117#endif /* ! HAVE_STRERROR */
118
119static void
120lose_syserr (const char *msg) 98lose_syserr (const char *msg)
121{ 99{
122 fprintf (stderr, "%s: %s\n", msg, strerror (errno)); 100 fprintf (stderr, "%s: %s\n", msg, strerror (errno));
diff --git a/lib-src/vcdiff b/lib-src/vcdiff
deleted file mode 100755
index dd7ca446d7c..00000000000
--- a/lib-src/vcdiff
+++ /dev/null
@@ -1,114 +0,0 @@
1#! /bin/sh
2
3# Enhanced sccs diff utility for use with vc mode.
4# This version is more compatible with rcsdiff(1).
5
6# Copyright (C) 1992-1993, 1995, 1997, 2001-2012
7# Free Software Foundation, Inc.
8
9# Author: Paul Eggert
10# (according to authors.el)
11
12# This file is part of GNU Emacs.
13
14# GNU Emacs is free software: you can redistribute it and/or modify
15# it under the terms of the GNU General Public License as published by
16# the Free Software Foundation, either version 3 of the License, or
17# (at your option) any later version.
18
19# GNU Emacs is distributed in the hope that it will be useful,
20# but WITHOUT ANY WARRANTY; without even the implied warranty of
21# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22# GNU General Public License for more details.
23
24# You should have received a copy of the GNU General Public License
25# along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
26
27
28DIFF="diff"
29usage="$0: Usage: vcdiff [--brief] [-q] [-r<sid1>] [-r<sid2>] [diffopts] sccsfile..."
30
31# Now that we use `sccs get' rather than just `get', we don't need this.
32# PATH=$PATH:/usr/ccs/bin:/usr/sccs:/usr/xpg4/bin # common SCCS hangouts
33
34echo="echo"
35sid1= sid2=
36
37for f
38do
39 case $f in
40 -*)
41 case $f in
42 --brief)
43 DIFF=cmp;;
44 -q)
45 echo=:;;
46 -r?*)
47 case $sid1 in
48 '')
49 sid1=$f
50 ;;
51 *)
52 case $sid2 in
53 ?*) echo "$usage" >&2; exit 2 ;;
54 esac
55 sid2=$f
56 ;;
57 esac
58 ;;
59 *)
60 options="$options $f"
61 ;;
62 esac
63 shift
64 ;;
65 *)
66 break
67 ;;
68 esac
69done
70
71case $# in
720)
73 echo "$usage" >&2
74 exit 2
75esac
76
77
78rev1= rev2= status=0
79trap 'status=2; exit' 1 2 13 15
80trap 'rm -f $rev1 $rev2 || status=2; exit $status' 0
81
82for f
83do
84 s=2
85
86 case $f in
87 s.* | */s.*)
88 if
89 rev1=`mktemp /tmp/geta.XXXXXXXX`
90 sccs get -s -p -k $sid1 "$f" > $rev1 &&
91 case $sid2 in
92 '')
93 workfile=`expr " /$f" : '.*/s.\(.*\)'`
94 ;;
95 *)
96 rev2=`mktemp /tmp/getb.XXXXXXXX`
97 sccs get -s -p -k $sid2 "$f" > $rev2
98 workfile=$rev2
99 esac
100 then
101 $echo $DIFF $options $rev1 $workfile >&2
102 $DIFF $options $rev1 $workfile
103 s=$?
104 fi
105 ;;
106 *)
107 echo "$0: $f is not an SCCS file" >&2
108 esac
109
110 if test $status -lt $s
111 then status=$s
112 fi
113done
114