Commit Graph

112 Commits

Author SHA1 Message Date
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
Tim J. Robbins
e4d0177f50 Document the limitation that multibyte characters cannot be used as
delimiters with the 's' and 'y' commands.
2004-07-17 03:37:31 +00:00
Tim J. Robbins
220d8b581a Document the -E and -a options as being extensions. 2004-07-14 10:37:21 +00:00
Tim J. Robbins
8b086367a0 Update BUGS section to reflect current state of multibyte character support. 2004-07-14 10:33:29 +00:00
Tim J. Robbins
81a8648adb Make the 'y' (translate) command aware of multibyte characters. 2004-07-14 10:06:22 +00:00
Tim J. Robbins
b4828720f7 Overhaul lputs() to deal with multibyte characters, characters that take
up more than one column position, and null bytes.
2004-07-13 04:35:43 +00:00
Tim J. Robbins
4f45d81178 Document missing multibyte character support in utilities specified
by POSIX.
2004-07-03 01:28:21 +00:00
Ruslan Ermilov
6a3e8b0adc Mechanically kill hard sentence breaks. 2004-07-02 22:22:35 +00:00
Ruslan Ermilov
d37ea99837 Removed trailing whitespace. 2004-07-02 19:07:33 +00:00
Brian Somers
7bbdbe1482 Plug a file descriptor leak.
When sed is asked to inline-edit files, it forgets to close the temporary
file and runs out of descriptors for long command lines (assuming you reset
kern.maxfilesperproc to something sane that's less than the number of files
passed to sed).
2004-06-03 22:33:50 +00:00
Sean Kelly
528d980cc0 A new version that does exponents and lots of other neat things. Update
from the original author of math.sed.

Submitted by:	K S Braunsdorf <sed@ksb.npcguild.org>
2004-05-01 02:15:58 +00:00
Philippe Charnier
ca802a8abe Avoid using .Nm at the start of the sentence. 2004-01-04 15:33:06 +00:00
Dag-Erling Smørgrav
591c337e01 Fix the case where the file is not in the current directory.
Discovered by:	Vladimir Kravchenko <jimson@mostcom.ru>
Pointy hat to:	des
2003-11-04 22:39:25 +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
Dag-Erling Smørgrav
9cde9a2e85 Whitespace cleanup 2003-11-04 12:16:47 +00:00
Dag-Erling Smørgrav
e6478125c8 ANSIfy 2003-11-04 12:15:20 +00:00
Dag-Erling Smørgrav
9df25dda8c Correct style bugs in the in-place editing code. 2003-11-04 12:07:09 +00:00
Tim J. Robbins
ce20a8e9be 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
2003-11-02 23:20:24 +00:00
Diomidis Spinellis
b6059c5c01 Fixed .Nm element, updated HISTORY section, added AUTHORS section.
Reviewed by:	schweikh (mentor)
MFC after:	2 weeks
2003-07-22 19:23:45 +00:00
Diomidis Spinellis
37c94e1d78 Test 8.16 in sed.test tests the ability of a sed to handle an empty
regular expression as the first argument to a substitute command. If
used to test a sed which (erroneously) evaluates this at translation
time rather than at execution time, the bugged sed is put into an
infinite loop. This mode of failure seems excessive. Such a failing
sed is the Free Software Foundation's sed 3.02.

The specific test was also not being executed for the BSD sed.

Both problems are now fixed.

PR:		misc/25585
Submitted by:	Walter Briscoe <w.briscoe@ponl.com>
Approved by:	schweikh (mentor)
MFC after:	2 weeks
2003-07-22 19:22:08 +00:00
Tony Finch
c2b9b6eba8 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
2003-06-05 12:10:19 +00:00
Tony Finch
2f17b7e279 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
2003-06-04 15:31:55 +00:00
Jens Schweikhardt
9d5abbddbf Correct typos, mostly s/ a / an / where appropriate. Some whitespace cleanup,
especially in troff files.
2003-01-01 18:49:04 +00:00
Ruslan Ermilov
06e482e60a mdoc(7) police: markup polishing.
Approved by:	re
2002-11-26 17:33:37 +00:00
Eric Melville
b81df0819d Initialize a variable in order to fix when faced with picky compilers.
Sponsored by:	Apple
2002-09-20 19:40:23 +00:00
Tim J. Robbins
13ee49d316 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
2002-08-11 09:53:44 +00:00
Tony Finch
d1691a2ff6 Fix some bugs in in-place editing:
(1) errors from freopen were not reported correctly
(2) large files were not handled correctly
(3) read-only files broke things

