changeset 109185:908904655a40

* make-docfile.c (write_c_args): Restructure scanning loop.
author Andreas Schwab <schwab@linux-m68k.org>
date Fri, 09 Jul 2010 19:00:04 +0200
parents 04ae6087d3c0
children 29eae48799da
files lib-src/ChangeLog lib-src/make-docfile.c
diffstat 2 files changed, 45 insertions(+), 62 deletions(-) [+]
line wrap: on
line diff
--- a/lib-src/ChangeLog	Fri Jul 09 18:39:51 2010 +0200
+++ b/lib-src/ChangeLog	Fri Jul 09 19:00:04 2010 +0200
@@ -1,3 +1,7 @@
+2010-07-09  Andreas Schwab  <schwab@linux-m68k.org>
+
+	* make-docfile.c (write_c_args): Restructure scanning loop.
+
 2010-07-09  Dan Nicolaescu  <dann@ics.uci.edu>
 
 	* make-docfile.c (write_c_args): Deal with type names in DEFUN
--- a/lib-src/make-docfile.c	Fri Jul 09 18:39:51 2010 +0200
+++ b/lib-src/make-docfile.c	Fri Jul 09 19:00:04 2010 +0200
@@ -440,8 +440,8 @@
 {
   register char *p;
   int in_ident = 0;
-  int just_spaced = 0;
-  int need_space = 1;
+  char *ident_start;
+  int ident_length;
 
   fprintf (out, "(fn");
 
@@ -450,25 +450,9 @@
 
   for (p = buf; *p; p++)
     {
-      char c;
-      int ident_start = 0;
-
-      /* FIXME: this must be made a bit more robust*/
-      
-      /* Skip "register Lisp_Object", this can be removed when we get
-	 rid of "register" for DEFUNs. */
-      if (strncmp ("register Lisp_Object", p, 20) == 0)
-	p += 20;
+      char c = *p;
 
-      if (strncmp ("Lisp_Object", p, 11) == 0)
-	p += 11;
-
-      if (strncmp ("void", p, 4) == 0)
-	p += 4;
-
-      c  = *p;
-      
-      /* Notice when we start printing a new identifier.  */
+      /* Notice when a new identifier starts.  */
       if ((('A' <= c && c <= 'Z')
 	   || ('a' <= c && c <= 'z')
 	   || ('0' <= c && c <= '9')
@@ -478,55 +462,50 @@
 	  if (!in_ident)
 	    {
 	      in_ident = 1;
-	      ident_start = 1;
-
-	      if (need_space)
-		putc (' ', out);
-
-	      if (minargs == 0 && maxargs > 0)
-		fprintf (out, "&optional ");
-	      just_spaced = 1;
-
-	      minargs--;
-	      maxargs--;
+	      ident_start = p;
 	    }
 	  else
-	    in_ident = 0;
+	    {
+	      in_ident = 0;
+	      ident_length = p - ident_start;
+	    }
 	}
 
-      /* Print the C argument list as it would appear in lisp:
-	 print underscores as hyphens, and print commas and newlines
-	 as spaces.  Collapse adjacent spaces into one.  */
-      if (c == '_')
-	c = '-';
-      else if (c == ',' || c == '\n')
-	c = ' ';
-
-      /* In C code, `default' is a reserved word, so we spell it
-	 `defalt'; unmangle that here.  */
-      if (ident_start
-	  && strncmp (p, "defalt", 6) == 0
-	  && ! (('A' <= p[6] && p[6] <= 'Z')
-		|| ('a' <= p[6] && p[6] <= 'z')
-		|| ('0' <= p[6] && p[6] <= '9')
-		|| p[6] == '_'))
+      /* Found the end of an argument, write out the last seen
+	 identifier.  */
+      if (c == ',' || c == ')')
 	{
-	  fprintf (out, "DEFAULT");
-	  p += 5;
-	  in_ident = 0;
-	  just_spaced = 0;
+	  if (strncmp (ident_start, "void", ident_length) == 0)
+	    continue;
+
+	  putc (' ', out);
+
+	  if (minargs == 0 && maxargs > 0)
+	    fprintf (out, "&optional ");
+
+	  minargs--;
+	  maxargs--;
+
+	  /* In C code, `default' is a reserved word, so we spell it
+	     `defalt'; unmangle that here.  */
+	  if (strncmp (ident_start, "defalt", ident_length) == 0)
+	    fprintf (out, "DEFAULT");
+	  else
+	    while (ident_length-- > 0)
+	      {
+		c = *ident_start++;
+		if (c >= 'a' && c <= 'z')
+		  /* Upcase the letter.  */
+		  c += 'A' - 'a';
+		else if (c == '_')
+		  /* Print underscore as hyphen.  */
+		  c = '-';
+		putc (c, out);
+	      }
 	}
-      else if (c != ' ' || !just_spaced)
-	{
-	  if (c >= 'a' && c <= 'z')
-	    /* Upcase the letter.  */
-	    c += 'A' - 'a';
-	  putc (c, out);
-	}
+    }
 
-      just_spaced = c == ' ';
-      need_space = 0;
-    }
+  putc (')', out);
 }
 
 /* Read through a c file.  If a .o file is named,