From db9c31fcf57024abfdc7b35825409166f17d5aac Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Fri, 12 Apr 2019 07:55:04 +0530 Subject: tests: validate volfile grammar - strings in volfile * libglusterfs/graph-print: remove unused code updates: bz#1693692 Change-Id: Iae81bb6a3af5911c3da07ab8f1d8f58f27e06905 Signed-off-by: Amar Tumballi --- libglusterfs/src/graph.l | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-) (limited to 'libglusterfs/src/graph.l') 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 -#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]+ ; -- cgit