]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - test/picsmap.c
ncurses 6.2 - patch 20200718
[ncurses.git] / test / picsmap.c
index baa5de8465f04cab54befa838eabe4568ca303aa..3c4eb697a4de710a91be75b4e3aa3732bff09dbb 100644 (file)
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2017-2018,2019 Free Software Foundation, Inc.              *
+ * Copyright 2018-2019,2020 Thomas E. Dickey                                *
+ * Copyright 2017,2018 Free Software Foundation, Inc.                       *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -26,7 +27,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: picsmap.c,v 1.130 2019/08/24 23:07:34 tom Exp $
+ * $Id: picsmap.c,v 1.134 2020/07/11 23:01:49 tom Exp $
  *
  * Author: Thomas E. Dickey
  *
@@ -103,7 +104,7 @@ typedef struct {
 #define P2I(n) (((int)(my_intptr_t)(n)) - 1)
 #define I2P(n) (void *)(my_intptr_t)((n) + 1)
 
-#define stop_curses() if (in_curses) endwin()
+#define pause_curses() if (in_curses) stop_curses()
 
 #define debugmsg if (debugging) logmsg
 #define debugmsg2 if (debugging) logmsg2
@@ -187,7 +188,7 @@ close_log(void)
 static void
 cleanup(int code)
 {
-    stop_curses();
+    pause_curses();
     close_log();
     ExitProgram(code);
     /* NOTREACHED */
@@ -423,7 +424,7 @@ read_file(const char *filename)
     struct stat sb;
 
     if (!quiet) {
-       stop_curses();
+       pause_curses();
        printf("** %s\n", filename);
     }
 
@@ -511,7 +512,7 @@ usage(void)
     };
     size_t n;
 
-    stop_curses();
+    pause_curses();
 
     fflush(stdout);
     for (n = 0; n < SIZEOF(msg); n++)
@@ -524,7 +525,7 @@ giveup(const char *fmt, ...)
 {
     va_list ap;
 
-    stop_curses();
+    pause_curses();
     fflush(stdout);
 
     va_start(ap, fmt);
@@ -954,6 +955,20 @@ parse_rgb(char **data)
     return result;
 }
 
+#define LOWERCASE(c) ((isalpha(UChar(c)) && isupper(UChar(c))) ? tolower(UChar(c)) : (c))
+
+static int
+CaselessCmp(const char *a, const char *b)
+{                              /* strcasecmp isn't portable */
+    while (*a && *b) {
+       int cmp = LOWERCASE(*a) - LOWERCASE(*b);
+       if (cmp != 0)
+           break;
+       a++, b++;
+    }
+    return LOWERCASE(*a) - LOWERCASE(*b);
+}
+
 static RGB_NAME *
 lookup_rgb(const char *name)
 {
@@ -961,7 +976,7 @@ lookup_rgb(const char *name)
     if (rgb_table != 0) {
        int n;
        for (n = 0; rgb_table[n].name != 0; ++n) {
-           if (!strcasecmp(name, rgb_table[n].name)) {
+           if (!CaselessCmp(name, rgb_table[n].name)) {
                result = &rgb_table[n];
                break;
            }
@@ -1469,7 +1484,7 @@ init_display(const char *palette_path, int opt_d)
            init_palette(palette_path);
        }
        scrollok(stdscr, FALSE);
-       exit_curses();
+       stop_curses();
     }
 }