Skip to content

Commit a96cfdd

Browse files
committed
fix a subtle bug in check_strnum - seems that in the Linux branch, it's
not resetting errno before calling strtod to check conversion, making it fail "sometimes". My source-history says this was broken in 1.3.3
1 parent c9331c8 commit a96cfdd

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

cast.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/********************************************
22
cast.c
3-
copyright 2009-2012,2013 Thomas E. Dickey
3+
copyright 2009-2013,2014, Thomas E. Dickey
44
copyright 1991-1995,1996, Michael D. Brennan
55
66
This is a source file for mawk, an implementation of
@@ -11,7 +11,7 @@ the GNU General Public License, version 2, 1991.
1111
********************************************/
1212

1313
/*
14-
* $MawkId: cast.c,v 1.19 2013/12/26 23:23:55 tom Exp $
14+
* $MawkId: cast.c,v 1.20 2014/09/14 20:14:16 tom Exp $
1515
* @Log: cast.c,v @
1616
* Revision 1.6 1996/08/11 22:07:50 mike
1717
* Fix small bozo in rt_error("overflow converting ...")
@@ -88,8 +88,8 @@ cast1_to_d(CELL *cp)
8888
{
8989
register STRING *s = (STRING *) cp->ptr;
9090

91-
#ifdef FPE_TRAPS_ON /* look for overflow error */
9291
errno = 0;
92+
#ifdef FPE_TRAPS_ON /* look for overflow error */
9393
cp->dval = strtod(s->str, (char **) 0);
9494
if (errno && cp->dval != 0.0) /* ignore underflow */
9595
rt_error("overflow converting %s to double", s->str);
@@ -131,8 +131,8 @@ cast2_to_d(CELL *cp)
131131
case C_STRING:
132132
s = (STRING *) cp->ptr;
133133

134-
#ifdef FPE_TRAPS_ON /* look for overflow error */
135134
errno = 0;
135+
#ifdef FPE_TRAPS_ON /* look for overflow error */
136136
cp->dval = strtod(s->str, (char **) 0);
137137
if (errno && cp->dval != 0.0) /* ignore underflow */
138138
rt_error("overflow converting %s to double", s->str);
@@ -165,8 +165,8 @@ cast2_to_d(CELL *cp)
165165
case C_STRING:
166166
s = (STRING *) cp->ptr;
167167

168-
#ifdef FPE_TRAPS_ON /* look for overflow error */
169168
errno = 0;
169+
#ifdef FPE_TRAPS_ON /* look for overflow error */
170170
cp->dval = strtod(s->str, (char **) 0);
171171
if (errno && cp->dval != 0.0) /* ignore underflow */
172172
rt_error("overflow converting %s to double", s->str);
@@ -382,8 +382,8 @@ check_strnum(CELL *cp)
382382
case SC_MINUS:
383383
case SC_DOT:
384384

385-
#ifdef FPE_TRAPS_ON
386385
errno = 0;
386+
#ifdef FPE_TRAPS_ON
387387
cp->dval = strtod((char *) s, &temp);
388388
/* make overflow pure string */
389389
if (errno && cp->dval != 0.0)

0 commit comments

Comments
 (0)