comparison lib-src/make-docfile.c @ 26:441bb1e64a06 r19-15b96

Import from CVS: tag r19-15b96
author cvs
date Mon, 13 Aug 2007 08:51:32 +0200
parents 859a2309aef8
children 131b0175ea99
comparison
equal deleted inserted replaced
25:383a494979f8 26:441bb1e64a06
31 are entries containing function or variable names and their documentation. 31 are entries containing function or variable names and their documentation.
32 Each entry starts with a ^_ character. 32 Each entry starts with a ^_ character.
33 Then comes F for a function or V for a variable. 33 Then comes F for a function or V for a variable.
34 Then comes the function or variable name, terminated with a newline. 34 Then comes the function or variable name, terminated with a newline.
35 Then comes the documentation for that function or variable. 35 Then comes the documentation for that function or variable.
36
37 Added 19.15/20.1: `-i site-packages' allow installer to dump extra packages
38 without modifying Makefiles, etc.
36 */ 39 */
37 40
38 #define NO_SHORTNAMES /* Tell config not to load remap.h */ 41 #define NO_SHORTNAMES /* Tell config not to load remap.h */
39 #include <../src/config.h> 42 #include <../src/config.h>
40 43
72 #undef chdir 75 #undef chdir
73 #endif 76 #endif
74 77
75 /* Stdio stream for output to the DOC file. */ 78 /* Stdio stream for output to the DOC file. */
76 static FILE *outfile; 79 static FILE *outfile;
80 static char *extra_elcs = NULL;
77 81
78 enum 82 enum
79 { 83 {
80 el_file, 84 el_file,
81 elc_file, 85 elc_file,
128 if (result == NULL) 132 if (result == NULL)
129 fatal ("virtual memory exhausted", 0); 133 fatal ("virtual memory exhausted", 0);
130 return result; 134 return result;
131 } 135 }
132 136
137
138 static char *
139 next_extra_elc(char *extra_elcs)
140 {
141 static FILE *fp = NULL;
142 static char line_buf[BUFSIZ];
143 char *p = line_buf+1;
144
145 if (!fp) {
146 if (!extra_elcs) {
147 return NULL;
148 } else if (!(fp = fopen(extra_elcs, "r"))) {
149 /* It is not an error if this file doesn't exist. */
150 /*fatal("error opening site package file list", 0);*/
151 return NULL;
152 }
153 fgets(line_buf, BUFSIZ, fp);
154 }
155
156 again:
157 if (!fgets(line_buf, BUFSIZ, fp)) {
158 fclose(fp);
159 fp = NULL;
160 return NULL;
161 }
162 line_buf[0] = '\0';
163 if (strlen(p) <= 2 || strlen(p) >= (BUFSIZ - 5)) {
164 /* reject too short or too long lines */
165 goto again;
166 }
167 p[strlen(p) - 2] = '\0';
168 strcat(p, ".elc");
169
170 return p;
171 }
172
133 173
134 int 174 int
135 main (int argc, char **argv) 175 main (int argc, char **argv)
136 { 176 {
137 int i; 177 int i;
172 if (argc > i + 1 && !strcmp (argv[i], "-d")) 212 if (argc > i + 1 && !strcmp (argv[i], "-d"))
173 { 213 {
174 chdir (argv[i + 1]); 214 chdir (argv[i + 1]);
175 i += 2; 215 i += 2;
176 } 216 }
217
218 if (argc > (i + 1) && !strcmp(argv[i], "-i")) {
219 extra_elcs = argv[i + 1];
220 i += 2;
221 }
177 222
178 if (outfile == 0) 223 if (outfile == 0)
179 fatal ("No output file specified", ""); 224 fatal ("No output file specified", "");
180 225
181 first_infile = i; 226 first_infile = i;
188 break; 233 break;
189 if (j == i) 234 if (j == i)
190 /* err_count seems to be {mis,un}used */ 235 /* err_count seems to be {mis,un}used */
191 err_count += scan_file (argv[i]); 236 err_count += scan_file (argv[i]);
192 } 237 }
238
239 if (extra_elcs) {
240 char *p;
241
242 while ((p = next_extra_elc(extra_elcs)) != NULL) {
243 err_count += scan_file(p);
244 }
245 }
246
193 putc ('\n', outfile); 247 putc ('\n', outfile);
194 #ifndef VMS 248 #ifndef VMS
195 exit (err_count > 0); 249 exit (err_count > 0);
196 #endif /* VMS */ 250 #endif /* VMS */
197 return err_count > 0; 251 return err_count > 0;