[minupdate] whole browsed path
This commit is contained in:
parent
315a8be97a
commit
a66ea3fe14
|
@ -28,6 +28,7 @@ unsigned int browse(struct Automate* pAutomate, const char* pString, const char
|
|||
char* pathmem = malloc( sizeof(char) ); // will contain edge number for each dot
|
||||
unsigned int* indexmem = malloc( sizeof(unsigned int) ); // will contain offset of @pString for each dot
|
||||
char* dotmem = malloc( sizeof(char) );
|
||||
pAutomate->path = realloc(pAutomate->path, 1 );
|
||||
|
||||
/* [1] For each char
|
||||
=========================================================*/
|
||||
|
@ -44,6 +45,7 @@ unsigned int browse(struct Automate* pAutomate, const char* pString, const char
|
|||
c = 0;
|
||||
strIndex = 0;
|
||||
pathmem[0] = 0;
|
||||
pAutomate->path[0] = 0;
|
||||
|
||||
while( pAutomate->dCurrent != pAutomate->dFinal && strIndex <= len ){
|
||||
|
||||
|
@ -180,6 +182,11 @@ unsigned int browse(struct Automate* pAutomate, const char* pString, const char
|
|||
indexmem = realloc(indexmem, sizeof(unsigned int) * (c+1) );
|
||||
dotmem = realloc(dotmem, sizeof(char) * (c+1) );
|
||||
|
||||
pAutomate->n = c;
|
||||
pAutomate->path = realloc(pAutomate->path, sizeof(char) * (c+1) );
|
||||
pAutomate->path[c] = pAutomate->dCurrent;
|
||||
|
||||
|
||||
pathmem[c] = 0;
|
||||
}
|
||||
|
||||
|
@ -343,6 +350,8 @@ struct Automate createAutomate(const char* pName){
|
|||
automate.dCurrent = 0;
|
||||
automate.dFinal = 0;
|
||||
|
||||
automate.n = 0;
|
||||
|
||||
/* [2] First allocation
|
||||
=========================================================*/
|
||||
automate.dot = malloc( 0 );
|
||||
|
@ -350,6 +359,7 @@ struct Automate createAutomate(const char* pName){
|
|||
automate.redge = malloc( 0 );
|
||||
automate.ledge = malloc( 0 );
|
||||
automate.aedge = malloc( 0 );
|
||||
automate.path = malloc( 0 );
|
||||
automate.name = malloc( strlen(pName) + 1 );
|
||||
strcpy(automate.name, pName);
|
||||
|
||||
|
|
|
@ -51,6 +51,9 @@
|
|||
char steps; // number of steps
|
||||
|
||||
char* name; // automate name
|
||||
char* path; // automate path
|
||||
|
||||
unsigned int n; // automate path length
|
||||
};
|
||||
|
||||
|
||||
|
|
11
src/linter.c
11
src/linter.c
|
@ -58,6 +58,7 @@ int main(int argc, char* argv[]){
|
|||
|
||||
mergeAutomate(&positive, 0);
|
||||
debug(positive);
|
||||
|
||||
// mergeAutomate(&number, 0);
|
||||
// debug(number);
|
||||
|
||||
|
@ -73,6 +74,16 @@ int main(int argc, char* argv[]){
|
|||
printf(" (*) in %d steps\n", positive.steps);
|
||||
printf(" (*) in %.3lf seconds\n\n", (double)(stop-start)/CLOCKS_PER_SEC);
|
||||
|
||||
for( c = 0 ; c < positive.n ; c++ ){
|
||||
|
||||
if( c > 0 )
|
||||
printf(" -> ");
|
||||
|
||||
printf("q%d", positive.path[c]);
|
||||
|
||||
}
|
||||
printf(" -> q%d\n", positive.dFinal);
|
||||
|
||||
exit(0);
|
||||
/* Build RegExp */
|
||||
// char regex[40] = "(a([abc](b+a)(b+e)+ahd)*(b+i)c)sd";
|
||||
|
|
Loading…
Reference in New Issue