Category : OS/2 Files
Archive   : GNUGREP.ZIP
Filename : GREP16.BUG

 
Output of file : GREP16.BUG contained in archive : GNUGREP.ZIP
From NewsServ!reseq!sol.ctr.columbia.edu!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!twinsun.COM!eggert Wed Jun 10 02:22:56 MESZ 1992
Article: 3020 of gnu.utils.bug
Path: NewsServ!reseq!sol.ctr.columbia.edu!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!twinsun.COM!eggert
From: [email protected] (Paul Eggert)
Newsgroups: gnu.utils.bug
Subject: grep 1.6 issues wrong error messages for some bad patterns
Message-ID: <[email protected]>
Date: 9 Jun 92 00:03:51 GMT
Sender: [email protected]
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 37
Approved: [email protected]

With the -w and -x options, grep 1.6 issues the wrong error messages
for some bad patterns. For example:

$ grep -x '\'
grep: Unbalanced (
$ egrep -x ')('
egrep: Unmatched \)

The problem is that the regular expression syntax is not being checked
at the proper point. Here is a patch.

*** old/grep.c Tue May 5 19:40:20 1992
--- new/grep.c Mon Jun 8 16:57:49 1992
***************
*** 724,729 ****
--- 724,732 ----
}
else
regexp_len = strlen(the_regexp);
+
+ if (regex_errmesg = re_compile_pattern(the_regexp, regexp_len, ®ex))
+ regerror(regex_errmesg);

if (whole_word || whole_line)
{
***************
*** 768,776 ****
else
regcompile(the_regexp, regexp_len, ®, 1);

-
- if (regex_errmesg = re_compile_pattern(the_regexp, regexp_len, ®ex))
- regerror(regex_errmesg);

/*
Find the longest metacharacter-free string which must occur in the
--- 771,776 ----


From NewsServ!reseq!sol.ctr.columbia.edu!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!twinsun.COM!eggert Wed Jun 10 02:22:27 MESZ 1992
Article: 3018 of gnu.utils.bug
Path: NewsServ!reseq!sol.ctr.columbia.edu!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!twinsun.COM!eggert
From: [email protected] (Paul Eggert)
Newsgroups: gnu.utils.bug
Subject: grep 1.6 -w silently overrides -x
Message-ID: <[email protected]>
Date: 9 Jun 92 00:14:36 GMT
Sender: [email protected]
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 86
Approved: [email protected]

In GNU grep 1.6, the -w option silently overrides the -x option.
But from the documentation, one would expect -w -x to cause the pattern
to match only if the match is a whole word _and_ a whole line.
For example, if the input is

a
a b c

then `grep -w -x a' should output just the first line `a';
but currently it outputs both lines.

Here is an (untested) patch.

*** old/grep.c Tue May 5 19:40:20 1992
--- new/grep.c Mon Jun 8 17:12:26 1992
***************
*** 734,766 ****
BUG: Using [A-Za-z_] is locale-dependent! */

char *n = malloc(regexp_len + 50);
! int i = 0;

#ifdef EGREP
if (whole_word)
! strcpy(n, "(^|[^A-Za-z_])(");
! else
! strcpy(n, "^(");
#else
/* Todo: Make *sure* this is the right syntax. Down with grep! */
if (whole_word)
! strcpy(n, "\\(^\\|[^A-Za-z_]\\)\\(");
! else
! strcpy(n, "^\\(");
#endif
i = strlen(n);
bcopy(the_regexp, n + i, regexp_len);
i += regexp_len;
#ifdef EGREP
if (whole_word)
! strcpy(n + i, ")([^A-Za-z_]|$)");
! else
! strcpy(n + i, ")$");
#else
if (whole_word)
! strcpy(n + i, "\\)\\([^A-Za-z_]\\|$\\)");
! else
! strcpy(n + i, "\\)$");
#endif
i += strlen(n + i);
regcompile(n, i, ®, 1);
--- 737,771 ----
BUG: Using [A-Za-z_] is locale-dependent! */

char *n = malloc(regexp_len + 50);
! int i;

+ n[0] = 0;
#ifdef EGREP
+ if (whole_line)
+ strcat(n, "^(");
if (whole_word)
! strcat(n, "(^|[^A-Za-z_])(");
#else
/* Todo: Make *sure* this is the right syntax. Down with grep! */
+ if (whole_line)
+ strcat(n, "^\\(");
if (whole_word)
! strcat(n, "\\(^\\|[^A-Za-z_]\\)\\(");
#endif
i = strlen(n);
bcopy(the_regexp, n + i, regexp_len);
i += regexp_len;
+ n[i] = 0;
#ifdef EGREP
if (whole_word)
! strcat(n + i, ")([^A-Za-z_]|$)");
! if (whole_line)
! strcat(n + i, ")$");
#else
if (whole_word)
! strcat(n + i, "\\)\\([^A-Za-z_]\\|$\\)");
! if (whole_line)
! strcat(n + i, "\\)$");
#endif
i += strlen(n + i);
regcompile(n, i, ®, 1);




  3 Responses to “Category : OS/2 Files
Archive   : GNUGREP.ZIP
Filename : GREP16.BUG

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/