]> granicus.if.org Git - graphviz/commitdiff
gvc gvprintpointflist: take number of points as a size_t
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 18 Aug 2022 00:51:39 +0000 (17:51 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Tue, 23 Aug 2022 04:38:16 +0000 (21:38 -0700)
This is a more appropriate type for the length of an array.

lib/gvc/gvdevice.c
lib/gvc/gvio.h
plugin/core/gvrender_core_ps.c
plugin/core/gvrender_core_tk.c
plugin/lasi/gvrender_lasi.cpp

index 7a8c6f9b36caa6a58babb4892a947f7739fbe8d6..aca908f113cab49d52cd56548e9b8fae46669163 100644 (file)
@@ -595,10 +595,9 @@ void gvprintpointf(GVJ_t * job, pointf p)
     gvwrite(job, buf, len);
 } 
 
-void gvprintpointflist(GVJ_t * job, pointf *p, int n)
-{
+void gvprintpointflist(GVJ_t *job, pointf *p, size_t n) {
   const char *separator = "";
-  for (int i = 0; i < n; ++i) {
+  for (size_t i = 0; i < n; ++i) {
     gvputs(job, separator);
     gvprintpointf(job, p[i]);
     separator = " ";
index 078e17d072f1b9697a26bdbab6faec9c2e6038f9..5a5bcf107e1cdba84bfa1c0247860f80e918e4fb 100644 (file)
@@ -43,7 +43,7 @@ extern "C" {
     GVIO_API void gvprintf(GVJ_t * job, const char *format, ...);
     GVIO_API void gvprintdouble(GVJ_t * job, double num);
     GVIO_API void gvprintpointf(GVJ_t * job, pointf p);
-    GVIO_API void gvprintpointflist(GVJ_t * job, pointf *p, int n);
+    GVIO_API void gvprintpointflist(GVJ_t *job, pointf *p, size_t n);
 
 #undef GVIO_API
 
index f51f7c85f3c64892736def027b7d605f122c1a97..c46f275e6616a363b13b36bab81b705c432a88b8 100644 (file)
@@ -9,7 +9,7 @@
  *************************************************************************/
 
 #include "config.h"
-
+#include <assert.h>
 #include <stdlib.h>
 #include <string.h>
 
@@ -413,10 +413,11 @@ static void psgen_comment(GVJ_t * job, char *str)
 
 static void psgen_library_shape(GVJ_t * job, char *name, pointf * A, int n, int filled)
 {
+    assert(n >= 0);
     if (filled && job->obj->fillcolor.u.HSVA[3] > .5) {
        ps_set_color(job, &(job->obj->fillcolor));
        gvputs(job, "[ ");
-        gvprintpointflist(job, A, n);
+        gvprintpointflist(job, A, (size_t)n);
         gvputs(job, " ");
         gvprintpointf(job, A[0]);
        gvprintf(job, " ]  %d true %s\n", n, name);
@@ -425,7 +426,7 @@ static void psgen_library_shape(GVJ_t * job, char *name, pointf * A, int n, int
         ps_set_pen_style(job);
         ps_set_color(job, &(job->obj->pencolor));
         gvputs(job, "[ ");
-        gvprintpointflist(job, A, n);
+        gvprintpointflist(job, A, (size_t)n);
         gvputs(job, " ");
         gvprintpointf(job, A[0]);
         gvprintf(job, " ]  %d false %s\n", n, name);
index 17bba9a6fc280af3b87813aa80211761b6fce778..795f6e9acd9f6d4a4f72bdd086a46e892e72868e 100644 (file)
@@ -9,7 +9,7 @@
  *************************************************************************/
 
 #include "config.h"
-
+#include <assert.h>
 #include <inttypes.h>
 #include <stdarg.h>
 #include <stdint.h>
@@ -263,12 +263,14 @@ tkgen_bezier(GVJ_t * job, pointf * A, int n, int arrow_at_start,
     (void)arrow_at_end;
     (void)filled;
 
+    assert(n >= 0);
+
     obj_state_t *obj = job->obj;
 
     if (obj->pen != PEN_NONE) {
         tkgen_canvas(job);
         gvputs(job, " create line ");
-        gvprintpointflist(job, A, n);
+        gvprintpointflist(job, A, (size_t)n);
         gvputs(job, " -fill ");
         tkgen_print_color(job, obj->pencolor);
         gvputs(job, " -width ");
@@ -285,12 +287,14 @@ tkgen_bezier(GVJ_t * job, pointf * A, int n, int arrow_at_start,
 
 static void tkgen_polygon(GVJ_t * job, pointf * A, int n, int filled)
 {
+    assert(n >= 0);
+
     obj_state_t *obj = job->obj;
 
     if (obj->pen != PEN_NONE) {
         tkgen_canvas(job);
         gvputs(job, " create polygon ");
-        gvprintpointflist(job, A, n);
+        gvprintpointflist(job, A, (size_t)n);
         gvputs(job, " -fill ");
         if (filled)
             tkgen_print_color(job, obj->fillcolor);
@@ -318,12 +322,14 @@ static void tkgen_polygon(GVJ_t * job, pointf * A, int n, int filled)
 
 static void tkgen_polyline(GVJ_t * job, pointf * A, int n)
 {
+    assert(n >= 0);
+
     obj_state_t *obj = job->obj;
 
     if (obj->pen != PEN_NONE) {
         tkgen_canvas(job);
         gvputs(job, " create line ");
-        gvprintpointflist(job, A, n);
+        gvprintpointflist(job, A, (size_t)n);
         gvputs(job, " -fill ");
         tkgen_print_color(job, obj->pencolor);
         if (obj->pen == PEN_DASHED)
index 6cf68e02a658067c4c16e00443c0b0b666c23302..a80eebcb1781d3300d09d77345129b353baabb36 100644 (file)
@@ -534,10 +534,11 @@ static void lasi_comment(GVJ_t * job, char *str)
 
 static void lasi_library_shape(GVJ_t * job, char *name, pointf * A, int n, int filled)
 {
+    assert(n >= 0);
     if (filled && job->obj->fillcolor.u.HSVA[3] > .5) {
        ps_set_color(job, &(job->obj->fillcolor));
        gvputs(job, "[ ");
-       gvprintpointflist(job, A, n);
+       gvprintpointflist(job, A, (size_t)n);
        gvputs(job, " ");
        gvprintpointf(job, A[0]);
        gvprintf(job, " ]  %d true %s\n", n, name);