On Sunday 04 November 2007 12:10, Marc Blumentritt wrote:
> > Try attached patch.
>
> It does not work on my system (s. attached file). I'm using
> busybox-1.7.2 on Gentoo. What could be wrong?
Try this one, it is rediffed against 1.7.2
--
vda
diff -urN busybox-1.7.2/findutils/grep.c busybox-1.7.2-grep/findutils/grep.c
--- busybox-1.7.2/findutils/grep.c 2007-09-03 12:48:54.000000000 +0100
+++ busybox-1.7.2-grep/findutils/grep.c 2007-11-04 14:08:43.000000000 +0000
@@ -154,14 +154,14 @@
while ((line = xmalloc_getline(file)) != NULL) {
llist_t *pattern_ptr = pattern_head;
- grep_list_data_t * gl;
+ grep_list_data_t *gl = gl; /* for gcc */
linenum++;
ret = 0;
while (pattern_ptr) {
gl = (grep_list_data_t *)pattern_ptr->data;
if (FGREP_FLAG) {
- ret = strstr(line, gl->pattern) != NULL;
+ ret |= (strstr(line, gl->pattern) != NULL);
} else {
/*
* test for a postitive-assertion match (regexec returns success (0)
@@ -255,8 +255,15 @@
print_n_lines_after = lines_after;
#endif
if (option_mask32 & OPT_o) {
- line[regmatch.rm_eo] = '\0';
- print_line(line + regmatch.rm_so, linenum, ':');
+ if (FGREP_FLAG) {
+ /* -Fo just prints the pattern
+ * (unless -v: -Fov doesnt print anything at all) */
+ if (ret)
+ print_line(gl->pattern, linenum, ':');
+ } else {
+ line[regmatch.rm_eo] = '\0';
+ print_line(line + regmatch.rm_so, linenum, ':');
+ }
} else {
print_line(line, linenum, ':');
}
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox