]> granicus.if.org Git - graphviz/commitdiff
[nfc] cast inputs to ctype.h 'is*' functions
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Fri, 3 Dec 2021 01:28:53 +0000 (17:28 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 4 Dec 2021 22:58:40 +0000 (14:58 -0800)
The ctype.h `is*` functions are typically implemented as macros using a lookup
table. This is fine, but on Cygwin the compiler is somewhat picky about this:

  lib/ast/fmtesc.c:116:59: warning: array subscript has type char
    [-Wchar-subscripts]
    116 |                           (c == '#' && (b == f || isspace(*(b - 1)))
        |                                                           ^~~~~~~~

This change squashes these warnings.

27 files changed:
cmd/tools/ccomps.c
cmd/tools/colxlate.c
cmd/tools/graphml2gv.c
cmd/tools/gv2gml.c
cmd/tools/gxl2gv.c
lib/ast/fmtesc.c
lib/ast/strmatch.c
lib/cgraph/write.c
lib/common/args.c
lib/common/emit.c
lib/common/utils.c
lib/common/xml.c
lib/expr/excontext.c
lib/expr/exeval.c
lib/expr/exparse.y
lib/expr/extoken.c
lib/fdpgen/xlayout.c
lib/gvc/gvconfig.c
lib/gvc/gvdevice.c
lib/gvpr/gvpr.c
lib/neatogen/adjust.c
lib/neatogen/neatoinit.c
lib/sfdpgen/sfdpinit.c
lib/sfio/sftable.c
lib/sfio/sfvprintf.c
lib/sfio/sfvscanf.c
lib/xdot/xdot.c

index ad1afda115a7e8c99d538d9e5724eaf3658f8f85..fd54de156d4f6457da8ded38110d99c8ffb0144c 100644 (file)
@@ -188,12 +188,12 @@ static void init(int argc, char *argv[])
                char *p = optarg + 1;
                if (*optarg == '#') x_mode = BY_INDEX;
                else x_mode = BY_SIZE;
-               if (isdigit(*p)) {
+               if (isdigit((int)*p)) {
                    x_index = (int)strtol (p, &endp, 10);
                    printMode = EXTRACT;
                    if (*endp == '-') {
                        p = endp + 1;
-                       if (isdigit(*p)) {
+                       if (isdigit((int)*p)) {
                            x_final = atoi (p);
                            if (x_final < x_index) {
                                printMode = INTERNAL;
index 4c40ac4b18b5d337618750efafe1a5cce1bd61d9..f01b33fafe70197a32e4020746f613c6ef8c1656 100644 (file)
@@ -59,7 +59,7 @@ char *colorxlate(char *str, char *buf)
                       sizeof(fake), colorcmpf);
     }
     if (last == NULL) {
-       if (!isdigit(canon[0])) {
+       if (!isdigit((int)canon[0])) {
            fprintf(stderr, "warning: %s is not a known color\n", str);
            strcpy(buf, str);
        } else
index c4456f3cbd25fbb6442298b090e2c931b63a949c..21c8be7e37c88776b4112064313c99ca3e3dfdc0 100644 (file)
@@ -203,7 +203,7 @@ static int isAnonGraph(char *name)
 {
     if (*name++ != '%')
        return 0;
-    while (isdigit(*name))
+    while (isdigit((int)*name))
        name++;                 /* skip over digits */
     return (*name == '\0');
 }
index ad274e65ac1d6f8faa74a17814829b5c728617ec..e4a0a856ccf26a4568d842445088a5a80ea7f3c6 100644 (file)
@@ -102,7 +102,7 @@ isNumber (char* s)
     char* ep = s;
     strtod(s, &ep);
     if (s != ep) {
-       while (*ep && isspace(*ep)) ep++;
+       while (*ep && isspace((int)*ep)) ep++;
        if (*ep) return 0;
        else return 1;
     }
@@ -158,7 +158,7 @@ emitPoint (double x, double y, FILE* outFile, int ix)
 static char*
 skipWS (char* s)
 {
-    while (isspace(*s)) s++;
+    while (isspace((int)*s)) s++;
     return s;
 }
 
index 9adae44d6aea09f38074b7288d5bb1d7e57ba70f..18abeef225ed6ac5b88cfedcfce17b4cb3c63f76 100644 (file)
@@ -218,7 +218,7 @@ static int isAnonGraph(char *name)
 {
     if (*name++ != '%')
        return 0;
-    while (isdigit(*name))
+    while (isdigit((int)*name))
        name++;                 /* skip over digits */
     return (*name == '\0');
 }
index 4affb3c52f21be6e39c9f2b6d9e84c3fa70a6e0b..d94c6a5181808771e1aa7b061c00fe8fc5d793bc 100644 (file)
@@ -113,7 +113,7 @@ char *fmtquote(const char *as, const char *qb, const char *qe, size_t n,
                       (isspace(c) ||
                        (((flags & FMT_SHELL) || shell) &&
                         (strchr("\";~&|()<>[]*?", c) ||
-                         (c == '#' && (b == f || isspace(*(b - 1)))
+                         (c == '#' && (b == f || isspace((int)*(b - 1)))
                          )
                         )
                        )
index 362d0603075fc802c2fddecdfc15033e06a18362..d58edccabf66f61d4a8069a34e90e53dd7df1f73 100644 (file)
@@ -449,7 +449,7 @@ onematch(Match_t * mp, int g, char *s, char *p, char *e, char *r,
                            (void)mbgetchar(p);
                            range = oldp;
                        } else
-                           if ((isalpha(*oldp) && isalpha(*olds)
+                           if ((isalpha((int)*oldp) && isalpha((int)*olds)
                                 && tolower(*oldp) == tolower(*olds))
                                || sc == mbgetchar(oldp))
                            ok = 1;
index 2aea82550fcb3c9c97d0d456e06c0537b9189c63..d6cd8b23bfbdd26c06ae48132f2e738df220ec41 100644 (file)
@@ -657,7 +657,7 @@ int agwrite(Agraph_t * g, void *ofile)
     char* s;
     int len;
     Level = 0;                 /* re-initialize tab level */
-    if ((s = agget(g, "linelength")) && isdigit(*s)) {
+    if ((s = agget(g, "linelength")) && isdigit((int)*s)) {
        len = (int)strtol(s, (char **)NULL, 10);
        if (len == 0 || len >= MIN_OUTPUTLINE)
            Max_outputline = len;
index 9f8ee70fadd7c627b648a1f6eb784498a51a7948..803d6bc8b312cf1f7e1f3701a70aed9717524406 100644 (file)
@@ -127,7 +127,7 @@ config_extra_args(GVC_t *gvc, int argc, char** argv)
       switch (arg[1]) {
       case 'v':
        gvc->common.verbose = 1;
-       if (isdigit(arg[2]))
+       if (isdigit((int)arg[2]))
          gvc->common.verbose = atoi(&arg[2]);
         break;
       case 'O' :
index 3c76ac8053afd478dbad2844b5becf170d49582f..0488d96301dfba9ce1a1559e0745d33807f1d4cb 100644 (file)
@@ -1014,7 +1014,7 @@ static bool is_natural_number(const char *sstr)
     const char *str = sstr;
 
     while (*str)
-       if (!isdigit(*str++))
+       if (!isdigit((int)*str++))
            return false;
     return true;
 }
@@ -1995,7 +1995,7 @@ static void emit_attachment(GVJ_t * job, textlabel_t * lp, splines * spl)
     const char *s;
 
     for (s = lp->text; *s; s++) {
-       if (!isspace(*s))
+       if (!isspace((int)*s))
            break;
     }
     if (*s == '\0')
@@ -3770,7 +3770,7 @@ static int style_token(char **s, agxbuf * xb)
     int token;
     char c;
 
-    while (*p && (isspace(*p) || *p == ','))
+    while (*p && (isspace((int)*p) || *p == ','))
        p++;
     switch (*p) {
     case '\0':
index 3cfb95c0c3232a8a6c75d47b6c7e496e6989e0ae..929eb355430c843508a76dab3829cf61c6b825ae 100644 (file)
@@ -454,7 +454,7 @@ boolean mapBool(char *p, boolean dflt)
        return TRUE;
     if (!strcasecmp(p, "yes"))
        return TRUE;
-    if (isdigit(*p))
+    if (isdigit((int)*p))
        return atoi(p);
     else
        return dflt;
index abedd0561c9921d989120ddd1dd09c41af1dda5a..000d7471c0b5025163fe8ce538a9a9269ec77982 100644 (file)
@@ -22,10 +22,10 @@ static bool xml_isentity(const char *s)
        s++;
        if (*s == 'x' || *s == 'X') {
            s++;
-           while (isxdigit(*s))
+           while (isxdigit((int)*s))
                s++;
        } else {
-           while (isdigit(*s))
+           while (isdigit((int)*s))
                s++;
        }
     } else {
index d667ed38755fb53ec7456d19f08865f4ec4734bb..31a0e47af4a8ff349ae00c0f41023558e808651b 100644 (file)
@@ -36,7 +36,7 @@ excontext(Expr_t* p, char* buf, int n)
                if (p->linewrap)
                {
                        t = p->linep + 1;
-                       while (t < &p->line[sizeof(p->line)] && isspace(*t))
+                       while (t < &p->line[sizeof(p->line)] && isspace((int)*t))
                                t++;
                        if ((n = (sizeof(p->line) - (t - (p->linep + 1))) - (e - s)) > 0)
                        {
@@ -50,7 +50,7 @@ excontext(Expr_t* p, char* buf, int n)
                t = p->line;
                if (p->linewrap)
                        p->linewrap = 0;
-               else while (t < p->linep && isspace(*t))
+               else while (t < p->linep && isspace((int)*t))
                        t++;
                if ((n = (p->linep - t) - (e - s)) > 0)
                        t += n;
index 92557f6869cdc2757ff9b43283b690444ca870e6..b01335b346ed6635a8ea165bea11756c055b0fb2 100644 (file)
@@ -301,36 +301,36 @@ prformat(void* vp, Sffmt_t* dp)
                {
                        if (streqn(txt, "identifier", txt_len))
                        {
-                               if (*s && !isalpha(*s))
+                               if (*s && !isalpha((int)*s))
                                        *s++ = '_';
                                for (; *s; s++)
-                                       if (!isalnum(*s))
+                                       if (!isalnum((int)*s))
                                                *s = '_';
                        }
                        else if (streqn(txt, "invert", txt_len))
                        {
                                for (; *s; s++)
-                                       if (isupper(*s))
+                                       if (isupper((int)*s))
                                                *s = (char)tolower(*s);
-                                       else if (islower(*s))
+                                       else if (islower((int)*s))
                                                *s = (char)toupper(*s);
                        }
                        else if (streqn(txt, "lower", txt_len))
                        {
                                for (; *s; s++)
-                                       if (isupper(*s))
+                                       if (isupper((int)*s))
                                                *s = (char)tolower(*s);
                        }
                        else if (streqn(txt, "upper", txt_len))
                        {
                                for (; *s; s++)
-                                       if (islower(*s))
+                                       if (islower((int)*s))
                                                *s = (char)toupper(*s);
                        }
                        else if (streqn(txt, "variable", txt_len))
                        {
                                for (; *s; s++)
-                                       if (!isalnum(*s) && *s != '_')
+                                       if (!isalnum((int)*s) && *s != '_')
                                                *s = '.';
                        }
                }
index 796376d1e328c76f9e3ef1dd7c4675448ba41c32..3feeec6af742adcf83cd68edc5978edd8fc55886 100644 (file)
@@ -1306,7 +1306,7 @@ const char *exop(size_t index) {
       {
         size_t k;
         for (k = 0; yytname[i][k] != '\0'; ++k) {
-          if (yytname[i][k] != '_' && !isalnum(yytname[i][k])) {
+          if (yytname[i][k] != '_' && !isalnum((int)yytname[i][k])) {
             break;
           }
         }
index f5fa49e2d0f83056eabded2019441c51cbdf8284..2764fd3e9271a86725ddc55d3f3a115122c2ec13 100644 (file)
@@ -463,7 +463,7 @@ extoken_fn(Expr_t* ex)
                        if (!ex->linewrap && !(ex->disc->flags & EX_PURE))
                        {
                                s = ex->linep - 1;
-                               while (s > ex->line && isspace(*(s - 1)))
+                               while (s > ex->line && isspace((int)*(s - 1)))
                                        s--;
                                if (s == ex->line)
                                {
index fd8035d0bf635f6d4784caafa5ead2cd4e1cba50..0d76403b82006c76e4aa7c2b18f0833ec03c8604 100644 (file)
@@ -527,7 +527,7 @@ void fdp_xLayout(graph_t * g, xparams * xpms)
        ovlp = DFLT_overlap;
     }
     /* look for optional ":" or "number:" */
-    if ((cp = strchr(ovlp, ':')) && (cp == ovlp || isdigit(*ovlp))) {
+    if ((cp = strchr(ovlp, ':')) && (cp == ovlp || isdigit((int)*ovlp))) {
       cp++;
       rest = cp;
       tries = atoi (ovlp);
index 2d86321fbe74a517346148682610ed4b8cada592..1d73b5bb53ab9fe3fbbc3598f46f88ae4dc1734b 100644 (file)
@@ -429,10 +429,10 @@ static bool is_plugin(const char *filepath) {
 
 #else
     // does this filename have a version?
-    if (len == 0 || !isdigit(filepath[len - 1])) {
+    if (len == 0 || !isdigit((int)filepath[len - 1])) {
        return false;
     }
-    while (len > 0 && isdigit(filepath[len - 1])) {
+    while (len > 0 && isdigit((int)filepath[len - 1])) {
        --len;
     }
 
@@ -444,11 +444,11 @@ static bool is_plugin(const char *filepath) {
        return false;
     }
 #elif defined(__MINGW32__) || defined(__CYGWIN__)
-    if (len < 2 || isdigit(filepath[len - 2]) || filepath[len - 1] != '-') {
+    if (len < 2 || isdigit((int)filepath[len - 2]) || filepath[len - 1] != '-') {
        return false;
     }
 #elif defined(_WIN32)
-    if (len < 1 || isdigit(filepath[len - 1])) {
+    if (len < 1 || isdigit((int)filepath[len - 1])) {
        return false;
     }
 #elif ((defined(__hpux__) || defined(__hpux)) && !(defined(__ia64)))
index 40fce3c576798669d44539a97960cbbe4e4dbc49..0352baeb547e1c591f161ccf2c8da72f932e6477 100644 (file)
@@ -545,7 +545,7 @@ static void gv_trim_zeros(char* buf)
   }
 
   // check this really is the result of %.02f printing
-  assert(isdigit(dotp[1]) && isdigit(dotp[2]) && dotp[3] == '\0');
+  assert(isdigit((int)dotp[1]) && isdigit((int)dotp[2]) && dotp[3] == '\0');
 
   if (dotp[2] == '0') {
     if (dotp[1] == '0') {
index bba402c380f9eac2c8a5c740ea16bc525e2c51c6..4a537923511cefd2cf962ef5840b8279c781c3e0 100644 (file)
@@ -106,7 +106,7 @@ static char *gettok(char **sp)
     char c;
     char q = '\0';             /* if non-0, in quote mode with quote char q */
 
-    while (isspace(*rs))
+    while (isspace((int)*rs))
        rs++;
     if ((c = *rs) == '\0')
        return NULL;
index 29d09c6bc193365d4d589827b0489177a56f4d5d..be3729301ec653c346be9d9a118528ca7a03ce95 100644 (file)
@@ -1198,7 +1198,7 @@ parseFactor (char* s, expand_t* pp, float sepfact, float dflt)
     int i;
     float x, y;
 
-    while (isspace(*s)) s++;
+    while (isspace((int)*s)) s++;
     if (*s == '+') {
        s++;
        pp->doAdd = 1;
index bf1f28da310f4593a260f2377abd6b6c63e78ded..d14ecde6c307d07ebbd976d0fd041bcf5f721596 100644 (file)
@@ -317,7 +317,7 @@ static int user_spline(attrsym_t * E_pos, edge_t * e)
            pp++;
            n--;
        }
-       while (isspace(*pos)) pos++;
+       while (isspace((int)*pos)) pos++;
        if (*pos == '\0')
            more = 0;
        else
index 71a28f0e19b482b1a141f77e362e4026bb86288d..d9284b9b2d36494cd4c6ecd18177e2b5b7fe695c 100644 (file)
@@ -163,7 +163,7 @@ late_smooth (graph_t* g, Agsym_t* sym, int dflt)
 
     if (!sym) return dflt;
     s = agxget (g, sym);
-    if (isdigit(*s)) {
+    if (isdigit((int)*s)) {
 #if (defined(HAVE_GTS) || defined(HAVE_TRIANGLE))
        if ((v = atoi (s)) <= SMOOTHING_RNG)
 #else
@@ -173,7 +173,7 @@ late_smooth (graph_t* g, Agsym_t* sym, int dflt)
        else
            rv = dflt;
     }
-    else if (isalpha(*s)) {
+    else if (isalpha((int)*s)) {
        if (!strcasecmp(s, "avg_dist"))
            rv = SMOOTHING_STRESS_MAJORIZATION_AVG_DIST;
        else if (!strcasecmp(s, "graph_dist"))
@@ -209,13 +209,13 @@ late_quadtree_scheme (graph_t* g, Agsym_t* sym, int dflt)
 
     if (!sym) return dflt;
     s = agxget (g, sym);
-    if (isdigit(*s)) {
+    if (isdigit((int)*s)) {
       if ((v = atoi (s)) <= QUAD_TREE_FAST && v >= QUAD_TREE_NONE){
        rv = v;
       }        else {
        rv = dflt;
       }
-    } else if (isalpha(*s)) {
+    } else if (isalpha((int)*s)) {
       if (!strcasecmp(s, "none") || !strcasecmp(s, "false") ){
        rv = QUAD_TREE_NONE;
       } else if (!strcasecmp(s, "normal") || !strcasecmp(s, "true") || !strcasecmp(s, "yes")){
index c1800005f9ec85d3212d24628360c2892e5ddae7..85e4467423940405b941464c9ce82670d9dcba4f 100644 (file)
@@ -19,7 +19,7 @@
 
 static char *sffmtint(const char *str, int *v)
 {
-    for (*v = 0; isdigit(*str); ++str)
+    for (*v = 0; isdigit((int)*str); ++str)
        *v = *v * 10 + (*str - '0');
     *v -= 1;
     return (char *) str;
@@ -145,7 +145,7 @@ static Fmtpos_t *sffmtpos(Sfio_t * f, const char *form, va_list args,
        case '.':
            if ((dot += 1) == 2)
                base = 0;       /* for %s,%c */
-           if (isdigit(*form)) {
+           if (isdigit((int)*form)) {
                fmt = *form++;
                goto dot_size;
            } else if (*form != '*')
@@ -194,7 +194,7 @@ static Fmtpos_t *sffmtpos(Sfio_t * f, const char *form, va_list args,
        case 'I':               /* object length */
            size = 0;
            flags = (flags & ~SFFMT_TYPES) | SFFMT_IFLAG;
-           if (isdigit(*form)) {
+           if (isdigit((int)*form)) {
                for (n = *form; isdigit(n); n = *++form)
                    size = size * 10 + (n - '0');
            } else if (*form == '*') {
index d997e52e163b1de54aba6e836a956ffa66e6004e..b36dfdebc863462fa4ccb9f69a0389d32626686d 100644 (file)
@@ -226,7 +226,7 @@ int sfvprintf(Sfio_t * f, const char *form, va_list args)
                base = 0;       /* for %s,%c */
                if (*form == 'c' || *form == 's')
                    goto loop_flags;
-               if (*form && !isalnum(*form) &&
+               if (*form && !isalnum((int)*form) &&
                    (form[1] == 'c' || form[1] == 's')) {
                    if (*form == '*')
                        goto do_star;
@@ -237,7 +237,7 @@ int sfvprintf(Sfio_t * f, const char *form, va_list args)
                }
            }
 
-           if (isdigit(*form)) {
+           if (isdigit((int)*form)) {
                fmt = *form++;
                goto dot_size;
            } else if (*form != '*')
@@ -279,7 +279,7 @@ int sfvprintf(Sfio_t * f, const char *form, va_list args)
        case '8':
        case '9':
          dot_size:
-           for (v = fmt - '0'; isdigit(*form); ++form)
+           for (v = fmt - '0'; isdigit((int)*form); ++form)
                v = v * 10 + (*form - '0');
            if (*form == '$') {
                form += 1;
@@ -303,7 +303,7 @@ int sfvprintf(Sfio_t * f, const char *form, va_list args)
        case 'I':               /* object length */
            size = 0;
            flags = (flags & ~SFFMT_TYPES) | SFFMT_IFLAG;
-           if (isdigit(*form)) {
+           if (isdigit((int)*form)) {
                for (n = *form; isdigit(n); n = *++form)
                    size = size * 10 + (n - '0');
            } else if (*form == '*') {
@@ -815,7 +815,7 @@ int sfvprintf(Sfio_t * f, const char *form, va_list args)
            }
 
          e_format:             /* build the x.yyyy string */
-           if (isalpha(*ep))
+           if (isalpha((int)*ep))
                goto infinite;
            sp = endsp = buf + 1;       /* reserve space for sign */
            *endsp++ = *ep ? *ep++ : '0';
@@ -851,7 +851,7 @@ int sfvprintf(Sfio_t * f, const char *form, va_list args)
            goto end_efg;
 
          f_format:             /* data before the decimal point */
-           if (isalpha(*ep)) {
+           if (isalpha((int)*ep)) {
              infinite:
                endsp = (sp = ep) + sfslen();
                ep = endep;
index 39ac193c2bd4c0cd4bf123dfafda5b8b9a561f3e..078cf462b02add00440f21574405ae31c3eecb09 100644 (file)
@@ -241,7 +241,7 @@ int sfvscanf(Sfio_t * f, const char *form, va_list args)
 
        case '.':               /* width & base */
            dot += 1;
-           if (isdigit(*form)) {
+           if (isdigit((int)*form)) {
                fmt = *form++;
                goto dot_size;
            } else if (*form == '*') {
@@ -284,7 +284,7 @@ int sfvscanf(Sfio_t * f, const char *form, va_list args)
        case '8':
        case '9':
          dot_size:
-           for (v = fmt - '0'; isdigit(*form); ++form)
+           for (v = fmt - '0'; isdigit((int)*form); ++form)
                v = v * 10 + (*form - '0');
 
            if (*form == '$') {
@@ -305,7 +305,7 @@ int sfvscanf(Sfio_t * f, const char *form, va_list args)
        case 'I':               /* object size */
            size = 0;
            flags = (flags & ~SFFMT_TYPES) | SFFMT_IFLAG;
-           if (isdigit(*form)) {
+           if (isdigit((int)*form)) {
                for (n = *form; isdigit(n); n = *++form)
                    size = size * 10 + (n - '0');
            } else if (*form == '*') {
index 5bb1a59191c92b094f90846d7246937a44c01975..b03f60c1f4eccf90f54cf4ffc328734fa4527352 100644 (file)
@@ -245,7 +245,7 @@ static char *parseOp(xdot_op * op, char *s, drawfunc_t ops[], int* error)
     xdot_color clr;
 
     *error = 0;
-    while (isspace(*s))
+    while (isspace((int)*s))
        s++;
     switch (*s++) {
     case 'E':