annotate lib-src/sorted-doc.c @ 110562:ea50a897140e

Fix int/EMACS_INT use in process.c and term.c. term.c (fast_find_position, term_mouse_highlight): Use EMACS_INT for buffer positions. process.c (read_process_output, send_process) (Fprocess_send_region, status_notify): Use EMACS_INT for buffer and string positions and size.
author Eli Zaretskii <eliz@gnu.org>
date Sat, 25 Sep 2010 08:31:15 -0400
parents fdbd24f8d999
children 5c1a707ab452
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
42260
661375cd8c4c Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 42258
diff changeset
1 /* Give this program DOC-mm.nn.oo as standard input and it outputs to
36226
c8fb06423da0 Add copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 31884
diff changeset
2 standard output a file of texinfo input containing the doc strings.
42439
d8a417105504 Remove unnecessary whitespaces.
Pavel Janík <Pavel@Janik.cz>
parents: 42412
diff changeset
3
94828
3a4bc081639c Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 79748
diff changeset
4 Copyright (C) 1989, 1992, 1994, 1996, 1999, 2000, 2001, 2002, 2003,
106815
1d1d5d9bd884 Add 2010 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 100958
diff changeset
5 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
36226
c8fb06423da0 Add copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 31884
diff changeset
6
94828
3a4bc081639c Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 79748
diff changeset
7 This file is part of GNU Emacs.
36226
c8fb06423da0 Add copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 31884
diff changeset
8
94828
3a4bc081639c Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 79748
diff changeset
9 GNU Emacs is free software: you can redistribute it and/or modify
3a4bc081639c Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 79748
diff changeset
10 it under the terms of the GNU General Public License as published by
3a4bc081639c Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 79748
diff changeset
11 the Free Software Foundation, either version 3 of the License, or
3a4bc081639c Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 79748
diff changeset
12 (at your option) any later version.
36226
c8fb06423da0 Add copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 31884
diff changeset
13
94828
3a4bc081639c Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 79748
diff changeset
14 GNU Emacs is distributed in the hope that it will be useful,
3a4bc081639c Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 79748
diff changeset
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
3a4bc081639c Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 79748
diff changeset
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a4bc081639c Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 79748
diff changeset
17 GNU General Public License for more details.
36226
c8fb06423da0 Add copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 31884
diff changeset
18
94828
3a4bc081639c Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 79748
diff changeset
19 You should have received a copy of the GNU General Public License
3a4bc081639c Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 79748
diff changeset
20 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
42258
c9f9c2f9d025 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 36226
diff changeset
21
94828
3a4bc081639c Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 79748
diff changeset
22
3a4bc081639c Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 79748
diff changeset
23 /* This version sorts the output by function name. */
29
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
24
42412
83c1951257f1 Include <config.h>.
Pavel Janík <Pavel@Janik.cz>
parents: 42260
diff changeset
25 #ifdef HAVE_CONFIG_H
83c1951257f1 Include <config.h>.
Pavel Janík <Pavel@Janik.cz>
parents: 42260
diff changeset
26 #include <config.h>
83c1951257f1 Include <config.h>.
Pavel Janík <Pavel@Janik.cz>
parents: 42260
diff changeset
27 #endif
83c1951257f1 Include <config.h>.
Pavel Janík <Pavel@Janik.cz>
parents: 42260
diff changeset
28
29
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
29 #include <stdio.h>
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
30 #include <ctype.h>
71192
fa429804cb96 [DOS_NT] <top level>: Include fcntl.h and io.h.
Eli Zaretskii <eliz@gnu.org>
parents: 70285
diff changeset
31 #ifdef DOS_NT
fa429804cb96 [DOS_NT] <top level>: Include fcntl.h and io.h.
Eli Zaretskii <eliz@gnu.org>
parents: 70285
diff changeset
32 #include <fcntl.h> /* for O_BINARY */
fa429804cb96 [DOS_NT] <top level>: Include fcntl.h and io.h.
Eli Zaretskii <eliz@gnu.org>
parents: 70285
diff changeset
33 #include <io.h> /* for setmode */
fa429804cb96 [DOS_NT] <top level>: Include fcntl.h and io.h.
Eli Zaretskii <eliz@gnu.org>
parents: 70285
diff changeset
34 #endif
31884
7b52b49d1148 Include config.h.
Dave Love <fx@gnu.org>
parents: 24533
diff changeset
35 #ifndef HAVE_STDLIB_H /* config.h includes stdlib. */
71192
fa429804cb96 [DOS_NT] <top level>: Include fcntl.h and io.h.
Eli Zaretskii <eliz@gnu.org>
parents: 70285
diff changeset
36 #ifndef WINDOWSNT /* src/s/ms-w32.h includes stdlib.h */
29
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
37 extern char *malloc ();
31884
7b52b49d1148 Include config.h.
Dave Love <fx@gnu.org>
parents: 24533
diff changeset
38 #endif
71192
fa429804cb96 [DOS_NT] <top level>: Include fcntl.h and io.h.
Eli Zaretskii <eliz@gnu.org>
parents: 70285
diff changeset
39 #endif
29
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
40
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
41 #define NUL '\0'
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
42 #define MARKER '\037'
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
43
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
44 #define DEBUG 0
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
45
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
46 typedef struct line LINE;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
47
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
48 struct line
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
49 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
50 LINE *next; /* ptr to next or NULL */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
51 char *line; /* text of the line */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
52 };
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
53
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
54 typedef struct docstr DOCSTR;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
55
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
56 struct docstr /* Allocated thing for an entry. */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
57 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
58 DOCSTR *next; /* next in the chain */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
59 char *name; /* name of the function or var */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
60 LINE *first; /* first line of doc text. */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
61 char type; /* 'F' for function, 'V' for variable */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
62 };
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
63
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
64
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
65 /* Print error message. `s1' is printf control string, `s2' is arg for it. */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
66
9491
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 1175
diff changeset
67 void
109744
fdbd24f8d999 Fix warnings produced by compiling with -Wwrite_strings (i.e. use const char *).
Jan D <jan.h.d@swipnet.se>
parents: 109120
diff changeset
68 error (const char *s1, const char *s2)
29
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
69 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
70 fprintf (stderr, "sorted-doc: ");
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
71 fprintf (stderr, s1, s2);
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
72 fprintf (stderr, "\n");
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
73 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
74
9491
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 1175
diff changeset
75 /* Print error message and exit. */
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 1175
diff changeset
76
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 1175
diff changeset
77 void
109744
fdbd24f8d999 Fix warnings produced by compiling with -Wwrite_strings (i.e. use const char *).
Jan D <jan.h.d@swipnet.se>
parents: 109120
diff changeset
78 fatal (const char *s1, const char *s2)
9491
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 1175
diff changeset
79 {
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 1175
diff changeset
80 error (s1, s2);
55442
a47704955f8d Throughout, replace 0 destined for `exit' arg with `EXIT_SUCCESS'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 52401
diff changeset
81 exit (EXIT_FAILURE);
9491
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 1175
diff changeset
82 }
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 1175
diff changeset
83
29
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
84 /* Like malloc but get fatal error if memory is exhausted. */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
85
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
86 char *
109111
52b76722152a Convert function definitions to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 106815
diff changeset
87 xmalloc (int size)
29
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
88 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
89 char *result = malloc ((unsigned)size);
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
90 if (result == NULL)
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
91 fatal ("%s", "virtual memory exhausted");
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
92 return result;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
93 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
94
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
95 char *
109111
52b76722152a Convert function definitions to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 106815
diff changeset
96 xstrdup (char *str)
29
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
97 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
98 char *buf = xmalloc (strlen (str) + 1);
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
99 (void) strcpy (buf, str);
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
100 return (buf);
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
101 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
102
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
103 /* Comparison function for qsort to call. */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
104
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
105 int
109120
9983eb21a9c9 Fix invalid cast
Andreas Schwab <schwab@linux-m68k.org>
parents: 109115
diff changeset
106 cmpdoc (const void *va, const void *vb)
29
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
107 {
109120
9983eb21a9c9 Fix invalid cast
Andreas Schwab <schwab@linux-m68k.org>
parents: 109115
diff changeset
108 DOCSTR *const *a = va;
9983eb21a9c9 Fix invalid cast
Andreas Schwab <schwab@linux-m68k.org>
parents: 109115
diff changeset
109 DOCSTR *const *b = vb;
29
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
110 register int val = strcmp ((*a)->name, (*b)->name);
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
111 if (val) return val;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
112 return (*a)->type - (*b)->type;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
113 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
114
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
115 enum state
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
116 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
117 WAITING, BEG_NAME, NAME_GET, BEG_DESC, DESC_GET
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
118 };
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
119
109744
fdbd24f8d999 Fix warnings produced by compiling with -Wwrite_strings (i.e. use const char *).
Jan D <jan.h.d@swipnet.se>
parents: 109120
diff changeset
120 const char *states[] =
29
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
121 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
122 "WAITING", "BEG_NAME", "NAME_GET", "BEG_DESC", "DESC_GET"
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
123 };
42439
d8a417105504 Remove unnecessary whitespaces.
Pavel Janík <Pavel@Janik.cz>
parents: 42412
diff changeset
124
9491
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 1175
diff changeset
125 int
109111
52b76722152a Convert function definitions to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 106815
diff changeset
126 main (void)
29
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
127 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
128 register DOCSTR *dp = NULL; /* allocated DOCSTR */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
129 register LINE *lp = NULL; /* allocated line */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
130 register char *bp; /* ptr inside line buffer */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
131 register enum state state = WAITING; /* state at start */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
132 int cnt = 0; /* number of DOCSTRs read */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
133
70285
0f15a453179c (main): Initialize docs to NULL.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 68647
diff changeset
134 DOCSTR *docs = NULL; /* chain of allocated DOCSTRS */
29
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
135 char buf[512]; /* line buffer */
42439
d8a417105504 Remove unnecessary whitespaces.
Pavel Janík <Pavel@Janik.cz>
parents: 42412
diff changeset
136
71192
fa429804cb96 [DOS_NT] <top level>: Include fcntl.h and io.h.
Eli Zaretskii <eliz@gnu.org>
parents: 70285
diff changeset
137 #ifdef DOS_NT
fa429804cb96 [DOS_NT] <top level>: Include fcntl.h and io.h.
Eli Zaretskii <eliz@gnu.org>
parents: 70285
diff changeset
138 /* DOC is a binary file. */
fa429804cb96 [DOS_NT] <top level>: Include fcntl.h and io.h.
Eli Zaretskii <eliz@gnu.org>
parents: 70285
diff changeset
139 if (!isatty (fileno (stdin)))
fa429804cb96 [DOS_NT] <top level>: Include fcntl.h and io.h.
Eli Zaretskii <eliz@gnu.org>
parents: 70285
diff changeset
140 setmode (fileno (stdin), O_BINARY);
fa429804cb96 [DOS_NT] <top level>: Include fcntl.h and io.h.
Eli Zaretskii <eliz@gnu.org>
parents: 70285
diff changeset
141 #endif
fa429804cb96 [DOS_NT] <top level>: Include fcntl.h and io.h.
Eli Zaretskii <eliz@gnu.org>
parents: 70285
diff changeset
142
71194
036770549c03 (main): Initialize bp, to avoid compiler warnings
Eli Zaretskii <eliz@gnu.org>
parents: 71192
diff changeset
143 bp = buf;
036770549c03 (main): Initialize bp, to avoid compiler warnings
Eli Zaretskii <eliz@gnu.org>
parents: 71192
diff changeset
144
29
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
145 while (1) /* process one char at a time */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
146 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
147 /* this char from the DOCSTR file */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
148 register int ch = getchar ();
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
149
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
150 /* Beginnings */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
151
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
152 if (state == WAITING)
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
153 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
154 if (ch == MARKER)
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
155 state = BEG_NAME;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
156 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
157 else if (state == BEG_NAME)
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
158 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
159 cnt++;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
160 if (dp == NULL) /* first dp allocated */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
161 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
162 docs = dp = (DOCSTR*) xmalloc (sizeof (DOCSTR));
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
163 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
164 else /* all the rest */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
165 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
166 dp->next = (DOCSTR*) xmalloc (sizeof (DOCSTR));
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
167 dp = dp->next;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
168 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
169 lp = NULL;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
170 dp->next = NULL;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
171 bp = buf;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
172 state = NAME_GET;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
173 /* Record whether function or variable. */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
174 dp->type = ch;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
175 ch = getchar ();
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
176 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
177 else if (state == BEG_DESC)
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
178 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
179 if (lp == NULL) /* first line for dp */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
180 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
181 dp->first = lp = (LINE*)xmalloc (sizeof (LINE));
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
182 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
183 else /* continuing lines */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
184 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
185 lp->next = (LINE*)xmalloc (sizeof (LINE));
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
186 lp = lp->next;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
187 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
188 lp->next = NULL;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
189 bp = buf;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
190 state = DESC_GET;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
191 }
42439
d8a417105504 Remove unnecessary whitespaces.
Pavel Janík <Pavel@Janik.cz>
parents: 42412
diff changeset
192
29
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
193 /* process gets */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
194
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
195 if (state == NAME_GET || state == DESC_GET)
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
196 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
197 if (ch != MARKER && ch != '\n' && ch != EOF)
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
198 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
199 *bp++ = ch;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
200 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
201 else /* saving and changing state */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
202 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
203 *bp = NUL;
9491
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 1175
diff changeset
204 bp = xstrdup (buf);
29
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
205
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
206 if (state == NAME_GET)
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
207 dp->name = bp;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
208 else
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
209 lp->line = bp;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
210
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
211 bp = buf;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
212 state = (ch == MARKER) ? BEG_NAME : BEG_DESC;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
213 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
214 } /* NAME_GET || DESC_GET */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
215 if (ch == EOF)
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
216 break;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
217 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
218
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
219 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
220 DOCSTR **array;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
221 register int i; /* counter */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
222
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
223 /* build array of ptrs to DOCSTRs */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
224
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
225 array = (DOCSTR**)xmalloc (cnt * sizeof (*array));
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
226 for (dp = docs, i = 0; dp != NULL ; dp = dp->next)
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
227 array[i++] = dp;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
228
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
229 /* sort the array by name; within each name, by type */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
230
109120
9983eb21a9c9 Fix invalid cast
Andreas Schwab <schwab@linux-m68k.org>
parents: 109115
diff changeset
231 qsort ((char*)array, cnt, sizeof (DOCSTR*), cmpdoc);
29
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
232
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
233 /* write the output header */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
234
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
235 printf ("\\input texinfo @c -*-texinfo-*-\n");
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
236 printf ("@setfilename ../info/summary\n");
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
237 printf ("@settitle Command Summary for GNU Emacs\n");
24533
32a7344ac2e7 (main): Split up tables. Modify the preamble
Dave Love <fx@gnu.org>
parents: 15719
diff changeset
238 printf ("@finalout\n");
29
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
239 printf ("@unnumbered Command Summary for GNU Emacs\n");
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
240 printf ("@table @asis\n");
1175
c4535b4417d2 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 29
diff changeset
241 printf ("\n");
24533
32a7344ac2e7 (main): Split up tables. Modify the preamble
Dave Love <fx@gnu.org>
parents: 15719
diff changeset
242 printf ("@iftex\n");
32a7344ac2e7 (main): Split up tables. Modify the preamble
Dave Love <fx@gnu.org>
parents: 15719
diff changeset
243 printf ("@global@let@ITEM@item\n");
1175
c4535b4417d2 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 29
diff changeset
244 printf ("@def@item{@filbreak@vskip5pt@ITEM}\n");
c4535b4417d2 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 29
diff changeset
245 printf ("@font@tensy cmsy10 scaled @magstephalf\n");
c4535b4417d2 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 29
diff changeset
246 printf ("@font@teni cmmi10 scaled @magstephalf\n");
c4535b4417d2 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 29
diff changeset
247 printf ("@def\\{{@tensy@char110}}\n"); /* this backslash goes with cmr10 */
c4535b4417d2 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 29
diff changeset
248 printf ("@def|{{@tensy@char106}}\n");
c4535b4417d2 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 29
diff changeset
249 printf ("@def@{{{@tensy@char102}}\n");
c4535b4417d2 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 29
diff changeset
250 printf ("@def@}{{@tensy@char103}}\n");
c4535b4417d2 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 29
diff changeset
251 printf ("@def<{{@teni@char62}}\n");
c4535b4417d2 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 29
diff changeset
252 printf ("@def>{{@teni@char60}}\n");
c4535b4417d2 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 29
diff changeset
253 printf ("@chardef@@64\n");
c4535b4417d2 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 29
diff changeset
254 printf ("@catcode43=12\n");
c4535b4417d2 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 29
diff changeset
255 printf ("@tableindent-0.2in\n");
24533
32a7344ac2e7 (main): Split up tables. Modify the preamble
Dave Love <fx@gnu.org>
parents: 15719
diff changeset
256 printf ("@end iftex\n");
29
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
257
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
258 /* print each function from the array */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
259
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
260 for (i = 0; i < cnt; i++)
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
261 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
262 printf ("\n@item %s @code{%s}\n@display\n",
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
263 array[i]->type == 'F' ? "Function" : "Variable",
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
264 array[i]->name);
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
265
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
266 for (lp = array[i]->first; lp != NULL ; lp = lp->next)
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
267 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
268 for (bp = lp->line; *bp; bp++)
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
269 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
270 /* the characters "@{}" need special treatment */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
271 if (*bp == '@' || *bp == '{' || *bp == '}')
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
272 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
273 putchar('@');
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
274 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
275 putchar(*bp);
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
276 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
277 putchar ('\n');
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
278 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
279 printf("@end display\n");
24533
32a7344ac2e7 (main): Split up tables. Modify the preamble
Dave Love <fx@gnu.org>
parents: 15719
diff changeset
280 /* Try to avoid a save size overflow in the TeX output
32a7344ac2e7 (main): Split up tables. Modify the preamble
Dave Love <fx@gnu.org>
parents: 15719
diff changeset
281 routine. */
32a7344ac2e7 (main): Split up tables. Modify the preamble
Dave Love <fx@gnu.org>
parents: 15719
diff changeset
282 if (i%100 == 0 && i > 0 && i != cnt)
32a7344ac2e7 (main): Split up tables. Modify the preamble
Dave Love <fx@gnu.org>
parents: 15719
diff changeset
283 printf("\n@end table\n@table @asis\n");
29
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
284 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
285
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
286 printf ("@end table\n");
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
287 printf ("@bye\n");
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
288 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
289
55442
a47704955f8d Throughout, replace 0 destined for `exit' arg with `EXIT_SUCCESS'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 52401
diff changeset
290 return EXIT_SUCCESS;
29
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
291 }
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 42439
diff changeset
292
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 42439
diff changeset
293 /* arch-tag: ce28f204-1e70-4b34-8210-3d54a5662071
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 42439
diff changeset
294 (do not change this comment) */
55442
a47704955f8d Throughout, replace 0 destined for `exit' arg with `EXIT_SUCCESS'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 52401
diff changeset
295
a47704955f8d Throughout, replace 0 destined for `exit' arg with `EXIT_SUCCESS'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 52401
diff changeset
296 /* sorted-doc.c ends here */