Commit Graph
408 Commits
Author SHA1 Message Date
Jim Meyering 937b1ba642 tests: use just-built sed in more places
* cfg.mk (PATH): Prepend $(srcdir)/src, so that we use the just-
built sed also when running commands like those of "make distcheck".
Tested by running this in a just-built directory:
f=sed/sed; printf '%s\n' '#!/bin/sh' 'sleep 9h' > $f; chmod a+x $f
and then verifying that nearly every "make syntax-check" rule hangs.
2016-12-18 11:19:15 +01:00
Jim Meyering 62f8375628 doc: fix sed.1-building rule to work on mingw
* doc/local.mk (doc/sed.1): Add $(EXEEXT) suffix on "sed/sed" dependent.
Patch by Miodrag Milanovic via Stephan T. Lavavej, in
https://lists.gnu.org/archive/html/sed-devel/2016-12/msg00026.html
2016-12-14 08:54:46 -08:00
Jim Meyering 70d57098dd tests: port tests to avoid tr NUL-eliding behavior on Solaris
* testsuite/Makefile.tests (elide_cr): Define this to use sed.
Replace every prior use of "$(TR) -d \\r" with it.
Our just-built sed can do that job (elide CR bytes) even when the
input contains NUL bytes.  Solaris 11.3's /bin/tr would remove any
NUL byte from the result.  Reported by Nelson H.F. Beebe in
https://lists.gnu.org/archive/html/sed-devel/2016-12/msg00006.html
2016-12-12 17:51:18 -08:00
Jim Meyering e43965d076 gnulib: update to latest, for solaris-10-vs-configure fix 2016-12-12 15:04:24 -08:00
Jim Meyering e38c18a676 doc: add a README-hacking file
* README-hacking: New file: instructions for building from a git clone.
Copied from grep's repo, but with s/grep/sed/.
2016-12-12 07:56:59 -08:00
Jim Meyering 5a56178244 build: avoid "make dist" failure due to missing dependencies
* sed/local.mk ($(sed_sed_OBJECTS)): Depend on $(BUILT_SOURCES).
Reported by Assaf Gordon in
https://lists.gnu.org/archive/html/sed-devel/2016-12/msg00016.html
2016-12-11 10:08:06 -08:00
Assaf Gordon adcc31c126 doc: simplify documentation building
Do not bother autogenerating sed.texi from sed-in.texi.  All it did
was to add a few '@group' commands.  Since these are rarely modified,
add them manually.  This simplifies the documentation-building rules
and lets us distribute only one copy of the texinfo manual.
See http://lists.gnu.org/archive/html/sed-devel/2016-12/msg00013.html

* doc/groupify.sed, doc/sed-in.texi: Remove files.
* doc/sed.texi: Remove the 'auto-generated' warning, as this file is no
longer auto-generated.
* doc/local.mk (doc_sed_TEXINFOS): Rename from sed_TEXINFOS.
(dist_noinst_DATA): The above renaming enables us to remove
doc/config.texi and doc/fdl.texi from this list.
(dist_noinst_SCRIPTS): Remove.
(doc/sed.texi): Remove rule.
(doc/s-texi): Likewise.
2016-12-10 21:48:34 -05:00
Assaf Gordon 77f32cf6c6 maint: add missing fdl.texi to distribution
Neglected to add it in commit v4.2.2-175-gc6a55aa.

* doc/local.mk (sed_TEXINFOS, dist_noinst_DATA): Add doc/fdl.texi.
2016-12-06 19:59:08 -05:00
Assaf Gordon 0989654f71 doc: follow-up changes for manual improvements
Fixes few missing issues from commit v4.2.2-176-g801a2c8,
discussed in
http://lists.gnu.org/archive/html/sed-devel/2016-12/msg00005.html

* doc/config.texi: Add stub texinfo macros '@codequotebacktick' and
'@codequoteundirected' (needed if using older versions of texinfo).
* doc/sed-in.texi: Fix syntax that's accepted by newer texinfo but
rejected by texinfo-4.13; Disable directed quote characters in examples.
* doc/sed.texi: Auto-regenerated.
2016-12-06 19:59:08 -05:00
Jim Meyering a3486ce3dd gnulib: update to latest 2016-12-05 15:23:41 -08:00
Assaf Gordon 801a2c83b2 doc: reorganize and expand manual
Discussed in
http://lists.gnu.org/archive/html/sed-devel/2016-11/msg00005.html

