Mercurial > hg > xemacs-beta
annotate lib-src/make-docfile.c @ 4742:4cf435fcebbc
Make #'letf not error if handed a #'values form.
lisp/ChangeLog addition:
2009-11-14 Aidan Kehoe <kehoea@parhasard.net>
* cl-macs.el (letf):
Check whether arguments to #'values are bound, and make them
unbound after evaluating BODY; document the limitations of this
macro.
tests/ChangeLog addition:
2009-11-14 Aidan Kehoe <kehoea@parhasard.net>
* automated/lisp-tests.el:
Don't call Known-Bug-Expect-Failure now that the particular letf
bug it tickled is fixed.
| author | Aidan Kehoe <kehoea@parhasard.net> |
|---|---|
| date | Sat, 14 Nov 2009 11:43:09 +0000 |
| parents | f3a65dff1912 |
| children | d555581e3cba |
| rev | line source |
|---|---|
| 428 | 1 /* Generate doc-string file for XEmacs from source files. |
| 930 | 2 Copyright (C) 1985, 86, 92, 93, 94, 97, 1999, 2000, 2001 |
| 3 Free Software Foundation, Inc. | |
| 428 | 4 Copyright (C) 1995 Board of Trustees, University of Illinois. |
| 5 Copyright (C) 1998, 1999 J. Kean Johnston. | |
| 814 | 6 Copyright (C) 2001, 2002 Ben Wing. |
| 930 | 7 |
| 8 This file is part of XEmacs. | |
| 9 | |
| 10 XEmacs is free software; you can redistribute it and/or modify | |
| 11 it under the terms of the GNU General Public License as published by | |
| 12 the Free Software Foundation; either version 2, or (at your option) | |
| 13 any later version. | |
| 428 | 14 |
| 930 | 15 XEmacs is distributed in the hope that it will be useful, |
| 16 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 18 GNU General Public License for more details. | |
| 19 | |
| 20 You should have received a copy of the GNU General Public License | |
| 21 along with XEmacs; see the file COPYING. If not, write to | |
| 22 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
| 23 Boston, MA 02111-1307, USA. */ | |
| 24 | |
| 1618 | 25 /* Synched up with: FSF 21.3. */ |
| 428 | 26 |
| 27 /* The arguments given to this program are all the C and Lisp source files | |
| 930 | 28 of XEmacs. .elc and .el and .c files are allowed. |
| 29 A .o or .obj file can also be specified; the .c file it was made from is used. | |
| 30 This helps the makefile pass the correct list of files. | |
| 31 | |
| 32 The results, which go to standard output or to a file | |
| 33 specified with -a or -o (-a to append, -o to start from nothing), | |
| 34 are entries containing function or variable names and their documentation. | |
| 35 Each entry starts with a ^_ character. | |
| 36 Then comes F for a function or V for a variable. | |
| 37 Then comes the function or variable name, terminated with a newline. | |
| 38 Then comes the documentation for that function or variable. | |
| 39 | |
| 40 Added 19.15/20.1: `-i site-packages' allow installer to dump extra packages | |
| 41 without modifying Makefiles, etc. | |
| 428 | 42 */ |
| 43 | |
| 438 | 44 #include <config.h> |
| 930 | 45 #include <sysfile.h> |
| 428 | 46 |
| 3368 | 47 #include <assert.h> |
| 428 | 48 #include <stdio.h> |
| 49 #include <stdlib.h> | |
| 50 #include <string.h> | |
| 51 #include <ctype.h> | |
| 52 | |
| 2286 | 53 #include "compiler.h" |
| 54 | |
| 930 | 55 /* XEmacs addition */ |
| 56 #define C_IDENTIFIER_CHAR_P(c) \ | |
| 57 (('A' <= c && c <= 'Z') || \ | |
| 58 ('a' <= c && c <= 'z') || \ | |
| 59 ('0' <= c && c <= '9') || \ | |
| 60 (c == '_')) | |
| 428 | 61 |
| 3368 | 62 static void put_filename (const char *filename); |
| 442 | 63 static int scan_file (const char *filename); |
| 428 | 64 static int read_c_string (FILE *, int, int); |
| 442 | 65 static void write_c_args (FILE *out, const char *func, char *buf, int minargs, |
| 428 | 66 int maxargs); |
| 442 | 67 static int scan_c_file (const char *filename, const char *mode); |
| 428 | 68 static void skip_white (FILE *); |
| 69 static void read_lisp_symbol (FILE *, char *); | |
| 442 | 70 static int scan_lisp_file (const char *filename, const char *mode); |
| 428 | 71 |
| 930 | 72 /* Stdio stream for output to the DOC file. */ |
| 73 static FILE *outfile; | |
| 74 | |
| 75 /* XEmacs addition */ | |
| 76 enum | |
| 77 { | |
| 78 el_file, | |
| 79 elc_file, | |
| 80 c_file | |
| 81 } Current_file_type; | |
| 428 | 82 |
| 83 /* Name this program was invoked with. */ | |
| 84 char *progname; | |
| 85 | |
| 930 | 86 /* XEmacs addition: set to 1 if this was invoked by ellcc */ |
| 428 | 87 int ellcc = 0; |
| 88 | |
| 89 /* Print error message. `s1' is printf control string, `s2' is arg for it. */ | |
| 90 | |
| 91 static void | |
| 442 | 92 error (const char *s1, const char *s2) |
| 428 | 93 { |
| 94 fprintf (stderr, "%s: ", progname); | |
| 95 fprintf (stderr, s1, s2); | |
| 96 fprintf (stderr, "\n"); | |
| 97 } | |
| 98 | |
| 99 /* Print error message and exit. */ | |
| 100 | |
| 101 static void | |
| 442 | 102 fatal (const char *s1, const char *s2) |
| 428 | 103 { |
| 104 error (s1, s2); | |
| 105 exit (1); | |
| 106 } | |
| 107 | |
| 108 /* Like malloc but get fatal error if memory is exhausted. */ | |
| 109 | |
| 110 static long * | |
| 111 xmalloc (unsigned int size) | |
| 112 { | |
| 113 long *result = (long *) malloc (size); | |
| 114 if (result == NULL) | |
| 115 fatal ("virtual memory exhausted", 0); | |
| 116 return result; | |
| 117 } | |
| 118 | |
| 930 | 119 /* XEmacs addition */ |
| 428 | 120 static char * |
| 814 | 121 next_extra_elc (char *extra_elcs) |
| 428 | 122 { |
| 123 static FILE *fp = NULL; | |
| 124 static char line_buf[BUFSIZ]; | |
| 125 char *p = line_buf+1; | |
| 126 | |
| 814 | 127 if (!fp) |
| 128 { | |
| 129 if (!extra_elcs) | |
| 130 return NULL; | |
| 131 else if (!(fp = fopen (extra_elcs, READ_BINARY))) | |
| 132 { | |
| 133 /* It is not an error if this file doesn't exist. */ | |
| 134 /*fatal ("error opening site package file list", 0);*/ | |
| 135 return NULL; | |
| 136 } | |
| 137 fgets (line_buf, BUFSIZ, fp); | |
| 138 } | |
| 139 | |
| 930 | 140 do |
| 814 | 141 { |
| 930 | 142 if (!fgets (line_buf, BUFSIZ, fp)) |
| 143 { | |
| 144 fclose (fp); | |
| 145 fp = NULL; | |
| 146 return NULL; | |
| 147 } | |
| 148 line_buf[0] = '\0'; | |
| 814 | 149 /* reject too short or too long lines */ |
| 930 | 150 } while (strlen (p) <= 2 || strlen (p) >= (BUFSIZ - 5)); |
| 151 | |
| 814 | 152 p[strlen (p) - 2] = '\0'; |
| 153 strcat (p, ".elc"); | |
| 428 | 154 |
| 155 return p; | |
| 156 } | |
| 157 | |
| 158 | |
| 159 int | |
| 160 main (int argc, char **argv) | |
| 161 { | |
| 162 int i; | |
| 163 int err_count = 0; | |
| 164 int first_infile; | |
| 930 | 165 char *extra_elcs = NULL; /* XEmacs addition */ |
| 428 | 166 |
| 167 progname = argv[0]; | |
| 168 | |
| 169 outfile = stdout; | |
| 170 | |
| 171 /* Don't put CRs in the DOC file. */ | |
| 442 | 172 #ifdef WIN32_NATIVE |
| 428 | 173 _fmode = O_BINARY; |
| 174 _setmode (fileno (stdout), O_BINARY); | |
| 442 | 175 #endif /* WIN32_NATIVE */ |
| 428 | 176 |
| 177 /* If first two args are -o FILE, output to FILE. */ | |
| 178 i = 1; | |
| 179 if (argc > i + 1 && !strcmp (argv[i], "-o")) | |
| 180 { | |
| 181 outfile = fopen (argv[i + 1], WRITE_BINARY); | |
| 182 i += 2; | |
| 183 } | |
| 184 if (argc > i + 1 && !strcmp (argv[i], "-a")) | |
| 185 { | |
| 186 outfile = fopen (argv[i + 1], APPEND_BINARY); | |
| 187 i += 2; | |
| 188 } | |
| 930 | 189 if (argc > i + 1 && !strcmp (argv[i], "-d")) |
| 190 { | |
| 191 chdir (argv[i + 1]); | |
| 192 i += 2; | |
| 193 } | |
| 194 | |
| 195 /* Additional command line arguments for XEmacs */ | |
| 428 | 196 if (argc > i + 1 && !strcmp (argv[i], "-E")) |
| 197 { | |
| 198 outfile = fopen (argv[i + 1], APPEND_BINARY); | |
| 199 i += 2; | |
| 200 ellcc = 1; | |
| 201 } | |
| 814 | 202 if (argc > (i + 1) && !strcmp (argv[i], "-i")) |
| 203 { | |
| 204 extra_elcs = argv[i + 1]; | |
| 205 i += 2; | |
| 206 } | |
| 428 | 207 |
| 208 if (outfile == 0) | |
| 209 fatal ("No output file specified", ""); | |
| 210 | |
| 930 | 211 /* XEmacs addition */ |
| 428 | 212 if (ellcc) |
| 213 fprintf (outfile, "{\n"); | |
| 214 | |
| 215 first_infile = i; | |
| 216 for (; i < argc; i++) | |
| 217 { | |
| 930 | 218 /* XEmacs addition: the "if" clause is new; the "else" clause is the |
| 219 original FSF Emacs code */ | |
| 771 | 220 if (argv[i][0] == '@') |
| 221 { | |
| 222 /* Allow a file containing files to process, for use w/MS Windows | |
| 223 (where command-line length limits are more problematic) */ | |
| 224 FILE *argfile = fopen (argv[i] + 1, READ_TEXT); | |
| 2421 | 225 char arg[QXE_PATH_MAX]; |
| 771 | 226 |
| 227 if (!argfile) | |
| 228 fatal ("Unable to open argument file %s", argv[i] + 1); | |
| 2421 | 229 while (fgets (arg, QXE_PATH_MAX, argfile)) |
| 771 | 230 { |
| 231 if (arg[strlen (arg) - 1] == '\n') | |
| 232 arg[strlen (arg) - 1] = '\0'; /* chop \n */ | |
| 233 err_count += scan_file (arg); | |
| 234 } | |
| 235 } | |
|
4539
061e030e3270
Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4456
diff
changeset
|
236 else if (argc > i + 1 && !strcmp (argv[i], "-d")) |
|
061e030e3270
Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4456
diff
changeset
|
237 { |
|
061e030e3270
Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4456
diff
changeset
|
238 /* XEmacs change; allow more than one chdir. |
|
061e030e3270
Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4456
diff
changeset
|
239 The idea is that the second chdir is to source-lisp, and that |
|
061e030e3270
Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4456
diff
changeset
|
240 any Lisp files not under there have the full path specified. */ |
|
061e030e3270
Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4456
diff
changeset
|
241 i += 1; |
|
061e030e3270
Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4456
diff
changeset
|
242 chdir (argv[i]); |
|
061e030e3270
Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4456
diff
changeset
|
243 continue; |
|
061e030e3270
Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4456
diff
changeset
|
244 } |
| 771 | 245 else |
| 246 { | |
| 247 int j; | |
| 248 /* Don't process one file twice. */ | |
| 249 for (j = first_infile; j < i; j++) | |
| 250 if (! strcmp (argv[i], argv[j])) | |
| 251 break; | |
| 252 if (j == i) | |
| 253 err_count += scan_file (argv[i]); | |
| 254 } | |
| 428 | 255 } |
| 256 | |
| 930 | 257 /* XEmacs addition */ |
| 814 | 258 if (extra_elcs) |
| 259 { | |
| 260 char *p; | |
| 428 | 261 |
| 814 | 262 while ((p = next_extra_elc (extra_elcs)) != NULL) |
| 263 err_count += scan_file (p); | |
| 428 | 264 } |
| 265 | |
| 266 putc ('\n', outfile); | |
| 267 if (ellcc) | |
| 268 fprintf (outfile, "}\n\n"); | |
| 930 | 269 /* End XEmacs addition */ |
| 270 | |
| 428 | 271 #ifndef VMS |
| 272 exit (err_count > 0); | |
| 273 #endif /* VMS */ | |
| 274 return err_count > 0; | |
| 275 } | |
| 276 | |
| 3368 | 277 /* Add a source file name boundary in the output file. */ |
| 278 static void | |
| 279 put_filename (const char *filename) | |
| 280 { | |
|
4539
061e030e3270
Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4456
diff
changeset
|
281 /* XEmacs change; don't strip directory information. */ |
|
061e030e3270
Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4456
diff
changeset
|
282 #if 0 |
| 3368 | 283 const char *tmp; |
| 284 | |
| 285 for (tmp = filename; *tmp; tmp++) | |
| 286 { | |
| 287 if (IS_DIRECTORY_SEP(*tmp)) | |
| 288 filename = tmp + 1; | |
| 289 } | |
|
4539
061e030e3270
Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4456
diff
changeset
|
290 #endif |
| 3368 | 291 |
| 292 /* <= because sizeof includes the nul byte at the end. Not quite right, | |
| 293 because it should include the length of the symbol + "\037[VF]" instead | |
| 294 of simply 10. */ | |
| 295 assert(sizeof("\037S\n") + strlen(filename) + 10 | |
| 296 <= DOC_MAX_FILENAME_LENGTH); | |
| 297 | |
| 298 putc (037, outfile); | |
| 299 putc ('S', outfile); | |
| 300 fprintf (outfile, "%s\n", filename); | |
| 301 } | |
| 302 | |
| 428 | 303 /* Read file FILENAME and output its doc strings to outfile. */ |
| 304 /* Return 1 if file is not found, 0 if it is found. */ | |
| 305 | |
| 306 static int | |
| 442 | 307 scan_file (const char *filename) |
| 428 | 308 { |
| 309 int len = strlen (filename); | |
| 930 | 310 |
| 311 /* XEmacs change: test ellcc and set Current_file_type in each case */ | |
| 428 | 312 if (ellcc == 0 && len > 4 && !strcmp (filename + len - 4, ".elc")) |
| 313 { | |
| 314 Current_file_type = elc_file; | |
| 315 return scan_lisp_file (filename, READ_BINARY); | |
| 316 } | |
| 317 else if (ellcc == 0 && len > 3 && !strcmp (filename + len - 3, ".el")) | |
| 318 { | |
| 319 Current_file_type = el_file; | |
|
4456
c785f98c6737
Pass READ_BINARY to scan_lisp_file, scan_c_file in make-docfile.c
Aidan Kehoe <kehoea@parhasard.net>
parents:
3368
diff
changeset
|
320 return scan_lisp_file (filename, READ_BINARY); |
| 428 | 321 } |
| 322 else | |
| 323 { | |
| 324 Current_file_type = c_file; | |
|
4456
c785f98c6737
Pass READ_BINARY to scan_lisp_file, scan_c_file in make-docfile.c
Aidan Kehoe <kehoea@parhasard.net>
parents:
3368
diff
changeset
|
325 return scan_c_file (filename, READ_BINARY); |
| 428 | 326 } |
| 327 } | |
| 930 | 328 |
| 329 /* XEmacs addition: ISO 2022 handling */ | |
| 814 | 330 static int |
| 331 getc_skipping_iso2022 (FILE *file) | |
| 332 { | |
| 333 register int c; | |
| 334 /* #### Kludge -- Ignore any ISO2022 sequences */ | |
| 335 c = getc (file); | |
| 336 while (c == 27) | |
| 337 { | |
| 338 c = getc (file); | |
| 339 if (c == '$') | |
| 340 c = getc (file); | |
| 341 if (c >= '(' && c <= '/') | |
| 342 c = getc (file); | |
| 343 c = getc (file); | |
| 344 } | |
| 345 return c; | |
| 346 } | |
| 347 | |
| 348 enum iso2022_state | |
| 349 { | |
| 350 ISO_NOTHING, | |
| 351 ISO_ESC, | |
| 352 ISO_DOLLAR, | |
| 353 ISO_FINAL_IS_NEXT, | |
| 354 ISO_DOLLAR_AND_FINAL_IS_NEXT | |
| 355 }; | |
| 356 | |
| 357 static int non_ascii_p; | |
| 358 | |
| 359 static int | |
| 360 getc_iso2022 (FILE *file) | |
| 361 { | |
| 362 /* #### Kludge -- Parse ISO2022 sequences (more or less) */ | |
| 363 static enum iso2022_state state; | |
| 364 static int prevc; | |
| 365 register int c; | |
| 366 c = getc (file); | |
| 367 switch (state) | |
| 368 { | |
| 369 case ISO_NOTHING: | |
| 370 if (c == 27) | |
| 371 state = ISO_ESC; | |
| 372 break; | |
| 373 | |
| 374 case ISO_ESC: | |
| 375 if (c == '$') | |
| 376 state = ISO_DOLLAR; | |
| 377 else if (c >= '(' && c <= '/') | |
| 378 state = ISO_FINAL_IS_NEXT; | |
| 379 else | |
| 380 state = ISO_NOTHING; | |
| 381 break; | |
| 382 | |
| 383 case ISO_DOLLAR: | |
| 384 if (c >= '(' && c <= '/') | |
| 385 state = ISO_DOLLAR_AND_FINAL_IS_NEXT; | |
| 386 else if (c >= '@' && c <= 'B') /* ESC $ @ etc */ | |
| 387 { | |
| 388 non_ascii_p = 1; | |
| 389 state = ISO_NOTHING; | |
| 390 } | |
| 391 else | |
| 392 state = ISO_NOTHING; | |
| 393 break; | |
| 394 | |
| 395 case ISO_FINAL_IS_NEXT: | |
| 396 if (prevc == '(' && c == 'B') /* ESC ( B, invoke ASCII */ | |
| 397 non_ascii_p = 0; | |
| 398 else if (prevc == '(' || prevc == ',') /* ESC ( x or ESC , x */ | |
| 399 non_ascii_p = 1; | |
| 400 state = ISO_NOTHING; | |
| 401 break; | |
| 402 | |
| 403 case ISO_DOLLAR_AND_FINAL_IS_NEXT: | |
| 404 if (prevc == '(' || prevc == ',') /* ESC $ ( x or ESC $ , x */ | |
| 405 non_ascii_p = 1; | |
| 406 state = ISO_NOTHING; | |
| 407 break; | |
| 408 } | |
| 409 | |
| 410 prevc = c; | |
| 411 return c; | |
| 412 } | |
| 413 | |
| 428 | 414 |
| 1111 | 415 char globalbuf[128]; |
| 428 | 416 |
| 417 /* Skip a C string from INFILE, | |
| 930 | 418 and return the character that follows the closing ". |
| 428 | 419 If printflag is positive, output string contents to outfile. |
| 420 If it is negative, store contents in buf. | |
| 421 Convert escape sequences \n and \t to newline and tab; | |
| 422 discard \ followed by newline. */ | |
| 423 | |
| 814 | 424 #define MDGET do { prevc = c; c = getc_iso2022 (infile); } while (0) |
| 428 | 425 static int |
| 426 read_c_string (FILE *infile, int printflag, int c_docstring) | |
| 427 { | |
| 442 | 428 register int prevc = 0, c = 0; |
| 1111 | 429 char *p = globalbuf; |
| 930 | 430 int start = -1; /* XEmacs addition */ |
| 428 | 431 |
| 442 | 432 MDGET; |
| 428 | 433 while (c != EOF) |
| 434 { | |
| 814 | 435 while ((c_docstring || c != '"' || non_ascii_p) && c != EOF) |
| 428 | 436 { |
| 930 | 437 /* XEmacs addition: the first two "if" clauses are new */ |
| 814 | 438 if (c == '*' && !non_ascii_p) |
| 428 | 439 { |
| 442 | 440 int cc = getc (infile); |
| 441 if (cc == '/') | |
| 428 | 442 { |
| 442 | 443 if (prevc != '\n') |
| 444 { | |
| 445 if (printflag > 0) | |
| 446 { | |
| 447 if (ellcc) | |
| 448 fprintf (outfile, "\\n\\"); | |
| 449 putc ('\n', outfile); | |
| 450 } | |
| 451 else if (printflag < 0) | |
| 452 *p++ = '\n'; | |
| 453 } | |
| 454 break; | |
| 428 | 455 } |
| 442 | 456 else |
| 457 ungetc (cc, infile); | |
| 458 } | |
| 428 | 459 |
| 442 | 460 if (start == 1) |
| 461 { | |
| 462 if (printflag > 0) | |
| 428 | 463 { |
| 442 | 464 if (ellcc) |
| 465 fprintf (outfile, "\\n\\"); | |
| 466 putc ('\n', outfile); | |
| 428 | 467 } |
| 442 | 468 else if (printflag < 0) |
| 469 *p++ = '\n'; | |
| 428 | 470 } |
| 930 | 471 /* End XEmacs addition */ |
| 428 | 472 |
| 814 | 473 if (c == '\\' && !non_ascii_p) |
| 428 | 474 { |
| 442 | 475 MDGET; |
| 428 | 476 if (c == '\n') |
| 477 { | |
| 442 | 478 MDGET; |
| 428 | 479 start = 1; |
| 480 continue; | |
| 481 } | |
| 482 if (!c_docstring && c == 'n') | |
| 483 c = '\n'; | |
| 484 if (c == 't') | |
| 485 c = '\t'; | |
| 486 } | |
| 930 | 487 |
| 488 /* XEmacs change: the "if" clause is new; the "else" clause is | |
| 489 mostly the original FSF Emacs code */ | |
| 428 | 490 if (c == '\n') |
| 491 start = 1; | |
| 492 else | |
| 493 { | |
| 494 start = 0; | |
| 442 | 495 if (printflag > 0) |
| 496 { | |
| 814 | 497 if (ellcc && c == '"' && !non_ascii_p) |
| 442 | 498 putc ('\\', outfile); |
| 499 putc (c, outfile); | |
| 500 } | |
| 428 | 501 else if (printflag < 0) |
| 502 *p++ = c; | |
| 503 } | |
| 442 | 504 MDGET; |
| 428 | 505 } |
| 930 | 506 /* XEmacs change: look for continuation of string */ |
| 428 | 507 if (Current_file_type == c_file) |
| 508 { | |
| 442 | 509 do |
| 510 { | |
| 511 MDGET; | |
| 512 } | |
| 513 while (isspace (c)); | |
| 814 | 514 if (c != '"' || non_ascii_p) |
| 428 | 515 break; |
| 516 } | |
| 517 else | |
| 518 { | |
| 442 | 519 MDGET; |
| 814 | 520 if (c != '"' || non_ascii_p) |
| 428 | 521 break; |
| 522 /* If we had a "", concatenate the two strings. */ | |
| 523 } | |
| 442 | 524 MDGET; |
| 428 | 525 } |
| 930 | 526 |
| 428 | 527 if (printflag < 0) |
| 528 *p = 0; | |
| 930 | 529 |
| 428 | 530 return c; |
| 531 } | |
| 532 | |
| 533 /* Write to file OUT the argument names of function FUNC, whose text is in BUF. | |
| 534 MINARGS and MAXARGS are the minimum and maximum number of arguments. */ | |
| 535 | |
|
4665
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
536 #define SKIPWHITE do { while (isspace ((unsigned char) (*p))) p++; } while (0) |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
537 |
| 428 | 538 static void |
| 2286 | 539 write_c_args (FILE *out, const char *UNUSED (func), char *buf, |
| 540 int minargs, int maxargs) | |
| 428 | 541 { |
| 542 register char *p; | |
| 543 int in_ident = 0; | |
| 544 int just_spaced = 0; | |
|
4665
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
545 int need_paren = 0; |
| 428 | 546 #if 0 |
| 547 int need_space = 1; | |
| 548 | |
| 549 fprintf (out, "(%s", func); | |
| 550 #else | |
| 551 /* XEmacs - "arguments:" is for parsing the docstring. FSF's help system | |
| 552 doesn't parse the docstring for arguments like we do, so we're also | |
| 553 going to omit the function name to preserve compatibility with elisp | |
| 554 that parses the docstring. Finally, not prefixing the arglist with | |
| 555 anything is asking for trouble because it's not uncommon to have an | |
| 556 unescaped parenthesis at the beginning of a line. --Stig */ | |
| 557 fprintf (out, "arguments: ("); | |
| 558 #endif | |
| 559 | |
| 930 | 560 if (*buf == '(') |
| 561 ++buf; | |
| 428 | 562 |
| 930 | 563 for (p = buf; *p; p++) |
| 428 | 564 { |
| 565 char c = *p; | |
|
4665
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
566 #if 0 |
| 428 | 567 int ident_start = 0; |
|
4665
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
568 #endif |
| 428 | 569 |
|
4665
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
570 /* XEmacs addition: used for ANSI prototypes and UNUSED macros. */ |
| 2603 | 571 static char uu [] = "UNUSED"; |
| 572 static char ui [] = "USED_IF_"; | |
|
4665
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
573 static char lo [] = "Lisp_Object"; |
| 428 | 574 |
|
4665
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
575 /* Notice when we enter or leave an identifier. */ |
| 428 | 576 if (C_IDENTIFIER_CHAR_P (c) != in_ident) |
| 577 { | |
| 578 if (!in_ident) | |
| 579 { | |
|
4665
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
580 /* Entering identifier. Print as we parse. */ |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
581 char *here; /* Target for backtracking. */ |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
582 |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
583 /* XEmacs addition: add support for ANSI prototypes and the |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
584 UNUSED macros. Hop over them. "Lisp_Object" is the only |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
585 C type allowed in DEFUNs. For the UNUSED macros we need |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
586 to eat parens, too. */ |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
587 /* Aren't these all vulnerable to buffer overrun? I guess that |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
588 means that the .c is busted, so we may as well just die ... */ |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
589 |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
590 /* Skip over "Lisp_Object". */ |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
591 if ((strncmp (p, lo, sizeof (lo) - 1) == 0) && |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
592 isspace ((unsigned char) p[sizeof (lo) - 1])) |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
593 { |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
594 p += (sizeof (lo) - 1); |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
595 SKIPWHITE; |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
596 } |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
597 /* Skip over "UNUSED" or "USED_IF_*" invocation. */ |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
598 need_paren = 1; |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
599 here = p; |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
600 if (strncmp (p, uu, sizeof (uu) - 1) == 0) |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
601 p += (sizeof (uu) - 1); |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
602 else if (strncmp (p, ui, sizeof (ui) - 1) == 0) |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
603 p += (sizeof (ui) - 1); |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
604 else |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
605 need_paren = 0; |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
606 |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
607 if (need_paren) |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
608 { |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
609 /* Skip rest of macro name, open paren, whitespace. */ |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
610 while (*p && C_IDENTIFIER_CHAR_P (*p)) |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
611 p++; |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
612 SKIPWHITE; |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
613 if (*p++ == '(') |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
614 SKIPWHITE; |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
615 else |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
616 { |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
617 need_paren = 0; |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
618 p = here; |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
619 } |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
620 } |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
621 c = *p; |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
622 |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
623 /* Do bookkeeping. Maybe output lambda keywords. */ |
| 428 | 624 in_ident = 1; |
| 625 #if 0 | |
| 626 /* XEmacs - This goes along with the change above. */ | |
|
4665
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
627 ident_start = 1; |
| 428 | 628 if (need_space) |
| 629 putc (' ', out); | |
| 630 #endif | |
| 631 if (minargs == 0 && maxargs > 0) | |
| 632 fprintf (out, "&optional "); | |
| 633 just_spaced = 1; | |
| 634 | |
| 635 minargs--; | |
| 636 maxargs--; | |
| 637 } | |
| 638 else | |
|
4665
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
639 { |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
640 /* Leaving identifier. */ |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
641 in_ident = 0; |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
642 if (need_paren) |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
643 { |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
644 SKIPWHITE; |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
645 if (*p == ')') |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
646 p++; |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
647 c = *p; |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
648 need_paren = 0; |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
649 } |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
650 } |
| 428 | 651 } |
| 652 | |
| 653 /* Print the C argument list as it would appear in lisp: | |
| 930 | 654 print underscores as hyphens, and print commas and newlines |
| 655 as spaces. Collapse adjacent spaces into one. */ | |
| 656 if (c == '_') | |
| 657 c = '-'; | |
| 1618 | 658 else if (c == ',' /* || c == '\n' */) |
| 930 | 659 c = ' '; |
| 1618 | 660 /* XEmacs change: handle \n below for readability */ |
| 428 | 661 |
| 930 | 662 #if 0 |
| 663 /* In C code, `default' is a reserved word, so we spell it | |
| 664 `defalt'; unmangle that here. */ | |
| 665 if (ident_start | |
| 666 && strncmp (p, "defalt", 6) == 0 | |
| 667 && ! (('A' <= p[6] && p[6] <= 'Z') | |
| 668 || ('a' <= p[6] && p[6] <= 'z') | |
| 669 || ('0' <= p[6] && p[6] <= '9') | |
| 670 || p[6] == '_')) | |
| 671 { | |
| 672 fprintf (out, "DEFAULT"); | |
| 673 p += 5; | |
| 674 in_ident = 0; | |
| 675 just_spaced = 0; | |
| 676 } | |
| 677 #endif | |
| 428 | 678 /* If the C argument name ends with `_', change it to ' ', |
| 679 to allow use of C reserved words or global symbols as Lisp args. */ | |
| 680 if (c == '-' && ! C_IDENTIFIER_CHAR_P (p[1])) | |
| 681 { | |
| 682 in_ident = 0; | |
| 683 just_spaced = 0; | |
| 684 } | |
| 1618 | 685 /* XEmacs change: if the character is carriage return or linefeed, |
| 686 escape it for the compiler */ | |
| 687 else if (c == '\n') | |
| 688 { | |
| 689 putc('\\', out); | |
| 690 putc('\n', out); | |
| 691 } | |
| 692 else if (c == '\r') | |
| 693 { | |
| 694 putc('\\', out); | |
| 695 putc('\r', out); | |
| 696 } | |
| 930 | 697 else if (c != ' ' || !just_spaced) |
| 428 | 698 { |
| 699 if (c >= 'a' && c <= 'z') | |
| 700 /* Upcase the letter. */ | |
| 701 c += 'A' - 'a'; | |
| 702 putc (c, out); | |
| 703 } | |
| 704 | |
| 705 just_spaced = (c == ' '); | |
| 706 #if 0 | |
| 707 need_space = 0; | |
| 708 #endif | |
| 709 } | |
| 930 | 710 /* XEmacs addition */ |
| 428 | 711 if (!ellcc) |
| 930 | 712 putc ('\n', out); |
| 428 | 713 } |
|
4665
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
714 #undef SKIPWHITE |
|
f3a65dff1912
Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4539
diff
changeset
|
715 |
| 428 | 716 |
| 771 | 717 /* Read through a c file. If a .o or .obj file is named, |
| 428 | 718 the corresponding .c file is read instead. |
| 719 Looks for DEFUN constructs such as are defined in ../src/lisp.h. | |
| 930 | 720 Accepts any word starting DEF... so it finds DEFSIMPLE and DEFPRED ... |
| 721 which don't exist anymore! */ | |
| 428 | 722 |
| 723 static int | |
| 442 | 724 scan_c_file (const char *filename, const char *mode) |
| 428 | 725 { |
| 726 FILE *infile; | |
| 727 register int c; | |
| 728 register int commas; | |
| 729 register int defunflag; | |
| 730 register int defvarperbufferflag = 0; | |
| 731 register int defvarflag; | |
| 732 int minargs, maxargs; | |
| 733 int l = strlen (filename); | |
| 2421 | 734 char f[QXE_PATH_MAX]; |
| 428 | 735 |
| 930 | 736 /* XEmacs change: different method for checking filename extension */ |
| 2421 | 737 if (l > QXE_PATH_MAX - 1) |
| 647 | 738 { |
| 428 | 739 #ifdef ENAMETOOLONG |
| 647 | 740 errno = ENAMETOOLONG; |
| 428 | 741 #else |
| 647 | 742 errno = EINVAL; |
| 428 | 743 #endif |
| 930 | 744 return 0; |
| 647 | 745 } |
| 428 | 746 |
| 747 strcpy (f, filename); | |
| 771 | 748 if (l > 4 && !strcmp (f + l - 4, ".obj")) /* MS Windows */ |
| 749 strcpy (f + l - 4, ".c"); | |
| 428 | 750 if (f[l - 1] == 'o') |
| 751 f[l - 1] = 'c'; | |
| 752 infile = fopen (f, mode); | |
| 753 | |
| 754 /* No error if non-ex input file */ | |
| 755 if (infile == NULL) | |
| 756 { | |
| 757 perror (f); | |
| 758 return 0; | |
| 759 } | |
| 760 | |
| 930 | 761 #if 0 |
| 762 /* Reset extension to be able to detect duplicate files. */ | |
| 763 filename[strlen (filename) - 1] = extension; | |
| 764 #endif | |
| 765 | |
| 428 | 766 c = '\n'; |
| 767 while (!feof (infile)) | |
| 768 { | |
| 769 if (c != '\n') | |
| 770 { | |
| 771 c = getc (infile); | |
| 772 continue; | |
| 773 } | |
| 774 c = getc (infile); | |
| 775 if (c == ' ') | |
| 776 { | |
| 777 while (c == ' ') | |
| 778 c = getc (infile); | |
| 779 if (c != 'D') | |
| 780 continue; | |
| 781 c = getc (infile); | |
| 782 if (c != 'E') | |
| 783 continue; | |
| 784 c = getc (infile); | |
| 785 if (c != 'F') | |
| 786 continue; | |
| 787 c = getc (infile); | |
| 788 if (c != 'V') | |
| 789 continue; | |
| 790 c = getc (infile); | |
| 791 if (c != 'A') | |
| 792 continue; | |
| 793 c = getc (infile); | |
| 794 if (c != 'R') | |
| 795 continue; | |
| 796 c = getc (infile); | |
| 797 if (c != '_') | |
| 798 continue; | |
| 799 | |
| 800 defvarflag = 1; | |
| 801 defunflag = 0; | |
| 802 | |
| 803 c = getc (infile); | |
| 804 /* Note that this business doesn't apply under XEmacs. | |
| 805 DEFVAR_BUFFER_LOCAL in XEmacs behaves normally. */ | |
| 806 defvarperbufferflag = (c == 'P'); | |
| 807 | |
| 808 c = getc (infile); | |
| 809 } | |
| 810 else if (c == 'D') | |
| 811 { | |
| 812 c = getc (infile); | |
| 813 if (c != 'E') | |
| 814 continue; | |
| 815 c = getc (infile); | |
| 816 if (c != 'F') | |
| 817 continue; | |
| 818 c = getc (infile); | |
| 819 defunflag = (c == 'U'); | |
| 820 defvarflag = 0; | |
| 930 | 821 c = getc (infile); /* XEmacs addition */ |
| 428 | 822 } |
| 823 else continue; | |
| 824 | |
| 825 while (c != '(') | |
| 826 { | |
| 827 if (c < 0) | |
| 828 goto eof; | |
| 829 c = getc (infile); | |
| 830 } | |
| 831 | |
| 832 c = getc (infile); | |
| 833 if (c != '"') | |
| 834 continue; | |
| 835 c = read_c_string (infile, -1, 0); | |
| 836 | |
| 837 if (defunflag) | |
| 838 commas = 4; | |
| 839 else if (defvarperbufferflag) | |
| 840 commas = 2; | |
| 841 else if (defvarflag) | |
| 842 commas = 1; | |
| 930 | 843 else /* For DEFSIMPLE and DEFPRED ... which now don't exist! */ |
| 428 | 844 commas = 2; |
| 845 | |
| 846 while (commas) | |
| 847 { | |
| 848 if (c == ',') | |
| 849 { | |
| 850 commas--; | |
| 851 if (defunflag && (commas == 1 || commas == 2)) | |
| 852 { | |
| 853 do | |
| 854 c = getc (infile); | |
| 930 | 855 while (c == ' ' || c == '\n' || c == '\t'); |
| 428 | 856 if (c < 0) |
| 857 goto eof; | |
| 858 ungetc (c, infile); | |
| 859 if (commas == 2) /* pick up minargs */ | |
| 860 fscanf (infile, "%d", &minargs); | |
| 930 | 861 else /* pick up maxargs */ |
| 428 | 862 if (c == 'M' || c == 'U') /* MANY || UNEVALLED */ |
| 863 maxargs = -1; | |
| 864 else | |
| 865 fscanf (infile, "%d", &maxargs); | |
| 866 } | |
| 867 } | |
| 868 if (c < 0) | |
| 869 goto eof; | |
| 870 c = getc (infile); | |
| 871 } | |
| 872 while (c == ' ' || c == '\n' || c == '\t') | |
| 873 c = getc (infile); | |
| 874 if (c == '"') | |
| 875 c = read_c_string (infile, 0, 0); | |
| 930 | 876 /* XEmacs change */ |
| 428 | 877 if (defunflag | defvarflag) |
| 878 { | |
| 879 while (c != '/') | |
| 853 | 880 { |
| 881 if (c < 0) | |
| 882 goto eof; | |
| 930 | 883 if (defunflag && c == '(') |
| 1111 | 884 fatal ("Missing doc string for DEFUN %s\n", globalbuf); |
| 853 | 885 c = getc (infile); |
| 886 } | |
| 428 | 887 c = getc (infile); |
| 888 while (c == '*') | |
| 889 c = getc (infile); | |
| 890 } | |
| 891 else | |
| 892 { | |
| 893 while (c != ',') | |
| 853 | 894 { |
| 895 if (c < 0) | |
| 896 goto eof; | |
| 897 c = getc (infile); | |
| 898 } | |
| 428 | 899 c = getc (infile); |
| 900 } | |
| 930 | 901 /* End XEmacs change */ |
| 428 | 902 while (c == ' ' || c == '\n' || c == '\t') |
| 903 c = getc (infile); | |
| 930 | 904 /* XEmacs addition */ |
| 428 | 905 if (defunflag | defvarflag) |
| 906 ungetc (c, infile); | |
| 930 | 907 /* End XEmacs addition */ |
| 428 | 908 |
| 909 if (defunflag || defvarflag || c == '"') | |
| 910 { | |
| 930 | 911 /* XEmacs change: the original code is in the "else" clause */ |
| 3368 | 912 /* XXX Must modify the documentation file name code to handle |
| 913 ELLCCs */ | |
| 814 | 914 if (ellcc) |
| 915 fprintf (outfile, " CDOC%s(\"%s\", \"\\\n", | |
| 1111 | 916 defvarflag ? "SYM" : "SUBR", globalbuf); |
| 814 | 917 else |
| 918 { | |
| 3368 | 919 put_filename (filename); /* XEmacs addition */ |
| 814 | 920 putc (037, outfile); |
| 921 putc (defvarflag ? 'V' : 'F', outfile); | |
| 1111 | 922 fprintf (outfile, "%s\n", globalbuf); |
| 814 | 923 } |
| 930 | 924 c = read_c_string (infile, 1, defunflag || defvarflag); |
| 428 | 925 |
| 926 /* If this is a defun, find the arguments and print them. If | |
| 927 this function takes MANY or UNEVALLED args, then the C source | |
| 928 won't give the names of the arguments, so we shouldn't bother | |
| 929 trying to find them. */ | |
| 930 if (defunflag && maxargs != -1) | |
| 931 { | |
| 932 char argbuf[1024], *p = argbuf; | |
| 2603 | 933 int paren_level = 1; |
| 814 | 934 #if 0 /* For old DEFUN's only */ |
| 428 | 935 while (c != ')') |
| 936 { | |
| 937 if (c < 0) | |
| 938 goto eof; | |
| 939 c = getc (infile); | |
| 940 } | |
| 941 #endif | |
| 942 /* Skip into arguments. */ | |
| 943 while (c != '(') | |
| 944 { | |
| 945 if (c < 0) | |
| 946 goto eof; | |
| 947 c = getc (infile); | |
| 948 } | |
| 949 /* Copy arguments into ARGBUF. */ | |
| 950 *p++ = c; | |
| 951 do | |
| 853 | 952 { |
| 953 *p++ = c = getc (infile); | |
| 954 if (c < 0) | |
| 955 goto eof; | |
| 2603 | 956 /* XEmacs change: handle macros with args (eg, UNUSED) */ |
| 957 if (c == ')') | |
| 958 paren_level--; | |
| 959 if (c == '(') | |
| 960 paren_level++; | |
| 853 | 961 } |
| 2603 | 962 while (paren_level > 0); |
| 428 | 963 *p = '\0'; |
| 964 /* Output them. */ | |
| 814 | 965 if (ellcc) |
| 966 fprintf (outfile, "\\n\\\n\\n\\\n"); | |
| 967 else | |
| 968 fprintf (outfile, "\n\n"); | |
| 1111 | 969 write_c_args (outfile, globalbuf, argbuf, minargs, maxargs); |
| 428 | 970 } |
| 814 | 971 if (ellcc) |
| 972 fprintf (outfile, "\\n\");\n\n"); | |
| 428 | 973 } |
| 974 } | |
| 975 eof: | |
| 976 fclose (infile); | |
| 977 return 0; | |
| 978 } | |
| 979 | |
| 980 /* Read a file of Lisp code, compiled or interpreted. | |
| 930 | 981 Looks for |
| 982 (defun NAME ARGS DOCSTRING ...) | |
| 983 (defmacro NAME ARGS DOCSTRING ...) | |
| 984 (defsubst NAME ARGS DOCSTRING ...) | |
| 985 (autoload (quote NAME) FILE DOCSTRING ...) | |
| 986 (defvar NAME VALUE DOCSTRING) | |
| 987 (defconst NAME VALUE DOCSTRING) | |
| 988 (fset (quote NAME) (make-byte-code ... DOCSTRING ...)) | |
| 989 (fset (quote NAME) #[... DOCSTRING ...]) | |
| 990 (defalias (quote NAME) #[... DOCSTRING ...]) | |
| 991 (custom-declare-variable (quote NAME) VALUE DOCSTRING ...) | |
| 992 starting in column zero. | |
| 993 (quote NAME) may appear as 'NAME as well. | |
| 428 | 994 |
| 995 We also look for #@LENGTH CONTENTS^_ at the beginning of the line. | |
| 996 When we find that, we save it for the following defining-form, | |
| 997 and we use that instead of reading a doc string within that defining-form. | |
| 998 | |
| 930 | 999 For defvar, defconst, and fset we skip to the docstring with a kludgy |
| 428 | 1000 formatting convention: all docstrings must appear on the same line as the |
| 930 | 1001 initial open-paren (the one in column zero) and must contain a backslash |
| 1002 and a newline immediately after the initial double-quote. No newlines | |
| 428 | 1003 must appear between the beginning of the form and the first double-quote. |
| 930 | 1004 For defun, defmacro, and autoload, we know how to skip over the |
| 1005 arglist, but the doc string must still have a backslash and newline | |
| 1006 immediately after the double quote. | |
| 1007 The only source files that must follow this convention are preloaded | |
| 1008 uncompiled ones like loaddefs.el and bindings.el; aside | |
| 428 | 1009 from that, it is always the .elc file that we look at, and they are no |
| 1010 problem because byte-compiler output follows this convention. | |
| 1011 The NAME and DOCSTRING are output. | |
| 1012 NAME is preceded by `F' for a function or `V' for a variable. | |
| 1013 An entry is output only if DOCSTRING has \ newline just after the opening " | |
| 3368 | 1014 |
| 1015 Adds the filename a symbol or function was found in before its docstring; | |
| 1016 there's no need for this with the load-history available, but we do it for | |
| 1017 consistency with the C parsing code. | |
| 428 | 1018 */ |
| 1019 | |
| 1020 static void | |
| 1021 skip_white (FILE *infile) | |
| 1022 { | |
| 1023 char c = ' '; | |
| 1024 while (c == ' ' || c == '\t' || c == '\n') | |
| 1025 c = getc (infile); | |
| 1026 ungetc (c, infile); | |
| 1027 } | |
| 1028 | |
| 1029 static void | |
| 1030 read_lisp_symbol (FILE *infile, char *buffer) | |
| 1031 { | |
| 1032 char c; | |
| 1033 char *fillp = buffer; | |
| 1034 | |
| 1035 skip_white (infile); | |
| 1036 while (1) | |
| 1037 { | |
| 1038 c = getc (infile); | |
| 1039 if (c == '\\') | |
| 1040 /* FSF has *(++fillp), which is wrong. */ | |
| 1041 *fillp++ = getc (infile); | |
| 1042 else if (c == ' ' || c == '\t' || c == '\n' || c == '(' || c == ')') | |
| 1043 { | |
| 1044 ungetc (c, infile); | |
| 1045 *fillp = 0; | |
| 1046 break; | |
| 1047 } | |
| 1048 else | |
| 1049 *fillp++ = c; | |
| 1050 } | |
| 1051 | |
| 1052 if (! buffer[0]) | |
| 1053 fprintf (stderr, "## expected a symbol, got '%c'\n", c); | |
| 814 | 1054 |
| 428 | 1055 skip_white (infile); |
| 1056 } | |
| 1057 | |
| 1058 static int | |
| 442 | 1059 scan_lisp_file (const char *filename, const char *mode) |
| 428 | 1060 { |
| 1061 FILE *infile; | |
| 1062 register int c; | |
| 1063 char *saved_string = 0; | |
| 1064 | |
| 1065 infile = fopen (filename, mode); | |
| 1066 if (infile == NULL) | |
| 1067 { | |
| 1068 perror (filename); | |
| 930 | 1069 return 0; /* No error */ |
| 428 | 1070 } |
| 1071 | |
| 1072 c = '\n'; | |
| 1073 while (!feof (infile)) | |
| 1074 { | |
| 1075 char buffer[BUFSIZ]; | |
| 1076 char type; | |
| 1077 | |
| 930 | 1078 /* If not at end of line, skip till we get to one. */ |
| 428 | 1079 if (c != '\n') |
| 1080 { | |
| 814 | 1081 c = getc_skipping_iso2022 (infile); |
| 428 | 1082 continue; |
| 1083 } | |
| 930 | 1084 /* Skip the line break. */ |
| 1085 while (c == '\n') | |
| 1086 c = getc_skipping_iso2022 (infile); | |
| 428 | 1087 /* Detect a dynamic doc string and save it for the next expression. */ |
| 1088 if (c == '#') | |
| 1089 { | |
| 814 | 1090 c = getc_skipping_iso2022 (infile); |
| 428 | 1091 if (c == '@') |
| 1092 { | |
| 1093 int length = 0; | |
| 1094 int i; | |
| 1095 | |
| 1096 /* Read the length. */ | |
| 814 | 1097 while ((c = getc_skipping_iso2022 (infile), |
| 428 | 1098 c >= '0' && c <= '9')) |
| 1099 { | |
| 1100 length *= 10; | |
| 1101 length += c - '0'; | |
| 1102 } | |
| 1103 | |
| 1104 /* The next character is a space that is counted in the length | |
| 1105 but not part of the doc string. | |
| 1106 We already read it, so just ignore it. */ | |
| 1107 length--; | |
| 1108 | |
| 1109 /* Read in the contents. */ | |
| 1110 if (saved_string != 0) | |
| 1111 free (saved_string); | |
| 1112 saved_string = (char *) xmalloc (length); | |
| 1113 for (i = 0; i < length; i++) | |
| 1114 saved_string[i] = getc (infile); | |
| 1115 /* The last character is a ^_. | |
| 1116 That is needed in the .elc file | |
| 1117 but it is redundant in DOC. So get rid of it here. */ | |
| 1118 saved_string[length - 1] = 0; | |
| 930 | 1119 /* Skip the line break. */ |
| 1120 while (c == '\n') | |
| 1121 c = getc_skipping_iso2022 (infile); | |
| 1122 /* Skip the following line. */ | |
| 428 | 1123 while (c != '\n') |
| 930 | 1124 c = getc_skipping_iso2022 (infile); |
| 428 | 1125 } |
| 1126 continue; | |
| 1127 } | |
| 1128 | |
| 1129 if (c != '(') | |
| 1130 continue; | |
| 1131 | |
| 1132 read_lisp_symbol (infile, buffer); | |
| 1133 | |
| 930 | 1134 if (! strcmp (buffer, "defun") |
| 1135 || ! strcmp (buffer, "defmacro") | |
| 1136 || ! strcmp (buffer, "defsubst")) | |
| 428 | 1137 { |
| 1138 type = 'F'; | |
| 1139 read_lisp_symbol (infile, buffer); | |
| 1140 | |
| 1141 /* Skip the arguments: either "nil" or a list in parens */ | |
| 1142 | |
| 814 | 1143 c = getc_skipping_iso2022 (infile); |
| 930 | 1144 if (c == 'n') /* nil */ |
| 428 | 1145 { |
| 814 | 1146 if ((c = getc_skipping_iso2022 (infile)) != 'i' || |
| 1147 (c = getc_skipping_iso2022 (infile)) != 'l') | |
| 428 | 1148 { |
| 1149 fprintf (stderr, "## unparsable arglist in %s (%s)\n", | |
| 1150 buffer, filename); | |
| 1151 continue; | |
| 1152 } | |
| 1153 } | |
| 1154 else if (c != '(') | |
| 1155 { | |
| 1156 fprintf (stderr, "## unparsable arglist in %s (%s)\n", | |
| 1157 buffer, filename); | |
| 1158 continue; | |
| 1159 } | |
| 1160 else | |
| 1161 while (c != ')') | |
| 853 | 1162 { |
| 1163 c = getc_skipping_iso2022 (infile); | |
| 1164 if (c < 0) | |
| 1165 continue; | |
| 1166 } | |
| 428 | 1167 skip_white (infile); |
| 1168 | |
| 1169 /* If the next three characters aren't `dquote bslash newline' | |
| 1170 then we're not reading a docstring. | |
| 930 | 1171 */ |
| 814 | 1172 if ((c = getc_skipping_iso2022 (infile)) != '"' || |
| 1173 (c = getc_skipping_iso2022 (infile)) != '\\' || | |
| 1174 (c = getc_skipping_iso2022 (infile)) != '\n') | |
| 428 | 1175 { |
| 1176 #ifdef DEBUG | |
| 1177 fprintf (stderr, "## non-docstring in %s (%s)\n", | |
| 1178 buffer, filename); | |
| 1179 #endif | |
| 1180 continue; | |
| 1181 } | |
| 1182 } | |
| 1183 | |
| 930 | 1184 else if (! strcmp (buffer, "defvar") |
| 1185 || ! strcmp (buffer, "defconst")) | |
| 428 | 1186 { |
| 1187 char c1 = 0, c2 = 0; | |
| 1188 type = 'V'; | |
| 1189 read_lisp_symbol (infile, buffer); | |
| 1190 | |
| 1191 if (saved_string == 0) | |
| 1192 { | |
| 1193 | |
| 930 | 1194 /* Skip until the end of line; remember two previous chars. */ |
| 428 | 1195 while (c != '\n' && c >= 0) |
| 1196 { | |
| 1197 c2 = c1; | |
| 1198 c1 = c; | |
| 814 | 1199 c = getc_skipping_iso2022 (infile); |
| 428 | 1200 } |
| 930 | 1201 |
| 1202 /* If two previous characters were " and \, | |
| 1203 this is a doc string. Otherwise, there is none. */ | |
| 1204 if (c2 != '"' || c1 != '\\') | |
| 1205 { | |
| 1206 #ifdef DEBUG | |
| 1207 fprintf (stderr, "## non-docstring in %s (%s)\n", | |
| 1208 buffer, filename); | |
| 1209 #endif | |
| 1210 continue; | |
| 1211 } | |
| 1212 } | |
| 1213 } | |
| 428 | 1214 |
| 930 | 1215 else if (! strcmp (buffer, "custom-declare-variable")) |
| 1216 { | |
| 1217 char c1 = 0, c2 = 0; | |
| 1218 type = 'V'; | |
| 1219 | |
| 1220 c = getc (infile); | |
| 1221 if (c == '\'') | |
| 1222 read_lisp_symbol (infile, buffer); | |
| 1223 else | |
| 1224 { | |
| 1225 if (c != '(') | |
| 1226 { | |
| 1227 fprintf (stderr, | |
| 1228 "## unparsable name in custom-declare-variable in %s\n", | |
| 1229 filename); | |
| 1230 continue; | |
| 1231 } | |
| 1232 read_lisp_symbol (infile, buffer); | |
| 1233 if (strcmp (buffer, "quote")) | |
| 1234 { | |
| 1235 fprintf (stderr, | |
| 1236 "## unparsable name in custom-declare-variable in %s\n", | |
| 1237 filename); | |
| 1238 continue; | |
| 1239 } | |
| 1240 read_lisp_symbol (infile, buffer); | |
| 1241 c = getc (infile); | |
| 1242 if (c != ')') | |
| 1243 { | |
| 1244 fprintf (stderr, | |
| 1245 "## unparsable quoted name in custom-declare-variable in %s\n", | |
| 1246 filename); | |
| 1247 continue; | |
| 1248 } | |
| 1249 } | |
| 1250 | |
| 1251 if (saved_string == 0) | |
| 1252 { | |
| 1253 /* Skip to end of line; remember the two previous chars. */ | |
| 1254 while (c != '\n' && c >= 0) | |
| 1255 { | |
| 1256 c2 = c1; | |
| 1257 c1 = c; | |
| 1258 c = getc_skipping_iso2022 (infile); | |
| 1259 } | |
| 1260 | |
| 428 | 1261 /* If two previous characters were " and \, |
| 1262 this is a doc string. Otherwise, there is none. */ | |
| 1263 if (c2 != '"' || c1 != '\\') | |
| 1264 { | |
| 1265 #ifdef DEBUG | |
| 1266 fprintf (stderr, "## non-docstring in %s (%s)\n", | |
| 1267 buffer, filename); | |
| 1268 #endif | |
| 1269 continue; | |
| 1270 } | |
| 1271 } | |
| 1272 } | |
| 1273 | |
| 1274 else if (! strcmp (buffer, "fset") || ! strcmp (buffer, "defalias")) | |
| 1275 { | |
| 1276 char c1 = 0, c2 = 0; | |
| 1277 type = 'F'; | |
| 1278 | |
| 814 | 1279 c = getc_skipping_iso2022 (infile); |
| 428 | 1280 if (c == '\'') |
| 1281 read_lisp_symbol (infile, buffer); | |
| 1282 else | |
| 1283 { | |
| 1284 if (c != '(') | |
| 1285 { | |
| 1286 fprintf (stderr, "## unparsable name in fset in %s\n", | |
| 1287 filename); | |
| 1288 continue; | |
| 1289 } | |
| 1290 read_lisp_symbol (infile, buffer); | |
| 1291 if (strcmp (buffer, "quote")) | |
| 1292 { | |
| 1293 fprintf (stderr, "## unparsable name in fset in %s\n", | |
| 1294 filename); | |
| 1295 continue; | |
| 1296 } | |
| 1297 read_lisp_symbol (infile, buffer); | |
| 814 | 1298 c = getc_skipping_iso2022 (infile); |
| 428 | 1299 if (c != ')') |
| 1300 { | |
| 1301 fprintf (stderr, | |
| 1302 "## unparsable quoted name in fset in %s\n", | |
| 1303 filename); | |
| 1304 continue; | |
| 1305 } | |
| 1306 } | |
| 1307 | |
| 1308 if (saved_string == 0) | |
| 1309 { | |
| 930 | 1310 /* Skip to end of line; remember the two previous chars. */ |
| 428 | 1311 while (c != '\n' && c >= 0) |
| 1312 { | |
| 1313 c2 = c1; | |
| 1314 c1 = c; | |
| 814 | 1315 c = getc_skipping_iso2022 (infile); |
| 428 | 1316 } |
| 930 | 1317 |
| 428 | 1318 /* If two previous characters were " and \, |
| 1319 this is a doc string. Otherwise, there is none. */ | |
| 1320 if (c2 != '"' || c1 != '\\') | |
| 1321 { | |
| 1322 #ifdef DEBUG | |
| 1323 fprintf (stderr, "## non-docstring in %s (%s)\n", | |
| 1324 buffer, filename); | |
| 1325 #endif | |
| 1326 continue; | |
| 1327 } | |
| 1328 } | |
| 1329 } | |
| 1330 | |
| 1331 else if (! strcmp (buffer, "autoload")) | |
| 1332 { | |
| 1333 type = 'F'; | |
| 814 | 1334 c = getc_skipping_iso2022 (infile); |
| 428 | 1335 if (c == '\'') |
| 1336 read_lisp_symbol (infile, buffer); | |
| 1337 else | |
| 1338 { | |
| 1339 if (c != '(') | |
| 1340 { | |
| 1341 fprintf (stderr, "## unparsable name in autoload in %s\n", | |
| 1342 filename); | |
| 1343 continue; | |
| 1344 } | |
| 1345 read_lisp_symbol (infile, buffer); | |
| 1346 if (strcmp (buffer, "quote")) | |
| 1347 { | |
| 1348 fprintf (stderr, "## unparsable name in autoload in %s\n", | |
| 1349 filename); | |
| 1350 continue; | |
| 1351 } | |
| 1352 read_lisp_symbol (infile, buffer); | |
| 814 | 1353 c = getc_skipping_iso2022 (infile); |
| 428 | 1354 if (c != ')') |
| 1355 { | |
| 1356 fprintf (stderr, | |
| 1357 "## unparsable quoted name in autoload in %s\n", | |
| 1358 filename); | |
| 1359 continue; | |
| 1360 } | |
| 1361 } | |
| 1362 skip_white (infile); | |
| 814 | 1363 if ((c = getc_skipping_iso2022 (infile)) != '\"') |
| 428 | 1364 { |
| 1365 fprintf (stderr, "## autoload of %s unparsable (%s)\n", | |
| 1366 buffer, filename); | |
| 1367 continue; | |
| 1368 } | |
| 1369 read_c_string (infile, 0, 0); | |
| 1370 skip_white (infile); | |
| 1371 | |
| 1372 if (saved_string == 0) | |
| 1373 { | |
| 1374 /* If the next three characters aren't `dquote bslash newline' | |
| 1375 then we're not reading a docstring. */ | |
| 814 | 1376 if ((c = getc_skipping_iso2022 (infile)) != '"' || |
| 1377 (c = getc_skipping_iso2022 (infile)) != '\\' || | |
| 1378 (c = getc_skipping_iso2022 (infile)) != '\n') | |
| 428 | 1379 { |
| 1380 #ifdef DEBUG | |
| 1381 fprintf (stderr, "## non-docstring in %s (%s)\n", | |
| 1382 buffer, filename); | |
| 1383 #endif | |
| 1384 continue; | |
| 1385 } | |
| 1386 } | |
| 1387 } | |
| 1388 | |
| 814 | 1389 #if 0 /* causes crash */ |
| 930 | 1390 else if (! strcmp (buffer, "if") |
| 1391 || ! strcmp (buffer, "byte-code")) | |
| 428 | 1392 ; |
| 1393 #endif | |
| 1394 | |
| 1395 else | |
| 1396 { | |
| 1397 #ifdef DEBUG | |
| 1398 fprintf (stderr, "## unrecognized top-level form, %s (%s)\n", | |
| 1399 buffer, filename); | |
| 1400 #endif | |
| 1401 continue; | |
| 1402 } | |
| 1403 | |
| 1404 /* At this point, we should either use the previous | |
| 1405 dynamic doc string in saved_string | |
| 1406 or gobble a doc string from the input file. | |
| 930 | 1407 |
| 428 | 1408 In the latter case, the opening quote (and leading |
| 1409 backslash-newline) have already been read. */ | |
| 930 | 1410 |
| 3368 | 1411 put_filename (filename); /* XEmacs addition */ |
| 428 | 1412 putc (037, outfile); |
| 1413 putc (type, outfile); | |
| 1414 fprintf (outfile, "%s\n", buffer); | |
| 1415 if (saved_string) | |
| 1416 { | |
| 1417 fputs (saved_string, outfile); | |
| 1418 /* Don't use one dynamic doc string twice. */ | |
| 1419 free (saved_string); | |
| 1420 saved_string = 0; | |
| 1421 } | |
| 1422 else | |
| 1423 read_c_string (infile, 1, 0); | |
| 1424 } | |
| 1425 fclose (infile); | |
| 1426 return 0; | |
| 1427 } |
