shithub: trueawk

Download patch

ref: 3f04f886187fdde3001a1804d1bc1f5b150f1a41
parent: 5b9d0b92a9734854eea52ec1ead5355c62797bdd
author: ozan yigit <ozan.yigit@gmail.com>
date: Thu Sep 14 07:14:36 EDT 2023

length error in u8_byte2char that set RSTART to -1 for EOL match(str, /$/).

--- a/FIXES
+++ b/FIXES
@@ -25,6 +25,13 @@
 This file lists all bug fixes, changes, etc., made since the 
 second edition of the AWK book was published in September 2023.
 
+Sep 12, 2023:
+	Fixed a length error in u8_byte2char that set RSTART to
+	incorrect (cannot happen) value for EOL match(str, /$/).
+
+
+-----------------------------------------------------------------
+
 [This entry is a summary, not a precise list of changes.]
 
 	Added --csv option to enable processing of comma-separated
--- /dev/null
+++ b/bugs-fixed/rstart-rlength.awk
@@ -1,0 +1,10 @@
+BEGIN {
+	str="\342\200\257"
+	print length(str)
+	match(str,/^/)
+	print RSTART, RLENGTH	
+	match(str,/.+/)
+	print RSTART, RLENGTH
+	match(str,/$/)
+	print RSTART, RLENGTH
+}
--- /dev/null
+++ b/bugs-fixed/rstart-rlength.ok
@@ -1,0 +1,4 @@
+1
+1 0
+1 1
+2 0
--- a/run.c
+++ b/run.c
@@ -714,7 +714,7 @@
 	/* should be 0 to match start==0 which means no match */	
 
 	b = strlen(s);
-	if (bytenum >= b) {
+	if (bytenum > b) {
 		return -1; /* ??? */
 	}
 	for (i = 0; i <= bytenum; i += len) {
--