Glenn L McGrath
6e5687abc3
A test and fix for the sed 'n' command
2003-09-15 06:12:53 +00:00
Glenn L McGrath
73116311e5
Fix for the sed-append-next-line test
2003-09-15 05:42:05 +00:00
Glenn L McGrath
640c1f547f
Fix recursion problem
2003-09-15 04:55:29 +00:00
Glenn L McGrath
294d113adb
Memory cleanups and fix for echo "foo" | sed 's/foo/bar/;H;q'
2003-09-14 16:28:08 +00:00
Glenn L McGrath
8417c8c38b
Cleanup memory usage
2003-09-14 15:24:18 +00:00
Glenn L McGrath
edc388cf4e
The previous fix for 's/a/1/;s/b/2/;t one;p;:one;p' broke the case of
...
echo fooba | ./busybox sed -n 's/foo//;s/bar/found/p'
I really need to start adding these tests to the testsuite.
keep the substituted and altered flags seperate
2003-09-14 08:52:53 +00:00
Glenn L McGrath
3fe475677a
Preserve substitution flag value within the current line.
...
Fixed the following testcase
# cat strings |./busybox sed -n -f test3.sed
1
1
2
c
c
# cat strings
a
b
c
2003-09-14 07:59:28 +00:00
Glenn L McGrath
f4523562b6
Fix branching commands.
...
If a label isnt specified, jump to end of script, not the last command
in the script.
Print an error and exit if you try and jump to a non-existant label
Works for the following testcase
# cat strings
a
b
c
d
e
f
g
# cat strings | ./busybox sed -n '/d/b;p'
a
b
c
e
f
g
2003-09-14 06:01:14 +00:00
Glenn L McGrath
8aac05bfe5
Patch from Rob Landley
...
Fixed a memory leak in add_cmd/add_cmd_str by moving the allocation
of sed_cmd down to where it's actually first needed.
In get_address, if index_of_next_unescaped_regexp_delim ever failed, we
wouldn't notice because the return value was added to idx, which was
already guaranteed to be > 0. (This is buried in the changes made when
I redid get_address to be based on pointer arithmetic, because all the tests
were gratuitously dereferencing with a constant zero, which wasn't obvious.)
Comment in parse_regex_delim was wrong: 's' and 'y' both call it.
The reason "sed_cmd->num_backrefs = 0;" isn't needed is that sed_cmd was
allocated with cmalloc, which zeroes memory.
Different handling of space after \ in i...
Different handling of pattern "s/a/b s/c/d"
Cool, resursive reads don't cause a crash. :)
Fixed "sed -f blah filename - < filename" since GNU sed was handling
both - and filenames on the same line. (You can even list - more than
once, although it's immediate EOF...)
2003-09-14 04:06:12 +00:00
Glenn L McGrath
7c59a83a77
Stupid typo
2003-09-14 02:37:46 +00:00
Glenn L McGrath
4dc1d25a30
Fix some memory allocation problems
2003-09-14 01:25:31 +00:00
Glenn L McGrath
f36635cec6
Fix the following testcase by disabling global substitution if the regex
...
is anchored to the start of line, there can be only one subst.
echo "aah" | sed 's/^a/b/g'
2003-09-13 15:12:22 +00:00
Glenn L McGrath
c18ce373a2
Fix the following testcase by storing the state of the adress match with
...
the command.
# cat strings
a
b
c
d
e
f
g
# ./busybox sed '1,2d;4,$d' <strings
c
# ./busybox sed '4,$d;1,2d' <strings
# sed '4,$d;1,2d' <strings
c
# sed '1,2d;4,$d' <strings
c
2003-09-13 06:57:39 +00:00
Glenn L McGrath
9b04f1841e
Fix the substitution print subcommand, it should only print if its
...
own substitution matched, not previous ones.
e.g
echo fooba | sed -n 's/foo//;s/bar/found/p'
shouldnt print anything
2003-08-30 04:35:07 +00:00
Glenn L McGrath
91e1978ff0
New commands, 'G' and 'H'
2003-04-26 07:40:07 +00:00
Glenn L McGrath
fc4cb4dbb5
Fix logic error in grouped commands
2003-04-12 16:10:42 +00:00
Glenn L McGrath
d4185b0e15
Fix up indenting
2003-04-11 17:10:23 +00:00
Glenn L McGrath
d7fe39b587
Really fix the 'r' command
2003-04-09 15:52:32 +00:00
Glenn L McGrath
d87a7ac269
Fix the sed 'r' command
2003-04-09 15:26:14 +00:00
Glenn L McGrath
2410386611
fix substitution when replacing with &, we shouldnt check for an escape charcter. Its already been taken care of _somewhere_ else
2003-04-09 07:51:43 +00:00
Glenn L McGrath
bd9b32bc0d
Label ends at a newline, update comments, rename linked list field
2003-04-09 01:43:54 +00:00
Glenn L McGrath
8d6395d41a
Run through indent
2003-04-08 11:56:11 +00:00
Glenn L McGrath
c1d95076f0
Fixes block commands to correctly identify end of block, recognise the #n directive, fix substitue command when regex isnt specified
2003-04-08 06:42:45 +00:00
Glenn L McGrath
7ce9e247f0
Add hold space commands 'g', 'h', 'x'
2003-04-07 16:04:14 +00:00
Glenn L McGrath
c6adada158
Rename "line" to pattern_space to be more descriptive and closer to the POSIX description
2003-04-07 12:24:44 +00:00
Glenn L McGrath
9a52bb6878
Group common string
2003-03-30 09:38:40 +00:00
Glenn L McGrath
30b47df86b
Small fix for sed 'y' command
2003-03-30 08:40:09 +00:00
Glenn L McGrath
f01b46d7dd
sed 'y' command, simplify some other code
2003-03-30 08:02:18 +00:00
Glenn L McGrath
0c51832b60
Experimental support for embeded newline. (im evil)
...
Fix segfault when using 'N' with an odd number of lines.
2003-03-30 03:41:53 +00:00
Glenn L McGrath
a0f0f0cf76
Still fine tunning the printing of the substitute command
2003-03-28 14:11:34 +00:00
Glenn L McGrath
595a6a4199
sed 't' branching command
2003-03-28 08:36:52 +00:00
Glenn L McGrath
ccd43a8301
Fix sed 's' command's 'p' flag, so it can print line twice
2003-03-28 07:44:03 +00:00
Glenn L McGrath
b08e3e8c2e
fix q command
2003-03-28 04:57:52 +00:00
Glenn L McGrath
961c6c19da
Add basic branching support, sed ':' and 'b' commands
2003-03-28 04:43:39 +00:00
Glenn L McGrath
56c633c139
make sed cleanup use linked list
2003-03-28 04:23:23 +00:00
Glenn L McGrath
c949bfa555
Use a linked list for sed commands in preparation for branching support
2003-03-28 03:53:31 +00:00
Manuel Novoa III
cad5364599
Major coreutils update.
2003-03-19 09:13:01 +00:00
Glenn L McGrath
e01f9662a5
Match newlines, this fixes matching of ^ or $ when there is a '\n' in the pattern being matched. This fixes cases when the N command is used.
2003-03-18 08:37:57 +00:00
Glenn L McGrath
2971ef1730
Fix a bug that corrupted the string followed commands that had no arguments ( Closes #1304 )
2003-03-18 01:19:23 +00:00
Glenn L McGrath
4157a8a71e
fix n, add N, P
2003-03-10 04:12:35 +00:00
Glenn L McGrath
ff724fb076
add the 'n' command
2003-03-10 02:56:56 +00:00
Glenn L McGrath
bed4033e96
Add the q (quit) option
2003-03-10 02:21:14 +00:00
Glenn L McGrath
f3bd7c4631
Fix a delimiter matching bug i introduced.
2003-03-09 15:40:40 +00:00
Glenn L McGrath
f50ce3135f
Support grouped commands, i.e. {cmd1;cmd2}
2003-03-09 15:12:24 +00:00
Glenn L McGrath
4c6523a90b
alloc array for commands, use string ptr in parse_command_string()
2003-03-09 11:06:38 +00:00
Glenn L McGrath
e7a8bc949b
use typedef for struct sed_cmd
2003-03-09 10:23:57 +00:00
Glenn L McGrath
1fb446795d
redo get_addres(). save some space. possible fix a bug where the command might be set to 0 if no second address is given. dont parse sed_cmd struct to get_address, we only need the delim field.
2003-03-09 08:44:49 +00:00
Glenn L McGrath
2f8a401772
Woops, remove the code i didnt mean to commit
2003-03-09 02:44:49 +00:00
Glenn L McGrath
d5eadea970
Mention the opengroup sed reference, add a check which is disabled at present.
2003-03-09 02:39:29 +00:00
Glenn L McGrath
505bd0f15a
Fix matching for the $ address (last line)
2003-03-08 05:21:02 +00:00
Glenn L McGrath
0a65e190f4
Support the '=' command
2002-12-23 10:16:12 +00:00
Aaron Lehmann
a170e1c858
Change if(x)free(x); to free(x);
2002-11-28 11:27:31 +00:00
Robert Griebl
00f5ecb141
Somehow I applied an old patch for the last commit - this one works now:
...
- Added \CregexC support to sed (sed testsuite reported no errors, btw)
2002-08-06 23:13:31 +00:00
Robert Griebl
7940147e25
Added the \CregexpC syntax as an alternative for /regexp/ (like GNU sed)
2002-08-06 21:07:17 +00:00
Eric Andersen
2276d83639
Fixup warnings and undefined operations that show up in gcc-3.1
...
-Erik
2002-07-11 11:11:56 +00:00
Robert Griebl
47abc49c4a
Patch from Simon Krahnke:
...
I wrote a patch for busybox for our company's (www.lisa.de)
private use. [...] To sed it adds the '!'-inversion of addresses.
2002-06-11 23:43:27 +00:00
Matt Kraai
5c69cd84ff
* editors/sed.c (process_file): Stop processing deleted lines.
...
* testsuite/sed/sed-does-not-substitute-in-delete-line: New.
2002-04-01 16:17:37 +00:00
Matt Kraai
9eaf059d28
* editors/sed.c (parse_cmd_str): Remove redundant code to skip initial
...
whitespace.
2002-01-03 21:19:19 +00:00
Matt Kraai
5ed78adca5
* editors/sed.c (parse_edit_cmd): Rewrite.
...
* testsuite/sed/sed-splits-edit-commands-on-command-line: New.
2002-01-03 21:12:34 +00:00
Matt Kraai
d21735de2d
* editors/sed.c (parse_edit_command): Require a newline after the backslash
...
after an edit command.
* testsuite/sed/sed-requires-newline-after-edit-command: New.
2002-01-02 17:56:38 +00:00
Matt Kraai
70624846fd
Ignore blanks before the first address and before the command.
2001-12-21 16:04:12 +00:00
Matt Kraai
0c390a76fe
Eliminate warning.
2001-11-20 16:00:19 +00:00
Eric Andersen
9c6b5fcb0a
Minor warning cleanups
2001-11-17 07:23:46 +00:00
Matt Kraai
c8227639db
Change strdup calls to xstrdup (patch from Steve Merrifield).
2001-11-12 16:57:27 +00:00
Matt Kraai
a5f09c668e
Use fopen wrapper.
2001-11-12 16:44:55 +00:00
Eric Andersen
c52a6b0f10
|2001-10-08 Rodney Brown <rbrown64@csc.com.au>
...
|
| * editors/sed.c: Fix multiline [aic] commands. Make # an endline
| comment for compatibility. Codespace reduction.
| * tests/testcases: Cope with move to subdirectories.
| * testsuite/sed/sed-aic-commands: Add.
|
| text data bss dec hex filename
| 3772 16 0 3788 ecc editors/sed.o
| 4516 16 0 4532 11b4 editors/sed.o.bu
2001-11-10 10:49:42 +00:00
Eric Andersen
bdfd0d78bc
Major rework of the directory structure and the entire build system.
...
-Erik
2001-10-24 05:00:29 +00:00
Matt Kraai
8470b9a85c
Fix empty line substitutions (noted by Joshua Hudson).
2001-10-23 21:12:07 +00:00
Matt Kraai
a0065d5955
Fix s/[/]// handling (noted by Dumas Patrice).
2001-08-24 14:45:50 +00:00
Eric Andersen
b76cb68979
A patch from Shu-Hao Chang <shuhao_chang@trend.com.tw> to
...
fixed sed handling of multiple -e commands
2001-08-22 05:58:16 +00:00
Matt Kraai
a3e4f455ac
Fix a problem with unsatisfied backrefs (noted by Martin Bene).
2001-08-20 21:21:06 +00:00
Matt Kraai
547e102082
Preserve whether or not the line was previously altered when running a
...
subst command (discovery and patch by Jim Gleason).
2001-07-30 14:05:58 +00:00
Matt Kraai
5009f90ea2
Removed obsolete function, strdup_substr.
2001-07-05 19:00:47 +00:00
Matt Kraai
ceeff73819
Rewrote mkdir (and touched lots of things in the process).
2001-06-21 19:41:37 +00:00
Matt Kraai
02c40a72b8
Always apply commands with no specified range.
2001-06-21 13:57:51 +00:00
Mark Whitley
0915c4b985
- Fixed bug where you couldn't mix line number and regexes in two-address cmds
...
- Fixed bug where you couldn't use two addresses for a 'c' cmd
- Moved the do_sed_cmd function into process_file to simplify some things
- Reduced a buncha lines of code in the process
2001-06-11 23:50:06 +00:00
Matt Kraai
6e9e136fcb
Use safe_strncpy.
2001-05-27 14:11:52 +00:00
Eric Andersen
77d9268892
Patch from larry to fix some grammar errors.
2001-05-23 20:32:09 +00:00
Matt Kraai
233817437d
Always print a newline after a matching substitution.
2001-05-17 01:02:58 +00:00
Mark Whitley
d928accbbd
...Need to print just a few more newlines.
2001-05-14 20:44:26 +00:00
Mark Whitley
dd527d3c62
...And now that we're chomping lines, we need to re-add the newline later...
2001-05-14 19:53:08 +00:00
Mark Whitley
9de2659264
We will chomp() lines so REG_NEWLINE does not break stuff. Thanks, Matt.
2001-05-14 19:44:44 +00:00
Mark Whitley
452cc1f293
Added REG_NEWLINE as cflags to xregcomp for normal addresses so EOL $ will work
2001-05-14 19:23:02 +00:00
Mark Whitley
1f3b9f297e
Added support for 'r' command in sed.
2001-05-11 22:27:13 +00:00
Mark Whitley
56c14a6473
Fixed a buglet where an extra newline was being added after an insert command
...
in some cases.
2001-04-20 23:41:44 +00:00
Mark Whitley
497ef46587
Made a correction to a bad test expression. Props to Larry Doolittle for
...
spotting this one.
2001-04-20 23:27:17 +00:00
Mark Whitley
af633757d3
Applied patch from Anthony Towns that he posted to Debian bug tracking.
2001-03-26 16:47:57 +00:00
Mark Whitley
038c8eb5a9
Applied patch from Erik Habbinga to fix a problem with an uninitialized
...
substitution delimiter.
2001-03-14 21:11:49 +00:00
Eric Andersen
b50da53e0c
Get rid of long stale usage message code.
...
-Erik
2001-02-17 16:52:35 +00:00
Eric Andersen
67991cf824
This patch, put together by Manuel Novoa III, is a merge of work
...
done by Evin Robertson (bug#1105) and work from Manuel to make
usage messages occupy less space and simplify how usage messages
are displayed.
2001-02-14 21:23:06 +00:00
Matt Kraai
05e782ddd3
Fix wget error message and add (and use) chomp library function.
2001-02-01 16:49:30 +00:00
Matt Kraai
dd19c69904
Removed trailing \n from error_msg{,_and_die} messages.
2001-01-31 19:00:21 +00:00
Eric Andersen
8ec10a9483
Fix up copyright msgs. Bump version to 0.49 in preparation for
...
a release. Update the website with release details.
-Erik
2001-01-27 09:33:39 +00:00
Eric Andersen
ed3ef50c23
Fix header file usage -- there were many unnecessary header files included in
...
busybox.h which slowed compiles. I left only what was needed and then fixed up
all the apps to include their own header files. I also fixed naming for pwd.h
and grp.h functions. Tested to compile and run with libc5, glibc, and uClibc.
-Erik
2001-01-27 08:24:39 +00:00
Mark Whitley
6c6ea6cba2
Changed email address to codepoet.org, updated list of applets / docs I
...
maintain in AUTHORS.
2001-01-04 22:21:13 +00:00
Eric Andersen
28b3c53f0d
I just whipped up support for arbitrary regex delimiters, so
...
now things such as
$ echo foo | sed 'sxfooxb\arx'
bar
will work as expected (and so doogie can stop complaining).
-Erik
2001-01-02 11:01:31 +00:00
Matt Kraai
a9819b2908
Use busybox error handling functions wherever possible.
2000-12-22 01:48:07 +00:00
Matt Kraai
1fa1adea2a
Change calls to error_msg.* and strerror to use perror_msg.*.
2000-12-18 03:57:16 +00:00
Mark Whitley
f57c944e09
Changed names of functions in utility.c and all affected files, to make
...
compliant with the style guide. Everybody rebuild your tags file!
2000-12-07 19:56:48 +00:00
Eric Andersen
f61caf0411
Remove unneeded junk
2000-11-14 20:31:45 +00:00