On Monday, April 8th, 2024 at 12:22, Oliver Webb via Toybox 
<toybox@lists.landley.net> wrote:
> On Mon, Apr 8, 2024 at 12:00, Rob Landley <r...@landley.net> wrote:
> > On 4/8/24 11:53, Oliver Webb wrote:
> > > Still, U+0000 is a valid code point, and having a special case especially 
> > > for it
> > > that isn’t mentioned but you have to watch out for is either a bug or a
> > > documentation error.
> > 
> > I say it's intentional, you reassert that I'm wrong.
> this is at least the 4th time I said “if you want that behavior, that’s fine… 
> but can we at least document the Landmine so no one steps on it”
> …

Since apparently this isn't a bug, can we at least update the comment to match 
the code.
(This is the solution I was implying when I said "or a documentation error", 
and "A special case
for null bytes is fine, but to save me and any other person that debugging 
nightmare when they
try to do utf8 processing on data with null bytes in it. I'd prefer if that was 
mentioned somewhere."
in the email you didn't read ("What's context needed for?"))


-   Oliver Webb <aquahobby...@proton.me>
From bef7a03af421d4abf02e8d7538b98d013779204c Mon Sep 17 00:00:00 2001
From: Oliver Webb <aquahobby...@proton.me>
Date: Mon, 8 Apr 2024 18:38:53 -0500
Subject: [PATCH] Update comment in utf8towc() to match what code is doing
 (Null byte edge case)

 lib/lib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/lib.c b/lib/lib.c
index 6a4a77dd..9b049ca7 100644
--- a/lib/lib.c
+++ b/lib/lib.c
@@ -373,7 +373,7 @@ int wctoutf8(char *s, unsigned wc)
 // Convert utf8 sequence to a unicode wide character
-// returns bytes consumed, or -1 if err, or -2 if need more data.
+// returns bytes consumed, or 0 if null byte, -1 if err, -2 if need more data.
 int utf8towc(unsigned *wc, char *str, unsigned len)
   unsigned result, mask, first;

Toybox mailing list

Reply via email to