Imported Upstream version 7.44.0
[platform/upstream/curl.git] / src / tool_parsecfg.c
index c5d390b..39b43ee 100644 (file)
@@ -5,7 +5,7 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
  *
  * This software is licensed as described in the file COPYING, which
  * you should have received as part of this distribution. The terms
@@ -69,7 +69,7 @@ int parseconfig(const char *filename, struct GlobalConfig *global)
         /* Check if the file exists - if not, try CURLRC in the same
          * directory as our executable
          */
-        file = fopen(filebuffer, "r");
+        file = fopen(filebuffer, FOPEN_READTEXT);
         if(file != NULL) {
           fclose(file);
           filename = filebuffer;
@@ -114,8 +114,8 @@ int parseconfig(const char *filename, struct GlobalConfig *global)
 #endif
   }
 
-  if(strcmp(filename,"-"))
-    file = fopen(filename, "r");
+  if(strcmp(filename, "-"))
+    file = fopen(filename, FOPEN_READTEXT);
   else
     file = stdin;
 
@@ -187,24 +187,27 @@ int parseconfig(const char *filename, struct GlobalConfig *global)
         param = line; /* parameter starts here */
         while(*line && !ISSPACE(*line))
           line++;
-        *line = '\0'; /* zero terminate */
 
-        /* to detect mistakes better, see if there's data following */
-        line++;
-        /* pass all spaces */
-        while(*line && ISSPACE(*line))
-          line++;
+        if(*line) {
+          *line = '\0'; /* zero terminate */
 
-        switch(*line) {
-        case '\0':
-        case '\r':
-        case '\n':
-        case '#': /* comment */
-          break;
-        default:
-          warnf(operation, "%s:%d: warning: '%s' uses unquoted white space in"
-                " the line that may cause side-effects!\n",
-                filename, lineno, option);
+          /* to detect mistakes better, see if there's data following */
+          line++;
+          /* pass all spaces */
+          while(*line && ISSPACE(*line))
+            line++;
+
+          switch(*line) {
+          case '\0':
+          case '\r':
+          case '\n':
+          case '#': /* comment */
+            break;
+          default:
+            warnf(operation->global, "%s:%d: warning: '%s' uses unquoted "
+                  "white space in the line that may cause side-effects!\n",
+                  filename, lineno, option);
+          }
         }
       }
 
@@ -261,7 +264,7 @@ int parseconfig(const char *filename, struct GlobalConfig *global)
            res != PARAM_VERSION_INFO_REQUESTED &&
            res != PARAM_ENGINES_REQUESTED) {
           const char *reason = param2text(res);
-          warnf(operation, "%s:%d: warning: '%s' %s\n",
+          warnf(operation->global, "%s:%d: warning: '%s' %s\n",
                 filename, lineno, option, reason);
         }
       }