History log of /freebsd-10.0-release/usr.bin/sed/process.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 259065 07-Dec-2013 gjb

- Copy stable/10 (r259064) to releng/10.0 as part of the
10.0-RELEASE cycle.
- Update __FreeBSD_version [1]
- Set branch name to -RC1

[1] 10.0-CURRENT __FreeBSD_version value ended at '55', so
start releng/10.0 at '100' so the branch is started with
a value ending in zero.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation

# 256281 10-Oct-2013 gjb

Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation


# 192732 25-May-2009 brian

Implement "addr1,+N" ranges - not dissimilar to grep's -A switch.

PR: 134856
Submitted by: Jeremie Le Hen - jeremie at le-hen dot org


# 176126 09-Feb-2008 dwmalone

WARNS fixes:
1) Add missing parens around assignment that is compared to zero.
2) Make some variables that only take non-negative values unsigned.
3) Some casts/type changes to fix other constness warnings.
4) Make one variable a const char *.
5) Make sure termwidth is positive, it doesn't make sense for it to be negative.

Approved by: dds


# 170609 12-Jun-2007 yar

Drop the argument to the OUT macro because it can't emit
anything but the pattern space anyway. Apply style(9)
to the macro.

Tested with: md5(1)


# 170608 12-Jun-2007 yar

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


# 170605 12-Jun-2007 yar

There is a symbolic antonym for REPLACE as a flag to cspace()
and mf_fgets(): APPEND. So use it instead of a 0 constant for
clarity.

Tested with: md5(1)


# 168921 20-Apr-2007 yar

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


# 168258 02-Apr-2007 yar

Don't forget to close the range if we branched over its end
and had no chance to match it by the 2nd address precisely.
Otherwise the unclosed range would bogusly extend to the end
of stream.

