mirror of
https://github.com/leahneukirchen/cwm.git
synced 2023-08-10 21:13:12 +03:00
slightly alter the semantics of config files:
- if no config file, continue silently and apply defaults - if config file, parse and move on - if config file specified but not found, error out ok oga@
This commit is contained in:
parent
bdcbbe7f53
commit
9d9c61b8f6
8
conf.c
8
conf.c
@ -168,6 +168,8 @@ conf_init(struct conf *c)
|
|||||||
void
|
void
|
||||||
conf_setup(struct conf *c, const char *conf_file)
|
conf_setup(struct conf *c, const char *conf_file)
|
||||||
{
|
{
|
||||||
|
struct stat sb;
|
||||||
|
|
||||||
if (conf_file == NULL) {
|
if (conf_file == NULL) {
|
||||||
char *home = getenv("HOME");
|
char *home = getenv("HOME");
|
||||||
|
|
||||||
@ -177,7 +179,11 @@ conf_setup(struct conf *c, const char *conf_file)
|
|||||||
snprintf(c->conf_path, sizeof(c->conf_path), "%s/%s", home,
|
snprintf(c->conf_path, sizeof(c->conf_path), "%s/%s", home,
|
||||||
CONFFILE);
|
CONFFILE);
|
||||||
} else
|
} else
|
||||||
snprintf(c->conf_path, sizeof(c->conf_path), "%s", conf_file);
|
if (stat(conf_file, &sb) == -1 || !(sb.st_mode & S_IFREG))
|
||||||
|
errx(1, "%s: %s", conf_file, strerror(errno));
|
||||||
|
else
|
||||||
|
snprintf(c->conf_path, sizeof(c->conf_path), "%s",
|
||||||
|
conf_file);
|
||||||
|
|
||||||
conf_init(c);
|
conf_init(c);
|
||||||
|
|
||||||
|
1
parse.y
1
parse.y
@ -441,6 +441,7 @@ pushfile(const char *name)
|
|||||||
nfile->name = xstrdup(name);
|
nfile->name = xstrdup(name);
|
||||||
|
|
||||||
if ((nfile->stream = fopen(nfile->name, "r")) == NULL) {
|
if ((nfile->stream = fopen(nfile->name, "r")) == NULL) {
|
||||||
|
if (errno != ENOENT)
|
||||||
warn("%s", nfile->name);
|
warn("%s", nfile->name);
|
||||||
free(nfile->name);
|
free(nfile->name);
|
||||||
free(nfile);
|
free(nfile);
|
||||||
|
Loading…
Reference in New Issue
Block a user