Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/gen vis(3): Avoid nonportable MIN in portable code.



details:   https://anonhg.NetBSD.org/src/rev/21a6728a7b11
branches:  trunk
changeset: 377168:21a6728a7b11
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Thu Jun 29 16:11:31 2023 +0000

description:
vis(3): Avoid nonportable MIN in portable code.

diffstat:

 lib/libc/gen/vis.c |  9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diffs (30 lines):

diff -r 1f288d85630e -r 21a6728a7b11 lib/libc/gen/vis.c
--- a/lib/libc/gen/vis.c        Thu Jun 29 14:18:58 2023 +0000
+++ b/lib/libc/gen/vis.c        Thu Jun 29 16:11:31 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vis.c,v 1.75 2021/06/18 10:57:14 christos Exp $        */
+/*     $NetBSD: vis.c,v 1.76 2023/06/29 16:11:31 riastradh Exp $       */
 
 /*-
  * Copyright (c) 1989, 1993
@@ -57,7 +57,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: vis.c,v 1.75 2021/06/18 10:57:14 christos Exp $");
+__RCSID("$NetBSD: vis.c,v 1.76 2023/06/29 16:11:31 riastradh Exp $");
 #endif /* LIBC_SCCS and not lint */
 #ifdef __FBSDID
 __FBSDID("$FreeBSD$");
@@ -466,7 +466,10 @@ istrsenvisx(char **mbdstp, size_t *dlen,
        while (mbslength > 0) {
                /* Convert one multibyte character to wchar_t. */
                if (!cerr)
-                       clen = mbrtowc(src, mbsrc, MIN(mbslength, MB_LEN_MAX),
+                       clen = mbrtowc(src, mbsrc,
+                           (mbslength < MB_LEN_MAX
+                               ? mbslength
+                               : MB_LEN_MAX),
                            &mbstate);
                if (cerr || clen < 0) {
                        /* Conversion error, process as a byte instead. */



Home | Main Index | Thread Index | Old Index