-/* $OpenBSD: awk.h,v 1.29 2023/09/17 14:49:44 millert Exp $ */
+/* $OpenBSD: awk.h,v 1.30 2023/09/18 19:32:19 millert Exp $ */
/****************************************************************
Copyright (C) Lucent Technologies 1997
All Rights Reserved
#define RECSIZE (8 * 1024) /* sets limit on records, fields, etc., etc. */
extern int recsize; /* size of current record, orig RECSIZE */
+extern size_t awk_mb_cur_max; /* max size of a multi-byte character */
+
extern char EMPTY[]; /* this avoid -Wwritable-strings issues */
extern char **FS;
extern char **RS;
-/* $OpenBSD: b.c,v 1.38 2023/09/17 14:49:44 millert Exp $ */
+/* $OpenBSD: b.c,v 1.39 2023/09/18 19:32:19 millert Exp $ */
/****************************************************************
Copyright (C) Lucent Technologies 1997
All Rights Reserved
buf[k++] = (c = getc(f)) != EOF ? c : 0;
}
c = (uschar)buf[j];
- if (c < 128)
+ if (c < 128 || awk_mb_cur_max == 1)
rune = c;
else {
j--;
-/* $OpenBSD: main.c,v 1.60 2023/09/18 15:20:48 jmc Exp $ */
+/* $OpenBSD: main.c,v 1.61 2023/09/18 19:32:19 millert Exp $ */
/****************************************************************
Copyright (C) Lucent Technologies 1997
All Rights Reserved
bool safe = false; /* true => "safe" mode */
bool do_posix = false; /* true => POSIX mode */
+size_t awk_mb_cur_max = 1;
+
static noreturn void fpecatch(int n
#ifdef SA_SIGINFO
, siginfo_t *si, void *uc
setlocale(LC_CTYPE, "");
setlocale(LC_NUMERIC, "C"); /* for parsing cmdline & prog */
+ awk_mb_cur_max = MB_CUR_MAX;
cmdname = __progname;
if (pledge("stdio rpath wpath cpath proc exec", NULL) == -1) {
-/* $OpenBSD: run.c,v 1.76 2023/09/18 15:16:22 deraadt Exp $ */
+/* $OpenBSD: run.c,v 1.77 2023/09/18 19:32:19 millert Exp $ */
/****************************************************************
Copyright (C) Lucent Technologies 1997
All Rights Reserved
unsigned char c;
c = s[0];
- if (c < 128)
+ if (c < 128 || awk_mb_cur_max == 1)
return 1; /* what if it's 0? */
n = strlen(s);
unsigned char c;
c = s[0];
- if (c < 128) {
+ if (c < 128 || awk_mb_cur_max == 1) {
*rune = c;
return 1;
}
totlen = 0;
for (i = 0; i < n; i += len) {
c = s[i];
- if (c < 128) {
+ if (c < 128 || awk_mb_cur_max == 1) {
len = 1;
} else {
len = u8_nextlen(&s[i]);
int charval = (int) getfval(x);
if (charval != 0) {
- if (charval < 128)
+ if (charval < 128 || awk_mb_cur_max == 1)
snprintf(p, BUFSZ(p), fmt, charval);
else {
// possible unicode character