Mercurial > hg > Applications > Grep
changeset 91:912d7bd51f38
remove static variable in createRegexTree.cc
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 23 Oct 2015 18:53:46 +0900 |
parents | d139af3bbd67 |
children | 9a1bb8f439f5 |
files | c/regexParser/createRegexTree.cc c/regexParser/main.cc c/regexParser/printTree.cc c/regexParser/regexParser.h |
diffstat | 4 files changed, 5 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/c/regexParser/createRegexTree.cc Fri Oct 23 17:48:01 2015 +0900 +++ b/c/regexParser/createRegexTree.cc Fri Oct 23 18:53:46 2015 +0900 @@ -24,9 +24,8 @@ n->right = right; if (ri->tokenType == 'a') { - static int number = 1; - n->nodeNumber = number; - number++; + n->nodeNumber = ri->nodeNumber; + ri->nodeNumber++; ri->tokenType = 0; } return n; @@ -143,4 +142,3 @@ } } return n; } -
--- a/c/regexParser/main.cc Fri Oct 23 17:48:01 2015 +0900 +++ b/c/regexParser/main.cc Fri Oct 23 18:53:46 2015 +0900 @@ -18,6 +18,7 @@ int main(int argc, char **argv) { RegexInfoPtr ri = (RegexInfoPtr)malloc(sizeof(RegexInfo)); + ri->nodeNumber = 1; for (int i = 1; i < argc; i++) { if (strcmp(argv[i],"-regex") == 0) {
--- a/c/regexParser/printTree.cc Fri Oct 23 17:48:01 2015 +0900 +++ b/c/regexParser/printTree.cc Fri Oct 23 18:53:46 2015 +0900 @@ -8,7 +8,7 @@ d--; } if (n->tokenType == 'a') { - printf("%*c(%d)%c\n",d*4, ' ',n->nodeNumber,n->Value.character); + printf("%*c%c(%d)\n",d*4, ' ',n->Value.character,n->nodeNumber); } else { printf("%*c%c\n",d*4, ' ',n->Value.character); }