]> granicus.if.org Git - graphviz/commitdiff
remove use of %d to print size_t
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Wed, 24 Feb 2021 03:31:08 +0000 (19:31 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Tue, 2 Mar 2021 06:05:11 +0000 (22:05 -0800)
Now that we build with C99, %zu is available.

cmd/gvmap/make_map.c
lib/xdot/xdot.c
plugin/core/gvrender_core_dot.c

index 93baee07fc02ad4f6edd5844c9ab6a6c8951ecd0..b189b157aa9292b85593a3a48d46d56fb990be57 100644 (file)
@@ -648,16 +648,16 @@ static void dot_polygon(char **sbuff, int *len, int *len_max, int np, float *xp,
   if (np > 0){
     /* figure out the size needed */
     if (fill >= 0){/* poly*/
-      ret += snprintf(buf, sizeof(buf), " c %d -%s C %d -%s P %d ",(int) strlen(cstring), cstring, (int) strlen(cstring), cstring, np);
+      ret += snprintf(buf, sizeof(buf), " c %zu -%s C %zu -%s P %d ", strlen(cstring), cstring, strlen(cstring), cstring, np);
     } else {/* line*/
       assert(line_width >= 0);
       if (line_width > 0){
        sprintf(swidth,"%f",line_width);
        len_swidth = strlen(swidth);
        sprintf(swidth,"S %d -setlinewidth(%f)",len_swidth+14, line_width);
-       ret += snprintf(buf, sizeof(buf), " c %d -%s %s L %d ",(int) strlen(cstring), cstring, swidth, np);
+       ret += snprintf(buf, sizeof(buf), " c %zu -%s %s L %d ", strlen(cstring), cstring, swidth, np);
       } else {
-       ret += snprintf(buf, sizeof(buf), " c %d -%s L %d ",(int) strlen(cstring), cstring, np);
+       ret += snprintf(buf, sizeof(buf), " c %zu -%s L %d ", strlen(cstring), cstring, np);
       }
     }
     for (i = 0; i < np; i++){
@@ -671,15 +671,15 @@ static void dot_polygon(char **sbuff, int *len, int *len_max, int np, float *xp,
 
     /* do the actual string */
     if (fill >= 0){
-      ret = sprintf(&((*sbuff)[*len]), " c %d -%s C %d -%s P %d ",(int) strlen(cstring), cstring, (int) strlen(cstring), cstring, np);
+      ret = sprintf(&((*sbuff)[*len]), " c %zu -%s C %zu -%s P %d ", strlen(cstring), cstring, strlen(cstring), cstring, np);
     } else {
       if (line_width > 0){
         sprintf(swidth,"%f",line_width);
         len_swidth = strlen(swidth);
         sprintf(swidth,"S %d -setlinewidth(%f)",len_swidth+14, line_width);
-       ret = sprintf(&((*sbuff)[*len]), " c %d -%s %s L %d ",(int) strlen(cstring), cstring, swidth, np);
+       ret = sprintf(&((*sbuff)[*len]), " c %zu -%s %s L %d ", strlen(cstring), cstring, swidth, np);
       } else {
-       ret = sprintf(&((*sbuff)[*len]), " c %d -%s L %d ",(int) strlen(cstring), cstring, np);
+       ret = sprintf(&((*sbuff)[*len]), " c %zu -%s L %d ", strlen(cstring), cstring, np);
       }
     }
     (*len) += ret;
index b521086fed475cec24a187bb82353525311d3f9e..df6897af04efdfb2edd140268c16432d29344b84 100644 (file)
@@ -533,7 +533,7 @@ static void printString(char *p, pf print, void *info)
 {
     char buf[30];
 
-    sprintf(buf, " %d -", (int) strlen(p));
+    sprintf(buf, " %zu -", strlen(p));
     print(buf, info);
     print(p, info);
 }
index 7e7327c7cf865c9f0f798b4783e3ed66462a51c7..2a783969a0c2b42ca69dc715057561896eb54605 100644 (file)
@@ -81,7 +81,7 @@ static xdot_state_t* xd;
 
 static void xdot_str_xbuf (agxbuf* xb, char* pfx, char* s)
 {
-    agxbprint (xb, "%s%d -%s ", pfx, (int)strlen(s), s);
+    agxbprint (xb, "%s%zu -%s ", pfx, strlen(s), s);
 }
 
 static void xdot_str (GVJ_t *job, char* pfx, char* s)