bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] regex: allow inclusion of <regex.h> before <limits.h>


From: Paul Eggert
Subject: [PATCH] regex: allow inclusion of <regex.h> before <limits.h>
Date: Sat, 10 Mar 2012 12:16:48 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.1) Gecko/20120209 Thunderbird/10.0.1

Without this patch, portable programs had to include <limits.h> before
<regex.h> if they wanted a consistent value for RE_DUP_MAX.
I ran into this problem with a test version of GNU grep on Solaris 8.
* lib/regex.h: Include <limits.h> if _REGEX_INCLUDE_LIMITS_H.
This is done conditionally so that this change can be merged
back to glibc.
* m4/regex.m4 (gl_REGEX): Define _REGEX_INCLUDE_LIMITS_H if
using the included regex.
---
 ChangeLog   |   10 ++++++++++
 lib/regex.h |    3 +++
 m4/regex.m4 |    5 ++++-
 3 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c000ece..ab2d85c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2012-03-10  Paul Eggert  <address@hidden>
 
+       regex: allow inclusion of <regex.h> before <limits.h>
+       Without this patch, portable programs had to include <limits.h> before
+       <regex.h> if they wanted a consistent value for RE_DUP_MAX.
+       I ran into this problem with a test version of GNU grep on Solaris 8.
+       * lib/regex.h: Include <limits.h> if _REGEX_INCLUDE_LIMITS_H.
+       This is done conditionally so that this change can be merged
+       back to glibc.
+       * m4/regex.m4 (gl_REGEX): Define _REGEX_INCLUDE_LIMITS_H if
+       using the included regex.
+
        fts: depend on fdopendir
        * modules/fts (Depends-on): Depend on fdopendir.  This is needed
        on Solaris 8, at least, since it lacks fdopendir.  Evidently the
diff --git a/lib/regex.h b/lib/regex.h
index 7399cb7..0c3b420 100644
--- a/lib/regex.h
+++ b/lib/regex.h
@@ -294,6 +294,9 @@ extern reg_syntax_t re_syntax_options;
 /* Maximum number of duplicates an interval can allow.  POSIX-conforming
    systems might define this in <limits.h>, but we want our
    value, so remove any previous define.  */
+# ifdef _REGEX_INCLUDE_LIMITS_H
+#  include <limits.h>
+# endif
 # ifdef RE_DUP_MAX
 #  undef RE_DUP_MAX
 # endif
diff --git a/m4/regex.m4 b/m4/regex.m4
index 08f1352..41be5e8 100644
--- a/m4/regex.m4
+++ b/m4/regex.m4
@@ -1,4 +1,4 @@
-# serial 60
+# serial 61
 
 # Copyright (C) 1996-2001, 2003-2012 Free Software Foundation, Inc.
 #
@@ -175,6 +175,9 @@ AC_DEFUN([gl_REGEX],
   esac
 
   if test $ac_use_included_regex = yes; then
+    AC_DEFINE([_REGEX_INCLUDE_LIMITS_H], [1],
+      [Define if you want <regex.h> to include <limits.h>, so that it
+       consistently overrides <limits.h>'s RE_DUP_MAX.])
     AC_DEFINE([_REGEX_LARGE_OFFSETS], [1],
       [Define if you want regoff_t to be at least as wide POSIX requires.])
     AC_DEFINE([re_syntax_options], [rpl_re_syntax_options],
-- 
1.7.6.5




reply via email to

[Prev in Thread] Current Thread [Next in Thread]