]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - progs/tset.c
ncurses 6.2 - patch 20200906
[ncurses.git] / progs / tset.c
index d660d84d0f21787787eb24dccaee93a0d1e25bf9..4d33ca8789c279fb34b544210fc6a39e53dd2981 100644 (file)
@@ -1,5 +1,6 @@
 /****************************************************************************
 /****************************************************************************
- * Copyright (c) 1998-2016,2017 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1998-2016,2017 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            *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -97,7 +98,7 @@
 char *ttyname(int fd);
 #endif
 
 char *ttyname(int fd);
 #endif
 
-MODULE_ID("$Id: tset.c,v 1.116 2017/01/07 22:48:20 tom Exp $")
+MODULE_ID("$Id: tset.c,v 1.125 2020/09/05 22:54:47 tom Exp $")
 
 #ifndef environ
 extern char **environ;
 
 #ifndef environ
 extern char **environ;
@@ -132,7 +133,7 @@ exit_error(void)
 }
 
 static void
 }
 
 static void
-err(const char *fmt,...)
+err(const char *fmt, ...)
 {
     va_list ap;
     va_start(ap, fmt);
 {
     va_list ap;
     va_start(ap, fmt);
@@ -226,10 +227,16 @@ static MAP *cur, *maplist;
 #define DATA(name,value) { { name }, value }
 
 typedef struct speeds {
 #define DATA(name,value) { { name }, value }
 
 typedef struct speeds {
-    const char string[7];
+    const char string[8];
     int speed;
 } SPEEDS;
 
     int speed;
 } SPEEDS;
 
+#if defined(EXP_WIN32_DRIVER)
+static const SPEEDS speeds[] =
+{
+    {"0", 0}
+};
+#else
 static const SPEEDS speeds[] =
 {
     DATA("0", B0),
 static const SPEEDS speeds[] =
 {
     DATA("0", B0),
@@ -330,6 +337,7 @@ static const SPEEDS speeds[] =
 #endif
 };
 #undef DATA
 #endif
 };
 #undef DATA
+#endif
 
 static int
 tbaudrate(char *rate)
 
 static int
 tbaudrate(char *rate)
@@ -711,27 +719,36 @@ print_shell_commands(const char *ttype)
 static void
 usage(void)
 {
 static void
 usage(void)
 {
-#define DATA(s) s "\n"
+#define SKIP(s)                        /* nothing */
+#define KEEP(s) s "\n"
     static const char msg[] =
     {
     static const char msg[] =
     {
-       DATA("")
-       DATA("Options:")
-       DATA("  -c          set control characters")
-       DATA("  -e ch       erase character")
-       DATA("  -I          no initialization strings")
-       DATA("  -i ch       interrupt character")
-       DATA("  -k ch       kill character")
-       DATA("  -m mapping  map identifier to type")
-       DATA("  -Q          do not output control key settings")
-       DATA("  -r          display term on stderr")
-       DATA("  -s          output TERM set command")
-       DATA("  -V          print curses-version")
-       DATA("  -w          set window-size")
+       KEEP("")
+       KEEP("Options:")
+       SKIP("  -a arpanet  (obsolete)")
+       KEEP("  -c          set control characters")
+       SKIP("  -d dialup   (obsolete)")
+       KEEP("  -e ch       erase character")
+       KEEP("  -I          no initialization strings")
+       KEEP("  -i ch       interrupt character")
+       KEEP("  -k ch       kill character")
+       KEEP("  -m mapping  map identifier to type")
+       SKIP("  -p plugboard (obsolete)")
+       KEEP("  -Q          do not output control key settings")
+       KEEP("  -q          display term only, do no changes")
+       KEEP("  -r          display term on stderr")
+       SKIP("  -S          (obsolete)")
+       KEEP("  -s          output TERM set command")
+       KEEP("  -V          print curses-version")
+       KEEP("  -w          set window-size")
+       KEEP("")
+       KEEP("If neither -c/-w are given, both are assumed.")
     };
     };
-#undef DATA
+#undef KEEP
+#undef SKIP
     (void) fprintf(stderr, "Usage: %s [options] [terminal]\n", _nc_progname);
     fputs(msg, stderr);
     (void) fprintf(stderr, "Usage: %s [options] [terminal]\n", _nc_progname);
     fputs(msg, stderr);
-    exit_error();
+    ExitProgram(EXIT_FAILURE);
     /* NOTREACHED */
 }
 
     /* NOTREACHED */
 }
 
@@ -751,7 +768,7 @@ main(int argc, char **argv)
     int terasechar = -1;       /* new erase character */
     int intrchar = -1;         /* new interrupt character */
     int tkillchar = -1;                /* new kill character */
     int terasechar = -1;       /* new erase character */
     int intrchar = -1;         /* new interrupt character */
     int tkillchar = -1;                /* new kill character */
-    int my_fd = -1;
+    int my_fd;
     bool opt_c = FALSE;                /* set control-chars */
     bool opt_w = FALSE;                /* set window-size */
     TTY mode, oldmode;
     bool opt_c = FALSE;                /* set control-chars */
     bool opt_w = FALSE;                /* set window-size */
     TTY mode, oldmode;
@@ -759,7 +776,7 @@ main(int argc, char **argv)
     my_fd = STDERR_FILENO;
     obsolete(argv);
     noinit = noset = quiet = Sflag = sflag = showterm = 0;
     my_fd = STDERR_FILENO;
     obsolete(argv);
     noinit = noset = quiet = Sflag = sflag = showterm = 0;
-    while ((ch = getopt(argc, argv, "a:cd:e:Ii:k:m:p:qQSrsVw")) != -1) {
+    while ((ch = getopt(argc, argv, "a:cd:e:Ii:k:m:p:qQrSsVw")) != -1) {
        switch (ch) {
        case 'c':               /* set control-chars */
            opt_c = TRUE;
        switch (ch) {
        case 'c':               /* set control-chars */
            opt_c = TRUE;
@@ -825,10 +842,12 @@ main(int argc, char **argv)
     if (!opt_c && !opt_w)
        opt_c = opt_w = TRUE;
 
     if (!opt_c && !opt_w)
        opt_c = opt_w = TRUE;
 
-    my_fd = save_tty_settings(&mode);
+    my_fd = save_tty_settings(&mode, TRUE);
     oldmode = mode;
 #ifdef TERMIOS
     ospeed = (NCURSES_OSPEED) cfgetospeed(&mode);
     oldmode = mode;
 #ifdef TERMIOS
     ospeed = (NCURSES_OSPEED) cfgetospeed(&mode);
+#elif defined(EXP_WIN32_DRIVER)
+    ospeed = 0;
 #else
     ospeed = (NCURSES_OSPEED) mode.sg_ospeed;
 #endif
 #else
     ospeed = (NCURSES_OSPEED) mode.sg_ospeed;
 #endif