summaryrefslogtreecommitdiffstats
path: root/usr.bin/sed/process.c
Commit message (Collapse)AuthorAgeFilesLines
* WARNS fixes:dwmalone2008-02-091-5/+7
| | | | | | | | | | 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
* Drop the argument to the OUT macro because it can't emityar2007-06-121-7/+7
| | | | | | | anything but the pattern space anyway. Apply style(9) to the macro. Tested with: md5(1)
* Don't forget to clear out the hold space for each subsequent fileyar2007-06-121-2/+16
| | | | | | | | 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
* There is a symbolic antonym for REPLACE as a flag to cspace()yar2007-06-121-6/+6
| | | | | | | and mf_fgets(): APPEND. So use it instead of a 0 constant for clarity. Tested with: md5(1)
* Change the semantics of -i (in-place editing) so that it treatsyar2007-04-211-0/+13
| | | | | | | | | | | | | | | | | 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
* Don't forget to close the range if we branched over its endyar2007-04-021-2/+11
| | | | | | | | | | | | | 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
* Prevent foot-shooting in advance: Put the MATCH() macro's valueyar2007-04-021-3/+3
| | | | | | | | 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)
* This trivial change should fix at least 3 similar bugs. All ofyar2007-04-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Make the comment for cspace() match reality.yar2007-03-311-3/+3
|
* Fix using "P" command on empty pattern space. If the "P" command iskrion2006-05-271-2/+1
| | | | | | | | | | 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
* Remove unused variables.stefanf2005-04-091-2/+1
|
* Per letter dated July 22, 1999 remove 3rd clause of Berkeley deriveddds2004-08-091-4/+0
| | | | | | software (original contributor). Reviewed by: imp
* Make the 'y' (translate) command aware of multibyte characters.tjr2004-07-141-3/+59
|
* Overhaul lputs() to deal with multibyte characters, characters that taketjr2004-07-131-24/+53
| | | | up more than one column position, and null bytes.
* Reimplement in-place editing in a slightly less disgusting manner. Also,des2003-11-041-19/+21
| | | | | | | make an effort to preserve the ownership and mode of the file we are editing. Sponsored by: Registrar AS
* Whitespace cleanupdes2003-11-041-11/+11
|
* ANSIfydes2003-11-041-23/+10
|
* Change the buffer length test in NEEDSP() so that it does nottjr2003-11-021-1/+2
| | | | | | | | subtract one unsigned number from another potentially smaller one, leading to wraparound (and heap corruption, eventually). PR: 58813 MFC after: 2 weeks
* Do not dribble zero bytes into the output, by replacing an obfuscated iffanf2003-06-051-4/+1
| | | | | | | | 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
* Fix substitution when the regex matches the zero-length string.fanf2003-06-041-5/+6
| | | | | | | | | 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
* Initialize a variable in order to fix when faced with picky compilers.eric2002-09-201-0/+2
| | | | Sponsored by: Apple
* Correct boundary condition error in `D' and `P' commands when the lasttjr2002-08-111-6/+3
| | | | | | | | 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
* s/inline/__inline/markm2002-07-191-4/+4
|
* Make cspace()'s second argument const. Make `escapes' in lputs() const.tjr2002-07-081-2/+3
|
* Avoid checking whether each line is the last line of the file when we don'ttjr2002-07-031-1/+1
| | | | | | | | | 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
* Don't let the pattern space become null if the `x' command is used when thetjr2002-07-031-0/+2
| | | | | | hold space is null; some functions assume it's never null. MFC after: 3 days
* Fix off by one in `y' (transliterate) command which caused the last charactertjr2002-06-241-1/+1
| | | | | | of the pattern space not to be examined. Noticed by: Motoyuki Konno <motoyuki@bsdclub.org>
* Now that the pattern space contains no trailing newline, modify the `l'tjr2002-06-221-1/+5
| | | | command's output so it's the same as what SUSv3 specifies.
* Don't store newlines at the end of each line in the hold/pattern spaces,tjr2002-06-221-11/+10
| | | | | | | | 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
* Don't write escape newlines with `l' command (SUSv3)tjr2002-06-101-3/+3
|
* Correctly handle global substitutions where the pattern is only "$", thetjr2002-06-101-0/+3
| | | | | EOL anchor, when the last input line does not end in a newline character. Picked up by the GNU sed test suite.
* Wrap lines correctly for the `l' command.tjr2002-06-041-1/+1
|
* Ignore COLUMNS environment variable if it is empty (SUSv3)tjr2002-06-041-1/+1
|
* More consistancy. file system > filesystemtrhodes2002-05-161-1/+1
|
* Fix sed(1) in the case where a last line is specified and hold space is notjmallett2002-04-071-3/+5
| | | | | | | | | | | | | | | | | 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
* Fix sed(1) behaviour for 'G' when given null holdspace by making sure itjmallett2002-04-051-0/+2
| | | | | | | | | | contains a \n. PR: misc/26153 Submitted by: ashp Reviewed by: mike Obtained from: NetBSD MFC after: 2 days
* remove __Pimp2002-03-221-6/+6
|
* WARNS=2 partial fix; use NO_WERROR to protect against some hard-to-fix warnings.markm2001-12-121-11/+10
| | | | Use __FBSDID(), kill register keyword.
* Expand xmalloc in-place, along with xrealloc; which wasn't even ANSI in itsobrien2001-07-241-6/+12
| | | | implementation.
* $Id$ -> $FreeBSD$peter1999-08-281-1/+1
|
* More egcs warning fixes:imp1999-04-251-2/+3
| | | | | | | | | | 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
* Compile -Wallarchie1998-12-071-2/+2
|
* Make 'y' command 8bit cleanache1998-04-291-2/+2
| | | | PR: 6458
* Remove local redefinition for err(). Add usage().charnier1997-08-111-18/+20
|
* Localize itache1996-08-111-2/+2
| | | | 8bit cleanup
* Merge various fixes from NetBSD. This will allow the WordPerfect forjkh1995-08-161-16/+18
| | | | SCO installation to run all the way through (some POSIX fixes).
* Remove trailing whitespace.rgrimes1995-05-301-5/+5
|
* Correct a bug in the P function: according to 7th edition UNIX (tm), thejmz1995-02-061-1/+1
| | | | | | | | | 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!)
* BSD 4.4 Lite Usr.bin Sourcesrgrimes1994-05-271-0/+629
OpenPOWER on IntegriCloud