From 4733e1172e59574c8676792f9026221535051826 Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Sat, 19 Mar 2022 21:53:18 -0400 Subject: [PATCH] Fix uncaught mismatched paren error. Add test against that error behavior. Remove bits of unused code from web.c and tests.sh --- src/tests.sh | 5 ++--- src/tokens.c | 3 +-- src/web.c | 6 +----- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/tests.sh b/src/tests.sh index 3fa1579..1463139 100755 --- a/src/tests.sh +++ b/src/tests.sh @@ -9,8 +9,6 @@ FAIL_OUTPUT="" VALGRIND=false DISABLED=false -CURRENT_BLOCK="" - if [ "$1" == "-val" ]; then VALGRIND=true filter="$2" @@ -137,7 +135,7 @@ check "Identifying empty list" "(islist ())" "T" check "Identifying not a list" "(islist 1)" "F" deep_nesting="10" -for i in {0..25}; do deep_nesting="( $deep_nesting )"; done +for _ in {0..25}; do deep_nesting="( $deep_nesting )"; done check "DeepNesting" "$deep_nesting" "$deep_nesting" # Above 25 it starts to stack-smash title "Spacing" @@ -216,6 +214,7 @@ check "BadParens2" "(hey)(" regex "'MISMATCHED_PARENS.*" check "BadParens3" "((hey(" regex "'MISMATCHED_PARENS.*" check "BadParens4" ")))hey" regex "'MISMATCHED_PARENS.*" check "BadParens5" "hey))(" regex "'MISMATCHED_PARENS.*" +check "BadParens6" '(ey")"' regex "'MISMATCHED_PARENS.*" title "Eval" check "BasicNumberEval" '(eval "5")' "5" diff --git a/src/tokens.c b/src/tokens.c index da6d191..a42fbf1 100644 --- a/src/tokens.c +++ b/src/tokens.c @@ -123,8 +123,7 @@ struct Slice* nf_tokenize(const char* input, struct Error* err) } i++; } else { - while (!isWhitespace(input[++i]) && !isSingle(input[i]) && - input[i] != '\0') { + while (!isWhitespace(input[++i]) && !isSingle(input[i]) && input[i] != '"' && input[i] != '\0') { l++; } } diff --git a/src/web.c b/src/web.c index 655e046..5ef6885 100644 --- a/src/web.c +++ b/src/web.c @@ -39,7 +39,7 @@ int methodMatches(const char* method, struct Route* route) case GET: return method[0] == 'G' || method[0] == 'g'; case POST: - return method[0] == 'P' || method[0] == 'p'; + return (method[0] == 'P' || method[0] == 'p') && (method[1] == 'O' || method[1] == 'o'); default: return 0; } @@ -103,10 +103,6 @@ answer_to_connection(void* cls, struct MHD_Connection* connection, HttpResult ret = MHD_queue_response(connection, MHD_HTTP_OK, response); MHD_destroy_response(response); - // if (needsFree) { - // free(page); - // } - return ret; }