about summary refs log tree commit diff
path: root/parse.y
diff options
context:
space:
mode:
authoranton <anton>2018-02-19 19:29:42 +0000
committeranton <anton>2018-02-19 19:29:42 +0000
commitcae69879221ff88eca85c731246eaf33a51ea50e (patch)
tree05400c8903ee52678b505d19aa97f0a8ffe71593 /parse.y
parentc6745ee21cabbdad5791494bb1d0a754ee264c39 (diff)
parent05510941822cb14969bae35d57ff7778fc4daee1 (diff)
downloadcwm-cae69879221ff88eca85c731246eaf33a51ea50e.tar.gz
cwm-cae69879221ff88eca85c731246eaf33a51ea50e.tar.xz
cwm-cae69879221ff88eca85c731246eaf33a51ea50e.zip
cvsimport
* refs/heads/master:
  Do not print any parse errors when ~/.cwmrc is missing. Regression introduced in revision 1.109 of calmwm.c.
  Store the screen's visual type and colormap.
  Consolidate region 'view' and 'area'.
  limit scope of screen_apply_gap()
  Clean up conf_file/homedir and conf_init() bits.
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y20
1 files changed, 10 insertions, 10 deletions
diff --git a/parse.y b/parse.y
index 1db92c0..e9dce3a 100644
--- a/parse.y
+++ b/parse.y
@@ -45,7 +45,7 @@ static struct file {
 	int			 lineno;
 	int			 errors;
 } *file, *topfile;
-struct file	*pushfile(const char *);
+struct file	*pushfile(const char *, FILE *);
 int		 popfile(void);
 int		 yyparse(void);
 int		 yylex(void);
@@ -559,19 +559,13 @@ nodigits:
 }
 
 struct file *
-pushfile(const char *name)
+pushfile(const char *name, FILE *stream)
 {
 	struct file	*nfile;
 
 	nfile = xcalloc(1, sizeof(struct file));
 	nfile->name = xstrdup(name);
-
-	if ((nfile->stream = fopen(nfile->name, "r")) == NULL) {
-		warn("%s", nfile->name);
-		free(nfile->name);
-		free(nfile);
-		return (NULL);
-	}
+	nfile->stream = stream;
 	nfile->lineno = 1;
 	TAILQ_INSERT_TAIL(&files, nfile, entry);
 	return (nfile);
@@ -596,13 +590,19 @@ popfile(void)
 int
 parse_config(const char *filename, struct conf *xconf)
 {
+	FILE		*stream;
 	int		 errors = 0;
 
 	conf = xconf;
 
-	if ((file = pushfile(filename)) == NULL) {
+	stream = fopen(filename, "r");
+	if (stream == NULL) {
+		if (errno == ENOENT)
+			return (0);
+		warn("%s", filename);
 		return (-1);
 	}
+	file = pushfile(filename, stream);
 	topfile = file;
 
 	yyparse();