Module Name: src
Committed By: christos
Date: Sun Sep 1 14:45:39 UTC 2024
Modified Files:
src/external/historical/nawk/dist: main.c
Log Message:
PR/58619: Rin Okuyama: Force C locale for non-utf-8 (from RVP)
To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/external/historical/nawk/dist/main.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/external/historical/nawk/dist/main.c
diff -u src/external/historical/nawk/dist/main.c:1.12 src/external/historical/nawk/dist/main.c:1.13
--- src/external/historical/nawk/dist/main.c:1.12 Sat Aug 17 18:22:29 2024
+++ src/external/historical/nawk/dist/main.c Sun Sep 1 10:45:39 2024
@@ -32,6 +32,7 @@ const char *version = "version 20240728"
#include <stdio.h>
#include <ctype.h>
#include <locale.h>
+#include <langinfo.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
@@ -141,8 +142,9 @@ int main(int argc, char *argv[])
const char *fs = NULL;
char *fn, *vn;
- setlocale(LC_CTYPE, "");
setlocale(LC_NUMERIC, "C"); /* for parsing cmdline & prog */
+ /* Force C locale for non-UTF-8 */
+ setlocale(LC_CTYPE, strcmp(nl_langinfo(CODESET), "UTF-8") ? "C" : "");
awk_mb_cur_max = MB_CUR_MAX;
cmdname = argv[0];
if (argc == 1) {