/*
* testRegexp.c: simple module for testing regular expressions
*
* See Copyright for the status of this software.
*
* Daniel Veillard <veillard@redhat.com>
*/
#include "libxml.h"
#ifdef LIBXML_AUTOMATA_ENABLED
#include <string.h>
#include <libxml/xmlautomata.h>
int ret = 0;
char *cur;
cur++;
}
return(ret);
}
static void
int len;
int ret;
int i;
for (i = 0;i<1000;i++)
"Cannot open %s for reading\n", filename);
return;
}
am = xmlNewAutomata();
"Cannot create automata\n");
return;
}
"Cannot get start state\n");
return;
}
ret = 0;
if (expr[0] == '#')
continue;
len--;
while ((len >= 0) &&
if (len >= 0) {
if (*ptr != ' ') {
"Bad line %s\n", expr);
break;
}
ptr++;
if (*ptr != ' ') {
"Bad line %s\n", expr);
break;
}
ptr++;
if (*ptr != ' ') {
"Bad line %s\n", expr);
break;
}
ptr++;
int state;
break;
}
if (*ptr != ' ') {
"Bad line %s\n", expr);
break;
}
ptr++;
if (*ptr != ' ') {
"Bad line %s\n", expr);
break;
}
ptr++;
if (*ptr != ' ') {
"Bad line %s\n", expr);
break;
}
ptr++;
if (*ptr != ' ') {
"Bad line %s\n", expr);
break;
}
ptr++;
/* end of the automata */
"Failed to compile the automata");
break;
}
printf("=> failed not compiled\n");
} else {
if (ret == 0) {
}
if (ret == 1)
printf("=> Passed\n");
printf("=> Failed\n");
else if (ret < 0)
printf("=> Error\n");
}
ret = 0;
} else {
"Unexpected line %s\n", expr);
}
}
}
}
if (argc == 1) {
int ret;
am = xmlNewAutomata();
/* generate a[ba]*a */
/* compile it in a regexp and free the automata */
/* test the regexp */
if (ret == 1)
printf("final\n");
else if (ret < 0)
printf("error\n");
if (ret == 1)
printf("final\n");
else if (ret < 0)
printf("error\n");
if (ret == 1)
printf("final\n");
else if (ret < 0)
printf("error\n");
if (ret == 1)
printf("final\n");
else if (ret < 0)
printf("error\n");
if (ret == 1)
printf("final\n");
else if (ret < 0)
printf("error\n");
if (ret == 1)
printf("final\n");
else if (ret < 0)
printf("error\n");
if (ret == 1)
printf("final\n");
else if (ret < 0)
printf("error\n");
if (ret == 0) {
if (ret == 1)
printf("final\n");
else if (ret < 0)
printf("error\n");
}
/* free the regexp */
} else {
int i;
for (i = 1;i < argc;i++)
testRegexpFile(argv[i]);
}
return(0);
}
#else
#include <stdio.h>
return(0);
}
#endif /* LIBXML_AUTOMATA_ENABLED */