Mercurial > hg > xemacs-beta
comparison lib-src/make-docfile.c @ 20:859a2309aef8 r19-15b93
Import from CVS: tag r19-15b93
author | cvs |
---|---|
date | Mon, 13 Aug 2007 08:50:05 +0200 |
parents | 376386a54a3c |
children | 441bb1e64a06 |
comparison
equal
deleted
inserted
replaced
19:ac1f612d5250 | 20:859a2309aef8 |
---|---|
88 int maxargs); | 88 int maxargs); |
89 static int scan_c_file (CONST char *filename, CONST char *mode); | 89 static int scan_c_file (CONST char *filename, CONST char *mode); |
90 static void skip_white (FILE *); | 90 static void skip_white (FILE *); |
91 static void read_lisp_symbol (FILE *, char *); | 91 static void read_lisp_symbol (FILE *, char *); |
92 static int scan_lisp_file (CONST char *filename, CONST char *mode); | 92 static int scan_lisp_file (CONST char *filename, CONST char *mode); |
93 | |
94 #define C_IDENTIFIER_CHAR_P(c) \ | |
95 (('A' <= c && c <= 'Z') || \ | |
96 ('a' <= c && c <= 'z') || \ | |
97 ('0' <= c && c <= '9') || \ | |
98 (c == '_')) | |
93 | 99 |
94 /* Name this program was invoked with. */ | 100 /* Name this program was invoked with. */ |
95 char *progname; | 101 char *progname; |
96 | 102 |
97 /* Print error message. `s1' is printf control string, `s2' is arg for it. */ | 103 /* Print error message. `s1' is printf control string, `s2' is arg for it. */ |
336 for (p = buff; *p; p++) | 342 for (p = buff; *p; p++) |
337 { | 343 { |
338 char c = *p; | 344 char c = *p; |
339 int ident_start = 0; | 345 int ident_start = 0; |
340 | 346 |
347 /* Add support for ANSI prototypes. Hop over | |
348 "Lisp_Object" string (the only C type allowed in DEFUNs) */ | |
349 static char lo[] = "Lisp_Object"; | |
350 if ((C_IDENTIFIER_CHAR_P (c) != in_ident) && !in_ident && | |
351 (strncmp (p, lo, sizeof (lo) - 1) == 0) && | |
352 isspace(*(p + sizeof (lo) - 1))) | |
353 { | |
354 p += (sizeof (lo) - 1); | |
355 while (isspace (*p)) | |
356 p++; | |
357 c = *p; | |
358 } | |
359 | |
341 /* Notice when we start printing a new identifier. */ | 360 /* Notice when we start printing a new identifier. */ |
342 if ((('A' <= c && c <= 'Z') | 361 if (C_IDENTIFIER_CHAR_P (c) != in_ident) |
343 || ('a' <= c && c <= 'z') | |
344 || ('0' <= c && c <= '9') | |
345 || c == '_') | |
346 != in_ident) | |
347 { | 362 { |
348 if (!in_ident) | 363 if (!in_ident) |
349 { | 364 { |
350 in_ident = 1; | 365 in_ident = 1; |
351 ident_start = 1; | 366 ident_start = 1; |
352 | |
353 #if 0 | 367 #if 0 |
354 /* XEmacs - This goes along with the change above. */ | 368 /* XEmacs - This goes along with the change above. */ |
355 if (need_space) | 369 if (need_space) |
356 putc (' ', out); | 370 putc (' ', out); |
357 #endif | 371 #endif |
358 | |
359 if (minargs == 0 && maxargs > 0) | 372 if (minargs == 0 && maxargs > 0) |
360 fprintf (out, "&optional "); | 373 fprintf (out, "&optional "); |
361 just_spaced = 1; | 374 just_spaced = 1; |
362 | 375 |
363 minargs--; | 376 minargs--; |
375 | 388 |
376 /* In C code, `default' is a reserved word, so we spell it | 389 /* In C code, `default' is a reserved word, so we spell it |
377 `defalt'; unmangle that here. */ | 390 `defalt'; unmangle that here. */ |
378 if (ident_start | 391 if (ident_start |
379 && strncmp (p, "defalt", 6) == 0 | 392 && strncmp (p, "defalt", 6) == 0 |
380 && ! (('A' <= p[6] && p[6] <= 'Z') | 393 && ! C_IDENTIFIER_CHAR_P (p[6])) |
381 || ('a' <= p[6] && p[6] <= 'z') | |
382 || ('0' <= p[6] && p[6] <= '9') | |
383 || p[6] == '_')) | |
384 { | 394 { |
385 fprintf (out, "DEFAULT"); | 395 fprintf (out, "DEFAULT"); |
386 p += 5; | 396 p += 5; |
387 in_ident = 0; | 397 in_ident = 0; |
388 just_spaced = 0; | 398 just_spaced = 0; |
494 continue; | 504 continue; |
495 c = getc (infile); | 505 c = getc (infile); |
496 if (c != 'F') | 506 if (c != 'F') |
497 continue; | 507 continue; |
498 c = getc (infile); | 508 c = getc (infile); |
499 defunflag = c == 'U'; | 509 defunflag = (c == 'U'); |
500 defvarflag = 0; | 510 defvarflag = 0; |
511 c = getc (infile); | |
501 } | 512 } |
502 else continue; | 513 else continue; |
503 | 514 |
504 while (c != '(') | 515 while (c != '(') |
505 { | 516 { |
512 if (c != '"') | 523 if (c != '"') |
513 continue; | 524 continue; |
514 c = read_c_string (infile, -1, 0); | 525 c = read_c_string (infile, -1, 0); |
515 | 526 |
516 if (defunflag) | 527 if (defunflag) |
517 commas = 5; | 528 commas = 4; |
518 else if (defvarperbufferflag) | 529 else if (defvarperbufferflag) |
519 commas = 2; | 530 commas = 2; |
520 else if (defvarflag) | 531 else if (defvarflag) |
521 commas = 1; | 532 commas = 1; |
522 else /* For DEFSIMPLE and DEFPRED */ | 533 else /* For DEFSIMPLE and DEFPRED */ |
529 commas--; | 540 commas--; |
530 if (defunflag && (commas == 1 || commas == 2)) | 541 if (defunflag && (commas == 1 || commas == 2)) |
531 { | 542 { |
532 do | 543 do |
533 c = getc (infile); | 544 c = getc (infile); |
534 while (c == ' ' || c == '\n' || c == '\t'); | 545 while (c == ' ' || c == '\n' || c == '\t') |
546 ; | |
535 if (c < 0) | 547 if (c < 0) |
536 goto eof; | 548 goto eof; |
537 ungetc (c, infile); | 549 ungetc (c, infile); |
538 if (commas == 2) /* pick up minargs */ | 550 if (commas == 2) /* pick up minargs */ |
539 fscanf (infile, "%d", &minargs); | 551 fscanf (infile, "%d", &minargs); |
583 won't give the names of the arguments, so we shouldn't bother | 595 won't give the names of the arguments, so we shouldn't bother |
584 trying to find them. */ | 596 trying to find them. */ |
585 if (defunflag && maxargs != -1) | 597 if (defunflag && maxargs != -1) |
586 { | 598 { |
587 char argbuf[1024], *p = argbuf; | 599 char argbuf[1024], *p = argbuf; |
600 #if 0 /* For old DEFUN's only */ | |
588 while (c != ')') | 601 while (c != ')') |
589 { | 602 { |
590 if (c < 0) | 603 if (c < 0) |
591 goto eof; | 604 goto eof; |
592 c = getc (infile); | 605 c = getc (infile); |
593 } | 606 } |
607 #endif | |
594 /* Skip into arguments. */ | 608 /* Skip into arguments. */ |
595 while (c != '(') | 609 while (c != '(') |
596 { | 610 { |
597 if (c < 0) | 611 if (c < 0) |
598 goto eof; | 612 goto eof; |
811 { | 825 { |
812 | 826 |
813 /* Skip until the first newline; remember the two previous chars. */ | 827 /* Skip until the first newline; remember the two previous chars. */ |
814 while (c != '\n' && c >= 0) | 828 while (c != '\n' && c >= 0) |
815 { | 829 { |
830 /* ### Kludge -- Ignore any ESC x x ISO2022 sequences */ | |
831 if (c == 27) | |
832 { | |
833 getc (infile); | |
834 getc (infile); | |
835 goto nextchar; | |
836 } | |
837 | |
816 c2 = c1; | 838 c2 = c1; |
817 c1 = c; | 839 c1 = c; |
840 nextchar: | |
818 c = getc (infile); | 841 c = getc (infile); |
819 } | 842 } |
820 | 843 |
821 /* If two previous characters were " and \, | 844 /* If two previous characters were " and \, |
822 this is a doc string. Otherwise, there is none. */ | 845 this is a doc string. Otherwise, there is none. */ |
931 | 954 |
932 if (saved_string == 0) | 955 if (saved_string == 0) |
933 { | 956 { |
934 /* If the next three characters aren't `dquote bslash newline' | 957 /* If the next three characters aren't `dquote bslash newline' |
935 then we're not reading a docstring. */ | 958 then we're not reading a docstring. */ |
936 if ((c = getc (infile)) != '"' || | 959 if ((c = getc (infile)) != '"' || |
937 (c = getc (infile)) != '\\' || | 960 (c = getc (infile)) != '\\' || |
938 (c = getc (infile)) != '\n') | 961 (c = getc (infile)) != '\n') |
939 { | 962 { |
940 #ifdef DEBUG | 963 #ifdef DEBUG |
941 fprintf (stderr, "## non-docstring in %s (%s)\n", | 964 fprintf (stderr, "## non-docstring in %s (%s)\n", |
944 continue; | 967 continue; |
945 } | 968 } |
946 } | 969 } |
947 } | 970 } |
948 | 971 |
949 #ifdef DEBUG | 972 #if 0 /* causes crash */ |
950 else if (! strcmp (buffer, "if") || | 973 else if (! strcmp (buffer, "if") || |
951 ! strcmp (buffer, "byte-code")) | 974 ! strcmp (buffer, "byte-code")) |
952 ; | 975 ; |
953 #endif | 976 #endif |
954 | 977 |