mirror of
https://github.com/Tha14/toxic.git
synced 2024-12-27 19:23:25 +01:00
small fix
This commit is contained in:
parent
4426eaddd9
commit
b5f34f42a8
@ -84,14 +84,14 @@ static int parse_command(WINDOW *w, ToxWindow *self, const char *input, char (*a
|
||||
char *cmd = strdup(input);
|
||||
int num_args = 0;
|
||||
int i = 0; /* index of last char in an argument */
|
||||
bool cmd_end = false;
|
||||
|
||||
/* characters wrapped in double quotes count as one arg */
|
||||
while (cmd[i] && num_args < MAX_NUM_ARGS) {
|
||||
while (!cmd_end && num_args < MAX_NUM_ARGS) {
|
||||
int qt_ofst = 0; /* set to 1 to offset index for quote char at end of arg */
|
||||
|
||||
if (*cmd == '\"') {
|
||||
qt_ofst = 1;
|
||||
|
||||
i = char_find(1, cmd, '\"');
|
||||
|
||||
if (cmd[i] == '\0') {
|
||||
@ -107,8 +107,10 @@ static int parse_command(WINDOW *w, ToxWindow *self, const char *input, char (*a
|
||||
memcpy(args[num_args], cmd, i + qt_ofst);
|
||||
args[num_args++][i + qt_ofst] = '\0';
|
||||
|
||||
if (cmd[i] != '\0')
|
||||
if (cmd[i])
|
||||
strcpy(cmd, &cmd[i + 1]);
|
||||
else
|
||||
cmd_end = true;
|
||||
}
|
||||
|
||||
free(cmd);
|
||||
|
@ -239,9 +239,9 @@ int get_nick_truncate(Tox *m, char *buf, int friendnum)
|
||||
returns length of s if char not found */
|
||||
int char_find(int idx, const char *s, char ch)
|
||||
{
|
||||
int i = 0;
|
||||
int i = idx;
|
||||
|
||||
for (i = idx; s[i]; ++i) {
|
||||
for ( ; s[i]; ++i) {
|
||||
if (s[i] == ch)
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user