comparison lib-src/sorted-doc.c @ 412:697ef44129c6 r21-2-14

Import from CVS: tag r21-2-14
author cvs
date Mon, 13 Aug 2007 11:20:41 +0200
parents 74fd4e045ea6
children
comparison
equal deleted inserted replaced
411:12e008d41344 412:697ef44129c6
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 <config.h> 10 #include <../src/config.h>
11 11
12 #include <stdio.h> 12 #include <stdio.h>
13 #include <ctype.h> 13 #include <ctype.h>
14 #include <stdlib.h> /* for qsort() and malloc() */ 14 #if __STDC__ || defined(STDC_HEADERS)
15 #include <string.h> 15 # include <stdlib.h> /* for qsort() and malloc() */
16 static void *xmalloc (size_t); 16 # include <string.h>
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
17 28
18 #define NUL '\0' 29 #define NUL '\0'
19 #define MARKER '\037' 30 #define MARKER '\037'
20 31
21 #define DEBUG 0 32 #define DEBUG 0
22 33
23 typedef struct LINE LINE; 34 typedef struct line LINE;
24 35
25 struct LINE 36 struct line
26 { 37 {
27 LINE *next; /* ptr to next or NULL */ 38 LINE *next; /* ptr to next or NULL */
28 char *line; /* text of the line */ 39 char *line; /* text of the line */
29 }; 40 };
30 41
59 } 70 }
60 71
61 /* Like malloc but get fatal error if memory is exhausted. */ 72 /* Like malloc but get fatal error if memory is exhausted. */
62 73
63 static void * 74 static void *
64 xmalloc (size_t size) 75 xmalloc (int size)
65 { 76 {
66 void *result = malloc (size); 77 char *result = malloc ((unsigned)size);
67 if (result == NULL) 78 if (result == NULL)
68 fatal ("%s", "virtual memory exhausted"); 79 fatal ("%s", "virtual memory exhausted");
69 return result; 80 return result;
70 } 81 }
71 82
72 static char * 83 static char *
73 strsav (char *str) 84 strsav (char *str)
74 { 85 {
75 char *buf = (char *) xmalloc (strlen (str) + 1); 86 char *buf = xmalloc (strlen (str) + 1);
76 strcpy (buf, str); 87 (void) strcpy (buf, str);
77 return buf; 88 return (buf);
78 } 89 }
79 90
80 /* Comparison function for qsort to call. */ 91 /* Comparison function for qsort to call. */
81 92
82 static int 93 static int
91 enum state 102 enum state
92 { 103 {
93 WAITING, BEG_NAME, NAME_GET, BEG_DESC, DESC_GET 104 WAITING, BEG_NAME, NAME_GET, BEG_DESC, DESC_GET
94 }; 105 };
95 106
96 const char *states[] = 107 CONST char *states[] =
97 { 108 {
98 "WAITING", "BEG_NAME", "NAME_GET", "BEG_DESC", "DESC_GET" 109 "WAITING", "BEG_NAME", "NAME_GET", "BEG_DESC", "DESC_GET"
99 }; 110 };
100 111
101 int 112 int
196 array[i++] = dp; 207 array[i++] = dp;
197 208
198 /* sort the array by name; within each name, by type */ 209 /* sort the array by name; within each name, by type */
199 210
200 qsort ((char*)array, cnt, sizeof (DOCSTR*), 211 qsort ((char*)array, cnt, sizeof (DOCSTR*),
201 (int (*)(const void *, const void *)) cmpdoc); 212 /* was cast to (int (*)(CONST void *, CONST void *))
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);
202 218
203 /* write the output header */ 219 /* write the output header */
204 220
205 printf ("\\input texinfo @c -*-texinfo-*-\n"); 221 printf ("\\input texinfo @c -*-texinfo-*-\n");
206 printf ("@setfilename ../info/summary\n"); 222 printf ("@setfilename ../info/summary\n");