From 9595e512876f98a42412f6bb2f217f2ceb43ec0e Mon Sep 17 00:00:00 2001 From: Kosma Moczek Date: Fri, 14 Feb 2014 17:17:59 +0100 Subject: [PATCH] minmea.c: ctype.h requires integer, not signed char --- minmea.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/minmea.c b/minmea.c index ef4261a..89c6be8 100644 --- a/minmea.c +++ b/minmea.c @@ -31,7 +31,7 @@ bool minmea_check(const char *sentence) return false; // The optional checksum is an XOR of all bytes between "$" and "*". - while (*sentence && *sentence != '*' && isprint(*sentence)) + while (*sentence && *sentence != '*' && isprint((unsigned char) *sentence)) checksum ^= *sentence++; if (*sentence == '*') { @@ -58,7 +58,7 @@ bool minmea_check(const char *sentence) } static inline bool minmea_isfield(char c) { - return isprint(c) && c != ',' && c != '*'; + return isprint((unsigned char) c) && c != ',' && c != '*'; } bool minmea_scan(const char *sentence, const char *format, ...) @@ -120,7 +120,7 @@ bool minmea_scan(const char *sentence, const char *format, ...) sign = 1; } else if (*field == '-' && !sign && value == -1) { sign = -1; - } else if (isdigit(*field)) { + } else if (isdigit((unsigned char) *field)) { if (value == -1) value = 0; value = (10 * value) + (*field - '0'); @@ -185,7 +185,7 @@ bool minmea_scan(const char *sentence, const char *format, ...) int d = -1, m = -1, y = -1; // Always six digits. for (int i=0; i<6; i++) - if (!isdigit(field[i])) + if (!isdigit((unsigned char) field[i])) goto end_D; d = strtol((char[]) {field[0], field[1], '\0'}, NULL, 10); @@ -204,7 +204,7 @@ bool minmea_scan(const char *sentence, const char *format, ...) int h = -1, i = -1, s = -1, u = -1; // Minimum required: integer time. for (int i=0; i<6; i++) - if (!isdigit(field[i])) + if (!isdigit((unsigned char) field[i])) goto end_T; h = strtol((char[]) {field[0], field[1], '\0'}, NULL, 10); @@ -216,7 +216,7 @@ bool minmea_scan(const char *sentence, const char *format, ...) if (*field++ == '.') { int value = 0; int scale = 1000000; - while (isdigit(*field) && scale > 1) { + while (isdigit((unsigned char) *field) && scale > 1) { value = (value * 10) + (*field++ - '0'); scale /= 10; }