annotate lib-src/sorted-doc.c @ 9227:968bb25ec1af

(display_menu_item): Add support for displaying the title in pop up menus.
author Paul Reilly <pmr@pajato.com>
date Sun, 02 Oct 1994 12:14:00 +0000
parents c4535b4417d2
children dd3b83e4ceb0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
29
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1 /* Give this program DOCSTR.mm.nn as standard input
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2 and it outputs to standard output
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3 a file of texinfo input containing the doc strings.
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5 This version sorts the output by function name.
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6 */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
7
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
8 #include <stdio.h>
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
9 #include <ctype.h>
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11 extern char *malloc ();
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
12 char *xmalloc ();
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
13
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
14 #define NUL '\0'
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15 #define MARKER '\037'
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17 #define DEBUG 0
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
18
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
19 typedef struct line LINE;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
20
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21 struct line
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
22 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
23 LINE *next; /* ptr to next or NULL */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
24 char *line; /* text of the line */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
25 };
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
26
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
27 typedef struct docstr DOCSTR;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
28
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
29 struct docstr /* Allocated thing for an entry. */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
30 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
31 DOCSTR *next; /* next in the chain */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
32 char *name; /* name of the function or var */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
33 LINE *first; /* first line of doc text. */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
34 char type; /* 'F' for function, 'V' for variable */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
35 };
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
36
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
37
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
38 /* Print error message and exit. */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
39
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
40 fatal (s1, s2)
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
41 char *s1, *s2;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
42 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
43 error (s1, s2);
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
44 exit (1);
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
45 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
46
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
47 /* Print error message. `s1' is printf control string, `s2' is arg for it. */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
48
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
49 error (s1, s2)
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
50 char *s1, *s2;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
51 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
52 fprintf (stderr, "sorted-doc: ");
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
53 fprintf (stderr, s1, s2);
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
54 fprintf (stderr, "\n");
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
55 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
56
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
57 /* Like malloc but get fatal error if memory is exhausted. */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
58
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
59 char *
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
60 xmalloc (size)
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
61 int size;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
62 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
63 char *result = malloc ((unsigned)size);
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
64 if (result == NULL)
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
65 fatal ("%s", "virtual memory exhausted");
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
66 return result;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
67 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
68
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
69 char *
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
70 strsav (str)
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
71 char * str;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
72 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
73 char *buf = xmalloc (strlen (str) + 1);
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
74 (void) strcpy (buf, str);
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
75 return (buf);
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
76 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
77
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
78 /* Comparison function for qsort to call. */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
79
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
80 int
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
81 cmpdoc (a, b)
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
82 DOCSTR **a;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
83 DOCSTR **b;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
84 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
85 register int val = strcmp ((*a)->name, (*b)->name);
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
86 if (val) return val;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
87 return (*a)->type - (*b)->type;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
88 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
89
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
90
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
91 enum state
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
92 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
93 WAITING, BEG_NAME, NAME_GET, BEG_DESC, DESC_GET
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
94 };
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
95
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
96 char *states[] =
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
97 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
98 "WAITING", "BEG_NAME", "NAME_GET", "BEG_DESC", "DESC_GET"
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
99 };
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
100
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
101 main ()
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
102 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
103 register DOCSTR *dp = NULL; /* allocated DOCSTR */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
104 register LINE *lp = NULL; /* allocated line */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
105 register char *bp; /* ptr inside line buffer */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
106 int notfirst = 0; /* set after read something */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
107 register enum state state = WAITING; /* state at start */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
108 int cnt = 0; /* number of DOCSTRs read */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
109
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
110 DOCSTR *docs; /* chain of allocated DOCSTRS */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
111 char buf[512]; /* line buffer */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
112
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
113 while (1) /* process one char at a time */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
114 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
115 /* this char from the DOCSTR file */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
116 register int ch = getchar ();
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
117
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
118 /* Beginnings */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
119
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
120 if (state == WAITING)
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
121 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
122 if (ch == MARKER)
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
123 state = BEG_NAME;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
124 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
125 else if (state == BEG_NAME)
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
126 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
127 cnt++;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
128 if (dp == NULL) /* first dp allocated */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
129 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
130 docs = dp = (DOCSTR*) xmalloc (sizeof (DOCSTR));
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
131 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
132 else /* all the rest */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
133 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
134 dp->next = (DOCSTR*) xmalloc (sizeof (DOCSTR));
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
135 dp = dp->next;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
136 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
137 lp = NULL;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
138 dp->next = NULL;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
139 bp = buf;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
140 state = NAME_GET;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
141 /* Record whether function or variable. */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
142 dp->type = ch;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
143 ch = getchar ();
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
144 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
145 else if (state == BEG_DESC)
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
146 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
147 if (lp == NULL) /* first line for dp */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
148 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
149 dp->first = lp = (LINE*)xmalloc (sizeof (LINE));
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
150 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
151 else /* continuing lines */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
152 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
153 lp->next = (LINE*)xmalloc (sizeof (LINE));
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
154 lp = lp->next;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
155 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
156 lp->next = NULL;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
157 bp = buf;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
158 state = DESC_GET;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
159 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
160
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
161 /* process gets */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
162
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
163 if (state == NAME_GET || state == DESC_GET)
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
164 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
165 if (ch != MARKER && ch != '\n' && ch != EOF)
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
166 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
167 *bp++ = ch;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
168 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
169 else /* saving and changing state */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
170 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
171 *bp = NUL;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
172 bp = strsav (buf);
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
173
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
174 if (state == NAME_GET)
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
175 dp->name = bp;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
176 else
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
177 lp->line = bp;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
178
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
179 bp = buf;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
180 state = (ch == MARKER) ? BEG_NAME : BEG_DESC;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
181 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
182 } /* NAME_GET || DESC_GET */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
183 if (ch == EOF)
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
184 break;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
185 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
186
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
187 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
188 DOCSTR **array;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
189 register int i; /* counter */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
190
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
191 /* build array of ptrs to DOCSTRs */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
192
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
193 array = (DOCSTR**)xmalloc (cnt * sizeof (*array));
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
194 for (dp = docs, i = 0; dp != NULL ; dp = dp->next)
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
195 array[i++] = dp;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
196
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
197 /* sort the array by name; within each name, by type */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
198
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
199 qsort ((char*)array, cnt, sizeof (DOCSTR*), cmpdoc);
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
200
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
201 /* write the output header */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
202
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
203 printf ("\\input texinfo @c -*-texinfo-*-\n");
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
204 printf ("@setfilename ../info/summary\n");
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
205 printf ("@settitle Command Summary for GNU Emacs\n");
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
206 printf ("@unnumbered Command Summary for GNU Emacs\n");
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
207 printf ("@table @asis\n");
1175
c4535b4417d2 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 29
diff changeset
208 printf ("\n");
c4535b4417d2 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 29
diff changeset
209 printf ("@let@ITEM@item\n");
c4535b4417d2 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 29
diff changeset
210 printf ("@def@item{@filbreak@vskip5pt@ITEM}\n");
c4535b4417d2 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 29
diff changeset
211 printf ("@font@tensy cmsy10 scaled @magstephalf\n");
c4535b4417d2 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 29
diff changeset
212 printf ("@font@teni cmmi10 scaled @magstephalf\n");
c4535b4417d2 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 29
diff changeset
213 printf ("@def\\{{@tensy@char110}}\n"); /* this backslash goes with cmr10 */
c4535b4417d2 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 29
diff changeset
214 printf ("@def|{{@tensy@char106}}\n");
c4535b4417d2 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 29
diff changeset
215 printf ("@def@{{{@tensy@char102}}\n");
c4535b4417d2 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 29
diff changeset
216 printf ("@def@}{{@tensy@char103}}\n");
c4535b4417d2 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 29
diff changeset
217 printf ("@def<{{@teni@char62}}\n");
c4535b4417d2 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 29
diff changeset
218 printf ("@def>{{@teni@char60}}\n");
c4535b4417d2 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 29
diff changeset
219 printf ("@chardef@@64\n");
c4535b4417d2 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 29
diff changeset
220 printf ("@catcode43=12\n");
c4535b4417d2 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 29
diff changeset
221 printf ("@tableindent-0.2in\n");
29
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
222
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
223 /* print each function from the array */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
224
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
225 for (i = 0; i < cnt; i++)
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
226 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
227 printf ("\n@item %s @code{%s}\n@display\n",
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
228 array[i]->type == 'F' ? "Function" : "Variable",
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
229 array[i]->name);
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
230
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
231 for (lp = array[i]->first; lp != NULL ; lp = lp->next)
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
232 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
233 for (bp = lp->line; *bp; bp++)
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
234 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
235 /* the characters "@{}" need special treatment */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
236 if (*bp == '@' || *bp == '{' || *bp == '}')
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
237 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
238 putchar('@');
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
239 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
240 putchar(*bp);
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
241 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
242 putchar ('\n');
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
243 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
244 printf("@end display\n");
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
245 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
246
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
247 printf ("@end table\n");
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
248 printf ("@bye\n");
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
249 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
250
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
251 return 0;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
252 }