public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
* A patch for regex.c
@ 2000-03-08 14:03 H . J . Lu
  0 siblings, 0 replies; 3+ messages in thread
From: H . J . Lu @ 2000-03-08 14:03 UTC (permalink / raw)
  To: GNU C Library

I am enclosing testcase here. According to regex.h,

/* If this bit is set, either \{...\} or {...} defines an
     interval, depending on RE_NO_BK_BRACES.
   If not set, \{, \}, {, and } are literals.  */
#define RE_INTERVALS (RE_HAT_LISTS_NOT_NEWLINE << 1)

/* If this bit is set, then `{...}' defines an interval, and \{ and \}
     are literals.
  If not set, then `\{...\}' defines an interval.  */
#define RE_NO_BK_BRACES (RE_NEWLINE_ALT << 1)

When RE_INTERVALS is set and RE_NO_BK_BRACES is not set, \{...\}
define an interval.

Did I miss something?

H.J.
----
#include <stdio.h>
#include <regex.h>

int
main ()
{
  static struct re_pattern_buffer regex;
  const char *s;
  re_set_syntax (RE_SYNTAX_POSIX_EGREP);
  printf ("syntax: RE_NO_BK_BRACES: %d, RE_INTERVALS: %d\n",
	  re_syntax_options & RE_NO_BK_BRACES,
	  re_syntax_options & RE_INTERVALS);
  s = re_compile_pattern ("\\{1", 2, &regex);
  printf ("\\{1: %s\n", s ? "FAIL" : "PASS");
  s = re_compile_pattern ("{1", 2, &regex);
  printf ("{1: %s\n", s ? "PASS" : "FAIL");
  re_syntax_options &= ~RE_NO_BK_BRACES;
  printf ("syntax: RE_NO_BK_BRACES: %d, RE_INTERVALS: %d\n",
	  re_syntax_options & RE_NO_BK_BRACES,
	  re_syntax_options & RE_INTERVALS);
  s = re_compile_pattern ("\\{1", 2, &regex);
  printf ("\\{1: %s\n", s ? "PASS" : "FAIL");
  s = re_compile_pattern ("{1", 2, &regex);
  printf ("{1: %s\n", s ? "FAIL" : "PASS");
  return 0;
}
----
-- 
H.J. Lu (hjl@gnu.org)
---
2000-03-08  H.J. Lu  <hjl@gnu.org>

	* posix/regex.c (regex_compile): Correctly handle "\{" when
	the RE_INTERVALS is set and the RE_NO_BK_BRACES bit is not set.

Index: posix/regex.c
===================================================================
RCS file: /work/cvs/gnu/glibc-2.1/posix/regex.c,v
retrieving revision 1.1.1.32
diff -u -p -r1.1.1.32 regex.c
--- posix/regex.c	2000/02/24 18:05:37	1.1.1.32
+++ posix/regex.c	2000/03/08 21:26:58
@@ -2604,8 +2604,7 @@ regex_compile (pattern, size, syntax, bu
               if (!(syntax & RE_INTERVALS)
                      /* If we're at `\{' and it's not the open-interval
                         operator.  */
-                  || ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES))
-                  || (p - 2 == pattern  &&  p == pend))
+                  || (syntax & RE_NO_BK_BRACES))
                 goto normal_backslash;
 
             handle_interval:

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: A patch for regex.c
  2000-07-13 13:42 H . J . Lu
@ 2000-08-01 17:26 ` Ulrich Drepper
  0 siblings, 0 replies; 3+ messages in thread
From: Ulrich Drepper @ 2000-08-01 17:26 UTC (permalink / raw)
  To: H . J . Lu; +Cc: GNU C Library

"H . J . Lu" <hjl@valinux.com> writes:

> 2000-07-13  H.J. Lu  <hjl@gnu.org>
> 
> 	* posix/regex.c (re_max_failures): Set to 4000.

I've applied this patch for now though I'm sure we'll get complains
from some people.  The problem is that a threaded application using
regex will run into stack limit problems without it.  Maybe we'll lift
the limit once the stack handling is dynamic or the regex functions
are rewritten.

-- 
---------------.                          ,-.   1325 Chesapeake Terrace
Ulrich Drepper  \    ,-------------------'   \  Sunnyvale, CA 94089 USA
Red Hat          `--' drepper at redhat.com   `------------------------

^ permalink raw reply	[flat|nested] 3+ messages in thread

* A patch for regex.c
@ 2000-07-13 13:42 H . J . Lu
  2000-08-01 17:26 ` Ulrich Drepper
  0 siblings, 1 reply; 3+ messages in thread
From: H . J . Lu @ 2000-07-13 13:42 UTC (permalink / raw)
  To: GNU C Library

posix/runptests failed on my 4GB RAM machine when run through make.
It ran ok by hand. This patch fixes it. The comments indicate
4000 is a better choice. 


-- 
H.J. Lu (hjl@gnu.org)
--
2000-07-13  H.J. Lu  <hjl@gnu.org>

	* posix/regex.c (re_max_failures): Set to 4000.

Index: posix/regex.c
===================================================================
RCS file: /work/cvs/gnu/glibc/posix/regex.c,v
retrieving revision 1.1.1.2
diff -u -p -r1.1.1.2 regex.c
--- posix/regex.c	2000/07/12 18:50:17	1.1.1.2
+++ posix/regex.c	2000/07/13 20:35:54
@@ -1234,7 +1234,7 @@ typedef struct
 # if defined MATCH_MAY_ALLOCATE
 /* 4400 was enough to cause a crash on Alpha OSF/1,
    whose default stack limit is 2mb.  */
-int re_max_failures = 20000;
+int re_max_failures = 4000;
 # else
 int re_max_failures = 2000;
 # endif

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2000-08-01 17:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-03-08 14:03 A patch for regex.c H . J . Lu
2000-07-13 13:42 H . J . Lu
2000-08-01 17:26 ` Ulrich Drepper

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).