git: 9front

Download patch

ref: 53004d7576b54fe18002db7fa106a5434e2698a5
parent: e1f5e4bb32d799e1313ee052092dea30ccc2b879
author: qwx <qwx@sciops.net>
date: Mon Jan 19 07:48:36 EST 2026

awk: fix multibyte \ddd octals in regex

--- a/sys/src/cmd/awk/re.c
+++ b/sys/src/cmd/awk/re.c
@@ -285,15 +285,9 @@
 	default:
 		if (t < end-1)		/* all else must be escaped */
 			*t++ = '\\';
-		if (c == 'x') {		/* hexadecimal goo follows */
+		if (c == 'x')		/* hexadecimal goo follows */
 			c = hexstr(&p);
-			if (t >= end - runelen(c))
-				overflow();
-			t += runetochar(t, &c);
-			*to = t;
-			*s = p;
-			return;
-		} else if (isoctdigit(c)) {	/* \d \dd \ddd */
+		else if (isoctdigit(c)) {	/* \d \dd \ddd */
 			c -= '0';
 			if (isoctdigit(*p)) {
 				c = 8 * c + *p++ - '0';
@@ -303,8 +297,9 @@
 		}
 		break;
 	}
-	if (t < end-1)
-		*t++ = c;
+	if (t >= end - runelen(c))
+		overflow();
+	t += runetochar(t, &c);
 	*s = p;
 	*to = t;
 }
--