MFC after:	1 week
2002-07-30 19:42:18 +00:00
Tim J. Robbins
0467aed3c9 Ignore leading semicolons on commands; required by SUSv3.
Obtained from:	NetBSD (kleink, Aymeric Vincent)
2002-07-30 14:07:30 +00:00
Mark Murray
8bd89d7e04 s/inline/__inline/ 2002-07-19 14:12:27 +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
05018c64fd Silence WARNS=4 by passing a non-const buffer to regerror(). Since it
doesn't actually use the buffer when errbuf_size == 0, pass NULL.
2002-07-08 05:36:24 +00:00
Tim J. Robbins
54411faf6f Update another mention of <CR><CR> I missed the first time around (rev 1.2) 2002-07-04 05:16:19 +00:00
Tim J. Robbins
bfed7b6485 Note that two carriage returns aren't required after entering the
initial setup anymore (since process.c rev. 1.25). Add $FreeBSD$.

MFC after:	2 weeks
2002-07-03 14:42:53 +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
Tim J. Robbins
5a3232258e 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
2002-07-03 14:32:43 +00:00
Tim J. Robbins
42676968c6 Sort sections, and refer to sed as a utility, not a function. 2002-06-25 08:36:19 +00:00
Tim J. Robbins
d1a1392d8f 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>
2002-06-24 11:24:02 +00:00
Tim J. Robbins
5953156dca Now that the pattern space contains no trailing newline, modify the `l'
command's output so it's the same as what SUSv3 specifies.
2002-06-22 03:00:52 +00:00
Tim J. Robbins
ed92199d30 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
2002-06-22 01:42:26 +00:00
Maxim Sobolev
33bad4f17d Kill superfluous blank line. 2002-06-17 08:21:53 +00:00
Tim J. Robbins
254fac850d Correct the handling of (for example) the N command by only zeroing the
input space in mf_fgets() if we reach the end of all input files.
2002-06-16 08:44:39 +00:00
Tim J. Robbins
6689fb2bbc Exit with non-zero status if an input file can not be opened. This was
broken by rev. 1.22.
2002-06-14 02:20:05 +00:00
Maxim Sobolev
8701af62ee Fix one serious bug and one potential problem with in-place editing code:
- original version of code worked incorrectly when more than one
  input files were specified - it was moving the last line from the 1st file
  to be the first line of the 2nd, last line of the 2nd to be the first
  line of the 3rd and so on;

- use mmap()->write() to create temporary file instead of
  malloc()->read()->write(), which was not only slower, but also did not
  bother to free allocated memory once backup file was created, potentially
  leading to memory exhausting when regex is applied to a big file or a large
  number of small ones.
2002-06-14 01:28:52 +00:00
Tim J. Robbins
e7cc3a2191 Refer to environ(7) for description of COLUMNS instead of describing it
in-line. Document effects of locale environment variables in the same way.
2002-06-10 07:55:13 +00:00
Tim J. Robbins
1fa600e8fe The 10 occurrence limit for the `s' command documented here has not existed
for a very long time (or never did exist).
2002-06-10 07:44:04 +00:00
Tim J. Robbins
2ef53777fd Newlines are not escaped anymore. 2002-06-10 07:27:32 +00:00
Tim J. Robbins
e307a7a172 Don't write escape newlines with `l' command (SUSv3) 2002-06-10 07:25:35 +00:00
Tim J. Robbins
03fef72fe9 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.
2002-06-10 06:06:20 +00:00
Tim J. Robbins
d1ccc822a5 Wrap lines correctly for the `l' command. 2002-06-04 10:40:14 +00:00
Tim J. Robbins
30e9580eca Document the fact that the `l' command uses the COLUMNS environment
variable (SUSv3)
2002-06-04 10:01:06 +00:00