From 65bd4ce7669c2d8f12b977318da4e4ddd0164b4c Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Thu, 31 Oct 2024 11:06:19 +0100 Subject: [PATCH] fix is_quoted() (reported "aaa\\\"bbb" as unquoted) --- src/token.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/token.c b/src/token.c index 8b0e801e..2941bedc 100644 --- a/src/token.c +++ b/src/token.c @@ -872,32 +872,40 @@ void check_unique_names(int rename) } static int is_quoted(const char *s) +{ + size_t len = strlen(s); + + if(s[0] == '"' && s[len - 1] == '"') return 1; + return 0; +} + +int xis_quoted(const char *s) { int c, escape = 0; int openquote = 0; int closequote = 0; while( (c = *s++) ) { - + escape = 0; if(c == '\\' && !escape) { escape = 1; c = *s++; - } else escape = 0; - + } if(c == '"' && !escape && !openquote ) { openquote = 1; - continue; } else if(c == '"' && !escape && openquote && !closequote) { closequote = 1; - continue; } else if(c == '"' && !escape ) { return 0; } - - if(!isspace(c) && !openquote) return 0; - if(!isspace(c) && openquote && closequote) return 0; + else if(!isspace(c) && !openquote) { + return 0; + } + else if(!isspace(c) && openquote && closequote) { + return 0; + } } if(openquote && closequote) return 1; return 0;