On 06/05/15 23:33, Nikos Mavrogiannopoulos wrote:
On Fri, 2015-06-05 at 18:19 -0700, Bruce Korb wrote:
export AUTOGEN_TRACE=everything AUTOGEN_TRACE_OUT='>>/tmp/ag-log.txt'
Log is attached.
In that log, I find:
Compiling '[ -~]' with bits 0x1 <<<=== compiled as extended RE
CASE no match: `c' MATCH_FULL vs. `[ -~]'
I think there is a RE library problem. The code is as follows:
/*
* On the first call for this macro, compile the expression
*/
if (cur_macro->md_pvt == NULL) {
void * mat = VOIDP(pattern);
regex_t * re = AGALOC(sizeof(*re), "select match full re");
if (OPT_VALUE_TRACE > TRACE_EXPRESSIONS) {
fprintf(trace_fp, TRACE_SEL_MATCH_FULL,
pattern, cur_macro->md_res);
The "Compiling '...'" message is printed here. The following "compile_re"
function WILL NOT RETURN if there is a problem.
}
compile_re(re, mat, (int)cur_macro->md_res);
cur_macro->md_pvt = re;
}
if (regexec((regex_t *)cur_macro->md_pvt, sample, (size_t)2, m, 0)
"sample" points to the NUL terminated, single character string: "c".
!= 0)
return FAILURE;
if ( (m[0].rm_eo != (int)strlen( sample ))
|| (m[0].rm_so != 0))
return FAILURE;
return SUCCESS;
This function returns FAILURE, and that is incorrect.
This code has not changed in many years (16).
Last January, I changed the casting of 'pattern' to coerce it into a "void *"
without any const attributes, but functionally no changes for 16 years.
The following program should replicate the same test that fails in AutoGen.
If this succeeds, then the question is, "what is different in the execution
env?"
If this fails, on the other hand, then you need to look to the regcomp library.
#define VOIDP(_p) ((void *)(unsigned long)(_p))
static void
compile_re(regex_t * re, char const * pat, int flags)
{
int rerr = regcomp(re, VOIDP(pat), flags);
if (rerr != 0) {
char erbf[ 1024 ];
regerror(rerr, re, erbf, sizeof(erbf));
fprintf(stderr, BAD_RE_FMT, rerr, erbf, pat);
abort();
}
}
static bool
check_full_match(char const * sample, char const * pattern)
{
regmatch_t m[2];
regex_t * md_pvt;
/*
* On the first call for this macro, compile the expression
*/
{
void * mat = VOIDP(pattern);
regex_t * re = malloc(sizeof(*re));
compile_re(re, mat, 1);
md_pvt = re;
}
// In this function, the RE must match the entire string.
//
if (regexec((regex_t *)cur_macro->md_pvt, sample, (size_t)2, m, 0)
!= 0)
return false;
if ( (m[0].rm_eo != (int)strlen( sample ))
|| (m[0].rm_so != 0))
return false;
return true;
}
int main(int argc, char ** argv) {
if (! check_full_match("c", "[ -~]"))
printf("FAILED\n");
return 0;
}
--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org