diff options
author | Lasse Collin <lasse.collin@tukaani.org> | 2009-06-24 13:01:59 +0300 |
---|---|---|
committer | Lasse Collin <lasse.collin@tukaani.org> | 2009-06-24 13:01:59 +0300 |
commit | ae82dde5d9cc60c80cc89601b6c51cc1611d48e7 (patch) | |
tree | 1eff9d50516a738243f2bd334ca7475ac42c4104 /src/xz/args.c | |
parent | A few more spelling fixes. Released the .xz spec 1.0.3. (diff) | |
download | xz-ae82dde5d9cc60c80cc89601b6c51cc1611d48e7.tar.xz |
Cast a char argument to isspace() to unsigned char.
Diffstat (limited to 'src/xz/args.c')
-rw-r--r-- | src/xz/args.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/xz/args.c b/src/xz/args.c index 57f34823..97b22448 100644 --- a/src/xz/args.c +++ b/src/xz/args.c @@ -374,7 +374,14 @@ parse_environment(args_info *args, char *argv0) int argc = 1; bool prev_was_space = true; for (size_t i = 0; env[i] != '\0'; ++i) { - if (isspace(env[i])) { + // NOTE: Cast to unsigned char is needed so that correct + // value gets passed to isspace(), which expects + // unsigned char cast to int. Casting to int is done + // automatically due to integer promotion, but we need to + // force char to unsigned char manually. Otherwise 8-bit + // characters would get promoted to wrong value if + // char is signed. + if (isspace((unsigned char)env[i])) { prev_was_space = true; } else if (prev_was_space) { prev_was_space = false; @@ -399,7 +406,7 @@ parse_environment(args_info *args, char *argv0) argc = 1; prev_was_space = true; for (size_t i = 0; env[i] != '\0'; ++i) { - if (isspace(env[i])) { + if (isspace((unsigned char)env[i])) { prev_was_space = true; env[i] = '\0'; } else if (prev_was_space) { |