From 8b9a527ace7605750dd1ce81207b16804352c0d1 Mon Sep 17 00:00:00 2001 From: Alex Denes Date: Thu, 24 Sep 2020 18:59:16 +0200 Subject: [PATCH] Fix argument tokenizer --- CMakeLists.txt | 2 +- src/tokenizers.c | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 91cf74b..ee94d97 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ project(microirc LANGUAGES C) if (CMAKE_C_COMPILER_ID STREQUAL "GNU") add_compile_options(-Wall -Wextra -Werror -Wformat-overflow=2 -Wformat-security -Winit-self -Wstrict-overflow=2 -Wstringop-overflow=2 -Walloc-zero -Wduplicated-branches -Wduplicated-cond -Wtrampolines -Wfloat-equal -Wshadow -Wunsafe-loop-optimizations -Wparentheses -pedantic -fanalyzer -fstack-check) elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang") - add_compile_options(-Weverything -pedantic) + add_compile_options(-Weverything -Wno-padded -pedantic) endif() if (NOT CMAKE_BUILD_TYPE) diff --git a/src/tokenizers.c b/src/tokenizers.c index 0c84bbb..ec1c936 100644 --- a/src/tokenizers.c +++ b/src/tokenizers.c @@ -55,15 +55,16 @@ signed int Tok_mesg(char* str, IRC_Message* out) skip_spaces(&progr); int i; - for (i = 0; i < 15 && *progr; i++) { + for (i = 0; i < 15 && *progr;) { if (i == 14 || *progr == ':') { out->args[i++] = (*progr == ':') ? progr + 1 : progr; out->trailing = true; + break; } else { - if ((out->args[i] = strtok_mr(&progr, " ")) == NULL) + if ((out->args[i++] = strtok_mr(&progr, " ")) == NULL) return ERR_UIRC_INVALID_FORMAT; + skip_spaces(&progr); } - skip_spaces(&progr); } out->args[i] = NULL; return 1;