From 6d5e4b7a4a8839d9406702ab30af62054078d3af Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Tue, 14 Jun 2016 21:18:36 +0300 Subject: Fix long runs of backslashes in sub/gsub. --- builtin.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'builtin.c') diff --git a/builtin.c b/builtin.c index a5dba010..21f295f7 100644 --- a/builtin.c +++ b/builtin.c @@ -2876,8 +2876,10 @@ set_how_many: leave alone, it goes into the output */ } else { /* gawk default behavior since 1996 */ - if (strncmp(scan, "\\\\\\&", 4) == 0) { + if (strncmp(scan, "\\\\\\&", 4) == 0 + || strncmp(scan, "\\\\\\\\", 4) == 0) { /* 2016: fixed */ /* \\\& --> \& */ + /* \\\\ --> \\ */ repllen -= 2; scan += 3; } else if (strncmp(scan, "\\\\&", 3) == 0) { @@ -2982,10 +2984,12 @@ set_how_many: *bp++ = *scan; } else { /* gawk default behavior since 1996 */ - if (strncmp(scan, "\\\\\\&", 4) == 0) { + if (strncmp(scan, "\\\\\\&", 4) == 0 + || strncmp(scan, "\\\\\\\\", 4) == 0) { /* 2016: fixed */ /* \\\& --> \& */ + /* \\\\ --> \\ */ *bp++ = '\\'; - *bp++ = '&'; + *bp++ = scan[3]; scan += 3; } else if (strncmp(scan, "\\\\&", 3) == 0) { /* \\& --> \ */ -- cgit v1.2.3