From bb391235c312bfabed06c462ea782fae18fd057c Mon Sep 17 00:00:00 2001 From: Ray Gardner Date: Sat, 13 Apr 2024 09:55:21 -0600 Subject: [PATCH] Implement -b in bytesinutf8() (fixes substr()) Credit to Oliver Webb, thanks! Also fixes mono.c that didn't get updated in prev. commit Co-Authored-By: Oliver Webb --- toys/pending/awk.c | 1 + 1 file changed, 1 insertion(+) diff --git a/toys/pending/awk.c b/toys/pending/awk.c index 5660609e..7fc73a4a 100644 --- a/toys/pending/awk.c +++ b/toys/pending/awk.c @@ -383,6 +383,7 @@ static void get_token_text(char *op, int tk) // Return number of bytes in 'cnt' utf8 codepoints static int bytesinutf8(char *str, size_t len, size_t cnt) { + if (FLAG(b)) return cnt; unsigned wch; char *lim = str + len, *s0 = str; while (cnt-- && str < lim) { -- 2.39.2