n62@np1.hep.nl (Klamer Schutte) (03/29/89)
(This bug is found on MINIX-ST; probably also resident on minix-pc???)
There was a bug in grep.c : in regexp.c (in libc.a) regexp() has 3 arguments;
in grep.c only the first 2 are used. This prevented grep from correctly
interpreting a regular expression starting with ^. Patch, enjoy!
Klamer Schutte (.signature at end)
----------------------------------------------------------------------------
*** grep.c.B Thu Mar 22 18:35:13 1989
--- grep.c Thu Mar 22 18:44:04 1989
***************
*** 104,124 ****
char buf[MAXLINE];
int lineno = 0;
while(getline(buf,MAXLINE) != NULL) {
char *cr = index(buf,'\n');
lineno++;
if(cr == 0) {
std_err("Line too long in ");
std_err(name == 0 ? "stdin":name);
} else
*cr = '\0';
! if(regexec(exp,buf)) {
if(pmflag)
pline(name,lineno,buf);
if(status != 2)
status = 0;
} else if(pnmflag)
pline(name,lineno,buf);
}
}
void regerror(s)
--- 104,128 ----
char buf[MAXLINE];
int lineno = 0;
+ int bol = 1, next_bol;
+
while(getline(buf,MAXLINE) != NULL) {
char *cr = index(buf,'\n');
lineno++;
+ next_bol = (int) cr;
if(cr == 0) {
std_err("Line too long in ");
std_err(name == 0 ? "stdin":name);
} else
*cr = '\0';
! if(regexec(exp,buf,bol)) {
if(pmflag)
pline(name,lineno,buf);
if(status != 2)
status = 0;
} else if(pnmflag)
pline(name,lineno,buf);
+ bol = next_bol;
}
}
void regerror(s)
--
________________________________________________________________________________
Klamer Schutte mcvax!nikhefh!n62 n62@nikhefh.hep.nl