commit b75563b88e8d2718cf2a1027d3ee783889e52645
parent 33e1bf14350ff05a16374d73a5f16cc81ae890ee
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Tue, 28 May 2019 12:31:16 +0200
tweaks: use a symbol instead of zero to refer to standard input
Diffstat:
3 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/files.c b/src/files.c
@@ -827,7 +827,7 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable)
/* When reading from stdin, restore the terminal and reenter curses mode. */
if (isendwin()) {
- if (!isatty(0))
+ if (!isatty(STANDARD_INPUT))
reconnect_and_store_state();
terminal_init();
doupdate();
diff --git a/src/nano.c b/src/nano.c
@@ -1078,7 +1078,7 @@ void reconnect_and_store_state(void)
if (thetty < 1)
die(_("Could not reconnect stdin to keyboard\n"));
- dup2(thetty, 0);
+ dup2(thetty, STANDARD_INPUT);
close(thetty);
/* If input was not cut short, store the current state of the terminal. */
@@ -1096,7 +1096,7 @@ bool scoop_stdin(void)
tcsetattr(0, TCSANOW, &oldterm);
/* When input comes from a terminal, show a helpful message. */
- if (isatty(0))
+ if (isatty(STANDARD_INPUT))
fprintf(stderr, _("Reading data from keyboard; "
"type ^D or ^D^D to finish.\n"));
diff --git a/src/nano.h b/src/nano.h
@@ -146,6 +146,8 @@
#define BAD_COLOR -2
#endif
+#define STANDARD_INPUT 0
+
/* Enumeration types. */
typedef enum {
NIX_FILE, DOS_FILE, MAC_FILE