commit c407e30e texdraw: negative of unsigned int requires a cast

Ethan A Merritt <[email protected]>
Newsgroups gmane.comp.graphics.gnuplot.devel
Organization University of Washington
Message-ID <1836819.5S0FaIm1YL@stonelion>
Probably not a big deal, but...
     I believe this commit to be incorrect.

It is not true that passing the negative of an unsigned int requires a cast.
Or if it is true, then something is wrong with the compiler.

If the function has a prototype (now required!) then arguments are promoted to
match the prototype.

fprintf() is a weird special case because it is a variadic function but nevertheless 
anything given a format specifier %d will be promoted to integer.

This is covered in section 6.5.2.2 of the ISO C standard (checked in draft dated 2007)

If for some reason there is a real problem here I would prefer to understand
what it is.   Did you get a compiler warning?  What compiler?
Do you have a test case where this commit actually makes a difference to the output?

If a change is necessary for some reason, I would rather consider
all of these structure fields to int rather than unsigned.

*diff --git a/src/term_api.h b/src/term_api.h* 
*index c836e19cd..f8898c0b5 100644* 
*--- a/src/term_api.h* 
*+++ b/src/term_api.h* 
@@ -290,7 +290,7 @@ typedef enum t_imagecolor { IC_PALETTE, IC_RGB, IC_RGBA } 
-    unsigned int xmax,ymax,v_char,h_char,v_tic,h_tic; 
+    int xmax,ymax,v_char,h_char,v_tic,h_tic; 


  best,
	Ethan

%% commit    c407e30e
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -410,11 +410,11 @@ TEXDRAW_graphics()
 	/* enforce bounding box */
 	fprintf(gpoutfile, "\\move (0 0) \\rmove (%d %d)\n",
 		    term->xmax, term->ymax);
     } else {
 	fprintf(gpoutfile, "\\move (0 0) \\rlvec (%d 0) \\rlvec (0 %d) \\rlvec (%d 0) \\ifill f:%0.2f\n",
-		    term->xmax, term->ymax, -term->xmax,
+		    term->xmax, term->ymax, - (int) term->xmax,
 		    TEXDRAW_background);
     }
 
     TEXDRAW_last_type = 0;
     TEXDRAW_type = 0;
@@ -814,11 +814,11 @@ TEXDRAW_fillbox(int style,
 
     // outline box using relative moves
     fprintf(gpoutfile, "\\move (%d %d)", x1, y1);
     fprintf(gpoutfile, "\\rlvec (%d %d)", width, 0);
     fprintf(gpoutfile, "\\rlvec (%d %d)", 0, height);
-    fprintf(gpoutfile, "\\rlvec (%d %d)", -width, 0);
+    fprintf(gpoutfile, "\\rlvec (%d %d)", - (int) width, 0);
     // the polygon is closed automatically by fill
     fprintf(gpoutfile, "\\ifill f:%0.2f\n", gray);
 }
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

_______________________________________________
gnuplot-beta mailing list
[email protected]
Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-beta
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.