Source-Changes-HG archive

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

[src/netbsd-2-0]: src/dist/nawk Pull up revision 1.10 (requested by jdolecek ...



details:   https://anonhg.NetBSD.org/src/rev/4e73ba70c0bc
branches:  netbsd-2-0
changeset: 561291:4e73ba70c0bc
user:      jdc <jdc%NetBSD.org@localhost>
date:      Sun Jun 06 06:51:14 2004 +0000

description:
Pull up revision 1.10 (requested by jdolecek in ticket #446).

fix off-by-one use of gensub() index parameter, and treat negative
number to mean 'replace first match'; the index use is now fully
aligned with GNU awk

fixes PR bin/25543 by Richard Rauch

diffstat:

 dist/nawk/run.c |  12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diffs (22 lines):

diff -r 6c77a69eaf0d -r 4e73ba70c0bc dist/nawk/run.c
--- a/dist/nawk/run.c   Sun Jun 06 06:47:53 2004 +0000
+++ b/dist/nawk/run.c   Sun Jun 06 06:51:14 2004 +0000
@@ -1946,8 +1946,16 @@
        sptr = getsval(h);
        if (sptr[0] == 'g' || sptr[0] == 'G')
                whichm = -1;
-       else
-               whichm = (int) getfval(h);
+       else {
+               /*
+                * The specified number is index of replacement, starting
+                * from 1. GNU awk treats index lower than 0 same as
+                * 1, we do same for compatibility.
+                */
+               whichm = (int) getfval(h) - 1;
+               if (whichm < 0)
+                       whichm = 0;
+       }
        tempfree(h);
 
        if (pmatch(pfa, t)) {



Home | Main Index | Thread Index | Old Index