aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src
diff options
context:
space:
mode:
authorStefan Monnier2012-03-25 16:37:21 -0400
committerStefan Monnier2012-03-25 16:37:21 -0400
commit699c782b7668c44d0fa4446331b0590a6d5dac82 (patch)
tree5dcce364741d0761920a3d274b0fc8aba4103d45 /lib-src
parent98fb480ee31bf74cf554044f60f21df16566dd7f (diff)
parente99a9b8bdccadded1f6fae88ee7a2a93dfd4eacf (diff)
downloademacs-pending.tar.gz
emacs-pending.zip
Merge from trunkpending
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/ChangeLog194
-rw-r--r--lib-src/Makefile.in10
-rw-r--r--lib-src/ebrowse.c24
-rw-r--r--lib-src/emacsclient.c334
-rw-r--r--lib-src/etags.c230
-rwxr-xr-xlib-src/grep-changelog2
-rw-r--r--lib-src/hexl.c4
-rw-r--r--lib-src/make-docfile.c8
-rw-r--r--lib-src/makefile.w32-in6
-rw-r--r--lib-src/movemail.c15
-rw-r--r--lib-src/ntlib.c2
-rw-r--r--lib-src/ntlib.h2
-rw-r--r--lib-src/pop.c24
-rw-r--r--lib-src/pop.h2
-rw-r--r--lib-src/profile.c2
-rwxr-xr-xlib-src/rcs-checkin2
-rwxr-xr-xlib-src/rcs2log4
-rw-r--r--lib-src/test-distrib.c2
-rw-r--r--lib-src/update-game-score.c31
-rwxr-xr-xlib-src/vcdiff2
20 files changed, 515 insertions, 385 deletions
diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog
index 098ee06c762..2384599caf2 100644
--- a/lib-src/ChangeLog
+++ b/lib-src/ChangeLog
@@ -1,3 +1,129 @@
12012-03-11 Andreas Schwab <schwab@linux-m68k.org>
2
3 * emacsclient.c (main): Handle -print-nonl command.
4
5 * emacsclient.c (main): Handle multiple messages in a single
6 datagram.
7
8 * emacsclient.c (socket_name): Add const.
9 (get_server_config): Add parameter config_file, use it instead of
10 global server_file.
11 (set_tcp_socket): Add parameter local_server_file, pass it down to
12 get_server_config.
13 (set_local_socket): Add parameter local_socket_name, use it
14 instead of global socket_name.
15 (set_socket): Adjust calls to set_local_socket and set_tcp_socket.
16 Don't clobber global server_file or socket_name.
17 (main): No longer reset server_file or socket_name.
18
192012-01-05 Glenn Morris <rgm@gnu.org>
20
21 * ebrowse.c (version) <emacs_copyright>:
22 * etags.c (print_version) <emacs_copyright>:
23 * rcs2log (Copyright): Update short copyright year to 2012.
24
252011-12-25 Andreas Schwab <schwab@linux-m68k.org>
26
27 * etags.c (C_entries): Properly skip over string and character
28 constants and comments inside brackets. (Bug#10357)
29
302011-12-04 Juanma Barranquero <lekktu@gmail.com>
31
32 * emacsclient.c (decode_options) [WINDOWSNT]: Don't force tty = 0;
33 instead, treat both -c and -t as always requesting a new "tty" frame,
34 and let server.el decide which kind is actually required.
35 Reported by Uwe Siart <usenet@siart.de> in this thread:
36 http://lists.gnu.org/archive/html/emacs-devel/2011-11/msg00303.html
37
382011-11-30 Chong Yidong <cyd@gnu.org>
39
40 * emacsclient.c (main): Condition last change on WINDOWSNT
41 (Bug#10155).
42
432011-11-27 Eli Zaretskii <eliz@gnu.org>
44
45 * makefile.w32-in (LOCAL_FLAGS): Add $(EMACS_EXTRA_C_FLAGS).
46
47 * emacsclient.c (main) <environ>: Remove declaration, already
48 pulled in by unistd.h on Posix hosts and stdlib.h on MS-Windows.
49
502011-11-24 Glenn Morris <rgm@gnu.org>
51
52 * make-docfile.c (scan_lisp_file): Treat defcustom like defvar.
53
542011-11-14 Dan Nicolaescu <dann@ics.uci.edu>
55
56 * Makefile.in (all): Make sure "all" is the first target.
57
582011-10-27 Juanma Barranquero <lekktu@gmail.com>
59
60 * emacsclient.c (w32_getenv): Silence compiler warnings.
61
622011-09-07 Glenn Morris <rgm@gnu.org>
63
64 * etags.c (Fortran_functions): Handle "elemental" functions.
65
662011-09-07 Dieter Schuster <didischuster@arcor.de> (tiny change)
67
68 * etags.c (Fortran_functions): Handle "pure" functions. (Bug#9359)
69
702011-09-06 Paul Eggert <eggert@cs.ucla.edu>
71
72 * Makefile.in ($(DESTDIR)${archlibdir}): install-sh moved
73 to build-aux (Bug#9169).
74
752011-09-04 Paul Eggert <eggert@cs.ucla.edu>
76
77 Integer and memory overflow issues (Bug#9397).
78
79 * emacsclient.c (xmalloc): Accept size_t, not unsigned int, to
80 avoid potential buffer overflow issues on typical 64-bit hosts.
81 Return void *, not long *.
82 (get_current_dir_name): Report a failure, instead of looping
83 forever, if buffer size calculation overflows. Treat malloc
84 failures like realloc failures, as that has better behavior and is
85 more consistent. Do not check whether xmalloc returns NULL, as
86 that's not possible.
87 (message): Do not arbitrarily truncate message to 2048 bytes when
88 sending it to stderr; use vfprintf instead.
89 (get_server_config, set_local_socket)
90 (start_daemon_and_retry_set_socket): Do not alloca
91 arbitrarily-large buffers; that's not safe.
92 (get_server_config, set_local_socket): Do not use sprintf when its
93 result might not fit in 'int'.
94 (set_local_socket): Do not assume uid fits in 'int'.
95
96 * etags.c (xmalloc, xrealloc): Accept size_t, not unsigned int,
97 to avoid potential buffer overflow issues on typical 64-bit hosts.
98 (whatlen_max): New static var.
99 (main): Avoid buffer overflow if subsidiary command length is
100 greater than BUFSIZ or 2*BUFSIZ + 20. Do not use sprintf when its
101 result might not fit in 'int'.
102
103 * movemail.c (main): Do not use sprintf when its result might not fit
104 in 'int'. Instead, put the possibly-long file name into the
105 output of pfatal_with_name.
106
107 * update-game-score.c: Include <limits.h>
108 (get_user_id): Do not assume uid fits in 'int'. Simplify.
109
1102011-07-28 Paul Eggert <eggert@cs.ucla.edu>
111
112 Assume freestanding C89 headers, string.h, stdlib.h.
113 * ebrowse.c: Include stdlib.h unconditionally.
114 * etags.c, update-game-score.c:
115 Include string.h and stdlib.h unconditionally.
116 * makefile.w32-in (LOCAL_CFLAGS): Don't define STDC_HEADERS.
117 * movemail.c, pop.c: Include string.h unconditionally.
118 * update-game-score.c: No need to include stdarg.h; not used.
119
120 Assume support for memcmp, memcpy, memmove, memset.
121 * etags.c (absolute_filename): Assume memmove exists.
122
1232011-07-09 Andreas Schwab <schwab@linux-m68k.org>
124
125 * update-game-score.c (usage): Update usage line.
126
12011-07-02 Jason Rumney <jasonr@gnu.org> 1272011-07-02 Jason Rumney <jasonr@gnu.org>
2 128
3 * emacsclient.c (decode_options) [WINDOWSNT]: Avoid tty mode on 129 * emacsclient.c (decode_options) [WINDOWSNT]: Avoid tty mode on
@@ -1959,7 +2085,7 @@
1959 * etags.c [ETAGS_REGEXPS]: Now is unconditionally defined. 2085 * etags.c [ETAGS_REGEXPS]: Now is unconditionally defined.
1960 [LONG_OPTIONS]: Changed to NO_LONG_OPTIONS, which is undefined. 2086 [LONG_OPTIONS]: Changed to NO_LONG_OPTIONS, which is undefined.
1961 (Objc_suffixes): Suggest using --lang=c for full help. 2087 (Objc_suffixes): Suggest using --lang=c for full help.
1962 (C_entries): Initialise savetoken to 0 to shut up the compiler. 2088 (C_entries): Initialize savetoken to 0 to shut up the compiler.
1963 2089
19642006-07-20 Andreas Schwab <schwab@suse.de> 20902006-07-20 Andreas Schwab <schwab@suse.de>
1965 2091
@@ -2665,7 +2791,7 @@
2665 (add_regex, regex_tag_multiline, readline): Use it. 2791 (add_regex, regex_tag_multiline, readline): Use it.
2666 (main): Free some global structures. 2792 (main): Free some global structures.
2667 (fdesc): New member `written'. 2793 (fdesc): New member `written'.
2668 (readline, process_file): Initialise it. 2794 (readline, process_file): Initialize it.
2669 (put_entries): Set it. 2795 (put_entries): Set it.
2670 (main): Use it to create entries for files without tags. 2796 (main): Use it to create entries for files without tags.
2671 (total_size_of_entries): Do not count invalid tags. 2797 (total_size_of_entries): Do not count invalid tags.
@@ -2776,7 +2902,7 @@
2776 (find_entries): Rewind unconditionally. 2902 (find_entries): Rewind unconditionally.
2777 (find_entries): Do not call language functions directly, now calls 2903 (find_entries): Do not call language functions directly, now calls
2778 itself. 2904 itself.
2779 (find_entries): Do general initialisations here. 2905 (find_entries): Do general initializations here.
2780 (CNL_SAVE_DEFINEDEF, C_entries, LOOP_ON_INPUT_LINES, F_getit) 2906 (CNL_SAVE_DEFINEDEF, C_entries, LOOP_ON_INPUT_LINES, F_getit)
2781 (Ada_getit, Pascal_functions, Pascal_functions) 2907 (Ada_getit, Pascal_functions, Pascal_functions)
2782 (prolog_skip_comment): Do not do them here. 2908 (prolog_skip_comment): Do not do them here.
@@ -3012,7 +3138,7 @@
3012 (TeX_commands): Name tags. Correction of old disabled code. 3138 (TeX_commands): Name tags. Correction of old disabled code.
3013 3139
3014 * etags.c (curfiledir, curtagfname): New global variables. 3140 * etags.c (curfiledir, curtagfname): New global variables.
3015 (process_file): Initialise them. 3141 (process_file): Initialize them.
3016 (readline): Canonicalize the name found in #line directive. 3142 (readline): Canonicalize the name found in #line directive.
3017 3143
30182002-03-06 Jason Rumney <jasonr@gnu.org> 31442002-03-06 Jason Rumney <jasonr@gnu.org>
@@ -3040,7 +3166,7 @@
3040 (main): Call put_entries here even in CTAGS mode. 3166 (main): Call put_entries here even in CTAGS mode.
3041 (main, process_file): Check the return values of fclose and pclose. 3167 (main, process_file): Check the return values of fclose and pclose.
3042 (process_file): Do not call put_entries after parsing each file. 3168 (process_file): Do not call put_entries after parsing each file.
3043 (process_file): Canonicalise file names even for ctags. 3169 (process_file): Canonicalize file names even for ctags.
3044 (process_file): Set curfile here... 3170 (process_file): Set curfile here...
3045 (find_entries): ... not here any more. 3171 (find_entries): ... not here any more.
3046 (add_node): In etags mode, build a linked list of entries (on 3172 (add_node): In etags mode, build a linked list of entries (on
@@ -3102,7 +3228,7 @@
3102 (L_getit): Simplify by using get_tag. 3228 (L_getit): Simplify by using get_tag.
3103 (Perl_functions, Postscript_functions, erlang_attribute): Use the 3229 (Perl_functions, Postscript_functions, erlang_attribute): Use the
3104 modified LOOKING_AT. 3230 modified LOOKING_AT.
3105 (notinname): Remove '[' and added ')' to the recognised chars. 3231 (notinname): Remove '[' and added ')' to the recognized chars.
3106 (LOOKING_AT, get_tag, PHP_functions): Use notinname. 3232 (LOOKING_AT, get_tag, PHP_functions): Use notinname.
3107 (Ada_getit, Ada_funcs, Python_functions, Scheme_functions): 3233 (Ada_getit, Ada_funcs, Python_functions, Scheme_functions):
3108 Clarified, using strneq or notinname. 3234 Clarified, using strneq or notinname.
@@ -3169,7 +3295,7 @@
3169 (Scheme_functions, Texinfo_nodes): Use it. 3295 (Scheme_functions, Texinfo_nodes): Use it.
3170 (Perl_functions): Use strneq. 3296 (Perl_functions): Use strneq.
3171 (prolog_pred): Rename to prolog_pr. 3297 (prolog_pred): Rename to prolog_pr.
3172 (prolog_pr): Recognise Prolog rules in addition to predicates. 3298 (prolog_pr): Recognize Prolog rules in addition to predicates.
3173 [ETAGS_REGEXPS] [!HAVE_CONFIG_H] [__CYGWIN__]: Prevent 3299 [ETAGS_REGEXPS] [!HAVE_CONFIG_H] [__CYGWIN__]: Prevent
3174 unmodified compile, as Cygwin's regex.h is incompatible with us. 3300 unmodified compile, as Cygwin's regex.h is incompatible with us.
3175 [!HAVE_CONFIG_H] [!__STDC__]: #define const as the empty string. 3301 [!HAVE_CONFIG_H] [!__STDC__]: #define const as the empty string.
@@ -3443,7 +3569,7 @@
3443 * etags.c (enum sym_type): New label st_C_template. 3569 * etags.c (enum sym_type): New label st_C_template.
3444 (gperf input): Use it for switching to C++ from C. 3570 (gperf input): Use it for switching to C++ from C.
3445 (consider_token): Do it. 3571 (consider_token): Do it.
3446 (C_entries): Initialise typdefcblev to quiet compilers. 3572 (C_entries): Initialize typdefcblev to quiet compilers.
3447 [!HAVE_CONFIG_H] [!__STDC__]: #define static as nothing. 3573 [!HAVE_CONFIG_H] [!__STDC__]: #define static as nothing.
3448 3574
34492001-02-22 Andrew Innes <andrewi@gnu.org> 35752001-02-22 Andrew Innes <andrewi@gnu.org>
@@ -3569,7 +3695,7 @@
3569 (lang_names): Add a NULL member for every entry, added an entry 3695 (lang_names): Add a NULL member for every entry, added an entry
3570 for makefiles. 3696 for makefiles.
3571 (Makefile_targets): New function. 3697 (Makefile_targets): New function.
3572 (Texinfo_nodes): Rename from Texinfo_fuctions and made 3698 (Texinfo_nodes): Rename from Texinfo_functions and made
3573 it conformant to the style of the rest of the code. 3699 it conformant to the style of the rest of the code.
3574 3700
35752001-01-13 Gerd Moellmann <gerd@gnu.org> 37012001-01-13 Gerd Moellmann <gerd@gnu.org>
@@ -3894,7 +4020,7 @@
3894 4020
3895 * etags.c (C_entries, consider_token): C++ `operator' now is 4021 * etags.c (C_entries, consider_token): C++ `operator' now is
3896 tagged in most cases. 4022 tagged in most cases.
3897 As before, :: is not recognised if surrounded by spaces. 4023 As before, :: is not recognized if surrounded by spaces.
3898 4024
3899 * etags.c (relative_filename): Account for DOS file names such 4025 * etags.c (relative_filename): Account for DOS file names such
3900 that is impossible to make one relative to another. 4026 that is impossible to make one relative to another.
@@ -4194,7 +4320,7 @@
4194 4320
41951998-12-08 Geoff Voelker <voelker@cs.washington.edu> 43211998-12-08 Geoff Voelker <voelker@cs.washington.edu>
4196 4322
4197 * makefile.nt: Do string comparision of _NMAKE_VER. 4323 * makefile.nt: Do string comparison of _NMAKE_VER.
4198 4324
41991998-11-03 Theodore Jump <tjump@cais.com> 43251998-11-03 Theodore Jump <tjump@cais.com>
4200 4326
@@ -4503,7 +4629,7 @@
4503 * etags.c (C_entries): Use "." instead of "::" for Java. 4629 * etags.c (C_entries): Use "." instead of "::" for Java.
4504 (consider_token): is_func renamed to is_func_or_var. 4630 (consider_token): is_func renamed to is_func_or_var.
4505 (C_entries): is_func renamed to funorvar. 4631 (C_entries): is_func renamed to funorvar.
4506 (C_entries): Initialise tok.named. 4632 (C_entries): Initialize tok.named.
4507 (sym_type, C_stab_entry, consider_token): st_C_ignore is used to 4633 (sym_type, C_stab_entry, consider_token): st_C_ignore is used to
4508 get rid of "import", "package" and "friend". 4634 get rid of "import", "package" and "friend".
4509 (fvdef): Rename from funcdef. Also some constants renamed. 4635 (fvdef): Rename from funcdef. Also some constants renamed.
@@ -4557,13 +4683,13 @@
4557 (lang_names): Add Java. 4683 (lang_names): Add Java.
4558 (sym_type): Add st_C_javastruct for Java. 4684 (sym_type): Add st_C_javastruct for Java.
4559 (C_stab_entry): Add `extends' and `implements' keywords. 4685 (C_stab_entry): Add `extends' and `implements' keywords.
4560 (consider_token, C_entries): Recognise Java structures. 4686 (consider_token, C_entries): Recognize Java structures.
4561 4687
45621997-05-12 Francesco Potortì <F.Potorti@cnuce.cnr.it> 46881997-05-12 Francesco Potortì <F.Potorti@cnuce.cnr.it>
4563 4689
4564 * etags.c (Cplusplus_suffixes): .pdb is Postscript with C syntax. 4690 * etags.c (Cplusplus_suffixes): .pdb is PostScript with C syntax.
4565 (Postscript_suffixes): .ps is Postscript. 4691 (Postscript_suffixes): .ps is PostScript.
4566 (lang_names): Add Postscript. 4692 (lang_names): Add postscript.
4567 (Postscript_functions): New function. 4693 (Postscript_functions): New function.
4568 (TEX_decode_env): Close minor memory leak. 4694 (TEX_decode_env): Close minor memory leak.
4569 (just_read_file): Correct the char number of the tag. 4695 (just_read_file): Correct the char number of the tag.
@@ -4605,7 +4731,7 @@
4605 4731
4606 * etags.c (xnew): Add support for debugging with chkmalloc. 4732 * etags.c (xnew): Add support for debugging with chkmalloc.
4607 (error): Use this instead of printf whenever possible. 4733 (error): Use this instead of printf whenever possible.
4608 (main): Only call xnew after having initialised progname. 4734 (main): Only call xnew after having initialized progname.
4609 (substitute): Bad memory corruption error corrected. 4735 (substitute): Bad memory corruption error corrected.
4610 4736
46111997-04-08 Francesco Potortì <F.Potorti@cnuce.cnr.it> 47371997-04-08 Francesco Potortì <F.Potorti@cnuce.cnr.it>
@@ -5061,7 +5187,7 @@
5061 5187
50621996-03-15 Anders Lindgren <andersl@csd.uu.se> 51881996-03-15 Anders Lindgren <andersl@csd.uu.se>
5063 5189
5064 * etags.c: Prolog language totaly rewritten. 5190 * etags.c: Prolog language totally rewritten.
5065 (Prolog_functions): Rewritten from scratch. 5191 (Prolog_functions): Rewritten from scratch.
5066 (skip_comment, prolog_getit): Removed. 5192 (skip_comment, prolog_getit): Removed.
5067 (prolog_skip_comment): New function, like old skip_comment. 5193 (prolog_skip_comment): New function, like old skip_comment.
@@ -5523,8 +5649,8 @@
5523 5649
55241995-02-22 Francesco Potortì (pot@cnuce.cnr.it) 56501995-02-22 Francesco Potortì (pot@cnuce.cnr.it)
5525 5651
5526 * etags.c (C_entries): token_saved removed. Initialise tok.valid and 5652 * etags.c (C_entries): token_saved removed. Initialize tok.valid and
5527 savetok.valid. Mark token as valid when it is initialised. 5653 savetok.valid. Mark token as valid when it is initialized.
5528 (make_tag): Make token only if token is valid and reset validity. 5654 (make_tag): Make token only if token is valid and reset validity.
5529 (CNL_SAVE_DEFINEDEF): Test for savetok.valid instead of token_saved. 5655 (CNL_SAVE_DEFINEDEF): Test for savetok.valid instead of token_saved.
5530 (TOKEN): Add a new member: valid. 5656 (TOKEN): Add a new member: valid.
@@ -5536,15 +5662,15 @@
5536 5662
55371995-02-14 Francesco Potortì (pot@cnuce.cnr.it) 56631995-02-14 Francesco Potortì (pot@cnuce.cnr.it)
5538 5664
5539 * etags.c (C_entries): Initialise the new members of TOKEN. 5665 * etags.c (C_entries): Initialize the new members of TOKEN.
5540 (C_entries): Do not allocate a new space for each token found by 5666 (C_entries): Do not allocate a new space for each token found by
5541 consider_token. Let make_tag do that instead. 5667 consider_token. Let make_tag do that instead.
5542 (make_tag): Since now TOKEN has memory of where it is taken from, 5668 (make_tag): Since now TOKEN has memory of where it is taken from,
5543 this new macro substitutes both make_tag_from_new_lb and 5669 this new macro substitutes both make_tag_from_new_lb and
5544 make_tag_from_oth_lb. All callers changed. 5670 make_tag_from_oth_lb. All callers changed.
5545 (TOKEN): Add linepos and buffer members. 5671 (TOKEN): Add linepos and buffer members.
5546 (main): Initialise token_str. 5672 (main): Initialize token_str.
5547 (lang_extensions): Recognise .c++ and .h++ as C++ file suffixes. 5673 (lang_extensions): Recognize .c++ and .h++ as C++ file suffixes.
5548 (token_str): New global variable used by C_entries. 5674 (token_str): New global variable used by C_entries.
5549 5675
55501995-02-07 Richard Stallman <rms@pogo.gnu.ai.mit.edu> 56761995-02-07 Richard Stallman <rms@pogo.gnu.ai.mit.edu>
@@ -5553,7 +5679,7 @@
5553 5679
55541995-02-01 Francesco Potortì (pot@cnuce.cnr.it) 56801995-02-01 Francesco Potortì (pot@cnuce.cnr.it)
5555 5681
5556 * etags.c (pfnote): Initialise been_warned in the node. 5682 * etags.c (pfnote): Initialize been_warned in the node.
5557 (C_entries): Remove a speed hack for the sake of clarity. 5683 (C_entries): Remove a speed hack for the sake of clarity.
5558 5684
55591995-01-18 Francesco Potortì (pot@cnuce.cnr.it) 56851995-01-18 Francesco Potortì (pot@cnuce.cnr.it)
@@ -5838,8 +5964,8 @@
5838 5964
58391994-09-29 Francesco Potortì (pot@cnuce.cnr.it) 59651994-09-29 Francesco Potortì (pot@cnuce.cnr.it)
5840 5966
5841 * etags.c (C_entries): Recognise typedef of ANSI style functions. 5967 * etags.c (C_entries): Recognize typedef of ANSI style functions.
5842 (C_entries): Recognise #define inside a struct. 5968 (C_entries): Recognize #define inside a struct.
5843 (C_entries): ANSI tells that preprocessor commands do not have to 5969 (C_entries): ANSI tells that preprocessor commands do not have to
5844 start on the first column. 5970 start on the first column.
5845 (print_help): Documentation corrected for -d and -D. 5971 (print_help): Documentation corrected for -d and -D.
@@ -5953,7 +6079,7 @@
5953 6079
59541994-07-08 Dave Love (d.love@dl.ac.uk) 60801994-07-08 Dave Love (d.love@dl.ac.uk)
5955 6081
5956 * etags.c (takeprec): Recognise `character*(*) function'. 6082 * etags.c (takeprec): Recognize `character*(*) function'.
5957 6083
59581994-07-08 Francesco Potortì (pot@cnuce.cnr.it) 60841994-07-08 Francesco Potortì (pot@cnuce.cnr.it)
5959 6085
@@ -6146,7 +6272,7 @@
6146 TeX_functions, Prolog_functions. 6272 TeX_functions, Prolog_functions.
6147 (inf): No more a global variable. 6273 (inf): No more a global variable.
6148 (C_entries): Take 2nd parameter `inf' instead of using the global one. 6274 (C_entries): Take 2nd parameter `inf' instead of using the global one.
6149 (find_entries): Add the cp1 var for optimisation. 6275 (find_entries): Add the cp1 var for optimization.
6150 (find_entries): Add more suffixes for assembler files. 6276 (find_entries): Add more suffixes for assembler files.
6151 (Asm_funcs): Now finds labels even without an ending colon. 6277 (Asm_funcs): Now finds labels even without an ending colon.
6152 6278
@@ -6174,7 +6300,7 @@
6174 functions added to compute filenames in tags files. 6300 functions added to compute filenames in tags files.
6175 (process_file): Filenames in tags file are relative to the 6301 (process_file): Filenames in tags file are relative to the
6176 directory where the tags file is (useful with the -o option). 6302 directory where the tags file is (useful with the -o option).
6177 (main): Initialise the outfiledir var. 6303 (main): Initialize the outfiledir var.
6178 (TYPEDST): Add the `tignore' value. 6304 (TYPEDST): Add the `tignore' value.
6179 (C_entries): Corrected various small bugs. 6305 (C_entries): Corrected various small bugs.
6180 6306
@@ -6480,7 +6606,7 @@
6480 6606
64811993-09-20 Francesco Potortì (pot@fly) 66071993-09-20 Francesco Potortì (pot@fly)
6482 6608
6483 * etags.c (C_entries): is_func is initialised here instead of in 6609 * etags.c (C_entries): is_func is initialized here instead of in
6484 consider_token for the sake of the yacc rules section. 6610 consider_token for the sake of the yacc rules section.
6485 (C_entries): Now class, struct, enum, union and typedef produce 6611 (C_entries): Now class, struct, enum, union and typedef produce
6486 named tags. 6612 named tags.
@@ -6534,7 +6660,7 @@
6534 6660
65351993-08-04 Francesco Potortì (pot@spiff.gnu.ai.mit.edu) 66611993-08-04 Francesco Potortì (pot@spiff.gnu.ai.mit.edu)
6536 6662
6537 * etags.c (L_isdef, L_isquote, L_getit): Small optimisations. 6663 * etags.c (L_isdef, L_isquote, L_getit): Small optimizations.
6538 (L_funcs): The (foo::defmumble stuff now should work. 6664 (L_funcs): The (foo::defmumble stuff now should work.
6539 (consider_token): Function returned random value--corrected. 6665 (consider_token): Function returned random value--corrected.
6540 (C_entries): Corrected == versus = typo. 6666 (C_entries): Corrected == versus = typo.
@@ -6556,7 +6682,7 @@
6556 (C_entries, consider_token): Make use of fignore. 6682 (C_entries, consider_token): Make use of fignore.
6557 (consider_token): Reset funcdef when next_token_is_func: when in 6683 (consider_token): Reset funcdef when next_token_is_func: when in
6558 ctags mode makes DEFVAR and others work better. 6684 ctags mode makes DEFVAR and others work better.
6559 (L_isquote): Function that recognises the "(quote" string. 6685 (L_isquote): Function that recognizes the "(quote" string.
6560 (L_getit): Ignore quoting via "'" or "(quote". Useful for defalias. 6686 (L_getit): Ignore quoting via "'" or "(quote". Useful for defalias.
6561 6687
65621993-07-29 Paul Eggert (eggert@twinsun.com) 66881993-07-29 Paul Eggert (eggert@twinsun.com)
@@ -6903,7 +7029,7 @@
6903 (TOKEN): Member linestart removed. 7029 (TOKEN): Member linestart removed.
6904 (linepos, prev_linepos, lb1): Deleted. 7030 (linepos, prev_linepos, lb1): Deleted.
6905 (main): Call initbuffer on lbs array instead of lb1. 7031 (main): Call initbuffer on lbs array instead of lb1.
6906 (init): Remove the initialisation of the logical _gd array. 7032 (init): Remove the initialization of the logical _gd array.
6907 (find_entries): A .sa suffix means assembler file. 7033 (find_entries): A .sa suffix means assembler file.
6908 (C_create_stab): "auto", "void", "extern", "static" are st_C_typespec. 7034 (C_create_stab): "auto", "void", "extern", "static" are st_C_typespec.
6909 All C state machines rewritten. 7035 All C state machines rewritten.
@@ -7828,7 +7954,7 @@
7828;; coding: utf-8 7954;; coding: utf-8
7829;; End: 7955;; End:
7830 7956
7831 Copyright (C) 1988-1999, 2001-2011 Free Software Foundation, Inc. 7957 Copyright (C) 1988-1999, 2001-2012 Free Software Foundation, Inc.
7832 7958
7833 This file is part of GNU Emacs. 7959 This file is part of GNU Emacs.
7834 7960
diff --git a/lib-src/Makefile.in b/lib-src/Makefile.in
index f619febbb2b..cc1757e4e3b 100644
--- a/lib-src/Makefile.in
+++ b/lib-src/Makefile.in
@@ -1,5 +1,5 @@
1# Makefile for lib-src subdirectory in GNU Emacs. 1# Makefile for lib-src subdirectory in GNU Emacs.
2# Copyright (C) 1985, 1987-1988, 1993-1994, 2001-2011 2# Copyright (C) 1985, 1987-1988, 1993-1994, 2001-2012
3# Free Software Foundation, Inc. 3# Free Software Foundation, Inc.
4 4
5# This file is part of GNU Emacs. 5# This file is part of GNU Emacs.
@@ -175,11 +175,11 @@ ALL_CFLAGS = ${BASE_CFLAGS} ${PROFILING_CFLAGS} ${LDFLAGS} ${CPPFLAGS} ${CFLAGS}
175LINK_CFLAGS = ${BASE_CFLAGS} ${LDFLAGS} ${CFLAGS} 175LINK_CFLAGS = ${BASE_CFLAGS} ${LDFLAGS} ${CFLAGS}
176CPP_CFLAGS = ${BASE_CFLAGS} ${PROFILING_CFLAGS} ${CPPFLAGS} ${CFLAGS} 176CPP_CFLAGS = ${BASE_CFLAGS} ${PROFILING_CFLAGS} ${CPPFLAGS} ${CFLAGS}
177 177
178all: ${EXE_FILES} ${SCRIPTS} ${INSTALLABLE_SCRIPTS} ${STAMP_INST_SCRIPTS} ${STAMP_SCRIPTS}
179
178LOADLIBES = ../lib/libgnu.a $(LIBS_SYSTEM) 180LOADLIBES = ../lib/libgnu.a $(LIBS_SYSTEM)
179$(EXE_FILES): ../lib/libgnu.a 181$(EXE_FILES): ../lib/libgnu.a
180 182
181all: ${EXE_FILES} ${SCRIPTS} ${INSTALLABLE_SCRIPTS} ${STAMP_INST_SCRIPTS} ${STAMP_SCRIPTS}
182
183## These targets copy the scripts into the build directory so that 183## These targets copy the scripts into the build directory so that
184## they can be run from there in an uninstalled Emacs. 184## they can be run from there in an uninstalled Emacs.
185## Nothing to do if pwd = srcdir. 185## Nothing to do if pwd = srcdir.
@@ -229,13 +229,13 @@ maybe-blessmail: $(BLESSMAIL_TARGET)
229$(DESTDIR)${archlibdir}: all 229$(DESTDIR)${archlibdir}: all
230 @echo 230 @echo
231 @echo "Installing utilities run internally by Emacs." 231 @echo "Installing utilities run internally by Emacs."
232 umask 022; $(top_srcdir)/install-sh -d $(DESTDIR)${archlibdir} 232 umask 022; $(top_srcdir)/build-aux/install-sh -d $(DESTDIR)${archlibdir}
233 if [ `(cd $(DESTDIR)${archlibdir} && /bin/pwd)` != `/bin/pwd` ]; then \ 233 if [ `(cd $(DESTDIR)${archlibdir} && /bin/pwd)` != `/bin/pwd` ]; then \
234 for file in ${UTILITIES}; do \ 234 for file in ${UTILITIES}; do \
235 $(INSTALL_PROGRAM) $(INSTALL_STRIP) $$file $(DESTDIR)${archlibdir}/$$file ; \ 235 $(INSTALL_PROGRAM) $(INSTALL_STRIP) $$file $(DESTDIR)${archlibdir}/$$file ; \
236 done ; \ 236 done ; \
237 fi 237 fi
238 umask 022; $(top_srcdir)/install-sh -d $(DESTDIR)${gamedir}; \ 238 umask 022; $(top_srcdir)/build-aux/install-sh -d $(DESTDIR)${gamedir}; \
239 touch $(DESTDIR)${gamedir}/snake-scores; \ 239 touch $(DESTDIR)${gamedir}/snake-scores; \
240 touch $(DESTDIR)${gamedir}/tetris-scores 240 touch $(DESTDIR)${gamedir}/tetris-scores
241 -if chown ${gameuser} $(DESTDIR)${archlibdir}/update-game-score && chmod u+s $(DESTDIR)${archlibdir}/update-game-score; then \ 241 -if chown ${gameuser} $(DESTDIR)${archlibdir}/update-game-score && chmod u+s $(DESTDIR)${archlibdir}/update-game-score; then \
diff --git a/lib-src/ebrowse.c b/lib-src/ebrowse.c
index 7871a804997..a1fe10b863a 100644
--- a/lib-src/ebrowse.c
+++ b/lib-src/ebrowse.c
@@ -1,6 +1,6 @@
1/* ebrowse.c --- parsing files for the ebrowse C++ browser 1/* ebrowse.c --- parsing files for the ebrowse C++ browser
2 2
3Copyright (C) 1992-2011 Free Software Foundation, Inc. 3Copyright (C) 1992-2012 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
@@ -20,11 +20,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
20 20
21#include <config.h> 21#include <config.h>
22#include <stdio.h> 22#include <stdio.h>
23
24#ifdef HAVE_STDLIB_H
25#include <stdlib.h> 23#include <stdlib.h>
26#endif
27
28#include <string.h> 24#include <string.h>
29#include <ctype.h> 25#include <ctype.h>
30#include <assert.h> 26#include <assert.h>
@@ -49,16 +45,16 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
49 45
50/* The character used as a separator in path lists (like $PATH). */ 46/* The character used as a separator in path lists (like $PATH). */
51 47
52#if defined(__MSDOS__) 48#if defined (__MSDOS__)
53#define PATH_LIST_SEPARATOR ';' 49#define PATH_LIST_SEPARATOR ';'
54#define FILENAME_EQ(X,Y) (strcasecmp(X,Y) == 0) 50#define FILENAME_EQ(X,Y) (strcasecmp (X,Y) == 0)
55#else 51#else
56#if defined(WINDOWSNT) 52#if defined (WINDOWSNT)
57#define PATH_LIST_SEPARATOR ';' 53#define PATH_LIST_SEPARATOR ';'
58#define FILENAME_EQ(X,Y) (stricmp(X,Y) == 0) 54#define FILENAME_EQ(X,Y) (stricmp (X,Y) == 0)
59#else 55#else
60#define PATH_LIST_SEPARATOR ':' 56#define PATH_LIST_SEPARATOR ':'
61#define FILENAME_EQ(X,Y) (streq(X,Y)) 57#define FILENAME_EQ(X,Y) (streq (X,Y))
62#endif 58#endif
63#endif 59#endif
64/* The default output file name. */ 60/* The default output file name. */
@@ -985,7 +981,7 @@ make_namespace (char *name, struct sym *context)
985} 981}
986 982
987 983
988/* Find the symbol for namespace NAME. If not found, retrun NULL */ 984/* Find the symbol for namespace NAME. If not found, return NULL */
989 985
990static struct sym * 986static struct sym *
991check_namespace (char *name, struct sym *context) 987check_namespace (char *name, struct sym *context)
@@ -2515,7 +2511,7 @@ member (struct sym *cls, int vis)
2515 2511
2516 /* A function or class may follow. */ 2512 /* A function or class may follow. */
2517 case TEMPLATE: 2513 case TEMPLATE:
2518 MATCH(); 2514 MATCH ();
2519 SET_FLAG (flags, F_TEMPLATE); 2515 SET_FLAG (flags, F_TEMPLATE);
2520 /* Skip over template argument list */ 2516 /* Skip over template argument list */
2521 SKIP_MATCHING_IF ('<'); 2517 SKIP_MATCHING_IF ('<');
@@ -2934,7 +2930,7 @@ parse_qualified_ident_or_type (char **last_id)
2934 } 2930 }
2935 2931
2936 while (enter--) 2932 while (enter--)
2937 leave_namespace(); 2933 leave_namespace ();
2938 2934
2939 return cls; 2935 return cls;
2940} 2936}
@@ -3530,7 +3526,7 @@ static void
3530version (void) 3526version (void)
3531{ 3527{
3532 /* Makes it easier to update automatically. */ 3528 /* Makes it easier to update automatically. */
3533 char emacs_copyright[] = "Copyright (C) 2011 Free Software Foundation, Inc."; 3529 char emacs_copyright[] = "Copyright (C) 2012 Free Software Foundation, Inc.";
3534 3530
3535 printf ("ebrowse %s\n", VERSION); 3531 printf ("ebrowse %s\n", VERSION);
3536 puts (emacs_copyright); 3532 puts (emacs_copyright);
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c
index 2af139aee6d..049886ed2ba 100644
--- a/lib-src/emacsclient.c
+++ b/lib-src/emacsclient.c
@@ -1,5 +1,5 @@
1/* Client process that communicates with GNU Emacs acting as server. 1/* Client process that communicates with GNU Emacs acting as server.
2 Copyright (C) 1986-1987, 1994, 1999-2011 Free Software Foundation, Inc. 2 Copyright (C) 1986-1987, 1994, 1999-2012 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
@@ -152,7 +152,7 @@ int tty = 0;
152const char *alternate_editor = NULL; 152const char *alternate_editor = NULL;
153 153
154/* If non-NULL, the filename of the UNIX socket. */ 154/* If non-NULL, the filename of the UNIX socket. */
155char *socket_name = NULL; 155const char *socket_name = NULL;
156 156
157/* If non-NULL, the filename of the authentication file. */ 157/* If non-NULL, the filename of the authentication file. */
158const char *server_file = NULL; 158const char *server_file = NULL;
@@ -194,10 +194,10 @@ struct option longopts[] =
194 194
195/* Like malloc but get fatal error if memory is exhausted. */ 195/* Like malloc but get fatal error if memory is exhausted. */
196 196
197static long * 197static void *
198xmalloc (unsigned int size) 198xmalloc (size_t size)
199{ 199{
200 long *result = (long *) malloc (size); 200 void *result = malloc (size);
201 if (result == NULL) 201 if (result == NULL)
202 { 202 {
203 perror ("malloc"); 203 perror ("malloc");
@@ -250,32 +250,33 @@ get_current_dir_name (void)
250 ) 250 )
251 { 251 {
252 buf = (char *) xmalloc (strlen (pwd) + 1); 252 buf = (char *) xmalloc (strlen (pwd) + 1);
253 if (!buf)
254 return NULL;
255 strcpy (buf, pwd); 253 strcpy (buf, pwd);
256 } 254 }
257#ifdef HAVE_GETCWD 255#ifdef HAVE_GETCWD
258 else 256 else
259 { 257 {
260 size_t buf_size = 1024; 258 size_t buf_size = 1024;
261 buf = (char *) xmalloc (buf_size);
262 if (!buf)
263 return NULL;
264 for (;;) 259 for (;;)
265 { 260 {
261 int tmp_errno;
262 buf = malloc (buf_size);
263 if (! buf)
264 break;
266 if (getcwd (buf, buf_size) == buf) 265 if (getcwd (buf, buf_size) == buf)
267 break; 266 break;
268 if (errno != ERANGE) 267 tmp_errno = errno;
268 free (buf);
269 if (tmp_errno != ERANGE)
269 { 270 {
270 int tmp_errno = errno;
271 free (buf);
272 errno = tmp_errno; 271 errno = tmp_errno;
273 return NULL; 272 return NULL;
274 } 273 }
275 buf_size *= 2; 274 buf_size *= 2;
276 buf = (char *) realloc (buf, buf_size); 275 if (! buf_size)
277 if (!buf) 276 {
278 return NULL; 277 errno = ENOMEM;
278 return NULL;
279 }
279 } 280 }
280 } 281 }
281#else 282#else
@@ -283,8 +284,6 @@ get_current_dir_name (void)
283 { 284 {
284 /* We need MAXPATHLEN here. */ 285 /* We need MAXPATHLEN here. */
285 buf = (char *) xmalloc (MAXPATHLEN + 1); 286 buf = (char *) xmalloc (MAXPATHLEN + 1);
286 if (!buf)
287 return NULL;
288 if (getwd (buf) == NULL) 287 if (getwd (buf) == NULL)
289 { 288 {
290 int tmp_errno = errno; 289 int tmp_errno = errno;
@@ -360,7 +359,7 @@ w32_getenv (char *envvar)
360 char *value; 359 char *value;
361 DWORD dwType; 360 DWORD dwType;
362 361
363 if (value = getenv (envvar)) 362 if ((value = getenv (envvar)))
364 /* Found in the environment. strdup it, because values returned 363 /* Found in the environment. strdup it, because values returned
365 by getenv cannot be free'd. */ 364 by getenv cannot be free'd. */
366 return xstrdup (value); 365 return xstrdup (value);
@@ -383,7 +382,7 @@ w32_getenv (char *envvar)
383 { 382 {
384 DWORD size; 383 DWORD size;
385 384
386 if (size = ExpandEnvironmentStrings (value, NULL, 0)) 385 if ((size = ExpandEnvironmentStrings (value, NULL, 0)))
387 { 386 {
388 char *buffer = (char *) xmalloc (size); 387 char *buffer = (char *) xmalloc (size);
389 if (ExpandEnvironmentStrings (value, buffer, size)) 388 if (ExpandEnvironmentStrings (value, buffer, size))
@@ -494,16 +493,17 @@ static void message (int, const char *, ...) ATTRIBUTE_FORMAT_PRINTF (2, 3);
494static void 493static void
495message (int is_error, const char *format, ...) 494message (int is_error, const char *format, ...)
496{ 495{
497 char msg[2048];
498 va_list args; 496 va_list args;
499 497
500 va_start (args, format); 498 va_start (args, format);
501 vsprintf (msg, format, args);
502 va_end (args);
503 499
504#ifdef WINDOWSNT 500#ifdef WINDOWSNT
505 if (w32_window_app ()) 501 if (w32_window_app ())
506 { 502 {
503 char msg[2048];
504 vsnprintf (msg, sizeof msg, format, args);
505 msg[sizeof msg - 1] = '\0';
506
507 if (is_error) 507 if (is_error)
508 MessageBox (NULL, msg, "Emacsclient ERROR", MB_ICONERROR); 508 MessageBox (NULL, msg, "Emacsclient ERROR", MB_ICONERROR);
509 else 509 else
@@ -514,9 +514,11 @@ message (int is_error, const char *format, ...)
514 { 514 {
515 FILE *f = is_error ? stderr : stdout; 515 FILE *f = is_error ? stderr : stdout;
516 516
517 fputs (msg, f); 517 vfprintf (f, format, args);
518 fflush (f); 518 fflush (f);
519 } 519 }
520
521 va_end (args);
520} 522}
521 523
522/* Decode the options from argv and argc. 524/* Decode the options from argv and argc.
@@ -636,6 +638,22 @@ decode_options (int argc, char **argv)
636 if (display && strlen (display) == 0) 638 if (display && strlen (display) == 0)
637 display = NULL; 639 display = NULL;
638 640
641#ifdef WINDOWSNT
642 /* Emacs on Windows does not support GUI and console frames in the same
643 instance. So, it makes sense to treat the -t and -c options as
644 equivalent, and open a new frame regardless of whether the running
645 instance is GUI or console. Ideally, we would only set tty = 1 when
646 the instance is running in a console, but alas we don't know that.
647 The simplest workaround is to always ask for a tty frame, and let
648 server.el check whether it makes sense. */
649 if (tty || !current_frame)
650 {
651 display = (const char *) ttyname;
652 current_frame = 0;
653 tty = 1;
654 }
655#endif
656
639 /* If no display is available, new frames are tty frames. */ 657 /* If no display is available, new frames are tty frames. */
640 if (!current_frame && !display) 658 if (!current_frame && !display)
641 tty = 1; 659 tty = 1;
@@ -652,14 +670,6 @@ decode_options (int argc, char **argv)
652an empty string"); 670an empty string");
653 exit (EXIT_FAILURE); 671 exit (EXIT_FAILURE);
654 } 672 }
655
656 /* TTY frames not supported on Windows. Continue using GUI rather than
657 forcing the user to change their command-line. This is required since
658 tty is set above if certain options are given and $DISPLAY is not set,
659 which is not obvious to users. */
660 if (tty)
661 tty = 0;
662
663#endif /* WINDOWSNT */ 673#endif /* WINDOWSNT */
664} 674}
665 675
@@ -945,32 +955,39 @@ initialize_sockets (void)
945 * the Emacs server: host, port, and authentication string. 955 * the Emacs server: host, port, and authentication string.
946 */ 956 */
947static int 957static int
948get_server_config (struct sockaddr_in *server, char *authentication) 958get_server_config (const char *config_file, struct sockaddr_in *server,
959 char *authentication)
949{ 960{
950 char dotted[32]; 961 char dotted[32];
951 char *port; 962 char *port;
952 FILE *config = NULL; 963 FILE *config = NULL;
953 964
954 if (file_name_absolute_p (server_file)) 965 if (file_name_absolute_p (config_file))
955 config = fopen (server_file, "rb"); 966 config = fopen (config_file, "rb");
956 else 967 else
957 { 968 {
958 const char *home = egetenv ("HOME"); 969 const char *home = egetenv ("HOME");
959 970
960 if (home) 971 if (home)
961 { 972 {
962 char *path = alloca (strlen (home) + strlen (server_file) 973 char *path = xmalloc (strlen (home) + strlen (config_file)
963 + EXTRA_SPACE); 974 + EXTRA_SPACE);
964 sprintf (path, "%s/.emacs.d/server/%s", home, server_file); 975 strcpy (path, home);
976 strcat (path, "/.emacs.d/server/");
977 strcat (path, config_file);
965 config = fopen (path, "rb"); 978 config = fopen (path, "rb");
979 free (path);
966 } 980 }
967#ifdef WINDOWSNT 981#ifdef WINDOWSNT
968 if (!config && (home = egetenv ("APPDATA"))) 982 if (!config && (home = egetenv ("APPDATA")))
969 { 983 {
970 char *path = alloca (strlen (home) + strlen (server_file) 984 char *path = xmalloc (strlen (home) + strlen (config_file)
971 + EXTRA_SPACE); 985 + EXTRA_SPACE);
972 sprintf (path, "%s/.emacs.d/server/%s", home, server_file); 986 strcpy (path, home);
987 strcat (path, "/.emacs.d/server/");
988 strcat (path, config_file);
973 config = fopen (path, "rb"); 989 config = fopen (path, "rb");
990 free (path);
974 } 991 }
975#endif 992#endif
976 } 993 }
@@ -1003,14 +1020,14 @@ get_server_config (struct sockaddr_in *server, char *authentication)
1003} 1020}
1004 1021
1005static HSOCKET 1022static HSOCKET
1006set_tcp_socket (void) 1023set_tcp_socket (const char *local_server_file)
1007{ 1024{
1008 HSOCKET s; 1025 HSOCKET s;
1009 struct sockaddr_in server; 1026 struct sockaddr_in server;
1010 struct linger l_arg = {1, 1}; 1027 struct linger l_arg = {1, 1};
1011 char auth_string[AUTH_KEY_LENGTH + 1]; 1028 char auth_string[AUTH_KEY_LENGTH + 1];
1012 1029
1013 if (! get_server_config (&server, auth_string)) 1030 if (! get_server_config (local_server_file, &server, auth_string))
1014 return INVALID_SOCKET; 1031 return INVALID_SOCKET;
1015 1032
1016 if (server.sin_addr.s_addr != inet_addr ("127.0.0.1") && !quiet) 1033 if (server.sin_addr.s_addr != inet_addr ("127.0.0.1") && !quiet)
@@ -1185,7 +1202,7 @@ handle_sigtstp (int signalnum)
1185 send_to_emacs (emacs_socket, "-suspend \n"); 1202 send_to_emacs (emacs_socket, "-suspend \n");
1186 1203
1187 /* Unblock this signal and call the default handler by temporarily 1204 /* Unblock this signal and call the default handler by temporarily
1188 changing the handler and resignalling. */ 1205 changing the handler and resignaling. */
1189 sigprocmask (SIG_BLOCK, NULL, &set); 1206 sigprocmask (SIG_BLOCK, NULL, &set);
1190 sigdelset (&set, signalnum); 1207 sigdelset (&set, signalnum);
1191 signal (signalnum, SIG_DFL); 1208 signal (signalnum, SIG_DFL);
@@ -1220,7 +1237,7 @@ init_signals (void)
1220 1237
1221 1238
1222static HSOCKET 1239static HSOCKET
1223set_local_socket (void) 1240set_local_socket (const char *local_socket_name)
1224{ 1241{
1225 HSOCKET s; 1242 HSOCKET s;
1226 struct sockaddr_un server; 1243 struct sockaddr_un server;
@@ -1238,23 +1255,20 @@ set_local_socket (void)
1238 server.sun_family = AF_UNIX; 1255 server.sun_family = AF_UNIX;
1239 1256
1240 { 1257 {
1241 int sock_status = 0; 1258 int sock_status;
1242 int default_sock = !socket_name; 1259 int use_tmpdir = 0;
1243 int saved_errno = 0; 1260 int saved_errno;
1244 const char *server_name = "server"; 1261 const char *server_name = local_socket_name;
1245 const char *tmpdir IF_LINT ( = NULL); 1262 const char *tmpdir IF_LINT ( = NULL);
1263 char *tmpdir_storage = NULL;
1264 char *socket_name_storage = NULL;
1246 1265
1247 if (socket_name && !strchr (socket_name, '/') 1266 if (!strchr (local_socket_name, '/') && !strchr (local_socket_name, '\\'))
1248 && !strchr (socket_name, '\\'))
1249 { 1267 {
1250 /* socket_name is a file name component. */ 1268 /* socket_name is a file name component. */
1251 server_name = socket_name; 1269 long uid = geteuid ();
1252 socket_name = NULL; 1270 ptrdiff_t tmpdirlen;
1253 default_sock = 1; /* Try both UIDs. */ 1271 use_tmpdir = 1;
1254 }
1255
1256 if (default_sock)
1257 {
1258 tmpdir = egetenv ("TMPDIR"); 1272 tmpdir = egetenv ("TMPDIR");
1259 if (!tmpdir) 1273 if (!tmpdir)
1260 { 1274 {
@@ -1265,32 +1279,35 @@ set_local_socket (void)
1265 size_t n = confstr (_CS_DARWIN_USER_TEMP_DIR, NULL, (size_t) 0); 1279 size_t n = confstr (_CS_DARWIN_USER_TEMP_DIR, NULL, (size_t) 0);
1266 if (n > 0) 1280 if (n > 0)
1267 { 1281 {
1268 tmpdir = alloca (n); 1282 tmpdir = tmpdir_storage = xmalloc (n);
1269 confstr (_CS_DARWIN_USER_TEMP_DIR, tmpdir, n); 1283 confstr (_CS_DARWIN_USER_TEMP_DIR, tmpdir, n);
1270 } 1284 }
1271 else 1285 else
1272#endif 1286#endif
1273 tmpdir = "/tmp"; 1287 tmpdir = "/tmp";
1274 } 1288 }
1275 socket_name = alloca (strlen (tmpdir) + strlen (server_name) 1289 tmpdirlen = strlen (tmpdir);
1276 + EXTRA_SPACE); 1290 socket_name_storage =
1277 sprintf (socket_name, "%s/emacs%d/%s", 1291 xmalloc (tmpdirlen + strlen (server_name) + EXTRA_SPACE);
1278 tmpdir, (int) geteuid (), server_name); 1292 strcpy (socket_name_storage, tmpdir);
1293 sprintf (socket_name_storage + tmpdirlen, "/emacs%ld/", uid);
1294 strcat (socket_name_storage + tmpdirlen, server_name);
1295 local_socket_name = socket_name_storage;
1279 } 1296 }
1280 1297
1281 if (strlen (socket_name) < sizeof (server.sun_path)) 1298 if (strlen (local_socket_name) < sizeof (server.sun_path))
1282 strcpy (server.sun_path, socket_name); 1299 strcpy (server.sun_path, local_socket_name);
1283 else 1300 else
1284 { 1301 {
1285 message (TRUE, "%s: socket-name %s too long\n", 1302 message (TRUE, "%s: socket-name %s too long\n",
1286 progname, socket_name); 1303 progname, local_socket_name);
1287 fail (); 1304 fail ();
1288 } 1305 }
1289 1306
1290 /* See if the socket exists, and if it's owned by us. */ 1307 /* See if the socket exists, and if it's owned by us. */
1291 sock_status = socket_status (server.sun_path); 1308 sock_status = socket_status (server.sun_path);
1292 saved_errno = errno; 1309 saved_errno = errno;
1293 if (sock_status && default_sock) 1310 if (sock_status && use_tmpdir)
1294 { 1311 {
1295 /* Failing that, see if LOGNAME or USER exist and differ from 1312 /* Failing that, see if LOGNAME or USER exist and differ from
1296 our euid. If so, look for a socket based on the UID 1313 our euid. If so, look for a socket based on the UID
@@ -1309,19 +1326,23 @@ set_local_socket (void)
1309 if (pw && (pw->pw_uid != geteuid ())) 1326 if (pw && (pw->pw_uid != geteuid ()))
1310 { 1327 {
1311 /* We're running under su, apparently. */ 1328 /* We're running under su, apparently. */
1312 socket_name = alloca (strlen (tmpdir) + strlen (server_name) 1329 long uid = pw->pw_uid;
1313 + EXTRA_SPACE); 1330 ptrdiff_t tmpdirlen = strlen (tmpdir);
1314 sprintf (socket_name, "%s/emacs%d/%s", 1331 char *user_socket_name
1315 tmpdir, (int) pw->pw_uid, server_name); 1332 = xmalloc (tmpdirlen + strlen (server_name) + EXTRA_SPACE);
1316 1333 strcpy (user_socket_name, tmpdir);
1317 if (strlen (socket_name) < sizeof (server.sun_path)) 1334 sprintf (user_socket_name + tmpdirlen, "/emacs%ld/", uid);
1318 strcpy (server.sun_path, socket_name); 1335 strcat (user_socket_name + tmpdirlen, server_name);
1336
1337 if (strlen (user_socket_name) < sizeof (server.sun_path))
1338 strcpy (server.sun_path, user_socket_name);
1319 else 1339 else
1320 { 1340 {
1321 message (TRUE, "%s: socket-name %s too long\n", 1341 message (TRUE, "%s: socket-name %s too long\n",
1322 progname, socket_name); 1342 progname, user_socket_name);
1323 exit (EXIT_FAILURE); 1343 exit (EXIT_FAILURE);
1324 } 1344 }
1345 free (user_socket_name);
1325 1346
1326 sock_status = socket_status (server.sun_path); 1347 sock_status = socket_status (server.sun_path);
1327 saved_errno = errno; 1348 saved_errno = errno;
@@ -1331,6 +1352,9 @@ set_local_socket (void)
1331 } 1352 }
1332 } 1353 }
1333 1354
1355 free (socket_name_storage);
1356 free (tmpdir_storage);
1357
1334 switch (sock_status) 1358 switch (sock_status)
1335 { 1359 {
1336 case 1: 1360 case 1:
@@ -1372,6 +1396,7 @@ static HSOCKET
1372set_socket (int no_exit_if_error) 1396set_socket (int no_exit_if_error)
1373{ 1397{
1374 HSOCKET s; 1398 HSOCKET s;
1399 const char *local_server_file = server_file;
1375 1400
1376 INITIALIZE (); 1401 INITIALIZE ();
1377 1402
@@ -1379,7 +1404,7 @@ set_socket (int no_exit_if_error)
1379 /* Explicit --socket-name argument. */ 1404 /* Explicit --socket-name argument. */
1380 if (socket_name) 1405 if (socket_name)
1381 { 1406 {
1382 s = set_local_socket (); 1407 s = set_local_socket (socket_name);
1383 if ((s != INVALID_SOCKET) || no_exit_if_error) 1408 if ((s != INVALID_SOCKET) || no_exit_if_error)
1384 return s; 1409 return s;
1385 message (TRUE, "%s: error accessing socket \"%s\"\n", 1410 message (TRUE, "%s: error accessing socket \"%s\"\n",
@@ -1389,30 +1414,29 @@ set_socket (int no_exit_if_error)
1389#endif 1414#endif
1390 1415
1391 /* Explicit --server-file arg or EMACS_SERVER_FILE variable. */ 1416 /* Explicit --server-file arg or EMACS_SERVER_FILE variable. */
1392 if (!server_file) 1417 if (!local_server_file)
1393 server_file = egetenv ("EMACS_SERVER_FILE"); 1418 local_server_file = egetenv ("EMACS_SERVER_FILE");
1394 1419
1395 if (server_file) 1420 if (local_server_file)
1396 { 1421 {
1397 s = set_tcp_socket (); 1422 s = set_tcp_socket (local_server_file);
1398 if ((s != INVALID_SOCKET) || no_exit_if_error) 1423 if ((s != INVALID_SOCKET) || no_exit_if_error)
1399 return s; 1424 return s;
1400 1425
1401 message (TRUE, "%s: error accessing server file \"%s\"\n", 1426 message (TRUE, "%s: error accessing server file \"%s\"\n",
1402 progname, server_file); 1427 progname, local_server_file);
1403 exit (EXIT_FAILURE); 1428 exit (EXIT_FAILURE);
1404 } 1429 }
1405 1430
1406#ifndef NO_SOCKETS_IN_FILE_SYSTEM 1431#ifndef NO_SOCKETS_IN_FILE_SYSTEM
1407 /* Implicit local socket. */ 1432 /* Implicit local socket. */
1408 s = set_local_socket (); 1433 s = set_local_socket ("server");
1409 if (s != INVALID_SOCKET) 1434 if (s != INVALID_SOCKET)
1410 return s; 1435 return s;
1411#endif 1436#endif
1412 1437
1413 /* Implicit server file. */ 1438 /* Implicit server file. */
1414 server_file = "server"; 1439 s = set_tcp_socket ("server");
1415 s = set_tcp_socket ();
1416 if ((s != INVALID_SOCKET) || no_exit_if_error) 1440 if ((s != INVALID_SOCKET) || no_exit_if_error)
1417 return s; 1441 return s;
1418 1442
@@ -1526,8 +1550,8 @@ start_daemon_and_retry_set_socket (void)
1526 { 1550 {
1527 /* Pass --daemon=socket_name as argument. */ 1551 /* Pass --daemon=socket_name as argument. */
1528 const char *deq = "--daemon="; 1552 const char *deq = "--daemon=";
1529 char *daemon_arg = alloca (strlen (deq) 1553 char *daemon_arg = xmalloc (strlen (deq)
1530 + strlen (socket_name) + 1); 1554 + strlen (socket_name) + 1);
1531 strcpy (daemon_arg, deq); 1555 strcpy (daemon_arg, deq);
1532 strcat (daemon_arg, socket_name); 1556 strcat (daemon_arg, socket_name);
1533 d_argv[1] = daemon_arg; 1557 d_argv[1] = daemon_arg;
@@ -1544,8 +1568,6 @@ main (int argc, char **argv)
1544 int rl = 0, needlf = 0; 1568 int rl = 0, needlf = 0;
1545 char *cwd, *str; 1569 char *cwd, *str;
1546 char string[BUFSIZ+1]; 1570 char string[BUFSIZ+1];
1547 int null_socket_name IF_LINT ( = 0);
1548 int null_server_file IF_LINT ( = 0);
1549 int start_daemon_if_needed; 1571 int start_daemon_if_needed;
1550 int exit_status = EXIT_SUCCESS; 1572 int exit_status = EXIT_SUCCESS;
1551 1573
@@ -1573,14 +1595,6 @@ main (int argc, char **argv)
1573 in case of failure to connect. */ 1595 in case of failure to connect. */
1574 start_daemon_if_needed = (alternate_editor 1596 start_daemon_if_needed = (alternate_editor
1575 && (alternate_editor[0] == '\0')); 1597 && (alternate_editor[0] == '\0'));
1576 if (start_daemon_if_needed)
1577 {
1578 /* set_socket changes the values for socket_name and
1579 server_file, we need to reset them, if they were NULL before
1580 for the second call to set_socket. */
1581 null_socket_name = (socket_name == NULL);
1582 null_server_file = (server_file == NULL);
1583 }
1584 1598
1585 emacs_socket = set_socket (alternate_editor || start_daemon_if_needed); 1599 emacs_socket = set_socket (alternate_editor || start_daemon_if_needed);
1586 if (emacs_socket == INVALID_SOCKET) 1600 if (emacs_socket == INVALID_SOCKET)
@@ -1588,13 +1602,6 @@ main (int argc, char **argv)
1588 if (! start_daemon_if_needed) 1602 if (! start_daemon_if_needed)
1589 fail (); 1603 fail ();
1590 1604
1591 /* Reset socket_name and server_file if they were NULL
1592 before the set_socket call. */
1593 if (null_socket_name)
1594 socket_name = NULL;
1595 if (null_server_file)
1596 server_file = NULL;
1597
1598 start_daemon_and_retry_set_socket (); 1605 start_daemon_and_retry_set_socket ();
1599 } 1606 }
1600 1607
@@ -1614,7 +1621,11 @@ main (int argc, char **argv)
1614 /* Send over our environment and current directory. */ 1621 /* Send over our environment and current directory. */
1615 if (!current_frame) 1622 if (!current_frame)
1616 { 1623 {
1624#ifndef WINDOWSNT
1625 /* This is defined in stdlib.h on MS-Windows. It's defined in
1626 unistd.h on some POSIX hosts, but not all (Bug#10155). */
1617 extern char **environ; 1627 extern char **environ;
1628#endif
1618 int i; 1629 int i;
1619 for (i = 0; environ[i]; i++) 1630 for (i = 0; environ[i]; i++)
1620 { 1631 {
@@ -1757,7 +1768,7 @@ main (int argc, char **argv)
1757 /* Now, wait for an answer and print any messages. */ 1768 /* Now, wait for an answer and print any messages. */
1758 while (exit_status == EXIT_SUCCESS) 1769 while (exit_status == EXIT_SUCCESS)
1759 { 1770 {
1760 char *p; 1771 char *p, *end_p;
1761 do 1772 do
1762 { 1773 {
1763 errno = 0; 1774 errno = 0;
@@ -1772,61 +1783,72 @@ main (int argc, char **argv)
1772 1783
1773 string[rl] = '\0'; 1784 string[rl] = '\0';
1774 1785
1775 p = string + strlen (string) - 1; 1786 /* Loop over all NL-terminated messages. */
1776 while (p > string && *p == '\n') 1787 for (end_p = p = string; end_p != NULL && *end_p != '\0'; p = end_p)
1777 *p-- = 0; 1788 {
1789 end_p = strchr (p, '\n');
1790 if (end_p != NULL)
1791 *end_p++ = '\0';
1778 1792
1779 if (strprefix ("-emacs-pid ", string)) 1793 if (strprefix ("-emacs-pid ", p))
1780 { 1794 {
1781 /* -emacs-pid PID: The process id of the Emacs process. */ 1795 /* -emacs-pid PID: The process id of the Emacs process. */
1782 emacs_pid = strtol (string + strlen ("-emacs-pid"), NULL, 10); 1796 emacs_pid = strtol (p + strlen ("-emacs-pid"), NULL, 10);
1783 } 1797 }
1784 else if (strprefix ("-window-system-unsupported ", string)) 1798 else if (strprefix ("-window-system-unsupported ", p))
1785 { 1799 {
1786 /* -window-system-unsupported: Emacs was compiled without X 1800 /* -window-system-unsupported: Emacs was compiled without X
1787 support. Try again on the terminal. */ 1801 support. Try again on the terminal. */
1788 nowait = 0; 1802 nowait = 0;
1789 tty = 1; 1803 tty = 1;
1790 goto retry; 1804 goto retry;
1791 } 1805 }
1792 else if (strprefix ("-print ", string)) 1806 else if (strprefix ("-print ", p))
1793 { 1807 {
1794 /* -print STRING: Print STRING on the terminal. */ 1808 /* -print STRING: Print STRING on the terminal. */
1795 str = unquote_argument (string + strlen ("-print ")); 1809 str = unquote_argument (p + strlen ("-print "));
1796 if (needlf) 1810 if (needlf)
1797 printf ("\n"); 1811 printf ("\n");
1798 printf ("%s", str); 1812 printf ("%s", str);
1799 needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n'; 1813 needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n';
1800 } 1814 }
1801 else if (strprefix ("-error ", string)) 1815 else if (strprefix ("-print-nonl ", p))
1802 { 1816 {
1803 /* -error DESCRIPTION: Signal an error on the terminal. */ 1817 /* -print-nonl STRING: Print STRING on the terminal.
1804 str = unquote_argument (string + strlen ("-error ")); 1818 Used to continue a preceding -print command. */
1805 if (needlf) 1819 str = unquote_argument (p + strlen ("-print-nonl "));
1806 printf ("\n"); 1820 printf ("%s", str);
1807 fprintf (stderr, "*ERROR*: %s", str); 1821 needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n';
1808 needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n'; 1822 }
1809 exit_status = EXIT_FAILURE; 1823 else if (strprefix ("-error ", p))
1810 } 1824 {
1825 /* -error DESCRIPTION: Signal an error on the terminal. */
1826 str = unquote_argument (p + strlen ("-error "));
1827 if (needlf)
1828 printf ("\n");
1829 fprintf (stderr, "*ERROR*: %s", str);
1830 needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n';
1831 exit_status = EXIT_FAILURE;
1832 }
1811#ifdef SIGSTOP 1833#ifdef SIGSTOP
1812 else if (strprefix ("-suspend ", string)) 1834 else if (strprefix ("-suspend ", p))
1813 { 1835 {
1814 /* -suspend: Suspend this terminal, i.e., stop the process. */ 1836 /* -suspend: Suspend this terminal, i.e., stop the process. */
1815 if (needlf) 1837 if (needlf)
1816 printf ("\n"); 1838 printf ("\n");
1817 needlf = 0; 1839 needlf = 0;
1818 kill (0, SIGSTOP); 1840 kill (0, SIGSTOP);
1819 } 1841 }
1820#endif 1842#endif
1821 else 1843 else
1822 { 1844 {
1823 /* Unknown command. */ 1845 /* Unknown command. */
1824 if (needlf) 1846 if (needlf)
1825 printf ("\n"); 1847 printf ("\n");
1826 printf ("*ERROR*: Unknown message: %s", string); 1848 needlf = 0;
1827 needlf = string[0] 1849 printf ("*ERROR*: Unknown message: %s\n", p);
1828 == '\0' ? needlf : string[strlen (string) - 1] != '\n'; 1850 }
1829 } 1851 }
1830 } 1852 }
1831 1853
1832 if (needlf) 1854 if (needlf)
diff --git a/lib-src/etags.c b/lib-src/etags.c
index 693c999047f..c88473ad525 100644
--- a/lib-src/etags.c
+++ b/lib-src/etags.c
@@ -28,7 +28,7 @@ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
28IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 29
30 30
31Copyright (C) 1984, 1987-1989, 1993-1995, 1998-2011 31Copyright (C) 1984, 1987-1989, 1993-1995, 1998-2012
32 Free Software Foundation, Inc. 32 Free Software Foundation, Inc.
33 33
34This file is not considered part of GNU Emacs. 34This file is not considered part of GNU Emacs.
@@ -103,7 +103,7 @@ char pot_etags_version[] = "@(#) pot revision number is 17.38.1.4";
103# define PTR void * 103# define PTR void *
104# endif 104# endif
105#else /* no config.h */ 105#else /* no config.h */
106# if defined(__STDC__) && (__STDC__ || defined(__SUNPRO_C)) 106# if defined (__STDC__) && (__STDC__ || defined (__SUNPRO_C))
107# define PTR void * /* for generic pointers */ 107# define PTR void * /* for generic pointers */
108# else /* not standard C */ 108# else /* not standard C */
109# define const /* remove const for old compilers' sake */ 109# define const /* remove const for old compilers' sake */
@@ -138,9 +138,7 @@ char pot_etags_version[] = "@(#) pot revision number is 17.38.1.4";
138#endif /* MSDOS */ 138#endif /* MSDOS */
139 139
140#ifdef WINDOWSNT 140#ifdef WINDOWSNT
141# include <stdlib.h>
142# include <fcntl.h> 141# include <fcntl.h>
143# include <string.h>
144# include <direct.h> 142# include <direct.h>
145# include <io.h> 143# include <io.h>
146# define MAXPATHLEN _MAX_PATH 144# define MAXPATHLEN _MAX_PATH
@@ -151,27 +149,6 @@ char pot_etags_version[] = "@(#) pot revision number is 17.38.1.4";
151# define HAVE_GETCWD 149# define HAVE_GETCWD
152# endif /* undef HAVE_GETCWD */ 150# endif /* undef HAVE_GETCWD */
153#else /* not WINDOWSNT */ 151#else /* not WINDOWSNT */
154# ifdef STDC_HEADERS
155# include <stdlib.h>
156# include <string.h>
157# else /* no standard C headers */
158 extern char *getenv (const char *);
159 extern char *strcpy (char *, const char *);
160 extern char *strncpy (char *, const char *, unsigned long);
161 extern char *strcat (char *, const char *);
162 extern char *strncat (char *, const char *, unsigned long);
163 extern int strcmp (const char *, const char *);
164 extern int strncmp (const char *, const char *, unsigned long);
165 extern int system (const char *);
166 extern unsigned long strlen (const char *);
167 extern void *malloc (unsigned long);
168 extern void *realloc (void *, unsigned long);
169 extern void exit (int);
170 extern void free (void *);
171 extern void *memmove (void *, const void *, unsigned long);
172# define EXIT_SUCCESS 0
173# define EXIT_FAILURE 1
174# endif
175#endif /* !WINDOWSNT */ 152#endif /* !WINDOWSNT */
176 153
177#include <unistd.h> 154#include <unistd.h>
@@ -181,6 +158,8 @@ char pot_etags_version[] = "@(#) pot revision number is 17.38.1.4";
181# endif 158# endif
182#endif /* HAVE_UNISTD_H */ 159#endif /* HAVE_UNISTD_H */
183 160
161#include <stdlib.h>
162#include <string.h>
184#include <stdio.h> 163#include <stdio.h>
185#include <ctype.h> 164#include <ctype.h>
186#include <errno.h> 165#include <errno.h>
@@ -223,25 +202,25 @@ If you want regular expression support, you should delete this notice and
223# define CTAGS FALSE 202# define CTAGS FALSE
224#endif 203#endif
225 204
226#define streq(s,t) (assert((s)!=NULL || (t)!=NULL), !strcmp (s, t)) 205#define streq(s,t) (assert ((s)!=NULL || (t)!=NULL), !strcmp (s, t))
227#define strcaseeq(s,t) (assert((s)!=NULL && (t)!=NULL), !etags_strcasecmp (s, t)) 206#define strcaseeq(s,t) (assert ((s)!=NULL && (t)!=NULL), !etags_strcasecmp (s, t))
228#define strneq(s,t,n) (assert((s)!=NULL || (t)!=NULL), !strncmp (s, t, n)) 207#define strneq(s,t,n) (assert ((s)!=NULL || (t)!=NULL), !strncmp (s, t, n))
229#define strncaseeq(s,t,n) (assert((s)!=NULL && (t)!=NULL), !etags_strncasecmp (s, t, n)) 208#define strncaseeq(s,t,n) (assert ((s)!=NULL && (t)!=NULL), !etags_strncasecmp (s, t, n))
230 209
231#define CHARS 256 /* 2^sizeof(char) */ 210#define CHARS 256 /* 2^sizeof(char) */
232#define CHAR(x) ((unsigned int)(x) & (CHARS - 1)) 211#define CHAR(x) ((unsigned int)(x) & (CHARS - 1))
233#define iswhite(c) (_wht[CHAR(c)]) /* c is white (see white) */ 212#define iswhite(c) (_wht[CHAR (c)]) /* c is white (see white) */
234#define notinname(c) (_nin[CHAR(c)]) /* c is not in a name (see nonam) */ 213#define notinname(c) (_nin[CHAR (c)]) /* c is not in a name (see nonam) */
235#define begtoken(c) (_btk[CHAR(c)]) /* c can start token (see begtk) */ 214#define begtoken(c) (_btk[CHAR (c)]) /* c can start token (see begtk) */
236#define intoken(c) (_itk[CHAR(c)]) /* c can be in token (see midtk) */ 215#define intoken(c) (_itk[CHAR (c)]) /* c can be in token (see midtk) */
237#define endtoken(c) (_etk[CHAR(c)]) /* c ends tokens (see endtk) */ 216#define endtoken(c) (_etk[CHAR (c)]) /* c ends tokens (see endtk) */
238 217
239#define ISALNUM(c) isalnum (CHAR(c)) 218#define ISALNUM(c) isalnum (CHAR (c))
240#define ISALPHA(c) isalpha (CHAR(c)) 219#define ISALPHA(c) isalpha (CHAR (c))
241#define ISDIGIT(c) isdigit (CHAR(c)) 220#define ISDIGIT(c) isdigit (CHAR (c))
242#define ISLOWER(c) islower (CHAR(c)) 221#define ISLOWER(c) islower (CHAR (c))
243 222
244#define lowcase(c) tolower (CHAR(c)) 223#define lowcase(c) tolower (CHAR (c))
245 224
246 225
247/* 226/*
@@ -347,7 +326,7 @@ typedef struct regexp
347 struct re_pattern_buffer *pat; /* the compiled pattern */ 326 struct re_pattern_buffer *pat; /* the compiled pattern */
348 struct re_registers regs; /* re registers */ 327 struct re_registers regs; /* re registers */
349 bool error_signaled; /* already signaled for this regexp */ 328 bool error_signaled; /* already signaled for this regexp */
350 bool force_explicit_name; /* do not allow implict tag name */ 329 bool force_explicit_name; /* do not allow implicit tag name */
351 bool ignore_case; /* ignore case when matching */ 330 bool ignore_case; /* ignore case when matching */
352 bool multi_line; /* do a multi-line match on the whole file */ 331 bool multi_line; /* do a multi-line match on the whole file */
353} regexp; 332} regexp;
@@ -435,8 +414,8 @@ static bool filename_is_absolute (char *f);
435static void canonicalize_filename (char *); 414static void canonicalize_filename (char *);
436static void linebuffer_init (linebuffer *); 415static void linebuffer_init (linebuffer *);
437static void linebuffer_setlen (linebuffer *, int); 416static void linebuffer_setlen (linebuffer *, int);
438static PTR xmalloc (unsigned int); 417static PTR xmalloc (size_t);
439static PTR xrealloc (char *, unsigned int); 418static PTR xrealloc (char *, size_t);
440 419
441 420
442static char searchar = '/'; /* use /.../ searches */ 421static char searchar = '/'; /* use /.../ searches */
@@ -446,6 +425,7 @@ static char *progname; /* name this program was invoked with */
446static char *cwd; /* current working directory */ 425static char *cwd; /* current working directory */
447static char *tagfiledir; /* directory of tagfile */ 426static char *tagfiledir; /* directory of tagfile */
448static FILE *tagf; /* ioptr for tags file */ 427static FILE *tagf; /* ioptr for tags file */
428static ptrdiff_t whatlen_max; /* maximum length of any 'what' member */
449 429
450static fdesc *fdhead; /* head of file description list */ 430static fdesc *fdhead; /* head of file description list */
451static fdesc *curfdp; /* current file description */ 431static fdesc *curfdp; /* current file description */
@@ -631,7 +611,7 @@ using `--declarations'.";
631static const char *Cplusplus_suffixes [] = 611static const char *Cplusplus_suffixes [] =
632 { "C", "c++", "cc", "cpp", "cxx", "H", "h++", "hh", "hpp", "hxx", 612 { "C", "c++", "cc", "cpp", "cxx", "H", "h++", "hh", "hpp", "hxx",
633 "M", /* Objective C++ */ 613 "M", /* Objective C++ */
634 "pdb", /* Postscript with C syntax */ 614 "pdb", /* PostScript with C syntax */
635 NULL }; 615 NULL };
636static const char Cplusplus_help [] = 616static const char Cplusplus_help [] =
637"In C++ code, all the tag constructs of C code are tagged. (Use\n\ 617"In C++ code, all the tag constructs of C code are tagged. (Use\n\
@@ -887,7 +867,7 @@ static void
887print_version (void) 867print_version (void)
888{ 868{
889 /* Makes it easier to update automatically. */ 869 /* Makes it easier to update automatically. */
890 char emacs_copyright[] = "Copyright (C) 2011 Free Software Foundation, Inc."; 870 char emacs_copyright[] = "Copyright (C) 2012 Free Software Foundation, Inc.";
891 871
892 printf ("%s (%s %s)\n", (CTAGS) ? "ctags" : "etags", EMACS_NAME, VERSION); 872 printf ("%s (%s %s)\n", (CTAGS) ? "ctags" : "etags", EMACS_NAME, VERSION);
893 puts (emacs_copyright); 873 puts (emacs_copyright);
@@ -1087,6 +1067,7 @@ main (int argc, char **argv)
1087 int current_arg, file_count; 1067 int current_arg, file_count;
1088 linebuffer filename_lb; 1068 linebuffer filename_lb;
1089 bool help_asked = FALSE; 1069 bool help_asked = FALSE;
1070 ptrdiff_t len;
1090 char *optstring; 1071 char *optstring;
1091 int opt; 1072 int opt;
1092 1073
@@ -1131,6 +1112,9 @@ main (int argc, char **argv)
1131 /* This means that a file name has been seen. Record it. */ 1112 /* This means that a file name has been seen. Record it. */
1132 argbuffer[current_arg].arg_type = at_filename; 1113 argbuffer[current_arg].arg_type = at_filename;
1133 argbuffer[current_arg].what = optarg; 1114 argbuffer[current_arg].what = optarg;
1115 len = strlen (optarg);
1116 if (whatlen_max < len)
1117 whatlen_max = len;
1134 ++current_arg; 1118 ++current_arg;
1135 ++file_count; 1119 ++file_count;
1136 break; 1120 break;
@@ -1139,6 +1123,9 @@ main (int argc, char **argv)
1139 /* Parse standard input. Idea by Vivek <vivek@etla.org>. */ 1123 /* Parse standard input. Idea by Vivek <vivek@etla.org>. */
1140 argbuffer[current_arg].arg_type = at_stdin; 1124 argbuffer[current_arg].arg_type = at_stdin;
1141 argbuffer[current_arg].what = optarg; 1125 argbuffer[current_arg].what = optarg;
1126 len = strlen (optarg);
1127 if (whatlen_max < len)
1128 whatlen_max = len;
1142 ++current_arg; 1129 ++current_arg;
1143 ++file_count; 1130 ++file_count;
1144 if (parsing_stdin) 1131 if (parsing_stdin)
@@ -1181,6 +1168,9 @@ main (int argc, char **argv)
1181 case 'r': 1168 case 'r':
1182 argbuffer[current_arg].arg_type = at_regexp; 1169 argbuffer[current_arg].arg_type = at_regexp;
1183 argbuffer[current_arg].what = optarg; 1170 argbuffer[current_arg].what = optarg;
1171 len = strlen (optarg);
1172 if (whatlen_max < len)
1173 whatlen_max = len;
1184 ++current_arg; 1174 ++current_arg;
1185 break; 1175 break;
1186 case 'R': 1176 case 'R':
@@ -1219,6 +1209,9 @@ main (int argc, char **argv)
1219 { 1209 {
1220 argbuffer[current_arg].arg_type = at_filename; 1210 argbuffer[current_arg].arg_type = at_filename;
1221 argbuffer[current_arg].what = argv[optind]; 1211 argbuffer[current_arg].what = argv[optind];
1212 len = strlen (argv[optind]);
1213 if (whatlen_max < len)
1214 whatlen_max = len;
1222 ++current_arg; 1215 ++current_arg;
1223 ++file_count; 1216 ++file_count;
1224 } 1217 }
@@ -1352,7 +1345,9 @@ main (int argc, char **argv)
1352 /* From here on, we are in (CTAGS && !cxref_style) */ 1345 /* From here on, we are in (CTAGS && !cxref_style) */
1353 if (update) 1346 if (update)
1354 { 1347 {
1355 char cmd[BUFSIZ]; 1348 char *cmd =
1349 xmalloc (strlen (tagfile) + whatlen_max +
1350 sizeof "mv..OTAGS;fgrep -v '\t\t' OTAGS >;rm OTAGS");
1356 for (i = 0; i < current_arg; ++i) 1351 for (i = 0; i < current_arg; ++i)
1357 { 1352 {
1358 switch (argbuffer[i].arg_type) 1353 switch (argbuffer[i].arg_type)
@@ -1363,12 +1358,17 @@ main (int argc, char **argv)
1363 default: 1358 default:
1364 continue; /* the for loop */ 1359 continue; /* the for loop */
1365 } 1360 }
1366 sprintf (cmd, 1361 strcpy (cmd, "mv ");
1367 "mv %s OTAGS;fgrep -v '\t%s\t' OTAGS >%s;rm OTAGS", 1362 strcat (cmd, tagfile);
1368 tagfile, argbuffer[i].what, tagfile); 1363 strcat (cmd, " OTAGS;fgrep -v '\t");
1364 strcat (cmd, argbuffer[i].what);
1365 strcat (cmd, "\t' OTAGS >");
1366 strcat (cmd, tagfile);
1367 strcat (cmd, ";rm OTAGS");
1369 if (system (cmd) != EXIT_SUCCESS) 1368 if (system (cmd) != EXIT_SUCCESS)
1370 fatal ("failed to execute shell command", (char *)NULL); 1369 fatal ("failed to execute shell command", (char *)NULL);
1371 } 1370 }
1371 free (cmd);
1372 append_to_tagfile = TRUE; 1372 append_to_tagfile = TRUE;
1373 } 1373 }
1374 1374
@@ -1384,11 +1384,14 @@ main (int argc, char **argv)
1384 if (CTAGS) 1384 if (CTAGS)
1385 if (append_to_tagfile || update) 1385 if (append_to_tagfile || update)
1386 { 1386 {
1387 char cmd[2*BUFSIZ+20]; 1387 char *cmd = xmalloc (2 * strlen (tagfile) + sizeof "sort -u -o..");
1388 /* Maybe these should be used: 1388 /* Maybe these should be used:
1389 setenv ("LC_COLLATE", "C", 1); 1389 setenv ("LC_COLLATE", "C", 1);
1390 setenv ("LC_ALL", "C", 1); */ 1390 setenv ("LC_ALL", "C", 1); */
1391 sprintf (cmd, "sort -u -o %.*s %.*s", BUFSIZ, tagfile, BUFSIZ, tagfile); 1391 strcpy (cmd, "sort -u -o ");
1392 strcat (cmd, tagfile);
1393 strcat (cmd, " ");
1394 strcat (cmd, tagfile);
1392 exit (system (cmd)); 1395 exit (system (cmd));
1393 } 1396 }
1394 return EXIT_SUCCESS; 1397 return EXIT_SUCCESS;
@@ -1722,16 +1725,16 @@ init (void)
1722 register int i; 1725 register int i;
1723 1726
1724 for (i = 0; i < CHARS; i++) 1727 for (i = 0; i < CHARS; i++)
1725 iswhite(i) = notinname(i) = begtoken(i) = intoken(i) = endtoken(i) = FALSE; 1728 iswhite (i) = notinname (i) = begtoken (i) = intoken (i) = endtoken (i) = FALSE;
1726 for (sp = white; *sp != '\0'; sp++) iswhite (*sp) = TRUE; 1729 for (sp = white; *sp != '\0'; sp++) iswhite (*sp) = TRUE;
1727 for (sp = nonam; *sp != '\0'; sp++) notinname (*sp) = TRUE; 1730 for (sp = nonam; *sp != '\0'; sp++) notinname (*sp) = TRUE;
1728 notinname('\0') = notinname('\n'); 1731 notinname ('\0') = notinname ('\n');
1729 for (sp = begtk; *sp != '\0'; sp++) begtoken (*sp) = TRUE; 1732 for (sp = begtk; *sp != '\0'; sp++) begtoken (*sp) = TRUE;
1730 begtoken('\0') = begtoken('\n'); 1733 begtoken ('\0') = begtoken ('\n');
1731 for (sp = midtk; *sp != '\0'; sp++) intoken (*sp) = TRUE; 1734 for (sp = midtk; *sp != '\0'; sp++) intoken (*sp) = TRUE;
1732 intoken('\0') = intoken('\n'); 1735 intoken ('\0') = intoken ('\n');
1733 for (sp = endtk; *sp != '\0'; sp++) endtoken (*sp) = TRUE; 1736 for (sp = endtk; *sp != '\0'; sp++) endtoken (*sp) = TRUE;
1734 endtoken('\0') = endtoken('\n'); 1737 endtoken ('\0') = endtoken ('\n');
1735} 1738}
1736 1739
1737/* 1740/*
@@ -1859,10 +1862,10 @@ find_entries (FILE *inf)
1859 1862
1860 assert (parser != NULL); 1863 assert (parser != NULL);
1861 1864
1862 /* Generic initialisations before reading from file. */ 1865 /* Generic initializations before reading from file. */
1863 linebuffer_setlen (&filebuf, 0); /* reset the file buffer */ 1866 linebuffer_setlen (&filebuf, 0); /* reset the file buffer */
1864 1867
1865 /* Generic initialisations before parsing file with readline. */ 1868 /* Generic initializations before parsing file with readline. */
1866 lineno = 0; /* reset global line number */ 1869 lineno = 0; /* reset global line number */
1867 charno = 0; /* reset global char number */ 1870 charno = 0; /* reset global char number */
1868 linecharno = 0; /* reset global char number of line start */ 1871 linecharno = 0; /* reset global char number of line start */
@@ -1892,7 +1895,7 @@ find_entries (FILE *inf)
1892 * 4. the character, if any, immediately after NAME in LINESTART must 1895 * 4. the character, if any, immediately after NAME in LINESTART must
1893 * also be a character in NONAM. 1896 * also be a character in NONAM.
1894 * 1897 *
1895 * The implementation uses the notinname() macro, which recognises the 1898 * The implementation uses the notinname() macro, which recognizes the
1896 * characters stored in the string `nonam'. 1899 * characters stored in the string `nonam'.
1897 * etags.el needs to use the same characters that are in NONAM. 1900 * etags.el needs to use the same characters that are in NONAM.
1898 */ 1901 */
@@ -3054,7 +3057,7 @@ make_C_tag (int isfun)
3054 make_tag (token_name.buffer, token_name.len, isfun, token.line, 3057 make_tag (token_name.buffer, token_name.len, isfun, token.line,
3055 token.offset+token.length+1, token.lineno, token.linepos); 3058 token.offset+token.length+1, token.lineno, token.linepos);
3056 else if (DEBUG) 3059 else if (DEBUG)
3057 { /* this branch is optimised away if !DEBUG */ 3060 { /* this branch is optimized away if !DEBUG */
3058 make_tag (concat ("INVALID TOKEN:-->", token_name.buffer, ""), 3061 make_tag (concat ("INVALID TOKEN:-->", token_name.buffer, ""),
3059 token_name.len + 17, isfun, token.line, 3062 token_name.len + 17, isfun, token.line,
3060 token.offset+token.length+1, token.lineno, token.linepos); 3063 token.offset+token.length+1, token.lineno, token.linepos);
@@ -3186,24 +3189,12 @@ C_entries (int c_ext, FILE *inf)
3186 } 3189 }
3187 continue; 3190 continue;
3188 } 3191 }
3189 else if (bracketlev > 0)
3190 {
3191 switch (c)
3192 {
3193 case ']':
3194 if (--bracketlev > 0)
3195 continue;
3196 break;
3197 case '\0':
3198 CNL_SAVE_DEFINEDEF ();
3199 break;
3200 }
3201 continue;
3202 }
3203 else switch (c) 3192 else switch (c)
3204 { 3193 {
3205 case '"': 3194 case '"':
3206 inquote = TRUE; 3195 inquote = TRUE;
3196 if (bracketlev > 0)
3197 continue;
3207 if (inattribute) 3198 if (inattribute)
3208 break; 3199 break;
3209 switch (fvdef) 3200 switch (fvdef)
@@ -3221,9 +3212,11 @@ C_entries (int c_ext, FILE *inf)
3221 continue; 3212 continue;
3222 case '\'': 3213 case '\'':
3223 inchar = TRUE; 3214 inchar = TRUE;
3215 if (bracketlev > 0)
3216 continue;
3224 if (inattribute) 3217 if (inattribute)
3225 break; 3218 break;
3226 if (fvdef != finlist && fvdef != fignore && fvdef !=vignore) 3219 if (fvdef != finlist && fvdef != fignore && fvdef != vignore)
3227 { 3220 {
3228 fvextern = FALSE; 3221 fvextern = FALSE;
3229 fvdef = fvnone; 3222 fvdef = fvnone;
@@ -3235,6 +3228,8 @@ C_entries (int c_ext, FILE *inf)
3235 incomm = TRUE; 3228 incomm = TRUE;
3236 lp++; 3229 lp++;
3237 c = ' '; 3230 c = ' ';
3231 if (bracketlev > 0)
3232 continue;
3238 } 3233 }
3239 else if (/* cplpl && */ *lp == '/') 3234 else if (/* cplpl && */ *lp == '/')
3240 { 3235 {
@@ -3267,7 +3262,7 @@ C_entries (int c_ext, FILE *inf)
3267 for (cp = newlb.buffer; cp < lp-1; cp++) 3262 for (cp = newlb.buffer; cp < lp-1; cp++)
3268 if (!iswhite (*cp)) 3263 if (!iswhite (*cp))
3269 { 3264 {
3270 if (*cp == '*' && *(cp+1) == '/') 3265 if (*cp == '*' && cp[1] == '/')
3271 { 3266 {
3272 cp++; 3267 cp++;
3273 cpptoken = TRUE; 3268 cpptoken = TRUE;
@@ -3281,7 +3276,17 @@ C_entries (int c_ext, FILE *inf)
3281 continue; 3276 continue;
3282 case '[': 3277 case '[':
3283 bracketlev++; 3278 bracketlev++;
3284 continue; 3279 continue;
3280 default:
3281 if (bracketlev > 0)
3282 {
3283 if (c == ']')
3284 --bracketlev;
3285 else if (c == '\0')
3286 CNL_SAVE_DEFINEDEF ();
3287 continue;
3288 }
3289 break;
3285 } /* switch (c) */ 3290 } /* switch (c) */
3286 3291
3287 3292
@@ -3301,7 +3306,7 @@ C_entries (int c_ext, FILE *inf)
3301 if (c == ':' && *lp == ':' && begtoken (lp[1])) 3306 if (c == ':' && *lp == ':' && begtoken (lp[1]))
3302 /* This handles :: in the middle, 3307 /* This handles :: in the middle,
3303 but not at the beginning of an identifier. 3308 but not at the beginning of an identifier.
3304 Also, space-separated :: is not recognised. */ 3309 Also, space-separated :: is not recognized. */
3305 { 3310 {
3306 if (c_ext & C_AUTO) /* automatic detection of C++ */ 3311 if (c_ext & C_AUTO) /* automatic detection of C++ */
3307 c_ext = (c_ext | C_PLPL) & ~C_AUTO; 3312 c_ext = (c_ext | C_PLPL) & ~C_AUTO;
@@ -3956,16 +3961,16 @@ Yacc_entries (FILE *inf)
3956 ) 3961 )
3957 3962
3958#define LOOKING_AT(cp, kw) /* kw is the keyword, a literal string */ \ 3963#define LOOKING_AT(cp, kw) /* kw is the keyword, a literal string */ \
3959 ((assert("" kw), TRUE) /* syntax error if not a literal string */ \ 3964 ((assert ("" kw), TRUE) /* syntax error if not a literal string */ \
3960 && strneq ((cp), kw, sizeof(kw)-1) /* cp points at kw */ \ 3965 && strneq ((cp), kw, sizeof (kw)-1) /* cp points at kw */ \
3961 && notinname ((cp)[sizeof(kw)-1]) /* end of kw */ \ 3966 && notinname ((cp)[sizeof (kw)-1]) /* end of kw */ \
3962 && ((cp) = skip_spaces((cp)+sizeof(kw)-1))) /* skip spaces */ 3967 && ((cp) = skip_spaces ((cp)+sizeof (kw)-1))) /* skip spaces */
3963 3968
3964/* Similar to LOOKING_AT but does not use notinname, does not skip */ 3969/* Similar to LOOKING_AT but does not use notinname, does not skip */
3965#define LOOKING_AT_NOCASE(cp, kw) /* the keyword is a literal string */ \ 3970#define LOOKING_AT_NOCASE(cp, kw) /* the keyword is a literal string */ \
3966 ((assert("" kw), TRUE) /* syntax error if not a literal string */ \ 3971 ((assert ("" kw), TRUE) /* syntax error if not a literal string */ \
3967 && strncaseeq ((cp), kw, sizeof(kw)-1) /* cp points at kw */ \ 3972 && strncaseeq ((cp), kw, sizeof (kw)-1) /* cp points at kw */ \
3968 && ((cp) += sizeof(kw)-1)) /* skip spaces */ 3973 && ((cp) += sizeof (kw)-1)) /* skip spaces */
3969 3974
3970/* 3975/*
3971 * Read a file, but do no processing. This is used to do regexp 3976 * Read a file, but do no processing. This is used to do regexp
@@ -4045,6 +4050,12 @@ Fortran_functions (FILE *inf)
4045 if (LOOKING_AT_NOCASE (dbp, "recursive")) 4050 if (LOOKING_AT_NOCASE (dbp, "recursive"))
4046 dbp = skip_spaces (dbp); 4051 dbp = skip_spaces (dbp);
4047 4052
4053 if (LOOKING_AT_NOCASE (dbp, "pure"))
4054 dbp = skip_spaces (dbp);
4055
4056 if (LOOKING_AT_NOCASE (dbp, "elemental"))
4057 dbp = skip_spaces (dbp);
4058
4048 switch (lowcase (*dbp)) 4059 switch (lowcase (*dbp))
4049 { 4060 {
4050 case 'i': 4061 case 'i':
@@ -4132,7 +4143,7 @@ Ada_getit (FILE *inf, const char *name_qualifier)
4132 readline (&lb, inf); 4143 readline (&lb, inf);
4133 dbp = lb.buffer; 4144 dbp = lb.buffer;
4134 } 4145 }
4135 switch (lowcase(*dbp)) 4146 switch (lowcase (*dbp))
4136 { 4147 {
4137 case 'b': 4148 case 'b':
4138 if (nocase_tail ("body")) 4149 if (nocase_tail ("body"))
@@ -4236,7 +4247,7 @@ Ada_funcs (FILE *inf)
4236 } 4247 }
4237 4248
4238 /* We are at the beginning of a token. */ 4249 /* We are at the beginning of a token. */
4239 switch (lowcase(*dbp)) 4250 switch (lowcase (*dbp))
4240 { 4251 {
4241 case 'f': 4252 case 'f':
4242 if (!packages_only && nocase_tail ("function")) 4253 if (!packages_only && nocase_tail ("function"))
@@ -4362,7 +4373,7 @@ Perl_functions (FILE *inf)
4362 *cp = '\0'; 4373 *cp = '\0';
4363 name = concat (package, "::", sp); 4374 name = concat (package, "::", sp);
4364 *cp = savechar; 4375 *cp = savechar;
4365 make_tag (name, strlen(name), TRUE, 4376 make_tag (name, strlen (name), TRUE,
4366 lb.buffer, cp - lb.buffer + 1, lineno, linecharno); 4377 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
4367 free (name); 4378 free (name);
4368 } 4379 }
@@ -4457,9 +4468,9 @@ PHP_functions (FILE *inf)
4457 } 4468 }
4458 else if (LOOKING_AT (cp, "function")) 4469 else if (LOOKING_AT (cp, "function"))
4459 { 4470 {
4460 if(*cp == '&') 4471 if (*cp == '&')
4461 cp = skip_spaces (cp+1); 4472 cp = skip_spaces (cp+1);
4462 if(*cp != '\0') 4473 if (*cp != '\0')
4463 { 4474 {
4464 name = cp; 4475 name = cp;
4465 while (!notinname (*cp)) 4476 while (!notinname (*cp))
@@ -4500,7 +4511,7 @@ PHP_functions (FILE *inf)
4500 && *cp == '$') 4511 && *cp == '$')
4501 { 4512 {
4502 name = cp; 4513 name = cp;
4503 while (!notinname(*cp)) 4514 while (!notinname (*cp))
4504 cp++; 4515 cp++;
4505 make_tag (name, cp - name, FALSE, 4516 make_tag (name, cp - name, FALSE,
4506 lb.buffer, cp - lb.buffer + 1, lineno, linecharno); 4517 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
@@ -4837,7 +4848,7 @@ Lua_functions (FILE *inf)
4837 4848
4838 4849
4839/* 4850/*
4840 * Postscript tags 4851 * PostScript tags
4841 * Just look for lines where the first character is '/' 4852 * Just look for lines where the first character is '/'
4842 * Also look at "defineps" for PSWrap 4853 * Also look at "defineps" for PSWrap
4843 * Ideas by: 4854 * Ideas by:
@@ -4881,13 +4892,13 @@ Forth_words (FILE *inf)
4881 4892
4882 LOOP_ON_INPUT_LINES (inf, lb, bp) 4893 LOOP_ON_INPUT_LINES (inf, lb, bp)
4883 while ((bp = skip_spaces (bp))[0] != '\0') 4894 while ((bp = skip_spaces (bp))[0] != '\0')
4884 if (bp[0] == '\\' && iswhite(bp[1])) 4895 if (bp[0] == '\\' && iswhite (bp[1]))
4885 break; /* read next line */ 4896 break; /* read next line */
4886 else if (bp[0] == '(' && iswhite(bp[1])) 4897 else if (bp[0] == '(' && iswhite (bp[1]))
4887 do /* skip to ) or eol */ 4898 do /* skip to ) or eol */
4888 bp++; 4899 bp++;
4889 while (*bp != ')' && *bp != '\0'); 4900 while (*bp != ')' && *bp != '\0');
4890 else if ((bp[0] == ':' && iswhite(bp[1]) && bp++) 4901 else if ((bp[0] == ':' && iswhite (bp[1]) && bp++)
4891 || LOOKING_AT_NOCASE (bp, "constant") 4902 || LOOKING_AT_NOCASE (bp, "constant")
4892 || LOOKING_AT_NOCASE (bp, "code") 4903 || LOOKING_AT_NOCASE (bp, "code")
4893 || LOOKING_AT_NOCASE (bp, "create") 4904 || LOOKING_AT_NOCASE (bp, "create")
@@ -5276,7 +5287,7 @@ Prolog_functions (FILE *inf)
5276 /* Predicate or rule. Store the function name so that we 5287 /* Predicate or rule. Store the function name so that we
5277 only generate a tag for the first clause. */ 5288 only generate a tag for the first clause. */
5278 if (last == NULL) 5289 if (last == NULL)
5279 last = xnew(len + 1, char); 5290 last = xnew (len + 1, char);
5280 else if (len + 1 > allocated) 5291 else if (len + 1 > allocated)
5281 xrnew (last, len + 1, char); 5292 xrnew (last, len + 1, char);
5282 allocated = len + 1; 5293 allocated = len + 1;
@@ -5300,7 +5311,7 @@ prolog_skip_comment (linebuffer *plb, FILE *inf)
5300 return; 5311 return;
5301 readline (plb, inf); 5312 readline (plb, inf);
5302 } 5313 }
5303 while (!feof(inf)); 5314 while (!feof (inf));
5304} 5315}
5305 5316
5306/* 5317/*
@@ -5359,11 +5370,11 @@ prolog_atom (char *s, size_t pos)
5359 5370
5360 origpos = pos; 5371 origpos = pos;
5361 5372
5362 if (ISLOWER(s[pos]) || (s[pos] == '_')) 5373 if (ISLOWER (s[pos]) || (s[pos] == '_'))
5363 { 5374 {
5364 /* The atom is unquoted. */ 5375 /* The atom is unquoted. */
5365 pos++; 5376 pos++;
5366 while (ISALNUM(s[pos]) || (s[pos] == '_')) 5377 while (ISALNUM (s[pos]) || (s[pos] == '_'))
5367 { 5378 {
5368 pos++; 5379 pos++;
5369 } 5380 }
@@ -5706,7 +5717,7 @@ add_regex (char *regexp_pattern, language *lang)
5706 single_line = FALSE; /* dot does not match newline */ 5717 single_line = FALSE; /* dot does not match newline */
5707 5718
5708 5719
5709 if (strlen(regexp_pattern) < 3) 5720 if (strlen (regexp_pattern) < 3)
5710 { 5721 {
5711 error ("null regexp", (char *)NULL); 5722 error ("null regexp", (char *)NULL);
5712 return; 5723 return;
@@ -5891,7 +5902,7 @@ regex_tag_multiline (void)
5891 if (!rp->multi_line) 5902 if (!rp->multi_line)
5892 continue; /* skip normal regexps */ 5903 continue; /* skip normal regexps */
5893 5904
5894 /* Generic initialisations before parsing file from memory. */ 5905 /* Generic initializations before parsing file from memory. */
5895 lineno = 1; /* reset global line number */ 5906 lineno = 1; /* reset global line number */
5896 charno = 0; /* reset global char number */ 5907 charno = 0; /* reset global char number */
5897 linecharno = 0; /* reset global char number of line start */ 5908 linecharno = 0; /* reset global char number of line start */
@@ -6088,7 +6099,7 @@ readline (linebuffer *lbp, FILE *stream)
6088 lineno += 1; /* increment global line number */ 6099 lineno += 1; /* increment global line number */
6089 charno += result; /* increment global char number */ 6100 charno += result; /* increment global char number */
6090 6101
6091 /* Honour #line directives. */ 6102 /* Honor #line directives. */
6092 if (!no_line_directive) 6103 if (!no_line_directive)
6093 { 6104 {
6094 static bool discard_until_line_directive; 6105 static bool discard_until_line_directive;
@@ -6567,22 +6578,13 @@ absolute_filename (char *file, char *dir)
6567 else if (cp[0] != '/') 6578 else if (cp[0] != '/')
6568 cp = slashp; 6579 cp = slashp;
6569#endif 6580#endif
6570#ifdef HAVE_MEMMOVE
6571 memmove (cp, slashp + 3, strlen (slashp + 2)); 6581 memmove (cp, slashp + 3, strlen (slashp + 2));
6572#else
6573 /* Overlapping copy isn't really okay */
6574 strcpy (cp, slashp + 3);
6575#endif
6576 slashp = cp; 6582 slashp = cp;
6577 continue; 6583 continue;
6578 } 6584 }
6579 else if (slashp[2] == '/' || slashp[2] == '\0') 6585 else if (slashp[2] == '/' || slashp[2] == '\0')
6580 { 6586 {
6581#ifdef HAVE_MEMMOVE
6582 memmove (slashp, slashp + 2, strlen (slashp + 1)); 6587 memmove (slashp, slashp + 2, strlen (slashp + 1));
6583#else
6584 strcpy (slashp, slashp + 2);
6585#endif
6586 continue; 6588 continue;
6587 } 6589 }
6588 } 6590 }
@@ -6626,7 +6628,7 @@ filename_is_absolute (char *fn)
6626{ 6628{
6627 return (fn[0] == '/' 6629 return (fn[0] == '/'
6628#ifdef DOS_NT 6630#ifdef DOS_NT
6629 || (ISALPHA(fn[0]) && fn[1] == ':' && fn[2] == '/') 6631 || (ISALPHA (fn[0]) && fn[1] == ':' && fn[2] == '/')
6630#endif 6632#endif
6631 ); 6633 );
6632} 6634}
@@ -6641,7 +6643,7 @@ canonicalize_filename (register char *fn)
6641 6643
6642#ifdef DOS_NT 6644#ifdef DOS_NT
6643 /* Canonicalize drive letter case. */ 6645 /* Canonicalize drive letter case. */
6644# define ISUPPER(c) isupper (CHAR(c)) 6646# define ISUPPER(c) isupper (CHAR (c))
6645 if (fn[0] != '\0' && fn[1] == ':' && ISUPPER (fn[0])) 6647 if (fn[0] != '\0' && fn[1] == ':' && ISUPPER (fn[0]))
6646 fn[0] = lowcase (fn[0]); 6648 fn[0] = lowcase (fn[0]);
6647 6649
@@ -6686,7 +6688,7 @@ linebuffer_setlen (linebuffer *lbp, int toksize)
6686 6688
6687/* Like malloc but get fatal error if memory is exhausted. */ 6689/* Like malloc but get fatal error if memory is exhausted. */
6688static PTR 6690static PTR
6689xmalloc (unsigned int size) 6691xmalloc (size_t size)
6690{ 6692{
6691 PTR result = (PTR) malloc (size); 6693 PTR result = (PTR) malloc (size);
6692 if (result == NULL) 6694 if (result == NULL)
@@ -6695,7 +6697,7 @@ xmalloc (unsigned int size)
6695} 6697}
6696 6698
6697static PTR 6699static PTR
6698xrealloc (char *ptr, unsigned int size) 6700xrealloc (char *ptr, size_t size)
6699{ 6701{
6700 PTR result = (PTR) realloc (ptr, size); 6702 PTR result = (PTR) realloc (ptr, size);
6701 if (result == NULL) 6703 if (result == NULL)
diff --git a/lib-src/grep-changelog b/lib-src/grep-changelog
index 0c7c42dc7ce..5477de7b577 100755
--- a/lib-src/grep-changelog
+++ b/lib-src/grep-changelog
@@ -1,6 +1,6 @@
1#! /usr/bin/perl 1#! /usr/bin/perl
2 2
3# Copyright (C) 1999-2011 Free Software Foundation, Inc. 3# Copyright (C) 1999-2012 Free Software Foundation, Inc.
4# 4#
5# This file is part of GNU Emacs. 5# This file is part of GNU Emacs.
6 6
diff --git a/lib-src/hexl.c b/lib-src/hexl.c
index 89ea7d9f60c..f8fb11f8218 100644
--- a/lib-src/hexl.c
+++ b/lib-src/hexl.c
@@ -1,5 +1,5 @@
1/* Convert files for Emacs Hexl mode. 1/* Convert files for Emacs Hexl mode.
2 Copyright (C) 1989, 2001-2011 Free Software Foundation, Inc. 2 Copyright (C) 1989, 2001-2012 Free Software Foundation, Inc.
3 3
4Author: Keith Gabryelski 4Author: Keith Gabryelski
5(according to authors.el) 5(according to authors.el)
@@ -48,7 +48,7 @@ int base = DEFAULT_BASE, un_flag = FALSE, iso_flag = FALSE, endian = 1;
48int group_by = DEFAULT_GROUPING; 48int group_by = DEFAULT_GROUPING;
49char *progname; 49char *progname;
50 50
51void usage(void) NO_RETURN; 51void usage (void) NO_RETURN;
52 52
53int 53int
54main (int argc, char **argv) 54main (int argc, char **argv)
diff --git a/lib-src/make-docfile.c b/lib-src/make-docfile.c
index ba54202954b..3e79cae4f41 100644
--- a/lib-src/make-docfile.c
+++ b/lib-src/make-docfile.c
@@ -1,5 +1,5 @@
1/* Generate doc-string file for GNU Emacs from source files. 1/* Generate doc-string file for GNU Emacs from source files.
2 Copyright (C) 1985-1986, 1992-1994, 1997, 1999-2011 2 Copyright (C) 1985-1986, 1992-1994, 1997, 1999-2012
3 Free Software Foundation, Inc. 3 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
@@ -541,7 +541,7 @@ write_c_args (FILE *out, char *func, char *buf, int minargs, int maxargs)
541 maxargs--; 541 maxargs--;
542 542
543 /* In C code, `default' is a reserved word, so we spell it 543 /* In C code, `default' is a reserved word, so we spell it
544 `defalt'; unmangle that here. */ 544 `defalt'; demangle that here. */
545 if (ident_length == 6 && strncmp (ident_start, "defalt", 6) == 0) 545 if (ident_length == 6 && strncmp (ident_start, "defalt", 6) == 0)
546 fprintf (out, "DEFAULT"); 546 fprintf (out, "DEFAULT");
547 else 547 else
@@ -1149,8 +1149,10 @@ scan_lisp_file (const char *filename, const char *mode)
1149 } 1149 }
1150 } 1150 }
1151 1151
1152 /* defcustom can only occur in uncompiled Lisp files. */
1152 else if (! strcmp (buffer, "defvar") 1153 else if (! strcmp (buffer, "defvar")
1153 || ! strcmp (buffer, "defconst")) 1154 || ! strcmp (buffer, "defconst")
1155 || ! strcmp (buffer, "defcustom"))
1154 { 1156 {
1155 char c1 = 0, c2 = 0; 1157 char c1 = 0, c2 = 0;
1156 type = 'V'; 1158 type = 'V';
diff --git a/lib-src/makefile.w32-in b/lib-src/makefile.w32-in
index 07f6170afe4..117a835c03f 100644
--- a/lib-src/makefile.w32-in
+++ b/lib-src/makefile.w32-in
@@ -1,5 +1,5 @@
1# -*- Makefile -*- for GNU Emacs on the Microsoft W32 API. 1# -*- Makefile -*- for GNU Emacs on the Microsoft W32 API.
2# Copyright (C) 2000-2011 Free Software Foundation, Inc. 2# Copyright (C) 2000-2012 Free Software Foundation, Inc.
3 3
4# This file is part of GNU Emacs. 4# This file is part of GNU Emacs.
5 5
@@ -21,9 +21,9 @@ ALL = make-docfile hexl ctags etags movemail ebrowse emacsclient
21 21
22.PHONY: $(ALL) 22.PHONY: $(ALL)
23 23
24LOCAL_FLAGS = -DWINDOWSNT -DDOS_NT -DSTDC_HEADERS=1 -DNO_LDAV=1 \ 24LOCAL_FLAGS = -DWINDOWSNT -DDOS_NT -DNO_LDAV=1 \
25 -DNO_ARCHIVES=1 -DHAVE_CONFIG_H=1 -I../lib \ 25 -DNO_ARCHIVES=1 -DHAVE_CONFIG_H=1 -I../lib \
26 -I../nt/inc -I../src 26 -I../nt/inc -I../src $(EMACS_EXTRA_C_FLAGS)
27 27
28LIBS = $(BASE_LIBS) $(ADVAPI32) 28LIBS = $(BASE_LIBS) $(ADVAPI32)
29 29
diff --git a/lib-src/movemail.c b/lib-src/movemail.c
index e8c09f090f3..9d19df32814 100644
--- a/lib-src/movemail.c
+++ b/lib-src/movemail.c
@@ -1,7 +1,7 @@
1/* movemail foo bar -- move file foo to file bar, 1/* movemail foo bar -- move file foo to file bar,
2 locking file foo the way /bin/mail respects. 2 locking file foo the way /bin/mail respects.
3 3
4Copyright (C) 1986, 1992-1994, 1996, 1999, 2001-2011 4Copyright (C) 1986, 1992-1994, 1996, 1999, 2001-2012
5 Free Software Foundation, Inc. 5 Free Software Foundation, Inc.
6 6
7This file is part of GNU Emacs. 7This file is part of GNU Emacs.
@@ -68,9 +68,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
68#ifdef HAVE_FCNTL_H 68#ifdef HAVE_FCNTL_H
69#include <fcntl.h> 69#include <fcntl.h>
70#endif 70#endif
71#ifdef HAVE_STRING_H
72#include <string.h> 71#include <string.h>
73#endif
74#include "syswait.h" 72#include "syswait.h"
75#ifdef MAIL_USE_POP 73#ifdef MAIL_USE_POP
76#include "pop.h" 74#include "pop.h"
@@ -185,8 +183,8 @@ main (int argc, char **argv)
185# define ARGSTR "p" 183# define ARGSTR "p"
186#endif /* MAIL_USE_POP */ 184#endif /* MAIL_USE_POP */
187 185
188 uid_t real_gid = getgid(); 186 uid_t real_gid = getgid ();
189 uid_t priv_gid = getegid(); 187 uid_t priv_gid = getegid ();
190 188
191#ifdef WINDOWSNT 189#ifdef WINDOWSNT
192 /* Ensure all file i/o is in binary mode. */ 190 /* Ensure all file i/o is in binary mode. */
@@ -327,11 +325,10 @@ main (int argc, char **argv)
327 if (desc < 0) 325 if (desc < 0)
328 { 326 {
329 int mkstemp_errno = errno; 327 int mkstemp_errno = errno;
330 char *message = (char *) xmalloc (strlen (tempname) + 50); 328 error ("error while creating what would become the lock file",
331 sprintf (message, "creating %s, which would become the lock file", 329 0, 0);
332 tempname);
333 errno = mkstemp_errno; 330 errno = mkstemp_errno;
334 pfatal_with_name (message); 331 pfatal_with_name (tempname);
335 } 332 }
336 close (desc); 333 close (desc);
337 334
diff --git a/lib-src/ntlib.c b/lib-src/ntlib.c
index 83f653f3ea3..d3b001c157c 100644
--- a/lib-src/ntlib.c
+++ b/lib-src/ntlib.c
@@ -1,5 +1,5 @@
1/* Utility and Unix shadow routines for GNU Emacs support programs on NT. 1/* Utility and Unix shadow routines for GNU Emacs support programs on NT.
2 Copyright (C) 1994, 2001-2011 Free Software Foundation, Inc. 2 Copyright (C) 1994, 2001-2012 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
diff --git a/lib-src/ntlib.h b/lib-src/ntlib.h
index be8d2a58a50..7502a8a8b34 100644
--- a/lib-src/ntlib.h
+++ b/lib-src/ntlib.h
@@ -1,5 +1,5 @@
1/* Utility and Unix shadow routines for GNU Emacs support programs on NT. 1/* Utility and Unix shadow routines for GNU Emacs support programs on NT.
2 Copyright (C) 1994, 2002-2011 Free Software Foundation, Inc. 2 Copyright (C) 1994, 2002-2012 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
diff --git a/lib-src/pop.c b/lib-src/pop.c
index 426b39bd1fb..37494d17a44 100644
--- a/lib-src/pop.c
+++ b/lib-src/pop.c
@@ -1,6 +1,6 @@
1/* pop.c: client routines for talking to a POP3-protocol post-office server 1/* pop.c: client routines for talking to a POP3-protocol post-office server
2 2
3Copyright (C) 1991, 1993, 1996-1997, 1999, 2001-2011 3Copyright (C) 1991, 1993, 1996-1997, 1999, 2001-2012
4 Free Software Foundation, Inc. 4 Free Software Foundation, Inc.
5 5
6Author: Jonathan Kamens <jik@security.ov.com> 6Author: Jonathan Kamens <jik@security.ov.com>
@@ -34,15 +34,15 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
34#include "ntlib.h" 34#include "ntlib.h"
35#include <winsock.h> 35#include <winsock.h>
36#undef SOCKET_ERROR 36#undef SOCKET_ERROR
37#define RECV(s,buf,len,flags) recv(s,buf,len,flags) 37#define RECV(s,buf,len,flags) recv (s,buf,len,flags)
38#define SEND(s,buf,len,flags) send(s,buf,len,flags) 38#define SEND(s,buf,len,flags) send (s,buf,len,flags)
39#define CLOSESOCKET(s) closesocket(s) 39#define CLOSESOCKET(s) closesocket (s)
40#else 40#else
41#include <netinet/in.h> 41#include <netinet/in.h>
42#include <sys/socket.h> 42#include <sys/socket.h>
43#define RECV(s,buf,len,flags) read(s,buf,len) 43#define RECV(s,buf,len,flags) read (s,buf,len)
44#define SEND(s,buf,len,flags) write(s,buf,len) 44#define SEND(s,buf,len,flags) write (s,buf,len)
45#define CLOSESOCKET(s) close(s) 45#define CLOSESOCKET(s) close (s)
46#endif 46#endif
47#include <pop.h> 47#include <pop.h>
48 48
@@ -65,9 +65,7 @@ extern struct servent *hes_getservbyname (/* char *, char * */);
65#include <netdb.h> 65#include <netdb.h>
66#include <errno.h> 66#include <errno.h>
67#include <stdio.h> 67#include <stdio.h>
68#ifdef STDC_HEADERS
69#include <string.h> 68#include <string.h>
70#endif
71#include <unistd.h> 69#include <unistd.h>
72 70
73#ifdef KERBEROS 71#ifdef KERBEROS
@@ -103,7 +101,7 @@ extern char *krb_realmofhost (/* char * */);
103#endif /* KERBEROS */ 101#endif /* KERBEROS */
104 102
105#ifndef WINDOWSNT 103#ifndef WINDOWSNT
106#if !defined(HAVE_H_ERRNO) || !defined(HAVE_CONFIG_H) 104#if !defined (HAVE_H_ERRNO) || !defined (HAVE_CONFIG_H)
107extern int h_errno; 105extern int h_errno;
108#endif 106#endif
109#endif 107#endif
@@ -1069,7 +1067,7 @@ socket_connection (char *host, int flags)
1069 } 1067 }
1070 1068
1071#ifdef HAVE_GETADDRINFO 1069#ifdef HAVE_GETADDRINFO
1072 memset (&hints, 0, sizeof(hints)); 1070 memset (&hints, 0, sizeof (hints));
1073 hints.ai_socktype = SOCK_STREAM; 1071 hints.ai_socktype = SOCK_STREAM;
1074 hints.ai_flags = AI_CANONNAME; 1072 hints.ai_flags = AI_CANONNAME;
1075 hints.ai_family = AF_INET; 1073 hints.ai_family = AF_INET;
@@ -1161,7 +1159,7 @@ socket_connection (char *host, int flags)
1161 krb5_free_context (kcontext); 1159 krb5_free_context (kcontext);
1162 strcpy (pop_error, KRB_ERROR); 1160 strcpy (pop_error, KRB_ERROR);
1163 strncat (pop_error, error_message (rem), 1161 strncat (pop_error, error_message (rem),
1164 ERROR_MAX - sizeof(KRB_ERROR)); 1162 ERROR_MAX - sizeof (KRB_ERROR));
1165 CLOSESOCKET (sock); 1163 CLOSESOCKET (sock);
1166 return (-1); 1164 return (-1);
1167 } 1165 }
@@ -1214,7 +1212,7 @@ socket_connection (char *host, int flags)
1214 ERROR_MAX - strlen (pop_error) - 1); 1212 ERROR_MAX - strlen (pop_error) - 1);
1215 } 1213 }
1216#elif defined HAVE_KRB5_ERROR_E_TEXT 1214#elif defined HAVE_KRB5_ERROR_E_TEXT
1217 if (err_ret && err_ret->e_text && strlen(*err_ret->e_text)) 1215 if (err_ret && err_ret->e_text && strlen (*err_ret->e_text))
1218 { 1216 {
1219 strncat (pop_error, " [server says '", 1217 strncat (pop_error, " [server says '",
1220 ERROR_MAX - strlen (pop_error) - 1); 1218 ERROR_MAX - strlen (pop_error) - 1);
diff --git a/lib-src/pop.h b/lib-src/pop.h
index bc079fcc971..682a7f93dc5 100644
--- a/lib-src/pop.h
+++ b/lib-src/pop.h
@@ -1,5 +1,5 @@
1/* pop.h: Header file for the "pop.c" client POP3 protocol. 1/* pop.h: Header file for the "pop.c" client POP3 protocol.
2 Copyright (C) 1991, 1993, 2001-2011 Free Software Foundation, Inc. 2 Copyright (C) 1991, 1993, 2001-2012 Free Software Foundation, Inc.
3 3
4Author: Jonathan Kamens <jik@security.ov.com> 4Author: Jonathan Kamens <jik@security.ov.com>
5 5
diff --git a/lib-src/profile.c b/lib-src/profile.c
index 086d8cc3e9d..8ed4f318974 100644
--- a/lib-src/profile.c
+++ b/lib-src/profile.c
@@ -1,5 +1,5 @@
1/* profile.c --- generate periodic events for profiling of Emacs Lisp code. 1/* profile.c --- generate periodic events for profiling of Emacs Lisp code.
2 Copyright (C) 1992, 1994, 1999, 2001-2011 Free Software Foundation, Inc. 2 Copyright (C) 1992, 1994, 1999, 2001-2012 Free Software Foundation, Inc.
3 3
4Author: Boaz Ben-Zvi <boaz@lcs.mit.edu> 4Author: Boaz Ben-Zvi <boaz@lcs.mit.edu>
5 5
diff --git a/lib-src/rcs-checkin b/lib-src/rcs-checkin
index 6861a30b40b..57e91becf9d 100755
--- a/lib-src/rcs-checkin
+++ b/lib-src/rcs-checkin
@@ -2,7 +2,7 @@
2 2
3# This script accepts any number of file arguments and checks them into RCS. 3# This script accepts any number of file arguments and checks them into RCS.
4 4
5# Copyright (C) 1993-1995, 2001-2011 Free Software Foundation, Inc. 5# Copyright (C) 1993-1995, 2001-2012 Free Software Foundation, Inc.
6 6
7# This file is part of GNU Emacs. 7# This file is part of GNU Emacs.
8 8
diff --git a/lib-src/rcs2log b/lib-src/rcs2log
index 4e1dd306977..3ed54684a7e 100755
--- a/lib-src/rcs2log
+++ b/lib-src/rcs2log
@@ -2,7 +2,7 @@
2 2
3# RCS to ChangeLog generator 3# RCS to ChangeLog generator
4 4
5# Copyright (C) 1992-1998, 2001-2011 Free Software Foundation, Inc. 5# Copyright (C) 1992-1998, 2001-2012 Free Software Foundation, Inc.
6 6
7# Author: Paul Eggert <eggert@twinsun.com> 7# Author: Paul Eggert <eggert@twinsun.com>
8 8
@@ -20,7 +20,7 @@
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
23Copyright='Copyright (C) 2011 Free Software Foundation, Inc. 23Copyright='Copyright (C) 2012 Free Software Foundation, Inc.
24This program comes with NO WARRANTY, to the extent permitted by law. 24This program comes with NO WARRANTY, to the extent permitted by law.
25You may redistribute copies of this program 25You may redistribute copies of this program
26under the terms of the GNU General Public License. 26under the terms of the GNU General Public License.
diff --git a/lib-src/test-distrib.c b/lib-src/test-distrib.c
index 5ad19201118..b404c8230d1 100644
--- a/lib-src/test-distrib.c
+++ b/lib-src/test-distrib.c
@@ -1,6 +1,6 @@
1/* test-distrib.c --- testing distribution of nonprinting chars 1/* test-distrib.c --- testing distribution of nonprinting chars
2 2
3Copyright (C) 1987, 1993-1995, 1999, 2001-2011 Free Software Foundation, Inc. 3Copyright (C) 1987, 1993-1995, 1999, 2001-2012 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
diff --git a/lib-src/update-game-score.c b/lib-src/update-game-score.c
index e95e2ce259d..a32bd6d8d78 100644
--- a/lib-src/update-game-score.c
+++ b/lib-src/update-game-score.c
@@ -1,6 +1,6 @@
1/* update-game-score.c --- Update a score file 1/* update-game-score.c --- Update a score file
2 2
3Copyright (C) 2002-2011 Free Software Foundation, Inc. 3Copyright (C) 2002-2012 Free Software Foundation, Inc.
4 4
5Author: Colin Walters <walters@debian.org> 5Author: Colin Walters <walters@debian.org>
6 6
@@ -35,12 +35,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
35 35
36#include <unistd.h> 36#include <unistd.h>
37#include <errno.h> 37#include <errno.h>
38#ifdef HAVE_STRING_H 38#include <limits.h>
39#include <string.h> 39#include <string.h>
40#endif
41#ifdef HAVE_STDLIB_H
42#include <stdlib.h> 40#include <stdlib.h>
43#endif
44#include <stdio.h> 41#include <stdio.h>
45#include <time.h> 42#include <time.h>
46#include <pwd.h> 43#include <pwd.h>
@@ -48,9 +45,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
48#ifdef HAVE_FCNTL_H 45#ifdef HAVE_FCNTL_H
49#include <fcntl.h> 46#include <fcntl.h>
50#endif 47#endif
51#ifdef STDC_HEADERS
52#include <stdarg.h>
53#endif
54#include <sys/stat.h> 48#include <sys/stat.h>
55 49
56/* Needed for SunOS4, for instance. */ 50/* Needed for SunOS4, for instance. */
@@ -71,7 +65,7 @@ static int usage (int err) NO_RETURN;
71static int 65static int
72usage (int err) 66usage (int err)
73{ 67{
74 fprintf (stdout, "Usage: update-game-score [-m MAX ] [ -r ] game/scorefile SCORE DATA\n"); 68 fprintf (stdout, "Usage: update-game-score [-m MAX] [-r] [-d DIR] game/scorefile SCORE DATA\n");
75 fprintf (stdout, " update-game-score -h\n"); 69 fprintf (stdout, " update-game-score -h\n");
76 fprintf (stdout, " -h\t\tDisplay this help.\n"); 70 fprintf (stdout, " -h\t\tDisplay this help.\n");
77 fprintf (stdout, " -m MAX\t\tLimit the maximum number of scores to MAX.\n"); 71 fprintf (stdout, " -m MAX\t\tLimit the maximum number of scores to MAX.\n");
@@ -113,8 +107,7 @@ static void lose_syserr (const char *msg) NO_RETURN;
113#ifndef HAVE_STRERROR 107#ifndef HAVE_STRERROR
114#ifndef WINDOWSNT 108#ifndef WINDOWSNT
115char * 109char *
116strerror (errnum) 110strerror (int errnum)
117 int errnum;
118{ 111{
119 extern char *sys_errlist[]; 112 extern char *sys_errlist[];
120 extern int sys_nerr; 113 extern int sys_nerr;
@@ -136,19 +129,13 @@ lose_syserr (const char *msg)
136static char * 129static char *
137get_user_id (void) 130get_user_id (void)
138{ 131{
139 char *name;
140 struct passwd *buf = getpwuid (getuid ()); 132 struct passwd *buf = getpwuid (getuid ());
141 if (!buf) 133 if (!buf)
142 { 134 {
143 int count = 1; 135 long uid = getuid ();
144 int uid = (int) getuid (); 136 char *name = malloc (sizeof uid * CHAR_BIT / 3 + 1);
145 int tuid = uid; 137 if (name)
146 while (tuid /= 10) 138 sprintf (name, "%ld", uid);
147 count++;
148 name = malloc (count+1);
149 if (!name)
150 return NULL;
151 sprintf (name, "%d", uid);
152 return name; 139 return name;
153 } 140 }
154 return buf->pw_name; 141 return buf->pw_name;
@@ -359,7 +346,7 @@ read_scores (const char *filename, struct score_entry **scores, int *count)
359 return -1; 346 return -1;
360 while ((readval = read_score (f, &ret[scorecount])) == 0) 347 while ((readval = read_score (f, &ret[scorecount])) == 0)
361 { 348 {
362 /* We encoutered an error */ 349 /* We encountered an error. */
363 if (readval < 0) 350 if (readval < 0)
364 return -1; 351 return -1;
365 scorecount++; 352 scorecount++;
diff --git a/lib-src/vcdiff b/lib-src/vcdiff
index 0f975cd0ee3..dd7ca446d7c 100755
--- a/lib-src/vcdiff
+++ b/lib-src/vcdiff
@@ -3,7 +3,7 @@
3# Enhanced sccs diff utility for use with vc mode. 3# Enhanced sccs diff utility for use with vc mode.
4# This version is more compatible with rcsdiff(1). 4# This version is more compatible with rcsdiff(1).
5 5
6# Copyright (C) 1992-1993, 1995, 1997, 2001-2011 6# Copyright (C) 1992-1993, 1995, 1997, 2001-2012
7# Free Software Foundation, Inc. 7# Free Software Foundation, Inc.
8 8
9# Author: Paul Eggert 9# Author: Paul Eggert