Add a basic regression test for the bug fixed. (This change
also fixes the more complex case 5.3 from `multitest.t'.)

Compared with: SUN and GNU seds
Tested by: regression tests
MFC after: 1 week


# 168255 02-Apr-2007 yar

Prevent foot-shooting in advance: Put the MATCH() macro's value
in parentheses. The ?: operator has a remarkably low precedence, so
expressions like (MATCH(foo) && bar) would have an unexpected meaning
w/o the parentheses around MATCH().

Tested with: md5(1)


# 168211 01-Apr-2007 yar

This trivial change should fix at least 3 similar bugs. All of
them are related to the `c' function's need to know if we are at
the actual end of the address range. (It must print the text not
earlier than the whole pattern space was deleted.) It appears the
only sed function with this requirement.

There is `lastaddr' set by applies(), which is to notify the `c'
function, but it can't always help because it's false when we are
hitting the end of file early. There is also a bug in applies()
due to which `lastaddr' isn't set to true on degenerate ranges such
as `$,$' or `N,$' if N appears the last line number.

Handling early EOF condition in applies() could look more logical,
but it would effectively revert sed to the unreasonable behaviour
rev. 1.26 of main.c fought against, as it would require lastline()
be called for each line within each address range. So it's better
to call lastline() only if needed by the `c' function.

Together with this change to sed go regression tests for the bugs
fixed (c1-c3). A basic test of `c' (c0) is also added as it helped
me to spot my own error.

Discussed with: dds
Tested by: the regression tests
MFC after: 1 week


# 168120 31-Mar-2007 yar

Make the comment for cspace() match reality.


# 158989 27-May-2006 krion

Fix using "P" command on empty pattern space. If the "P" command is
used once on a non-empty pattern space and then again on an empty
pattern space, the second usage restores the pattern space length to
the length that it had when the first "P" was used.

PR: bin/96052
Submitted by: Andrey Zholos <aaz@althenia.net>
MFC after: 7 days


# 144840 09-Apr-2005 stefanf

Remove unused variables.


# 133385 09-Aug-2004 dds

Per letter dated July 22, 1999 remove 3rd clause of Berkeley derived
software (original contributor).

Reviewed by: imp


# 132145 14-Jul-2004 tjr

Make the 'y' (translate) command aware of multibyte characters.


# 132083 13-Jul-2004 tjr

Overhaul lputs() to deal with multibyte characters, characters that take
up more than one column position, and null bytes.


# 122049 04-Nov-2003 des

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


# 122045 04-Nov-2003 des

Whitespace cleanup


# 122044 04-Nov-2003 des

ANSIfy


# 121915 02-Nov-2003 tjr

Change the buffer length test in NEEDSP() so that it does not
subtract one unsigned number from another potentially smaller
one, leading to wraparound (and heap corruption, eventually).

PR: 58813
MFC after: 2 weeks


# 115871 05-Jun-2003 fanf

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


# 115831 04-Jun-2003 fanf

Fix substitution when the regex matches the zero-length string.
There are two bugs: in the s///g case, the substitution didn't occur
at the end of the line; in the s///N case, the code didn't count
forwards along the line properly. See the sg, s3, s4, and s5 tests
in src/tools/regression/usr.bin/sed/.

Reviewed by: tjr


# 103715 20-Sep-2002 eric

Initialize a variable in order to fix when faced with picky compilers.

Sponsored by: Apple


# 101668 11-Aug-2002 tjr

Correct boundary condition error in `D' and `P' commands when the last
line of the pattern space is empty. Don't emit spurious newline when
EOF is reached with the `N' command.

Pointed out by: Oleg Osyka
MFC after: 1 week


# 100359 19-Jul-2002 markm

s/inline/__inline/


# 99573 08-Jul-2002 tjr

Make cspace()'s second argument const. Make `escapes' in lputs() const.


# 99352 03-Jul-2002 tjr

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


# 99351 03-Jul-2002 tjr

Don't let the pattern space become null if the `x' command is used when the
hold space is null; some functions assume it's never null.

MFC after: 3 days


# 98743 24-Jun-2002 tjr

Fix off by one in `y' (transliterate) command which caused the last character
of the pattern space not to be examined.

Noticed by: Motoyuki Konno <motoyuki@bsdclub.org>


# 98603 22-Jun-2002 tjr

Now that the pattern space contains no trailing newline, modify the `l'
command's output so it's the same as what SUSv3 specifies.


# 98601 21-Jun-2002 tjr

Don't store newlines at the end of each line in the hold/pattern spaces,
instead add the newline when the pattern space is printed. Make the `G' and
`H' commands add a newline to the space before the data, remove bogus
addition of newline from `x' command.

PR: 29790, 38195


# 98085 10-Jun-2002 tjr

Don't write escape newlines with `l' command (SUSv3)


# 98082 10-Jun-2002 tjr

Correctly handle global substitutions where the pattern is only "$", the
EOL anchor, when the last input line does not end in a newline character.
Picked up by the GNU sed test suite.


# 97808 04-Jun-2002 tjr

Wrap lines correctly for the `l' command.


# 97801 04-Jun-2002 tjr

Ignore COLUMNS environment variable if it is empty (SUSv3)


# 96704 16-May-2002 trhodes

More consistancy. file system > filesystem


# 94012 07-Apr-2002 jmallett

Fix sed(1) in the case where a last line is specified and hold space is not
specified, and then the first part of the pattern space is deleted, when
there are two or more input lines, as this results in subtraction of one from
an unsigned integral value of '0'. That bogus value is used in one case
for a loop (that will run far too many times in this case) and a function to
search for a value within a specified range of memory, however now the range
of memory is obscenely large and a segmentation fault will occur. This is
fixed by checking for and appropriately handling a nil pattern space as if
the specified search in memory failed, as indeed it obviously will with nil
pattern space.

Submitted by: Tim J. Robbins <tim@robbins.dropbear.id.au>
PR: bin/34813
Reviewed by: mike
MFC after: 1 day


# 93860 05-Apr-2002 jmallett

Fix sed(1) behaviour for 'G' when given null holdspace by making sure it
contains a \n.

PR: misc/26153
Submitted by: ashp
Reviewed by: mike
Obtained from: NetBSD
MFC after: 2 days


# 92922 21-Mar-2002 imp

remove __P


# 87766 12-Dec-2001 markm

WARNS=2 partial fix; use NO_WERROR to protect against some hard-to-fix warnings.

Use __FBSDID(), kill register keyword.


# 80286 24-Jul-2001 obrien

Expand xmalloc in-place, along with xrealloc; which wasn't even ANSI in its
implementation.


# 50477 27-Aug-1999 peter

$Id$ -> $FreeBSD$


# 46081 25-Apr-1999 imp

More egcs warning fixes:
o main returns int not void
o use return 0 at end of main when needed
o use braces to avoid potentially ambiguous else
o don't default to type int
o #ifdef 0 -> #if 0

Reviewed by: obrien and chuckr


# 41572 07-Dec-1998 archie

Compile -Wall


# 35520 29-Apr-1998 ache

Make 'y' command 8bit clean
PR: 6458


# 28066 11-Aug-1997 charnier

Remove local redefinition for err(). Add usage().


# 17522 11-Aug-1996 ache

Localize it
8bit cleanup


# 10075 16-Aug-1995 jkh

Merge various fixes from NetBSD. This will allow the WordPerfect for
SCO installation to run all the way through (some POSIX fixes).


# 8874 30-May-1995 rgrimes

Remove trailing whitespace.


# 6209 05-Feb-1995 jmz

Correct a bug in the P function: according to 7th edition UNIX (tm), the
newline must be part of the pattern space i.e. `echo a|sed -e P' must print
a
a
and not
aa
This is consistent with gnu sed, SunOS, Ultrix (and probably others!)


# 1591 27-May-1994 rgrimes

This commit was generated by cvs2svn to compensate for changes in r1590,
which included commits to RCS files with non-trunk default branches.


# 1590 27-May-1994 rgrimes

BSD 4.4 Lite Usr.bin Sources