aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZack Weinberg <zackw@panix.com>2015-08-01 14:38:05 -0400
committerCarlos O'Donell <carlos@systemhalted.org>2015-08-01 14:38:05 -0400
commit2ec11c2b6e92b3622f0dc0a970634156b286ccd8 (patch)
treec42213e95f79504a90f2fffa6defee7077d45265
parentf4ddb3557e80a193c4169bbaf01a0e7f556098b9 (diff)
downloadglibc-2ec11c2b6e92b3622f0dc0a970634156b286ccd8.zip
glibc-2ec11c2b6e92b3622f0dc0a970634156b286ccd8.tar.gz
glibc-2ec11c2b6e92b3622f0dc0a970634156b286ccd8.tar.bz2
Deprecate the use of regexp.h
<regexp.h> (not to be confused with <regex.h>) is an obsolete and frankly horrible regular expression-matching API. It was part of SVID but was withdrawn in Issue 5 (for reference, we're on Issue 7 now). It doesn't do anything you can't do with <regex.h>, and using it involves defining a bunch of macros before including the header. Moreover, the code in regexp.h that uses those macros has been buggy since its creation (in 1996) and no one has noticed, which indicates to me that there are no users. (Specifically, RETURN() is used in a whole bunch of cases where it should have been ERROR().) The header is given a warning and marked deprecated for 2.22. See: https://sourceware.org/ml/libc-alpha/2015-07/msg00862.html and https://sourceware.org/ml/libc-alpha/2015-07/msg00871.html.
-rw-r--r--ChangeLog10
-rw-r--r--NEWS8
-rw-r--r--misc/regexp.c8
-rw-r--r--misc/regexp.h31
4 files changed, 39 insertions, 18 deletions
diff --git a/ChangeLog b/ChangeLog
index 720a20d..56fdbbf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2015-07-31 Zack Weinberg <zackw@panix.com>
+
+ [BZ #18681]
+ * regexp.h: Add unconditional #warning stating that this header
+ will be removed soon. Revise banner comment to match.
+ (compile): Consistently use ERROR instead of RETURN to report
+ errors (partial fix for bz#18681).
+ * regexp.c: Don't include regexp.h. Remove some unnecessary
+ declarations.
+
2015-07-31 Carlos O'Donell <carlos@redhat.com>
* po/libc.pot: Regenerated.
diff --git a/NEWS b/NEWS
index 3956263..1179f92 100644
--- a/NEWS
+++ b/NEWS
@@ -79,6 +79,14 @@ Version 2.22
* Port to Native Client running on ARMv7-A (--host=arm-nacl).
Contributed by Roland McGrath (Google).
+
+* The header <regexp.h> is deprecated, and will be removed in a future
+ release. Use of this header will trigger a deprecation warning.
+ Application developers should update their code to use <regex.h> instead.
+
+ This header was formerly part of SUSv2, but was deprecated in 1997 and
+ removed from the standard in 2001. Also, the glibc implementation
+ leaks memory. See BZ#18681 for more details.
Version 2.21
diff --git a/misc/regexp.c b/misc/regexp.c
index 3b83203..ee7d572 100644
--- a/misc/regexp.c
+++ b/misc/regexp.c
@@ -17,8 +17,10 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
-#define __DO_NOT_DEFINE_COMPILE
-#include <regexp.h>
+/* We don't include regexp.h here because of the macros it requires, and
+ because it now contains an unconditional #warning. */
+
+#include <regex.h>
/* Define the variables used for the interface. */
char *loc1;
@@ -32,7 +34,6 @@ char *locs;
found in the buffer starting at EXPBUF. `loc1' will return the
first character matched and `loc2' points to the next unmatched
character. */
-extern int __step (const char *string, const char *expbuf);
int
__step (const char *string, const char *expbuf)
{
@@ -55,7 +56,6 @@ weak_alias (__step, step)
/* Match the beginning of STRING with the compiled regular expression
in EXPBUF. If the match is successful `loc2' will contain the
position of the first unmatched character. */
-extern int __advance (const char *string, const char *expbuf);
int
__advance (const char *string, const char *expbuf)
{
diff --git a/misc/regexp.h b/misc/regexp.h
index 3fc0bc5..3460989 100644
--- a/misc/regexp.h
+++ b/misc/regexp.h
@@ -19,14 +19,17 @@
#ifndef _REGEXP_H
#define _REGEXP_H 1
-/* The contents of this header file was first standardized in X/Open
- System Interface and Headers Issue 2, originally coming from SysV.
- In issue 4, version 2, it is marked as TO BE WITDRAWN, and it has
- been withdrawn in SUSv3.
+/* The contents of this header file were standardized in the
+ Single Unix Specification, Version 2 (1997) but marked as
+ LEGACY; new applications were already being encouraged to
+ use <regex.h> instead. POSIX.1-2001 removed this header.
- This code shouldn't be used in any newly written code. It is
- included only for compatibility reasons. Use the POSIX definition
- in <regex.h> for portable applications and a reasonable interface. */
+ This header is provided only for backward compatibility.
+ It will be removed in the next release of the GNU C Library.
+ New code should use <regex.h> instead. */
+
+#warning "<regexp.h> will be removed in the next release of the GNU C Library."
+#warning "Please update your code to use <regex.h> instead (no trailing 'p')."
#include <features.h>
#include <alloca.h>
@@ -182,19 +185,19 @@ compile (char *__restrict instring, char *__restrict expbuf,
case REG_ERPAREN:
default:
/* There is no matching error code. */
- RETURN (36);
+ ERROR (36);
case REG_ESUBREG:
- RETURN (25);
+ ERROR (25);
case REG_EBRACK:
- RETURN (49);
+ ERROR (49);
case REG_EPAREN:
- RETURN (42);
+ ERROR (42);
case REG_EBRACE:
- RETURN (44);
+ ERROR (44);
case REG_BADBR:
- RETURN (46);
+ ERROR (46);
case REG_ERANGE:
- RETURN (11);
+ ERROR (11);
case REG_ESPACE:
case REG_ESIZE:
ERROR (50);