shithub: trueawk

Download patch

ref: cef51801109a3032c66aa76503a92ce66724725a
parent: b2de1c4ee74c1283bae52cd6a94a56308430f79e
author: Arnold D. Robbins <arnold@skeeve.com>
date: Fri Jun 12 10:30:03 EDT 2020

Fix Issue 78 and apply PR 80.

--- a/FIXES
+++ b/FIXES
@@ -25,6 +25,15 @@
 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>
--- a/lib.c
+++ b/lib.c
@@ -758,6 +758,9 @@
 /* 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 @@
 	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;
--- a/main.c
+++ b/main.c
@@ -22,7 +22,7 @@
 THIS SOFTWARE.
 ****************************************************************/
 
-const char	*version = "version 20200605";
+const char	*version = "version 20200612";
 
 #define DEBUG
 #include <stdio.h>
--