Fix Issue 78 and apply PR 80.

This commit is contained in:
Arnold D. Robbins 2020-06-12 14:30:03 +03:00
parent b2de1c4ee7
commit cef5180110
3 changed files with 15 additions and 2 deletions

9
FIXES
View File

@ -25,6 +25,15 @@ THIS SOFTWARE.
This file lists all bug fixes, changes, etc., made since the AWK book
was sent to the printers in August, 1987.
June 12, 2020:
Clear errno before calling errcheck to avoid any spurious errors
left over from previous calls that may have set it. Thanks to
Todd Miller for the fix, from PR #80.
Fix Issue #78 by allowing \r to follow floating point numbers in
lib.c:is_number. Thanks to GitHub user ajcarr for the report
and to Arnold Robbins for the fix.
June 5, 2020:
In fldbld(), make sure that inputFS is set before trying to
use it. Thanks to Steffen Nurpmeso <steffen@sdaoden.eu>

6
lib.c
View File

@ -758,6 +758,9 @@ int isclvar(const char *s) /* is s of form var=something ? */
/* strtod is supposed to be a proper test of what's a valid number */
/* appears to be broken in gcc on linux: thinks 0x123 is a valid FP number */
/* wrong: violates 4.10.1.4 of ansi C standard */
/* well, not quite. As of C99, hex floating point is allowed. so this is
* a bit of a mess.
*/
#include <math.h>
int is_number(const char *s)
@ -768,7 +771,8 @@ int is_number(const char *s)
r = strtod(s, &ep);
if (ep == s || r == HUGE_VAL || errno == ERANGE)
return 0;
while (*ep == ' ' || *ep == '\t' || *ep == '\n')
/* allow \r as well. windows files aren't going to go away. */
while (*ep == ' ' || *ep == '\t' || *ep == '\n' || *ep == '\r')
ep++;
if (*ep == '\0')
return 1;

2
main.c
View File

@ -22,7 +22,7 @@ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
****************************************************************/
const char *version = "version 20200605";
const char *version = "version 20200612";
#define DEBUG
#include <stdio.h>