summary refs log tree commit diff
diff options
context:
space:
mode:
authoranton <anton>2018-02-19 19:29:42 +0000
committeranton <anton>2018-02-19 19:29:42 +0000
commit05510941822cb14969bae35d57ff7778fc4daee1 (patch)
tree8396455db01c726457d3bd7e1a2510987f747b88
parentb1929b5ed6a33fa6d031912c9963ab5e113f81ea (diff)
downloadcwm-05510941822cb14969bae35d57ff7778fc4daee1.tar.gz
cwm-05510941822cb14969bae35d57ff7778fc4daee1.tar.xz
cwm-05510941822cb14969bae35d57ff7778fc4daee1.zip
Do not print any parse errors when ~/.cwmrc is missing. Regression introduced in
revision 1.109 of calmwm.c.

ok okan@
-rw-r--r--parse.y20
1 files changed, 10 insertions, 10 deletions
diff --git a/parse.y b/parse.y
index 6c4a556..0e4f791 100644
--- a/parse.y
+++ b/parse.y
@@ -43,7 +43,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);
@@ -557,19 +557,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);
@@ -594,13 +588,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();