]> git.eshelyaron.com Git - emacs.git/commitdiff
(tparam1): Add handling for `%pN', which
authorThien-Thi Nguyen <ttn@gnuvola.org>
Sun, 2 May 2004 14:05:36 +0000 (14:05 +0000)
committerThien-Thi Nguyen <ttn@gnuvola.org>
Sun, 2 May 2004 14:05:36 +0000 (14:05 +0000)
means use param N for the next substitution.

src/tparam.c

index 0548c722198ce2d260e8025c6cd574b3253b5e1e..4f6edd078576bb90f5cef7c1c671311a8e8e6e93 100644 (file)
@@ -138,7 +138,9 @@ tparam1 (string, outstring, len, up, left, argp)
   int outlen = 0;
 
   register int tem;
-  int *old_argp = argp;
+  int *old_argp = argp;                /* may move */
+  int *fixed_argp = argp;      /* never moves */
+  int explicit_param_p = 0;    /* set by %p */
   int doleft = 0;
   int doup = 0;
 
@@ -163,7 +165,7 @@ tparam1 (string, outstring, len, up, left, argp)
              outlen *= 2;
              new = (char *) xrealloc (outstring, outlen);
            }
-         
+
          op = new + offset;
          outend = new + outlen;
          outstring = new;
@@ -174,7 +176,10 @@ tparam1 (string, outstring, len, up, left, argp)
       if (c == '%')
        {
          c = *p++;
-         tem = *argp;
+         if (explicit_param_p)
+           explicit_param_p = 0;
+         else
+           tem = *argp;
          switch (c)
            {
            case 'd':           /* %d means output in decimal.  */
@@ -198,6 +203,11 @@ tparam1 (string, outstring, len, up, left, argp)
              argp++;
              break;
 
+           case 'p':           /* %pN means use param N in following susbt.  */
+             tem = fixed_argp[(*p++) - '1'];
+             explicit_param_p = 1;
+             break;
+
            case 'C':
              /* For c-100: print quotient of value by 96, if nonzero,
                 then do like %+.  */
@@ -328,3 +338,5 @@ main (argc, argv)
 }
 
 #endif /* DEBUG */
+
+/* tparam.c ends here */