diff options
Diffstat (limited to 'lib-src')
| -rw-r--r-- | lib-src/make-docfile.c | 115 |
1 files changed, 83 insertions, 32 deletions
diff --git a/lib-src/make-docfile.c b/lib-src/make-docfile.c index 793c5e4211a..9796db4ede0 100644 --- a/lib-src/make-docfile.c +++ b/lib-src/make-docfile.c | |||
| @@ -198,25 +198,32 @@ scan_file (filename) | |||
| 198 | 198 | ||
| 199 | char buf[128]; | 199 | char buf[128]; |
| 200 | 200 | ||
| 201 | /* Skip a C string from INFILE, | 201 | /* Skip a C string or C-style comment from INFILE, and return the |
| 202 | and return the character that follows the closing ". | 202 | character that follows. COMMENT non-zero means skip a comment. If |
| 203 | If printflag is positive, output string contents to outfile. | 203 | PRINTFLAG is positive, output string contents to outfile. If it is |
| 204 | If it is negative, store contents in buf. | 204 | negative, store contents in buf. Convert escape sequences \n and |
| 205 | Convert escape sequences \n and \t to newline and tab; | 205 | \t to newline and tab; discard \ followed by newline. */ |
| 206 | discard \ followed by newline. */ | ||
| 207 | 206 | ||
| 208 | int | 207 | int |
| 209 | read_c_string (infile, printflag) | 208 | read_c_string_or_comment (infile, printflag, comment) |
| 210 | FILE *infile; | 209 | FILE *infile; |
| 211 | int printflag; | 210 | int printflag; |
| 212 | { | 211 | { |
| 213 | register int c; | 212 | register int c; |
| 214 | char *p = buf; | 213 | char *p = buf; |
| 215 | 214 | ||
| 216 | c = getc (infile); | 215 | if (comment) |
| 216 | { | ||
| 217 | while ((c = getc (infile)) != EOF | ||
| 218 | && (c == '\n' || c == '\r' || c == '\t' || c == ' ')) | ||
| 219 | ; | ||
| 220 | } | ||
| 221 | else | ||
| 222 | c = getc (infile); | ||
| 223 | |||
| 217 | while (c != EOF) | 224 | while (c != EOF) |
| 218 | { | 225 | { |
| 219 | while (c != '"' && c != EOF) | 226 | while (c != EOF && (comment ? c != '*' : c != '"')) |
| 220 | { | 227 | { |
| 221 | if (c == '\\') | 228 | if (c == '\\') |
| 222 | { | 229 | { |
| @@ -231,24 +238,41 @@ read_c_string (infile, printflag) | |||
| 231 | if (c == 't') | 238 | if (c == 't') |
| 232 | c = '\t'; | 239 | c = '\t'; |
| 233 | } | 240 | } |
| 241 | |||
| 234 | if (printflag > 0) | 242 | if (printflag > 0) |
| 235 | putc (c, outfile); | 243 | putc (c, outfile); |
| 236 | else if (printflag < 0) | 244 | else if (printflag < 0) |
| 237 | *p++ = c; | 245 | *p++ = c; |
| 238 | c = getc (infile); | 246 | c = getc (infile); |
| 239 | } | 247 | } |
| 248 | |||
| 240 | c = getc (infile); | 249 | c = getc (infile); |
| 241 | if (c != '"') | ||
| 242 | break; | ||
| 243 | /* If we had a "", concatenate the two strings. */ | ||
| 244 | c = getc (infile); | ||
| 245 | } | ||
| 246 | 250 | ||
| 251 | if (comment) | ||
| 252 | { | ||
| 253 | if (c == '/') | ||
| 254 | { | ||
| 255 | c = getc (infile); | ||
| 256 | break; | ||
| 257 | } | ||
| 258 | } | ||
| 259 | else | ||
| 260 | { | ||
| 261 | if (c != '"') | ||
| 262 | break; | ||
| 263 | |||
| 264 | /* If we had a "", concatenate the two strings. */ | ||
| 265 | c = getc (infile); | ||
| 266 | } | ||
| 267 | } | ||
| 268 | |||
| 247 | if (printflag < 0) | 269 | if (printflag < 0) |
| 248 | *p = 0; | 270 | *p = 0; |
| 249 | 271 | ||
| 250 | return c; | 272 | return c; |
| 251 | } | 273 | } |
| 274 | |||
| 275 | |||
| 252 | 276 | ||
| 253 | /* Write to file OUT the argument names of function FUNC, whose text is in BUF. | 277 | /* Write to file OUT the argument names of function FUNC, whose text is in BUF. |
| 254 | MINARGS and MAXARGS are the minimum and maximum number of arguments. */ | 278 | MINARGS and MAXARGS are the minimum and maximum number of arguments. */ |
| @@ -431,10 +455,14 @@ scan_c_file (filename, mode) | |||
| 431 | c = getc (infile); | 455 | c = getc (infile); |
| 432 | } | 456 | } |
| 433 | 457 | ||
| 458 | /* Lisp variable or function name. */ | ||
| 434 | c = getc (infile); | 459 | c = getc (infile); |
| 435 | if (c != '"') | 460 | if (c != '"') |
| 436 | continue; | 461 | continue; |
| 437 | c = read_c_string (infile, -1); | 462 | c = read_c_string_or_comment (infile, -1, 0); |
| 463 | |||
| 464 | /* DEFVAR_LISP ("name", addr /\* doc *\/) | ||
| 465 | DEFVAR_LISP ("name", addr, doc) */ | ||
| 438 | 466 | ||
| 439 | if (defunflag) | 467 | if (defunflag) |
| 440 | commas = 5; | 468 | commas = 5; |
| @@ -450,6 +478,7 @@ scan_c_file (filename, mode) | |||
| 450 | if (c == ',') | 478 | if (c == ',') |
| 451 | { | 479 | { |
| 452 | commas--; | 480 | commas--; |
| 481 | |||
| 453 | if (defunflag && (commas == 1 || commas == 2)) | 482 | if (defunflag && (commas == 1 || commas == 2)) |
| 454 | { | 483 | { |
| 455 | do | 484 | do |
| @@ -467,40 +496,62 @@ scan_c_file (filename, mode) | |||
| 467 | fscanf (infile, "%d", &maxargs); | 496 | fscanf (infile, "%d", &maxargs); |
| 468 | } | 497 | } |
| 469 | } | 498 | } |
| 470 | if (c < 0) | 499 | |
| 500 | if (c == EOF) | ||
| 471 | goto eof; | 501 | goto eof; |
| 472 | c = getc (infile); | 502 | c = getc (infile); |
| 473 | } | 503 | } |
| 504 | |||
| 474 | while (c == ' ' || c == '\n' || c == '\r' || c == '\t') | 505 | while (c == ' ' || c == '\n' || c == '\r' || c == '\t') |
| 475 | c = getc (infile); | 506 | c = getc (infile); |
| 507 | |||
| 476 | if (c == '"') | 508 | if (c == '"') |
| 477 | c = read_c_string (infile, 0); | 509 | c = read_c_string_or_comment (infile, 0, 0); |
| 478 | while (c != ',') | 510 | |
| 479 | c = getc (infile); | 511 | while (c != EOF && c != ',' && c != '/') |
| 480 | c = getc (infile); | ||
| 481 | while (c == ' ' || c == '\n' || c == '\r' || c == '\t') | ||
| 482 | c = getc (infile); | 512 | c = getc (infile); |
| 513 | if (c == ',') | ||
| 514 | { | ||
| 515 | c = getc (infile); | ||
| 516 | while (c == ' ' || c == '\n' || c == '\r' || c == '\t') | ||
| 517 | c = getc (infile); | ||
| 518 | } | ||
| 483 | 519 | ||
| 484 | if (c == '"') | 520 | if (c == '"' |
| 521 | || (c == '/' | ||
| 522 | && (c = getc (infile), | ||
| 523 | ungetc (c, infile), | ||
| 524 | c == '*'))) | ||
| 485 | { | 525 | { |
| 526 | int comment = c != '"'; | ||
| 527 | |||
| 486 | putc (037, outfile); | 528 | putc (037, outfile); |
| 487 | putc (defvarflag ? 'V' : 'F', outfile); | 529 | putc (defvarflag ? 'V' : 'F', outfile); |
| 488 | fprintf (outfile, "%s\n", buf); | 530 | fprintf (outfile, "%s\n", buf); |
| 489 | c = read_c_string (infile, 1); | 531 | |
| 532 | if (comment) | ||
| 533 | getc (infile); /* Skip past `*' */ | ||
| 534 | c = read_c_string_or_comment (infile, 1, comment); | ||
| 490 | 535 | ||
| 491 | /* If this is a defun, find the arguments and print them. If | 536 | /* If this is a defun, find the arguments and print them. If |
| 492 | this function takes MANY or UNEVALLED args, then the C source | 537 | this function takes MANY or UNEVALLED args, then the C source |
| 493 | won't give the names of the arguments, so we shouldn't bother | 538 | won't give the names of the arguments, so we shouldn't bother |
| 494 | trying to find them. */ | 539 | trying to find them. |
| 540 | |||
| 541 | Old: DEFUN (..., "DOC") (args) | ||
| 542 | New: DEFUN (..., /\* DOC *\/ (args)) */ | ||
| 495 | if (defunflag && maxargs != -1) | 543 | if (defunflag && maxargs != -1) |
| 496 | { | 544 | { |
| 497 | char argbuf[1024], *p = argbuf; | 545 | char argbuf[1024], *p = argbuf; |
| 498 | while (c != ')') | 546 | |
| 499 | { | 547 | if (!comment) |
| 500 | if (c < 0) | 548 | while (c != ')') |
| 501 | goto eof; | 549 | { |
| 502 | c = getc (infile); | 550 | if (c < 0) |
| 503 | } | 551 | goto eof; |
| 552 | c = getc (infile); | ||
| 553 | } | ||
| 554 | |||
| 504 | /* Skip into arguments. */ | 555 | /* Skip into arguments. */ |
| 505 | while (c != '(') | 556 | while (c != '(') |
| 506 | { | 557 | { |
| @@ -909,7 +960,7 @@ scan_lisp_file (filename, mode) | |||
| 909 | buffer, filename); | 960 | buffer, filename); |
| 910 | continue; | 961 | continue; |
| 911 | } | 962 | } |
| 912 | read_c_string (infile, 0); | 963 | read_c_string_or_comment (infile, 0, 0); |
| 913 | skip_white (infile); | 964 | skip_white (infile); |
| 914 | 965 | ||
| 915 | if (saved_string == 0) | 966 | if (saved_string == 0) |
| @@ -962,7 +1013,7 @@ scan_lisp_file (filename, mode) | |||
| 962 | saved_string = 0; | 1013 | saved_string = 0; |
| 963 | } | 1014 | } |
| 964 | else | 1015 | else |
| 965 | read_c_string (infile, 1); | 1016 | read_c_string_or_comment (infile, 1, 0); |
| 966 | } | 1017 | } |
| 967 | fclose (infile); | 1018 | fclose (infile); |
| 968 | return 0; | 1019 | return 0; |