Source-Changes-HG archive

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

[src/trunk]: src/bin/sh PR bin/52280



details:   https://anonhg.NetBSD.org/src/rev/677053c0d1e3
branches:  trunk
changeset: 824507:677053c0d1e3
user:      kre <kre%NetBSD.org@localhost>
date:      Wed Jun 07 09:31:30 2017 +0000

description:
PR bin/52280

removescapes_nl in expari() even when not quoted,
CRTNONL's appear regardless of quoting (unlike CTLESC).

diffstat:

 bin/sh/expand.c |  17 +++++++----------
 1 files changed, 7 insertions(+), 10 deletions(-)

diffs (70 lines):

diff -r 5c762e25015b -r 677053c0d1e3 bin/sh/expand.c
--- a/bin/sh/expand.c   Wed Jun 07 09:14:32 2017 +0000
+++ b/bin/sh/expand.c   Wed Jun 07 09:31:30 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: expand.c,v 1.114 2017/06/07 08:07:50 kre Exp $ */
+/*     $NetBSD: expand.c,v 1.115 2017/06/07 09:31:30 kre Exp $ */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)expand.c   8.5 (Berkeley) 5/15/95";
 #else
-__RCSID("$NetBSD: expand.c,v 1.114 2017/06/07 08:07:50 kre Exp $");
+__RCSID("$NetBSD: expand.c,v 1.115 2017/06/07 09:31:30 kre Exp $");
 #endif
 #endif /* not lint */
 
@@ -100,7 +100,7 @@
 STATIC const char *argstr(const char *, int);
 STATIC const char *exptilde(const char *, int);
 STATIC void expbackq(union node *, int, int);
-STATIC const char *expari(const char *, int);
+STATIC const char *expari(const char *);
 STATIC int subevalvar(const char *, const char *, int, int, int);
 STATIC int subevalvar_trim(const char *, int, int, int, int, int);
 STATIC const char *evalvar(const char *, int);
@@ -288,7 +288,7 @@
                           expdest-ed, ed, *expdest));
                        break;
                case CTLARI:
-                       p = expari(p, flag);
+                       p = expari(p);
                        VTRACE(DBG_EXPAND, ("argstr expari "
                           "+ \"%.*s\" to dest (fwd by: %2.2x) p=\"%.5s...\"\n",
                           expdest-ed, ed, *expdest, p));
@@ -435,13 +435,12 @@
  * evaluate, place result in (backed up) result, adjust string position.
  */
 STATIC const char *
-expari(const char *p, int flag)
+expari(const char *p)
 {
        char *q, *start;
        intmax_t result;
        int adjustment;
        int begoff;
-       int quotes = flag & (EXP_GLOB | EXP_CASE);
        int quoted;
 #ifdef DEBUG
        const char *ed = expdest;
@@ -478,16 +477,14 @@
         */
        quoted = *p++ == '"';
        begoff = expdest - stackblock();
-       VTRACE(DBG_EXPAND, ("expari: '%c' \"%s\" begoff %d quotes %x\n",
-           p[-1],p,begoff, quotes));
+       VTRACE(DBG_EXPAND, ("expari: '%c' \"%s\" begoff %d\n", p[-1],p,begoff));
        p = argstr(p, EXP_NL);                  /* expand $(( )) string */
        STPUTC('\0', expdest);
        start = stackblock() + begoff;
        VTRACE(DBG_EXPAND, ("expari: argstr added: '%s' start: \"%.8s\"\n",
            ed, start));
        removerecordregions(begoff);
-       if (quotes)
-               rmescapes_nl(start);    /* convert CRTNONL back into \n's */
+       rmescapes_nl(start);    /* convert CRTNONL back into \n's */
        q = grabstackstr(expdest);
        result = arith(start, line_number);
        VTRACE(DBG_EXPAND, ("expari: after arith: result=%jd '%s' q@'%.3s'\n",



Home | Main Index | Thread Index | Old Index