Source-Changes-HG archive

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

[src/trunk]: src/dist/nawk exit with fatal error if backreferences are used i...



details:   https://anonhg.NetBSD.org/src/rev/8f50b829de8d
branches:  trunk
changeset: 554260:8f50b829de8d
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Sun Oct 26 13:27:26 2003 +0000

description:
exit with fatal error if backreferences are used in subst string
of gensub(); these are not supported (yet) and better to fail with
error than to end up with silent incorrect substitution

diffstat:

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

diffs (26 lines):

diff -r fd7443cdd13b -r 8f50b829de8d dist/nawk/run.c
--- a/dist/nawk/run.c   Sun Oct 26 13:19:30 2003 +0000
+++ b/dist/nawk/run.c   Sun Oct 26 13:27:26 2003 +0000
@@ -1951,10 +1951,22 @@
        tempfree(h);
 
        if (pmatch(pfa, t)) {
+               char *sl;
+
                tempstat = pfa->initstat;
                pfa->initstat = 2;
                pb = buf;
                rptr = getsval(y);
+               /*
+                * XXX if there are any backreferences in subst string,
+                * complain now.
+                */
+               for(sl=rptr; (sl = strchr(sl, '\\')) && sl[1]; sl++) {
+                       if (strchr("0123456789", sl[1])) {
+                               FATAL("gensub doesn't support backreferences (subst \"%s\")", rptr);
+                       }
+               }
+               
                do {
                        if (whichm >= 0 && whichm != num) {
                                num++;



Home | Main Index | Thread Index | Old Index