diff options
author | Amar Tumballi <amarts@redhat.com> | 2019-04-12 07:55:04 +0530 |
---|---|---|
committer | Amar Tumballi <amarts@redhat.com> | 2019-05-06 13:57:44 +0000 |
commit | db9c31fcf57024abfdc7b35825409166f17d5aac (patch) | |
tree | 85a51adf6ec9289599475fb8d01a7badd46c8d91 /libglusterfs/src/graph.l | |
parent | e0dadeb3242a10827c6142f609c87d860b3ce546 (diff) |
tests: validate volfile grammar - strings in volfile
* libglusterfs/graph-print: remove unused code
updates: bz#1693692
Change-Id: Iae81bb6a3af5911c3da07ab8f1d8f58f27e06905
Signed-off-by: Amar Tumballi <amarts@redhat.com>
Diffstat (limited to 'libglusterfs/src/graph.l')
-rw-r--r-- | libglusterfs/src/graph.l | 38 |
1 files changed, 16 insertions, 22 deletions
diff --git a/libglusterfs/src/graph.l b/libglusterfs/src/graph.l index 4447191ac73..b9d4b2b6828 100644 --- a/libglusterfs/src/graph.l +++ b/libglusterfs/src/graph.l @@ -17,32 +17,24 @@ #include "glusterfs/xlator.h" #include "y.tab.h" #include <string.h> -#define START_STRSIZE 32 static char *text; -static int text_asize; static int text_size; void append_string(const char *str, int size) { - int new_size = text_size + size + 1; - if (new_size > text_asize) { - new_size += START_STRSIZE - 1; - new_size &= -START_STRSIZE; - if (!text) { - text = GF_CALLOC (1, new_size, - gf_common_mt_char); - } else { - text = GF_REALLOC (text, new_size); - } - if (!text) { - return; - } - text_asize = new_size; - } - memcpy(text + text_size, str, size); - text_size += size; - text[text_size] = 0; + int new_size = text_size + size + 1; + if (!text) { + text = GF_CALLOC (1, new_size, gf_common_mt_char); + } else { + text = GF_REALLOC (text, new_size); + } + if (!text) { + return; + } + memcpy(text + text_size, str, size); + text_size += size; + text[text_size] = 0; } %} @@ -65,12 +57,14 @@ TYPE [t][y][p][e] \\. { append_string (yytext + 1, yyleng - 1); } \" { if (0) { - yyunput (0, NULL); + yyunput (0, NULL); } BEGIN (INITIAL); graphyylval = text; + text = NULL; + text_size = 0; return STRING_TOK; - } + } } [^ \t\r\n\"\\]+ { graphyylval = gf_strdup (yytext) ; return ID; } [ \t\r\n]+ ; |