From 1b9274c1419f4e48885534920a85937f3d971efb Mon Sep 17 00:00:00 2001 From: Emil Date: Tue, 15 Aug 2023 07:15:33 -0600 Subject: [PATCH] Fixed have args user commands --- src/irc.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/irc.c b/src/irc.c index b9d3e5e..838dc7d 100644 --- a/src/irc.c +++ b/src/irc.c @@ -155,6 +155,7 @@ event_channel(irc_session_t * lsession, DECL int has_arg(char const * cmd) { + char const * start = cmd; while (isalnum(*cmd)) { if (*cmd == '\0') @@ -164,7 +165,7 @@ has_arg(char const * cmd) while (*cmd != '\0') { if (!isspace(*cmd)) - { return 1; } + { return cmd - start; } ++cmd; } return 0; @@ -177,7 +178,7 @@ parse_command(char const * cmd) char* msgswp = NULL; /* size_t len = strlen(cmd); */ printf("Handling '%s'\n", cmd); - if (!(i += has_arg(cmd))) + if (!(i = has_arg(cmd))) { /* NO ARGUMENTS */ if (strcmp(cmd, "remind") == 0) @@ -206,7 +207,8 @@ parse_command(char const * cmd) } else /* HAS ARGUMENTS */ { - char const * const arg = cmd + i + 1; + char const * const arg = cmd + i; + printf("argoff: %p; i: %ld; arg: %sEOA\n", cmd + i + 1, i, arg); #ifndef NO_VULN_COMMANDS if (strncmp(cmd, "raw", i) == 0) { @@ -226,7 +228,3 @@ parse_command(char const * cmd) } free(msgswp); } - - - -