From 18c6b0f85db6683f1d0789e800acfdd35da3ce07 Mon Sep 17 00:00:00 2001 From: "Andrew J. Schorr" Date: Mon, 13 Jun 2016 18:39:10 -0400 Subject: Fix usage of scalar type flag bits and fix some bugs in numeric conversions and lint checks. --- io.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'io.c') diff --git a/io.c b/io.c index db903fd7..9d827d75 100644 --- a/io.c +++ b/io.c @@ -785,7 +785,7 @@ redirect_string(const char *str, size_t explen, bool not_string, cant_happen(); } if (do_lint && not_string) - lintwarn(_("expression in `%s' redirection only has numeric value"), + lintwarn(_("expression in `%s' redirection is a number"), what); if (str == NULL || *str == '\0') @@ -1083,7 +1083,7 @@ redirect_string(const char *str, size_t explen, bool not_string, struct redirect * redirect(NODE *redir_exp, int redirtype, int *errflg, bool failure_fatal) { - bool not_string = ((redir_exp->flags & STRCUR) == 0); + bool not_string = ((redir_exp->flags & STRING) == 0); redir_exp = force_string(redir_exp); return redirect_string(redir_exp->stptr, redir_exp->stlen, not_string, @@ -3896,8 +3896,7 @@ pty_vs_pipe(const char *command) */ val = in_PROCINFO(command, "pty", NULL); if (val) { - if ((val->flags & MAYBE_NUM) != 0) - (void) force_number(val); + val = fixtype(val); if ((val->flags & NUMBER) != 0) return ! iszero(val); else -- cgit v1.2.3 From 5826beec258141776469c5fd9b703d52c81a35fb Mon Sep 17 00:00:00 2001 From: "Andrew J. Schorr" Date: Tue, 14 Jun 2016 16:35:48 -0400 Subject: Add a new boolval function to awk.h to make sure we handle this consistently. --- io.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'io.c') diff --git a/io.c b/io.c index 9d827d75..94a5dfc3 100644 --- a/io.c +++ b/io.c @@ -3895,13 +3895,8 @@ pty_vs_pipe(const char *command) * in_PROCINFO function now checks that for us. */ val = in_PROCINFO(command, "pty", NULL); - if (val) { - val = fixtype(val); - if ((val->flags & NUMBER) != 0) - return ! iszero(val); - else - return (val->stlen != 0); - } + if (val) + return boolval(val); #endif /* HAVE_TERMIOS_H */ return false; } -- cgit v1.2.3 From 2d2744ec74076d29e94a2a004e308f73a86b9fa5 Mon Sep 17 00:00:00 2001 From: "Andrew J. Schorr" Date: Mon, 20 Jun 2016 10:10:30 -0400 Subject: Call fixtype in a few more places to make sure we check types properly. --- io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'io.c') diff --git a/io.c b/io.c index 94a5dfc3..b9bce694 100644 --- a/io.c +++ b/io.c @@ -1083,7 +1083,7 @@ redirect_string(const char *str, size_t explen, bool not_string, struct redirect * redirect(NODE *redir_exp, int redirtype, int *errflg, bool failure_fatal) { - bool not_string = ((redir_exp->flags & STRING) == 0); + bool not_string = ((fixtype(redir_exp)->flags & STRING) == 0); redir_exp = force_string(redir_exp); return redirect_string(redir_exp->stptr, redir_exp->stlen, not_string, -- cgit v1.2.3