Mercurial > hg > xemacs-beta
comparison lib-src/sorted-doc.c @ 398:74fd4e045ea6 r21-2-29
Import from CVS: tag r21-2-29
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:13:30 +0200 |
parents | cc15677e0335 |
children | 697ef44129c6 |
comparison
equal
deleted
inserted
replaced
397:f4aeb21a5bad | 398:74fd4e045ea6 |
---|---|
5 This version sorts the output by function name. | 5 This version sorts the output by function name. |
6 */ | 6 */ |
7 | 7 |
8 /* Synched up with: FSF 19.28. */ | 8 /* Synched up with: FSF 19.28. */ |
9 | 9 |
10 #include <../src/config.h> | 10 #include <config.h> |
11 | 11 |
12 #include <stdio.h> | 12 #include <stdio.h> |
13 #include <ctype.h> | 13 #include <ctype.h> |
14 #if __STDC__ || defined(STDC_HEADERS) | 14 #include <stdlib.h> /* for qsort() and malloc() */ |
15 # include <stdlib.h> /* for qsort() and malloc() */ | 15 #include <string.h> |
16 # include <string.h> | 16 static void *xmalloc (size_t); |
17 static void *xmalloc (int); | |
18 # ifndef CONST | |
19 # define CONST const | |
20 # endif | |
21 #else | |
22 extern char *malloc (); | |
23 static void *xmalloc (); | |
24 # ifndef CONST | |
25 # define CONST | |
26 # endif | |
27 #endif | |
28 | 17 |
29 #define NUL '\0' | 18 #define NUL '\0' |
30 #define MARKER '\037' | 19 #define MARKER '\037' |
31 | 20 |
32 #define DEBUG 0 | 21 #define DEBUG 0 |
33 | 22 |
34 typedef struct line LINE; | 23 typedef struct LINE LINE; |
35 | 24 |
36 struct line | 25 struct LINE |
37 { | 26 { |
38 LINE *next; /* ptr to next or NULL */ | 27 LINE *next; /* ptr to next or NULL */ |
39 char *line; /* text of the line */ | 28 char *line; /* text of the line */ |
40 }; | 29 }; |
41 | 30 |
70 } | 59 } |
71 | 60 |
72 /* Like malloc but get fatal error if memory is exhausted. */ | 61 /* Like malloc but get fatal error if memory is exhausted. */ |
73 | 62 |
74 static void * | 63 static void * |
75 xmalloc (int size) | 64 xmalloc (size_t size) |
76 { | 65 { |
77 char *result = malloc ((unsigned)size); | 66 void *result = malloc (size); |
78 if (result == NULL) | 67 if (result == NULL) |
79 fatal ("%s", "virtual memory exhausted"); | 68 fatal ("%s", "virtual memory exhausted"); |
80 return result; | 69 return result; |
81 } | 70 } |
82 | 71 |
83 static char * | 72 static char * |
84 strsav (char *str) | 73 strsav (char *str) |
85 { | 74 { |
86 char *buf = xmalloc (strlen (str) + 1); | 75 char *buf = (char *) xmalloc (strlen (str) + 1); |
87 (void) strcpy (buf, str); | 76 strcpy (buf, str); |
88 return (buf); | 77 return buf; |
89 } | 78 } |
90 | 79 |
91 /* Comparison function for qsort to call. */ | 80 /* Comparison function for qsort to call. */ |
92 | 81 |
93 static int | 82 static int |
102 enum state | 91 enum state |
103 { | 92 { |
104 WAITING, BEG_NAME, NAME_GET, BEG_DESC, DESC_GET | 93 WAITING, BEG_NAME, NAME_GET, BEG_DESC, DESC_GET |
105 }; | 94 }; |
106 | 95 |
107 CONST char *states[] = | 96 const char *states[] = |
108 { | 97 { |
109 "WAITING", "BEG_NAME", "NAME_GET", "BEG_DESC", "DESC_GET" | 98 "WAITING", "BEG_NAME", "NAME_GET", "BEG_DESC", "DESC_GET" |
110 }; | 99 }; |
111 | 100 |
112 int | 101 int |
207 array[i++] = dp; | 196 array[i++] = dp; |
208 | 197 |
209 /* sort the array by name; within each name, by type */ | 198 /* sort the array by name; within each name, by type */ |
210 | 199 |
211 qsort ((char*)array, cnt, sizeof (DOCSTR*), | 200 qsort ((char*)array, cnt, sizeof (DOCSTR*), |
212 /* was cast to (int (*)(CONST void *, CONST void *)) | 201 (int (*)(const void *, const void *)) cmpdoc); |
213 but that loses on HP because CONST_IS_LOSING. */ | |
214 /* This one loses too: (int (*)()) */ | |
215 /* Ok, so let's try const instead of CONST. Fuck me!!! */ | |
216 (int (*)(const void *, const void *)) | |
217 cmpdoc); | |
218 | 202 |
219 /* write the output header */ | 203 /* write the output header */ |
220 | 204 |
221 printf ("\\input texinfo @c -*-texinfo-*-\n"); | 205 printf ("\\input texinfo @c -*-texinfo-*-\n"); |
222 printf ("@setfilename ../info/summary\n"); | 206 printf ("@setfilename ../info/summary\n"); |
223 printf ("@settitle Command Summary for GNU Emacs\n"); | 207 printf ("@settitle Command Summary for GNU Emacs\n"); |
224 printf ("@unnumbered Command Summary for GNU Emacs\n"); | 208 printf ("@unnumbered Command Summary for GNU Emacs\n"); |
225 printf ("@table @asis\n"); | 209 printf ("@table @asis\n"); |
226 printf ("\n"); | 210 printf ("\n"); |
227 printf ("@let@ITEM@item\n"); | 211 printf ("@iftex\n"); |
212 printf ("@global@let@ITEM=@item\n"); | |
228 printf ("@def@item{@filbreak@vskip5pt@ITEM}\n"); | 213 printf ("@def@item{@filbreak@vskip5pt@ITEM}\n"); |
229 printf ("@font@tensy cmsy10 scaled @magstephalf\n"); | 214 printf ("@font@tensy cmsy10 scaled @magstephalf\n"); |
230 printf ("@font@teni cmmi10 scaled @magstephalf\n"); | 215 printf ("@font@teni cmmi10 scaled @magstephalf\n"); |
231 printf ("@def\\{{@tensy@char110}}\n"); /* this backslash goes with cmr10 */ | 216 printf ("@def\\{{@tensy@char110}}\n"); /* this backslash goes with cmr10 */ |
232 printf ("@def|{{@tensy@char106}}\n"); | 217 printf ("@def|{{@tensy@char106}}\n"); |
235 printf ("@def<{{@teni@char62}}\n"); | 220 printf ("@def<{{@teni@char62}}\n"); |
236 printf ("@def>{{@teni@char60}}\n"); | 221 printf ("@def>{{@teni@char60}}\n"); |
237 printf ("@chardef@@64\n"); | 222 printf ("@chardef@@64\n"); |
238 printf ("@catcode43=12\n"); | 223 printf ("@catcode43=12\n"); |
239 printf ("@tableindent-0.2in\n"); | 224 printf ("@tableindent-0.2in\n"); |
225 printf ("@end iftex\n"); | |
240 | 226 |
241 /* print each function from the array */ | 227 /* print each function from the array */ |
242 | 228 |
243 for (i = 0; i < cnt; i++) | 229 for (i = 0; i < cnt; i++) |
244 { | 230 { |
258 putchar(*bp); | 244 putchar(*bp); |
259 } | 245 } |
260 putchar ('\n'); | 246 putchar ('\n'); |
261 } | 247 } |
262 printf("@end display\n"); | 248 printf("@end display\n"); |
249 if ( i%200 == 0 && i != 0 ) printf("@end table\n\n@table @asis\n"); | |
263 } | 250 } |
264 | 251 |
265 printf ("@end table\n"); | 252 printf ("@end table\n"); |
266 printf ("@bye\n"); | 253 printf ("@bye\n"); |
267 } | 254 } |