aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--awk.h6
-rw-r--r--debug.c12
-rw-r--r--io.c4
-rw-r--r--main.c2
-rw-r--r--pc/ChangeLog5
-rw-r--r--pc/config.h4
-rw-r--r--pc/gawkmisc.pc12
-rw-r--r--posix/ChangeLog4
-rw-r--r--posix/gawkmisc.c8
10 files changed, 47 insertions, 18 deletions
diff --git a/ChangeLog b/ChangeLog
index 7264bb3e..c0137952 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Fri Apr 1 11:49:17 2011 Arnold D. Robbins <arnold@skeeve.com>
+
+ Change ISATTY macro to os_isatty function.
+
+ * awk.h (ISATTY): Remove definition.
+ (os_isatty): Add declaration.
+ * debug.c, io.c, main.c: Change all calls.
+
Thu Mar 31 22:57:36 2011 Arnold D. Robbins <arnold@skeeve.com>
* Checklist: Updated. This is a git-only file.
diff --git a/awk.h b/awk.h
index d5a3735e..d781ff65 100644
--- a/awk.h
+++ b/awk.h
@@ -163,11 +163,6 @@ typedef int off_t;
#define O_BINARY 0
#endif
-/* Windows needs a separate definition, see pc/config.h. */
-#ifndef ISATTY
-# define ISATTY(fd) isatty(fd)
-#endif
-
#ifndef HAVE_VPRINTF
#error "you lose: you need a system with vfprintf"
#endif /* HAVE_VPRINTF */
@@ -1279,6 +1274,7 @@ extern char *gawk_name(const char *filespec);
extern void os_arg_fixup(int *argcp, char ***argvp);
extern int os_devopen(const char *name, int flag);
extern void os_close_on_exec(int fd, const char *name, const char *what, const char *dir);
+extern int os_isatty(int fd);
extern int os_isdir(int fd);
extern int os_is_setuid(void);
extern int os_setbinmode(int fd, int mode);
diff --git a/debug.c b/debug.c
index 1086563b..3726f054 100644
--- a/debug.c
+++ b/debug.c
@@ -2738,7 +2738,7 @@ interpret(INSTRUCTION *pc)
input_fd = fileno(stdin);
out_fp = stdout;
- if (ISATTY(input_fd))
+ if (os_isatty(input_fd))
input_from_tty = TRUE;
if (input_fd == 0 && input_from_tty)
initialize_readline();
@@ -4089,7 +4089,7 @@ do_option(CMDARG *arg, int cmd ATTRIBUTE_UNUSED)
void
initialize_pager(FILE *fp)
{
- if (! ISATTY(fileno(fp)) || ! input_from_tty || input_fd != 0) {
+ if (! os_isatty(fileno(fp)) || ! input_from_tty || input_fd != 0) {
screen_width = INT_MAX;
screen_height = INT_MAX;
} else {
@@ -4113,7 +4113,7 @@ prompt_continue(FILE *fp)
{
int quit_pager = FALSE;
- if (ISATTY(fileno(fp)) && input_fd == 0)
+ if (os_isatty(fileno(fp)) && input_fd == 0)
quit_pager = prompt_yes_no(
_("\t------[Enter] to continue or q [Enter] to quit------"),
_("q")[0], FALSE, fp);
@@ -5071,7 +5071,7 @@ set_gawk_output(const char *file)
efree(output_file);
}
output_fp = stdout;
- output_is_tty = ISATTY(fileno(stdout));
+ output_is_tty = os_isatty(fileno(stdout));
output_file = "/dev/stdout";
}
@@ -5092,7 +5092,7 @@ set_gawk_output(const char *file)
if (STREQ(cp, "stderr")) {
output_fp = stderr;
output_file = "/dev/stderr";
- output_is_tty = ISATTY(fileno(stderr));
+ output_is_tty = os_isatty(fileno(stderr));
return;
}
@@ -5125,7 +5125,7 @@ set_gawk_output(const char *file)
output_fp = fp;
output_file = estrdup(file, strlen(file));
setbuf(fp, (char *) NULL);
- output_is_tty = ISATTY(fileno(fp));
+ output_is_tty = os_isatty(fileno(fp));
} else {
d_error(_("could not open `%s' for writing (%s)"),
file,
diff --git a/io.c b/io.c
index c9d421bd..dfe449cd 100644
--- a/io.c
+++ b/io.c
@@ -781,7 +781,7 @@ redirect(NODE *redir_exp, int redirtype, int *errflg)
if (rp->fp == NULL)
close(fd);
}
- if (rp->fp != NULL && ISATTY(fd))
+ if (rp->fp != NULL && os_isatty(fd))
rp->flag |= RED_NOBUF;
/* Move rp to the head of the list. */
@@ -2561,7 +2561,7 @@ iop_alloc(int fd, const char *name, IOBUF *iop, int do_openhooks)
return NULL;
}
- if (ISATTY(iop->fd))
+ if (os_isatty(iop->fd))
iop->flag |= IOP_IS_TTY;
iop->readsize = iop->size = optimal_bufsize(iop->fd, & sbuf);
iop->sbuf = sbuf;
diff --git a/main.c b/main.c
index b1773d25..b60692a3 100644
--- a/main.c
+++ b/main.c
@@ -621,7 +621,7 @@ out:
#ifdef GAWKDEBUG
setbuf(stdout, (char *) NULL); /* make debugging easier */
#endif
- if (ISATTY(fileno(stdout)))
+ if (os_isatty(fileno(stdout)))
output_is_tty = TRUE;
/* No -f or --source options, use next arg */
if (srcfiles->next == srcfiles) {
diff --git a/pc/ChangeLog b/pc/ChangeLog
index 316b23f7..532ea8b2 100644
--- a/pc/ChangeLog
+++ b/pc/ChangeLog
@@ -1,3 +1,8 @@
+Fri Apr 1 11:50:59 2011 Arnold D. Robbins <arnold@skeeve.com>
+
+ * config.h (ISATTY): Remove definition.
+ * gawkmisc.pc (os_iastty): New function.
+
Sun Feb 27 22:58:08 2011 Scott Deifik <scottd.mail@sbcglobal.net>
* Makefile.tst: Sync with mainline version.
diff --git a/pc/config.h b/pc/config.h
index 4ec2d711..4dd797c1 100644
--- a/pc/config.h
+++ b/pc/config.h
@@ -518,8 +518,4 @@
#define HAVE_USLEEP 1
#endif
-#if defined(__MINGW32__) || defined(_MSC_VER)
-# define ISATTY(fd) (isatty(fd) && lseek(fd,SEEK_CUR,0) == -1)
-#endif
-
/* #define NO_LINT 1 */
diff --git a/pc/gawkmisc.pc b/pc/gawkmisc.pc
index 67760676..43f81ff9 100644
--- a/pc/gawkmisc.pc
+++ b/pc/gawkmisc.pc
@@ -280,6 +280,18 @@ int fd;
setmode(fd, orig_tty_mode);
}
}
+
+/* os_isatty --- return true if fd is a tty */
+
+int
+os_isatty(int fd)
+{
+#if defined(__MINGW32__) || defined(_MSC_VER)
+ return (isatty(fd) && lseek(fd, SEEK_CUR, 0) == -1);
+#else
+ return isatty(fd);
+#endif
+}
/* files_are_same --- return true if files are identical */
diff --git a/posix/ChangeLog b/posix/ChangeLog
index e0cce059..ceecc6b5 100644
--- a/posix/ChangeLog
+++ b/posix/ChangeLog
@@ -1,3 +1,7 @@
+Fri Apr 1 11:50:59 2011 Arnold D. Robbins <arnold@skeeve.com>
+
+ * gawkmisc.c (os_iastty): New function.
+
Sun Feb 13 20:23:34 2011 Eli Zaretskii <eliz@gnu.org>
* gawkmisc.c (files_are_same): Change arguments; call `stat' as
diff --git a/posix/gawkmisc.c b/posix/gawkmisc.c
index 8c40f538..6290ff57 100644
--- a/posix/gawkmisc.c
+++ b/posix/gawkmisc.c
@@ -234,6 +234,14 @@ os_restore_mode(int fd)
/* no-op */
return;
}
+
+/* os_isatty --- return true if fd is a tty */
+
+int
+os_isatty(int fd)
+{
+ return isatty(fd);
+}
/* files_are_same --- return true if files are identical */