summaryrefslogtreecommitdiffstats
path: root/usr.bin/sed/process.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Make sed's -i flag more compatible with what gsed does.martijn2018-11-141-2/+6
| | | | | | | | | | | - Reset the hold-space in between files - quit the editor as soon as a 'q' command is found - Make sure the temp-file is written back to the original file if we quit the editor temp-file not written back issue found by Time Chase. Lots of feedback from millert@ and schwarze@ OK millert@
* Fix sign compare warnings; OK martijn@millert2017-12-131-10/+10
|
* Remove unused-with-dead-store variable oldpsanl.tom2017-02-221-3/+1
| | | | | | From Daniel Cegielka - thanks ok jca@
* Nuke more whitespace caught in the headlights of "warning:"krw2017-01-211-6/+6
| | | | rectification.
* Split error() into error() and warning() so error() can be marked __dead tokrw2017-01-201-2/+1
| | | | | | appease gcc. ok procter@ deraadt@
* Fix an off by one error when no matches were found in a substitute.martijn2016-10-111-2/+2
| | | | | | By pfg@ from FreeBSD OK millert@ and otto@
* Make sed use the new REG_STARTEND | REG_NOTBOL combination. This fixes a beginmartijn2016-05-301-17/+24
| | | | | | | | | | of word mismatch as reported by jsg@. Discussed with otto@ and others early on, earlier version tested in ports build by aja@ OK millert@ Few readability tweaks and OK schwarze@
* Rename err() to error() to prevent confusion with the stdlib function.mmcc2015-10-261-12/+12
| | | | Discussed with jca@.
* fix eyesore whitespacejasper2015-07-201-6/+6
|
* figure out the linewidth at initialization, rather than latederaadt2015-07-191-19/+2
| | | | ok tedu miod
* add -i flag to sed to do in-place editing; mostly based on freebsdjasper2015-07-171-47/+74
| | | | feedback/ok deraadt@ millert@
* Convert many atoi() calls to strtonum(), adding range checks and failurederaadt2015-04-181-4/+6
| | | | | handling along the way. Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert
* correct multiplication idiom during xreallocarray, and expand appendnumderaadt2015-04-131-7/+9
| | | | | to size_t to avoid overflow after allocation success ok guenther doug
* Rework the pointer swap in the 'P' command to make the intentjsg2014-12-121-4/+5
| | | | | clearer and avoid a crash on 'g;P' found by Sebastien Marie with the afl fuzzer.
* sed has a xreallocarray(), but two n*s cases were not replacedderaadt2014-12-011-7/+7
|
* unsigned char for ctypederaadt2013-11-281-3/+4
| | | | ok krw okan
* Rewrite the main loop of the "sed s/..." command, to fix multipleschwarze2011-09-171-49/+44
| | | | | | | | | | | | | issues regarding the replacement of zero-length strings. This commit brings back rev. 1.16, but without the regression that forced the backout: No NUL bytes will be output now, not even when the input file lacks a trailing newline character and there is a zero-length match at the end. OK otto@ deraadt@; and naddy@ (who originally found the regression) checked that the regression is indeed fixed.
* Backout previous, naddy@ found the following regression:schwarze2011-07-261-43/+49
| | | | | | | | When the input does not end in a trailing newline character and there is an empty match at the end, the new code adds a spurious '\0' character. I have a fix, but otto@ prefers backout and full re-evaluation after release.
* Rewrite the main loop of the "sed s/..." command, shortening it by tenschwarze2011-07-241-49/+43
| | | | | | | | | | | | | | | lines and simplifying it by removing the switch statement implementing /g, /1, and /2 separately and repetitively. The idea to make the loop control variable slen, i.e. the length of the string remaining to be processed, signed, and stay in the loop even when slen == 0 (i.e. at the end of the string), lifted from FreeBSD by otto@. On i386, process.o shrinks by 440 bytes, and the sed binary by 23 bytes. This fixes multiple aspects of the replacement of multiple (/g) or specific (e.g. /2) instances of zero-length matches, both with BREs and EREs, both with and without a trailing newline character on the input. Feedback and OK otto@.
* rcsid[] and sccsid[] and copyright[] are essentially unmaintained (andderaadt2009-10-271-6/+1
| | | | | | | unmaintainable). these days, people use source. these id's do not provide any benefit, and do hurt the small install media (the 33,000 line diff is essentially mechanical) ok with the idea millert, ok dms
* The 'l' command should not encode newlines. Also document thatmillert2008-10-071-5/+5
| | | | backspace is escaped as \b. OK phessler@ and jmc@
* pretty. the comma operator should not be used to cram two statements intotedu2006-10-091-14/+15
| | | | an if without braces, or worse, into a return.
* prevent overflow, see freebsd r1.32. also, do nicer reallocs.tedu2003-11-071-9/+13
| | | | ok millert@ otto@
* mostly ansi cleanup; pval okderaadt2003-06-101-25/+12
|
* Remove the advertising clause in the UCB license which Berkeleymillert2003-06-031-7/+3
| | | | rescinded 22 July 1999. Proofed by myself and Theo.
* kill err(3) newlines; ok miod@, deraadt@jsyn2002-06-111-6/+6
|
* Fix sed(1) in the case where a last line is specified and hold spacemillert2002-04-151-5/+7
| | | | | | | | | | | | | | | 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 (or memory) 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. From Tim J. Robbins by way of FreeBSD
* Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.millert2002-02-161-8/+8
|
* kill more registersmpech2001-11-191-8/+8
| | | | millert@ ok
* make G newline if hold is emptyderaadt1999-06-061-2/+4
|
* make y command 8 bit clean; Elmar.Bartel@informatik.tu-muenchen.dederaadt1998-04-301-3/+3
|
* extra ()deraadt1997-09-111-5/+5
|
* rcsidderaadt1996-06-261-1/+3
|
* initial import of NetBSD treederaadt1995-10-181-0/+632