diff options
Diffstat (limited to 'lib-src')
| -rw-r--r-- | lib-src/ChangeLog | 4 | ||||
| -rw-r--r-- | lib-src/make-docfile.c | 103 |
2 files changed, 45 insertions, 62 deletions
diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog index 4cbf5dd50f1..9477811fe3c 100644 --- a/lib-src/ChangeLog +++ b/lib-src/ChangeLog | |||
| @@ -1,3 +1,7 @@ | |||
| 1 | 2010-07-09 Andreas Schwab <schwab@linux-m68k.org> | ||
| 2 | |||
| 3 | * make-docfile.c (write_c_args): Restructure scanning loop. | ||
| 4 | |||
| 1 | 2010-07-09 Dan Nicolaescu <dann@ics.uci.edu> | 5 | 2010-07-09 Dan Nicolaescu <dann@ics.uci.edu> |
| 2 | 6 | ||
| 3 | * make-docfile.c (write_c_args): Deal with type names in DEFUN | 7 | * make-docfile.c (write_c_args): Deal with type names in DEFUN |
diff --git a/lib-src/make-docfile.c b/lib-src/make-docfile.c index 3df7ec607d9..51c30f91d8f 100644 --- a/lib-src/make-docfile.c +++ b/lib-src/make-docfile.c | |||
| @@ -440,8 +440,8 @@ write_c_args (FILE *out, char *func, char *buf, int minargs, int maxargs) | |||
| 440 | { | 440 | { |
| 441 | register char *p; | 441 | register char *p; |
| 442 | int in_ident = 0; | 442 | int in_ident = 0; |
| 443 | int just_spaced = 0; | 443 | char *ident_start; |
| 444 | int need_space = 1; | 444 | int ident_length; |
| 445 | 445 | ||
| 446 | fprintf (out, "(fn"); | 446 | fprintf (out, "(fn"); |
| 447 | 447 | ||
| @@ -450,25 +450,9 @@ write_c_args (FILE *out, char *func, char *buf, int minargs, int maxargs) | |||
| 450 | 450 | ||
| 451 | for (p = buf; *p; p++) | 451 | for (p = buf; *p; p++) |
| 452 | { | 452 | { |
| 453 | char c; | 453 | char c = *p; |
| 454 | int ident_start = 0; | ||
| 455 | 454 | ||
| 456 | /* FIXME: this must be made a bit more robust*/ | 455 | /* Notice when a new identifier starts. */ |
| 457 | |||
| 458 | /* Skip "register Lisp_Object", this can be removed when we get | ||
| 459 | rid of "register" for DEFUNs. */ | ||
| 460 | if (strncmp ("register Lisp_Object", p, 20) == 0) | ||
| 461 | p += 20; | ||
| 462 | |||
| 463 | if (strncmp ("Lisp_Object", p, 11) == 0) | ||
| 464 | p += 11; | ||
| 465 | |||
| 466 | if (strncmp ("void", p, 4) == 0) | ||
| 467 | p += 4; | ||
| 468 | |||
| 469 | c = *p; | ||
| 470 | |||
| 471 | /* Notice when we start printing a new identifier. */ | ||
| 472 | if ((('A' <= c && c <= 'Z') | 456 | if ((('A' <= c && c <= 'Z') |
| 473 | || ('a' <= c && c <= 'z') | 457 | || ('a' <= c && c <= 'z') |
| 474 | || ('0' <= c && c <= '9') | 458 | || ('0' <= c && c <= '9') |
| @@ -478,55 +462,50 @@ write_c_args (FILE *out, char *func, char *buf, int minargs, int maxargs) | |||
| 478 | if (!in_ident) | 462 | if (!in_ident) |
| 479 | { | 463 | { |
| 480 | in_ident = 1; | 464 | in_ident = 1; |
| 481 | ident_start = 1; | 465 | ident_start = p; |
| 482 | |||
| 483 | if (need_space) | ||
| 484 | putc (' ', out); | ||
| 485 | |||
| 486 | if (minargs == 0 && maxargs > 0) | ||
| 487 | fprintf (out, "&optional "); | ||
| 488 | just_spaced = 1; | ||
| 489 | |||
| 490 | minargs--; | ||
| 491 | maxargs--; | ||
| 492 | } | 466 | } |
| 493 | else | 467 | else |
| 494 | in_ident = 0; | 468 | { |
| 469 | in_ident = 0; | ||
| 470 | ident_length = p - ident_start; | ||
| 471 | } | ||
| 495 | } | 472 | } |
| 496 | 473 | ||
| 497 | /* Print the C argument list as it would appear in lisp: | 474 | /* Found the end of an argument, write out the last seen |
| 498 | print underscores as hyphens, and print commas and newlines | 475 | identifier. */ |
| 499 | as spaces. Collapse adjacent spaces into one. */ | 476 | if (c == ',' || c == ')') |
| 500 | if (c == '_') | ||
| 501 | c = '-'; | ||
| 502 | else if (c == ',' || c == '\n') | ||
| 503 | c = ' '; | ||
| 504 | |||
| 505 | /* In C code, `default' is a reserved word, so we spell it | ||
| 506 | `defalt'; unmangle that here. */ | ||
| 507 | if (ident_start | ||
| 508 | && strncmp (p, "defalt", 6) == 0 | ||
| 509 | && ! (('A' <= p[6] && p[6] <= 'Z') | ||
| 510 | || ('a' <= p[6] && p[6] <= 'z') | ||
| 511 | || ('0' <= p[6] && p[6] <= '9') | ||
| 512 | || p[6] == '_')) | ||
| 513 | { | ||
| 514 | fprintf (out, "DEFAULT"); | ||
| 515 | p += 5; | ||
| 516 | in_ident = 0; | ||
| 517 | just_spaced = 0; | ||
| 518 | } | ||
| 519 | else if (c != ' ' || !just_spaced) | ||
| 520 | { | 477 | { |
| 521 | if (c >= 'a' && c <= 'z') | 478 | if (strncmp (ident_start, "void", ident_length) == 0) |
| 522 | /* Upcase the letter. */ | 479 | continue; |
| 523 | c += 'A' - 'a'; | 480 | |
| 524 | putc (c, out); | 481 | putc (' ', out); |
| 525 | } | 482 | |
| 483 | if (minargs == 0 && maxargs > 0) | ||
| 484 | fprintf (out, "&optional "); | ||
| 526 | 485 | ||
| 527 | just_spaced = c == ' '; | 486 | minargs--; |
| 528 | need_space = 0; | 487 | maxargs--; |
| 488 | |||
| 489 | /* In C code, `default' is a reserved word, so we spell it | ||
| 490 | `defalt'; unmangle that here. */ | ||
| 491 | if (strncmp (ident_start, "defalt", ident_length) == 0) | ||
| 492 | fprintf (out, "DEFAULT"); | ||
| 493 | else | ||
| 494 | while (ident_length-- > 0) | ||
| 495 | { | ||
| 496 | c = *ident_start++; | ||
| 497 | if (c >= 'a' && c <= 'z') | ||
| 498 | /* Upcase the letter. */ | ||
| 499 | c += 'A' - 'a'; | ||
| 500 | else if (c == '_') | ||
| 501 | /* Print underscore as hyphen. */ | ||
| 502 | c = '-'; | ||
| 503 | putc (c, out); | ||
| 504 | } | ||
| 505 | } | ||
| 529 | } | 506 | } |
| 507 | |||
| 508 | putc (')', out); | ||
| 530 | } | 509 | } |
| 531 | 510 | ||
| 532 | /* Read through a c file. If a .o file is named, | 511 | /* Read through a c file. If a .o file is named, |