aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src
diff options
context:
space:
mode:
authorJoakim Verona2011-02-05 11:23:09 +0100
committerJoakim Verona2011-02-05 11:23:09 +0100
commit4bd51ad5c3445b644dfb017d5b57b10a90aa325f (patch)
tree894801e7308ce4ecc34933f959e28f4b9cff9533 /lib-src
parent13cfe8df462ab8da9f0028e16cc84dcaceaca3d1 (diff)
parent9bcaafce5351d270ac514e23cb69ff1a5fd35229 (diff)
downloademacs-4bd51ad5c3445b644dfb017d5b57b10a90aa325f.tar.gz
emacs-4bd51ad5c3445b644dfb017d5b57b10a90aa325f.zip
merge from upstream. currently seems to have bitroted and i get segfaults
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/.gitignore2
-rw-r--r--lib-src/ChangeLog155
-rw-r--r--lib-src/Makefile.in66
-rw-r--r--lib-src/digest-doc.c81
-rw-r--r--lib-src/ebrowse.c20
-rw-r--r--lib-src/emacsclient.c18
-rw-r--r--lib-src/etags.c13
-rw-r--r--lib-src/fakemail.c7
-rw-r--r--lib-src/getopt.c1245
-rw-r--r--lib-src/getopt1.c177
-rw-r--r--lib-src/getopt_.h230
-rw-r--r--lib-src/getopt_int.h134
-rw-r--r--lib-src/gettext.h82
-rwxr-xr-xlib-src/grep-changelog4
-rw-r--r--lib-src/hexl.c13
-rw-r--r--lib-src/make-docfile.c32
-rw-r--r--lib-src/makefile.w32-in90
-rw-r--r--lib-src/movemail.c20
-rw-r--r--lib-src/ntlib.c7
-rw-r--r--lib-src/ntlib.h7
-rw-r--r--lib-src/pop.c10
-rw-r--r--lib-src/pop.h5
-rw-r--r--lib-src/profile.c5
-rwxr-xr-xlib-src/rcs-checkin4
-rwxr-xr-xlib-src/rcs2log7
-rw-r--r--lib-src/sorted-doc.c296
-rw-r--r--lib-src/test-distrib.c20
-rw-r--r--lib-src/update-game-score.c7
-rwxr-xr-xlib-src/vcdiff5
29 files changed, 267 insertions, 2495 deletions
diff --git a/lib-src/.gitignore b/lib-src/.gitignore
index c111257cc9a..e1693b13c5e 100644
--- a/lib-src/.gitignore
+++ b/lib-src/.gitignore
@@ -6,5 +6,3 @@ echolisp.tmp
6 6
7oo/ 7oo/
8oo-spd/ 8oo-spd/
9
10# arch-tag: bcd85c02-f779-4fe6-bd45-97a21150aadc
diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog
index 0f24b234972..3f4e4b1b9ff 100644
--- a/lib-src/ChangeLog
+++ b/lib-src/ChangeLog
@@ -1,3 +1,143 @@
12011-02-05 Paul Eggert <eggert@cs.ucla.edu>
2
3 * emacsclient.c: conform to C89 pointer rules
4 (file_name_absolute_p): Accept const char *, not const unsigned
5 char *, to satisfy C89 rules.
6
72011-02-02 Eli Zaretskii <eliz@gnu.org>
8
9 * makefile.w32-in (ETAGS_CFLAGS, CTAGS_CFLAGS): Add
10 ``-DEMACS_NAME="\"GNU Emacs\""''.
11 (obj): Remove strftime.o.
12
132011-01-31 Eli Zaretskii <eliz@gnu.org>
14
15 * makefile.w32-in (VERSION): Don't define, defined on nt/config.nt.
16 (ECLIENT_CFLAGS): Remove -DVERSION.
17 ($(BLD)/emacsclient.$(O)): Don't depend on makefile.w32-in.
18
192011-01-31 Paul Eggert <eggert@cs.ucla.edu>
20
21 src/emacs.c now gets version number from configure.in
22 * ebrowse.c: Adjust comment to say that.
23
242011-01-30 Jim Meyering <meyering@redhat.com>
25
26 make-docfile: don't corrupt heap for an invalid .elc file
27 "printf '#@1a' > in.elc; ./make-docfile in.elc" would store 0
28 one byte before just-malloc'd saved_string buffer.
29 * make-docfile.c (scan_lisp_file): Diagnose an invalid dynamic
30 doc string length. Also fix an always-false while-loop test.
31
322011-01-29 Eli Zaretskii <eliz@gnu.org>
33
34 * makefile.w32-in (LOCAL_FLAGS): Add -I../lib.
35 (GETOPTOBJS, GETOPTDEPS): Remove targets.
36 (MOVEMAILOBJS): Replace $(GETOPTOBJS) with ../lib/$(BLD)/libgnu.$(A).
37 ($(BLD)/movemail.exe): Depend on ../lib/getopt.h.
38 (ECLIENTOBJS, ETAGSOBJ, CTAGSOBJ, EBROWSEOBJ): Replace getopt.o
39 and getopt1.o with ../lib/$(BLD)/libgnu.$(A).
40 (clean): Don't remove getopt.h.
41 (getopt.h, $(BLD)/getopt.$(O), $(BLD)/getopt1.$(O)): Remove targets.
42 ($(BLD)/ctags.$(O), $(BLD)/etags.$(O)): Replace getopt.h with
43 $(EMACS_ROOT)/lib/getopt.h.
44
452011-01-28 Chong Yidong <cyd@stupidchicken.com>
46
47 * ntlib.c (setregid): New stub, renamed from setegid.
48
49 * ntlib.h: Update prototype.
50
512011-01-25 Chong Yidong <cyd@stupidchicken.com>
52
53 * movemail.c (main): Use setregid instead of setegid, which is
54 missing on older systems. Suggested by Peter O'Gorman (Bug#6811).
55
562011-01-23 Paul Eggert <eggert@cs.ucla.edu>
57
58 Check return values of some library calls.
59 * hexl.c (main): Check fread result.
60 * make-docfile.c (main): Check chdir result.
61 (scan_c_file): Check fscanf result.
62 * movemail.c (main): Check ftruncate result.
63
642011-01-17 Paul Eggert <eggert@cs.ucla.edu>
65
66 Include <unistd.h> unilaterally.
67 * emacsclient.c, etags.c, fakemail.c, make-docfile.c, movemail.c:
68 * pop.c, test-distrib.c, update-game-score.c:
69 Include <unistd.h> without worrying about HAVE_UNISTD_H, since
70 unistd.h is always present now, possibly supplied by gnulib.
71
72 Include <getopt.h> not "getopt.h".
73 * ebrowse.c, emacsclient.c: Include <getopt.h>, not "getopt.h".
74 Since getopt.h is no longer in this directory, there's no point
75 using the form with double-quotes.
76
77 Remove unused files.
78 * getopt.c, getopt1.c, getopt_.h, getopt_int.h: Remove.
79 These files are now in ../lib, copied from gnulib.
80
81 Use gnulib's getopt-gnu module.
82 * Makefile.in (mostlyclean): Do not clean getopt.h or getopt.h-t,
83 as these are now done by gnulib.
84 (GETOPT_H, getopt.h, GETOPTOBJS, GETOPTDEPS, getopt.o, getopt1.o):
85 Remove; now done by gnulib. All uses removed.
86
87 Automate syncing from gnulib.
88 * Makefile.in (EXE_FILES): New macro.
89 (BASE_CFLAGS): Add -I../lib and -I${srcdir}/../lib,
90 for gnulib's .h files.
91 (LOADLIBES): Add ../lib/libgnu.a.
92 ($(EXE_FILES)): Depend on ../lib/libgnu.a.
93 (../lib/libgnu.a): New rule.
94
952011-01-08 Paul Eggert <eggert@cs.ucla.edu>
96
97 * Makefile.in (EXECUTABLES): Remove; macro unused since 1993.
98
992011-01-08 Glenn Morris <rgm@gnu.org>
100
101 * Makefile.in (EMACSOPT): Add --no-site-lisp.
102
103 * Makefile.in (EMACSOPT): Remove --multibyte, it does nothing any more.
104
1052011-01-02 Glenn Morris <rgm@gnu.org>
106
107 * ebrowse.c (version) <emacs_copyright>:
108 * etags.c (print_version) <emacs_copyright>:
109 * rcs2log (Copyright): Set short copyright year to 2011.
110
1112010-11-27 Joe Matarazzo <joe.matarazzo@gmail.com> (tiny change)
112
113 * ebrowse.c (yylex): If end of input buffer encountered while
114 searching for a newline after "//", return YYEOF. (Bug#7446)
115
1162010-11-18 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
117
118 * emacsclient.c (set_local_socket) [DARWIN_OS]: Add fall-back
119 definition of _CS_DARWIN_USER_TEMP_DIR for Mac OS X 10.4 and older.
120
1212010-11-15 Dan Nicolaescu <dann@ics.uci.edu>
122
123 * test-distrib.c: Remove include guards for config.h and fcntl.h.
124 (O_RDONLY): Do not define.
125 (cool_read): Fix type for variable "sofar".
126
1272010-10-25 Glenn Morris <rgm@gnu.org>
128
129 * makefile.w32-in (OTHER_PLATFORM_SUPPORT): Remove easymenu.elc.
130
1312010-10-23 Glenn Morris <rgm@gnu.org>
132
133 * digest-doc.c, sorted-doc.c: Remove files.
134 * Makefile.in (UTILITIES): Remove digest-doc and sorted-doc.
135 (digest-doc${EXEEXT}, sorted-doc${EXEEXT}): Remove rules.
136 * makefile.w32-in (ALL): Remove digest-doc and sorted-doc.
137 ($(BLD)/sorted-doc.exe, $(BLD)/digest-doc.exe, sorted-doc, digest-doc)
138 ($(BLD)/digest-doc.$(O), $(BLD)/sorted-doc.$(O)): Remove rules.
139 (install): Don't install digest-doc.exe or sorted-doc.exe.
140
12010-10-10 Dan Nicolaescu <dann@ics.uci.edu> 1412010-10-10 Dan Nicolaescu <dann@ics.uci.edu>
2 142
3 * Makefile.in (PROFILING_LDFLAGS): Remove, not needed. 143 * Makefile.in (PROFILING_LDFLAGS): Remove, not needed.
@@ -5376,10 +5516,10 @@
5376 (main): Improve usage message. 5516 (main): Improve usage message.
5377 (error): Write to stderr, not stdout. 5517 (error): Write to stderr, not stdout.
5378 5518
5379 * b2m.c cvtmail.c digest-doc.c emacsclient.c emacsserver.c etags.c 5519 * b2m.c, cvtmail.c, digest-doc.c, emacsclient.c, emacsserver.c:
5380 fakemail.c hexl.c make-docfile.c profile.c sorted-doc.c test-distrib.c 5520 * etags.c, fakemail.c, hexl.c, make-docfile.c, profile.c, sorted-doc.c:
5381 timer.c wakeup.c yow.c: Eliminate some -Wall warnings from unused 5521 * test-distrib.c, timer.c, wakeup.c, yow.c: Eliminate some -Wall
5382 variables and implicitly declared functions. 5522 warnings from unused variables and implicitly declared functions.
5383 5523
53841994-10-11 Richard Stallman <rms@mole.gnu.ai.mit.edu> 55241994-10-11 Richard Stallman <rms@mole.gnu.ai.mit.edu>
5385 5525
@@ -7387,12 +7527,9 @@
7387 7527
7388;; Local Variables: 7528;; Local Variables:
7389;; coding: utf-8 7529;; coding: utf-8
7390;; add-log-time-zone-rule: t
7391;; End: 7530;; End:
7392 7531
7393 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 7532 Copyright (C) 1988-1999, 2001-2011 Free Software Foundation, Inc.
7394 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004, 2005, 2006,
7395 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
7396 7533
7397 This file is part of GNU Emacs. 7534 This file is part of GNU Emacs.
7398 7535
@@ -7408,5 +7545,3 @@
7408 7545
7409 You should have received a copy of the GNU General Public License 7546 You should have received a copy of the GNU General Public License
7410 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. 7547 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
7411
7412;;; arch-tag: 2d979296-954c-448e-95c1-b46d134513dc
diff --git a/lib-src/Makefile.in b/lib-src/Makefile.in
index b90b19b69b6..96975613104 100644
--- a/lib-src/Makefile.in
+++ b/lib-src/Makefile.in
@@ -1,6 +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, 2002, 2003, 2004, 2# Copyright (C) 1985, 1987-1988, 1993-1994, 2001-2011
3# 2005, 2006, 2007, 2008, 2009, 2010
4# Free Software Foundation, Inc. 3# Free Software Foundation, Inc.
5 4
6# This file is part of GNU Emacs. 5# This file is part of GNU Emacs.
@@ -25,7 +24,7 @@ SHELL = /bin/sh
25 24
26# Following ../lisp/Makefile.in. 25# Following ../lisp/Makefile.in.
27EMACS = ../src/emacs 26EMACS = ../src/emacs
28EMACSOPT = -batch --no-site-file --multibyte 27EMACSOPT = -batch --no-site-file --no-site-lisp
29 28
30# ==================== Things `configure' will edit ==================== 29# ==================== Things `configure' will edit ====================
31 30
@@ -118,8 +117,7 @@ STAMP_INST_SCRIPTS = stamp-rcs-checkin stamp-grep-changelog
118 117
119# Things that Emacs runs internally, or during the build process, 118# Things that Emacs runs internally, or during the build process,
120# which should not be installed in bindir. 119# which should not be installed in bindir.
121UTILITIES = profile${EXEEXT} digest-doc${EXEEXT} sorted-doc${EXEEXT} \ 120UTILITIES = profile${EXEEXT} movemail${EXEEXT} fakemail${EXEEXT} \
122 movemail${EXEEXT} fakemail${EXEEXT} \
123 hexl${EXEEXT} update-game-score${EXEEXT} 121 hexl${EXEEXT} update-game-score${EXEEXT}
124 122
125DONT_INSTALL= test-distrib${EXEEXT} make-docfile${EXEEXT} 123DONT_INSTALL= test-distrib${EXEEXT} make-docfile${EXEEXT}
@@ -129,7 +127,8 @@ DONT_INSTALL= test-distrib${EXEEXT} make-docfile${EXEEXT}
129SCRIPTS= rcs2log vcdiff 127SCRIPTS= rcs2log vcdiff
130STAMP_SCRIPTS= stamp-rcs2log stamp-vcdiff 128STAMP_SCRIPTS= stamp-rcs2log stamp-vcdiff
131 129
132EXECUTABLES= ${UTILITIES} ${INSTALLABLES} ${SCRIPTS} ${INSTALLABLE_SCRIPTS} 130# All files that are created by the linker, i.e., whose names end in ${EXEEXT}.
131EXE_FILES = ${INSTALLABLES} ${UTILITIES} ${DONT_INSTALL}
133 132
134# Specify additional -D flags for movemail. Options: 133# Specify additional -D flags for movemail. Options:
135# -DMAIL_USE_FLOCK or -DMAIL_USE_LOCKF (use flock or lockf for file locking). 134# -DMAIL_USE_FLOCK or -DMAIL_USE_LOCKF (use flock or lockf for file locking).
@@ -169,13 +168,15 @@ LIBS_SYSTEM = @LIBS_SYSTEM@
169# defined before they know they can take advantage of the information 168# defined before they know they can take advantage of the information
170# in ../src/config.h. 169# in ../src/config.h.
171BASE_CFLAGS = $(C_SWITCH_SYSTEM) $(C_SWITCH_MACHINE) ${C_WARNINGS_SWITCH} \ 170BASE_CFLAGS = $(C_SWITCH_SYSTEM) $(C_SWITCH_MACHINE) ${C_WARNINGS_SWITCH} \
172 -DHAVE_CONFIG_H -I. -I../src -I${srcdir} -I${srcdir}/../src 171 -DHAVE_CONFIG_H -I. -I../src -I../lib \
172 -I${srcdir} -I${srcdir}/../src -I${srcdir}/../lib
173 173
174ALL_CFLAGS = ${BASE_CFLAGS} ${PROFILING_CFLAGS} ${LDFLAGS} ${CPPFLAGS} ${CFLAGS} 174ALL_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
178LOADLIBES=$(LIBS_SYSTEM) 178LOADLIBES = ../lib/libgnu.a $(LIBS_SYSTEM)
179$(EXE_FILES): ../lib/libgnu.a
179 180
180## This is the default compilation command. 181## This is the default compilation command.
181## But we should never rely on it, because some make version failed to 182## But we should never rely on it, because some make version failed to
@@ -277,7 +278,7 @@ uninstall:
277 fi 278 fi
278 279
279mostlyclean: 280mostlyclean:
280 -rm -f core *.o getopt.h getopt.h-t 281 -rm -f core *.o
281 282
282clean: mostlyclean 283clean: mostlyclean
283 -rm -f ${INSTALLABLES} ${UTILITIES} ${DONT_INSTALL} 284 -rm -f ${INSTALLABLES} ${UTILITIES} ${DONT_INSTALL}
@@ -309,19 +310,8 @@ test-distrib${EXEEXT}: ${srcdir}/test-distrib.c
309 $(CC) ${ALL_CFLAGS} -o test-distrib ${srcdir}/test-distrib.c 310 $(CC) ${ALL_CFLAGS} -o test-distrib ${srcdir}/test-distrib.c
310 ./test-distrib ${srcdir}/testfile 311 ./test-distrib ${srcdir}/testfile
311 312
312## We need the following in order to create a <getopt.h> when the system 313../lib/libgnu.a: ../src/config.h
313## does not have one that works with the given compiler. 314 cd ../lib && $(MAKE) libgnu.a
314GETOPT_H = @GETOPT_H@
315getopt.h: getopt_.h
316 cp $(srcdir)/getopt_.h $@-t
317 mv $@-t $@
318
319GETOPTOBJS = @GETOPTOBJS@
320GETOPTDEPS = $(GETOPTOBJS) $(GETOPT_H)
321getopt.o: ${srcdir}/getopt.c $(GETOPT_H) ${srcdir}/gettext.h
322 ${CC} -c ${CPP_CFLAGS} ${srcdir}/getopt.c
323getopt1.o: ${srcdir}/getopt1.c $(GETOPT_H)
324 ${CC} -c ${CPP_CFLAGS} ${srcdir}/getopt1.c
325 315
326REGEXPOBJ = regex.o 316REGEXPOBJ = regex.o
327REGEXPDEPS = $(REGEXPOBJ) $(srcdir)/../src/regex.h 317REGEXPDEPS = $(REGEXPOBJ) $(srcdir)/../src/regex.h
@@ -330,20 +320,20 @@ regex.o: $(srcdir)/../src/regex.c $(srcdir)/../src/regex.h ../src/config.h
330 ${CC} -c ${CPP_CFLAGS} -DCONFIG_BROKETS -DINHIBIT_STRING_HEADER \ 320 ${CC} -c ${CPP_CFLAGS} -DCONFIG_BROKETS -DINHIBIT_STRING_HEADER \
331 ${srcdir}/../src/regex.c 321 ${srcdir}/../src/regex.c
332 322
333etags${EXEEXT}: ${srcdir}/etags.c $(GETOPTDEPS) $(REGEXPDEPS) ../src/config.h 323etags${EXEEXT}: ${srcdir}/etags.c $(REGEXPDEPS) ../src/config.h
334 $(CC) ${ALL_CFLAGS} -DEMACS_NAME="\"GNU Emacs\"" \ 324 $(CC) ${ALL_CFLAGS} -DEMACS_NAME="\"GNU Emacs\"" \
335 -DVERSION="\"${version}\"" ${srcdir}/etags.c $(GETOPTOBJS) \ 325 -DVERSION="\"${version}\"" ${srcdir}/etags.c \
336 $(REGEXPOBJ) $(LOADLIBES) -o etags 326 $(REGEXPOBJ) $(LOADLIBES) -o etags
337 327
338ebrowse${EXEEXT}: ${srcdir}/ebrowse.c $(GETOPTDEPS) ../src/config.h 328ebrowse${EXEEXT}: ${srcdir}/ebrowse.c ../src/config.h
339 $(CC) ${ALL_CFLAGS} -DVERSION="\"${version}\"" \ 329 $(CC) ${ALL_CFLAGS} -DVERSION="\"${version}\"" \
340 ${srcdir}/ebrowse.c $(GETOPTOBJS) $(LOADLIBES) -o ebrowse 330 ${srcdir}/ebrowse.c $(LOADLIBES) -o ebrowse
341 331
342## We depend on etags to assure that parallel makes do not write two 332## We depend on etags to assure that parallel makes do not write two
343## etags.o files on top of each other. 333## etags.o files on top of each other.
344ctags${EXEEXT}: etags${EXEEXT} 334ctags${EXEEXT}: etags${EXEEXT}
345 $(CC) ${ALL_CFLAGS} -DCTAGS -DEMACS_NAME="\"GNU Emacs\"" \ 335 $(CC) ${ALL_CFLAGS} -DCTAGS -DEMACS_NAME="\"GNU Emacs\"" \
346 -DVERSION="\"${version}\"" ${srcdir}/etags.c $(GETOPTOBJS) \ 336 -DVERSION="\"${version}\"" ${srcdir}/etags.c \
347 $(REGEXPOBJ) $(LOADLIBES) -o ctags 337 $(REGEXPOBJ) $(LOADLIBES) -o ctags
348 338
349profile${EXEEXT}: ${srcdir}/profile.c ../src/config.h 339profile${EXEEXT}: ${srcdir}/profile.c ../src/config.h
@@ -353,17 +343,11 @@ make-docfile${EXEEXT}: ${srcdir}/make-docfile.c ../src/config.h
353 $(CC) ${ALL_CFLAGS} ${srcdir}/make-docfile.c $(LOADLIBES) \ 343 $(CC) ${ALL_CFLAGS} ${srcdir}/make-docfile.c $(LOADLIBES) \
354 -o make-docfile 344 -o make-docfile
355 345
356digest-doc${EXEEXT}: ${srcdir}/digest-doc.c 346movemail${EXEEXT}: movemail.o pop.o
357 $(CC) ${ALL_CFLAGS} ${srcdir}/digest-doc.c $(LOADLIBES) -o digest-doc
358
359sorted-doc${EXEEXT}: ${srcdir}/sorted-doc.c
360 $(CC) ${ALL_CFLAGS} ${srcdir}/sorted-doc.c $(LOADLIBES) -o sorted-doc
361
362movemail${EXEEXT}: movemail.o pop.o $(GETOPTDEPS)
363 $(CC) ${LINK_CFLAGS} ${MOVE_FLAGS} movemail.o pop.o \ 347 $(CC) ${LINK_CFLAGS} ${MOVE_FLAGS} movemail.o pop.o \
364 $(GETOPTOBJS) $(LOADLIBES) $(LIBS_MOVE) -o movemail 348 $(LOADLIBES) $(LIBS_MOVE) -o movemail
365 349
366movemail.o: ${srcdir}/movemail.c ../src/config.h $(GETOPT_H) 350movemail.o: ${srcdir}/movemail.c ../src/config.h
367 $(CC) -c ${CPP_CFLAGS} ${MOVE_FLAGS} ${srcdir}/movemail.c 351 $(CC) -c ${CPP_CFLAGS} ${MOVE_FLAGS} ${srcdir}/movemail.c
368 352
369pop.o: ${srcdir}/pop.c ../src/config.h 353pop.o: ${srcdir}/pop.c ../src/config.h
@@ -372,19 +356,19 @@ pop.o: ${srcdir}/pop.c ../src/config.h
372fakemail${EXEEXT}: ${srcdir}/fakemail.c ../src/config.h 356fakemail${EXEEXT}: ${srcdir}/fakemail.c ../src/config.h
373 $(CC) ${ALL_CFLAGS} ${srcdir}/fakemail.c $(LOADLIBES) -o fakemail 357 $(CC) ${ALL_CFLAGS} ${srcdir}/fakemail.c $(LOADLIBES) -o fakemail
374 358
375emacsclient${EXEEXT}: ${srcdir}/emacsclient.c ../src/config.h $(GETOPTDEPS) 359emacsclient${EXEEXT}: ${srcdir}/emacsclient.c ../src/config.h
376 $(CC) ${ALL_CFLAGS} ${srcdir}/emacsclient.c $(GETOPTOBJS) \ 360 $(CC) ${ALL_CFLAGS} ${srcdir}/emacsclient.c \
377 -DVERSION="\"${version}\"" \ 361 -DVERSION="\"${version}\"" \
378 $(LOADLIBES) -o emacsclient 362 $(LOADLIBES) -o emacsclient
379 363
380hexl${EXEEXT}: ${srcdir}/hexl.c ../src/config.h 364hexl${EXEEXT}: ${srcdir}/hexl.c ../src/config.h
381 $(CC) ${ALL_CFLAGS} ${srcdir}/hexl.c $(LOADLIBES) -o hexl 365 $(CC) ${ALL_CFLAGS} ${srcdir}/hexl.c $(LOADLIBES) -o hexl
382 366
383update-game-score${EXEEXT}: update-game-score.o $(GETOPTDEPS) 367update-game-score${EXEEXT}: update-game-score.o
384 $(CC) ${LINK_CFLAGS} update-game-score.o $(GETOPTOBJS) \ 368 $(CC) ${LINK_CFLAGS} update-game-score.o \
385 $(LOADLIBES) -o update-game-score 369 $(LOADLIBES) -o update-game-score
386 370
387update-game-score.o: ${srcdir}/update-game-score.c ../src/config.h $(GETOPT_H) 371update-game-score.o: ${srcdir}/update-game-score.c ../src/config.h
388 $(CC) -c ${CPP_CFLAGS} ${srcdir}/update-game-score.c \ 372 $(CC) -c ${CPP_CFLAGS} ${srcdir}/update-game-score.c \
389 -DHAVE_SHARED_GAME_DIR="\"$(gamedir)\"" 373 -DHAVE_SHARED_GAME_DIR="\"$(gamedir)\""
390 374
diff --git a/lib-src/digest-doc.c b/lib-src/digest-doc.c
deleted file mode 100644
index b3cb58e6d99..00000000000
--- a/lib-src/digest-doc.c
+++ /dev/null
@@ -1,81 +0,0 @@
1/* Give this program DOC-mm.nn.oo as standard input and it outputs to
2 standard output a file of nroff output containing the doc strings.
3
4Copyright (C) 1987, 1994, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
5 2008, 2009, 2010 Free Software Foundation, Inc.
6
7This file is part of GNU Emacs.
8
9GNU Emacs is free software: you can redistribute it and/or modify
10it under the terms of the GNU General Public License as published by
11the Free Software Foundation, either version 3 of the License, or
12(at your option) any later version.
13
14GNU Emacs is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License
20along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
21
22
23See also sorted-doc.c, which produces similar output
24but in texinfo format and sorted by function/variable name. */
25
26#include <stdio.h>
27
28#ifdef DOS_NT
29#include <fcntl.h> /* for O_BINARY */
30#include <io.h> /* for setmode */
31#endif
32
33int
34main (void)
35{
36 register int ch;
37 register int notfirst = 0;
38
39#ifdef DOS_NT
40 /* DOC is a binary file. */
41 if (!isatty (fileno (stdin)))
42 setmode (fileno (stdin), O_BINARY);
43#endif
44
45 printf (".TL\n");
46 printf ("Command Summary for GNU Emacs\n");
47 printf (".AU\nRichard M. Stallman\n");
48 while ((ch = getchar ()) != EOF)
49 {
50 if (ch == '\037')
51 {
52 if (notfirst)
53 printf ("\n.DE");
54 else
55 notfirst = 1;
56
57 printf ("\n.SH\n");
58
59 ch = getchar ();
60 printf (ch == 'F' ? "Function " : "Variable ");
61
62 while ((ch = getchar ()) != '\n') /* Changed this line */
63 {
64 if (ch != EOF)
65 putchar (ch);
66 else
67 {
68 ungetc (ch, stdin);
69 break;
70 }
71 }
72 printf ("\n.DS L\n");
73 }
74 else
75 putchar (ch);
76 }
77 return 0;
78}
79
80/* arch-tag: 2ba2c9b0-4157-4eba-bd9f-967e3677e35f
81 (do not change this comment) */
diff --git a/lib-src/ebrowse.c b/lib-src/ebrowse.c
index 1fcbb8662f5..59a1dde7634 100644
--- a/lib-src/ebrowse.c
+++ b/lib-src/ebrowse.c
@@ -1,8 +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, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 3Copyright (C) 1992-2011 Free Software Foundation, Inc.
4 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
5 Free Software Foundation, Inc.
6 4
7This file is part of GNU Emacs. 5This file is part of GNU Emacs.
8 6
@@ -30,7 +28,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
30#include <string.h> 28#include <string.h>
31#include <ctype.h> 29#include <ctype.h>
32#include <assert.h> 30#include <assert.h>
33#include "getopt.h" 31#include <getopt.h>
34 32
35/* The SunOS compiler doesn't have SEEK_END. */ 33/* The SunOS compiler doesn't have SEEK_END. */
36#ifndef SEEK_END 34#ifndef SEEK_END
@@ -1700,6 +1698,11 @@ yylex (void)
1700 case '/': 1698 case '/':
1701 while (GET (c) && c != '\n') 1699 while (GET (c) && c != '\n')
1702 ; 1700 ;
1701 /* Don't try to read past the end of the input buffer if
1702 the file ends in a C++ comment without a newline. */
1703 if (c == 0)
1704 return YYEOF;
1705
1703 INCREMENT_LINENO; 1706 INCREMENT_LINENO;
1704 break; 1707 break;
1705 1708
@@ -3562,7 +3565,7 @@ usage (int error)
3562 3565
3563 3566
3564/* Display version and copyright info. The VERSION macro is set 3567/* Display version and copyright info. The VERSION macro is set
3565 from the Makefile and contains the Emacs version. */ 3568 from config.h and contains the Emacs version. */
3566 3569
3567#ifndef VERSION 3570#ifndef VERSION
3568# define VERSION "21" 3571# define VERSION "21"
@@ -3572,7 +3575,7 @@ void
3572version (void) 3575version (void)
3573{ 3576{
3574 /* Makes it easier to update automatically. */ 3577 /* Makes it easier to update automatically. */
3575 char emacs_copyright[] = "Copyright (C) 2010 Free Software Foundation, Inc."; 3578 char emacs_copyright[] = "Copyright (C) 2011 Free Software Foundation, Inc.";
3576 3579
3577 printf ("ebrowse %s\n", VERSION); 3580 printf ("ebrowse %s\n", VERSION);
3578 puts (emacs_copyright); 3581 puts (emacs_copyright);
@@ -3809,7 +3812,7 @@ main (int argc, char **argv)
3809 yyerror ("error getting size of file `%s'", out_filename); 3812 yyerror ("error getting size of file `%s'", out_filename);
3810 exit (EXIT_FAILURE); 3813 exit (EXIT_FAILURE);
3811 } 3814 }
3812 3815
3813 else if (rc == 0) 3816 else if (rc == 0)
3814 { 3817 {
3815 yyerror ("file `%s' is empty", out_filename); 3818 yyerror ("file `%s' is empty", out_filename);
@@ -3872,7 +3875,4 @@ main (int argc, char **argv)
3872 return EXIT_SUCCESS; 3875 return EXIT_SUCCESS;
3873} 3876}
3874 3877
3875/* arch-tag: fc03b4bc-91a9-4c3d-b3b9-12a77fa86dd8
3876 (do not change this comment) */
3877
3878/* ebrowse.c ends here */ 3878/* ebrowse.c ends here */
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c
index b60b2661805..e5484b987e2 100644
--- a/lib-src/emacsclient.c
+++ b/lib-src/emacsclient.c
@@ -1,6 +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, 2000, 2001, 2002, 2003, 2004, 2 Copyright (C) 1986-1987, 1994, 1999-2011 Free Software Foundation, Inc.
3 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
4 3
5This file is part of GNU Emacs. 4This file is part of GNU Emacs.
6 5
@@ -74,10 +73,8 @@ char *w32_getenv (char *);
74#include <stdarg.h> 73#include <stdarg.h>
75#include <ctype.h> 74#include <ctype.h>
76#include <stdio.h> 75#include <stdio.h>
77#include "getopt.h" 76#include <getopt.h>
78#ifdef HAVE_UNISTD_H 77#include <unistd.h>
79# include <unistd.h>
80#endif
81 78
82#include <pwd.h> 79#include <pwd.h>
83#include <sys/stat.h> 80#include <sys/stat.h>
@@ -857,7 +854,7 @@ unquote_argument (char *str)
857 854
858 855
859int 856int
860file_name_absolute_p (const unsigned char *filename) 857file_name_absolute_p (const char *filename)
861{ 858{
862 /* Sanity check, it shouldn't happen. */ 859 /* Sanity check, it shouldn't happen. */
863 if (! filename) return FALSE; 860 if (! filename) return FALSE;
@@ -870,7 +867,7 @@ file_name_absolute_p (const unsigned char *filename)
870 867
871#ifdef WINDOWSNT 868#ifdef WINDOWSNT
872 /* X:\xxx is always absolute. */ 869 /* X:\xxx is always absolute. */
873 if (isalpha (filename[0]) 870 if (isalpha ((unsigned char) filename[0])
874 && filename[1] == ':' && (filename[2] == '\\' || filename[2] == '/')) 871 && filename[1] == ':' && (filename[2] == '\\' || filename[2] == '/'))
875 return TRUE; 872 return TRUE;
876 873
@@ -1225,6 +1222,9 @@ set_local_socket (void)
1225 if (!tmpdir) 1222 if (!tmpdir)
1226 { 1223 {
1227#ifdef DARWIN_OS 1224#ifdef DARWIN_OS
1225#ifndef _CS_DARWIN_USER_TEMP_DIR
1226#define _CS_DARWIN_USER_TEMP_DIR 65537
1227#endif
1228 size_t n = confstr (_CS_DARWIN_USER_TEMP_DIR, NULL, (size_t) 0); 1228 size_t n = confstr (_CS_DARWIN_USER_TEMP_DIR, NULL, (size_t) 0);
1229 if (n > 0) 1229 if (n > 0)
1230 { 1230 {
@@ -1801,7 +1801,5 @@ strerror (errnum)
1801 1801
1802#endif /* ! HAVE_STRERROR */ 1802#endif /* ! HAVE_STRERROR */
1803 1803
1804/* arch-tag: f39bb9c4-73eb-477e-896d-50832e2ca9a7
1805 (do not change this comment) */
1806 1804
1807/* emacsclient.c ends here */ 1805/* emacsclient.c ends here */
diff --git a/lib-src/etags.c b/lib-src/etags.c
index abc8b06dd8e..9471c0fe29f 100644
--- a/lib-src/etags.c
+++ b/lib-src/etags.c
@@ -28,8 +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, 1988, 1989, 1993, 1994, 1995, 1998, 1999, 31Copyright (C) 1984, 1987-1989, 1993-1995, 1998-2011
32 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
33 Free Software Foundation, Inc. 32 Free Software Foundation, Inc.
34 33
35This file is not considered part of GNU Emacs. 34This file is not considered part of GNU Emacs.
@@ -172,9 +171,8 @@ char pot_etags_version[] = "@(#) pot revision number is 17.38.1.4";
172# endif 171# endif
173#endif /* !WINDOWSNT */ 172#endif /* !WINDOWSNT */
174 173
175#ifdef HAVE_UNISTD_H 174#include <unistd.h>
176# include <unistd.h> 175#ifndef HAVE_UNISTD_H
177#else
178# if defined (HAVE_GETCWD) && !defined (WINDOWSNT) 176# if defined (HAVE_GETCWD) && !defined (WINDOWSNT)
179 extern char *getcwd (char *buf, size_t size); 177 extern char *getcwd (char *buf, size_t size);
180# endif 178# endif
@@ -891,7 +889,7 @@ static void
891print_version (void) 889print_version (void)
892{ 890{
893 /* Makes it easier to update automatically. */ 891 /* Makes it easier to update automatically. */
894 char emacs_copyright[] = "Copyright (C) 2010 Free Software Foundation, Inc."; 892 char emacs_copyright[] = "Copyright (C) 2011 Free Software Foundation, Inc.";
895 893
896 printf ("%s (%s %s)\n", (CTAGS) ? "ctags" : "etags", EMACS_NAME, VERSION); 894 printf ("%s (%s %s)\n", (CTAGS) ? "ctags" : "etags", EMACS_NAME, VERSION);
897 puts (emacs_copyright); 895 puts (emacs_copyright);
@@ -6725,7 +6723,4 @@ xrealloc (char *ptr, unsigned int size)
6725 * End: 6723 * End:
6726 */ 6724 */
6727 6725
6728/* arch-tag: 8a9b748d-390c-4922-99db-2eeefa921051
6729 (do not change this comment) */
6730
6731/* etags.c ends here */ 6726/* etags.c ends here */
diff --git a/lib-src/fakemail.c b/lib-src/fakemail.c
index 16baeb266a8..4289e009e44 100644
--- a/lib-src/fakemail.c
+++ b/lib-src/fakemail.c
@@ -1,6 +1,5 @@
1/* sendmail-like interface to /bin/mail for system V, 1/* sendmail-like interface to /bin/mail for system V,
2 Copyright (C) 1985, 1994, 1999, 2001, 2002, 2003, 2004, 2 Copyright (C) 1985, 1994, 1999, 2001-2011 Free Software Foundation, Inc.
3 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
4 3
5Author: Bill Rozas <jinx@martigny.ai.mit.edu> 4Author: Bill Rozas <jinx@martigny.ai.mit.edu>
6(according to ack.texi) 5(according to ack.texi)
@@ -62,9 +61,7 @@ main ()
62#include <stdlib.h> 61#include <stdlib.h>
63 62
64/* This is to declare cuserid. */ 63/* This is to declare cuserid. */
65#ifdef HAVE_UNISTD_H
66#include <unistd.h> 64#include <unistd.h>
67#endif
68 65
69/* Type definitions */ 66/* Type definitions */
70 67
@@ -738,7 +735,5 @@ main (int argc, char **argv)
738#endif /* not MSDOS */ 735#endif /* not MSDOS */
739#endif /* not BSD 4.2 (or newer) */ 736#endif /* not BSD 4.2 (or newer) */
740 737
741/* arch-tag: acb0afa6-315a-4c5b-b9e3-def5725c8783
742 (do not change this comment) */
743 738
744/* fakemail.c ends here */ 739/* fakemail.c ends here */
diff --git a/lib-src/getopt.c b/lib-src/getopt.c
deleted file mode 100644
index 587c2e0f618..00000000000
--- a/lib-src/getopt.c
+++ /dev/null
@@ -1,1245 +0,0 @@
1/* Getopt for GNU.
2 NOTE: getopt is now part of the C library, so if you don't know what
3 "Keep this file name-space clean" means, talk to drepper@gnu.org
4 before changing it!
5 Copyright (C) 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
6 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003,
7 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
8 This file is part of the GNU C Library.
9
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 3, or (at your option)
13 any later version.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License along
21 with this program; if not, write to the Free Software Foundation,
22 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
23
24/* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>.
25 Ditto for AIX 3.2 and <stdlib.h>. */
26#ifndef _NO_PROTO
27# define _NO_PROTO
28#endif
29
30#ifdef HAVE_CONFIG_H
31# include <config.h>
32#endif
33
34#include <stdio.h>
35
36/* This needs to come after some library #include
37 to get __GNU_LIBRARY__ defined. */
38#ifdef __GNU_LIBRARY__
39/* Don't include stdlib.h for non-GNU C libraries because some of them
40 contain conflicting prototypes for getopt. */
41# include <stdlib.h>
42# include <unistd.h>
43#endif /* GNU C library. */
44
45#include <string.h>
46
47#ifdef VMS
48# include <unixlib.h>
49#endif
50
51#ifdef _LIBC
52# include <libintl.h>
53#else
54# include "gettext.h"
55# define _(msgid) gettext (msgid)
56#endif
57
58#if defined _LIBC && defined USE_IN_LIBIO
59# include <wchar.h>
60#endif
61
62#ifndef attribute_hidden
63# define attribute_hidden
64#endif
65
66/* Unlike standard Unix `getopt', functions like `getopt_long'
67 let the user intersperse the options with the other arguments.
68
69 As `getopt_long' works, it permutes the elements of ARGV so that,
70 when it is done, all the options precede everything else. Thus
71 all application programs are extended to handle flexible argument order.
72
73 Using `getopt' or setting the environment variable POSIXLY_CORRECT
74 disables permutation.
75 Then the application's behavior is completely standard.
76
77 GNU application programs can use a third alternative mode in which
78 they can distinguish the relative order of options and other arguments. */
79
80#include "getopt.h"
81#include "getopt_int.h"
82
83/* For communication from `getopt' to the caller.
84 When `getopt' finds an option that takes an argument,
85 the argument value is returned here.
86 Also, when `ordering' is RETURN_IN_ORDER,
87 each non-option ARGV-element is returned here. */
88
89char *optarg;
90
91/* Index in ARGV of the next element to be scanned.
92 This is used for communication to and from the caller
93 and for communication between successive calls to `getopt'.
94
95 On entry to `getopt', zero means this is the first call; initialize.
96
97 When `getopt' returns -1, this is the index of the first of the
98 non-option elements that the caller should itself scan.
99
100 Otherwise, `optind' communicates from one call to the next
101 how much of ARGV has been scanned so far. */
102
103/* 1003.2 says this must be 1 before any call. */
104int optind = 1;
105
106/* Callers store zero here to inhibit the error message
107 for unrecognized options. */
108
109int opterr = 1;
110
111/* Set to an option character which was unrecognized.
112 This must be initialized on some systems to avoid linking in the
113 system's own getopt implementation. */
114
115int optopt = '?';
116
117/* Keep a global copy of all internal members of getopt_data. */
118
119static struct _getopt_data getopt_data;
120
121
122#ifndef __GNU_LIBRARY__
123
124/* Avoid depending on library functions or files
125 whose names are inconsistent. */
126
127#ifndef getenv
128extern char *getenv ();
129#endif
130
131#endif /* not __GNU_LIBRARY__ */
132
133#ifdef _LIBC
134/* Stored original parameters.
135 XXX This is no good solution. We should rather copy the args so
136 that we can compare them later. But we must not use malloc(3). */
137extern int __libc_argc;
138extern char **__libc_argv;
139
140/* Bash 2.0 gives us an environment variable containing flags
141 indicating ARGV elements that should not be considered arguments. */
142
143# ifdef USE_NONOPTION_FLAGS
144/* Defined in getopt_init.c */
145extern char *__getopt_nonoption_flags;
146# endif
147
148# ifdef USE_NONOPTION_FLAGS
149# define SWAP_FLAGS(ch1, ch2) \
150 if (d->__nonoption_flags_len > 0) \
151 { \
152 char __tmp = __getopt_nonoption_flags[ch1]; \
153 __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \
154 __getopt_nonoption_flags[ch2] = __tmp; \
155 }
156# else
157# define SWAP_FLAGS(ch1, ch2)
158# endif
159#else /* !_LIBC */
160# define SWAP_FLAGS(ch1, ch2)
161#endif /* _LIBC */
162
163/* Exchange two adjacent subsequences of ARGV.
164 One subsequence is elements [first_nonopt,last_nonopt)
165 which contains all the non-options that have been skipped so far.
166 The other is elements [last_nonopt,optind), which contains all
167 the options processed since those non-options were skipped.
168
169 `first_nonopt' and `last_nonopt' are relocated so that they describe
170 the new indices of the non-options in ARGV after they are moved. */
171
172static void
173exchange (char **argv, struct _getopt_data *d)
174{
175 int bottom = d->__first_nonopt;
176 int middle = d->__last_nonopt;
177 int top = d->optind;
178 char *tem;
179
180 /* Exchange the shorter segment with the far end of the longer segment.
181 That puts the shorter segment into the right place.
182 It leaves the longer segment in the right place overall,
183 but it consists of two parts that need to be swapped next. */
184
185#if defined _LIBC && defined USE_NONOPTION_FLAGS
186 /* First make sure the handling of the `__getopt_nonoption_flags'
187 string can work normally. Our top argument must be in the range
188 of the string. */
189 if (d->__nonoption_flags_len > 0 && top >= d->__nonoption_flags_max_len)
190 {
191 /* We must extend the array. The user plays games with us and
192 presents new arguments. */
193 char *new_str = malloc (top + 1);
194 if (new_str == NULL)
195 d->__nonoption_flags_len = d->__nonoption_flags_max_len = 0;
196 else
197 {
198 memset (__mempcpy (new_str, __getopt_nonoption_flags,
199 d->__nonoption_flags_max_len),
200 '\0', top + 1 - d->__nonoption_flags_max_len);
201 d->__nonoption_flags_max_len = top + 1;
202 __getopt_nonoption_flags = new_str;
203 }
204 }
205#endif
206
207 while (top > middle && middle > bottom)
208 {
209 if (top - middle > middle - bottom)
210 {
211 /* Bottom segment is the short one. */
212 int len = middle - bottom;
213 register int i;
214
215 /* Swap it with the top part of the top segment. */
216 for (i = 0; i < len; i++)
217 {
218 tem = argv[bottom + i];
219 argv[bottom + i] = argv[top - (middle - bottom) + i];
220 argv[top - (middle - bottom) + i] = tem;
221 SWAP_FLAGS (bottom + i, top - (middle - bottom) + i);
222 }
223 /* Exclude the moved bottom segment from further swapping. */
224 top -= len;
225 }
226 else
227 {
228 /* Top segment is the short one. */
229 int len = top - middle;
230 register int i;
231
232 /* Swap it with the bottom part of the bottom segment. */
233 for (i = 0; i < len; i++)
234 {
235 tem = argv[bottom + i];
236 argv[bottom + i] = argv[middle + i];
237 argv[middle + i] = tem;
238 SWAP_FLAGS (bottom + i, middle + i);
239 }
240 /* Exclude the moved top segment from further swapping. */
241 bottom += len;
242 }
243 }
244
245 /* Update records for the slots the non-options now occupy. */
246
247 d->__first_nonopt += (d->optind - d->__last_nonopt);
248 d->__last_nonopt = d->optind;
249}
250
251/* Initialize the internal data when the first call is made. */
252
253static const char *
254_getopt_initialize (int argc, char **argv, const char *optstring,
255 int posixly_correct, struct _getopt_data *d)
256{
257 /* Start processing options with ARGV-element 1 (since ARGV-element 0
258 is the program name); the sequence of previously skipped
259 non-option ARGV-elements is empty. */
260
261 d->__first_nonopt = d->__last_nonopt = d->optind;
262
263 d->__nextchar = NULL;
264
265 d->__posixly_correct = posixly_correct || !!getenv ("POSIXLY_CORRECT");
266
267 /* Determine how to handle the ordering of options and nonoptions. */
268
269 if (optstring[0] == '-')
270 {
271 d->__ordering = RETURN_IN_ORDER;
272 ++optstring;
273 }
274 else if (optstring[0] == '+')
275 {
276 d->__ordering = REQUIRE_ORDER;
277 ++optstring;
278 }
279 else if (d->__posixly_correct)
280 d->__ordering = REQUIRE_ORDER;
281 else
282 d->__ordering = PERMUTE;
283
284#if defined _LIBC && defined USE_NONOPTION_FLAGS
285 if (!d->__posixly_correct
286 && argc == __libc_argc && argv == __libc_argv)
287 {
288 if (d->__nonoption_flags_max_len == 0)
289 {
290 if (__getopt_nonoption_flags == NULL
291 || __getopt_nonoption_flags[0] == '\0')
292 d->__nonoption_flags_max_len = -1;
293 else
294 {
295 const char *orig_str = __getopt_nonoption_flags;
296 int len = d->__nonoption_flags_max_len = strlen (orig_str);
297 if (d->__nonoption_flags_max_len < argc)
298 d->__nonoption_flags_max_len = argc;
299 __getopt_nonoption_flags =
300 (char *) malloc (d->__nonoption_flags_max_len);
301 if (__getopt_nonoption_flags == NULL)
302 d->__nonoption_flags_max_len = -1;
303 else
304 memset (__mempcpy (__getopt_nonoption_flags, orig_str, len),
305 '\0', d->__nonoption_flags_max_len - len);
306 }
307 }
308 d->__nonoption_flags_len = d->__nonoption_flags_max_len;
309 }
310 else
311 d->__nonoption_flags_len = 0;
312#endif
313
314 return optstring;
315}
316
317/* Scan elements of ARGV (whose length is ARGC) for option characters
318 given in OPTSTRING.
319
320 If an element of ARGV starts with '-', and is not exactly "-" or "--",
321 then it is an option element. The characters of this element
322 (aside from the initial '-') are option characters. If `getopt'
323 is called repeatedly, it returns successively each of the option characters
324 from each of the option elements.
325
326 If `getopt' finds another option character, it returns that character,
327 updating `optind' and `nextchar' so that the next call to `getopt' can
328 resume the scan with the following option character or ARGV-element.
329
330 If there are no more option characters, `getopt' returns -1.
331 Then `optind' is the index in ARGV of the first ARGV-element
332 that is not an option. (The ARGV-elements have been permuted
333 so that those that are not options now come last.)
334
335 OPTSTRING is a string containing the legitimate option characters.
336 If an option character is seen that is not listed in OPTSTRING,
337 return '?' after printing an error message. If you set `opterr' to
338 zero, the error message is suppressed but we still return '?'.
339
340 If a char in OPTSTRING is followed by a colon, that means it wants an arg,
341 so the following text in the same ARGV-element, or the text of the following
342 ARGV-element, is returned in `optarg'. Two colons mean an option that
343 wants an optional arg; if there is text in the current ARGV-element,
344 it is returned in `optarg', otherwise `optarg' is set to zero.
345
346 If OPTSTRING starts with `-' or `+', it requests different methods of
347 handling the non-option ARGV-elements.
348 See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
349
350 Long-named options begin with `--' instead of `-'.
351 Their names may be abbreviated as long as the abbreviation is unique
352 or is an exact match for some defined option. If they have an
353 argument, it follows the option name in the same ARGV-element, separated
354 from the option name by a `=', or else the in next ARGV-element.
355 When `getopt' finds a long-named option, it returns 0 if that option's
356 `flag' field is nonzero, the value of the option's `val' field
357 if the `flag' field is zero.
358
359 LONGOPTS is a vector of `struct option' terminated by an
360 element containing a name which is zero.
361
362 LONGIND returns the index in LONGOPT of the long-named option found.
363 It is only valid when a long-named option has been found by the most
364 recent call.
365
366 If LONG_ONLY is nonzero, '-' as well as '--' can introduce
367 long-named options.
368
369 If POSIXLY_CORRECT is nonzero, behave as if the POSIXLY_CORRECT
370 environment variable were set. */
371
372int
373_getopt_internal_r (int argc, char **argv, const char *optstring,
374 const struct option *longopts, int *longind,
375 int long_only, int posixly_correct, struct _getopt_data *d)
376{
377 int print_errors = d->opterr;
378 if (optstring[0] == ':')
379 print_errors = 0;
380
381 if (argc < 1)
382 return -1;
383
384 d->optarg = NULL;
385
386 if (d->optind == 0 || !d->__initialized)
387 {
388 if (d->optind == 0)
389 d->optind = 1; /* Don't scan ARGV[0], the program name. */
390 optstring = _getopt_initialize (argc, argv, optstring,
391 posixly_correct, d);
392 d->__initialized = 1;
393 }
394
395 /* Test whether ARGV[optind] points to a non-option argument.
396 Either it does not have option syntax, or there is an environment flag
397 from the shell indicating it is not an option. The later information
398 is only used when the used in the GNU libc. */
399#if defined _LIBC && defined USE_NONOPTION_FLAGS
400# define NONOPTION_P (argv[d->optind][0] != '-' || argv[d->optind][1] == '\0' \
401 || (d->optind < d->__nonoption_flags_len \
402 && __getopt_nonoption_flags[d->optind] == '1'))
403#else
404# define NONOPTION_P (argv[d->optind][0] != '-' || argv[d->optind][1] == '\0')
405#endif
406
407 if (d->__nextchar == NULL || *d->__nextchar == '\0')
408 {
409 /* Advance to the next ARGV-element. */
410
411 /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been
412 moved back by the user (who may also have changed the arguments). */
413 if (d->__last_nonopt > d->optind)
414 d->__last_nonopt = d->optind;
415 if (d->__first_nonopt > d->optind)
416 d->__first_nonopt = d->optind;
417
418 if (d->__ordering == PERMUTE)
419 {
420 /* If we have just processed some options following some non-options,
421 exchange them so that the options come first. */
422
423 if (d->__first_nonopt != d->__last_nonopt
424 && d->__last_nonopt != d->optind)
425 exchange ((char **) argv, d);
426 else if (d->__last_nonopt != d->optind)
427 d->__first_nonopt = d->optind;
428
429 /* Skip any additional non-options
430 and extend the range of non-options previously skipped. */
431
432 while (d->optind < argc && NONOPTION_P)
433 d->optind++;
434 d->__last_nonopt = d->optind;
435 }
436
437 /* The special ARGV-element `--' means premature end of options.
438 Skip it like a null option,
439 then exchange with previous non-options as if it were an option,
440 then skip everything else like a non-option. */
441
442 if (d->optind != argc && !strcmp (argv[d->optind], "--"))
443 {
444 d->optind++;
445
446 if (d->__first_nonopt != d->__last_nonopt
447 && d->__last_nonopt != d->optind)
448 exchange ((char **) argv, d);
449 else if (d->__first_nonopt == d->__last_nonopt)
450 d->__first_nonopt = d->optind;
451 d->__last_nonopt = argc;
452
453 d->optind = argc;
454 }
455
456 /* If we have done all the ARGV-elements, stop the scan
457 and back over any non-options that we skipped and permuted. */
458
459 if (d->optind == argc)
460 {
461 /* Set the next-arg-index to point at the non-options
462 that we previously skipped, so the caller will digest them. */
463 if (d->__first_nonopt != d->__last_nonopt)
464 d->optind = d->__first_nonopt;
465 return -1;
466 }
467
468 /* If we have come to a non-option and did not permute it,
469 either stop the scan or describe it to the caller and pass it by. */
470
471 if (NONOPTION_P)
472 {
473 if (d->__ordering == REQUIRE_ORDER)
474 return -1;
475 d->optarg = argv[d->optind++];
476 return 1;
477 }
478
479 /* We have found another option-ARGV-element.
480 Skip the initial punctuation. */
481
482 d->__nextchar = (argv[d->optind] + 1
483 + (longopts != NULL && argv[d->optind][1] == '-'));
484 }
485
486 /* Decode the current option-ARGV-element. */
487
488 /* Check whether the ARGV-element is a long option.
489
490 If long_only and the ARGV-element has the form "-f", where f is
491 a valid short option, don't consider it an abbreviated form of
492 a long option that starts with f. Otherwise there would be no
493 way to give the -f short option.
494
495 On the other hand, if there's a long option "fubar" and
496 the ARGV-element is "-fu", do consider that an abbreviation of
497 the long option, just like "--fu", and not "-f" with arg "u".
498
499 This distinction seems to be the most useful approach. */
500
501 if (longopts != NULL
502 && (argv[d->optind][1] == '-'
503 || (long_only && (argv[d->optind][2]
504 || !strchr (optstring, argv[d->optind][1])))))
505 {
506 char *nameend;
507 const struct option *p;
508 const struct option *pfound = NULL;
509 int exact = 0;
510 int ambig = 0;
511 int indfound = -1;
512 int option_index;
513
514 for (nameend = d->__nextchar; *nameend && *nameend != '='; nameend++)
515 /* Do nothing. */ ;
516
517 /* Test all long options for either exact match
518 or abbreviated matches. */
519 for (p = longopts, option_index = 0; p->name; p++, option_index++)
520 if (!strncmp (p->name, d->__nextchar, nameend - d->__nextchar))
521 {
522 if ((unsigned int) (nameend - d->__nextchar)
523 == (unsigned int) strlen (p->name))
524 {
525 /* Exact match found. */
526 pfound = p;
527 indfound = option_index;
528 exact = 1;
529 break;
530 }
531 else if (pfound == NULL)
532 {
533 /* First nonexact match found. */
534 pfound = p;
535 indfound = option_index;
536 }
537 else if (long_only
538 || pfound->has_arg != p->has_arg
539 || pfound->flag != p->flag
540 || pfound->val != p->val)
541 /* Second or later nonexact match found. */
542 ambig = 1;
543 }
544
545 if (ambig && !exact)
546 {
547 if (print_errors)
548 {
549#if defined _LIBC && defined USE_IN_LIBIO
550 char *buf;
551
552 if (__asprintf (&buf, _("%s: option `%s' is ambiguous\n"),
553 argv[0], argv[d->optind]) >= 0)
554 {
555 _IO_flockfile (stderr);
556
557 int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
558 ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
559
560 if (_IO_fwide (stderr, 0) > 0)
561 __fwprintf (stderr, L"%s", buf);
562 else
563 fputs (buf, stderr);
564
565 ((_IO_FILE *) stderr)->_flags2 = old_flags2;
566 _IO_funlockfile (stderr);
567
568 free (buf);
569 }
570#else
571 fprintf (stderr, _("%s: option `%s' is ambiguous\n"),
572 argv[0], argv[d->optind]);
573#endif
574 }
575 d->__nextchar += strlen (d->__nextchar);
576 d->optind++;
577 d->optopt = 0;
578 return '?';
579 }
580
581 if (pfound != NULL)
582 {
583 option_index = indfound;
584 d->optind++;
585 if (*nameend)
586 {
587 /* Don't test has_arg with >, because some C compilers don't
588 allow it to be used on enums. */
589 if (pfound->has_arg)
590 d->optarg = nameend + 1;
591 else
592 {
593 if (print_errors)
594 {
595#if defined _LIBC && defined USE_IN_LIBIO
596 char *buf;
597 int n;
598#endif
599
600 if (argv[d->optind - 1][1] == '-')
601 {
602 /* --option */
603#if defined _LIBC && defined USE_IN_LIBIO
604 n = __asprintf (&buf, _("\
605%s: option `--%s' doesn't allow an argument\n"),
606 argv[0], pfound->name);
607#else
608 fprintf (stderr, _("\
609%s: option `--%s' doesn't allow an argument\n"),
610 argv[0], pfound->name);
611#endif
612 }
613 else
614 {
615 /* +option or -option */
616#if defined _LIBC && defined USE_IN_LIBIO
617 n = __asprintf (&buf, _("\
618%s: option `%c%s' doesn't allow an argument\n"),
619 argv[0], argv[d->optind - 1][0],
620 pfound->name);
621#else
622 fprintf (stderr, _("\
623%s: option `%c%s' doesn't allow an argument\n"),
624 argv[0], argv[d->optind - 1][0],
625 pfound->name);
626#endif
627 }
628
629#if defined _LIBC && defined USE_IN_LIBIO
630 if (n >= 0)
631 {
632 _IO_flockfile (stderr);
633
634 int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
635 ((_IO_FILE *) stderr)->_flags2
636 |= _IO_FLAGS2_NOTCANCEL;
637
638 if (_IO_fwide (stderr, 0) > 0)
639 __fwprintf (stderr, L"%s", buf);
640 else
641 fputs (buf, stderr);
642
643 ((_IO_FILE *) stderr)->_flags2 = old_flags2;
644 _IO_funlockfile (stderr);
645
646 free (buf);
647 }
648#endif
649 }
650
651 d->__nextchar += strlen (d->__nextchar);
652
653 d->optopt = pfound->val;
654 return '?';
655 }
656 }
657 else if (pfound->has_arg == 1)
658 {
659 if (d->optind < argc)
660 d->optarg = argv[d->optind++];
661 else
662 {
663 if (print_errors)
664 {
665#if defined _LIBC && defined USE_IN_LIBIO
666 char *buf;
667
668 if (__asprintf (&buf, _("\
669%s: option `%s' requires an argument\n"),
670 argv[0], argv[d->optind - 1]) >= 0)
671 {
672 _IO_flockfile (stderr);
673
674 int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
675 ((_IO_FILE *) stderr)->_flags2
676 |= _IO_FLAGS2_NOTCANCEL;
677
678 if (_IO_fwide (stderr, 0) > 0)
679 __fwprintf (stderr, L"%s", buf);
680 else
681 fputs (buf, stderr);
682
683 ((_IO_FILE *) stderr)->_flags2 = old_flags2;
684 _IO_funlockfile (stderr);
685
686 free (buf);
687 }
688#else
689 fprintf (stderr,
690 _("%s: option `%s' requires an argument\n"),
691 argv[0], argv[d->optind - 1]);
692#endif
693 }
694 d->__nextchar += strlen (d->__nextchar);
695 d->optopt = pfound->val;
696 return optstring[0] == ':' ? ':' : '?';
697 }
698 }
699 d->__nextchar += strlen (d->__nextchar);
700 if (longind != NULL)
701 *longind = option_index;
702 if (pfound->flag)
703 {
704 *(pfound->flag) = pfound->val;
705 return 0;
706 }
707 return pfound->val;
708 }
709
710 /* Can't find it as a long option. If this is not getopt_long_only,
711 or the option starts with '--' or is not a valid short
712 option, then it's an error.
713 Otherwise interpret it as a short option. */
714 if (!long_only || argv[d->optind][1] == '-'
715 || strchr (optstring, *d->__nextchar) == NULL)
716 {
717 if (print_errors)
718 {
719#if defined _LIBC && defined USE_IN_LIBIO
720 char *buf;
721 int n;
722#endif
723
724 if (argv[d->optind][1] == '-')
725 {
726 /* --option */
727#if defined _LIBC && defined USE_IN_LIBIO
728 n = __asprintf (&buf, _("%s: unrecognized option `--%s'\n"),
729 argv[0], d->__nextchar);
730#else
731 fprintf (stderr, _("%s: unrecognized option `--%s'\n"),
732 argv[0], d->__nextchar);
733#endif
734 }
735 else
736 {
737 /* +option or -option */
738#if defined _LIBC && defined USE_IN_LIBIO
739 n = __asprintf (&buf, _("%s: unrecognized option `%c%s'\n"),
740 argv[0], argv[d->optind][0], d->__nextchar);
741#else
742 fprintf (stderr, _("%s: unrecognized option `%c%s'\n"),
743 argv[0], argv[d->optind][0], d->__nextchar);
744#endif
745 }
746
747#if defined _LIBC && defined USE_IN_LIBIO
748 if (n >= 0)
749 {
750 _IO_flockfile (stderr);
751
752 int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
753 ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
754
755 if (_IO_fwide (stderr, 0) > 0)
756 __fwprintf (stderr, L"%s", buf);
757 else
758 fputs (buf, stderr);
759
760 ((_IO_FILE *) stderr)->_flags2 = old_flags2;
761 _IO_funlockfile (stderr);
762
763 free (buf);
764 }
765#endif
766 }
767 d->__nextchar = (char *) "";
768 d->optind++;
769 d->optopt = 0;
770 return '?';
771 }
772 }
773
774 /* Look at and handle the next short option-character. */
775
776 {
777 char c = *d->__nextchar++;
778 char *temp = strchr (optstring, c);
779
780 /* Increment `optind' when we start to process its last character. */
781 if (*d->__nextchar == '\0')
782 ++d->optind;
783
784 if (temp == NULL || c == ':')
785 {
786 if (print_errors)
787 {
788#if defined _LIBC && defined USE_IN_LIBIO
789 char *buf;
790 int n;
791#endif
792
793 if (d->__posixly_correct)
794 {
795 /* 1003.2 specifies the format of this message. */
796#if defined _LIBC && defined USE_IN_LIBIO
797 n = __asprintf (&buf, _("%s: illegal option -- %c\n"),
798 argv[0], c);
799#else
800 fprintf (stderr, _("%s: illegal option -- %c\n"), argv[0], c);
801#endif
802 }
803 else
804 {
805#if defined _LIBC && defined USE_IN_LIBIO
806 n = __asprintf (&buf, _("%s: invalid option -- %c\n"),
807 argv[0], c);
808#else
809 fprintf (stderr, _("%s: invalid option -- %c\n"), argv[0], c);
810#endif
811 }
812
813#if defined _LIBC && defined USE_IN_LIBIO
814 if (n >= 0)
815 {
816 _IO_flockfile (stderr);
817
818 int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
819 ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
820
821 if (_IO_fwide (stderr, 0) > 0)
822 __fwprintf (stderr, L"%s", buf);
823 else
824 fputs (buf, stderr);
825
826 ((_IO_FILE *) stderr)->_flags2 = old_flags2;
827 _IO_funlockfile (stderr);
828
829 free (buf);
830 }
831#endif
832 }
833 d->optopt = c;
834 return '?';
835 }
836 /* Convenience. Treat POSIX -W foo same as long option --foo */
837 if (temp[0] == 'W' && temp[1] == ';')
838 {
839 char *nameend;
840 const struct option *p;
841 const struct option *pfound = NULL;
842 int exact = 0;
843 int ambig = 0;
844 int indfound = 0;
845 int option_index;
846
847 /* This is an option that requires an argument. */
848 if (*d->__nextchar != '\0')
849 {
850 d->optarg = d->__nextchar;
851 /* If we end this ARGV-element by taking the rest as an arg,
852 we must advance to the next element now. */
853 d->optind++;
854 }
855 else if (d->optind == argc)
856 {
857 if (print_errors)
858 {
859 /* 1003.2 specifies the format of this message. */
860#if defined _LIBC && defined USE_IN_LIBIO
861 char *buf;
862
863 if (__asprintf (&buf,
864 _("%s: option requires an argument -- %c\n"),
865 argv[0], c) >= 0)
866 {
867 _IO_flockfile (stderr);
868
869 int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
870 ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
871
872 if (_IO_fwide (stderr, 0) > 0)
873 __fwprintf (stderr, L"%s", buf);
874 else
875 fputs (buf, stderr);
876
877 ((_IO_FILE *) stderr)->_flags2 = old_flags2;
878 _IO_funlockfile (stderr);
879
880 free (buf);
881 }
882#else
883 fprintf (stderr, _("%s: option requires an argument -- %c\n"),
884 argv[0], c);
885#endif
886 }
887 d->optopt = c;
888 if (optstring[0] == ':')
889 c = ':';
890 else
891 c = '?';
892 return c;
893 }
894 else
895 /* We already incremented `d->optind' once;
896 increment it again when taking next ARGV-elt as argument. */
897 d->optarg = argv[d->optind++];
898
899 /* optarg is now the argument, see if it's in the
900 table of longopts. */
901
902 for (d->__nextchar = nameend = d->optarg; *nameend && *nameend != '=';
903 nameend++)
904 /* Do nothing. */ ;
905
906 /* Test all long options for either exact match
907 or abbreviated matches. */
908 for (p = longopts, option_index = 0; p->name; p++, option_index++)
909 if (!strncmp (p->name, d->__nextchar, nameend - d->__nextchar))
910 {
911 if ((unsigned int) (nameend - d->__nextchar) == strlen (p->name))
912 {
913 /* Exact match found. */
914 pfound = p;
915 indfound = option_index;
916 exact = 1;
917 break;
918 }
919 else if (pfound == NULL)
920 {
921 /* First nonexact match found. */
922 pfound = p;
923 indfound = option_index;
924 }
925 else
926 /* Second or later nonexact match found. */
927 ambig = 1;
928 }
929 if (ambig && !exact)
930 {
931 if (print_errors)
932 {
933#if defined _LIBC && defined USE_IN_LIBIO
934 char *buf;
935
936 if (__asprintf (&buf, _("%s: option `-W %s' is ambiguous\n"),
937 argv[0], argv[d->optind]) >= 0)
938 {
939 _IO_flockfile (stderr);
940
941 int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
942 ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
943
944 if (_IO_fwide (stderr, 0) > 0)
945 __fwprintf (stderr, L"%s", buf);
946 else
947 fputs (buf, stderr);
948
949 ((_IO_FILE *) stderr)->_flags2 = old_flags2;
950 _IO_funlockfile (stderr);
951
952 free (buf);
953 }
954#else
955 fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"),
956 argv[0], argv[d->optind]);
957#endif
958 }
959 d->__nextchar += strlen (d->__nextchar);
960 d->optind++;
961 return '?';
962 }
963 if (pfound != NULL)
964 {
965 option_index = indfound;
966 if (*nameend)
967 {
968 /* Don't test has_arg with >, because some C compilers don't
969 allow it to be used on enums. */
970 if (pfound->has_arg)
971 d->optarg = nameend + 1;
972 else
973 {
974 if (print_errors)
975 {
976#if defined _LIBC && defined USE_IN_LIBIO
977 char *buf;
978
979 if (__asprintf (&buf, _("\
980%s: option `-W %s' doesn't allow an argument\n"),
981 argv[0], pfound->name) >= 0)
982 {
983 _IO_flockfile (stderr);
984
985 int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
986 ((_IO_FILE *) stderr)->_flags2
987 |= _IO_FLAGS2_NOTCANCEL;
988
989 if (_IO_fwide (stderr, 0) > 0)
990 __fwprintf (stderr, L"%s", buf);
991 else
992 fputs (buf, stderr);
993
994 ((_IO_FILE *) stderr)->_flags2 = old_flags2;
995 _IO_funlockfile (stderr);
996
997 free (buf);
998 }
999#else
1000 fprintf (stderr, _("\
1001%s: option `-W %s' doesn't allow an argument\n"),
1002 argv[0], pfound->name);
1003#endif
1004 }
1005
1006 d->__nextchar += strlen (d->__nextchar);
1007 return '?';
1008 }
1009 }
1010 else if (pfound->has_arg == 1)
1011 {
1012 if (d->optind < argc)
1013 d->optarg = argv[d->optind++];
1014 else
1015 {
1016 if (print_errors)
1017 {
1018#if defined _LIBC && defined USE_IN_LIBIO
1019 char *buf;
1020
1021 if (__asprintf (&buf, _("\
1022%s: option `%s' requires an argument\n"),
1023 argv[0], argv[d->optind - 1]) >= 0)
1024 {
1025 _IO_flockfile (stderr);
1026
1027 int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
1028 ((_IO_FILE *) stderr)->_flags2
1029 |= _IO_FLAGS2_NOTCANCEL;
1030
1031 if (_IO_fwide (stderr, 0) > 0)
1032 __fwprintf (stderr, L"%s", buf);
1033 else
1034 fputs (buf, stderr);
1035
1036 ((_IO_FILE *) stderr)->_flags2 = old_flags2;
1037 _IO_funlockfile (stderr);
1038
1039 free (buf);
1040 }
1041#else
1042 fprintf (stderr,
1043 _("%s: option `%s' requires an argument\n"),
1044 argv[0], argv[d->optind - 1]);
1045#endif
1046 }
1047 d->__nextchar += strlen (d->__nextchar);
1048 return optstring[0] == ':' ? ':' : '?';
1049 }
1050 }
1051 d->__nextchar += strlen (d->__nextchar);
1052 if (longind != NULL)
1053 *longind = option_index;
1054 if (pfound->flag)
1055 {
1056 *(pfound->flag) = pfound->val;
1057 return 0;
1058 }
1059 return pfound->val;
1060 }
1061 d->__nextchar = NULL;
1062 return 'W'; /* Let the application handle it. */
1063 }
1064 if (temp[1] == ':')
1065 {
1066 if (temp[2] == ':')
1067 {
1068 /* This is an option that accepts an argument optionally. */
1069 if (*d->__nextchar != '\0')
1070 {
1071 d->optarg = d->__nextchar;
1072 d->optind++;
1073 }
1074 else
1075 d->optarg = NULL;
1076 d->__nextchar = NULL;
1077 }
1078 else
1079 {
1080 /* This is an option that requires an argument. */
1081 if (*d->__nextchar != '\0')
1082 {
1083 d->optarg = d->__nextchar;
1084 /* If we end this ARGV-element by taking the rest as an arg,
1085 we must advance to the next element now. */
1086 d->optind++;
1087 }
1088 else if (d->optind == argc)
1089 {
1090 if (print_errors)
1091 {
1092 /* 1003.2 specifies the format of this message. */
1093#if defined _LIBC && defined USE_IN_LIBIO
1094 char *buf;
1095
1096 if (__asprintf (&buf, _("\
1097%s: option requires an argument -- %c\n"),
1098 argv[0], c) >= 0)
1099 {
1100 _IO_flockfile (stderr);
1101
1102 int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
1103 ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
1104
1105 if (_IO_fwide (stderr, 0) > 0)
1106 __fwprintf (stderr, L"%s", buf);
1107 else
1108 fputs (buf, stderr);
1109
1110 ((_IO_FILE *) stderr)->_flags2 = old_flags2;
1111 _IO_funlockfile (stderr);
1112
1113 free (buf);
1114 }
1115#else
1116 fprintf (stderr,
1117 _("%s: option requires an argument -- %c\n"),
1118 argv[0], c);
1119#endif
1120 }
1121 d->optopt = c;
1122 if (optstring[0] == ':')
1123 c = ':';
1124 else
1125 c = '?';
1126 }
1127 else
1128 /* We already incremented `optind' once;
1129 increment it again when taking next ARGV-elt as argument. */
1130 d->optarg = argv[d->optind++];
1131 d->__nextchar = NULL;
1132 }
1133 }
1134 return c;
1135 }
1136}
1137
1138int
1139_getopt_internal (int argc, char **argv, const char *optstring,
1140 const struct option *longopts, int *longind,
1141 int long_only, int posixly_correct)
1142{
1143 int result;
1144
1145 getopt_data.optind = optind;
1146 getopt_data.opterr = opterr;
1147
1148 result = _getopt_internal_r (argc, argv, optstring, longopts, longind,
1149 long_only, posixly_correct, &getopt_data);
1150
1151 optind = getopt_data.optind;
1152 optarg = getopt_data.optarg;
1153 optopt = getopt_data.optopt;
1154
1155 return result;
1156}
1157
1158/* glibc gets a LSB-compliant getopt.
1159 Standalone applications get a POSIX-compliant getopt. */
1160#if _LIBC
1161enum { POSIXLY_CORRECT = 0 };
1162#else
1163enum { POSIXLY_CORRECT = 1 };
1164#endif
1165
1166int
1167getopt (int argc, char *const *argv, const char *optstring)
1168{
1169 return _getopt_internal (argc, (char **) argv, optstring, NULL, NULL, 0,
1170 POSIXLY_CORRECT);
1171}
1172
1173
1174#ifdef TEST
1175
1176/* Compile with -DTEST to make an executable for use in testing
1177 the above definition of `getopt'. */
1178
1179int
1180main (int argc, char **argv)
1181{
1182 int c;
1183 int digit_optind = 0;
1184
1185 while (1)
1186 {
1187 int this_option_optind = optind ? optind : 1;
1188
1189 c = getopt (argc, argv, "abc:d:0123456789");
1190 if (c == -1)
1191 break;
1192
1193 switch (c)
1194 {
1195 case '0':
1196 case '1':
1197 case '2':
1198 case '3':
1199 case '4':
1200 case '5':
1201 case '6':
1202 case '7':
1203 case '8':
1204 case '9':
1205 if (digit_optind != 0 && digit_optind != this_option_optind)
1206 printf ("digits occur in two different argv-elements.\n");
1207 digit_optind = this_option_optind;
1208 printf ("option %c\n", c);
1209 break;
1210
1211 case 'a':
1212 printf ("option a\n");
1213 break;
1214
1215 case 'b':
1216 printf ("option b\n");
1217 break;
1218
1219 case 'c':
1220 printf ("option c with value `%s'\n", optarg);
1221 break;
1222
1223 case '?':
1224 break;
1225
1226 default:
1227 printf ("?? getopt returned character code 0%o ??\n", c);
1228 }
1229 }
1230
1231 if (optind < argc)
1232 {
1233 printf ("non-option ARGV-elements: ");
1234 while (optind < argc)
1235 printf ("%s ", argv[optind++]);
1236 printf ("\n");
1237 }
1238
1239 exit (0);
1240}
1241
1242#endif /* TEST */
1243
1244/* arch-tag: 0e6da124-7269-4785-a9de-094c263d20dc
1245 (do not change this comment) */
diff --git a/lib-src/getopt1.c b/lib-src/getopt1.c
deleted file mode 100644
index 25f616250c1..00000000000
--- a/lib-src/getopt1.c
+++ /dev/null
@@ -1,177 +0,0 @@
1/* getopt_long and getopt_long_only entry points for GNU getopt.
2 Copyright (C) 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1996, 1997,
3 1998, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
9 any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License along
17 with this program; if not, write to the Free Software Foundation,
18 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
19
20#ifdef HAVE_CONFIG_H
21#include <config.h>
22#endif
23
24#ifdef _LIBC
25# include <getopt.h>
26#else
27# include "getopt.h"
28#endif
29#include "getopt_int.h"
30
31#include <stdio.h>
32
33/* This needs to come after some library #include
34 to get __GNU_LIBRARY__ defined. */
35#ifdef __GNU_LIBRARY__
36#include <stdlib.h>
37#endif
38
39#ifndef NULL
40#define NULL 0
41#endif
42
43int
44getopt_long (int argc, char *__getopt_argv_const *argv, const char *options,
45 const struct option *long_options, int *opt_index)
46{
47 return _getopt_internal (argc, (char **) argv, options, long_options,
48 opt_index, 0, 0);
49}
50
51int
52_getopt_long_r (int argc, char **argv, const char *options,
53 const struct option *long_options, int *opt_index,
54 struct _getopt_data *d)
55{
56 return _getopt_internal_r (argc, argv, options, long_options, opt_index,
57 0, 0, d);
58}
59
60/* Like getopt_long, but '-' as well as '--' can indicate a long option.
61 If an option that starts with '-' (not '--') doesn't match a long option,
62 but does match a short option, it is parsed as a short option
63 instead. */
64
65int
66getopt_long_only (int argc, char *__getopt_argv_const *argv,
67 const char *options,
68 const struct option *long_options, int *opt_index)
69{
70 return _getopt_internal (argc, (char **) argv, options, long_options,
71 opt_index, 1, 0);
72}
73
74int
75_getopt_long_only_r (int argc, char **argv, const char *options,
76 const struct option *long_options, int *opt_index,
77 struct _getopt_data *d)
78{
79 return _getopt_internal_r (argc, argv, options, long_options, opt_index,
80 1, 0, d);
81}
82
83
84#ifdef TEST
85
86#include <stdio.h>
87
88int
89main (int argc, char **argv)
90{
91 int c;
92 int digit_optind = 0;
93
94 while (1)
95 {
96 int this_option_optind = optind ? optind : 1;
97 int option_index = 0;
98 static struct option long_options[] =
99 {
100 {"add", 1, 0, 0},
101 {"append", 0, 0, 0},
102 {"delete", 1, 0, 0},
103 {"verbose", 0, 0, 0},
104 {"create", 0, 0, 0},
105 {"file", 1, 0, 0},
106 {0, 0, 0, 0}
107 };
108
109 c = getopt_long (argc, argv, "abc:d:0123456789",
110 long_options, &option_index);
111 if (c == -1)
112 break;
113
114 switch (c)
115 {
116 case 0:
117 printf ("option %s", long_options[option_index].name);
118 if (optarg)
119 printf (" with arg %s", optarg);
120 printf ("\n");
121 break;
122
123 case '0':
124 case '1':
125 case '2':
126 case '3':
127 case '4':
128 case '5':
129 case '6':
130 case '7':
131 case '8':
132 case '9':
133 if (digit_optind != 0 && digit_optind != this_option_optind)
134 printf ("digits occur in two different argv-elements.\n");
135 digit_optind = this_option_optind;
136 printf ("option %c\n", c);
137 break;
138
139 case 'a':
140 printf ("option a\n");
141 break;
142
143 case 'b':
144 printf ("option b\n");
145 break;
146
147 case 'c':
148 printf ("option c with value `%s'\n", optarg);
149 break;
150
151 case 'd':
152 printf ("option d with value `%s'\n", optarg);
153 break;
154
155 case '?':
156 break;
157
158 default:
159 printf ("?? getopt returned character code 0%o ??\n", c);
160 }
161 }
162
163 if (optind < argc)
164 {
165 printf ("non-option ARGV-elements: ");
166 while (optind < argc)
167 printf ("%s ", argv[optind++]);
168 printf ("\n");
169 }
170
171 exit (0);
172}
173
174#endif /* TEST */
175
176/* arch-tag: 28a5c558-b0c0-4bff-b5bc-e2e20291d4b6
177 (do not change this comment) */
diff --git a/lib-src/getopt_.h b/lib-src/getopt_.h
deleted file mode 100644
index 7cccef3eeea..00000000000
--- a/lib-src/getopt_.h
+++ /dev/null
@@ -1,230 +0,0 @@
1/* Declarations for getopt.
2 Copyright (C) 1989, 1990, 1991, 1992, 1993, 1994, 1996, 1997, 1998, 1999,
3 2001, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
9 any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License along
17 with this program; if not, write to the Free Software Foundation,
18 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
19
20#ifndef _GETOPT_H
21
22#ifndef __need_getopt
23# define _GETOPT_H 1
24#endif
25
26/* Standalone applications should #define __GETOPT_PREFIX to an
27 identifier that prefixes the external functions and variables
28 defined in this header. When this happens, include the
29 headers that might declare getopt so that they will not cause
30 confusion if included after this file. Then systematically rename
31 identifiers so that they do not collide with the system functions
32 and variables. Renaming avoids problems with some compilers and
33 linkers. */
34#if defined __GETOPT_PREFIX && !defined __need_getopt
35# include <stdlib.h>
36# include <stdio.h>
37# if HAVE_UNISTD_H
38# include <unistd.h>
39# endif
40# undef __need_getopt
41# undef getopt
42# undef getopt_long
43# undef getopt_long_only
44# undef optarg
45# undef opterr
46# undef optind
47# undef optopt
48# define __GETOPT_CONCAT(x, y) x ## y
49# define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y)
50# define __GETOPT_ID(y) __GETOPT_XCONCAT (__GETOPT_PREFIX, y)
51# define getopt __GETOPT_ID (getopt)
52# define getopt_long __GETOPT_ID (getopt_long)
53# define getopt_long_only __GETOPT_ID (getopt_long_only)
54# define optarg __GETOPT_ID (optarg)
55# define opterr __GETOPT_ID (opterr)
56# define optind __GETOPT_ID (optind)
57# define optopt __GETOPT_ID (optopt)
58#endif
59
60/* Standalone applications get correct prototypes for getopt_long and
61 getopt_long_only; they declare "char **argv". libc uses prototypes
62 with "char *const *argv" that are incorrect because getopt_long and
63 getopt_long_only can permute argv; this is required for backward
64 compatibility (e.g., for LSB 2.0.1).
65
66 This used to be `#if defined __GETOPT_PREFIX && !defined __need_getopt',
67 but it caused redefinition warnings if both unistd.h and getopt.h were
68 included, since unistd.h includes getopt.h having previously defined
69 __need_getopt.
70
71 The only place where __getopt_argv_const is used is in definitions
72 of getopt_long and getopt_long_only below, but these are visible
73 only if __need_getopt is not defined, so it is quite safe to rewrite
74 the conditional as follows:
75*/
76#if !defined __need_getopt
77# if defined __GETOPT_PREFIX
78# define __getopt_argv_const /* empty */
79# else
80# define __getopt_argv_const const
81# endif
82#endif
83
84/* If __GNU_LIBRARY__ is not already defined, either we are being used
85 standalone, or this is the first header included in the source file.
86 If we are being used with glibc, we need to include <features.h>, but
87 that does not exist if we are standalone. So: if __GNU_LIBRARY__ is
88 not defined, include <ctype.h>, which will pull in <features.h> for us
89 if it's from glibc. (Why ctype.h? It's guaranteed to exist and it
90 doesn't flood the namespace with stuff the way some other headers do.) */
91#if !defined __GNU_LIBRARY__
92# include <ctype.h>
93#endif
94
95#ifndef __THROW
96# ifndef __GNUC_PREREQ
97# define __GNUC_PREREQ(maj, min) (0)
98# endif
99# if defined __cplusplus && __GNUC_PREREQ (2,8)
100# define __THROW throw ()
101# else
102# define __THROW
103# endif
104#endif
105
106#ifdef __cplusplus
107extern "C" {
108#endif
109
110/* For communication from `getopt' to the caller.
111 When `getopt' finds an option that takes an argument,
112 the argument value is returned here.
113 Also, when `ordering' is RETURN_IN_ORDER,
114 each non-option ARGV-element is returned here. */
115
116extern char *optarg;
117
118/* Index in ARGV of the next element to be scanned.
119 This is used for communication to and from the caller
120 and for communication between successive calls to `getopt'.
121
122 On entry to `getopt', zero means this is the first call; initialize.
123
124 When `getopt' returns -1, this is the index of the first of the
125 non-option elements that the caller should itself scan.
126
127 Otherwise, `optind' communicates from one call to the next
128 how much of ARGV has been scanned so far. */
129
130extern int optind;
131
132/* Callers store zero here to inhibit the error message `getopt' prints
133 for unrecognized options. */
134
135extern int opterr;
136
137/* Set to an option character which was unrecognized. */
138
139extern int optopt;
140
141#ifndef __need_getopt
142/* Describe the long-named options requested by the application.
143 The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
144 of `struct option' terminated by an element containing a name which is
145 zero.
146
147 The field `has_arg' is:
148 no_argument (or 0) if the option does not take an argument,
149 required_argument (or 1) if the option requires an argument,
150 optional_argument (or 2) if the option takes an optional argument.
151
152 If the field `flag' is not NULL, it points to a variable that is set
153 to the value given in the field `val' when the option is found, but
154 left unchanged if the option is not found.
155
156 To have a long-named option do something other than set an `int' to
157 a compiled-in constant, such as set a value from `optarg', set the
158 option's `flag' field to zero and its `val' field to a nonzero
159 value (the equivalent single-letter option character, if there is
160 one). For long options that have a zero `flag' field, `getopt'
161 returns the contents of the `val' field. */
162
163struct option
164{
165 const char *name;
166 /* has_arg can't be an enum because some compilers complain about
167 type mismatches in all the code that assumes it is an int. */
168 int has_arg;
169 int *flag;
170 int val;
171};
172
173/* Names for the values of the `has_arg' field of `struct option'. */
174
175# define no_argument 0
176# define required_argument 1
177# define optional_argument 2
178#endif /* need getopt */
179
180
181/* Get definitions and prototypes for functions to process the
182 arguments in ARGV (ARGC of them, minus the program name) for
183 options given in OPTS.
184
185 Return the option character from OPTS just read. Return -1 when
186 there are no more options. For unrecognized options, or options
187 missing arguments, `optopt' is set to the option letter, and '?' is
188 returned.
189
190 The OPTS string is a list of characters which are recognized option
191 letters, optionally followed by colons, specifying that that letter
192 takes an argument, to be placed in `optarg'.
193
194 If a letter in OPTS is followed by two colons, its argument is
195 optional. This behavior is specific to the GNU `getopt'.
196
197 The argument `--' causes premature termination of argument
198 scanning, explicitly telling `getopt' that there are no more
199 options.
200
201 If OPTS begins with `--', then non-option arguments are treated as
202 arguments to the option '\0'. This behavior is specific to the GNU
203 `getopt'. */
204
205extern int getopt (int ___argc, char *const *___argv, const char *__shortopts)
206 __THROW;
207
208#ifndef __need_getopt
209extern int getopt_long (int ___argc, char *__getopt_argv_const *___argv,
210 const char *__shortopts,
211 const struct option *__longopts, int *__longind)
212 __THROW;
213extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv,
214 const char *__shortopts,
215 const struct option *__longopts, int *__longind)
216 __THROW;
217
218#endif
219
220#ifdef __cplusplus
221}
222#endif
223
224/* Make sure we later can get all the definitions and declarations. */
225#undef __need_getopt
226
227#endif /* getopt.h */
228
229/* arch-tag: e36f5607-3ac6-4cdc-9aa7-c26c6525fe9b
230 (do not change this comment) */
diff --git a/lib-src/getopt_int.h b/lib-src/getopt_int.h
deleted file mode 100644
index 049f4762900..00000000000
--- a/lib-src/getopt_int.h
+++ /dev/null
@@ -1,134 +0,0 @@
1/* Internal declarations for getopt.
2 Copyright (C) 1989, 1990, 1991, 1992, 1993, 1994, 1996, 1997, 1998, 1999,
3 2001, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
9 any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License along
17 with this program; if not, write to the Free Software Foundation,
18 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
19
20#ifndef _GETOPT_INT_H
21#define _GETOPT_INT_H 1
22
23extern int _getopt_internal (int ___argc, char **___argv,
24 const char *__shortopts,
25 const struct option *__longopts, int *__longind,
26 int __long_only, int __posixly_correct);
27
28
29/* Reentrant versions which can handle parsing multiple argument
30 vectors at the same time. */
31
32/* Data type for reentrant functions. */
33struct _getopt_data
34{
35 /* These have exactly the same meaning as the corresponding global
36 variables, except that they are used for the reentrant
37 versions of getopt. */
38 int optind;
39 int opterr;
40 int optopt;
41 char *optarg;
42
43 /* Internal members. */
44
45 /* True if the internal members have been initialized. */
46 int __initialized;
47
48 /* The next char to be scanned in the option-element
49 in which the last option character we returned was found.
50 This allows us to pick up the scan where we left off.
51
52 If this is zero, or a null string, it means resume the scan
53 by advancing to the next ARGV-element. */
54 char *__nextchar;
55
56 /* Describe how to deal with options that follow non-option ARGV-elements.
57
58 If the caller did not specify anything,
59 the default is REQUIRE_ORDER if the environment variable
60 POSIXLY_CORRECT is defined, PERMUTE otherwise.
61
62 REQUIRE_ORDER means don't recognize them as options;
63 stop option processing when the first non-option is seen.
64 This is what Unix does.
65 This mode of operation is selected by either setting the environment
66 variable POSIXLY_CORRECT, or using `+' as the first character
67 of the list of option characters, or by calling getopt.
68
69 PERMUTE is the default. We permute the contents of ARGV as we
70 scan, so that eventually all the non-options are at the end.
71 This allows options to be given in any order, even with programs
72 that were not written to expect this.
73
74 RETURN_IN_ORDER is an option available to programs that were
75 written to expect options and other ARGV-elements in any order
76 and that care about the ordering of the two. We describe each
77 non-option ARGV-element as if it were the argument of an option
78 with character code 1. Using `-' as the first character of the
79 list of option characters selects this mode of operation.
80
81 The special argument `--' forces an end of option-scanning regardless
82 of the value of `ordering'. In the case of RETURN_IN_ORDER, only
83 `--' can cause `getopt' to return -1 with `optind' != ARGC. */
84
85 enum
86 {
87 REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
88 } __ordering;
89
90 /* If the POSIXLY_CORRECT environment variable is set
91 or getopt was called. */
92 int __posixly_correct;
93
94
95 /* Handle permutation of arguments. */
96
97 /* Describe the part of ARGV that contains non-options that have
98 been skipped. `first_nonopt' is the index in ARGV of the first
99 of them; `last_nonopt' is the index after the last of them. */
100
101 int __first_nonopt;
102 int __last_nonopt;
103
104#if defined _LIBC && defined USE_NONOPTION_FLAGS
105 int __nonoption_flags_max_len;
106 int __nonoption_flags_len;
107# endif
108};
109
110/* The initializer is necessary to set OPTIND and OPTERR to their
111 default values and to clear the initialization flag. */
112#define _GETOPT_DATA_INITIALIZER { 1, 1 }
113
114extern int _getopt_internal_r (int ___argc, char **___argv,
115 const char *__shortopts,
116 const struct option *__longopts, int *__longind,
117 int __long_only, int __posixly_correct,
118 struct _getopt_data *__data);
119
120extern int _getopt_long_r (int ___argc, char **___argv,
121 const char *__shortopts,
122 const struct option *__longopts, int *__longind,
123 struct _getopt_data *__data);
124
125extern int _getopt_long_only_r (int ___argc, char **___argv,
126 const char *__shortopts,
127 const struct option *__longopts,
128 int *__longind,
129 struct _getopt_data *__data);
130
131#endif /* getopt_int.h */
132
133/* arch-tag: 8bfc548f-23d6-46aa-b5b5-2739b0edaf79
134 (do not change this comment) */
diff --git a/lib-src/gettext.h b/lib-src/gettext.h
deleted file mode 100644
index 4a5941f86dc..00000000000
--- a/lib-src/gettext.h
+++ /dev/null
@@ -1,82 +0,0 @@
1/* Convenience header for conditional use of GNU <libintl.h>.
2 Copyright (C) 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2004,
3 2005, 2006, 2007 Free Software Foundation, Inc.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3, or (at your option)
8 any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation,
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18
19#ifndef _LIBGETTEXT_H
20#define _LIBGETTEXT_H 1
21
22/* NLS can be disabled through the configure --disable-nls option. */
23#if ENABLE_NLS
24
25/* Get declarations of GNU message catalog functions. */
26# include <libintl.h>
27
28#else
29
30/* Solaris /usr/include/locale.h includes /usr/include/libintl.h, which
31 chokes if dcgettext is defined as a macro. So include it now, to make
32 later inclusions of <locale.h> a NOP. We don't include <libintl.h>
33 as well because people using "gettext.h" will not include <libintl.h>,
34 and also including <libintl.h> would fail on SunOS 4, whereas <locale.h>
35 is OK. */
36#if defined(__sun)
37# include <locale.h>
38#endif
39
40/* Many header files from the libstdc++ coming with g++ 3.3 or newer include
41 <libintl.h>, which chokes if dcgettext is defined as a macro. So include
42 it now, to make later inclusions of <libintl.h> a NOP. */
43#if defined(__cplusplus) && defined(__GNUG__) && (__GNUC__ >= 3)
44# include <cstdlib>
45# if (__GLIBC__ >= 2) || _GLIBCXX_HAVE_LIBINTL_H
46# include <libintl.h>
47# endif
48#endif
49
50/* Disabled NLS.
51 The casts to 'const char *' serve the purpose of producing warnings
52 for invalid uses of the value returned from these functions.
53 On pre-ANSI systems without 'const', the config.h file is supposed to
54 contain "#define const". */
55# define gettext(Msgid) ((const char *) (Msgid))
56# define dgettext(Domainname, Msgid) ((const char *) (Msgid))
57# define dcgettext(Domainname, Msgid, Category) ((const char *) (Msgid))
58# define ngettext(Msgid1, Msgid2, N) \
59 ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
60# define dngettext(Domainname, Msgid1, Msgid2, N) \
61 ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
62# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \
63 ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
64# define textdomain(Domainname) ((const char *) (Domainname))
65# define bindtextdomain(Domainname, Dirname) ((const char *) (Dirname))
66# define bind_textdomain_codeset(Domainname, Codeset) ((const char *) (Codeset))
67
68#endif
69
70/* A pseudo function call that serves as a marker for the automated
71 extraction of messages, but does not call gettext(). The run-time
72 translation is done at a different place in the code.
73 The argument, String, should be a literal string. Concatenated strings
74 and other string expressions won't work.
75 The macro's expansion is not parenthesized, so that it is suitable as
76 initializer for static 'char[]' or 'const char[]' variables. */
77#define gettext_noop(String) String
78
79#endif /* _LIBGETTEXT_H */
80
81/* arch-tag: 3d01bb8e-82e3-4674-9812-de4c4224f7d1
82 (do not change this comment) */
diff --git a/lib-src/grep-changelog b/lib-src/grep-changelog
index b63ae90eafb..0c7c42dc7ce 100755
--- a/lib-src/grep-changelog
+++ b/lib-src/grep-changelog
@@ -1,7 +1,6 @@
1#! /usr/bin/perl 1#! /usr/bin/perl
2 2
3# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 3# Copyright (C) 1999-2011 Free Software Foundation, Inc.
4# 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
5# 4#
6# This file is part of GNU Emacs. 5# This file is part of GNU Emacs.
7 6
@@ -263,5 +262,4 @@ while (defined (my $log = shift @ARGV)) {
263} 262}
264 263
265 264
266# arch-tag: 9e4f6749-e053-4bb7-b3ad-11947318418e
267# grep-changelog ends here. 265# grep-changelog ends here.
diff --git a/lib-src/hexl.c b/lib-src/hexl.c
index b31ab812534..89ea7d9f60c 100644
--- a/lib-src/hexl.c
+++ b/lib-src/hexl.c
@@ -1,6 +1,5 @@
1/* Convert files for Emacs Hexl mode. 1/* Convert files for Emacs Hexl mode.
2 Copyright (C) 1989, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2 Copyright (C) 1989, 2001-2011 Free Software Foundation, Inc.
3 2009, 2010 Free Software Foundation, Inc.
4 3
5Author: Keith Gabryelski 4Author: Keith Gabryelski
6(according to authors.el) 5(according to authors.el)
@@ -179,7 +178,9 @@ main (int argc, char **argv)
179 178
180#define hexchar(x) (isdigit (x) ? x - '0' : x - 'a' + 10) 179#define hexchar(x) (isdigit (x) ? x - '0' : x - 'a' + 10)
181 180
182 fread (buf, 1, 10, fp); /* skip 10 bytes */ 181 /* Skip 10 bytes. */
182 if (fread (buf, 1, 10, fp) != 10)
183 break;
183 184
184 for (i=0; i < 16; ++i) 185 for (i=0; i < 16; ++i)
185 { 186 {
@@ -207,7 +208,9 @@ main (int argc, char **argv)
207 if (i < 16) 208 if (i < 16)
208 break; 209 break;
209 210
210 fread (buf, 1, 18, fp); /* skip 18 bytes */ 211 /* Skip 18 bytes. */
212 if (fread (buf, 1, 18, fp) != 18)
213 break;
211 } 214 }
212 } 215 }
213 } 216 }
@@ -282,7 +285,5 @@ usage (void)
282 exit (EXIT_FAILURE); 285 exit (EXIT_FAILURE);
283} 286}
284 287
285/* arch-tag: 20e04fb7-926e-4e48-be86-64fe869ecdaa
286 (do not change this comment) */
287 288
288/* hexl.c ends here */ 289/* hexl.c ends here */
diff --git a/lib-src/make-docfile.c b/lib-src/make-docfile.c
index e2dc99214d2..8addbda0489 100644
--- a/lib-src/make-docfile.c
+++ b/lib-src/make-docfile.c
@@ -1,6 +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, 1993, 1994, 1997, 1999, 2000, 2001, 2 Copyright (C) 1985-1986, 1992-1994, 1997, 1999-2011
3 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
4 Free Software Foundation, Inc. 3 Free Software Foundation, Inc.
5 4
6This file is part of GNU Emacs. 5This file is part of GNU Emacs.
@@ -78,9 +77,7 @@ void fatal (const char *s1, const char *s2) NO_RETURN;
78#undef chdir 77#undef chdir
79#endif 78#endif
80 79
81#ifdef HAVE_UNISTD_H
82#include <unistd.h> 80#include <unistd.h>
83#endif
84 81
85/* Stdio stream for output to the DOC file. */ 82/* Stdio stream for output to the DOC file. */
86FILE *outfile; 83FILE *outfile;
@@ -160,7 +157,11 @@ main (int argc, char **argv)
160 } 157 }
161 if (argc > i + 1 && !strcmp (argv[i], "-d")) 158 if (argc > i + 1 && !strcmp (argv[i], "-d"))
162 { 159 {
163 chdir (argv[i + 1]); 160 if (chdir (argv[i + 1]) != 0)
161 {
162 perror (argv[i + 1]);
163 return EXIT_FAILURE;
164 }
164 i += 2; 165 i += 2;
165 } 166 }
166 167
@@ -650,6 +651,7 @@ scan_c_file (char *filename, const char *mode)
650 651
651 if (defunflag && (commas == 1 || commas == 2)) 652 if (defunflag && (commas == 1 || commas == 2))
652 { 653 {
654 int scanned = 0;
653 do 655 do
654 c = getc (infile); 656 c = getc (infile);
655 while (c == ' ' || c == '\n' || c == '\r' || c == '\t'); 657 while (c == ' ' || c == '\n' || c == '\r' || c == '\t');
@@ -657,12 +659,14 @@ scan_c_file (char *filename, const char *mode)
657 goto eof; 659 goto eof;
658 ungetc (c, infile); 660 ungetc (c, infile);
659 if (commas == 2) /* pick up minargs */ 661 if (commas == 2) /* pick up minargs */
660 fscanf (infile, "%d", &minargs); 662 scanned = fscanf (infile, "%d", &minargs);
661 else /* pick up maxargs */ 663 else /* pick up maxargs */
662 if (c == 'M' || c == 'U') /* MANY || UNEVALLED */ 664 if (c == 'M' || c == 'U') /* MANY || UNEVALLED */
663 maxargs = -1; 665 maxargs = -1;
664 else 666 else
665 fscanf (infile, "%d", &maxargs); 667 scanned = fscanf (infile, "%d", &maxargs);
668 if (scanned < 0)
669 goto eof;
666 } 670 }
667 } 671 }
668 672
@@ -869,8 +873,8 @@ scan_lisp_file (const char *filename, const char *mode)
869 c = getc (infile); 873 c = getc (infile);
870 if (c == '@') 874 if (c == '@')
871 { 875 {
872 int length = 0; 876 size_t length = 0;
873 int i; 877 size_t i;
874 878
875 /* Read the length. */ 879 /* Read the length. */
876 while ((c = getc (infile), 880 while ((c = getc (infile),
@@ -880,6 +884,12 @@ scan_lisp_file (const char *filename, const char *mode)
880 length += c - '0'; 884 length += c - '0';
881 } 885 }
882 886
887 if (length <= 1)
888 fatal ("invalid dynamic doc string length", "");
889
890 if (c != ' ')
891 fatal ("space not found after dynamic doc string length", "");
892
883 /* The next character is a space that is counted in the length 893 /* The next character is a space that is counted in the length
884 but not part of the doc string. 894 but not part of the doc string.
885 We already read it, so just ignore it. */ 895 We already read it, so just ignore it. */
@@ -895,7 +905,7 @@ scan_lisp_file (const char *filename, const char *mode)
895 but it is redundant in DOC. So get rid of it here. */ 905 but it is redundant in DOC. So get rid of it here. */
896 saved_string[length - 1] = 0; 906 saved_string[length - 1] = 0;
897 /* Skip the line break. */ 907 /* Skip the line break. */
898 while (c == '\n' && c == '\r') 908 while (c == '\n' || c == '\r')
899 c = getc (infile); 909 c = getc (infile);
900 /* Skip the following line. */ 910 /* Skip the following line. */
901 while (c != '\n' && c != '\r') 911 while (c != '\n' && c != '\r')
@@ -1201,7 +1211,5 @@ scan_lisp_file (const char *filename, const char *mode)
1201 return 0; 1211 return 0;
1202} 1212}
1203 1213
1204/* arch-tag: f7203aaf-991a-4238-acb5-601db56f2894
1205 (do not change this comment) */
1206 1214
1207/* make-docfile.c ends here */ 1215/* make-docfile.c ends here */
diff --git a/lib-src/makefile.w32-in b/lib-src/makefile.w32-in
index 25fb499cf3b..52d1cb5680a 100644
--- a/lib-src/makefile.w32-in
+++ b/lib-src/makefile.w32-in
@@ -1,6 +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, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2# Copyright (C) 2000-2011 Free Software Foundation, Inc.
3# 2009, 2010 Free Software Foundation, Inc.
4 3
5# This file is part of GNU Emacs. 4# This file is part of GNU Emacs.
6 5
@@ -18,15 +17,13 @@
18# along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. 17# along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
19 18
20 19
21ALL = make-docfile hexl ctags etags movemail ebrowse sorted-doc digest-doc emacsclient 20ALL = make-docfile hexl ctags etags movemail ebrowse emacsclient
22 21
23.PHONY: $(ALL) 22.PHONY: $(ALL)
24 23
25VERSION = 24.0.50
26
27LOCAL_FLAGS = -DWINDOWSNT -DDOS_NT -DSTDC_HEADERS=1 -DNO_LDAV=1 \ 24LOCAL_FLAGS = -DWINDOWSNT -DDOS_NT -DSTDC_HEADERS=1 -DNO_LDAV=1 \
28 -DNO_ARCHIVES=1 -DHAVE_CONFIG_H=1 -I../nt/inc \ 25 -DNO_ARCHIVES=1 -DHAVE_CONFIG_H=1 -I../lib \
29 -I../src 26 -I../nt/inc -I../src
30 27
31LIBS = $(BASE_LIBS) $(ADVAPI32) 28LIBS = $(BASE_LIBS) $(ADVAPI32)
32 29
@@ -36,10 +33,6 @@ $(BLD)/hexl.exe: $(BLD)/hexl.$(O)
36 $(LINK) $(LINK_OUT)$@ $(LINK_FLAGS) $(BLD)/hexl.$(O) $(LIBS) 33 $(LINK) $(LINK_OUT)$@ $(LINK_FLAGS) $(BLD)/hexl.$(O) $(LIBS)
37$(BLD)/fakemail.exe: $(BLD)/fakemail.$(O) $(BLD)/ntlib.$(O) 34$(BLD)/fakemail.exe: $(BLD)/fakemail.$(O) $(BLD)/ntlib.$(O)
38 $(LINK) $(LINK_OUT)$@ $(LINK_FLAGS) $(BLD)/fakemail.$(O) $(BLD)/ntlib.$(O) $(LIBS) 35 $(LINK) $(LINK_OUT)$@ $(LINK_FLAGS) $(BLD)/fakemail.$(O) $(BLD)/ntlib.$(O) $(LIBS)
39$(BLD)/sorted-doc.exe: $(BLD)/sorted-doc.$(O)
40 $(LINK) $(LINK_OUT)$@ $(LINK_FLAGS) $(BLD)/sorted-doc.$(O) $(LIBS)
41$(BLD)/digest-doc.exe: $(BLD)/digest-doc.$(O)
42 $(LINK) $(LINK_OUT)$@ $(LINK_FLAGS) $(BLD)/digest-doc.$(O) $(LIBS)
43$(BLD)/test-distrib.exe: $(BLD)/test-distrib.$(O) 36$(BLD)/test-distrib.exe: $(BLD)/test-distrib.$(O)
44 $(LINK) $(LINK_OUT)$@ $(LINK_FLAGS) $(BLD)/test-distrib.$(O) $(LIBS) 37 $(LINK) $(LINK_OUT)$@ $(LINK_FLAGS) $(BLD)/test-distrib.$(O) $(LIBS)
45 38
@@ -50,29 +43,24 @@ ebrowse: stamp_BLD $(BLD)/ebrowse.exe
50hexl: stamp_BLD $(BLD)/hexl.exe 43hexl: stamp_BLD $(BLD)/hexl.exe
51movemail: stamp_BLD $(BLD)/movemail.exe 44movemail: stamp_BLD $(BLD)/movemail.exe
52fakemail: stamp_BLD $(BLD)/fakemail.exe 45fakemail: stamp_BLD $(BLD)/fakemail.exe
53sorted-doc: stamp_BLD $(BLD)/sorted-doc.exe
54digest-doc: stamp_BLD $(BLD)/digest-doc.exe
55emacsclient: stamp_BLD $(BLD)/emacsclient.exe $(BLD)/emacsclientw.exe 46emacsclient: stamp_BLD $(BLD)/emacsclient.exe $(BLD)/emacsclientw.exe
56 47
57test-distrib: stamp_BLD $(BLD)/test-distrib.exe 48test-distrib: stamp_BLD $(BLD)/test-distrib.exe
58 "$(BLD)/test-distrib.exe" "$(SRC)/testfile" 49 "$(BLD)/test-distrib.exe" "$(SRC)/testfile"
59 50
60GETOPTOBJS = $(BLD)/getopt.$(O) $(BLD)/getopt1.$(O)
61GETOPTDEPS = $(GETOPTOBJS) getopt.h
62MOVEMAILOBJS = $(BLD)/movemail.$(O) \ 51MOVEMAILOBJS = $(BLD)/movemail.$(O) \
63 $(BLD)/pop.$(O) \ 52 $(BLD)/pop.$(O) \
64 $(BLD)/ntlib.$(O) \ 53 ../lib/$(BLD)/libgnu.$(A) \
65 $(GETOPTOBJS) 54 $(BLD)/ntlib.$(O)
66 55
67$(BLD)/movemail.exe: $(MOVEMAILOBJS) getopt.h 56$(BLD)/movemail.exe: $(MOVEMAILOBJS) ../lib/getopt.h
68# put wsock32.lib before $(LIBS) to ensure we don't link to ws2_32.lib 57# put wsock32.lib before $(LIBS) to ensure we don't link to ws2_32.lib
69 $(LINK) $(LINK_OUT)$@ $(LINK_FLAGS) $(MOVEMAILOBJS) $(WSOCK32) $(LIBS) 58 $(LINK) $(LINK_OUT)$@ $(LINK_FLAGS) $(MOVEMAILOBJS) $(WSOCK32) $(LIBS)
70 59
71ECLIENT_CFLAGS = -DHAVE_GETCWD -DHAVE_STRERROR -DVERSION="\"$(VERSION)\"" 60ECLIENT_CFLAGS = -DHAVE_GETCWD -DHAVE_STRERROR
72ECLIENTOBJS = $(BLD)/emacsclient.$(O) \ 61ECLIENTOBJS = $(BLD)/emacsclient.$(O) \
73 $(BLD)/getopt.$(O) \ 62 $(BLD)/ntlib.$(O) \
74 $(BLD)/getopt1.$(O) \ 63 ../lib/$(BLD)/libgnu.$(A)
75 $(BLD)/ntlib.$(O)
76CLIENTRES = ../nt/$(BLD)/emacsclient.res 64CLIENTRES = ../nt/$(BLD)/emacsclient.res
77 65
78$(CLIENTRES): ../nt/emacsclient.rc 66$(CLIENTRES): ../nt/emacsclient.rc
@@ -87,14 +75,11 @@ $(BLD)/emacsclientw.exe: $(ECLIENTOBJS) $(CLIENTRES)
87# put wsock32.lib before $(LIBS) to ensure we don't link to ws2_32.lib 75# put wsock32.lib before $(LIBS) to ensure we don't link to ws2_32.lib
88 $(LINK) $(LINK_OUT)$@ $(CLIENTRES) -mwindows $(LINK_FLAGS) $(ECLIENTOBJS) $(WSOCK32) $(USER32) $(COMCTL32) $(LIBS) 76 $(LINK) $(LINK_OUT)$@ $(CLIENTRES) -mwindows $(LINK_FLAGS) $(ECLIENTOBJS) $(WSOCK32) $(USER32) $(COMCTL32) $(LIBS)
89 77
90# emacsclient.$(O) depends on makefile.w32-in because makefile.w32-in 78$(BLD)/emacsclient.$(O): emacsclient.c
91# can be edited to define VERSION string, which is part of ECLIENT_CFLAGS.
92$(BLD)/emacsclient.$(O): emacsclient.c makefile.w32-in
93 $(CC) $(CFLAGS) $(ECLIENT_CFLAGS) $(CC_OUT)$@ emacsclient.c 79 $(CC) $(CFLAGS) $(ECLIENT_CFLAGS) $(CC_OUT)$@ emacsclient.c
94 80
95ETAGSOBJ = $(BLD)/etags.$(O) \ 81ETAGSOBJ = $(BLD)/etags.$(O) \
96 $(BLD)/getopt.$(O) \ 82 ../lib/$(BLD)/libgnu.$(A) \
97 $(BLD)/getopt1.$(O) \
98 $(BLD)/ntlib.$(O) \ 83 $(BLD)/ntlib.$(O) \
99 $(BLD)/regex.$(O) 84 $(BLD)/regex.$(O)
100 85
@@ -103,8 +88,7 @@ $(BLD)/etags.exe: $(ETAGSOBJ)
103 88
104 89
105EBROWSEOBJ = $(BLD)/ebrowse.$(O) \ 90EBROWSEOBJ = $(BLD)/ebrowse.$(O) \
106 $(BLD)/getopt.$(O) \ 91 ../lib/$(BLD)/libgnu.$(A) \
107 $(BLD)/getopt1.$(O) \
108 $(BLD)/ntlib.$(O) 92 $(BLD)/ntlib.$(O)
109 93
110$(BLD)/ebrowse.exe: $(EBROWSEOBJ) 94$(BLD)/ebrowse.exe: $(EBROWSEOBJ)
@@ -114,13 +98,12 @@ $(BLD)/regex.$(O): ../src/regex.c ../src/regex.h ../src/config.h
114 $(CC) $(CFLAGS) -DCONFIG_BROKETS -DINHIBIT_STRING_HEADER \ 98 $(CC) $(CFLAGS) -DCONFIG_BROKETS -DINHIBIT_STRING_HEADER \
115 ../src/regex.c $(CC_OUT)$@ 99 ../src/regex.c $(CC_OUT)$@
116 100
117ETAGS_CFLAGS = -DHAVE_GETCWD 101ETAGS_CFLAGS = -DHAVE_GETCWD -DEMACS_NAME="\"GNU Emacs\""
118$(BLD)/etags.$(O): etags.c 102$(BLD)/etags.$(O): etags.c
119 $(CC) $(CFLAGS) $(ETAGS_CFLAGS) $(CC_OUT)$@ etags.c 103 $(CC) $(CFLAGS) $(ETAGS_CFLAGS) $(CC_OUT)$@ etags.c
120 104
121CTAGSOBJ = $(BLD)/ctags.$(O) \ 105CTAGSOBJ = $(BLD)/ctags.$(O) \
122 $(BLD)/getopt.$(O) \ 106 ../lib/$(BLD)/libgnu.$(A) \
123 $(BLD)/getopt1.$(O) \
124 $(BLD)/ntlib.$(O) \ 107 $(BLD)/ntlib.$(O) \
125 $(BLD)/regex.$(O) 108 $(BLD)/regex.$(O)
126 109
@@ -131,7 +114,7 @@ ctags.c: etags.c
131 - $(DEL) ctags.c 114 - $(DEL) ctags.c
132 $(CP) etags.c ctags.c 115 $(CP) etags.c ctags.c
133 116
134CTAGS_CFLAGS = -DCTAGS $(ETAGS_CFLAGS) 117CTAGS_CFLAGS = -DCTAGS $(ETAGS_CFLAGS) -DEMACS_NAME="\"GNU Emacs\""
135$(BLD)/ctags.$(O): ctags.c 118$(BLD)/ctags.$(O): ctags.c
136 $(CC) $(CFLAGS) $(CTAGS_CFLAGS) $(CC_OUT)$@ ctags.c 119 $(CC) $(CFLAGS) $(CTAGS_CFLAGS) $(CC_OUT)$@ ctags.c
137 120
@@ -159,7 +142,7 @@ obj = dosfns.o msdos.o \
159 syntax.o bytecode.o \ 142 syntax.o bytecode.o \
160 process.o callproc.o unexw32.o \ 143 process.o callproc.o unexw32.o \
161 region-cache.o sound.o atimer.o \ 144 region-cache.o sound.o atimer.o \
162 doprnt.o strftime.o intervals.o textprop.o composite.o md5.o 145 doprnt.o intervals.o textprop.o composite.o md5.o
163 146
164# 147#
165# These are the lisp files that are loaded up in loadup.el 148# These are the lisp files that are loaded up in loadup.el
@@ -195,7 +178,6 @@ OTHER_PLATFORM_SUPPORT = \
195 $(lispsource)term/pc-win.elc \ 178 $(lispsource)term/pc-win.elc \
196 $(lispsource)x-dnd.elc \ 179 $(lispsource)x-dnd.elc \
197 $(lispsource)term/x-win.elc \ 180 $(lispsource)term/x-win.elc \
198 $(lispsource)emacs-lisp/easymenu.elc \
199 $(lispsource)term/ns-win.elc 181 $(lispsource)term/ns-win.elc
200 182
201 183
@@ -335,8 +317,6 @@ install: $(INSTALL_FILES)
335 $(CP) $(BLD)/ctags.exe $(INSTALL_DIR)/bin 317 $(CP) $(BLD)/ctags.exe $(INSTALL_DIR)/bin
336 $(CP) $(BLD)/hexl.exe $(INSTALL_DIR)/bin 318 $(CP) $(BLD)/hexl.exe $(INSTALL_DIR)/bin
337 $(CP) $(BLD)/movemail.exe $(INSTALL_DIR)/bin 319 $(CP) $(BLD)/movemail.exe $(INSTALL_DIR)/bin
338 $(CP) $(BLD)/sorted-doc.exe $(INSTALL_DIR)/bin
339 $(CP) $(BLD)/digest-doc.exe $(INSTALL_DIR)/bin
340 $(CP) $(BLD)/emacsclient.exe $(INSTALL_DIR)/bin 320 $(CP) $(BLD)/emacsclient.exe $(INSTALL_DIR)/bin
341 $(CP) $(BLD)/emacsclientw.exe $(INSTALL_DIR)/bin 321 $(CP) $(BLD)/emacsclientw.exe $(INSTALL_DIR)/bin
342 - mkdir "$(INSTALL_DIR)/etc" 322 - mkdir "$(INSTALL_DIR)/etc"
@@ -350,7 +330,6 @@ install: $(INSTALL_FILES)
350clean: 330clean:
351 - $(DEL) DOC* $(COMPILER_TEMP_FILES) 331 - $(DEL) DOC* $(COMPILER_TEMP_FILES)
352 - $(DEL) ctags.c 332 - $(DEL) ctags.c
353 - $(DEL) getopt.h
354 - $(DEL_TREE) $(OBJDIR) 333 - $(DEL_TREE) $(OBJDIR)
355 - $(DEL) stamp_BLD 334 - $(DEL) stamp_BLD
356 - $(DEL) echolisp.tmp 335 - $(DEL) echolisp.tmp
@@ -375,9 +354,6 @@ cleanall: clean
375 echo $(CONFIG_H) has changed. Re-run configure.bat. 354 echo $(CONFIG_H) has changed. Re-run configure.bat.
376 exit -1 355 exit -1
377 356
378getopt.h: getopt_.h
379 $(CP) $(ALL_DEPS) $@
380
381### TAGS ### 357### TAGS ###
382 358
383TAGS: $(BLD)/etags.exe *.c *.h 359TAGS: $(BLD)/etags.exe *.c *.h
@@ -402,10 +378,7 @@ $(BLD)/ctags.$(O) : \
402 $(EMACS_ROOT)/src/m/intel386.h \ 378 $(EMACS_ROOT)/src/m/intel386.h \
403 $(EMACS_ROOT)/lib-src/../src/config.h \ 379 $(EMACS_ROOT)/lib-src/../src/config.h \
404 $(SRC)/ntlib.h \ 380 $(SRC)/ntlib.h \
405 $(SRC)/getopt.h 381 $(EMACS_ROOT)/lib/getopt.h
406
407$(BLD)/digest-doc.$(O) : \
408 $(SRC)/digest-doc.c
409 382
410$(BLD)/emacsclient.$(O) : \ 383$(BLD)/emacsclient.$(O) : \
411 $(SRC)/emacsclient.c \ 384 $(SRC)/emacsclient.c \
@@ -420,7 +393,7 @@ $(BLD)/etags.$(O) : \
420 $(EMACS_ROOT)/src/m/intel386.h \ 393 $(EMACS_ROOT)/src/m/intel386.h \
421 $(EMACS_ROOT)/lib-src/../src/config.h \ 394 $(EMACS_ROOT)/lib-src/../src/config.h \
422 $(SRC)/ntlib.h \ 395 $(SRC)/ntlib.h \
423 $(SRC)/getopt.h 396 $(EMACS_ROOT)/lib/getopt.h
424 397
425$(BLD)/fakemail.$(O) : \ 398$(BLD)/fakemail.$(O) : \
426 $(SRC)/fakemail.c \ 399 $(SRC)/fakemail.c \
@@ -437,21 +410,6 @@ $(BLD)/getdate.$(O) : \
437 $(EMACS_ROOT)/src/config.h \ 410 $(EMACS_ROOT)/src/config.h \
438 $(MSTOOLS_SYS)/types.h 411 $(MSTOOLS_SYS)/types.h
439 412
440$(BLD)/getopt.$(O) : \
441 $(SRC)/getopt.c \
442 $(EMACS_ROOT)/src/s/ms-w32.h \
443 $(EMACS_ROOT)/src/m/intel386.h \
444 $(EMACS_ROOT)/src/config.h \
445 $(SRC)/ntlib.h \
446 $(SRC)/getopt.h
447
448$(BLD)/getopt1.$(O) : \
449 $(SRC)/getopt1.c \
450 $(EMACS_ROOT)/src/s/ms-w32.h \
451 $(EMACS_ROOT)/src/m/intel386.h \
452 $(EMACS_ROOT)/src/config.h \
453 $(SRC)/getopt.h
454
455$(BLD)/hexl.$(O) : \ 413$(BLD)/hexl.$(O) : \
456 $(SRC)/hexl.c 414 $(SRC)/hexl.c
457 415
@@ -496,12 +454,6 @@ $(BLD)/profile.$(O) : \
496$(BLD)/qsort.$(O) : \ 454$(BLD)/qsort.$(O) : \
497 $(SRC)/qsort.c 455 $(SRC)/qsort.c
498 456
499$(BLD)/sorted-doc.$(O) : \
500 $(SRC)/sorted-doc.c \
501 $(EMACS_ROOT)/src/s/ms-w32.h \
502 $(EMACS_ROOT)/src/m/intel386.h \
503 $(EMACS_ROOT)/src/config.h
504
505$(BLD)/tcp.$(O) : \ 457$(BLD)/tcp.$(O) : \
506 $(SRC)/tcp.c 458 $(SRC)/tcp.c
507 459
@@ -519,9 +471,7 @@ $(BLD)/timer.$(O) : \
519# 471#
520$(BLD)/make-docfile.$(O) $(BLD)/hexl.$(O) $(BLD)/fakemail.$(O): stamp_BLD 472$(BLD)/make-docfile.$(O) $(BLD)/hexl.$(O) $(BLD)/fakemail.$(O): stamp_BLD
521 473
522$(BLD)/sorted-doc.$(O) $(BLD)/digest-doc.$(O): stamp_BLD 474$(BLD)/test-distrib.$(O) $(MOVEMAILOBJS): stamp_BLD
523
524$(BLD)/test-distrib.$(O) $(GETOPTOBJS) $(MOVEMAILOBJS): stamp_BLD
525 475
526$(BLD)/emacsclient.$(O) $(BLD)/etags.$(O) $(BLD)/regex.$(O): stamp_BLD 476$(BLD)/emacsclient.$(O) $(BLD)/etags.$(O) $(BLD)/regex.$(O): stamp_BLD
527 477
diff --git a/lib-src/movemail.c b/lib-src/movemail.c
index f300942427e..682aa10aa39 100644
--- a/lib-src/movemail.c
+++ b/lib-src/movemail.c
@@ -1,7 +1,8 @@
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 Copyright (C) 1986, 1992, 1993, 1994, 1996, 1999, 2001, 2002, 2003, 2004, 3
4 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 4Copyright (C) 1986, 1992-1994, 1996, 1999, 2001-2011
5 Free Software Foundation, Inc.
5 6
6This file is part of GNU Emacs. 7This file is part of GNU Emacs.
7 8
@@ -63,9 +64,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
63#include <time.h> 64#include <time.h>
64 65
65#include <getopt.h> 66#include <getopt.h>
66#ifdef HAVE_UNISTD_H
67#include <unistd.h> 67#include <unistd.h>
68#endif
69#ifdef HAVE_FCNTL_H 68#ifdef HAVE_FCNTL_H
70#include <fcntl.h> 69#include <fcntl.h>
71#endif 70#endif
@@ -356,7 +355,7 @@ main (int argc, char **argv)
356 time_t touched_lock, now; 355 time_t touched_lock, now;
357#endif 356#endif
358 357
359 if (setuid (getuid ()) < 0 || setegid (real_gid) < 0) 358 if (setuid (getuid ()) < 0 || setregid (-1, real_gid) < 0)
360 fatal ("Failed to drop privileges", 0, 0); 359 fatal ("Failed to drop privileges", 0, 0);
361 360
362#ifndef MAIL_USE_MMDF 361#ifndef MAIL_USE_MMDF
@@ -383,7 +382,7 @@ main (int argc, char **argv)
383 if (outdesc < 0) 382 if (outdesc < 0)
384 pfatal_with_name (outname); 383 pfatal_with_name (outname);
385 384
386 if (setegid (priv_gid) < 0) 385 if (setregid (-1, priv_gid) < 0)
387 fatal ("Failed to regain privileges", 0, 0); 386 fatal ("Failed to regain privileges", 0, 0);
388 387
389 /* This label exists so we can retry locking 388 /* This label exists so we can retry locking
@@ -480,7 +479,7 @@ main (int argc, char **argv)
480#endif 479#endif
481 480
482 /* Prevent symlink attacks truncating other users' mailboxes */ 481 /* Prevent symlink attacks truncating other users' mailboxes */
483 if (setegid (real_gid) < 0) 482 if (setregid (-1, real_gid) < 0)
484 fatal ("Failed to drop privileges", 0, 0); 483 fatal ("Failed to drop privileges", 0, 0);
485 484
486 /* Check to make sure no errors before we zap the inbox. */ 485 /* Check to make sure no errors before we zap the inbox. */
@@ -490,7 +489,8 @@ main (int argc, char **argv)
490#ifdef MAIL_USE_SYSTEM_LOCK 489#ifdef MAIL_USE_SYSTEM_LOCK
491 if (! preserve_mail) 490 if (! preserve_mail)
492 { 491 {
493 ftruncate (indesc, 0L); 492 if (ftruncate (indesc, 0L) != 0)
493 pfatal_with_name (inname);
494 } 494 }
495#endif /* MAIL_USE_SYSTEM_LOCK */ 495#endif /* MAIL_USE_SYSTEM_LOCK */
496 496
@@ -515,7 +515,7 @@ main (int argc, char **argv)
515#endif /* not MAIL_USE_SYSTEM_LOCK */ 515#endif /* not MAIL_USE_SYSTEM_LOCK */
516 516
517 /* End of mailbox truncation */ 517 /* End of mailbox truncation */
518 if (setegid (priv_gid) < 0) 518 if (setregid (-1, priv_gid) < 0)
519 fatal ("Failed to regain privileges", 0, 0); 519 fatal ("Failed to regain privileges", 0, 0);
520 520
521#ifdef MAIL_USE_MAILLOCK 521#ifdef MAIL_USE_MAILLOCK
@@ -933,7 +933,5 @@ strerror (errnum)
933 933
934#endif /* ! HAVE_STRERROR */ 934#endif /* ! HAVE_STRERROR */
935 935
936/* arch-tag: 1c323112-41fe-4fe5-8de9-494de631f73f
937 (do not change this comment) */
938 936
939/* movemail.c ends here */ 937/* movemail.c ends here */
diff --git a/lib-src/ntlib.c b/lib-src/ntlib.c
index c24b35d9a19..0ecd4177d2c 100644
--- a/lib-src/ntlib.c
+++ b/lib-src/ntlib.c
@@ -1,6 +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, 2002, 2003, 2004, 2005, 2006, 2007, 2 Copyright (C) 1994, 2001-2011 Free Software Foundation, Inc.
3 2008, 2009, 2010 Free Software Foundation, Inc.
4 3
5This file is part of GNU Emacs. 4This file is part of GNU Emacs.
6 5
@@ -144,7 +143,7 @@ setuid (unsigned uid)
144} 143}
145 144
146int 145int
147setegid (unsigned gid) 146setregid (unsigned rgid, unsigned gid)
148{ 147{
149 return 0; 148 return 0;
150} 149}
@@ -374,5 +373,3 @@ stat (const char * path, struct stat * buf)
374 return 0; 373 return 0;
375} 374}
376 375
377/* arch-tag: 7b63fb83-70ee-4124-8822-54e53e5d0773
378 (do not change this comment) */
diff --git a/lib-src/ntlib.h b/lib-src/ntlib.h
index 4dd6a32ee32..be8d2a58a50 100644
--- a/lib-src/ntlib.h
+++ b/lib-src/ntlib.h
@@ -1,6 +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, 2003, 2004, 2005, 2006, 2007, 2 Copyright (C) 1994, 2002-2011 Free Software Foundation, Inc.
3 2008, 2009, 2010 Free Software Foundation, Inc.
4 3
5This file is part of GNU Emacs. 4This file is part of GNU Emacs.
6 5
@@ -39,7 +38,7 @@ unsigned getuid (void);
39unsigned getegid (void); 38unsigned getegid (void);
40unsigned getgid (void); 39unsigned getgid (void);
41int setuid (unsigned uid); 40int setuid (unsigned uid);
42int setegid (unsigned gid); 41int setregid (unsigned rgid, unsigned gid);
43char * getpass (const char * prompt); 42char * getpass (const char * prompt);
44int fchown (int fd, unsigned uid, unsigned gid); 43int fchown (int fd, unsigned uid, unsigned gid);
45 44
@@ -106,5 +105,3 @@ int fchown (int fd, unsigned uid, unsigned gid);
106 105
107/* end of ntlib.h */ 106/* end of ntlib.h */
108 107
109/* arch-tag: 93444f66-7b98-4aa5-a5cd-01444094af28
110 (do not change this comment) */
diff --git a/lib-src/pop.c b/lib-src/pop.c
index 9eabbd2041e..a3fda09d44f 100644
--- a/lib-src/pop.c
+++ b/lib-src/pop.c
@@ -1,6 +1,7 @@
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 Copyright (C) 1991, 1993, 1996, 1997, 1999, 2001, 2002, 2003, 2004, 2
3 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 3Copyright (C) 1991, 1993, 1996-1997, 1999, 2001-2011
4 Free Software Foundation, Inc.
4 5
5Author: Jonathan Kamens <jik@security.ov.com> 6Author: Jonathan Kamens <jik@security.ov.com>
6 7
@@ -68,9 +69,7 @@ extern struct servent *hes_getservbyname (/* char *, char * */);
68#include <string.h> 69#include <string.h>
69#define index strchr 70#define index strchr
70#endif 71#endif
71#ifdef HAVE_UNISTD_H
72#include <unistd.h> 72#include <unistd.h>
73#endif
74 73
75#ifdef KERBEROS 74#ifdef KERBEROS
76# ifdef HAVE_KRB5_H 75# ifdef HAVE_KRB5_H
@@ -1626,6 +1625,3 @@ find_crlf (char *in_string, int len)
1626} 1625}
1627 1626
1628#endif /* MAIL_USE_POP */ 1627#endif /* MAIL_USE_POP */
1629
1630/* arch-tag: ceb37041-b7ad-49a8-a63d-286618b8367d
1631 (do not change this comment) */
diff --git a/lib-src/pop.h b/lib-src/pop.h
index 2ba3fab83a0..bc079fcc971 100644
--- a/lib-src/pop.h
+++ b/lib-src/pop.h
@@ -1,6 +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, 2002, 2003, 2004, 2005, 2006, 2007, 2 Copyright (C) 1991, 1993, 2001-2011 Free Software Foundation, Inc.
3 2008, 2009, 2010 Free Software Foundation, Inc.
4 3
5Author: Jonathan Kamens <jik@security.ov.com> 4Author: Jonathan Kamens <jik@security.ov.com>
6 5
@@ -75,5 +74,3 @@ extern int pop_reset (popserver server);
75extern int pop_quit (popserver server); 74extern int pop_quit (popserver server);
76extern void pop_close (popserver); 75extern void pop_close (popserver);
77 76
78/* arch-tag: 76cc5f58-8e86-48fa-bc72-a7c6cb1c4f1c
79 (do not change this comment) */
diff --git a/lib-src/profile.c b/lib-src/profile.c
index 37653e63c49..9ce9993f4b1 100644
--- a/lib-src/profile.c
+++ b/lib-src/profile.c
@@ -1,6 +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, 2002, 2003, 2004, 2005, 2006, 2 Copyright (C) 1992, 1994, 1999, 2001-2011 Free Software Foundation, Inc.
3 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
4 3
5Author: Boaz Ben-Zvi <boaz@lcs.mit.edu> 4Author: Boaz Ben-Zvi <boaz@lcs.mit.edu>
6 5
@@ -102,7 +101,5 @@ main (void)
102 exit (EXIT_FAILURE); 101 exit (EXIT_FAILURE);
103} 102}
104 103
105/* arch-tag: 8db68f7e-2322-4944-a315-dba349bdbf39
106 (do not change this comment) */
107 104
108/* profile.c ends here */ 105/* profile.c ends here */
diff --git a/lib-src/rcs-checkin b/lib-src/rcs-checkin
index f82e03bdcf1..6861a30b40b 100755
--- a/lib-src/rcs-checkin
+++ b/lib-src/rcs-checkin
@@ -2,8 +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, 1994, 1995, 2001, 2002, 2003, 2004, 2005, 2006, 5# Copyright (C) 1993-1995, 2001-2011 Free Software Foundation, Inc.
6# 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
7 6
8# This file is part of GNU Emacs. 7# This file is part of GNU Emacs.
9 8
@@ -115,4 +114,3 @@ $file"
115 ci -d -q -u $owner -m"entered into RCS" "$file" || exit 114 ci -d -q -u $owner -m"entered into RCS" "$file" || exit
116done 115done
117 116
118# arch-tag: 89c86949-ef04-4380-838b-bc1444dcb074
diff --git a/lib-src/rcs2log b/lib-src/rcs2log
index 2a2eab83fcb..4e1dd306977 100755
--- a/lib-src/rcs2log
+++ b/lib-src/rcs2log
@@ -2,9 +2,7 @@
2 2
3# RCS to ChangeLog generator 3# RCS to ChangeLog generator
4 4
5# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2001, 2002, 2003, 5# Copyright (C) 1992-1998, 2001-2011 Free Software Foundation, Inc.
6# 2004, 2005, 2006, 2007, 2008, 2009, 2010
7# Free Software Foundation, Inc.
8 6
9# Author: Paul Eggert <eggert@twinsun.com> 7# Author: Paul Eggert <eggert@twinsun.com>
10 8
@@ -22,7 +20,7 @@
22# 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/>.
23 21
24 22
25Copyright='Copyright (C) 2010 Free Software Foundation, Inc. 23Copyright='Copyright (C) 2011 Free Software Foundation, Inc.
26This program comes with NO WARRANTY, to the extent permitted by law. 24This program comes with NO WARRANTY, to the extent permitted by law.
27You may redistribute copies of this program 25You may redistribute copies of this program
28under the terms of the GNU General Public License. 26under the terms of the GNU General Public License.
@@ -777,4 +775,3 @@ exec rm -fr $logdir
777# tab-width:4 775# tab-width:4
778# End: 776# End:
779 777
780# arch-tag: cea067bd-a552-4254-ba17-078208933073
diff --git a/lib-src/sorted-doc.c b/lib-src/sorted-doc.c
deleted file mode 100644
index 4fe830e4013..00000000000
--- a/lib-src/sorted-doc.c
+++ /dev/null
@@ -1,296 +0,0 @@
1/* Give this program DOC-mm.nn.oo as standard input and it outputs to
2 standard output a file of texinfo input containing the doc strings.
3
4Copyright (C) 1989, 1992, 1994, 1996, 1999, 2000, 2001, 2002, 2003,
5 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
6
7This file is part of GNU Emacs.
8
9GNU Emacs is free software: you can redistribute it and/or modify
10it under the terms of the GNU General Public License as published by
11the Free Software Foundation, either version 3 of the License, or
12(at your option) any later version.
13
14GNU Emacs is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License
20along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
21
22
23/* This version sorts the output by function name. */
24
25#ifdef HAVE_CONFIG_H
26#include <config.h>
27#endif
28
29#include <stdio.h>
30#include <ctype.h>
31#ifdef DOS_NT
32#include <fcntl.h> /* for O_BINARY */
33#include <io.h> /* for setmode */
34#endif
35#ifndef HAVE_STDLIB_H /* config.h includes stdlib. */
36#ifndef WINDOWSNT /* src/s/ms-w32.h includes stdlib.h */
37extern char *malloc ();
38#endif
39#endif
40
41#define NUL '\0'
42#define MARKER '\037'
43
44#define DEBUG 0
45
46typedef struct line LINE;
47
48struct line
49{
50 LINE *next; /* ptr to next or NULL */
51 char *line; /* text of the line */
52};
53
54typedef struct docstr DOCSTR;
55
56struct docstr /* Allocated thing for an entry. */
57{
58 DOCSTR *next; /* next in the chain */
59 char *name; /* name of the function or var */
60 LINE *first; /* first line of doc text. */
61 char type; /* 'F' for function, 'V' for variable */
62};
63
64
65/* Print error message. `s1' is printf control string, `s2' is arg for it. */
66
67void
68error (const char *s1, const char *s2)
69{
70 fprintf (stderr, "sorted-doc: ");
71 fprintf (stderr, s1, s2);
72 fprintf (stderr, "\n");
73}
74
75/* Print error message and exit. */
76
77void
78fatal (const char *s1, const char *s2)
79{
80 error (s1, s2);
81 exit (EXIT_FAILURE);
82}
83
84/* Like malloc but get fatal error if memory is exhausted. */
85
86char *
87xmalloc (int size)
88{
89 char *result = malloc ((unsigned)size);
90 if (result == NULL)
91 fatal ("%s", "virtual memory exhausted");
92 return result;
93}
94
95char *
96xstrdup (const char *str)
97{
98 char *buf = xmalloc (strlen (str) + 1);
99 (void) strcpy (buf, str);
100 return (buf);
101}
102
103/* Comparison function for qsort to call. */
104
105int
106cmpdoc (const void *va, const void *vb)
107{
108 DOCSTR *const *a = va;
109 DOCSTR *const *b = vb;
110 register int val = strcmp ((*a)->name, (*b)->name);
111 if (val) return val;
112 return (*a)->type - (*b)->type;
113}
114
115enum state
116{
117 WAITING, BEG_NAME, NAME_GET, BEG_DESC, DESC_GET
118};
119
120const char *states[] =
121{
122 "WAITING", "BEG_NAME", "NAME_GET", "BEG_DESC", "DESC_GET"
123};
124
125int
126main (void)
127{
128 register DOCSTR *dp = NULL; /* allocated DOCSTR */
129 register LINE *lp = NULL; /* allocated line */
130 register char *bp; /* ptr inside line buffer */
131 register enum state state = WAITING; /* state at start */
132 int cnt = 0; /* number of DOCSTRs read */
133
134 DOCSTR *docs = NULL; /* chain of allocated DOCSTRS */
135 char buf[512]; /* line buffer */
136
137#ifdef DOS_NT
138 /* DOC is a binary file. */
139 if (!isatty (fileno (stdin)))
140 setmode (fileno (stdin), O_BINARY);
141#endif
142
143 bp = buf;
144
145 while (1) /* process one char at a time */
146 {
147 /* this char from the DOCSTR file */
148 register int ch = getchar ();
149
150 /* Beginnings */
151
152 if (state == WAITING)
153 {
154 if (ch == MARKER)
155 state = BEG_NAME;
156 }
157 else if (state == BEG_NAME)
158 {
159 cnt++;
160 if (dp == NULL) /* first dp allocated */
161 {
162 docs = dp = (DOCSTR*) xmalloc (sizeof (DOCSTR));
163 }
164 else /* all the rest */
165 {
166 dp->next = (DOCSTR*) xmalloc (sizeof (DOCSTR));
167 dp = dp->next;
168 }
169 lp = NULL;
170 dp->next = NULL;
171 bp = buf;
172 state = NAME_GET;
173 /* Record whether function or variable. */
174 dp->type = ch;
175 ch = getchar ();
176 }
177 else if (state == BEG_DESC)
178 {
179 if (lp == NULL) /* first line for dp */
180 {
181 dp->first = lp = (LINE*)xmalloc (sizeof (LINE));
182 }
183 else /* continuing lines */
184 {
185 lp->next = (LINE*)xmalloc (sizeof (LINE));
186 lp = lp->next;
187 }
188 lp->next = NULL;
189 bp = buf;
190 state = DESC_GET;
191 }
192
193 /* process gets */
194
195 if (state == NAME_GET || state == DESC_GET)
196 {
197 if (ch != MARKER && ch != '\n' && ch != EOF)
198 {
199 *bp++ = ch;
200 }
201 else /* saving and changing state */
202 {
203 *bp = NUL;
204 bp = xstrdup (buf);
205
206 if (state == NAME_GET)
207 dp->name = bp;
208 else
209 lp->line = bp;
210
211 bp = buf;
212 state = (ch == MARKER) ? BEG_NAME : BEG_DESC;
213 }
214 } /* NAME_GET || DESC_GET */
215 if (ch == EOF)
216 break;
217 }
218
219 {
220 DOCSTR **array;
221 register int i; /* counter */
222
223 /* build array of ptrs to DOCSTRs */
224
225 array = (DOCSTR**)xmalloc (cnt * sizeof (*array));
226 for (dp = docs, i = 0; dp != NULL ; dp = dp->next)
227 array[i++] = dp;
228
229 /* sort the array by name; within each name, by type */
230
231 qsort ((char*)array, cnt, sizeof (DOCSTR*), cmpdoc);
232
233 /* write the output header */
234
235 printf ("\\input texinfo @c -*-texinfo-*-\n");
236 printf ("@setfilename ../info/summary\n");
237 printf ("@settitle Command Summary for GNU Emacs\n");
238 printf ("@finalout\n");
239 printf ("@unnumbered Command Summary for GNU Emacs\n");
240 printf ("@table @asis\n");
241 printf ("\n");
242 printf ("@iftex\n");
243 printf ("@global@let@ITEM@item\n");
244 printf ("@def@item{@filbreak@vskip5pt@ITEM}\n");
245 printf ("@font@tensy cmsy10 scaled @magstephalf\n");
246 printf ("@font@teni cmmi10 scaled @magstephalf\n");
247 printf ("@def\\{{@tensy@char110}}\n"); /* this backslash goes with cmr10 */
248 printf ("@def|{{@tensy@char106}}\n");
249 printf ("@def@{{{@tensy@char102}}\n");
250 printf ("@def@}{{@tensy@char103}}\n");
251 printf ("@def<{{@teni@char62}}\n");
252 printf ("@def>{{@teni@char60}}\n");
253 printf ("@chardef@@64\n");
254 printf ("@catcode43=12\n");
255 printf ("@tableindent-0.2in\n");
256 printf ("@end iftex\n");
257
258 /* print each function from the array */
259
260 for (i = 0; i < cnt; i++)
261 {
262 printf ("\n@item %s @code{%s}\n@display\n",
263 array[i]->type == 'F' ? "Function" : "Variable",
264 array[i]->name);
265
266 for (lp = array[i]->first; lp != NULL ; lp = lp->next)
267 {
268 for (bp = lp->line; *bp; bp++)
269 {
270 /* the characters "@{}" need special treatment */
271 if (*bp == '@' || *bp == '{' || *bp == '}')
272 {
273 putchar('@');
274 }
275 putchar(*bp);
276 }
277 putchar ('\n');
278 }
279 printf("@end display\n");
280 /* Try to avoid a save size overflow in the TeX output
281 routine. */
282 if (i%100 == 0 && i > 0 && i != cnt)
283 printf("\n@end table\n@table @asis\n");
284 }
285
286 printf ("@end table\n");
287 printf ("@bye\n");
288 }
289
290 return EXIT_SUCCESS;
291}
292
293/* arch-tag: ce28f204-1e70-4b34-8210-3d54a5662071
294 (do not change this comment) */
295
296/* sorted-doc.c ends here */
diff --git a/lib-src/test-distrib.c b/lib-src/test-distrib.c
index 1487c2bab57..acfb147325b 100644
--- a/lib-src/test-distrib.c
+++ b/lib-src/test-distrib.c
@@ -1,7 +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, 1994, 1995, 1999, 2001, 2002, 2003, 2004, 2005, 3Copyright (C) 1987, 1993-1995, 1999, 2001-2011 Free Software Foundation, Inc.
4 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
5 4
6This file is part of GNU Emacs. 5This file is part of GNU Emacs.
7 6
@@ -19,23 +18,10 @@ You should have received a copy of the GNU General Public License
19along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ 18along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
20 19
21 20
22#ifdef HAVE_CONFIG_H
23#include <config.h> 21#include <config.h>
24#endif
25
26#include <stdio.h> 22#include <stdio.h>
27
28#ifdef HAVE_FCNTL_H
29#include <fcntl.h> 23#include <fcntl.h>
30#endif
31
32#ifdef HAVE_UNISTD_H
33#include <unistd.h> 24#include <unistd.h>
34#endif
35
36#ifndef O_RDONLY
37#define O_RDONLY 0
38#endif
39 25
40/* Break string in two parts to avoid buggy C compilers that ignore characters 26/* Break string in two parts to avoid buggy C compilers that ignore characters
41 after nulls in strings. */ 27 after nulls in strings. */
@@ -55,7 +41,7 @@ int
55cool_read (int fd, char *buf, size_t size) 41cool_read (int fd, char *buf, size_t size)
56{ 42{
57 ssize_t num; 43 ssize_t num;
58 size_t sofar = 0; 44 ssize_t sofar = 0;
59 45
60 while (1) 46 while (1)
61 { 47 {
@@ -98,7 +84,5 @@ have been corrupted in the files of Emacs, and it will not work.\n",
98 return EXIT_SUCCESS; 84 return EXIT_SUCCESS;
99} 85}
100 86
101/* arch-tag: 3a89005d-df98-4c32-aa9f-33570e16a26a
102 (do not change this comment) */
103 87
104/* test-distrib.c ends here */ 88/* test-distrib.c ends here */
diff --git a/lib-src/update-game-score.c b/lib-src/update-game-score.c
index b8e1147d1c1..9466bf7b149 100644
--- a/lib-src/update-game-score.c
+++ b/lib-src/update-game-score.c
@@ -1,7 +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, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 3Copyright (C) 2002-2011 Free Software Foundation, Inc.
4 Free Software Foundation, Inc.
5 4
6Author: Colin Walters <walters@debian.org> 5Author: Colin Walters <walters@debian.org>
7 6
@@ -34,9 +33,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
34 33
35#include <config.h> 34#include <config.h>
36 35
37#ifdef HAVE_UNISTD_H
38#include <unistd.h> 36#include <unistd.h>
39#endif
40#include <errno.h> 37#include <errno.h>
41#ifdef HAVE_STRING_H 38#ifdef HAVE_STRING_H
42#include <string.h> 39#include <string.h>
@@ -498,7 +495,5 @@ unlock_file (const char *filename, void *state)
498 return ret; 495 return ret;
499} 496}
500 497
501/* arch-tag: 2bf5c52e-4beb-463a-954e-c58b9c64736b
502 (do not change this comment) */
503 498
504/* update-game-score.c ends here */ 499/* update-game-score.c ends here */
diff --git a/lib-src/vcdiff b/lib-src/vcdiff
index 1d08e5d194f..0f975cd0ee3 100755
--- a/lib-src/vcdiff
+++ b/lib-src/vcdiff
@@ -3,8 +3,8 @@
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, 2002, 2003, 2004, 2005, 6# Copyright (C) 1992-1993, 1995, 1997, 2001-2011
7# 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 7# Free Software Foundation, Inc.
8 8
9# Author: Paul Eggert 9# Author: Paul Eggert
10# (according to authors.el) 10# (according to authors.el)
@@ -112,4 +112,3 @@ do
112 fi 112 fi
113done 113done
114 114
115# arch-tag: 4344ba3a-bcbe-4f77-971c-f43c1606953a