Commits

TakUnity  committed b7c6528

Handle multiple --config options.

  • Participants
  • Parent commits 5deee33

Comments (0)

Files changed (1)

 // Dump --config arguments into CHGCMDSERVEROPTS
 static int get_config_arguments (int argc, const char *argv[])
 {
+    int found = 0,
+        actualsize = BUFSIZ-1;
+    char opts[BUFSIZ];
+    opts[0] = '\0';
+
     for (int i=0; i<argc-1; ++i) {
         if (0 == strcmp ("--config", argv[i])) {
-            char opts[BUFSIZ];
-            snprintf (opts, BUFSIZ, "%s %s", argv[i], argv[i+1]);
-            setenv ("CHGCMDSERVEROPTS", opts, 1);
-            return 1;
+            strncat (opts, argv[i], actualsize);
+            strncat (opts, " ", actualsize);
+            strncat (opts, argv[i+1], actualsize);
+            strncat (opts, " ", actualsize);
+            found = 1;
         }
     }
 
-    return 0;
+    if (found)
+        setenv ("CHGCMDSERVEROPTS", opts, 1);
+
+    return found;
 }
 
 int main(int argc, const char *argv[], const char *envp[])