Module Name:    src
Committed By:   rillig
Date:           Fri Feb  2 23:36:01 UTC 2024

Modified Files:
        src/tests/usr.bin/xlint/lint1: lex_utf8.c
        src/usr.bin/xlint/lint1: main1.c

Log Message:
lint: use the locale for interpreting wide character strings


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/lex_utf8.c
cvs rdiff -u -r1.79 -r1.80 src/usr.bin/xlint/lint1/main1.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/usr.bin/xlint/lint1/lex_utf8.c
diff -u src/tests/usr.bin/xlint/lint1/lex_utf8.c:1.1 src/tests/usr.bin/xlint/lint1/lex_utf8.c:1.2
--- src/tests/usr.bin/xlint/lint1/lex_utf8.c:1.1	Fri Feb  2 23:30:39 2024
+++ src/tests/usr.bin/xlint/lint1/lex_utf8.c	Fri Feb  2 23:36:01 2024
@@ -1,15 +1,12 @@
-/*	$NetBSD: lex_utf8.c,v 1.1 2024/02/02 23:30:39 rillig Exp $	*/
+/*	$NetBSD: lex_utf8.c,v 1.2 2024/02/02 23:36:01 rillig Exp $	*/
 # 3 "lex_utf8.c"
 
 /*
  * Test lexing of multibyte characters and strings in an UTF-8 locale.
+ *
+ * See also:
+ *	lex_wide_string.c	(runs in the C locale)
  */
 
-/*
- * Since lint always runs in the default "C" locale, it does not support any
- * multibyte character encoding, thus treating each byte as a separate
- * character. If lint were to support UTF-8, the array dimension would be 3
- * instead of 7.
- */
-/* expect+1: error: negative array dimension (-7) [20] */
+/* expect+1: error: negative array dimension (-3) [20] */
 typedef int mblen[-(int)(sizeof(L"Ä😄") / sizeof(L""))];

Index: src/usr.bin/xlint/lint1/main1.c
diff -u src/usr.bin/xlint/lint1/main1.c:1.79 src/usr.bin/xlint/lint1/main1.c:1.80
--- src/usr.bin/xlint/lint1/main1.c:1.79	Sun Jan 21 14:11:52 2024
+++ src/usr.bin/xlint/lint1/main1.c	Fri Feb  2 23:36:01 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: main1.c,v 1.79 2024/01/21 14:11:52 rillig Exp $	*/
+/*	$NetBSD: main1.c,v 1.80 2024/02/02 23:36:01 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,10 +37,11 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID)
-__RCSID("$NetBSD: main1.c,v 1.79 2024/01/21 14:11:52 rillig Exp $");
+__RCSID("$NetBSD: main1.c,v 1.80 2024/02/02 23:36:01 rillig Exp $");
 #endif
 
 #include <sys/types.h>
+#include <locale.h>
 #include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -134,6 +135,7 @@ main(int argc, char *argv[])
 {
 	int c;
 
+	setlocale(LC_ALL, "");
 	setprogname(argv[0]);
 
 	while ((c = getopt(argc, argv, "abceghpq:rstuvwyzA:FPR:STX:")) != -1) {

Reply via email to