]> granicus.if.org Git - nethack/commitdiff
Handle windowtype and CHOOSE config errors
authorPasi Kallinen <paxed@alt.org>
Sat, 9 Sep 2017 10:50:34 +0000 (13:50 +0300)
committerPasi Kallinen <paxed@alt.org>
Sat, 9 Sep 2017 10:50:34 +0000 (13:50 +0300)
src/files.c
src/options.c
src/windows.c
sys/share/pcmain.c
sys/unix/unixmain.c

index 3f877b215c58a6b968672c85cec396bd8b82aeb5..0ec9ff8c52ac8f679e99b244afce8f1f87c6b4ef 100644 (file)
@@ -2293,6 +2293,10 @@ int src;
         section = choose_random_part(bufp, ',');
         if (section)
             config_section_chosen = dupstr(section);
+        else {
+            config_error_add("No config section to choose");
+            retval = 0;
+        }
     } else if (match_varname(buf, "AUTOPICKUP_EXCEPTION", 5)) {
         add_autopickup_exception(bufp);
     } else if (match_varname(buf, "BINDINGS", 4)) {
index f7a79493d0cf654f195655d27b0a4cfdf383674b..d8646c42ae649363519442942b6a5334d5e7acd3 100644 (file)
@@ -1200,9 +1200,8 @@ int iscompound; /* 0 == boolean option, 1 == compound */
      * For now just return.
      */
 #else /* !MAC */
-    raw_printf("\nWarning - %s option specified multiple times: %s.\n",
+    config_error_add("%s option specified multiple times: %s.\n",
                iscompound ? "compound" : "boolean", opts);
-    wait_synch();
 #endif /* ?MAC */
     return;
 }
index af3d978cf1585ddb8baa089299ad1c914a1150eb..a23ec95c70eccf2a20e2814ba3ac5e6359daf5d8 100644 (file)
@@ -238,22 +238,25 @@ const char *s;
         exit(EXIT_FAILURE);
     }
     if (!winchoices[1].procs) {
-        raw_printf("Window type %s not recognized.  The only choice is: %s.",
+        config_error_add("Window type %s not recognized.  The only choice is: %s",
                    s, winchoices[0].procs->name);
     } else {
-        raw_printf("Window type %s not recognized.  Choices are:", s);
+        char buf[BUFSZ];
+        boolean first = TRUE;
+        buf[0] = '\0';
         for (i = 0; winchoices[i].procs; i++) {
             if ('+' == winchoices[i].procs->name[0])
                 continue;
             if ('-' == winchoices[i].procs->name[0])
                 continue;
-            raw_printf("        %s", winchoices[i].procs->name);
+            Sprintf(eos(buf), "%s%s", first ? "" : ",", winchoices[i].procs->name);
+            first = FALSE;
         }
+        config_error_add("Window type %s not recognized.  Choices are: %s", s, buf);
     }
 
     if (windowprocs.win_raw_print == def_raw_print)
         nh_terminate(EXIT_SUCCESS);
-    wait_synch();
 }
 
 #ifdef WINCHAIN
index df756234a2662575b4bf19312862e501c10fa584..a515541c284ea1d4ff48c691f8bb155edfffdcac 100644 (file)
@@ -776,7 +776,9 @@ char *argv[];
                             NHWinMainInit();
                         }
             */
+            config_error_init(FALSE, "command line");
             choose_windows(&argv[0][2]);
+            config_error_done();
             break;
 #endif
         case '@':
index 1c0d55f90f5c38d48b214292a0d026a4f17cfca6..61db447099a5668414629aa88f2ca49a9b0e9162 100644 (file)
@@ -405,7 +405,9 @@ char *argv[];
             }
             break;
         case 'w': /* windowtype */
+            config_error_init(FALSE, "command line");
             choose_windows(&argv[0][2]);
+            config_error_done();
             break;
         case '@':
             flags.randomall = 1;