User: stephent
Date: 05/02/22 09:05:59
Modified: xemacs/lib-src ChangeLog make-docfile.c
Log:
handle UNUSED in DEFUN <87vf8l58aq.fsf(a)tleepslib.sk.tsukuba.ac.jp>
Revision Changes Path
1.187 +5 -0 XEmacs/xemacs/lib-src/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/lib-src/ChangeLog,v
retrieving revision 1.186
retrieving revision 1.187
diff -u -r1.186 -r1.187
--- ChangeLog 2005/02/18 06:28:31 1.186
+++ ChangeLog 2005/02/22 08:05:58 1.187
@@ -1,3 +1,8 @@
+2004-12-19 Stephen J. Turnbull <stephen(a)xemacs.org>
+
+ * 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 <stephen(a)xemacs.org>
* XEmacs 21.5.19 "chives" is released.
1.17 +55 -3 XEmacs/xemacs/lib-src/make-docfile.c
Index: make-docfile.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/lib-src/make-docfile.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- make-docfile.c 2004/12/06 03:50:53 1.16
+++ make-docfile.c 2005/02/22 08:05:58 1.17
@@ -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)
Show replies by date