Hi all
I suspect (and can prove that there is a bug in the regexec function. I have
encountered this issue on two z/OS systems with two different z/OS level. The
proof is repeatable and produce same wrong results any time.
To prove it I modified a sample C program from the IBM manual and added a call
for dumping memory (see below). The documentation and the regex.h declare that
the regmatch_t construct should be a pair of doublewords (long) and it is
supposed to be an element in an array of as many as you need. Iinstead of
getting two pairs of double words containing (0,15),(8,2), I get the first
component of the first element as one word (int) of 0 and the rest are indeed
double words. This seems like a bug in the runtime library.Here is the dump
(only the first two lines are relevant)
19819478 | 00 00 00 00 00 00 00 00 00 00 00 0F 00 00 00 00 |
19819488 | 00 00 00 02 00 00 00 00 00 00 00 08 00 00 00 00 |
19819498 | 00 00 00 40 00 00 00 00 10 00 00 00 19 81 92 48 |
ak198194A8 | 00 00 00 00 99 80 01 6E 04 C6 3C 98 00 00 00 00 | r K F q
I do not have contacts with IBM. Would any one of you please pick up the issue
with IBM so they can explain or fix it. I think that some people in IBM
monitor this list, so please, could you help.
Here is the program
#include <regex.h>
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
extern void DUMPMEM(char *address, int length);
#include "zatoolib.h"
main() {
regex_t preg;
char *string = "a simple string";
char *pattern = ".*(simple).*";
int rc;
size_t nmatch = 2;
regmatch_t pmatch[2];
int my_size = sizeof(pmatch)*2;
if ((rc = regcomp(&preg, pattern, REG_EXTENDED)) != 0) {
printf("regcomp() failed, returning nonzero (%d)\n", rc);
exit(1);
}
if ((rc = regexec(&preg, string, nmatch, pmatch, 0)) != 0) {
printf("failed to ERE match '%s' with '%s',returning %d.\n",
string, pattern, rc);
}
DUMPMEM ((char *)pmatch, my_size);
regfree(&preg);
}
Ze'ev Atlas
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN