Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc unsigned char portability casts
details: https://anonhg.NetBSD.org/src/rev/3bbf3170aac9
branches: trunk
changeset: 778299:3bbf3170aac9
user: christos <christos%NetBSD.org@localhost>
date: Wed Mar 21 14:19:15 2012 +0000
description:
unsigned char portability casts
diffstat:
lib/libc/stdio/vfwprintf.c | 18 +++++++++++-------
lib/libc/stdlib/strfmon.c | 20 ++++++++++++--------
2 files changed, 23 insertions(+), 15 deletions(-)
diffs (129 lines):
diff -r 9978163bedf6 -r 3bbf3170aac9 lib/libc/stdio/vfwprintf.c
--- a/lib/libc/stdio/vfwprintf.c Wed Mar 21 14:17:54 2012 +0000
+++ b/lib/libc/stdio/vfwprintf.c Wed Mar 21 14:19:15 2012 +0000
@@ -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 @@
* 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 @@
* 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 @@
/* 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 -r 9978163bedf6 -r 3bbf3170aac9 lib/libc/stdlib/strfmon.c
--- a/lib/libc/stdlib/strfmon.c Wed Mar 21 14:17:54 2012 +0000
+++ b/lib/libc/stdlib/strfmon.c Wed Mar 21 14:19:15 2012 +0000
@@ -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@localhost>
@@ -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 @@
#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 @@
/* 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 @@
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 @@
/* 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 @@
grouping++;
/* no more grouping ? */
- if (*grouping == CHAR_MAX)
+ if ((unsigned char)*grouping == NBCHAR_MAX)
break;
/* rest grouping with same value ? */
Home |
Main Index |
Thread Index |
Old Index