]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - progs/tset.c
ncurses 5.4
[ncurses.git] / progs / tset.c
index 03c8ffde33afa611a7391dbc012ef29f8dda23c4..f67931f0506e31766ea6ec3e707e67282eaa5746 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2002,2003 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            *
@@ -103,7 +103,7 @@ char *ttyname(int fd);
 #include <dump_entry.h>
 #include <transform.h>
 
-MODULE_ID("$Id: tset.c,v 0.53 2002/08/24 23:18:16 tom Exp $")
+MODULE_ID("$Id: tset.c,v 0.56 2003/12/06 17:21:01 tom Exp $")
 
 extern char **environ;
 
@@ -142,7 +142,7 @@ exit_error(void)
        SET_TTY(STDERR_FILENO, &original);
     (void) fprintf(stderr, "\n");
     fflush(stderr);
-    exit(EXIT_FAILURE);
+    ExitProgram(EXIT_FAILURE);
     /* NOTREACHED */
 }
 
@@ -350,7 +350,7 @@ add_mapping(const char *port, char *arg)
     char *base = 0;
 
     copy = strdup(arg);
-    mapp = malloc(sizeof(MAP));
+    mapp = (MAP *) malloc(sizeof(MAP));
     if (copy == 0 || mapp == 0)
        failed("malloc");
     mapp->next = 0;
@@ -627,8 +627,10 @@ get_termcap_entry(char *userarg)
  **************************************************************************/
 
 /* some BSD systems have these built in, some systems are missing
- * one or more definitions. The safest solution is to override.
+ * one or more definitions. The safest solution is to override unless the
+ * commonly-altered ones are defined.
  */
+#if !(defined(CERASE) && defined(CINTR) && defined(CKILL) && defined(CQUIT))
 #undef CEOF
 #undef CERASE
 #undef CINTR
@@ -639,18 +641,39 @@ get_termcap_entry(char *userarg)
 #undef CSTART
 #undef CSTOP
 #undef CSUSP
+#endif
 
 /* control-character defaults */
+#ifndef CEOF
 #define CEOF   CTRL('D')
+#endif
+#ifndef CERASE
 #define CERASE CTRL('H')
+#endif
+#ifndef CINTR
 #define CINTR  127             /* ^? */
+#endif
+#ifndef CKILL
 #define CKILL  CTRL('U')
+#endif
+#ifndef CLNEXT
 #define CLNEXT  CTRL('v')
+#endif
+#ifndef CRPRNT
 #define CRPRNT  CTRL('r')
+#endif
+#ifndef CQUIT
 #define CQUIT  CTRL('\\')
+#endif
+#ifndef CSTART
 #define CSTART CTRL('Q')
+#endif
+#ifndef CSTOP
 #define CSTOP  CTRL('S')
+#endif
+#ifndef CSUSP
 #define CSUSP  CTRL('Z')
+#endif
 
 #define        CHK(val, dft)   ((int)val <= 0 ? dft : val)
 
@@ -1183,8 +1206,8 @@ main(int argc, char **argv)
 #ifdef TERMIOS
        if (!quiet) {
            report("Erase", VERASE, CERASE);
-           report("Kill", VKILL, CINTR);
-           report("Interrupt", VINTR, CKILL);
+           report("Kill", VKILL, CKILL);
+           report("Interrupt", VINTR, CINTR);
        }
 #endif
     }
@@ -1193,12 +1216,14 @@ main(int argc, char **argv)
        err("The -S option is not supported under terminfo.");
 
     if (sflag) {
+       int len;
        /*
         * Figure out what shell we're using.  A hack, we look for an
         * environmental variable SHELL ending in "csh".
         */
        if ((p = getenv("SHELL")) != 0
-           && !strcmp(p + strlen(p) - 3, "csh"))
+           && (len = strlen(p)) >= 3
+           && !strcmp(p + len - 3, "csh"))
            p = "set noglob;\nsetenv TERM %s;\nunset noglob;\n";
        else
            p = "TERM=%s;\n";
@@ -1207,5 +1232,3 @@ main(int argc, char **argv)
 
     return EXIT_SUCCESS;
 }
-
-/* tset.c ends here */