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);
|
||||
if (!key) continue;
|
||||
if (strcasecmp(key, "name") == 0) {
|
||||
save += strspn(save, " \t");
|
||||
size_t len = strlen(save);
|
||||
if (save) save += strspn(save, " \t");
|
||||
size_t len = save ? strlen(save) : 0;
|
||||
while (len && (save[len - 1] == ' ' || save[len - 1] == '\t'))
|
||||
save[--len] = 0;
|
||||
if (last && *save) {
|
||||
if (last && len) {
|
||||
free(last->name);
|
||||
last->name = dupstr(save);
|
||||
} else {
|
||||
|
|
@ -662,8 +662,8 @@ static void load_config(const char *path)
|
|||
continue;
|
||||
}
|
||||
if (strcasecmp(key, "autocommand") == 0) {
|
||||
save += strspn(save, " \t");
|
||||
if (last && *save && strlen(save) <= MAXLINE - 2 &&
|
||||
if (save) save += strspn(save, " \t");
|
||||
if (last && save && *save && strlen(save) <= MAXLINE - 2 &&
|
||||
!strchr(save, '\r')) {
|
||||
free(last->autocommand);
|
||||
last->autocommand = dupstr(save);
|
||||
|
|
@ -684,11 +684,11 @@ static void load_config(const char *path)
|
|||
*channel_tail = channel;
|
||||
channel_tail = &channel->next;
|
||||
|
||||
save += strspn(save, " \t");
|
||||
if (*save == '/' && save[1] && strlen(save) < MAXINPUT &&
|
||||
!strchr(save, '\r'))
|
||||
channel->command = dupstr(save);
|
||||
else if (*save)
|
||||
const char *command = save ? save + strspn(save, " \t") : "";
|
||||
if (*command == '/' && command[1] && strlen(command) < MAXINPUT &&
|
||||
!strchr(command, '\r'))
|
||||
channel->command = dupstr(command);
|
||||
else if (*command)
|
||||
fprintf(stderr, "irc9: ignoring invalid command for channel %s\n", a1);
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue