Manuel,
I rewrite bb_getopt_ulflags() function for more universal usage.
My version support now:
- options with arguments (optional arg as GNU extension also)
- complementaly and/or incomplementaly and/or incongruously and/or list
options
- long_opt (all applets may have long option, add supporting is trivial)
This realisation full compatibile from your version.
Code size grow 480 bytes, but only coreutils/* over compensate this size
after using new function. Last patch reduced over 800 bytes and not full
applied to all. "mkdir" and "mv" applets have long_opt now for demonstrate
trivial addition support long_opt with usage new bb_getopt_ulflags().
Complementaly and/or incomplementaly and/or incongruously and/or list options
logic is not trivial, but new "cut" and "grep" applets using this logic
for examples with full demostrating. New "grep" applet reduced over 300
bytes.
Mark,
Also. I removed bug from "grep" applet.
$ echo a b | busybox grep -e a b
a b
a b
But right is printing one only.
--w
vodz
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
- adds case-insensitive matching in sed s/// epxressions
- consolodates common regcomp code in grep & sed into bb_regcomp and put in
utility.c
- cleans up a bunch of cruft
However, the case of
grep foo$ file
didn't work, due to a problem with the flags used in regular expression
compilation. The attached patch fixes this problem.
---patch-------
Index: grep.c
===================================================================
RCS file: /var/cvs/busybox/grep.c,v
retrieving revision 1.30
diff -u -r1.30 grep.c
--- grep.c 2000/07/04 22:17:01 1.30
+++ grep.c 2000/07/10 08:57:04
@@ -141,8 +141,10 @@
if (argv[optind] == NULL)
usage(grep_usage);
- /* compile the regular expression */
- reflags = REG_NOSUB; /* we're not going to mess with sub-expressions
*/
+ /* compile the regular expression
+ * we're not going to mess with sub-expressions, and we need to
+ * treat newlines right. */
+ reflags = REG_NOSUB | REG_NEWLINE;
if (ignore_case)
reflags |= REG_ICASE;
if ((ret = regcomp(®ex, argv[optind], reflags)) != 0) {
---patch-------
Thanks, Matt, it works great.