changeset 53270:971b19b300e6

(tparam1): Add handling for `%pN', which means use param N for the next substitution.
author Thien-Thi Nguyen <ttn@gnuvola.org>
date Wed, 24 Dec 2003 07:31:42 +0000
parents 957afba80853
children 00ac28166865
files src/tparam.c
diffstat 1 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/tparam.c	Wed Dec 24 06:49:23 2003 +0000
+++ b/src/tparam.c	Wed Dec 24 07:31:42 2003 +0000
@@ -144,7 +144,9 @@
   int outlen = 0;
 
   register int tem;
-  int *old_argp = argp;
+  int *old_argp = argp;                 /* can move */
+  int *fixed_argp = argp;               /* never moves */
+  int explicit_param_p = 0;             /* set by %p */
   int doleft = 0;
   int doup = 0;
 
@@ -180,7 +182,10 @@
       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.  */
@@ -203,7 +208,10 @@
 	      *op++ = tem % 10 + '0';
 	      argp++;
 	      break;
-
+            case 'p':           /* %pN means use param N for next subst.  */
+	      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 %+.  */