Commit Graph

21 Commits

Author SHA1 Message Date
Mark Johnston
b480502648 sed: Fix -i option behavior with 'q' command.
Don't just exit when encountering the 'q' command if we edit file
inplace, and give mf_fgets() a chance to actually handle the
inplace case.

Also add a regression test.

Submitted by:	Yuri Pankov <yuripv@yuripv.net>
Approved by:	re (kib)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D16798
2018-08-29 17:09:03 +00:00
Pedro F. Giffuni
0649b6706f sed: unsign some indexes to fix sign-compare warnings.
Hinted by:	OpenBSD (CVS 1.32)

MFC after:	 1 week
2018-07-30 18:29:46 +00:00
Pedro F. Giffuni
8a16b7a18f General further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 3-Clause license.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.
2017-11-20 19:49:47 +00:00
Warner Losh
fbbd9655e5 Renumber copyright clause 4
Renumber cluase 4 to 3, per what everybody else did when BSD granted
them permission to remove clause 3. My insistance on keeping the same
numbering for legal reasons is too pedantic, so give up on that point.

Submitted by:	Jan Schaumann <jschauma@stevens.edu>
Pull Request:	https://github.com/freebsd/freebsd/pull/96
2017-02-28 23:42:47 +00:00
Pedro F. Giffuni
249a8a8003 sed(1): Revert r303047 "cleanup" and therefore r303572.
While big, the change was meant to have no effect on behavior and instead
so far we have found two regressions: one in the etcupdate tests and
another one in the games/openttd port[1].

Revert to a known working state. We will likely have to split the patch in
functional parts before bringing back the changes.

PR:		195929
Reported by:	danfe, madpilot [1]
2016-08-02 15:35:53 +00:00
Pedro F. Giffuni
b4932d18ee sed(1): Assorted cleanups and simplifications.
Const-ify several variables, make it build cleanly with WARNS level 5.

Submitted by:	mi
PR:		195929
MFC after:	1 month
2016-07-19 22:56:40 +00:00
Yaroslav Tykhiy
26a5710c40 Don't forget to clear out the hold space for each subsequent file
when in -i mode so that each file gets a clean context of its own.

Add a regression test for the bug.

Tested with:	regression tests
2007-06-12 12:05:24 +00:00
Yaroslav Tykhiy
f6703c9c0a Change the semantics of -i (in-place editing) so that it treats
each file independently from other files.  The new semantics are
desired in the most of practical cases, e.g.: delete lines 5-9
from each file.

Keep the previous semantics of -i under a new option, -I, which
uses a single continuous address space covering all files to edit
in-place -- they are too cool to just drop them.

Add regression tests for -i and -I.

Approved by:	dds
Compared with:	GNU sed
Discussed on:	-hackers
MFC after:	2 weeks
2007-04-21 01:21:36 +00:00
Diomidis Spinellis
30fd73fb81 Per letter dated July 22, 1999 remove 3rd clause of Berkeley derived
software (original contributor).

Reviewed by:	imp
2004-08-09 15:29:41 +00:00
Dag-Erling Smørgrav
f54cda1467 Reimplement in-place editing in a slightly less disgusting manner. Also,
make an effort to preserve the ownership and mode of the file we are
editing.

Sponsored by:	Registrar AS
2003-11-04 13:09:16 +00:00
Tim J. Robbins
dfb072f405 Make cspace()'s second argument const. Make `escapes' in lputs() const. 2002-07-08 06:00:55 +00:00
Tim J. Robbins
8523e9a677 Avoid checking whether each line is the last line of the file when we don't
need to know. Instead, check when we are trying to match a "$" address.
This does not change the way sed processes regular files, but makes it behave
more sensibly when used interactively.

PR:		40101
MFC after:	2 weeks
2002-07-03 14:38:27 +00:00
Warner Losh
3f330d7d1a remove __P 2002-03-22 01:42:45 +00:00
Mark Murray
e74bf75f1c WARNS=2 partial fix; use NO_WERROR to protect against some hard-to-fix warnings.
Use __FBSDID(), kill register keyword.
2001-12-12 23:20:16 +00:00
David E. O'Brien
8e33c0a0f6 Expand xmalloc in-place, along with xrealloc; which wasn't even ANSI in its
implementation.
2001-07-24 14:05:21 +00:00
Brian Feldman
d249b1750a Uncorrupt the SCCS id (s/ From: / /).
Put a tab before the comment for "rflags".

Submitted by:	bde
2000-03-20 21:31:30 +00:00
Brian Feldman
175de1e677 Add a new flag: -E enables "extended" regular expressions. 2000-03-19 19:41:53 +00:00
Brian Feldman
ab853c5a6f Add $FreeBSD$. 2000-03-19 19:39:41 +00:00
Archie Cobbs
c56690ef7b Fix a new bug introduced by the previous bug fix 1998-12-08 21:29:22 +00:00
Philippe Charnier
73a08bb2ad Remove local redefinition for err(). Add usage(). 1997-08-11 07:21:08 +00:00
Rodney W. Grimes
9b50d90275 BSD 4.4 Lite Usr.bin Sources 1994-05-27 12:33:43 +00:00