Module Name:    src
Committed By:   riastradh
Date:           Tue Aug 20 17:43:24 UTC 2024

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

Log Message:
mbrtoc32(3): Fix name and type of mbrtowc_l return value.

This was from `int mbtowc_l(...)' in an earlier draft and I didn't
update it to size_t when I changed the draft to mbrtowc_l.  Caught by
lint.

`mb_len' avoids (harmless) clash with standard C function mblen(3).

PR lib/58618: mbrtocN(3) fails to keep shift state


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 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.8 src/lib/libc/locale/mbrtoc32.c:1.9
--- src/lib/libc/locale/mbrtoc32.c:1.8	Tue Aug 20 17:43:09 2024
+++ src/lib/libc/locale/mbrtoc32.c	Tue Aug 20 17:43:24 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: mbrtoc32.c,v 1.8 2024/08/20 17:43:09 riastradh Exp $	*/
+/*	$NetBSD: mbrtoc32.c,v 1.9 2024/08/20 17:43:24 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2024 The NetBSD Foundation, Inc.
@@ -52,7 +52,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: mbrtoc32.c,v 1.8 2024/08/20 17:43:09 riastradh Exp $");
+__RCSID("$NetBSD: mbrtoc32.c,v 1.9 2024/08/20 17:43:24 riastradh Exp $");
 
 #include "namespace.h"
 
@@ -106,7 +106,7 @@ mbrtoc32_l(char32_t *restrict pc32, cons
 	wchar_t wc;
 	mbstate_t wcrtombstate = {0};
 	char mb[MB_LEN_MAX];
-	int mblen;
+	size_t mb_len;
 	char utf32le[MB_LEN_MAX];
 	const char *src;
 	char *dst;
@@ -191,7 +191,7 @@ mbrtoc32_l(char32_t *restrict pc32, cons
 	 * we can pass that through iconv to get a Unicode scalar
 	 * value.
 	 */
-	if ((mblen = wcrtomb_l(mb, wc, &wcrtombstate, loc)) == -1) {
+	if ((mb_len = wcrtomb_l(mb, wc, &wcrtombstate, loc)) == (size_t)-1) {
 		len = (size_t)-1;
 		goto out;
 	}
@@ -200,7 +200,7 @@ mbrtoc32_l(char32_t *restrict pc32, cons
 	 * Convert the multibyte sequence to UTF-16LE.
 	 */
 	src = mb;
-	srcleft = (size_t)mblen;
+	srcleft = mb_len;
 	dst = utf32le;
 	dstleft = sizeof(utf32le);
 	error = _citrus_iconv_convert(iconv, &src, &srcleft, &dst, &dstleft,

Reply via email to