1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-11-30 02:13:28 +01:00

small fix

This commit is contained in:
Jfreegman 2014-07-16 21:32:47 -04:00
parent 4426eaddd9
commit b5f34f42a8
2 changed files with 7 additions and 5 deletions

View File

@ -84,14 +84,14 @@ static int parse_command(WINDOW *w, ToxWindow *self, const char *input, char (*a
char *cmd = strdup(input); char *cmd = strdup(input);
int num_args = 0; int num_args = 0;
int i = 0; /* index of last char in an argument */ int i = 0; /* index of last char in an argument */
bool cmd_end = false;
/* characters wrapped in double quotes count as one arg */ /* 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 */ int qt_ofst = 0; /* set to 1 to offset index for quote char at end of arg */
if (*cmd == '\"') { if (*cmd == '\"') {
qt_ofst = 1; qt_ofst = 1;
i = char_find(1, cmd, '\"'); i = char_find(1, cmd, '\"');
if (cmd[i] == '\0') { 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); memcpy(args[num_args], cmd, i + qt_ofst);
args[num_args++][i + qt_ofst] = '\0'; args[num_args++][i + qt_ofst] = '\0';
if (cmd[i] != '\0') if (cmd[i])
strcpy(cmd, &cmd[i + 1]); strcpy(cmd, &cmd[i + 1]);
else
cmd_end = true;
} }
free(cmd); free(cmd);

View File

@ -239,9 +239,9 @@ int get_nick_truncate(Tox *m, char *buf, int friendnum)
returns length of s if char not found */ returns length of s if char not found */
int char_find(int idx, const char *s, char ch) 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) if (s[i] == ch)
break; break;
} }