annotate lib-src/sorted-doc.c @ 5935:d5eb0914ca1f cygwin

trial of E1 and UE1
author Henry Thompson <ht@markup.co.uk>
date Sat, 12 Dec 2015 21:49:31 +0000
parents 1f0b15040456
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5406
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 2367
diff changeset
1 /* Give this program DOC-mm.nn.oo as standard input and it outputs to
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 2367
diff changeset
2 standard output a file of texinfo input containing the doc strings.
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 2367
diff changeset
3
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 2367
diff changeset
4 Copyright (C) 1989, 1992, 1994, 1996, 1999, 2000, 2001, 2002, 2003,
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 2367
diff changeset
5 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 2367
diff changeset
6
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 2367
diff changeset
7 This file is part of XEmacs.
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 2367
diff changeset
8
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 2367
diff changeset
9 XEmacs is free software: you can redistribute it and/or modify
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 2367
diff changeset
10 it under the terms of the GNU General Public License as published by
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 2367
diff changeset
11 the Free Software Foundation, either version 3 of the License, or
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 2367
diff changeset
12 (at your option) any later version.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13
5406
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 2367
diff changeset
14 XEmacs is distributed in the hope that it will be useful,
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 2367
diff changeset
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 2367
diff changeset
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 2367
diff changeset
17 GNU General Public License for more details.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18
5406
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 2367
diff changeset
19 You should have received a copy of the GNU General Public License
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 2367
diff changeset
20 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 2367
diff changeset
21
5491
06dd936cde16 Merge some stuff in lib-src
Ben Wing <ben@xemacs.org>
parents: 2367
diff changeset
22 /* Synced up with: GNU 23.1.92. */
06dd936cde16 Merge some stuff in lib-src
Ben Wing <ben@xemacs.org>
parents: 2367
diff changeset
23 /* Synced by: Ben Wing, 2-17-10. */
5406
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 2367
diff changeset
24
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 2367
diff changeset
25 /* This version sorts the output by function name. */
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 2367
diff changeset
26
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 2367
diff changeset
27 #ifdef HAVE_CONFIG_H
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
28 #include <config.h>
5406
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 2367
diff changeset
29 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 #include <stdio.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 #include <ctype.h>
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
33 #include <stdlib.h> /* for qsort() and malloc() */
5406
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 2367
diff changeset
34 #include <string.h>
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
35 static void *xmalloc (size_t);
5491
06dd936cde16 Merge some stuff in lib-src
Ben Wing <ben@xemacs.org>
parents: 2367
diff changeset
36 #ifdef WIN32_NATIVE
5406
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 2367
diff changeset
37 #include <fcntl.h> /* for O_BINARY */
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 2367
diff changeset
38 #include <io.h> /* for setmode */
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 2367
diff changeset
39 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 #define NUL '\0'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 #define MARKER '\037'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 #define DEBUG 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
46 typedef struct LINE LINE;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
48 struct LINE
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 LINE *next; /* ptr to next or NULL */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 char *line; /* text of the line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 typedef struct docstr DOCSTR;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 struct docstr /* Allocated thing for an entry. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 DOCSTR *next; /* next in the chain */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 char *name; /* name of the function or var */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 LINE *first; /* first line of doc text. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 char type; /* 'F' for function, 'V' for variable */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 /* Print error message. `s1' is printf control string, `s2' is arg for it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 error (char *s1, char *s2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 fprintf (stderr, "sorted-doc: ");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 fprintf (stderr, s1, s2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 fprintf (stderr, "\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 /* Print error message and exit. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 fatal (char *s1, char *s2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 error (s1, s2);
5406
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 2367
diff changeset
81 exit (EXIT_FAILURE);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 /* Like malloc but get fatal error if memory is exhausted. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 static void *
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
87 xmalloc (size_t size)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
89 void *result = malloc (size);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 if (result == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 fatal ("%s", "virtual memory exhausted");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 return result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 static char *
5406
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 2367
diff changeset
96 xstrdup (char *str)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 {
5406
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 2367
diff changeset
98 char *buf = xmalloc (strlen (str) + 1);
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 2367
diff changeset
99 (void) strcpy (buf, str);
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 2367
diff changeset
100 return (buf);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 /* Comparison function for qsort to call. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 cmpdoc (DOCSTR **a, DOCSTR **b)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 register int val = strcmp ((*a)->name, (*b)->name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 if (val) return val;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 return (*a)->type - (*b)->type;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 enum state
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 WAITING, BEG_NAME, NAME_GET, BEG_DESC, DESC_GET
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
119 const char *states[] =
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 "WAITING", "BEG_NAME", "NAME_GET", "BEG_DESC", "DESC_GET"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 int
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
125 main (int argc, char **argv)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 register DOCSTR *dp = NULL; /* allocated DOCSTR */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 register LINE *lp = NULL; /* allocated line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 register char *bp = 0; /* ptr inside line buffer */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 register enum state state = WAITING; /* state at start */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 int cnt = 0; /* number of DOCSTRs read */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132
5406
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 2367
diff changeset
133 DOCSTR *docs = NULL; /* chain of allocated DOCSTRS */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 char buf[512]; /* line buffer */
5406
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 2367
diff changeset
135
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 2367
diff changeset
136 #ifdef DOS_NT
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 2367
diff changeset
137 /* DOC is a binary file. */
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 2367
diff changeset
138 if (!isatty (fileno (stdin)))
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 2367
diff changeset
139 setmode (fileno (stdin), O_BINARY);
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 2367
diff changeset
140 #endif
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 2367
diff changeset
141
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 2367
diff changeset
142 bp = buf;
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 2367
diff changeset
143
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144 while (1) /* process one char at a time */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 /* this char from the DOCSTR file */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 register int ch = getchar ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 /* Beginnings */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 if (state == WAITING)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 if (ch == MARKER)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 state = BEG_NAME;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 else if (state == BEG_NAME)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 cnt++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 if (dp == NULL) /* first dp allocated */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 docs = dp = (DOCSTR*) xmalloc (sizeof (DOCSTR));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 else /* all the rest */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 dp->next = (DOCSTR*) xmalloc (sizeof (DOCSTR));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 dp = dp->next;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 lp = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 dp->next = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 bp = buf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 state = NAME_GET;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 /* Record whether function or variable. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 dp->type = ch;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 ch = getchar ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 else if (state == BEG_DESC)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 if (lp == NULL) /* first line for dp */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 dp->first = lp = (LINE*)xmalloc (sizeof (LINE));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 else /* continuing lines */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 lp->next = (LINE*)xmalloc (sizeof (LINE));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 lp = lp->next;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 lp->next = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 bp = buf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 state = DESC_GET;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 }
5406
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 2367
diff changeset
191
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 /* process gets */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 if (state == NAME_GET || state == DESC_GET)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 if (ch != MARKER && ch != '\n' && ch != EOF)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 *bp++ = ch;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200 else /* saving and changing state */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 *bp = NUL;
5406
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 2367
diff changeset
203 bp = xstrdup (buf);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 if (state == NAME_GET)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 dp->name = bp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 lp->line = bp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 bp = buf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 state = (ch == MARKER) ? BEG_NAME : BEG_DESC;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 } /* NAME_GET || DESC_GET */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 if (ch == EOF)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 DOCSTR **array;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 register int i; /* counter */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 /* build array of ptrs to DOCSTRs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 array = (DOCSTR**)xmalloc (cnt * sizeof (*array));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 for (dp = docs, i = 0; dp != NULL ; dp = dp->next)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 array[i++] = dp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228 /* sort the array by name; within each name, by type */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 qsort ((char*)array, cnt, sizeof (DOCSTR*),
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
231 (int (*)(const void *, const void *)) cmpdoc);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233 /* write the output header */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235 printf ("\\input texinfo @c -*-texinfo-*-\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 printf ("@setfilename ../info/summary\n");
613
023b83f4e54b [xemacs-hg @ 2001-06-10 10:42:16 by ben]
ben
parents: 442
diff changeset
237 printf ("@settitle Command Summary for XEmacs\n");
5406
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 2367
diff changeset
238 printf ("@finalout\n");
613
023b83f4e54b [xemacs-hg @ 2001-06-10 10:42:16 by ben]
ben
parents: 442
diff changeset
239 printf ("@unnumbered Command Summary for XEmacs\n");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 printf ("@table @asis\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 printf ("\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 printf ("@iftex\n");
5491
06dd936cde16 Merge some stuff in lib-src
Ben Wing <ben@xemacs.org>
parents: 2367
diff changeset
243 /* #### XEmacs note: FSF 23.1.92 is missing the = sign below.
06dd936cde16 Merge some stuff in lib-src
Ben Wing <ben@xemacs.org>
parents: 2367
diff changeset
244 Which is correct? */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 printf ("@global@let@ITEM=@item\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 printf ("@def@item{@filbreak@vskip5pt@ITEM}\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 printf ("@font@tensy cmsy10 scaled @magstephalf\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 printf ("@font@teni cmmi10 scaled @magstephalf\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249 printf ("@def\\{{@tensy@char110}}\n"); /* this backslash goes with cmr10 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 printf ("@def|{{@tensy@char106}}\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 printf ("@def@{{{@tensy@char102}}\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 printf ("@def@}{{@tensy@char103}}\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 printf ("@def<{{@teni@char62}}\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 printf ("@def>{{@teni@char60}}\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 printf ("@chardef@@64\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 printf ("@catcode43=12\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 printf ("@tableindent-0.2in\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258 printf ("@end iftex\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 /* print each function from the array */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 for (i = 0; i < cnt; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 printf ("\n@item %s @code{%s}\n@display\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 array[i]->type == 'F' ? "Function" : "Variable",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 array[i]->name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 for (lp = array[i]->first; lp != NULL ; lp = lp->next)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 for (bp = lp->line; *bp; bp++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 /* the characters "@{}" need special treatment */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 if (*bp == '@' || *bp == '{' || *bp == '}')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 putchar('@');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 putchar(*bp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 putchar ('\n');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 printf("@end display\n");
5406
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 2367
diff changeset
282 /* Try to avoid a save size overflow in the TeX output
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 2367
diff changeset
283 routine. */
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 2367
diff changeset
284 if (i%100 == 0 && i > 0 && i != cnt)
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 2367
diff changeset
285 printf("\n@end table\n@table @asis\n");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 printf ("@end table\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 printf ("@bye\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291
5406
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 2367
diff changeset
292 return EXIT_SUCCESS;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293 }
5406
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 2367
diff changeset
294
5491
06dd936cde16 Merge some stuff in lib-src
Ben Wing <ben@xemacs.org>
parents: 2367
diff changeset
295 /* arch-tag: ce28f204-1e70-4b34-8210-3d54a5662071
06dd936cde16 Merge some stuff in lib-src
Ben Wing <ben@xemacs.org>
parents: 2367
diff changeset
296 (do not change this comment) */
06dd936cde16 Merge some stuff in lib-src
Ben Wing <ben@xemacs.org>
parents: 2367
diff changeset
297
5406
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 2367
diff changeset
298 /* sorted-doc.c ends here */