Handle missing config arguments on musl
This commit is contained in:
parent
e138004be9
commit
76578805ba
1 changed files with 10 additions and 10 deletions
20
irc9.c
20
irc9.c
|
|
@ -649,11 +649,11 @@ static void load_config(const char *path)
|
||||||
key = strtok_r(p, " \t", &save);
|
key = strtok_r(p, " \t", &save);
|
||||||
if (!key) continue;
|
if (!key) continue;
|
||||||
if (strcasecmp(key, "name") == 0) {
|
if (strcasecmp(key, "name") == 0) {
|
||||||
save += strspn(save, " \t");
|
if (save) save += strspn(save, " \t");
|
||||||
size_t len = strlen(save);
|
size_t len = save ? strlen(save) : 0;
|
||||||
while (len && (save[len - 1] == ' ' || save[len - 1] == '\t'))
|
while (len && (save[len - 1] == ' ' || save[len - 1] == '\t'))
|
||||||
save[--len] = 0;
|
save[--len] = 0;
|
||||||
if (last && *save) {
|
if (last && len) {
|
||||||
free(last->name);
|
free(last->name);
|
||||||
last->name = dupstr(save);
|
last->name = dupstr(save);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -662,8 +662,8 @@ static void load_config(const char *path)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (strcasecmp(key, "autocommand") == 0) {
|
if (strcasecmp(key, "autocommand") == 0) {
|
||||||
save += strspn(save, " \t");
|
if (save) save += strspn(save, " \t");
|
||||||
if (last && *save && strlen(save) <= MAXLINE - 2 &&
|
if (last && save && *save && strlen(save) <= MAXLINE - 2 &&
|
||||||
!strchr(save, '\r')) {
|
!strchr(save, '\r')) {
|
||||||
free(last->autocommand);
|
free(last->autocommand);
|
||||||
last->autocommand = dupstr(save);
|
last->autocommand = dupstr(save);
|
||||||
|
|
@ -684,11 +684,11 @@ static void load_config(const char *path)
|
||||||
*channel_tail = channel;
|
*channel_tail = channel;
|
||||||
channel_tail = &channel->next;
|
channel_tail = &channel->next;
|
||||||
|
|
||||||
save += strspn(save, " \t");
|
const char *command = save ? save + strspn(save, " \t") : "";
|
||||||
if (*save == '/' && save[1] && strlen(save) < MAXINPUT &&
|
if (*command == '/' && command[1] && strlen(command) < MAXINPUT &&
|
||||||
!strchr(save, '\r'))
|
!strchr(command, '\r'))
|
||||||
channel->command = dupstr(save);
|
channel->command = dupstr(command);
|
||||||
else if (*save)
|
else if (*command)
|
||||||
fprintf(stderr, "irc9: ignoring invalid command for channel %s\n", a1);
|
fprintf(stderr, "irc9: ignoring invalid command for channel %s\n", a1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue