annotate lib-src/sorted-doc.c @ 36854:b3f0de9a07ea

*** empty log message ***
author John Wiegley <johnw@newartisans.com>
date Fri, 16 Mar 2001 21:50:15 +0000
parents c8fb06423da0
children c9f9c2f9d025
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
36226
c8fb06423da0 Add copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 31884
diff changeset
1 /* Give this program DOCSTR.mm.nn as standard input and it outputs to
c8fb06423da0 Add copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 31884
diff changeset
2 standard output a file of texinfo input containing the doc strings.
29
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3
36226
c8fb06423da0 Add copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 31884
diff changeset
4 Copyright (C) 1989, 1992, 1994, 1996, 1999, 2000, 2001
c8fb06423da0 Add copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 31884
diff changeset
5 Free Software Foundation Inc.
c8fb06423da0 Add copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 31884
diff changeset
6
c8fb06423da0 Add copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 31884
diff changeset
7 This file is part of GNU Emacs.
c8fb06423da0 Add copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 31884
diff changeset
8
c8fb06423da0 Add copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 31884
diff changeset
9 GNU Emacs is free software; you can redistribute it and/or modify
c8fb06423da0 Add copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 31884
diff changeset
10 it under the terms of the GNU General Public License as published by
c8fb06423da0 Add copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 31884
diff changeset
11 the Free Software Foundation; either version 2, or (at your option)
c8fb06423da0 Add copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 31884
diff changeset
12 any later version.
c8fb06423da0 Add copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 31884
diff changeset
13
c8fb06423da0 Add copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 31884
diff changeset
14 GNU Emacs is distributed in the hope that it will be useful,
c8fb06423da0 Add copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 31884
diff changeset
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
c8fb06423da0 Add copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 31884
diff changeset
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
c8fb06423da0 Add copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 31884
diff changeset
17 GNU General Public License for more details.
c8fb06423da0 Add copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 31884
diff changeset
18
c8fb06423da0 Add copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 31884
diff changeset
19 You should have received a copy of the GNU General Public License
c8fb06423da0 Add copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 31884
diff changeset
20 along with GNU Emacs; see the file COPYING. If not, write to
c8fb06423da0 Add copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 31884
diff changeset
21 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
c8fb06423da0 Add copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 31884
diff changeset
22
c8fb06423da0 Add copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 31884
diff changeset
23 This version sorts the output by function name. */
29
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
24
31884
7b52b49d1148 Include config.h.
Dave Love <fx@gnu.org>
parents: 24533
diff changeset
25 #include "config.h"
29
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
26 #include <stdio.h>
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
27 #include <ctype.h>
31884
7b52b49d1148 Include config.h.
Dave Love <fx@gnu.org>
parents: 24533
diff changeset
28 #ifndef HAVE_STDLIB_H /* config.h includes stdlib. */
29
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
29 extern char *malloc ();
31884
7b52b49d1148 Include config.h.
Dave Love <fx@gnu.org>
parents: 24533
diff changeset
30 #endif
29
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
31
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
32 #define NUL '\0'
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
33 #define MARKER '\037'
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
34
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
35 #define DEBUG 0
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
36
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
37 typedef struct line LINE;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
38
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
39 struct line
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
40 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
41 LINE *next; /* ptr to next or NULL */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
42 char *line; /* text of the line */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
43 };
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
44
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
45 typedef struct docstr DOCSTR;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
46
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
47 struct docstr /* Allocated thing for an entry. */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
48 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
49 DOCSTR *next; /* next in the chain */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
50 char *name; /* name of the function or var */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
51 LINE *first; /* first line of doc text. */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
52 char type; /* 'F' for function, 'V' for variable */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
53 };
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
54
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
55
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
56 /* Print error message. `s1' is printf control string, `s2' is arg for it. */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
57
9491
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 1175
diff changeset
58 void
29
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
59 error (s1, s2)
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
60 char *s1, *s2;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
61 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
62 fprintf (stderr, "sorted-doc: ");
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
63 fprintf (stderr, s1, s2);
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
64 fprintf (stderr, "\n");
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
65 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
66
9491
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 1175
diff changeset
67 /* Print error message and exit. */
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 1175
diff changeset
68
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 1175
diff changeset
69 void
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 1175
diff changeset
70 fatal (s1, s2)
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 1175
diff changeset
71 char *s1, *s2;
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 1175
diff changeset
72 {
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 1175
diff changeset
73 error (s1, s2);
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 1175
diff changeset
74 exit (1);
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 1175
diff changeset
75 }
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 1175
diff changeset
76
29
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
77 /* Like malloc but get fatal error if memory is exhausted. */
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 *
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
80 xmalloc (size)
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
81 int size;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
82 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
83 char *result = malloc ((unsigned)size);
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
84 if (result == NULL)
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
85 fatal ("%s", "virtual memory exhausted");
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
86 return result;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
87 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
88
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
89 char *
9491
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 1175
diff changeset
90 xstrdup (str)
29
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
91 char * str;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
92 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
93 char *buf = xmalloc (strlen (str) + 1);
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
94 (void) strcpy (buf, str);
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
95 return (buf);
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
96 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
97
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
98 /* Comparison function for qsort to call. */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
99
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
100 int
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
101 cmpdoc (a, b)
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
102 DOCSTR **a;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
103 DOCSTR **b;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
104 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
105 register int val = strcmp ((*a)->name, (*b)->name);
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
106 if (val) return val;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
107 return (*a)->type - (*b)->type;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
108 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
109
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
110
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
111 enum state
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
112 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
113 WAITING, BEG_NAME, NAME_GET, BEG_DESC, DESC_GET
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
114 };
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
115
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
116 char *states[] =
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
117 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
118 "WAITING", "BEG_NAME", "NAME_GET", "BEG_DESC", "DESC_GET"
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
119 };
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
120
9491
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 1175
diff changeset
121 int
29
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
122 main ()
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
123 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
124 register DOCSTR *dp = NULL; /* allocated DOCSTR */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
125 register LINE *lp = NULL; /* allocated line */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
126 register char *bp; /* ptr inside line buffer */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
127 register enum state state = WAITING; /* state at start */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
128 int cnt = 0; /* number of DOCSTRs read */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
129
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
130 DOCSTR *docs; /* chain of allocated DOCSTRS */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
131 char buf[512]; /* line buffer */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
132
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
133 while (1) /* process one char at a time */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
134 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
135 /* this char from the DOCSTR file */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
136 register int ch = getchar ();
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
137
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
138 /* Beginnings */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
139
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
140 if (state == WAITING)
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
141 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
142 if (ch == MARKER)
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
143 state = BEG_NAME;
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_NAME)
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
146 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
147 cnt++;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
148 if (dp == NULL) /* first dp allocated */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
149 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
150 docs = dp = (DOCSTR*) xmalloc (sizeof (DOCSTR));
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
151 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
152 else /* all the rest */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
153 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
154 dp->next = (DOCSTR*) xmalloc (sizeof (DOCSTR));
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
155 dp = dp->next;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
156 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
157 lp = NULL;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
158 dp->next = NULL;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
159 bp = buf;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
160 state = NAME_GET;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
161 /* Record whether function or variable. */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
162 dp->type = ch;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
163 ch = getchar ();
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
164 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
165 else if (state == BEG_DESC)
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
166 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
167 if (lp == NULL) /* first line for dp */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
168 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
169 dp->first = lp = (LINE*)xmalloc (sizeof (LINE));
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
170 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
171 else /* continuing lines */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
172 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
173 lp->next = (LINE*)xmalloc (sizeof (LINE));
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
174 lp = lp->next;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
175 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
176 lp->next = NULL;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
177 bp = buf;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
178 state = DESC_GET;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
179 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
180
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
181 /* process gets */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
182
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
183 if (state == NAME_GET || state == DESC_GET)
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
184 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
185 if (ch != MARKER && ch != '\n' && ch != EOF)
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
186 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
187 *bp++ = ch;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
188 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
189 else /* saving and changing state */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
190 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
191 *bp = NUL;
9491
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 1175
diff changeset
192 bp = xstrdup (buf);
29
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
193
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
194 if (state == NAME_GET)
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
195 dp->name = bp;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
196 else
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
197 lp->line = bp;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
198
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
199 bp = buf;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
200 state = (ch == MARKER) ? BEG_NAME : BEG_DESC;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
201 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
202 } /* NAME_GET || DESC_GET */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
203 if (ch == EOF)
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
204 break;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
205 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
206
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
207 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
208 DOCSTR **array;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
209 register int i; /* counter */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
210
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
211 /* build array of ptrs to DOCSTRs */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
212
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
213 array = (DOCSTR**)xmalloc (cnt * sizeof (*array));
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
214 for (dp = docs, i = 0; dp != NULL ; dp = dp->next)
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
215 array[i++] = dp;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
216
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
217 /* sort the array by name; within each name, by type */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
218
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
219 qsort ((char*)array, cnt, sizeof (DOCSTR*), cmpdoc);
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
220
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
221 /* write the output header */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
222
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
223 printf ("\\input texinfo @c -*-texinfo-*-\n");
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
224 printf ("@setfilename ../info/summary\n");
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
225 printf ("@settitle Command Summary for GNU Emacs\n");
24533
32a7344ac2e7 (main): Split up tables. Modify the preamble
Dave Love <fx@gnu.org>
parents: 15719
diff changeset
226 printf ("@finalout\n");
29
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
227 printf ("@unnumbered Command Summary for GNU Emacs\n");
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
228 printf ("@table @asis\n");
1175
c4535b4417d2 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 29
diff changeset
229 printf ("\n");
24533
32a7344ac2e7 (main): Split up tables. Modify the preamble
Dave Love <fx@gnu.org>
parents: 15719
diff changeset
230 printf ("@iftex\n");
32a7344ac2e7 (main): Split up tables. Modify the preamble
Dave Love <fx@gnu.org>
parents: 15719
diff changeset
231 printf ("@global@let@ITEM@item\n");
1175
c4535b4417d2 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 29
diff changeset
232 printf ("@def@item{@filbreak@vskip5pt@ITEM}\n");
c4535b4417d2 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 29
diff changeset
233 printf ("@font@tensy cmsy10 scaled @magstephalf\n");
c4535b4417d2 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 29
diff changeset
234 printf ("@font@teni cmmi10 scaled @magstephalf\n");
c4535b4417d2 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 29
diff changeset
235 printf ("@def\\{{@tensy@char110}}\n"); /* this backslash goes with cmr10 */
c4535b4417d2 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 29
diff changeset
236 printf ("@def|{{@tensy@char106}}\n");
c4535b4417d2 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 29
diff changeset
237 printf ("@def@{{{@tensy@char102}}\n");
c4535b4417d2 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 29
diff changeset
238 printf ("@def@}{{@tensy@char103}}\n");
c4535b4417d2 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 29
diff changeset
239 printf ("@def<{{@teni@char62}}\n");
c4535b4417d2 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 29
diff changeset
240 printf ("@def>{{@teni@char60}}\n");
c4535b4417d2 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 29
diff changeset
241 printf ("@chardef@@64\n");
c4535b4417d2 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 29
diff changeset
242 printf ("@catcode43=12\n");
c4535b4417d2 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 29
diff changeset
243 printf ("@tableindent-0.2in\n");
24533
32a7344ac2e7 (main): Split up tables. Modify the preamble
Dave Love <fx@gnu.org>
parents: 15719
diff changeset
244 printf ("@end iftex\n");
29
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
245
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
246 /* print each function from the array */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
247
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
248 for (i = 0; i < cnt; i++)
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 ("\n@item %s @code{%s}\n@display\n",
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
251 array[i]->type == 'F' ? "Function" : "Variable",
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
252 array[i]->name);
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
253
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
254 for (lp = array[i]->first; lp != NULL ; lp = lp->next)
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
255 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
256 for (bp = lp->line; *bp; bp++)
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
257 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
258 /* the characters "@{}" need special treatment */
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
259 if (*bp == '@' || *bp == '{' || *bp == '}')
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
260 {
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
261 putchar('@');
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
262 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
263 putchar(*bp);
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
264 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
265 putchar ('\n');
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
266 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
267 printf("@end display\n");
24533
32a7344ac2e7 (main): Split up tables. Modify the preamble
Dave Love <fx@gnu.org>
parents: 15719
diff changeset
268 /* Try to avoid a save size overflow in the TeX output
32a7344ac2e7 (main): Split up tables. Modify the preamble
Dave Love <fx@gnu.org>
parents: 15719
diff changeset
269 routine. */
32a7344ac2e7 (main): Split up tables. Modify the preamble
Dave Love <fx@gnu.org>
parents: 15719
diff changeset
270 if (i%100 == 0 && i > 0 && i != cnt)
32a7344ac2e7 (main): Split up tables. Modify the preamble
Dave Love <fx@gnu.org>
parents: 15719
diff changeset
271 printf("\n@end table\n@table @asis\n");
29
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
272 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
273
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
274 printf ("@end table\n");
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
275 printf ("@bye\n");
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
276 }
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
277
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
278 return 0;
aa2024430f3f Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
279 }