Module Name:    src
Committed By:   riastradh
Date:           Fri Aug 16 14:00:48 UTC 2024

Modified Files:
        src/lib/libc/locale: mbrtoc32.c

Log Message:
mbrtoc32(3): Clarify control flow.

No need for another goto here; let's keep it clearly structured with
a single `out' label.

No functional change intended.

PR lib/52374: <uchar.h> missing


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libc/locale/mbrtoc32.c

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

Modified files:

Index: src/lib/libc/locale/mbrtoc32.c
diff -u src/lib/libc/locale/mbrtoc32.c:1.3 src/lib/libc/locale/mbrtoc32.c:1.4
--- src/lib/libc/locale/mbrtoc32.c:1.3	Thu Aug 15 22:22:35 2024
+++ src/lib/libc/locale/mbrtoc32.c	Fri Aug 16 14:00:48 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: mbrtoc32.c,v 1.3 2024/08/15 22:22:35 riastradh Exp $	*/
+/*	$NetBSD: mbrtoc32.c,v 1.4 2024/08/16 14:00:48 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2024 The NetBSD Foundation, Inc.
@@ -52,7 +52,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: mbrtoc32.c,v 1.3 2024/08/15 22:22:35 riastradh Exp $");
+__RCSID("$NetBSD: mbrtoc32.c,v 1.4 2024/08/16 14:00:48 riastradh Exp $");
 
 #include "namespace.h"
 
@@ -180,7 +180,7 @@ mbrtoc32(char32_t *restrict pc32, const 
 		    _CITRUS_ICONV_F_HIDE_INVALID, &inval);
 		if (error != EINVAL) {
 			if (error == 0)
-				goto ok;
+				break;
 			errno = error;
 			len = (size_t)-1;
 			goto out;
@@ -188,14 +188,15 @@ mbrtoc32(char32_t *restrict pc32, const 
 	}
 
 	/*
-	 * Incomplete.  Return (size_t)-2 and let the caller try again.
-	 * We have consumed all n bytes at this point without finding a
-	 * complete code point.
+	 * If it is still incomplete after trying the whole input
+	 * buffer, return (size_t)-2 and let the caller try again.
 	 */
-	len = (size_t)-2;
-	goto out;
+	if (error) {
+		len = (size_t)-2;
+		goto out;
+	}
 
-ok:	/*
+	/*
 	 * Successfully converted a minimal byte sequence, which should
 	 * produce exactly one UTF-32 code unit, encoded in
 	 * little-endian, representing a code point.  Get the code

Reply via email to