summaryrefslogtreecommitdiff
path: root/src/stty.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/stty.c')
-rw-r--r--src/stty.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/src/stty.c b/src/stty.c
index eb07f853..ee891a59 100644
--- a/src/stty.c
+++ b/src/stty.c
@@ -1,5 +1,5 @@
/* stty -- change and print terminal line settings
- Copyright (C) 1990-2012 Free Software Foundation, Inc.
+ Copyright (C) 1990-2013 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -52,6 +52,7 @@
#endif
#include <getopt.h>
#include <stdarg.h>
+#include <assert.h>
#include "system.h"
#include "error.h"
@@ -216,6 +217,9 @@ static struct mode_info const mode_info[] =
#ifdef CRTSCTS
{"crtscts", control, REV, CRTSCTS, 0},
#endif
+#ifdef CDTRDSR
+ {"cdtrdsr", control, REV, CDTRDSR, 0},
+#endif
{"ignbrk", input, SANE_UNSET | REV, IGNBRK, 0},
{"brkint", input, SANE_SET | REV, BRKINT, 0},
@@ -514,7 +518,11 @@ Usage: %s [-F DEVICE | --file=DEVICE] [SETTING]...\n\
program_name, program_name, program_name);
fputs (_("\
Print or change terminal characteristics.\n\
-\n\
+"), stdout);
+
+ emit_mandatory_arg_note ();
+
+ fputs (_("\
-a, --all print all current settings in human-readable form\n\
-g, --save print all current settings in a stty-readable form\n\
-F, --file=DEVICE open and use the specified DEVICE instead of stdin\n\
@@ -576,6 +584,7 @@ Control settings:\n\
[-]clocal disable modem control signals\n\
[-]cread allow input to be received\n\
* [-]crtscts enable RTS/CTS handshaking\n\
+ * [-]cdtrdsr enable DTR/DSR handshaking\n\
csN set character size to N bits, N in [5..8]\n\
"), stdout);
fputs (_("\
@@ -583,7 +592,7 @@ Control settings:\n\
[-]hup send a hangup signal when the last process closes the tty\n\
[-]hupcl same as [-]hup\n\
[-]parenb generate parity bit in output and expect parity bit in input\n\
- [-]parodd set odd parity (even with '-')\n\
+ [-]parodd set odd parity (or even parity with '-')\n\
"), stdout);
fputs (_("\
\n\
@@ -729,14 +738,14 @@ main (int argc, char **argv)
{
/* Initialize to all zeroes so there is no risk memcmp will report a
spurious difference in an uninitialized portion of the structure. */
- struct termios mode = { 0, };
+ static struct termios mode;
enum output_type output_type;
int optc;
int argi = 0;
int opti = 1;
bool require_set_attr;
- bool speed_was_set;
+ bool speed_was_set ATTRIBUTE_UNUSED;
bool verbose_output;
bool recoverable_output;
int k;
@@ -1002,7 +1011,7 @@ main (int argc, char **argv)
{
/* Initialize to all zeroes so there is no risk memcmp will report a
spurious difference in an uninitialized portion of the structure. */
- struct termios new_mode = { 0, };
+ static struct termios new_mode;
if (tcsetattr (STDIN_FILENO, TCSADRAIN, &mode))
error (EXIT_FAILURE, errno, "%s", device_name);
@@ -1538,6 +1547,12 @@ display_changed (struct termios *mode)
bitsp = mode_type_flag (mode_info[i].type, mode);
mask = mode_info[i].mask ? mode_info[i].mask : mode_info[i].bits;
+
+ /* bitsp would be NULL only for "combination" modes, yet those
+ are filtered out above via the OMIT flag. Tell static analysis
+ tools that it's ok to dereference bitsp here. */
+ assert (bitsp);
+
if ((*bitsp & mask) == mode_info[i].bits)
{
if (mode_info[i].flags & SANE_UNSET)
@@ -1615,6 +1630,7 @@ display_all (struct termios *mode, char const *device_name)
bitsp = mode_type_flag (mode_info[i].type, mode);
mask = mode_info[i].mask ? mode_info[i].mask : mode_info[i].bits;
+ assert (bitsp); /* See the identical assertion and comment above. */
if ((*bitsp & mask) == mode_info[i].bits)
wrapf ("%s", mode_info[i].name);
else if (mode_info[i].flags & REV)