On Fri, 2007-11-02 at 20:59 +0100, Marc Blumentritt wrote:
> 2.) There seems to be a bug in bb grep. I did this on my machine:
> hive ~ # busybox grep -Fo usbfs /proc/filesystems
> Segmentation fault
attatched patch should fix it (in svn). Should got to fixes-1.7.2 as
well.
while I was at it, I found another bug:
# grep -Fw usb /proc/filesystems
# busybox grep -Fw usb /proc/filesystems
nodev usbfs
but thats another story.
Index: libbb/lineedit.c
===================================================================
--- libbb/lineedit.c (revision 20355)
+++ libbb/lineedit.c (working copy)
@@ -1103,6 +1103,7 @@
if (!pwd_buf) {
pwd_buf = (char *)bb_msg_unknown;
}
+ fprintf(stderr, "DEBUG: prmt_ptr='%s'\n", prmt_ptr);
while (*prmt_ptr) {
pbuf = buf;
Index: findutils/grep.c
===================================================================
--- findutils/grep.c (revision 20355)
+++ findutils/grep.c (working copy)
@@ -174,12 +174,14 @@
while ((line = xmalloc_getline(file)) != NULL) {
llist_t *pattern_ptr = pattern_head;
- grep_list_data_t *gl;
linenum++;
found = 0;
while (pattern_ptr) {
+ grep_list_data_t *gl;
gl = (grep_list_data_t *)pattern_ptr->data;
+ regmatch.rm_so = 0;
+ regmatch.rm_eo = 0;
if (FGREP_FLAG) {
found |= (strstr(line, gl->pattern) != NULL);
} else {
@@ -187,8 +189,6 @@
gl->flg_mem_alocated_compiled |= COMPILED;
xregcomp(&(gl->preg), gl->pattern, reflags);
}
- regmatch.rm_so = 0;
- regmatch.rm_eo = 0;
if (regexec(&(gl->preg), line, 1, ®match, 0) == 0) {
if (!(option_mask32 & OPT_w))
found = 1;
@@ -274,8 +274,12 @@
print_n_lines_after = lines_after;
#endif
if (option_mask32 & OPT_o) {
+ char *p;
line[regmatch.rm_eo] = '\0';
- print_line(line + regmatch.rm_so, linenum, ':');
+ p = line + regmatch.rm_so;
+ if (option_mask32 & OPT_F)
+ p = ((grep_list_data_t *)pattern_ptr->data)->pattern;
+ print_line(p, linenum, ':');
} else {
print_line(line, linenum, ':');
}
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox