Fixed have args user commands

This commit is contained in:
Emil 2023-08-15 07:15:33 -06:00
parent 3e2cf10c77
commit 1b9274c141
No known key found for this signature in database
GPG Key ID: 5432DB986FDBCF8A

View File

@ -155,6 +155,7 @@ event_channel(irc_session_t * lsession,
DECL int DECL int
has_arg(char const * cmd) has_arg(char const * cmd)
{ {
char const * start = cmd;
while (isalnum(*cmd)) while (isalnum(*cmd))
{ {
if (*cmd == '\0') if (*cmd == '\0')
@ -164,7 +165,7 @@ has_arg(char const * cmd)
while (*cmd != '\0') while (*cmd != '\0')
{ {
if (!isspace(*cmd)) if (!isspace(*cmd))
{ return 1; } { return cmd - start; }
++cmd; ++cmd;
} }
return 0; return 0;
@ -177,7 +178,7 @@ parse_command(char const * cmd)
char* msgswp = NULL; char* msgswp = NULL;
/* size_t len = strlen(cmd); */ /* size_t len = strlen(cmd); */
printf("Handling '%s'\n", cmd); printf("Handling '%s'\n", cmd);
if (!(i += has_arg(cmd))) if (!(i = has_arg(cmd)))
{ {
/* NO ARGUMENTS */ /* NO ARGUMENTS */
if (strcmp(cmd, "remind") == 0) if (strcmp(cmd, "remind") == 0)
@ -206,7 +207,8 @@ parse_command(char const * cmd)
} }
else /* HAS ARGUMENTS */ 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 #ifndef NO_VULN_COMMANDS
if (strncmp(cmd, "raw", i) == 0) if (strncmp(cmd, "raw", i) == 0)
{ {
@ -226,7 +228,3 @@ parse_command(char const * cmd)
} }
free(msgswp); free(msgswp);
} }