Mercurial > hg > xemacs-beta
comparison lib-src/sorted-doc.c @ 5491:06dd936cde16
Merge some stuff in lib-src
-------------------- ChangeLog entries follow: --------------------
lib-src/ChangeLog addition:
2010-02-19 Ben Wing <ben@xemacs.org>
* digest-doc.c:
* digest-doc.c (main):
* emacs.csh:
* hexl.c:
* hexl.c (Gabryelski):
* hexl.c (main):
* hexl.c (usage):
* sorted-doc.c:
* sorted-doc.c (fatal):
* sorted-doc.c (xstrdup):
* sorted-doc.c (main):
* vcdiff:
Merge up to FSF 23.1.92.
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Fri, 19 Feb 2010 22:13:17 -0600 |
parents | ecf1ebac70d8 |
children | 1f0b15040456 |
comparison
equal
deleted
inserted
replaced
5030:422b4b4fb2a6 | 5491:06dd936cde16 |
---|---|
1 /* Give this program DOCSTR.mm.nn as standard input | 1 /* Give this program DOC-mm.nn.oo as standard input and it outputs to |
2 and it outputs to standard output | 2 standard output a file of texinfo input containing the doc strings. |
3 a file of texinfo input containing the doc strings. | 3 |
4 | 4 Copyright (C) 1989, 1992, 1994, 1996, 1999, 2000, 2001, 2002, 2003, |
5 This version sorts the output by function name. | 5 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
6 */ | 6 |
7 | 7 This file is part of GNU Emacs. |
8 /* Synched up with: FSF 19.28. */ | 8 |
9 | 9 GNU Emacs is free software: you can redistribute it and/or modify |
10 it under the terms of the GNU General Public License as published by | |
11 the Free Software Foundation, either version 3 of the License, or | |
12 (at your option) any later version. | |
13 | |
14 GNU Emacs is distributed in the hope that it will be useful, | |
15 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 GNU General Public License for more details. | |
18 | |
19 You should have received a copy of the GNU General Public License | |
20 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |
21 | |
22 /* Synced up with: GNU 23.1.92. */ | |
23 /* Synced by: Ben Wing, 2-17-10. */ | |
24 | |
25 /* This version sorts the output by function name. */ | |
26 | |
27 #ifdef HAVE_CONFIG_H | |
10 #include <config.h> | 28 #include <config.h> |
29 #endif | |
11 | 30 |
12 #include <stdio.h> | 31 #include <stdio.h> |
13 #include <ctype.h> | 32 #include <ctype.h> |
14 #include <stdlib.h> /* for qsort() and malloc() */ | 33 #include <stdlib.h> /* for qsort() and malloc() */ |
15 #include <string.h> | 34 #include <string.h> |
16 static void *xmalloc (size_t); | 35 static void *xmalloc (size_t); |
36 #ifdef WIN32_NATIVE | |
37 #include <fcntl.h> /* for O_BINARY */ | |
38 #include <io.h> /* for setmode */ | |
39 #endif | |
17 | 40 |
18 #define NUL '\0' | 41 #define NUL '\0' |
19 #define MARKER '\037' | 42 #define MARKER '\037' |
20 | 43 |
21 #define DEBUG 0 | 44 #define DEBUG 0 |
53 | 76 |
54 static void | 77 static void |
55 fatal (char *s1, char *s2) | 78 fatal (char *s1, char *s2) |
56 { | 79 { |
57 error (s1, s2); | 80 error (s1, s2); |
58 exit (1); | 81 exit (EXIT_FAILURE); |
59 } | 82 } |
60 | 83 |
61 /* Like malloc but get fatal error if memory is exhausted. */ | 84 /* Like malloc but get fatal error if memory is exhausted. */ |
62 | 85 |
63 static void * | 86 static void * |
68 fatal ("%s", "virtual memory exhausted"); | 91 fatal ("%s", "virtual memory exhausted"); |
69 return result; | 92 return result; |
70 } | 93 } |
71 | 94 |
72 static char * | 95 static char * |
73 strsav (char *str) | 96 xstrdup (char *str) |
74 { | 97 { |
75 char *buf = (char *) xmalloc (strlen (str) + 1); | 98 char *buf = xmalloc (strlen (str) + 1); |
76 strcpy (buf, str); | 99 (void) strcpy (buf, str); |
77 return buf; | 100 return (buf); |
78 } | 101 } |
79 | 102 |
80 /* Comparison function for qsort to call. */ | 103 /* Comparison function for qsort to call. */ |
81 | 104 |
82 static int | 105 static int |
102 main (int argc, char **argv) | 125 main (int argc, char **argv) |
103 { | 126 { |
104 register DOCSTR *dp = NULL; /* allocated DOCSTR */ | 127 register DOCSTR *dp = NULL; /* allocated DOCSTR */ |
105 register LINE *lp = NULL; /* allocated line */ | 128 register LINE *lp = NULL; /* allocated line */ |
106 register char *bp = 0; /* ptr inside line buffer */ | 129 register char *bp = 0; /* ptr inside line buffer */ |
107 /* int notfirst = 0; / * set after read something */ | |
108 register enum state state = WAITING; /* state at start */ | 130 register enum state state = WAITING; /* state at start */ |
109 int cnt = 0; /* number of DOCSTRs read */ | 131 int cnt = 0; /* number of DOCSTRs read */ |
110 | 132 |
111 DOCSTR *docs = 0; /* chain of allocated DOCSTRS */ | 133 DOCSTR *docs = NULL; /* chain of allocated DOCSTRS */ |
112 char buf[512]; /* line buffer */ | 134 char buf[512]; /* line buffer */ |
113 | 135 |
136 #ifdef DOS_NT | |
137 /* DOC is a binary file. */ | |
138 if (!isatty (fileno (stdin))) | |
139 setmode (fileno (stdin), O_BINARY); | |
140 #endif | |
141 | |
142 bp = buf; | |
143 | |
114 while (1) /* process one char at a time */ | 144 while (1) /* process one char at a time */ |
115 { | 145 { |
116 /* this char from the DOCSTR file */ | 146 /* this char from the DOCSTR file */ |
117 register int ch = getchar (); | 147 register int ch = getchar (); |
118 | 148 |
156 } | 186 } |
157 lp->next = NULL; | 187 lp->next = NULL; |
158 bp = buf; | 188 bp = buf; |
159 state = DESC_GET; | 189 state = DESC_GET; |
160 } | 190 } |
161 | 191 |
162 /* process gets */ | 192 /* process gets */ |
163 | 193 |
164 if (state == NAME_GET || state == DESC_GET) | 194 if (state == NAME_GET || state == DESC_GET) |
165 { | 195 { |
166 if (ch != MARKER && ch != '\n' && ch != EOF) | 196 if (ch != MARKER && ch != '\n' && ch != EOF) |
168 *bp++ = ch; | 198 *bp++ = ch; |
169 } | 199 } |
170 else /* saving and changing state */ | 200 else /* saving and changing state */ |
171 { | 201 { |
172 *bp = NUL; | 202 *bp = NUL; |
173 bp = strsav (buf); | 203 bp = xstrdup (buf); |
174 | 204 |
175 if (state == NAME_GET) | 205 if (state == NAME_GET) |
176 dp->name = bp; | 206 dp->name = bp; |
177 else | 207 else |
178 lp->line = bp; | 208 lp->line = bp; |
203 /* write the output header */ | 233 /* write the output header */ |
204 | 234 |
205 printf ("\\input texinfo @c -*-texinfo-*-\n"); | 235 printf ("\\input texinfo @c -*-texinfo-*-\n"); |
206 printf ("@setfilename ../info/summary\n"); | 236 printf ("@setfilename ../info/summary\n"); |
207 printf ("@settitle Command Summary for XEmacs\n"); | 237 printf ("@settitle Command Summary for XEmacs\n"); |
238 printf ("@finalout\n"); | |
208 printf ("@unnumbered Command Summary for XEmacs\n"); | 239 printf ("@unnumbered Command Summary for XEmacs\n"); |
209 printf ("@table @asis\n"); | 240 printf ("@table @asis\n"); |
210 printf ("\n"); | 241 printf ("\n"); |
211 printf ("@iftex\n"); | 242 printf ("@iftex\n"); |
243 /* #### XEmacs note: FSF 23.1.92 is missing the = sign below. | |
244 Which is correct? */ | |
212 printf ("@global@let@ITEM=@item\n"); | 245 printf ("@global@let@ITEM=@item\n"); |
213 printf ("@def@item{@filbreak@vskip5pt@ITEM}\n"); | 246 printf ("@def@item{@filbreak@vskip5pt@ITEM}\n"); |
214 printf ("@font@tensy cmsy10 scaled @magstephalf\n"); | 247 printf ("@font@tensy cmsy10 scaled @magstephalf\n"); |
215 printf ("@font@teni cmmi10 scaled @magstephalf\n"); | 248 printf ("@font@teni cmmi10 scaled @magstephalf\n"); |
216 printf ("@def\\{{@tensy@char110}}\n"); /* this backslash goes with cmr10 */ | 249 printf ("@def\\{{@tensy@char110}}\n"); /* this backslash goes with cmr10 */ |
244 putchar(*bp); | 277 putchar(*bp); |
245 } | 278 } |
246 putchar ('\n'); | 279 putchar ('\n'); |
247 } | 280 } |
248 printf("@end display\n"); | 281 printf("@end display\n"); |
249 if ( i%200 == 0 && i != 0 ) printf("@end table\n\n@table @asis\n"); | 282 /* Try to avoid a save size overflow in the TeX output |
283 routine. */ | |
284 if (i%100 == 0 && i > 0 && i != cnt) | |
285 printf("\n@end table\n@table @asis\n"); | |
250 } | 286 } |
251 | 287 |
252 printf ("@end table\n"); | 288 printf ("@end table\n"); |
253 printf ("@bye\n"); | 289 printf ("@bye\n"); |
254 } | 290 } |
255 | 291 |
256 return 0; | 292 return EXIT_SUCCESS; |
257 } | 293 } |
294 | |
295 /* arch-tag: ce28f204-1e70-4b34-8210-3d54a5662071 | |
296 (do not change this comment) */ | |
297 | |
298 /* sorted-doc.c ends here */ |