This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
Re: Regex
- From: vijay nag <vijunag at gmail dot com>
- To: ÐÐÐÑÑ ÐÐÑÐÐ <pashev dot igor at gmail dot com>
- Cc: "libc-help at sourceware dot org" <libc-help at sourceware dot org>
- Date: Thu, 9 Jan 2014 20:14:43 +0530
- Subject: Re: Regex
- Authentication-results: sourceware.org; auth=none
- References: <CAKhyrx-6xUawp0s96mANnwWaBsf2HheysAt0=wh4oDo1mySq4w at mail dot gmail dot com> <CALL-Q8wDpXCAbh+NgS3650hQ0HEtDdRqGMGBa2HNMLLmWEetpA at mail dot gmail dot com> <CAKhyrx_FpQd0eehL_4PDyit=X9E6686d4qWB7b+tbGh5SBXSrg at mail dot gmail dot com> <CALL-Q8xGv6J2uf2oSi52e4kht_GT_Z1r9t5ULPaVtSHaJ--91g at mail dot gmail dot com>
On Thu, Jan 9, 2014 at 5:57 PM, ÐÐÐÑÑ ÐÐÑÐÐ <pashev.igor@gmail.com> wrote:
> 2014/1/9 vijay nag <vijunag@gmail.com>:
>> Ok. And the real question here is, why "*" cannot be used to match any
>> string in extended regular expression whereas it works fine in basic
>> regular expressions ?
>
> Could you provide a minimal test program?
>
> It looks like a bug.
>
> http://pubs.opengroup.org/onlinepubs/009695399/functions/regcomp.html :
>
> REG_BADRPT
> '?', '*', or '+' not preceded by valid regular expression.
cat regex.c
#include <stdio.h>
#include <regex.h>
int main()
{
regex_t regex;
int val;
val = regcomp(®ex, "*", REG_EXTENDED);
printf("retVal = %d\n", val);
if (0 != val) {
printf("Bad usage of ^, + or *\n");
}
val = regcomp(®ex, "*", REG_BASIC);
printf("retVal = %d\n", val);
if (0 != val) {
printf("Bad usage of ^, + or *\n");
}
}
Vijays-MacBook-Pro:/Users/vinag]$ gcc -g -O0 regex.c
Vijays-MacBook-Pro:/Users/vinag]$ ./a.out
retVal = 13 ------------->REG_BDRPT
Bad usage of ^, + or *
retVal = 0