Fix argument tokenizer

This commit is contained in:
Alex D. 2020-09-24 18:59:16 +02:00
parent 98e580f29c
commit 8b9a527ace
Signed by: caskd
GPG Key ID: F92BA85F61F4C173
2 changed files with 5 additions and 4 deletions

View File

@ -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)

View File

@ -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;