bug-texinfo
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Backslash in zero-argument @macros


From: Karl Berry
Subject: Re: Backslash in zero-argument @macros
Date: Sun, 1 Jun 2003 19:43:36 -0400

       @macro backsl {}
       \\
       @end macro
       This @backsl{} is a backslash.

    results in the following info output:

       This  is a backslash.

Thanks for the report.  Here's a patch if you'd like to try it ...


*** macro.c.~1.1.~      Thu Oct 31 14:11:41 2002
--- macro.c     Sun Jun  1 16:39:52 2003
***************
*** 322,328 ****
        else
          { /* Snarf parameter name, check against named parameters. */
            char *param;
!           int param_start, which, len;
  
            param_start = ++i;
            while (body[i] && body[i] != '\\')
--- 322,328 ----
        else
          { /* Snarf parameter name, check against named parameters. */
            char *param;
!           int param_start, len;
  
            param_start = ++i;
            while (body[i] && body[i] != '\\')
***************
*** 336,364 ****
            if (body[i]) /* move past \ */
              i++;
  
!           /* Now check against named parameters. */
!           for (which = 0; named && named[which]; which++)
!             if (STREQ (named[which], param))
!               break;
! 
!           if (named && named[which])
!             {
!               text = which < length_of_actuals ? actuals[which] : NULL;
!               if (!text)
!                 text = "";
!               len = strlen (text);
!             }
!           else
!             { /* not a parameter, either it's \\ (if len==0) or an
!                  error.  In either case, restore one \ at least.  */
!               if (len) {
!                 warning (_("\\ in macro expansion followed by `%s' instead of 
\\ or parameter name"),
!                          param); 
!               }
                len++;
                text = xmalloc (1 + len);
                sprintf (text, "\\%s", param);
              }
  
            if (strlen (param) + 2 < len)
              {
--- 336,373 ----
            if (body[i]) /* move past \ */
              i++;
  
!           if (len == 0)
!             { /* \\ always means \, even if macro has no args.  */
                len++;
                text = xmalloc (1 + len);
                sprintf (text, "\\%s", param);
              }
+           else
+             {
+               int which;
+               
+               /* Check against named parameters. */
+               for (which = 0; named && named[which]; which++)
+                 if (STREQ (named[which], param))
+                   break;
+ 
+               if (named && named[which])
+                 {
+                   text = which < length_of_actuals ? actuals[which] : NULL;
+                   if (!text)
+                     text = "";
+                   len = strlen (text);
+                   text = xstrdup (text);  /* so we can free it */
+                 }
+               else
+                 { /* not a parameter, so it's an error.  */
+                   warning (_("\\ in macro expansion followed by `%s' instead 
of parameter name"),
+                              param); 
+                   len++;
+                   text = xmalloc (1 + len);
+                   sprintf (text, "\\%s", param);
+                 }
+             }
  
            if (strlen (param) + 2 < len)
              {
***************
*** 371,378 ****
            strcpy (new_body + new_body_index, text);
            new_body_index += len;
  
!           if (!named || !named[which])
!             free (text);
          }
      }
  
--- 380,386 ----
            strcpy (new_body + new_body_index, text);
            new_body_index += len;
  
!           free (text);
          }
      }
  




reply via email to

[Prev in Thread] Current Thread [Next in Thread]