From b712ef44ad49c5eed7fb89e1ab4b85a114ab4c6d Mon Sep 17 00:00:00 2001 From: sin Date: Tue, 2 Sep 2014 12:45:39 +0100 Subject: [PATCH] Fix warning 'array subscript of type char' --- fold.c | 10 ++++++---- sort.c | 2 +- split.c | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/fold.c b/fold.c index c307bb9..9f6d66a 100644 --- a/fold.c +++ b/fold.c @@ -75,21 +75,23 @@ foldline(const char *str, long width) bool space; long col, j; size_t i = 0, n = 0; + int c; do { space = false; for(j = i, col = 0; str[j] && col <= width; j++) { - if(!UTF8_POINT(str[j]) && !bflag) + c = str[j]; + if(!UTF8_POINT(c) && !bflag) continue; - if(sflag && isspace(str[j])) { + if(sflag && isspace(c)) { space = true; n = j+1; } else if(!space) n = j; - if(!bflag && iscntrl(str[j])) - switch(str[j]) { + if(!bflag && iscntrl(c)) + switch(c) { case '\b': col--; break; diff --git a/sort.c b/sort.c index b0b9131..e97673b 100644 --- a/sort.c +++ b/sort.c @@ -172,7 +172,7 @@ linecmp(const char **a, const char **b) static int parse_flags(char **s, int *flags, int bflag) { - while(isalpha(**s)) + while(isalpha((int)**s)) switch(*((*s)++)) { case 'b': *flags |= bflag; diff --git a/split.c b/split.c index 638af54..4b2c2d8 100644 --- a/split.c +++ b/split.c @@ -41,7 +41,7 @@ main(int argc, char *argv[]) size = strtoull(tmp, &end, 10); if(*end == '\0') break; - switch(toupper(*end)) { + switch(toupper((int)*end)) { case 'K': scale = 1024; break;