Sergey Poznyakoff <gray <at> gnu.org.ua> writes: > > Eric Blake <ebb9 <at> byu.net> ha escrit: > > > I noticed some use of undefined behavior of ctype macros (not all platforms > > guarantee that isxxx(char) produces sane results, when the high bit is > > set). > > Thanks, Eric. I'll apply this.
And another one, for paxutils (necessary for 'make check' in tar). From: Eric Blake <[email protected]> Date: Tue, 12 May 2009 13:52:38 -0600 Subject: [PATCH] Avoid undefined ctype usage. * tests/argcv.c (escaped_length, escape_copy, argcv_string): Pass correct type to ctype macros. * tests/genfile.c (print_stat, exec_command): Likewise. Signed-off-by: Eric Blake <[email protected]> --- tests/argcv.c | 9 +++++---- tests/genfile.c | 10 +++++----- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/tests/argcv.c b/tests/argcv.c index c9f2743..c609094 100644 --- a/tests/argcv.c +++ b/tests/argcv.c @@ -1,5 +1,6 @@ /* argcv.c - simple functions for parsing input based on whitespace - Copyright (C) 1999, 2000, 2001, 2007 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 2001, 2007, 2009 Free Software + Foundation, Inc. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -153,7 +154,7 @@ escaped_length (const char *str, int *quote) len += 2; *quote = 1; } - else if (isprint (*str)) + else if (isprint ((unsigned char) *str)) len++; else if (argcv_escape_char (*str) != -1) len += 2; @@ -249,7 +250,7 @@ escape_copy (char *dst, const char *src) *dst++ = '\\'; *dst++ = '"'; } - else if (*src != '\t' && isprint(*src)) + else if (*src != '\t' && isprint ((unsigned char) *src)) *dst++ = *src; else { @@ -368,7 +369,7 @@ argcv_string (int argc, char **argv, char **pstring) buffer[j++] = '"'; } - for (; j > 0 && isspace (buffer[j-1]); j--) + for (; j > 0 && isspace ((unsigned char) buffer[j - 1]); j--) ; buffer[j] = 0; if (pstring) diff --git a/tests/genfile.c b/tests/genfile.c index 1b338bc..3cceb02 100644 --- a/tests/genfile.c +++ b/tests/genfile.c @@ -2,7 +2,7 @@ Print statistics for existing files. Copyright (C) 1995, 1996, 1997, 2001, 2003, 2004, 2005, 2006, 2007, - 2008 Free Software Foundation, Inc. + 2008, 2009 Free Software Foundation, Inc. François Pinard <[email protected]>, 1995. Sergey Poznyakoff <[email protected]>, 2004, 2005, 2006, 2007, 2008. @@ -574,7 +574,7 @@ print_stat (const char *name) { mode_t mask = ~0; - if (ispunct (p[4])) + if (ispunct ((unsigned char) p[4])) { char *q; @@ -771,12 +771,12 @@ exec_command (void) while ((p = fgets (buf, sizeof buf, fp))) { - while (*p && !isspace (*p) && *p != ':') + while (*p && !isspace ((unsigned char) *p) && *p != ':') p++; if (*p == ':') { - for (p++; *p && isspace (*p); p++) + for (p++; *p && isspace ((unsigned char) *p); p++) ; if (*p @@ -784,7 +784,7 @@ exec_command (void) { char *end; size_t n = strtoul (p + sizeof CHECKPOINT_TEXT - 1, &end, 10); - if (!(*end && !isspace (*end))) + if (!(*end && !isspace ((unsigned char) *end))) { process_checkpoint (n); continue; -- 1.6.2.4
