diff options
| author | christos <christos@NetBSD.org> | 2012-03-21 14:19:15 +0000 |
|---|---|---|
| committer | christos <christos@NetBSD.org> | 2012-03-21 14:19:15 +0000 |
| commit | eb87d17cb6eb40446c3e17d52f968a3e7fd15aba (patch) | |
| tree | d390cc8c6d4307d1b7d24cfe6374235641947ac6 /lib | |
| parent | 2cec01875b1c60740ed77fa0ba9782c6dcac5f8b (diff) | |
unsigned char portability casts
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/libc/stdio/vfwprintf.c | 18 | ||||
| -rw-r--r-- | lib/libc/stdlib/strfmon.c | 20 |
2 files changed, 23 insertions, 15 deletions
diff --git a/lib/libc/stdio/vfwprintf.c b/lib/libc/stdio/vfwprintf.c index 850d783e27a..6e997a27757 100644 --- a/lib/libc/stdio/vfwprintf.c +++ b/lib/libc/stdio/vfwprintf.c @@ -1,4 +1,4 @@ -/* $NetBSD: vfwprintf.c,v 1.28 2012/03/15 18:22:30 christos Exp $ */ +/* $NetBSD: vfwprintf.c,v 1.29 2012/03/21 14:20:47 christos Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -38,7 +38,7 @@ static char sccsid[] = "@(#)vfprintf.c 8.1 (Berkeley) 6/4/93"; __FBSDID("$FreeBSD: src/lib/libc/stdio/vfwprintf.c,v 1.27 2007/01/09 00:28:08 imp Exp $"); #else -__RCSID("$NetBSD: vfwprintf.c,v 1.28 2012/03/15 18:22:30 christos Exp $"); +__RCSID("$NetBSD: vfwprintf.c,v 1.29 2012/03/21 14:20:47 christos Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -290,8 +290,9 @@ __ultoa(u_long val, CHAR_T *endp, int base, int octzero, const char *xdigs, * If (*grp == CHAR_MAX) then no more grouping * should be performed. */ - if (needgrp && ndig == *grp && *grp != CHAR_MAX - && sval > 9) { + if (needgrp && ndig == *grp + && (unsigned char)*grp != (unsigned char)CHAR_MAX + && sval > 9) { *--cp = thousep; ndig = 0; /* @@ -362,8 +363,10 @@ __ujtoa(uintmax_t val, CHAR_T *endp, int base, int octzero, * If (*grp == CHAR_MAX) then no more grouping * should be performed. */ - if (needgrp && *grp != CHAR_MAX && ndig == *grp - && sval > 9) { + if (needgrp + && (unsigned char)*grp != (unsigned char)CHAR_MAX + && ndig == *grp + && sval > 9) { *--cp = thousep; ndig = 0; /* @@ -1240,7 +1243,8 @@ fp_common: /* space for thousands' grouping */ nseps = nrepeats = 0; lead = expt; - while (*grouping != CHAR_MAX) { + while ((unsigned char)*grouping + != (unsigned char)CHAR_MAX) { if (lead <= *grouping) break; lead -= *grouping; diff --git a/lib/libc/stdlib/strfmon.c b/lib/libc/stdlib/strfmon.c index 290ac125b80..d4985f997e6 100644 --- a/lib/libc/stdlib/strfmon.c +++ b/lib/libc/stdlib/strfmon.c @@ -1,4 +1,4 @@ -/* $NetBSD: strfmon.c,v 1.9 2012/03/13 21:13:48 christos Exp $ */ +/* $NetBSD: strfmon.c,v 1.10 2012/03/21 14:19:15 christos Exp $ */ /*- * Copyright (c) 2001 Alexey Zelkin <phantom@FreeBSD.org> @@ -32,7 +32,7 @@ #if 0 __FBSDID("$FreeBSD: src/lib/libc/stdlib/strfmon.c,v 1.14 2003/03/20 08:18:55 ache Exp $"); #else -__RCSID("$NetBSD: strfmon.c,v 1.9 2012/03/13 21:13:48 christos Exp $"); +__RCSID("$NetBSD: strfmon.c,v 1.10 2012/03/21 14:19:15 christos Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -63,6 +63,10 @@ __RCSID("$NetBSD: strfmon.c,v 1.9 2012/03/13 21:13:48 christos Exp $"); #define USE_INTL_CURRENCY 0x40 /* use international currency symbol */ #define IS_NEGATIVE 0x80 /* is argument value negative ? */ +#ifndef NBCHAR_MAX +#define NBCHAR_MAX ((unsigned char)CHAR_MAX) +#endif + /* internal macros */ #define PRINT(CH) do { \ if (dst >= s + maxsize) \ @@ -443,9 +447,9 @@ __setup_vars(int flags, char *cs_precedes, char *sep_by_space, /* Set defult values for unspecified information. */ if (*cs_precedes != 0) *cs_precedes = 1; - if (*sep_by_space == CHAR_MAX) + if ((unsigned char)*sep_by_space == NBCHAR_MAX) *sep_by_space = 0; - if (*sign_posn == CHAR_MAX) + if ((unsigned char)*sign_posn == NBCHAR_MAX) *sign_posn = 0; } @@ -482,14 +486,14 @@ get_groups(int size, char *grouping) { int chars = 0; - if (*grouping == CHAR_MAX || *grouping <= 0) /* no grouping ? */ + if ((unsigned char)*grouping == NBCHAR_MAX || *grouping <= 0) /* no grouping ? */ return (0); while (size > (int)*grouping) { chars++; size -= (int)*grouping++; /* no more grouping ? */ - if (*grouping == CHAR_MAX) + if ((unsigned char)*grouping == NBCHAR_MAX) break; /* rest grouping with same value ? */ if (*grouping == 0) { @@ -581,7 +585,7 @@ __format_grouped_double(double value, int *flags, /* XXX: Why not use %' instead? */ if ((*flags & NEED_GROUPING) && thousands_sep != '\0' && /* XXX: need investigation */ - *grouping != CHAR_MAX && + (unsigned char)*grouping != NBCHAR_MAX && *grouping > 0) { while (avalue_size > (int)*grouping) { GRPCPY(*grouping); @@ -589,7 +593,7 @@ __format_grouped_double(double value, int *flags, grouping++; /* no more grouping ? */ - if (*grouping == CHAR_MAX) + if ((unsigned char)*grouping == NBCHAR_MAX) break; /* rest grouping with same value ? */ |
