c++ - regexp, Assertion failure
- Heinz Saathoff <newshsaat arcor.de> Oct 25 2012
Hallo,
I've tried to use the RegExp class to parse a 8051 map file for certain
lines. In case sensitive mode it works as expected, but terminates with
an assertion when the attribute string is "i" for case insensitive.
This is a small program to reproduce the error:
//========= a.cpp ============
#include <stdio.h>
#include <regexp.h>
#define GEN_ERROR 1
#if GEN_ERROR == 0
#define ATTRIB NULL
#else
#define ATTRIB "i" // ignore case causes problem
#endif
char test_str1[] = " D:00CCH SYMBOL TL2 ";
char pattern[] = "([DX]:[0-9A-F]+H)[\t ]+([A-Z]+)[\t ]+([\\S]+)";
int main()
{ RegExp rexp;
if(rexp.compile(pattern, ATTRIB, 0) == 0)
printf("Compile failed\n");
else {
printf("regexp compiled ok\n");
if(rexp.test(test_str1) == 0)
printf("Failed finding a match\n");
else {
printf("matched %d\n", rexp.re_nsub);
for(int i=1; i<=3; ++i) {
printf("%d => %.*s\n", i,
rexp.pmatch[i].rm_eo-rexp.pmatch[i].rm_so,
test_str1+rexp.pmatch[i].rm_so);
}//for
}//if else
}//if else
}//main
//=========== end a.cpp =============
Compile as console application with
dmc a.cpp
Output in case insensitive mode:
regexp compiled ok
matched 3
1 => D:00CCH
2 => SYMBOL
3 => TL2
Output in case sensitive mode:
regexp compiled ok
Assertion failure: '0' on line 921 in file '..\core\regexp.cpp'
abnormal program termination
I don't have the file regexp.cpp so I can not look for the problem
mmyself.
- Heinz
Oct 25 2012








Heinz Saathoff <newshsaat arcor.de>