* doc/sed-in.texi: Reorganize and expand.
* doc/sed.texi: Auto-regenerated.
2016-12-05 08:46:34 -05:00
Assaf Gordon c6a55aa201 maint: upgrade documentation license to GFDL-1.3 (or later)
* bootstrap.conf: Add gnulib's fdl module.
* doc/sed-in.texi: Update license blurb to latest recommended text.
Remove duplicated copyright information from title page (copied from
coreutil's texinfo style). Include fdl.texi in a new appendix.
2016-12-02 17:31:15 -05:00
Jim Meyering 2d426c3711 tests: use "returns_ N env VAR=val ..."
Use "returns_ N env VAR=val ..." rather than "VAR=val returns_ N ...".
Some shells do not propagate envvar settings through our use
of the "returns_" function, so set any envvar via use of "env".
This was an issue at least on Ubuntu, Debian and *BSD-based systems.
* testsuite/mb-bad-delim.sh: As above.
* testsuite/mb-y-translate.sh: Likewise.
2016-11-29 17:14:46 -08:00
Jim Meyering 5af42765d6 gnulib: update to latest 2016-11-29 15:01:41 -08:00
Jim Meyering 93e9311f29 tests: use "returns_ 1" rather than "&& fail=1"
* testsuite/colon-with-no-label.sh: Rather than failing only upon
success (exit 0), fail upon exit with any value other than 1.
2016-11-27 09:53:14 -08:00
Jim Meyering dc2145f853 build: stop suppressing many -W... warnings
This code in configure.ac added many -W options to the list
of warnings that we do *not* enable.  When I copied most of
this code into this file from coreutils, I did not try to
remove the options that happened not to be needed for sed.
Now, compilers have improved and I have done that triage.
Many -W options can be left enabled.
* configure.ac (GNULIB_WARN_CFLAGS): There is no longer any
need to use a different set of warnings for lib/ files, so
remove this variable, along with many -W-related exemptions.
2016-11-27 09:15:52 -08:00
Jim Meyering ba7cd21262 build: avoid "make distcheck" failure due to leftover .Po files
The following definitions caused trouble for no gain.  They caused
some .o file names to have a long additional prefix and even
resulted in some .Po files not being removed by "make distclean"
when building with recent automake.  The only reason to use these
definitions was -- long ago -- to require different compiler options
for files in lib/ than elsewhere.  That is no longer necessary.
* lib/local.mk (lib_libsed_a_CPPFLAGS): Remove definition.
(lib_libsed_a_CFLAGS, lib_libsed_a_LIBADD): Likewise.
(lib_libsed_a_DEPENDENCIES): Likewise.
2016-11-27 09:15:52 -08:00
Jim Meyering ed15b8cb13 maint: fix -Wformat-exposed errors in uses of "panic"
* sed/utils.h (panic): Add __printf__ attribute, so that compilers
can diagnose format/arg-type errors.  This exposed the following:
* sed/utils.c (ck_fwrite): Don't try to print size_t via %u.
Instead, use %llu and a cast to unsigned long long.
* sed/mbcs.c (is_mb_char): Cast an "int" to unsigned int, to avoid
mismatch with %x.
2016-11-27 09:15:52 -08:00
Jim Meyering 7869c66841 maint: remove unused parameters
* sed/compile.c (finish_program): This function's sole argument
was unused. Remove it and update callers.
* sed/sed.h: Update prototype.
* sed/utils.c (register_open_file): This functions's third argument,
"temp", was unused.  Remove it and update callers.
* sed/sed.c: Update use.
2016-11-27 09:15:52 -08:00
Jim Meyering fbe256efa2 maint: fix two "make syntax-check" failures
* cfg.mk (exclude_file_name_regexp--sc_prohibit_empty_lines_at_EOF):
Also exempt zero-anchor.{inp,good}.
* sed/regexp.c (match_regex): s/can not/cannot/
2016-11-27 09:15:52 -08:00
Assaf Gordon 575b76c47a build: remove explicit 'html' makefile target
The 'html' target was a left-over from the recursive Makefiles,
which were converted to non-recursive in sed v4.2.2-129-g3b29bec.

With this removed, the 'html' target in 'Makefile' is correctly
genererated by automake (from doc/local.mk), and 'make html' works again.

* Makefile.am: Remove explicit 'html' target.
2016-11-16 13:10:04 -05:00
Jim Meyering 6e760c0b4d tests: use "returns_ 1" rather than testing $? = 1
* testsuite/temp-file-cleanup.sh: As above.
2016-11-12 14:37:41 -08:00
Assaf Gordon 9796bdd2d6 sed: standardize exit code values
Use exit-code constants, and document them:
1=syntax error, 2=bad input files, 4=I/O error or panic.
Add "Exit Status" section in manual.

* sed/utils.h: Define new constants.
* sed/utils.c,
  sed/compile.c,
  sed/execute.c,
  sed/sed.c: Use constants instead of hard-coded values.
* doc/sed-in.texi: Add "Exit Status" section.
* doc/sed.texi: Automatically re-generated.
2016-11-04 21:29:51 -04:00
Assaf Gordon 50d2687936 maint: regenerate sed.texi after doc change
Regenerate sed.texi from sed-in.texi after
doc change in v4.2.2-160-10549b7 ( https://bugs.gnu.org/24799 ).

* doc/sed.texi: Regenerated with 'make info'.
2016-11-04 21:20:11 -04:00
Norihiro Tanaka 7c5b3bed65 sed: fix multi-line regex matching with -z
Sed incorrectly matches the anchor '^' to a newline character
(ASCII 10) despite using NUL line terminators (-z).
See https://bugs.gnu.org/24615 .

Previous (incorrect) behavior:

    $ printf "a\0b\0" | sed -z 'N;s/^/X/mg;' | od -An -a
       X   a nul   b nul

With this fix:

    $ printf "a\0b\0" | sed -z 'N;s/^/X/mg;' | od -An -a
       X   a nul   X   b nul

Current regex engine can not handle NUL multiline anchors.
Implement such search manually (by breaking the pattern into separate
NUL-terminated lines) and searching each one individually.

* NEWS: Mention it.
* sed/regexp.c (compile_regex_1): Don't use newline_anchor of regex, if
the buffer delimiter is not newline character.
(match_regex): Do above case line-by-line.
* testsuite/zero-anchor.good, testsuite/zero-anchor.inp,
  testsuite/zero-anchor.sed: New test.
* testsuite/local.mk: Add the test.
* testsuite/Makefile.tests: Add the test.
* bootstrap.conf: Add memrchr.
* lib/.gitignore, m4/.gitignore: Ignore memrchr files.
2016-11-04 21:03:46 -04:00
Norihiro Tanaka 6dea75e708 sed: optimize regex processing of lone ^ or $
Optimize /^/ and /$/ patterns and avoid invoking the regular expression
engine if possible.
See https://bugs.gnu.org/24615 .

* sed/regex.c (compile_regex_1): Mark the patterns which consist of ^ or $.
(match_regex): Handle the patterns which consist of ^ or $ manually.
* sed/sed.h (struct regex): New members 'begline' and 'endline'.
* testsuite/newline-anchor.good, testsuite/newline-anchor.sed,
testsuite/newline-anchor.sed: New test.
* testsuite/Makefile.tests: Add the test.
* testsuite/local.mk: Add the test.
2016-11-04 21:03:43 -04:00
Vincenzo Romano 10549b7e6d doc: make an example's description more precise
* doc/sed-in.texi (Regular Expressions): Mention that the match
must be at the end of a line.
2016-10-26 11:12:23 -07:00
Jim Meyering 639e80e8ee maint: address syntax-check warnings about @pxref
* doc/sed-in.texi: Improve cross-references.
* doc/sed.texi: Regenerate.
2016-10-02 15:52:14 -07:00
Jim Meyering b5f1552429 build: address warnings from GCC 7
* sed/sed.c (usage): Declare with the _Noreturn attribute to suppress
this warning/error:
sed/sed.c:359:11: error: this statement may fall through \
  [-Werror=implicit-fallthrough]
           usage(0);
           ^~~~~~~~
* sed/execute.c (execute_program) [case 'q']: Add FALLTHROUGH comment
to avoid warning from GCC 7's -Wimplicit-fallthrough.
* sed/compile.c (compile_program): Likewise.
2016-10-02 14:16:31 -07:00
Jim Meyering b2d8e03acb gnulib: update to latest 2016-10-02 14:16:31 -07:00
Norihiro Tanaka 188207529c sed: fix incorrect match for title case
* sed/regexp.c (compile_regex_1): Avoid building fastmap for case-
insensitive matching.
* testsuite/title-case.sh: New file, to test for this fix.
* testsuite/local.mk (T): Add the new file name and sort alphabetically.
* init.cfg (require_el_iso88597_locale_): Define.
2016-09-25 16:34:03 -07:00
Jim Meyering ba26be8954 dfa: reflect move of dfa code to new gnulib module
* bootstrap.conf (gnulib_modules): Add dfa.
* sed/dfa.c: Remove file.
* sed/dfa.h: Likewise.
* sed/local.mk (sed_sed_SOURCES): Remove dfa.c.
(NOINST_HEADERS): Remove dfa.h.
* sed/regexp.c (compile_regex_1): Use new dfasyntax API.
* sed/sed.c (localeinfo): New global.
(main): Call init_localeinfo to initialize it.
* sed/sed.h: Include localeinfo.h and declare the new global.
* lib/.gitignore: Ignore new gnulib-imported files.
* m4/.gitignore: Likewise.
* po/POTFILES.in: s,sed/dfa.c,lib/dfa.c,
2016-09-11 20:53:03 -07:00
Jim Meyering 098ce3f6d1 gnulib: update to latest, for new dfa module 2016-09-11 20:31:04 -07:00
Assaf Gordon d8e71fe737 sed: new --sandbox option
In sandbox mode, r/w/e commands are not allowed.
This ensures sed operates only on files designated on the command line,
and cannot execute external programs.

* sed/sed.c (sandbox): New option variable.
  (usage): List new option.
  (main): Accept new option in getopt.
* sed/sed.h (sandbox): New extern option variable.
* sed/compile.c (DISALLOWED_CMD): New error message.
  (read_filename): Abort in sandbox mode (r/w commands).
  (compile_program): Abort on 'e' in sandbox mode.
* testsuite/sandbox.sh: Test new option.
* testsuite/local.mk: Add new test.
* NEWS: Mention new option.
* doc/sed-in.texi, doc/sed.texi: Document new option.
2016-09-05 00:27:04 -04:00
Jim Meyering 55b3353648 maint: fix distclean-vs-excess-.Po files more cleanly
* doc/local.mk (distclean-local): Remove rule.  Moved to ...
* Makefile.am (distclean-local): ...here, and add a command to
remove all .deps directories.  It could have stayed in that .mk
file, but since with this change, it is no longer specific to doc/,
the top level makes more sense.
* lib/local.mk (MOSTLYCLEANFILES): Remove this.  Covered by the above.
Reported by Assaf Gordon in
https://lists.gnu.org/archive/html/sed-devel/2016-08/msg00019.html
2016-08-27 23:03:37 -07:00
Assaf Gordon 8033dcda70 maint: update .mailmap
Consolidate author's upper/lower case email addresses.
Fixes the following problem:
    $ make THANKS
    GEN      THANKS
    ./thanks-gen: THANKS.in: duplicate name: Ralf Wildenhues

Due to:
    $ git log --pretty=format:'%aN %aE' | grep -i ralf | sort -u
    Ralf Wildenhues ralf.wildenhues@gmx.de
    Ralf Wildenhues Ralf.Wildenhues@gmx.de

see http://lists.gnu.org/archive/html/sed-devel/2016-08/msg00023.html
    http://lists.gnu.org/archive/html/sed-devel/2016-08/msg00025.html

* .mailmap: Add email mapping.
2016-08-26 11:54:30 -04:00
Assaf Gordon 0c0e67bd26 doc: update README
* README: Update information: remove mention of README.boot, mention
AUTHORS, THANKS, website and help/usage information.
2016-08-24 18:39:20 -04:00
Assaf Gordon 97b4c86f75 maint: update program name in THANKS.in
* THANKS.in: Replace 'grep' with 'sed'.
2016-08-24 18:39:20 -04:00
Assaf Gordon 3d94929bcd maint: remove superfluous name from THANKS.in
* THANKS.in: Remove Pádraig Brady: He is the author of two commits
(v4.2.1-1-g737ca5e and v4.2.1-37-g629ef76) and will be automatically
included in the auto-generated THANKS file.
2016-08-24 18:39:20 -04:00
Assaf Gordon 7f3e1a59b6 maint: remove README-alpha
* README-alpha: Removed.
2016-08-24 18:39:20 -04:00
Assaf Gordon 2223f2e54c maint: update AUTHORS
* AUTHORS: Update information.
2016-08-22 20:57:02 -04:00
Jim Meyering 5ceaf1a059 doc: work with read-only sed.1
* doc/local.mk (doc/sed.1): Also remove $@, so that mv does not
prompt about read-only target.
2016-08-18 09:16:03 -07:00
Jim Meyering 5b44cd088a build: fix sed.1 dependency; work with latest automake
* doc/local.mk (doc/sed.1): Depend not on sed.c, but on the binary
that help2man must run.  Also depend on .version, to be sure we
pick up a version change.  Also, be careful not to write directly
to $@: instead write to $@-t, and make read-only to mark as generated,
and then, only if all is well, rename atomically to $@.
Also, prefix commands with $(AM_V_GEN) and $(AM_V_at) and ensure
that doc/ exists via $(MKDIR_P).
(distclean-local): New target. Use this instead of ...
(dist-hook-man-page): ... this. Remove rule.
(SEDBIN): Remove unnecessary $(top_builddir)/ prefix.
(doc/sed.texi, doc/s-texi): Remove some uses of $(top_builddir).
Replace others with $(srcdir).
* Makefile (dist-hook): remove dependency on dist-hook-man-page.
* lib/local.mk (MOSTLYCLEANFILES): Arrange for lib/.deps/*.Po
to be removed as part of "make distclean", so that make distcheck
no longer fails when using latest automake.
2016-08-14 22:36:15 -07:00
Jim Meyering a2fccfc85a sed: remove obsolete advice from --help output
* sed/sed.c (contact): Now that there is a sed-specific
mailing list, there is no longer any need to include "sed"
in the subject.  Remove that advice.
2016-08-14 22:36:15 -07:00
Assaf Gordon 1f2cb7cd3c doc: mention \s,\S,\<,\> regex gnu-extensions
* doc/sed-in.texi: Mention the extensions.
* doc/sed.texi: Automatically re-generated.
2016-08-11 23:51:58 -04:00
Assaf Gordon 6003a01f87 doc: expand on N command
* doc/sed-in.texi: Expand on gnu-extension of 'N' command.
* doc/sed.texi: Automatically re-generated.
2016-08-11 23:51:50 -04:00
Jim Meyering ae6c2bba70 sed: avoid one-byte heap buffer overrun
* sed/execute.c (DFA_SLOP): Define.
(resize_line): Use it in each line-related allocation.
(line_init): Likewise.
(line_copy): Likewise.
2016-08-09 13:47:52 -07:00
Assaf Gordon f62a2a9965 sed: adjust line-terminator of F/l/= commands when -z is used
Change F/l/= commands to use NUL line terminator if '-z' option is used.
Previously F/l/= used '\n' regardless of -z option.
See: http://lists.gnu.org/archive/html/sed-devel/2016-08/msg00000.html
http://lists.gnu.org/archive/html/sed-devel/2016-08/msg00002.html .

* sed/execute.c: (do_list,execute_program): Use 'buffer_delimiter' as
line delimiter instead of hard-coded '\n'.
* testsuite/nulldata.sh: Adjust tests accordingly.
2016-08-08 20:59:10 -04:00
Norihiro Tanaka cbd13f729d sed: use grep's DFA matcher to speed up regular expression matching
When possible, sed now uses grep's DFA matcher to match regular
expression, often resulting in a 10x speed-up.
* NEWS (Improvements): Mention it.  Move this section to the top.
* sed/local.mk (sed_sed_SOURCES): Add dfa.c, and sort file names.
(noinst_HEADERS): Add dfa.h, and sort file names.
* sed/regexp.c (dfaerror, dfawarn): New functions.
(compile_regex_1): Compile pattern with dfa.
(match_regex): Use dfa.
* sed/sed.h: Include dfa.h.
(struct regex): New member dfa.
* sed/dfa.c: New file, copied from grep.
* sed/dfa.h: New file, copied from grep.
* po/POTFILES.in: Add sed/dfa.c.
2016-08-08 17:50:49 -07:00
Assaf Gordon ab0cfea35c sed: reject 's///e' in --posix mode
's///e' modifier is a gnu extension - reject it in --posix mode.

* sed/compile.c: (mark_subst_opt): Exit upon 's///e' in posix mode.
* testsuite/posix-mode-s.sh: Adjust tests accordingly.
2016-08-08 20:32:16 -04:00