Forráskód Böngészése

don't abort of configfile does not exist

Wichert Akkerman 26 éve
szülő
commit
1819d9c3a6
1 módosított fájl, 6 hozzáadás és 1 törlés
  1. 6 1
      lib/myopt.c

+ 6 - 1
lib/myopt.c

@@ -21,6 +21,7 @@
  */
 
 #include <string.h>
+#include <errno.h>
 
 #include <config.h>
 #include <myopt.h>
@@ -31,7 +32,11 @@ void myfileopt(const char* fn, const struct cmdinfo* cmdinfos) {
   char linebuf[MAXDIVERTFILENAME];
 
   file= fopen(fn, "r");
-  if (!file) ohshite(_("failed to open configuration file `%.255s' for reading"), fn);
+  if (!file) {
+    if (errno==ENOENT)
+      return;
+    ohshite(_("failed to open configuration file `%.255s' for reading"), fn);
+  }
 
   while (fgets(linebuf, sizeof(linebuf), file)) {
     char* opt;