Do not dribble zero bytes into the output, by replacing an obfuscated if

whose true and false clauses were equivalent with a check that we are
not about to stumble off the end of the line.

Reported by:	peter
Pointy hat to:	fanf
This commit is contained in:
Tony Finch 2003-06-05 12:10:19 +00:00
parent 30ef7aacc2
commit c2b9b6eba8

View File

@ -362,10 +362,7 @@ substitute(cp)
slen -= match[0].rm_eo; slen -= match[0].rm_eo;
lastempty = 0; lastempty = 0;
} else { } else {
if (match[0].rm_so == 0) if (match[0].rm_so < slen)
cspace(&SS, s, match[0].rm_so + 1,
APPEND);
else
cspace(&SS, s + match[0].rm_so, 1, cspace(&SS, s + match[0].rm_so, 1,
APPEND); APPEND);
s += match[0].rm_so + 1; s += match[0].rm_so + 1;