annotate lib-src/sorted-doc.c @ 15701:5db02009315e libc-1-93 libc-960716 libc-960717 libc-960718 libc-960719 libc-960720 libc-960721 libc-960722 libc-960723 libc-960724 libc-960725 libc-960726 libc-960727 libc-960728 libc-960729 libc-960730 libc-960731 libc-960801 libc-960802 libc-960803 libc-960804 libc-960805 libc-960806 libc-960807 libc-960808 libc-960809 libc-960810 libc-960811 libc-960812 libc-960813 libc-960814 libc-960815 libc-960816 libc-960817 libc-960818 libc-960819 libc-960820 libc-960821 libc-960822 libc-960823 libc-960824 libc-960825 libc-960826 libc-960827 libc-960828 libc-960829 libc-960830 libc-960831 libc-960901 libc-960902 libc-960903 libc-960904 libc-960905 libc-960906 libc-960907 libc-960908 libc-960909 libc-960910 libc-960911 libc-960912 release-0-0 release-0-1

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