diff options
| author | Joakim Verona | 2012-07-27 02:22:03 +0200 |
|---|---|---|
| committer | Joakim Verona | 2012-07-27 02:22:03 +0200 |
| commit | 5fb63197843dcae66f2fe0ddd6f4a9d560e9db2f (patch) | |
| tree | 5c55f1096a656a9759f0b53a0b5d1a2289bd366f /lib-src | |
| parent | 0c5c85cf2b350c965bb1ffa5b2d77c2adebc406b (diff) | |
| parent | 562157c814037dcba58a20cd6908a95992c22283 (diff) | |
| download | emacs-5fb63197843dcae66f2fe0ddd6f4a9d560e9db2f.tar.gz emacs-5fb63197843dcae66f2fe0ddd6f4a9d560e9db2f.zip | |
upstream
Diffstat (limited to 'lib-src')
| -rw-r--r-- | lib-src/ChangeLog | 156 | ||||
| -rw-r--r-- | lib-src/Makefile.in | 10 | ||||
| -rw-r--r-- | lib-src/ebrowse.c | 8 | ||||
| -rw-r--r-- | lib-src/emacsclient.c | 89 | ||||
| -rw-r--r-- | lib-src/etags.c | 129 | ||||
| -rw-r--r-- | lib-src/hexl.c | 4 | ||||
| -rw-r--r-- | lib-src/make-docfile.c | 105 | ||||
| -rw-r--r-- | lib-src/makefile.w32-in | 153 | ||||
| -rw-r--r-- | lib-src/movemail.c | 97 | ||||
| -rw-r--r-- | lib-src/pop.c | 79 | ||||
| -rw-r--r-- | lib-src/profile.c | 39 | ||||
| -rw-r--r-- | lib-src/update-game-score.c | 28 |
12 files changed, 471 insertions, 426 deletions
diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog index 68a8c37c2fb..4f4d2b50a00 100644 --- a/lib-src/ChangeLog +++ b/lib-src/ChangeLog | |||
| @@ -1,3 +1,159 @@ | |||
| 1 | 2012-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 | |||
| 7 | 2012-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 | |||
| 22 | 2012-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 | |||
| 44 | 2012-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 | |||
| 49 | 2012-07-09 Juanma Barranquero <lekktu@gmail.com> | ||
| 50 | |||
| 51 | * emacsclient.c (w32_execvp): Declare execvp to silence the compiler. | ||
| 52 | |||
| 53 | 2012-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 | |||
| 65 | 2012-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 | |||
| 73 | 2012-07-07 Juanma Barranquero <lekktu@gmail.com> | ||
| 74 | |||
| 75 | * makefile.w32-in ($(BLD)/ctags.$(O), $(BLD)/etags.$(O)): | ||
| 76 | Update dependencies. | ||
| 77 | |||
| 78 | 2012-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 | |||
| 85 | 2012-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 | |||
| 90 | 2012-07-03 Paul Eggert <eggert@cs.ucla.edu> | ||
| 91 | |||
| 92 | * make-docfile.c (scan_c_file): Suppress GCC warning. | ||
| 93 | |||
| 94 | 2012-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 | |||
| 104 | 2012-06-30 Juanma Barranquero <lekktu@gmail.com> | ||
| 105 | |||
| 106 | * makefile.w32-in (CTAGS_CFLAGS): Remove EMACS_NAME; | ||
| 107 | already defined in ETAGS_CFLAGS. | ||
| 108 | |||
| 109 | 2012-06-27 Glenn Morris <rgm@gnu.org> | ||
| 110 | |||
| 111 | * makefile.w32-in (lisp2): Remove paths.el. | ||
| 112 | |||
| 113 | 2012-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 | |||
| 123 | 2012-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 | |||
| 128 | 2012-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 | |||
| 143 | 2012-06-24 Samuel Bronson <naesten@gmail.com> (tiny change) | ||
| 144 | |||
| 145 | * emacsclient.c (set_local_socket): Fix compiler warning (Bug#7838). | ||
| 146 | |||
| 147 | 2012-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 | |||
| 1 | 2012-06-08 Andreas Schwab <schwab@linux-m68k.org> | 157 | 2012-06-08 Andreas Schwab <schwab@linux-m68k.org> |
| 2 | 158 | ||
| 3 | * make-docfile.c (search_lisp_doc_at_eol): Unget last read | 159 | * make-docfile.c (search_lisp_doc_at_eol): Unget last read |
diff --git a/lib-src/Makefile.in b/lib-src/Makefile.in index 2df22d9f7d8..fe727c65730 100644 --- a/lib-src/Makefile.in +++ b/lib-src/Makefile.in | |||
| @@ -159,6 +159,8 @@ LIBHESIOD=@LIBHESIOD@ | |||
| 159 | LIBRESOLV=@LIBRESOLV@ | 159 | LIBRESOLV=@LIBRESOLV@ |
| 160 | ## -llockfile if HAVE_LIBLOCKFILE or -lmail if HAVE_LIBMAIL | 160 | ## -llockfile if HAVE_LIBLOCKFILE or -lmail if HAVE_LIBMAIL |
| 161 | LIBS_MAIL=@LIBS_MAIL@ | 161 | LIBS_MAIL=@LIBS_MAIL@ |
| 162 | ## empty or -lrt or -lposix4 if HAVE_CLOCK_GETTIME | ||
| 163 | LIB_CLOCK_GETTIME = @LIB_CLOCK_GETTIME@ | ||
| 162 | 164 | ||
| 163 | ## Extra libraries to use when linking movemail. | 165 | ## Extra libraries to use when linking movemail. |
| 164 | LIBS_MOVE = $(LIBS_MAIL) $(KRB4LIB) $(DESLIB) $(KRB5LIB) $(CRYPTOLIB) \ | 166 | LIBS_MOVE = $(LIBS_MAIL) $(KRB4LIB) $(DESLIB) $(KRB5LIB) $(CRYPTOLIB) \ |
| @@ -167,12 +169,9 @@ LIBS_MOVE = $(LIBS_MAIL) $(KRB4LIB) $(DESLIB) $(KRB5LIB) $(CRYPTOLIB) \ | |||
| 167 | ## Some systems define this to request special libraries. | 169 | ## Some systems define this to request special libraries. |
| 168 | LIBS_SYSTEM = @LIBS_SYSTEM@ | 170 | LIBS_SYSTEM = @LIBS_SYSTEM@ |
| 169 | 171 | ||
| 170 | # Those files shared with other GNU utilities need HAVE_CONFIG_H | ||
| 171 | # defined before they know they can take advantage of the information | ||
| 172 | # in ../src/config.h. | ||
| 173 | BASE_CFLAGS = $(C_SWITCH_SYSTEM) $(C_SWITCH_MACHINE) \ | 172 | BASE_CFLAGS = $(C_SWITCH_SYSTEM) $(C_SWITCH_MACHINE) \ |
| 174 | $(WARN_CFLAGS) $(WERROR_CFLAGS) \ | 173 | $(WARN_CFLAGS) $(WERROR_CFLAGS) \ |
| 175 | -DHAVE_CONFIG_H -I. -I../src -I../lib \ | 174 | -I. -I../src -I../lib \ |
| 176 | -I${srcdir} -I${srcdir}/../src -I${srcdir}/../lib | 175 | -I${srcdir} -I${srcdir}/../src -I${srcdir}/../lib |
| 177 | 176 | ||
| 178 | ALL_CFLAGS = ${BASE_CFLAGS} ${PROFILING_CFLAGS} ${LDFLAGS} ${CPPFLAGS} ${CFLAGS} | 177 | ALL_CFLAGS = ${BASE_CFLAGS} ${PROFILING_CFLAGS} ${LDFLAGS} ${CPPFLAGS} ${CFLAGS} |
| @@ -309,7 +308,8 @@ ctags${EXEEXT}: etags${EXEEXT} | |||
| 309 | regex.o $(LOADLIBES) -o ctags | 308 | regex.o $(LOADLIBES) -o ctags |
| 310 | 309 | ||
| 311 | profile${EXEEXT}: ${srcdir}/profile.c ../src/config.h | 310 | profile${EXEEXT}: ${srcdir}/profile.c ../src/config.h |
| 312 | $(CC) ${ALL_CFLAGS} ${srcdir}/profile.c $(LOADLIBES) -o profile | 311 | $(CC) ${ALL_CFLAGS} ${srcdir}/profile.c \ |
| 312 | $(LOADLIBES) $(LIB_CLOCK_GETTIME) -o profile | ||
| 313 | 313 | ||
| 314 | make-docfile${EXEEXT}: ${srcdir}/make-docfile.c ../src/config.h | 314 | make-docfile${EXEEXT}: ${srcdir}/make-docfile.c ../src/config.h |
| 315 | $(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); | |||
| 463 | static void class_definition (struct sym *, int, int, int); | 463 | static void class_definition (struct sym *, int, int, int); |
| 464 | static char *operator_name (int *); | 464 | static char *operator_name (int *); |
| 465 | static void parse_qualified_param_ident_or_type (char **); | 465 | static void parse_qualified_param_ident_or_type (char **); |
| 466 | static void usage (int) NO_RETURN; | ||
| 467 | static 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 | ||
| 3510 | static void | 3506 | static _Noreturn void |
| 3511 | usage (int error) | 3507 | usage (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 | ||
| 3525 | static void | 3521 | static _Noreturn void |
| 3526 | version (void) | 3522 | version (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 */ |
| 170 | const char *frame_parameters = NULL; | 170 | const char *frame_parameters = NULL; |
| 171 | 171 | ||
| 172 | static void print_help_and_exit (void) NO_RETURN; | 172 | static _Noreturn void print_help_and_exit (void); |
| 173 | static void fail (void) NO_RETURN; | ||
| 174 | 173 | ||
| 175 | 174 | ||
| 176 | struct option longopts[] = | 175 | struct 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 | |
| 464 | int | 462 | int |
| 465 | w32_execvp (const char *path, char **argv) | 463 | w32_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 | ||
| 673 | static void | 672 | static _Noreturn void |
| 674 | print_help_and_exit (void) | 673 | print_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 | */ | 719 | static _Noreturn void |
| 721 | static void | ||
| 722 | fail (void) | 720 | fail (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 | ||
| 754 | extern char *strerror (int); | ||
| 755 | |||
| 756 | /* Buffer to accumulate data to send in TCP connections. */ | 752 | /* Buffer to accumulate data to send in TCP connections. */ |
| 757 | char send_buffer[SEND_BUFFER_SIZE + 1]; | 753 | char send_buffer[SEND_BUFFER_SIZE + 1]; |
| 758 | int sblen = 0; /* Fill pointer for the send buffer. */ | 754 | int 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. */ |
| 760 | HSOCKET emacs_socket = 0; | 756 | HSOCKET 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 | |||
| 764 | static void | 761 | static void |
| 765 | sock_err_message (const char *function_name) | 762 | sock_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 | ||
| 870 | static char * | 867 | static char * |
| 871 | unquote_argument (char *str) | 868 | unquote_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 | */ | ||
| 955 | static int | 951 | static int |
| 956 | get_server_config (const char *config_file, struct sockaddr_in *server, | 952 | get_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 | ||
| 1193 | static void | 1183 | static void |
| 1194 | handle_sigtstp (int signalnum) | 1184 | handle_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 | */ | ||
| 1484 | void | 1470 | void |
| 1485 | w32_give_focus (void) | 1471 | w32_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 | ||
| 1868 | char * | ||
| 1869 | strerror (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! | ||
| 174 | If 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 *); | |||
| 366 | static void free_regexps (void); | 353 | static void free_regexps (void); |
| 367 | static void regex_tag_multiline (void); | 354 | static void regex_tag_multiline (void); |
| 368 | static void error (const char *, ...) ATTRIBUTE_FORMAT_PRINTF (1, 2); | 355 | static void error (const char *, ...) ATTRIBUTE_FORMAT_PRINTF (1, 2); |
| 369 | static void suggest_asking_for_help (void) NO_RETURN; | 356 | static _Noreturn void suggest_asking_for_help (void); |
| 370 | void fatal (const char *, const char *) NO_RETURN; | 357 | _Noreturn void fatal (const char *, const char *); |
| 371 | static void pfatal (const char *) NO_RETURN; | 358 | static _Noreturn void pfatal (const char *); |
| 372 | static void add_node (node *, node **); | 359 | static void add_node (node *, node **); |
| 373 | 360 | ||
| 374 | static void init (void); | 361 | static void init (void); |
| @@ -389,8 +376,6 @@ static char *savenstr (const char *, int); | |||
| 389 | static char *savestr (const char *); | 376 | static char *savestr (const char *); |
| 390 | static char *etags_strchr (const char *, int); | 377 | static char *etags_strchr (const char *, int); |
| 391 | static char *etags_strrchr (const char *, int); | 378 | static char *etags_strrchr (const char *, int); |
| 392 | static int etags_strcasecmp (const char *, const char *); | ||
| 393 | static int etags_strncasecmp (const char *, const char *, int); | ||
| 394 | static char *etags_getcwd (void); | 379 | static char *etags_getcwd (void); |
| 395 | static char *relative_filename (char *, char *); | 380 | static char *relative_filename (char *, char *); |
| 396 | static char *absolute_filename (char *, char *); | 381 | static char *absolute_filename (char *, char *); |
| @@ -2138,7 +2123,7 @@ invalidate_nodes (fdesc *badfdp, node **npp) | |||
| 2138 | 2123 | ||
| 2139 | 2124 | ||
| 2140 | static int total_size_of_entries (node *); | 2125 | static int total_size_of_entries (node *); |
| 2141 | static int number_len (long); | 2126 | static 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. */ |
| 2144 | static int | 2129 | static 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 | */ | ||
| 6328 | static int | ||
| 6329 | etags_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 | */ | ||
| 6348 | static int | ||
| 6349 | etags_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. */ |
| 6366 | static char * | 6301 | static char * |
| 6367 | skip_spaces (char *cp) | 6302 | skip_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 | |||
| 20 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | 20 | along 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; | |||
| 48 | int group_by = DEFAULT_GROUPING; | 46 | int group_by = DEFAULT_GROUPING; |
| 49 | char *progname; | 47 | char *progname; |
| 50 | 48 | ||
| 51 | void usage (void) NO_RETURN; | 49 | _Noreturn void usage (void); |
| 52 | 50 | ||
| 53 | int | 51 | int |
| 54 | main (int argc, char **argv) | 52 | main (int argc, char **argv) |
diff --git a/lib-src/make-docfile.c b/lib-src/make-docfile.c index 4f68fdb78c9..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/>. */ | |||
| 76 | static int scan_file (char *filename); | 76 | static int scan_file (char *filename); |
| 77 | static int scan_lisp_file (const char *filename, const char *mode); | 77 | static int scan_lisp_file (const char *filename, const char *mode); |
| 78 | static int scan_c_file (char *filename, const char *mode); | 78 | static int scan_c_file (char *filename, const char *mode); |
| 79 | static void fatal (const char *s1, const char *s2) NO_RETURN; | ||
| 80 | static void start_globals (void); | 79 | static void start_globals (void); |
| 81 | static void write_globals (void); | 80 | static 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 */ |
| 114 | static void | 113 | static _Noreturn void |
| 115 | fatal (const char *s1, const char *s2) | 114 | fatal (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. */ |
| 566 | enum global_type | 565 | enum 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; | |||
| 585 | struct global *globals; | 586 | struct global *globals; |
| 586 | 587 | ||
| 587 | static void | 588 | static void |
| 588 | add_global (enum global_type type, char *name) | 589 | add_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 | ||
| 620 | static void | 631 | static void |
| 632 | close_emacs_globals (void) | ||
| 633 | { | ||
| 634 | fprintf (outfile, "};\n"); | ||
| 635 | fprintf (outfile, "extern struct emacs_globals globals;\n"); | ||
| 636 | } | ||
| 637 | |||
| 638 | static void | ||
| 621 | write_globals (void) | 639 | write_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 | ||
diff --git a/lib-src/makefile.w32-in b/lib-src/makefile.w32-in index fea1d29592e..4b2b523ea34 100644 --- a/lib-src/makefile.w32-in +++ b/lib-src/makefile.w32-in | |||
| @@ -19,12 +19,12 @@ | |||
| 19 | 19 | ||
| 20 | ALL = $(BLD)/test-distrib.exe $(BLD)/make-docfile.exe $(BLD)/hexl.exe\ | 20 | ALL = $(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 | ||
| 26 | LOCAL_FLAGS = -DWINDOWSNT -DDOS_NT -DNO_LDAV=1 \ | 26 | LOCAL_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 | ||
| 30 | LIBS = $(BASE_LIBS) $(ADVAPI32) | 30 | LIBS = $(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 | ||
| 43 | MOVEMAILOBJS = $(BLD)/movemail.$(O) \ | 43 | MOVEMAILOBJS = $(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 | ||
| 109 | CTAGS_CFLAGS = -DCTAGS $(ETAGS_CFLAGS) -DEMACS_NAME="\"GNU Emacs\"" | 109 | CTAGS_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 | ||
| 113 | PROFILEOBJS = $(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,85 +355,108 @@ TAGS: $(BLD)/etags.exe *.c *.h | |||
| 349 | ### DEPENDENCIES ### | 355 | ### DEPENDENCIES ### |
| 350 | 356 | ||
| 351 | EMACS_ROOT = .. | 357 | EMACS_ROOT = .. |
| 352 | SRC = . | 358 | LIB_SRC = . |
| 353 | 359 | SRC = $(EMACS_ROOT)/src | |
| 354 | $(BLD)/alloca.$(O) : \ | 360 | NT_INC = $(EMACS_ROOT)/nt/inc |
| 355 | $(SRC)/alloca.c \ | 361 | GNU_LIB = $(EMACS_ROOT)/lib |
| 356 | $(EMACS_ROOT)/src/s/ms-w32.h \ | 362 | |
| 357 | $(EMACS_ROOT)/src/config.h \ | 363 | MS_W32_H = $(SRC)/s/ms-w32.h \ |
| 358 | $(EMACS_ROOT)/src/blockinput.h | 364 | $(NT_INC)/sys/stat.h |
| 365 | CONFIG_H = $(SRC)/config.h \ | ||
| 366 | $(MS_W32_H) | ||
| 367 | INTTYPES_H = $(NT_INC)/inttypes.h \ | ||
| 368 | $(NT_INC)/stdint.h | ||
| 369 | NTLIB_H = $(LIB_SRC)/ntlib.h \ | ||
| 370 | $(NT_INC)/pwd.h | ||
| 371 | SYSTIME_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 | 406 | ||
| 390 | $(BLD)/hexl.$(O) : \ | 407 | $(BLD)/hexl.$(O) : \ |
| 391 | $(SRC)/hexl.c | 408 | $(LIB_SRC)/hexl.c \ |
| 409 | $(CONFIG_H) | ||
| 392 | 410 | ||
| 393 | $(BLD)/make-docfile.$(O) : \ | 411 | $(BLD)/make-docfile.$(O) : \ |
| 394 | $(SRC)/make-docfile.c \ | 412 | $(LIB_SRC)/make-docfile.c \ |
| 395 | $(EMACS_ROOT)/src/config.h | 413 | $(NT_INC)/unistd.h \ |
| 414 | $(CONFIG_H) | ||
| 396 | 415 | ||
| 397 | $(BLD)/movemail.$(O) : \ | 416 | $(BLD)/movemail.$(O) : \ |
| 398 | $(SRC)/movemail.c \ | 417 | $(LIB_SRC)/movemail.c \ |
| 399 | $(EMACS_ROOT)/src/s/ms-w32.h \ | 418 | $(LIB_SRC)/pop.h \ |
| 400 | $(EMACS_ROOT)/lib-src/../src/config.h \ | 419 | $(SRC)/syswait.h \ |
| 401 | $(EMACS_ROOT)/nt/inc/sys/file.h \ | 420 | $(NT_INC)/pwd.h \ |
| 402 | $(EMACS_ROOT)/nt/inc/sys/stat.h \ | 421 | $(NT_INC)/sys/file.h \ |
| 403 | $(EMACS_ROOT)/lib-src/../src/syswait.h \ | 422 | $(NT_INC)/sys/stat.h \ |
| 404 | $(EMACS_ROOT)/nt/inc/pwd.h \ | 423 | $(NT_INC)/unistd.h \ |
| 405 | $(SRC)/ntlib.h | 424 | $(GNU_LIB)/getopt.h \ |
| 406 | $(CC) $(CFLAGS) -DUSG $(CC_OUT)$@ movemail.c | 425 | $(CONFIG_H) \ |
| 426 | $(NTLIB_H) | ||
| 407 | 427 | ||
| 408 | $(BLD)/ntlib.$(O) : \ | 428 | $(BLD)/ntlib.$(O) : \ |
| 409 | $(SRC)/ntlib.c \ | 429 | $(LIB_SRC)/ntlib.c \ |
| 410 | $(SRC)/ntlib.h \ | 430 | $(NT_INC)/sys/stat.h \ |
| 411 | $(EMACS_ROOT)/nt/inc/sys/stat.h \ | 431 | $(NTLIB_H) |
| 412 | $(EMACS_ROOT)/nt/inc/pwd.h | ||
| 413 | 432 | ||
| 414 | $(BLD)/pop.$(O) : \ | 433 | $(BLD)/pop.$(O) : \ |
| 415 | $(SRC)/pop.c \ | 434 | $(LIB_SRC)/pop.c \ |
| 416 | $(SRC)/pop.h \ | 435 | $(LIB_SRC)/pop.h \ |
| 417 | $(EMACS_ROOT)/lib/min-max.h \ | 436 | $(NT_INC)/netdb.h \ |
| 418 | $(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) | ||
| 419 | 442 | ||
| 420 | $(BLD)/profile.$(O) : \ | 443 | $(BLD)/profile.$(O) : \ |
| 421 | $(SRC)/profile.c \ | 444 | $(LIB_SRC)/profile.c \ |
| 422 | $(EMACS_ROOT)/src/s/ms-w32.h \ | 445 | $(GNU_LIB)/intprops.h \ |
| 423 | $(EMACS_ROOT)/lib-src/../src/config.h \ | 446 | $(CONFIG_H) \ |
| 424 | $(EMACS_ROOT)/lib-src/../src/systime.h | 447 | $(INTTYPES_H) \ |
| 425 | 448 | $(SYSTIME_H) | |
| 426 | $(BLD)/tcp.$(O) : \ | 449 | |
| 427 | $(SRC)/tcp.c | 450 | $(BLD)/regex.$(O) : \ |
| 451 | $(SRC)/regex.c \ | ||
| 452 | $(SRC)/regex.h \ | ||
| 453 | $(NT_INC)/unistd.h \ | ||
| 454 | $(CONFIG_H) | ||
| 428 | 455 | ||
| 429 | $(BLD)/test-distrib.$(O) : \ | 456 | $(BLD)/test-distrib.$(O) : \ |
| 430 | $(SRC)/test-distrib.c | 457 | $(LIB_SRC)/test-distrib.c \ |
| 458 | $(NT_INC)/unistd.h \ | ||
| 459 | $(CONFIG_H) | ||
| 431 | 460 | ||
| 432 | # The following dependencies are for supporting parallel builds, where | 461 | # The following dependencies are for supporting parallel builds, where |
| 433 | # 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 | 136 | static _Noreturn void fatal (const char *s1, const char *s2, const char *s3); |
| 137 | char *strerror (int); | ||
| 138 | #endif | ||
| 139 | |||
| 140 | static void fatal (const char *s1, const char *s2, const char *s3) NO_RETURN; | ||
| 141 | static void error (const char *s1, const char *s2, const char *s3); | 137 | static void error (const char *s1, const char *s2, const char *s3); |
| 142 | static void pfatal_with_name (char *name) NO_RETURN; | 138 | static _Noreturn void pfatal_with_name (char *name); |
| 143 | static void pfatal_and_delete (char *name) NO_RETURN; | 139 | static _Noreturn void pfatal_and_delete (char *name); |
| 144 | static char *concat (const char *s1, const char *s2, const char *s3); | ||
| 145 | static long *xmalloc (unsigned int size); | ||
| 146 | #ifdef MAIL_USE_POP | 140 | #ifdef MAIL_USE_POP |
| 147 | static int popmail (char *mailbox, char *outfile, int preserve, char *password, int reverse_order); | 141 | static int popmail (char *mailbox, char *outfile, int preserve, char *password, int reverse_order); |
| 148 | static int pop_retr (popserver server, int msgno, FILE *arg); | 142 | static int pop_retr (popserver server, int msgno, FILE *arg); |
| @@ -151,6 +145,21 @@ static int mbx_delimit_begin (FILE *mbf); | |||
| 151 | static int mbx_delimit_end (FILE *mbf); | 145 | static 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 | |||
| 153 | static void * | ||
| 154 | xmalloc (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. */ |
| 155 | static char *delete_lockname; | 164 | static 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 | |||
| 649 | static char * | ||
| 650 | concat (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 | |||
| 665 | static long * | ||
| 666 | xmalloc (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 | ||
| 944 | char * | ||
| 945 | strerror (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 | |||
| 21 | along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | 21 | along 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 |
| 105 | extern int h_errno; | 101 | extern 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 | ||
| 35 | static EMACS_TIME TV1, TV2; | 39 | static EMACS_TIME TV1; |
| 36 | static int watch_not_started = 1; /* flag */ | 40 | static int watch_not_started = 1; /* flag */ |
| 37 | static char time_string[30]; | 41 | static 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 | ||
| 41 | static void | 46 | static void |
| 42 | reset_watch (void) | 47 | reset_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 | ||
| 52 | static char * | 57 | static char * |
| 53 | get_time (void) | 58 | get_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 */ | ||
| 66 | gettimeofday (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 | ||
| 80 | int | 69 | int |
| 81 | main (void) | 70 | main (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 | ||
| 51 | static 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 | ||
| 62 | static int | 60 | static _Noreturn void |
| 63 | usage (int err) | 61 | usage (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); | |||
| 89 | static int write_scores (const char *filename, | 87 | static int write_scores (const char *filename, |
| 90 | const struct score_entry *scores, int count); | 88 | const struct score_entry *scores, int count); |
| 91 | 89 | ||
| 92 | static void lose (const char *msg) NO_RETURN; | 90 | static _Noreturn void |
| 93 | |||
| 94 | static void | ||
| 95 | lose (const char *msg) | 91 | lose (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 | ||
| 101 | static void lose_syserr (const char *msg) NO_RETURN; | 97 | static _Noreturn void |
| 102 | |||
| 103 | /* Taken from sysdep.c. */ | ||
| 104 | #ifndef HAVE_STRERROR | ||
| 105 | #ifndef WINDOWSNT | ||
| 106 | char * | ||
| 107 | strerror (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 | |||
| 119 | static void | ||
| 120 | lose_syserr (const char *msg) | 98 | lose_syserr (const char *msg) |
| 121 | { | 99 | { |
| 122 | fprintf (stderr, "%s: %s\n", msg, strerror (errno)); | 100 | fprintf (stderr, "%s: %s\n", msg, strerror (errno)); |