Report whether sed was built with SELinux support (determined at compile
time), and whether it is enabled on this system (determined at runtime).
Relates to https://bugs.gnu.org/35997 .
* sed/sed.c (selinux_support): New function, print SELinux status to
stdout. (main): Call selinux_support on --version.
Cause developer builds to fail for any use of a VLA.
VLAs (variable length arrays) limit portability.
* configure.ac (nw): Remove -Wvla from the list of disabled warnings,
thus enabling the warning when configured with --enable-gcc-warnings.
(GNULIB_NO_VLA) Define, disabling use of VLAs in gnulib. This commit
is functionally equivalent to coreutils' v8.30-44-gd26dece5d.
Under some conditions, \b would mistakenly fail to match. E.g.,
this would mistakenly print "123-x" instead of "123":
echo 123-x|LC_ALL=C sed 's/.\bx//'
* NEWS (Bug fixes): Mention it
* gnulib: Update to latest, for DFA regression fix.
* testsuite/word-delim.sh: New file, to test for the dfa.c regression.
* testsuite/local.mk (T): Add it.
Reported by Jan Palus in
https://lists.gnu.org/r/sed-devel/2018-12/msg00022.html
This test is skipped on most platforms (which do not support O_BINARY
and do not differentiate between TEXT and BINARY files).
On cygwin, the test is skipped because default cygwin installations
do not use O_TEXT/O_BINARY modes (unless file systems are mounted with
special options).
In practice this test will only run on native Windows (e.g. when compiled
with mingw or msvc). Note that almost every other test will fail with
such a binary (due to excesssive "\r" in the output). Thus it is
recommended to explictly run just this test alone:
make check SUBDIRS=. TESTS=testsuite/obinary.sh
The script tries to cover all cases mentioned in https://bugs.gnu.org/25459 .
See also https://lists.gnu.org/r/sed-devel/2018-10/msg00001.html .
* testsuite/obinary.sh: New test.
* testsuite/local.mk (TESTS): Add new test.
Discussed in https://lists.gnu.org/r/sed-devel/2018-10/msg00001.html .
* NEWS: Mention change.
* bootstrap.conf: Add gnulib's binary-io module.
* sed/sed.c (main): Set stdin/stdout to binary mode if needed.
* sed/utils.c (ck_mkstemp): Explicitly set binary mode on file
descriptor. It seems that on (non-cygwin) Windows the fdopen(3) call
ignores the 'b' in the 'mode' argument - and the file was always opened
in O_TEXT mode. Thus "--binary" was not working with "--inplace".
Require version 2.64 to bootstrap. This is already required in practice
by bootstrap.conf, but was not updated in configure.ac.
After recent gnulib update, gnulib-tool would complain:
$ ./gnulib/gnulib-tool
./gnulib/gnulib-tool: *** minimum supported autoconf version is 2.63.\
Try adding AC_PREREQ([2.63]) to your configure.ac.
./gnulib/gnulib-tool: *** Stop.
Hence this update.
* configure.ac: Require autoconf version 2.64 or later.
The NULL-initialized char string in_place_extension is free'ed everytime
it is redefined (using xstrdup) and at program exit with any return code.
See: https://lists.gnu.org/r/sed-devel/2018-11/msg00005.html
* sed/sed.c (main, cleanup): Free 'in_place_extension' if running with
lint.
* testsuite/debug.pl: Don't use Data::Dump. Unnecessary.
That package, perl-Data-Dump, appear not to be default-installed
on at least a Fedora 29 beta system.
* sed/debug.c (debug_print_function) [b, t, T]: For a b, t or T
command with no LABEL, do not access uninitialized memory.
I.e., print the label name only when there is one.
$ seq 3 | sed --debug -e 's/./--&--/ ; 2d'
SED PROGRAM:
s/./--&--/
2 d
INPUT: 'STDIN' line 1
PATTERN: 1
COMMAND: s/./--&--/
MATCHED REGEX REGISTERS
regex[0] = 0-1 '1'
PATTERN: --1--
COMMAND: 2 d
END-OF-CYCLE:
--1--
INPUT: 'STDIN' line 2
PATTERN: 2
COMMAND: s/./--&--/
MATCHED REGEX REGISTERS
regex[0] = 0-1 '2'
PATTERN: --2--
COMMAND: 2 d
END-OF-CYCLE:
INPUT: 'STDIN' line 3
PATTERN: 3
COMMAND: s/./--&--/
MATCHED REGEX REGISTERS
regex[0] = 0-1 '3'
PATTERN: --3--
COMMAND: 2 d
END-OF-CYCLE:
--3--
Discussed in https://lists.gnu.org/r/sed-devel/2018-07/msg00006.html
and https://lists.gnu.org/r/sed-devel/2018-10/msg00007.html .
* NEWS: Mention new option.
* doc/sed.texi (Program options): Mention new option.
* sed/debug.c: New unit with debug printing functions.
* sed/sed.h (debug_print_command, debug_print_char, debug_print_program,
debug): Declare functions and global variable.
(struct sed_cmd): Add label_name member variable.
* sed/compile.c (compile_program): Save the label's name.
(cleanup_program_filenames): extracted function to free filenames.
(check_final_program) Don't delete the filenames, instead move it to ...
(finish_program) ... here.
* sed/execute.c (debug_print_end_of_cycle, debug_print_input,
debug_print_line): New debug functions (cannot be defined in debug.c as
execute's structures are private).
(execute_program, process_files): Call debug functions.
* sed/sed.c: (DEBUG_OPTION): New option for getoptlong.
(debug): New global variable.
(usage): Mention new option.
(main): Process new option and call debug functions if needed.
* testsuite/debug.pl: New tests.
* testsuite/local.mk (T): Add new tests.
For the 'R' command, keep a pointer to 'struct output' instead of just
to FILE*. No change in functionality. This will help future debug code
to know the filename of the associated file.
As a side effect, fix invalid code in W/w execution:
The previous code checked for 'cur_cmd->x.fp' (which was related to R
command, not W/w). Since 'x' is a union, 'x.fp' was not relevant to
the 'x.outf' (which is the struct associted with W/w commands).
* sed/sed.h (struct sed_cmd): Replace 'FILE*' with 'struct *output' for
R command.
* sed/compile.c (compile_program): Adjust as needed.
* sed/execute.c (execute_program): Adjust as needed.
w/W (and s///w) commands Without a filename would print a confusing error
message:
$ sed w
sed: couldn't open file : No such file or directory
While r/R commands with empty file name were a silent no-op.
With this change, sed programs with empty filename are rejected with a
clear error:
$ sed 's/1/2/w'
sed: -e expression #1, char 7: missing filename in r/R/w/W commands
$ sed r
sed: -e expression #1, char 1: missing filename in r/R/w/W commands
* NEWS: Mention change.
* sed/compile.c (get_openfile): Exit with an error message if filename
is missing. (compile_program): Same for 'r' command code.
* testsuite/missing-filename.sh: New test.
* testsuite/local.mk (T): Add new test.
Discussed in https://bugs.gnu.org/22636 .
* doc/sed.texi: Use '@kbd{@key{TAB}}' instead of '@kbd{tab}' to improve
rendering in HTML and info formats.
Copyright-paperwork-exempt: Yes
Reported in https://bugs.gnu.org/30479 .
doc/sed.x: Change a HYPHEN-MINUS (code 0x55, 2D) to a dash (\-, minus)
if it matches " -[:alpha:]" or \(aq-[:alpha:] (for options); Use a pronoun
instead of a repeated noun.
Copyright-paperwork-exempt: Yes
Perl-regexp syntax (PCRE) in GNU Sed is shelved indefinitely.
See https://bugs.gnu.org/22801 , https://bugs.gnu.org/22647 .
Remove all (unused) REG_PERL related code.
* sed/sed.c, sed/sed.h, sed/regexp.c, sed/compile.c: Remove REG_PERL code.
Use the locally built sed binary only during 'check*' targets,
but not during build/installation targets - it might be buggy, or contain
temporary debugging/ASAN features that can break the build.
See: https://lists.gnu.org/r/sed-devel/2018-08/msg00013.html .
* cfg.mk (PATH): Add the 'sed' directory to the PATH only if this is a
'check' target.
Under normal operation there is no need for explicit freeing,
as all memory will be released when sed terminates.
During development (and specifically, valgrind and address-sanitizing)
enabling lint prevents false-positive warnings about memory
leaks.
Lint mode can be enabled with CFLAGS="-Dlint". It is also automatically
enabled by default when building from git (as opposed to tarball).
For consistency all instances of "#ifdef DEBUG_LEAKS" are replaced
with "#ifdef lint".
* sed/sed.h (struct subst): Add member variable to keep the address of
allocated buffer in compile.c:setup_replacement().
(release_regex): Add declaration.
(finish_program): Function now takes an argument: the sed program
vector.
* sed/sed.c (main): Adjust call to finish_program.
* sed/compile.c (finish_program): Release program allocations.
(setup_replacement): Remember the allocated buffer address.
(compile_program): Free temporary array in 'y' command.
* sed/execute.c (execute_program): Free allocated but unused buffer in
'R' command when reaching EOF.
* sed/regexp.c (release_regex): Remove 'static', free the allocated
dfa struct.
* sed/utils.c (panic): Free open files linked-list elements.