comparison lib-src/make-docfile.c @ 102:a145efe76779 r20-1b3

Import from CVS: tag r20-1b3
author cvs
date Mon, 13 Aug 2007 09:15:49 +0200
parents 6a378aca36af
children 8eaf7971accc
comparison
equal deleted inserted replaced
101:a0ec055d74dd 102:a145efe76779
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 static char *
138 next_extra_elc(char *extra_elcs)
139 {
140 static FILE *fp = NULL;
141 static char line_buf[BUFSIZ];
142 char *p = line_buf+1;
143
144 if (!fp) {
145 if (!extra_elcs) {
146 return NULL;
147 } else if (!(fp = fopen(extra_elcs, "r"))) {
148 /* It is not an error if this file doesn't exist. */
149 /*fatal("error opening site package file list", 0);*/
150 return NULL;
151 }
152 fgets(line_buf, BUFSIZ, fp);
153 }
154
155 again:
156 if (!fgets(line_buf, BUFSIZ, fp)) {
157 fclose(fp);
158 fp = NULL;
159 return NULL;
160 }
161 line_buf[0] = '\0';
162 if (strlen(p) <= 2 || strlen(p) >= (BUFSIZ - 5)) {
163 /* reject too short or too long lines */
164 goto again;
165 }
166 p[strlen(p) - 2] = '\0';
167 strcat(p, ".elc");
168
169 return p;
170 }
171
133 172
134 int 173 int
135 main (int argc, char **argv) 174 main (int argc, char **argv)
136 { 175 {
137 int i; 176 int i;
172 if (argc > i + 1 && !strcmp (argv[i], "-d")) 211 if (argc > i + 1 && !strcmp (argv[i], "-d"))
173 { 212 {
174 chdir (argv[i + 1]); 213 chdir (argv[i + 1]);
175 i += 2; 214 i += 2;
176 } 215 }
216
217 if (argc > (i + 1) && !strcmp(argv[i], "-i")) {
218 extra_elcs = argv[i + 1];
219 i += 2;
220 }
177 221
178 if (outfile == 0) 222 if (outfile == 0)
179 fatal ("No output file specified", ""); 223 fatal ("No output file specified", "");
180 224
181 first_infile = i; 225 first_infile = i;
188 break; 232 break;
189 if (j == i) 233 if (j == i)
190 /* err_count seems to be {mis,un}used */ 234 /* err_count seems to be {mis,un}used */
191 err_count += scan_file (argv[i]); 235 err_count += scan_file (argv[i]);
192 } 236 }
237
238 if (extra_elcs) {
239 char *p;
240
241 while ((p = next_extra_elc(extra_elcs)) != NULL) {
242 err_count += scan_file(p);
243 }
244 }
245
193 putc ('\n', outfile); 246 putc ('\n', outfile);
194 #ifndef VMS 247 #ifndef VMS
195 exit (err_count > 0); 248 exit (err_count > 0);
196 #endif /* VMS */ 249 #endif /* VMS */
197 return err_count > 0; 250 return err_count > 0;