Commit Graph

83 Commits

Author SHA1 Message Date
tjr
7cab19d576 Make cspace()'s second argument const. Make `escapes' in lputs() const. 2002-07-08 06:00:55 +00:00
tjr
ae7a40f1aa 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
tjr
25aa3182cb Update another mention of <CR><CR> I missed the first time around (rev 1.2) 2002-07-04 05:16:19 +00:00
tjr
f3c503c6ca 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
tjr
110c2de07c 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
tjr
f71af381af 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
tjr
4922dd1ddf Sort sections, and refer to sed as a utility, not a function. 2002-06-25 08:36:19 +00:00
tjr
32bee004db 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
tjr
98aa149b31 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
tjr
2db3395cea 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
sobomax
9bb33f87d3 Kill superfluous blank line. 2002-06-17 08:21:53 +00:00
tjr
0588706f27 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
tjr
b7f83f53f9 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
sobomax
0c8f30b575 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
tjr
de5809df72 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
tjr
f8ee1d2d03 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
tjr
b72fd54413 Newlines are not escaped anymore. 2002-06-10 07:27:32 +00:00
tjr
aebd48afab Don't write escape newlines with `l' command (SUSv3) 2002-06-10 07:25:35 +00:00
tjr
77f74738b6 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
tjr
1162c6ee51 Wrap lines correctly for the `l' command. 2002-06-04 10:40:14 +00:00
tjr
096096d1a2 Document the fact that the `l' command uses the COLUMNS environment
variable (SUSv3)
2002-06-04 10:01:06 +00:00
tjr
86435d3331 Ignore COLUMNS environment variable if it is empty (SUSv3) 2002-06-04 10:00:08 +00:00
green
20552d4d83 Fix a bug in sed(1)'s "s" command wherein if an escape ("\" character)
was initiated at the last character of the line buffer, the Wrong
Thing was done and sed barfed by interpreting the following NUL byte
as a digit.  Instead, pull up the next buffer and record that the "\"
was last seen.
2002-06-01 13:25:47 +00:00
ru
d654861f5c mdoc(7) police: typo in .Dd. 2002-05-30 06:05:42 +00:00
tjr
74ff5f42c5 If a file argument cannot be processed, process the remaining ones
and exit non-zero (SUSv3)
2002-05-24 10:58:21 +00:00
trhodes
fa6c7efe3f More consistancy. file system > filesystem 2002-05-16 02:19:14 +00:00
green
957e7d4f00 o Clean up tmp file usage a little by using mkstemp(3) instead of
mktemp(3).  It would be amazingly unlikely, but the former method
  could result in a symlink attack.  A better solution would use
  ${TMPDIR}, though.
o Make sed not overwrite old backup files with no warning.
2002-05-14 23:15:42 +00:00
jmallett
3dc6de51a7 Oops, update usage() to have -i. 2002-05-07 23:33:44 +00:00
jmallett
9514d77a48 Add handling for any nil-length string passed to -i for the backup extension.
Add a note that this is kinda-sorta dangerous to the manual page.
2002-05-07 23:32:26 +00:00
jmallett
8c85827b13 Un-shadow the `fname' variable. 2002-05-07 23:06:47 +00:00
jmallett
d3d2092758 Add a -i option to sed(1) to do inplace editing, to give us an alternative to
Perl for such things.  The key difference to Perl is that a backup extension
*MUST* be specified, because on one hand it isn't recommended to have options
which optionally take a parameter, and on the other hand, it'd be slightly
unpleasent to implement proper handling for that.

The difference between this and the version posted to developers@ is that it
does handle multiple files in argv after the getopt(3) handling "correctly",
in that the inplace editing-specific code has been moved out to a function,
and that function is used beyond the first file in our linked list.

This option has been documented as FreeBSD-specific in the manpage.

Reviewed by:	developers@ (got feedback from: des, fanf, sobomax, roberto,
		obrien)
MFC after:	1 week
2002-05-07 18:32:18 +00:00
keramida
f4dad30bfd Remove duplicated text.
PR:		docs/37287
Submitted by:	Tony Finch <dot@dotat.at>
MFC after:	3 days
2002-04-21 14:48:47 +00:00
sobomax
08c080ac1d Fix an ages-old bug in sed(1), which resulted in the absolutely valid
substitution expressions in the form `s,[fooexp],[barexp],;...' treated
as invalid when the third `,' is (_POSIX2_LINE_MAX * N)-th character in
the line.

MFC after:	2 weeks
2002-04-12 19:46:05 +00:00
jmallett
b5ca094f22 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
2002-04-07 02:29:56 +00:00
jmallett
51d6548d5c 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
2002-04-05 05:40:20 +00:00
imp
0b20191705 remove __P 2002-03-22 01:42:45 +00:00
markm
31d81e4fbc Remove NO_WERRORs and WARNS=n's. To be revisited after GCC3. 2002-02-08 23:07:37 +00:00
markm
f7397edc4d WARNS=2 partial fix; use NO_WERROR to protect against some hard-to-fix warnings.
Use __FBSDID(), kill register keyword.
2001-12-12 23:20:16 +00:00
mikeh
571866fa14 Don't allocate a zero byte segment.
PR:		bin/11900
MFC after:	2 weeks
2001-11-08 16:47:05 +00:00
ru
bde8ec1b70 mdoc(7) police: utilize the new .Ex macro. 2001-08-15 09:09:47 +00:00
ru
4345758876 mdoc(7) police:
Avoid using parenthesis enclosure macros (.Pq and .Po/.Pc) with plain text.
Not only this slows down the mdoc(7) processing significantly, but it also
has an undesired (in this case) effect of disabling hyphenation within the
entire enclosed block.
2001-08-07 15:48:51 +00:00
obrien
6dc73139c0 Expand xmalloc in-place, along with xrealloc; which wasn't even ANSI in its
implementation.
2001-07-24 14:05:21 +00:00
ru
4048b83188 Don't leak memory when compiling text following the a', c' or `i' command.
Testcase:

echo FOO | sed "/FOO/c\\
`jot -b 'aaaa\' 500`"

Submitted by:	Max Khon <fjoe@newst.net>
2001-05-18 09:48:17 +00:00
ru
b5cd63f616 mdoc(7) police: use the default ``file ...'' feature of the .Ar macro. 2001-02-13 09:56:35 +00:00
ru
ffef081534 Prepare for mdoc(7)NG. 2001-01-16 09:39:23 +00:00
ru
e6cfc0711d Prepare for mdoc(7)NG. 2000-12-19 16:00:12 +00:00
ru
0d1334ca0c mdoc(7) police: use the new features of the Nm macro. 2000-11-20 19:21:22 +00:00
ru
a6f5d950d8 Avoid use of direct troff requests in mdoc(7) manual pages. 2000-11-10 17:46:15 +00:00
nsayer
5895ba5618 Small style fix '=' -> ' = ' 2000-05-11 20:15:16 +00:00
nsayer
277ddd560d Fix compatibility issue in sed. Do so by explicitely adding a
newline to the end of any -e argument.

PR: bin/18474
2000-05-11 17:01:52 +00:00