tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: bin/57544: sed(1) and regex(3) problem with encoding



On Wed, 26 Jul 2023, tlaronde%polynum.com@localhost wrote:

$ export LC_CTYPE=fr_FR.ISO8859-15

and then:

$ echo "??" | sed 's/??\é/g'
sed: 1: "s/??\é/g": RE error: trailing backslash (\)


Not running NetBSD right now, but, FreeBSD 13.2 has the same issue which
can be seen even with a plain grep(1)--as it relies on the libc regexp
engine.

Can you try the patch below (it is for NetBSD):

```
diff -urN src/lib/libc/regex.orig/regcomp.c src/lib/libc/regex/regcomp.c
--- src/lib/libc/regex.orig/regcomp.c	2022-12-21 17:44:15.000000000 +0000
+++ src/lib/libc/regex/regcomp.c	2023-07-26 17:05:50.832242252 +0000
@@ -898,7 +898,7 @@
 	handled = false;

 	assert(MORE());		/* caller should have ensured this */
-	c = GETNEXT();
+	c = (unsigned char)GETNEXT();
 	if (c == '\\') {
 		(void)REQUIRE(MORE(), REG_EESCAPE);
 		cc = GETNEXT();
```

-RVP



Home | Main Index | Thread Index | Old Index