From ed62c33a791f2dd66bc9257fa8280548bfaf1def Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Tue, 2 Apr 2019 11:01:01 +0200 Subject: [PATCH] xpath parser scan strings instead of characters --- lib/src/clixon_xpath_parse.l | 8 ++++---- lib/src/clixon_xpath_parse.y | 6 +++--- test/long.sh | 4 ++-- test/mem.sh | 3 +-- test/test_yangmodels.sh | 1 - 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/lib/src/clixon_xpath_parse.l b/lib/src/clixon_xpath_parse.l index ca84f52a..7fd27c38 100644 --- a/lib/src/clixon_xpath_parse.l +++ b/lib/src/clixon_xpath_parse.l @@ -146,11 +146,11 @@ real ({digit}+[.]{digit}*)|({digit}*[.]{digit}+) . { fprintf(stderr,"LEXICAL ERROR\n"); return -1; } \" { BEGIN(TOKEN); return QUOTE; } -. { clixon_xpath_parselval.string = strdup(yytext); - return CHAR;} +[^"]+ { clixon_xpath_parselval.string = strdup(yytext); + return CHARS;} \' { BEGIN(TOKEN); return APOST; } -. { clixon_xpath_parselval.string = strdup(yytext); - return CHAR;} +[^']+ { clixon_xpath_parselval.string = strdup(yytext); + return CHARS;} %% diff --git a/lib/src/clixon_xpath_parse.y b/lib/src/clixon_xpath_parse.y index f2880804..f014b6a4 100644 --- a/lib/src/clixon_xpath_parse.y +++ b/lib/src/clixon_xpath_parse.y @@ -59,7 +59,7 @@ %token X_EOF %token QUOTE %token APOST -%token CHAR +%token CHARS %token NAME %token NODETYPE %token DOUBLEDOT @@ -276,14 +276,14 @@ args : args ',' expr { $$=xp_new(XP_EXP,A_NAN,0.0,NULL,NULL,$1, $3); clicon_debug(2,"args -> expr "); } ; -string : string CHAR { +string : string CHARS { int len = strlen($1); $$ = realloc($1, len+strlen($2) + 1); sprintf($$+len, "%s", $2); free($2); clicon_debug(2,"string-> string CHAR"); } - | CHAR { clicon_debug(2,"string-> "); } + | CHARS { clicon_debug(2,"string-> "); } ; diff --git a/test/long.sh b/test/long.sh index fd8d69a2..3db6b391 100755 --- a/test/long.sh +++ b/test/long.sh @@ -41,7 +41,7 @@ module scaling{ EOF cat < $cfg - + $cfg $dir /usr/local/share/clixon @@ -53,7 +53,7 @@ cat < $cfg /usr/local/var/$APPNAME /usr/local/lib/xmldb/text.so false - + EOF new "test params: -f $cfg -y $fyang" diff --git a/test/mem.sh b/test/mem.sh index 59cb4f81..94ed4b51 100755 --- a/test/mem.sh +++ b/test/mem.sh @@ -1,7 +1,6 @@ #!/bin/bash # Run valgrind leak test for cli, restconf, netconf or background. # Stop on first error - # Run valgrindtest once, args: # what: cli|netconf|restconf|backend @@ -24,7 +23,7 @@ memonce(){ ;; 'backend') valgrindtest=2 # This means backend valgrind test - : ${RCWAIT:=5} # valgrind backend needs some time to get up + : ${RCWAIT:=10} # valgrind backend needs some time to get up perfnr=100 # test_perf.sh restconf put more or less stops perfreq=10 diff --git a/test/test_yangmodels.sh b/test/test_yangmodels.sh index c7d12c0e..9acfc191 100755 --- a/test/test_yangmodels.sh +++ b/test/test_yangmodels.sh @@ -89,7 +89,6 @@ expectfn "$clixon_cli -D $DBG -1f $cfg -o CLICON_YANG_MAIN_DIR=$YANGMODELS/stand files=$(find $YANGMODELS/vendor/juniper/18.2/18.2R1/junos/conf -name "*.yang") let i=0; for f in $files; do - echo "f:$f" if [ -n "$(head -5 $f|grep '^ module')" ]; then new "$clixon_cli -1f $cfg -o CLICON_YANG_MAIN_FILE=$f -p $YANGMODELS/vendor/juniper/18.2/18.2R1/common -p $YANGMODELS/vendor/juniper/18.2/18.2R1/junos/conf show version" expectfn "$clixon_cli -1f $cfg -o CLICON_YANG_MAIN_FILE=$f -p $YANGMODELS/vendor/juniper/18.2/18.2R1/common -p $YANGMODELS/vendor/juniper/18.2/18.2R1/junos/conf -o CLICON_CLI_GENMODEL=0 show version" 0 "3."