Source-Changes-HG archive

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

[src/trunk]: src/bin/sh The correct usage of recordregion() is (begin, end) n...



details:   https://anonhg.NetBSD.org/src/rev/c2a1e225dcb5
branches:  trunk
changeset: 824390:c2a1e225dcb5
user:      kre <kre%NetBSD.org@localhost>
date:      Sat Jun 03 18:37:37 2017 +0000

description:
The correct usage of recordregion() is (begin, end) not (begin, length).

Fixing this fixes a regression introduced earlier today (UTC) where
arithmetic expressions would be split correctly when the arithmetic
started at the beginning of a word:
        echo $(( expression ))
where "begin" is 0, and so (begin, length) is the same as (begin, begin+length)
(aka: (begin,end) - and yes, "end" means 1 after last to consider).
but did not work correctly when the usage was
        echo XXX$( expression ))
(begin !+ 0) and would only split (some part of) the result of the expression.

This regression was also foung by the new t_fsplit:split_arith
test case added earlier to the ATF tests for sh.

diffstat:

 bin/sh/expand.c |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (27 lines):

diff -r fb075caffefa -r c2a1e225dcb5 bin/sh/expand.c
--- a/bin/sh/expand.c   Sat Jun 03 18:31:35 2017 +0000
+++ b/bin/sh/expand.c   Sat Jun 03 18:37:37 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: expand.c,v 1.107 2017/06/03 10:31:16 kre Exp $ */
+/*     $NetBSD: expand.c,v 1.108 2017/06/03 18:37:37 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.107 2017/06/03 10:31:16 kre Exp $");
+__RCSID("$NetBSD: expand.c,v 1.108 2017/06/03 18:37:37 kre Exp $");
 #endif
 #endif /* not lint */
 
@@ -481,7 +481,7 @@
                ;
 
        if (quoted == 0)                        /* allow weird splitting */
-               recordregion(begoff, q - 1 - start, 0);
+               recordregion(begoff, begoff + q - 1 - start, 0);
        adjustment = expdest - q + 1;
        STADJUST(-adjustment, expdest);
        VTRACE(DBG_EXPAND, ("expari: adding %d ed \"%.*s\", "



Home | Main Index | Thread Index | Old Index