[PATCH] symver for regexec (followup for REG_STARTEND)
Jakub Jelinek
jakub@redhat.com
Fri Mar 5 18:04:00 GMT 2004
On Fri, Mar 05, 2004 at 08:26:24AM +0100, Paolo Bonzini wrote:
> > This looks sufficiently simple t add. But you should not regard this as
> > a card blanche for further additions. The code is already complex enough.
>
> Thanks. I agree and no had other extensions in mind. But this one is
> actually useful and maybe its being more widespread could lead to POSIX
> blessing -- and the code to implement it is also well localized.
Given that regexec ATM ignores unknown eflags bits, IMHO your patch is not
enough, because if you compile your program with glibc which has
REG_STARTEND in its headers and use it for regexec, then somebody else
runs that program against older glibc without that flag, it will silently
do something else.
I don't know if REG_BADPAT is best return value for this, but am not sure
if for this we must create a new one or return REG_ENOSYS (which would
need changes to regerror to accept REG_ENOSYS).
2004-03-05 Jakub Jelinek <jakub@redhat.com>
* posix/regexec.c (regexec): Return with error on unknown eflags.
Replace weak_alias with versioned_symbol.
(__compat_regexec): New.
* posix/Versions (libc): Add regexec@GLIBC_2.3.4.
--- libc/posix/regexec.c.jj 2004-03-05 12:13:01.000000000 +0100
+++ libc/posix/regexec.c 2004-03-05 18:55:09.623158926 +0100
@@ -216,6 +216,10 @@ regexec (preg, string, nmatch, pmatch, e
{
reg_errcode_t err;
int start, length;
+
+ if (eflags & ~(REG_NOTBOL | REG_NOTEOL | REG_STARTEND))
+ return REG_BADPAT;
+
if (eflags & REG_STARTEND)
{
start = pmatch[0].rm_so;
@@ -234,8 +238,24 @@ regexec (preg, string, nmatch, pmatch, e
length, nmatch, pmatch, eflags);
return err != REG_NOERROR;
}
+
#ifdef _LIBC
-weak_alias (__regexec, regexec)
+# include <shlib-compat.h>
+versioned_symbol (libc, __regexec, regexec, GLIBC_2_3_4);
+
+# if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_3_4)
+__typeof__ (__regexec) __compat_regexec;
+
+int
+__compat_regexec (const regex_t *__restrict preg,
+ const char *__restrict string, size_t nmatch,
+ regmatch_t pmatch[], int eflags)
+{
+ return regexec (preg, string, nmatch, pmatch,
+ eflags & (REG_NOTBOL | REG_NOTEOL));
+}
+compat_symbol (libc, __compat_regexec, regexec, GLIBC_2_0);
+# endif
#endif
/* Entry points for GNU code. */
--- libc/posix/Versions.jj 2003-09-17 13:42:32.000000000 +0200
+++ libc/posix/Versions 2004-03-05 18:35:12.307807594 +0100
@@ -119,6 +119,9 @@ libc {
GLIBC_2.3.3 {
sched_getaffinity; sched_setaffinity;
}
+ GLIBC_2.3.4 {
+ regexec;
+ }
GLIBC_PRIVATE {
# functions which have an additional interface since they are
# are cancelable.
Jakub
More information about the Libc-alpha
mailing list