comparison lib-src/make-docfile.c @ 2603:43ba9e13ee82

[xemacs-hg @ 2005-02-22 08:05:58 by stephent] handle UNUSED in DEFUN <87vf8l58aq.fsf@tleepslib.sk.tsukuba.ac.jp>
author stephent
date Tue, 22 Feb 2005 08:05:58 +0000
parents ab71ad6ff3dd
children 959746c534f6
comparison
equal deleted inserted replaced
2602:3d8cce0303fa 2603:43ba9e13ee82
523 for (p = buf; *p; p++) 523 for (p = buf; *p; p++)
524 { 524 {
525 char c = *p; 525 char c = *p;
526 int ident_start = 0; 526 int ident_start = 0;
527 527
528 /* XEmacs addition: add support for ANSI prototypes. Hop over 528 /* XEmacs addition: add support for ANSI prototypes and the UNUSED
529 "Lisp_Object" string (the only C type allowed in DEFUNs) */ 529 macros. Hop over them. "Lisp_Object" is the only C type allowed
530 in DEFUNs. For the UNUSED macros we need to eat parens, too. */
531 static char uu [] = "UNUSED";
532 static char ui [] = "USED_IF_";
530 static char lo[] = "Lisp_Object"; 533 static char lo[] = "Lisp_Object";
534
535 /* aren't these all vulnerable to buffer overrun? I guess that
536 means that the .c is busted, so we may as well just die ... */
537 /* skip over "Lisp_Object" */
531 if ((C_IDENTIFIER_CHAR_P (c) != in_ident) && !in_ident && 538 if ((C_IDENTIFIER_CHAR_P (c) != in_ident) && !in_ident &&
532 (strncmp (p, lo, sizeof (lo) - 1) == 0) && 539 (strncmp (p, lo, sizeof (lo) - 1) == 0) &&
533 isspace ((unsigned char) p[sizeof (lo) - 1])) 540 isspace ((unsigned char) p[sizeof (lo) - 1]))
534 { 541 {
535 p += (sizeof (lo) - 1); 542 p += (sizeof (lo) - 1);
536 while (isspace ((unsigned char) (*p))) 543 while (isspace ((unsigned char) (*p)))
537 p++; 544 p++;
538 c = *p; 545 c = *p;
546 }
547
548 /* skip over "UNUSED" invocation */
549 if ((C_IDENTIFIER_CHAR_P (c) != in_ident) && !in_ident &&
550 (strncmp (p, uu, sizeof (uu) - 1) == 0))
551 {
552 char *here = p;
553 p += (sizeof (uu) - 1);
554 while (isspace ((unsigned char) (*p)))
555 p++;
556 if (*p == '(')
557 {
558 while (isspace ((unsigned char) (*++p)))
559 ;
560 c = *p;
561 }
562 else
563 p = here;
564 }
565
566 /* skip over "USED_IF_*" invocation (only if USED failed) */
567 else if ((C_IDENTIFIER_CHAR_P (c) != in_ident) && !in_ident &&
568 (strncmp (p, ui, sizeof (ui) - 1) == 0))
569 {
570 char *here = p;
571 p += (sizeof (ui) - 1);
572 /* There should be a law against parsing in C:
573 this allows a broken USED_IF call, skipping to next macro's
574 parens. *You* can fix that, I don't see how offhand. ;-) */
575 while (*p && *p++ != '(')
576 ;
577 if (*p)
578 {
579 while (isspace ((unsigned char) (*p)))
580 p++;
581 c = *p;
582 }
583 else
584 p = here;
539 } 585 }
540 586
541 /* Notice when we start printing a new identifier. */ 587 /* Notice when we start printing a new identifier. */
542 if (C_IDENTIFIER_CHAR_P (c) != in_ident) 588 if (C_IDENTIFIER_CHAR_P (c) != in_ident)
543 { 589 {
834 won't give the names of the arguments, so we shouldn't bother 880 won't give the names of the arguments, so we shouldn't bother
835 trying to find them. */ 881 trying to find them. */
836 if (defunflag && maxargs != -1) 882 if (defunflag && maxargs != -1)
837 { 883 {
838 char argbuf[1024], *p = argbuf; 884 char argbuf[1024], *p = argbuf;
885 int paren_level = 1;
839 #if 0 /* For old DEFUN's only */ 886 #if 0 /* For old DEFUN's only */
840 while (c != ')') 887 while (c != ')')
841 { 888 {
842 if (c < 0) 889 if (c < 0)
843 goto eof; 890 goto eof;
856 do 903 do
857 { 904 {
858 *p++ = c = getc (infile); 905 *p++ = c = getc (infile);
859 if (c < 0) 906 if (c < 0)
860 goto eof; 907 goto eof;
861 } 908 /* XEmacs change: handle macros with args (eg, UNUSED) */
862 while (c != ')'); 909 if (c == ')')
910 paren_level--;
911 if (c == '(')
912 paren_level++;
913 }
914 while (paren_level > 0);
863 *p = '\0'; 915 *p = '\0';
864 /* Output them. */ 916 /* Output them. */
865 if (ellcc) 917 if (ellcc)
866 fprintf (outfile, "\\n\\\n\\n\\\n"); 918 fprintf (outfile, "\\n\\\n\\n\\\n");
867 else 919 else