's/foo/\1/' is rejected by default (gnu extension),
silently accepted in POSIX.
* testsuite/posix-mode-bad-ref.sh: new test.
* testsuite/Makefile.am: add new test.
'N' with insufficient output prints nothing in POSIX mode, prints the
last read line in GNU Extension mode.
Compare:
echo a | sed N
echo a | sed --posix N
echo a | POSIXLY_CORRECT=y sed N
* testsuite/posix-mode-N.sh: test output of N command under gnu and
posix modes.
* testsuite/Makefile.am: add new test.
* testsuite/Makefile.am (TESTS_ENVIRONMENT): Propagate the
LOCALE_JA envvar setting determined at configure time into
the test environment. Without this, the test would fail on
some systems: at least CentOS6 and 7, but not Fedora 24.
* testsuite/envvar-check: New file. Identical to the one from
grep, but with the addition of sed-specific "COLS".
* testsuite/Makefile.am (EXTRA_DIST): Add it here.
(TESTS_ENVIRONMENT): New prologue, mostly copied from grep.
previously, sed 's/./\c\\/' or 's/./\c\d/' would produce incorrect
results. Require two backslashes after \c to denote control sequence
^\ (ASCII 0x34), and reject recursive escaping (e.g. \c\x61).
* sed/compile.c: (RECURSIVE_ESCAPE_C): New error message.
(normalize_text): Check for \c-backslash, reject recursive escaping.
* testsuite/recursive-escape-c.sh: New file. Test new behaviour.
* testsuite/Makefile.am (T): Add new test.
* NEWS (Bug fixes): Mention it.
Stephane Chazelas made a fine case for why sed's --in-place (-i)
should treat "-" as a file name, and not as standard input in
http://debbugs.gnu.org/21249
There was no specific test for the prior behavior, so rather than
letting the revert remove the sole test, adapt and retain it:
* testsuite/in-place-hyphen.sh: However, retain and adapt this
file to test for the restored behavior.
* testsuite/Makefile.am: Retain this change, too.
Now, sed copies such bytes into the output.
* sed/execute.c (str_append_modified): Copy each invalid byte
into the result string, as the comment suggests.
* testsuite/invalid-mb-seq-UMR.sh: Adjust this test to conform.
Perl does the same thing. Also, remove an unnecessary "-e" option.
* NEWS (Bug fixes): Mention it.
Bug introduced prior to the switch to git in 2004,
between the releases of sed-4.0.9 and sed-4.1.
This addresses http://debbugs.gnu.org/22254.
* sed/execute.c (str_append_modified): Upon encountering an
incomplete multi-byte sequence in a substitution replacement
string, do not treat mbrtowc's return value of -2 as a large,
positive number.
* testsuite/subst-mb-incomplete.sh: New file/test.
* testsuite/Makefile.am (T): Add it.
Reported by Hanno Böck in http://debbugs.gnu.org/22127.
Hanno used the AFL fuzzer to find the segfault-inducing input
from which I derived the test's input.
Introduced by v4.2.2-76-g78e8e58, this bug was never in a release.
Before, sed would accept it and treat it as a label whose name
had length 0, and that could be referenced via a "b" or "t"
command with no label.
* sed/compile.c (errors): Add the new diagnostic.
(COLON_LACKS_LABEL): Define.
(compile_program): Reject ":" command with no label.
* testsuite/colon-with-no-label.sh: New file.
* testsuite/Makefile.am (T): Add it.
* NEWS (Bug fixes): Mention it.
Reported by Stephane Chazelas in http://bugs.gnu.org/21250
* testsuite/invalid-mb-seq-UMR.sh: Use the configure-detected
locale name, $LOCALE_JA, rather than hard-coding ja_JP.eucJP.
If the required type of locale was not detected, then skip
this test. Reported by Assaf Gordon in http://bugs.gnu.org/21124
* sed/utils.c (ck_mkstemp): Remove $TMP/$TMPDIR-envvar-using code
that would have been run only if this function's second parameter
were to be NULL, but that could never happen, given the current
and sole caller.
Also, use mode_t as the type for the saved umask value, not "int".
Also, move each declaration down to point of definition.
* sed/utils.h (ck_mkstemp): Mark each of the four parameters as nonnull.
When reading from stdin, use of --follow-symlinks would cause failure:
$ echo abc | sed --follow-symlinks s/a/d/
sed: cannot stat -: No such file or directory
* sed/execute.c (open_next_file): Set input->in_file_name earlier,
so we can rearrange logic to avoid calling follow_symlink("-").
* testsuite/follow-symlinks-stdin.sh: New file.
* testsuite/Makefile.am (T): Add it.
* NEWS (Bug fixes): Mention it.
Bug introduced by commit v4.2.1-13-g84066bf.
http://bugs.gnu.org/20795
Most GNU utilities treat "-" as standard input, sed itself does that --
in most contexts. However, since the addition of support for
--in-place (-i) in sed-4.0, sed -i has treated a "-" argument as a
file name, i.e., like ./-. Now, that usage evokes a diagnostic:
$ sed -i s/a/b/ -
sed: couldn't edit -: is a terminal
If you require the old behavior, specify the file name as "./-".
Prompted by the report/patch from Stanislav Brabec in
http://bugs.gnu.org/20796 to document the strangely
inconsistent legacy behavior.
* sed/execute.c (open_next_file): Call panic before
even attempting to operate on the file descriptor.
* testsuite/in-place-hyphen.sh: New file. Test for this.
* testsuite/Makefile.am (T): Add it.
* NEWS (Feature removal): Mention it. Admittedly, the old behavior
feels more like a misfeature.
* sed/sed.c: Include <unistd.h>, for declaration of unlink.
Without this change, commit makes sed v4.2.2-84-g7689015 fail
to compile when configured with --enable-gcc-warnings.
For example, running a command like "sed -i s//b/ F" would fail
to remove a temporary file named sedXXXXXX (for random XXXXXX)
in the directory alongside F.
* sed/sed.c (G_file_to_unlink): New global.
(register_cleanup_file, cancel_cleanup, cleanup): New functions.
(main): Call atexit.
* sed/execute.c (open_next_file): Register for unlink.
(closedown): Call cancel_cleanup right after the rename.
* sed/sed.h: Declare two of the new functions.
* NEWS (Bug fixes): Mention it.
* testsuite/temp-file-cleanup.sh: New file. Test for this.
* testsuite/Makefile.am (T): Add it.
Reported by David Jones in http://bugs.gnu.org/20002.
* testsuite/invalid-mb-seq-UMR.sh: Upon failure due to a
valgrind-internal assertion, skip this test.
Reported by Norihiro Tanaka in http://debbugs.gnu.org/20490
When the line number ranges of two or more editing commands overlap,
sed applies all commands but the first to a line that is just beyond
the union of all ranges. E.g., with this command,
seq 9|sed '2,7d;3,6d', sed would mistakenly delete line 8.
* sed/execute.c (match_an_address_p) [ADDR_IS_NUM]: Make this
function work also in this case.
(match_address_p): Move the ADDR_IS_NUM +
...->line_number == ...->addr_number comparison "up" into
match_an_address_p, so we can hoist two similar if/return
blocks out of "if" and "else" branches.
Change so that this function returns false when the current
line number is outside the specified range.
* testsuite/range-overlap.sh: New file, to test for this.
* testsuite/Makefile.am (T): Add it to the list.
* NEWS (Bug fixes): Mention it.
Reported as http://bugs.gnu.org/19899
* cfg.mk (sc_preprocessor_indentation): New rule, from coreutils.
(local-checks-to-skip): Exempt it, for now.
(sc_THANKS_in_sorted): Another rule from coreutils. Enabled.
(announcement_Cc_): Define, so the auto-generated announcement
message template includes sed-devel@ as a recipient.
(update-copyright-env) [UPDATE_COPYRIGHT_USE_INTERVALS]: Update
to use =2, rather than=1, so that the next time we update
copyright dates, it will collapse a few more ranges.
* testsuite/invalid-mb-seq-UMR.sh: New file. Test for just-fixed bug.
* testsuite/Makefile.am (T): New variable.
Add the two init.sh-using test names here, rather than in
two separate lists.
(SEDTESTS, EXTRA_DIST): Use $(T).
(EXTRA_DIST): Add init.cfg.
* testsuite/init.cfg: New file, to add functions from coreutils.
(require_valgrind_, print_ver_): New functions.
* sed/execute.c (str_append_modified): When attempting to append an
invalid multibyte sequence, e.g., from the RHS of a substitution
expression, we would read uninitialized memory.
Don't capitalize first word of diagnostic; remove exclamation point.
Wrap new translatable strings in _(...).
* NEWS (Bug fixes): Mention it.
This addresses http://debbugs.gnu.org/20490
* Makefile.am (DISTCLEANFILES): Initialize.
(EXTRA_DIST): Add .version.
(BUILT_SOURCES): Set to .version.
(.version): New rule.
(THANKS): Depend on .version.
* sed/Makefile.am: Add rules to build version.[ch].
* sed/sed.c: Include version.h, and use the new variable, Version.
* testsuite/Makefile.am: Arrange to distribute and run the new
help-version.sh test. Also distribute the new init.sh.
* testsuite/help-version.sh: New file.
* testsuite/init.sh: Likewise.
* .gitignore: Ignore the generated files, .version and src/version.[ch].
This is covered by other tests, and the general --help/--version
checks provided by help-version.sh (about to be added) are more
thorough.
* configure.ac (COPYRIGHT_YEAR): Remove definition and AC_SUBST.
* Makefile.am (dist-hook): Remove test.
* testsuite/Makefile.am (SEDTESTS): Remove "version".
* testsuite/version.gin: Remove file.
* .gitignore: Remove mention of generated file, version.good.
* cfg.mk (local-checks-to-skip): Remove the overall exemption,
but continue to exempt some files in testsuite/.
* configure.ac: Split a long line.
* doc/sed-in.texi: Split long lines.
* doc/sed.texi: Likewise.
* sed/compile.c: Likewise.
* sed/execute.c: Split long lines.
(execute_program): Reorder "#ifdef HAVE_POPEN" and
"if (pipe_fp != NULL)" if/else blocks to make the code
clearer and (incidentally) the lines shorter, due to a
decrease in nesting level.
* sed/sed.c: Split long lines.
* sed/utils.c: Likewise.
* sed/utils.h: Likewise.
* cfg.mk (exclude_file_name_regexp--sc_prohibit_strncpy): Remove
its exemption.
* sed/compile.c (compile_program): Remove two misuses of strncpy;
use memcpy instead.
* sed/execute.c (do_list): Likewise, for one instance.
* build-aux/texi2dvi: Remove file. It was out of date and could
no longer parse our .texi files.
* Makefile.am (EXTRA_DIST): Don't list it here.
* cfg.mk: Remove an exemption for that file.
* doc/Makefile.am (TEXI2DVI): Remove definition.
* sed/Makefile.am (sed_SOURCES): Remove fmt.c.
* sed/execute.c (execute_program):
* sed/fmt.c: Remove file.
* sed/sed.h (fmt): Remove declaration.
* doc/sed.texi: Remove documentation for 'L' command.
* doc/sed-in.texi: Likewise.
* NEWS (Feature removal): Document it.
Prompted by the report from Jodie Cunningham that using this
command with a large number could cause sed to segfault:
https://bugs.launchpad.net/ubuntu/+source/sed/+bug/1400575