From a66ea3fe143cdfdba792b7db854a0288a0ef849c Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Mon, 15 May 2017 17:19:29 +0200 Subject: [PATCH] [minupdate] whole browsed path --- src/lib/automate/automate.c | 22 ++++++++++++++++------ src/lib/automate/automate.h | 3 +++ src/linter.c | 11 +++++++++++ 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/src/lib/automate/automate.c b/src/lib/automate/automate.c index 1cd4ef2..181a753 100644 --- a/src/lib/automate/automate.c +++ b/src/lib/automate/automate.c @@ -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 =========================================================*/ @@ -41,9 +42,10 @@ unsigned int browse(struct Automate* pAutomate, const char* pString, const char /* (1) For each char try to match ---------------------------------------------------------*/ - c = 0; - strIndex = 0; - pathmem[0] = 0; + c = 0; + strIndex = 0; + pathmem[0] = 0; + pAutomate->path[0] = 0; while( pAutomate->dCurrent != pAutomate->dFinal && strIndex <= len ){ @@ -176,9 +178,14 @@ unsigned int browse(struct Automate* pAutomate, const char* pString, const char (ADB&&0x01) && printf("%s< yes\n", pad(pDepth+1)); c++; - pathmem = realloc(pathmem, sizeof(char) * (c+1) ); - indexmem = realloc(indexmem, sizeof(unsigned int) * (c+1) ); - dotmem = realloc(dotmem, sizeof(char) * (c+1) ); + pathmem = realloc(pathmem, sizeof(char) * (c+1) ); + 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); diff --git a/src/lib/automate/automate.h b/src/lib/automate/automate.h index 50e7f29..2d57d58 100644 --- a/src/lib/automate/automate.h +++ b/src/lib/automate/automate.h @@ -51,6 +51,9 @@ char steps; // number of steps char* name; // automate name + char* path; // automate path + + unsigned int n; // automate path length }; diff --git a/src/linter.c b/src/linter.c index bc5fa8f..81fa74b 100644 --- a/src/linter.c +++ b/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";