summaryrefslogtreecommitdiffstats
path: root/usr.bin/sed
Commit message (Collapse)AuthorAgeFilesLines
* Per the resolution of POSIX bug 0000779 (note 0002050) add support for using 'i'eadler2013-12-092-3/+4
| | | | | | | | as a case insensitive flag. PR: standards/184641 Requested by: David A. Wheeler <dwheeler@dwheeler.com> MFC After: 1 week
* sed: use getline() instead of fgetln().pfg2013-06-261-8/+11
| | | | | | | | | | | | | | In BSD, fgetln() available in libc but in Illumos the Solaris port had to include it internally. It also seems to have caused problems [1]. Aid portability by using getline() instead. Reference: https://www.illumos.org/issues/3820 [1] Submitted by: Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.com> Reviewed by: dds MFC after: 2 weeks
* Remove trailing whitespace per mdoc lint warningeadler2012-03-291-2/+2
| | | | | | | Disussed with: gavin No objection from: doc Approved by: joel MFC after: 3 days
* Reword '}' description to sound more clear.ache2011-10-291-1/+1
| | | | | Submitted by: dougb MFC after: 7 days
* Update '}' description to reflect reality (and POSIX)ache2011-10-281-1/+1
| | | | | | PR: 96236 Submitted by: "Andreas Kohn" <andreas@syndrom23.de> MFC after: 7 days
* sed: Try hard links to make -i target available continually.jilles2011-01-081-4/+21
| | | | | | | | | | | | | | | | | | | | | When creating a backup file, sed renamed the original before renaming the changed copy into place, leading to a short time when no file with the original name was present (usually only visible on SMP systems). Try creating the backup file using a hard link instead, avoiding this problem. If creating the hard link fails for any reason, fall back to the old rename method. When not creating a backup file, sed already renamed the changed copy onto the original. This remains unchanged. I am not adding the suppression of redundant fchown/fchmod to this commit, because FreeBSD appears to check this in the kernel (for msdosfs at least). PR: bin/153261 Submitted by: Pedro F. Giffuni Reviewed by: dds (older version) Obtained from: Illumos MFC after: 2 weeks
* Make -r mean exactly the same thing as -E for increased compatibilityimp2010-03-312-3/+8
| | | | | | with GNU sed. MFC after: 7 days
* Build usr.bin/ with WARNS=6 by default.ed2010-01-021-0/+2
| | | | Also add some missing $FreeBSD$ to keep svn happy.
* Revert most part of 200420 as requested, as more review and polish isdelphij2009-12-132-0/+8
| | | | needed.
* Remove unneeded header includes from usr.bin/ except contributed code.delphij2009-12-112-8/+0
| | | | Tested with: make universe
* IEEE Std 1003.1, 2004 Edition states:dds2009-09-201-2/+1
| | | | | | | | | | | | | "The escape sequence '\n' shall match a <newline> embedded in the pattern space." It is unclear whether this also applies to a \n embedded in a character class. Disable the existing handling of \n in a character class following Mac OS X, GNU sed version 4.1.5 with --posix, and SunOS 5.10 /usr/bin/sed. Pointed by: Marius Strobl Obtained from: Mac OS X
* Follow POSIX (IEEE Std 1003.1, 2004 Edition) in the implementationdds2009-09-201-9/+12
| | | | | | | | | | | of the y (translate) command. "If a backslash character is immediately followed by a backslash character in string1 or string2, the two backslash characters shall be counted as a single literal backslash character" Pointed by: Marius Strobl Obtained from: Mac OS X
* Allow [ to be used as a delimiter.dds2009-09-201-1/+1
| | | | | Pointed by: Marius Strobl Obtained from: Apple
* Bump the document date to reflect the recent address range enhancements.brian2009-05-251-1/+1
| | | | Suggested by: throdes
* Implement "addr1,+N" ranges - not dissimilar to grep's -A switch.brian2009-05-254-18/+39
| | | | | PR: 134856 Submitted by: Jeremie Le Hen - jeremie at le-hen dot org
* Fix the code to conform to the "or more" part of the following POSIXdds2008-11-111-1/+1
| | | | | | | | | | specification and regression test regress:25. "A function can be preceded by one or more '!' characters, in which case the function shall be applied if the addresses do not select the pattern space." MFC after: 2 weeks
* Add workaround for a back reference when no correspondinghrs2008-11-091-0/+8
| | | | | | | | | | | parenthesized subexpression is defined. For example, the following command line caused unexpected behavior like segmentation fault: % echo test | sed -e 's/test/\1/' PR: bin/126682 MFC after: 1 week
* Correct a silly typo I introduced: withing -> within.yar2008-09-011-1/+1
| | | | Noticed by: das
* Explicitly tell that one needs to start a context address with ayar2008-08-241-4/+11
| | | | | | | | | | | | | backslash if he/she wants to use a non-traditional delimiter, i.e., anything other than a slash. That is, /abc/ works as is, but xabcx needs to be spelled as \xabcx. Add appropriate markup. Bump Dd. Checked with: IEEE Std 1003.1, 2004 Edition MFC after: 3 days
* WARNS fixes:dwmalone2008-02-094-10/+12
| | | | | | | | | | 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
* Fix visibility of "inplace".dds2007-11-081-1/+1
| | | | Found by: CScout
* Before doing compile_re() which needs a parameter to identifydelphij2007-07-061-4/+4
| | | | | | | | | | | whether we should ignore case, determine the flag by calling compile_flags() first. Also, make sure that we obtain an initialized cmd->u.s buffer before processing further. We may want to refine this solution later, but for now, make the changes in order to unbreak world build after a sed(1) with rev. 1.29 of compile.c is installed. Approved by: re (hrs)
* Add case-insensitive matching to sed, using the 'I' flag, similarly to GNU sed.ssouhlal2007-07-043-27/+52
| | | | | | | | | For example, sed /foo/Id sed s/foo/bar/Ig Reviewed by: dds Approved by: re (hrs)
* 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-123-4/+18
| | | | | | | | 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)
* Don't forget to bump document date after changing the content.yar2007-04-211-1/+1
|
* Change the semantics of -i (in-place editing) so that it treatsyar2007-04-214-11/+83
| | | | | | | | | | | | | | | | | 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
* style(9):yar2007-04-061-1/+1
| | | | | | Use a single space before $FreeBSD$ to avoid terminal line overflow. Pointed out by: ru (The All-Seeing Eye)
* Add an important detail to paragraph 12: the range is reset only if itsyar2007-04-051-2/+3
| | | | second address is a line number.
* Reflect the change in rev. 1.44 of process.c.yar2007-04-051-4/+9
| | | | Add $FreeBSD$ to please commit_prep.pl.
* 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
|
* Test files repo-copied into tools/regression/usr.bin/sed and integrateddds2007-03-143-1098/+0
| | | | into the regression testing framework.
* 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
* The function inplace_edit() doesn't exist anymore, remove the prototype.stefanf2005-09-241-1/+0
| | | | Submitted by: Leonardo Chiquitto Filho
* Bug fix: a numeric flag specification in the substitute command woulddds2005-08-041-2/+8
| | | | | | | | cause the next substitute flag to be ignored. While working at it, detect and report overflows. Reported by: Jingsong Liu MFC after: 1 week
* Markup and wording fixes.ru2005-06-141-1/+1
| | | | Approved by: re (blanket)
* Add option -l, to make output line buffered.glebius2005-05-102-5/+11
| | | | | | PR: bin/78692 Submitted by: Eugene Grosbein MFC after: 2 weeks
* Remove unused variables.stefanf2005-04-091-2/+1
|
* Fix dubious C code construct.stefanf2005-03-091-1/+1
|
* Expand *n't contractions.ru2005-02-131-1/+1
|
* Include missing headers.stefanf2005-02-091-0/+1
|
* Added the EXIT STATUS section where appropriate.ru2005-01-171-1/+1
|
* Scheduled mdoc(7) sweep.ru2005-01-111-5/+3
|
* Per letter dated July 22, 1999 remove 3rd clause of Berkeley deriveddds2004-08-098-32/+0
| | | | | | software (original contributor). Reviewed by: imp
* Document the limitation that multibyte characters cannot be used astjr2004-07-171-1/+6
| | | | delimiters with the 's' and 'y' commands.
* Document the -E and -a options as being extensions.tjr2004-07-141-2/+5
|
OpenPOWER on IntegriCloud