comparison lib-src/make-docfile.c @ 70:131b0175ea99 r20-0b30

Import from CVS: tag r20-0b30
author cvs
date Mon, 13 Aug 2007 09:02:59 +0200
parents 441bb1e64a06
children 6a378aca36af
comparison
equal deleted inserted replaced
69:804d1389bcd6 70:131b0175ea99
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.
39 */ 36 */
40 37
41 #define NO_SHORTNAMES /* Tell config not to load remap.h */ 38 #define NO_SHORTNAMES /* Tell config not to load remap.h */
42 #include <../src/config.h> 39 #include <../src/config.h>
43 40
75 #undef chdir 72 #undef chdir
76 #endif 73 #endif
77 74
78 /* Stdio stream for output to the DOC file. */ 75 /* Stdio stream for output to the DOC file. */
79 static FILE *outfile; 76 static FILE *outfile;
80 static char *extra_elcs = NULL;
81 77
82 enum 78 enum
83 { 79 {
84 el_file, 80 el_file,
85 elc_file, 81 elc_file,
132 if (result == NULL) 128 if (result == NULL)
133 fatal ("virtual memory exhausted", 0); 129 fatal ("virtual memory exhausted", 0);
134 return result; 130 return result;
135 } 131 }
136 132
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
173 133
174 int 134 int
175 main (int argc, char **argv) 135 main (int argc, char **argv)
176 { 136 {
177 int i; 137 int i;
212 if (argc > i + 1 && !strcmp (argv[i], "-d")) 172 if (argc > i + 1 && !strcmp (argv[i], "-d"))
213 { 173 {
214 chdir (argv[i + 1]); 174 chdir (argv[i + 1]);
215 i += 2; 175 i += 2;
216 } 176 }
217
218 if (argc > (i + 1) && !strcmp(argv[i], "-i")) {
219 extra_elcs = argv[i + 1];
220 i += 2;
221 }
222 177
223 if (outfile == 0) 178 if (outfile == 0)
224 fatal ("No output file specified", ""); 179 fatal ("No output file specified", "");
225 180
226 first_infile = i; 181 first_infile = i;
233 break; 188 break;
234 if (j == i) 189 if (j == i)
235 /* err_count seems to be {mis,un}used */ 190 /* err_count seems to be {mis,un}used */
236 err_count += scan_file (argv[i]); 191 err_count += scan_file (argv[i]);
237 } 192 }
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
247 putc ('\n', outfile); 193 putc ('\n', outfile);
248 #ifndef VMS 194 #ifndef VMS
249 exit (err_count > 0); 195 exit (err_count > 0);
250 #endif /* VMS */ 196 #endif /* VMS */
251 return err_count > 0; 197 return err_count > 0;
879 { 825 {
880 826
881 /* Skip until the first newline; remember the two previous chars. */ 827 /* Skip until the first newline; remember the two previous chars. */
882 while (c != '\n' && c >= 0) 828 while (c != '\n' && c >= 0)
883 { 829 {
884 /* ### Kludge -- Ignore any ESC x x ISO2022 sequences */
885 if (c == 27)
886 {
887 getc (infile);
888 getc (infile);
889 goto nextchar;
890 }
891
892 c2 = c1; 830 c2 = c1;
893 c1 = c; 831 c1 = c;
894 nextchar:
895 c = getc (infile); 832 c = getc (infile);
896 } 833 }
897 834
898 /* If two previous characters were " and \, 835 /* If two previous characters were " and \,
899 this is a doc string. Otherwise, there is none. */ 836 this is a doc string. Otherwise, there is none. */
1021 continue; 958 continue;
1022 } 959 }
1023 } 960 }
1024 } 961 }
1025 962
1026 #if 0 /* causes crash */ 963 #ifdef DEBUG
1027 else if (! strcmp (buffer, "if") || 964 else if (! strcmp (buffer, "if") ||
1028 ! strcmp (buffer, "byte-code")) 965 ! strcmp (buffer, "byte-code"))
1029 ; 966 ;
1030 #endif 967 #endif
1031 968