# HG changeset patch # User stephent # Date 1109059558 0 # Node ID 43ba9e13ee8212710fff3d52ac6d06f902ffc17c # Parent 3d8cce0303fa8aae7859a99aaedf7f9a69ece2b5 [xemacs-hg @ 2005-02-22 08:05:58 by stephent] handle UNUSED in DEFUN <87vf8l58aq.fsf@tleepslib.sk.tsukuba.ac.jp> diff -r 3d8cce0303fa -r 43ba9e13ee82 lib-src/ChangeLog --- a/lib-src/ChangeLog Tue Feb 22 07:16:16 2005 +0000 +++ b/lib-src/ChangeLog Tue Feb 22 08:05:58 2005 +0000 @@ -1,3 +1,8 @@ +2004-12-19 Stephen J. Turnbull + + * make-docfile.c (write_c_args): Handle UNUSED, USED_IF macros. + (scan_c_file): Handle nested parens in DEFUN argument lists. + 2005-02-18 Stephen J. Turnbull * XEmacs 21.5.19 "chives" is released. diff -r 3d8cce0303fa -r 43ba9e13ee82 lib-src/make-docfile.c --- a/lib-src/make-docfile.c Tue Feb 22 07:16:16 2005 +0000 +++ b/lib-src/make-docfile.c Tue Feb 22 08:05:58 2005 +0000 @@ -525,9 +525,16 @@ char c = *p; int ident_start = 0; - /* XEmacs addition: add support for ANSI prototypes. Hop over - "Lisp_Object" string (the only C type allowed in DEFUNs) */ + /* XEmacs addition: add support for ANSI prototypes and the UNUSED + macros. Hop over them. "Lisp_Object" is the only C type allowed + in DEFUNs. For the UNUSED macros we need to eat parens, too. */ + static char uu [] = "UNUSED"; + static char ui [] = "USED_IF_"; static char lo[] = "Lisp_Object"; + + /* aren't these all vulnerable to buffer overrun? I guess that + means that the .c is busted, so we may as well just die ... */ + /* skip over "Lisp_Object" */ if ((C_IDENTIFIER_CHAR_P (c) != in_ident) && !in_ident && (strncmp (p, lo, sizeof (lo) - 1) == 0) && isspace ((unsigned char) p[sizeof (lo) - 1])) @@ -538,6 +545,45 @@ c = *p; } + /* skip over "UNUSED" invocation */ + if ((C_IDENTIFIER_CHAR_P (c) != in_ident) && !in_ident && + (strncmp (p, uu, sizeof (uu) - 1) == 0)) + { + char *here = p; + p += (sizeof (uu) - 1); + while (isspace ((unsigned char) (*p))) + p++; + if (*p == '(') + { + while (isspace ((unsigned char) (*++p))) + ; + c = *p; + } + else + p = here; + } + + /* skip over "USED_IF_*" invocation (only if USED failed) */ + else if ((C_IDENTIFIER_CHAR_P (c) != in_ident) && !in_ident && + (strncmp (p, ui, sizeof (ui) - 1) == 0)) + { + char *here = p; + p += (sizeof (ui) - 1); + /* There should be a law against parsing in C: + this allows a broken USED_IF call, skipping to next macro's + parens. *You* can fix that, I don't see how offhand. ;-) */ + while (*p && *p++ != '(') + ; + if (*p) + { + while (isspace ((unsigned char) (*p))) + p++; + c = *p; + } + else + p = here; + } + /* Notice when we start printing a new identifier. */ if (C_IDENTIFIER_CHAR_P (c) != in_ident) { @@ -836,6 +882,7 @@ if (defunflag && maxargs != -1) { char argbuf[1024], *p = argbuf; + int paren_level = 1; #if 0 /* For old DEFUN's only */ while (c != ')') { @@ -858,8 +905,13 @@ *p++ = c = getc (infile); if (c < 0) goto eof; + /* XEmacs change: handle macros with args (eg, UNUSED) */ + if (c == ')') + paren_level--; + if (c == '(') + paren_level++; } - while (c != ')'); + while (paren_level > 0); *p = '\0'; /* Output them. */ if (ellcc)