From: Thien-Thi Nguyen Date: Sun, 2 May 2004 14:05:36 +0000 (+0000) Subject: (tparam1): Add handling for `%pN', which X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=f3c2539f014899ec1557c0f8dd780954bf3b676b;p=emacs.git (tparam1): Add handling for `%pN', which means use param N for the next substitution. --- diff --git a/src/tparam.c b/src/tparam.c index 0548c722198..4f6edd07857 100644 --- a/src/tparam.c +++ b/src/tparam.c @@ -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 */