make complaints about unrecognized keywords more verbose

tell the user in what section the keyword appeared, as that may help
spotting mistakes like stray empty lines.
This commit is contained in:
Oswald Buddenhagen 2020-10-05 13:05:38 +02:00
parent 217764bd35
commit 09341c10c5
5 changed files with 11 additions and 9 deletions

View File

@ -425,7 +425,8 @@ load_config( const char *where )
if (*++p)
channel->boxes[fn] = nfstrdup( p );
} else if (!getopt_helper( &cfile, &cops, channel )) {
error( "%s:%d: unknown keyword '%s'\n", cfile.file, cfile.line, cfile.cmd );
error( "%s:%d: keyword '%s' is not recognized in Channel sections\n",
cfile.file, cfile.line, cfile.cmd );
cfile.err = 1;
}
}
@ -476,7 +477,7 @@ load_config( const char *where )
}
else
{
error( "%s:%d: unknown keyword '%s'\n",
error( "%s:%d: keyword '%s' is not recognized in Group sections\n",
cfile.file, cfile.line, cfile.cmd );
cfile.err = 1;
}
@ -511,7 +512,7 @@ load_config( const char *where )
}
else if (!getopt_helper( &cfile, &gcops, &global_conf ))
{
error( "%s:%d: unknown section keyword '%s'\n",
error( "%s:%d: '%s' is not a recognized section-starting or global keyword\n",
cfile.file, cfile.line, cfile.cmd );
cfile.err = 1;
while (getcline( &cfile ))

View File

@ -49,7 +49,7 @@ free_generic_messages( message_t *msgs )
}
void
parse_generic_store( store_conf_t *store, conffile_t *cfg )
parse_generic_store( store_conf_t *store, conffile_t *cfg, const char *type )
{
if (!strcasecmp( "Trash", cfg->cmd )) {
store->trash = nfstrdup( cfg->val );
@ -72,7 +72,7 @@ parse_generic_store( store_conf_t *store, conffile_t *cfg )
}
store->flat_delim = nfstrdup( cfg->val );
} else {
error( "%s:%d: unknown keyword '%s'\n", cfg->file, cfg->line, cfg->cmd );
error( "%s:%d: keyword '%s' is not recognized in %s sections\n", cfg->file, cfg->line, cfg->cmd, type );
cfg->err = 1;
}
}

View File

@ -276,7 +276,7 @@ struct driver {
uint count_generic_messages( message_t * );
void free_generic_messages( message_t * );
void parse_generic_store( store_conf_t *store, conffile_t *cfg );
void parse_generic_store( store_conf_t *store, conffile_t *cfg, const char *type );
store_t *proxy_alloc_store( store_t *real_ctx, const char *label );

View File

@ -3529,10 +3529,11 @@ imap_parse_store( conffile_t *cfg, store_conf_t **storep )
}
store->delimiter = cfg->val[0];
} else
parse_generic_store( &store->gen, cfg );
parse_generic_store( &store->gen, cfg, "IMAPStore" );
continue;
} else {
error( "%s:%d: unknown/misplaced keyword '%s'\n", cfg->file, cfg->line, cfg->cmd );
error( "%s:%d: keyword '%s' is not recognized in IMAPAccount sections\n",
cfg->file, cfg->line, cfg->cmd );
cfg->err = 1;
continue;
}

View File

@ -1913,7 +1913,7 @@ maildir_parse_store( conffile_t *cfg, store_conf_t **storep )
cfg->err = 1;
}
} else
parse_generic_store( &store->gen, cfg );
parse_generic_store( &store->gen, cfg, "MaildirStore" );
if (!store->inbox)
store->inbox = expand_strdup( "~/Maildir" );
if (store->sub_style == SUB_MAILDIRPP && store->gen.path) {