# Bernhard Simon <simon@zid.tuwien.ac.at>
# 20 Oct 2006
#
# On Ultrix sprintf does *not* return the number of characters printed
# and "sp+=sprintf(sp,...)" does not work as expected. Had to replace it
# with "sprintf(sp,...); sp+=strlen(sp)". With these changes "make check"
# completes.
#
#    Return Values
#      printf and fprintf return zero for success and EOF for failure. The
#      sprintf subroutine returns its first argument for success and EOF for
#      failure.
# 
#
--- src/mouse.c.ORIG	2006-07-18 07:20:50.000000000 +0200
+++ src/mouse.c	2006-10-10 13:57:35.000000000 +0200
@@ -420,7 +420,7 @@
 	char format[0xff] = "[%s, ";
 	strcat(format, mouse_setting.fmt);
 	strcat(format, "]");
-	s += sprintf(s, format, xDateTimeFormat(x, buf, mode), y);
+	sprintf(s, format, xDateTimeFormat(x, buf, mode), y); s += strlen(s);
     } else if (mode == MOUSE_COORDINATES_FRACTIONAL) {
 	double xrange = axis_array[FIRST_X_AXIS].max - axis_array[FIRST_X_AXIS].min;
 	double yrange = axis_array[FIRST_Y_AXIS].max - axis_array[FIRST_Y_AXIS].min;
@@ -429,24 +429,24 @@
 	if (xrange) {
 	    char format[0xff] = "/";
 	    strcat(format, mouse_setting.fmt);
-	    s += sprintf(s, format, (x - axis_array[FIRST_X_AXIS].min) / xrange);
+	    sprintf(s, format, (x - axis_array[FIRST_X_AXIS].min) / xrange); s += strlen(s);
 	} else {
-	    s += sprintf(s, "/(undefined)");
+	    sprintf(s, "/(undefined)"); s += strlen(s);
 	}
 	if (yrange) {
 	    char format[0xff] = ", ";
 	    strcat(format, mouse_setting.fmt);
 	    strcat(format, "/");
-	    s += sprintf(s, format, (y - axis_array[FIRST_Y_AXIS].min) / yrange);
+	    sprintf(s, format, (y - axis_array[FIRST_Y_AXIS].min) / yrange); s += strlen(s);
 	} else {
-	    s += sprintf(s, ", (undefined)/");
+	    sprintf(s, ", (undefined)/"); s += strlen(s);
 	}
     } else if (mode == MOUSE_COORDINATES_REAL1) {
-	s += sprintf(s, xy_format(), x, y);	/* w/o brackets */
+	sprintf(s, xy_format(), x, y); s += strlen(s);	/* w/o brackets */
     } else if (mode == MOUSE_COORDINATES_ALT && fmt) {
-	s += sprintf(s, fmt, x, y);	/* user defined format */
+	sprintf(s, fmt, x, y); s += strlen(s);	/* user defined format */
     } else {
-	s += sprintf(s, xy_format(), x, y);	/* usual x,y values */
+	sprintf(s, xy_format(), x, y); s += strlen(s);	/* usual x,y values */
     }
     return s;
 }
@@ -511,7 +511,7 @@
 	     *(strchr(format,'\n')) = ' ';			\
 	sp+=gstrftime(sp, 40, format, x);			\
     } else							\
-	sp+=sprintf(sp, mouse_setting.fmt ,x);			\
+	{ sprintf(sp, mouse_setting.fmt ,x); sp+=strlen(sp); }	\
 } while (0)
 
 
@@ -913,13 +913,13 @@
 	    MousePosToGraphPosReal(ruler.px, ruler.py, &ruler.x, &ruler.y, &ruler.x2, &ruler.y2);
 # endif
 	    if (TICS_ON(axis_array[FIRST_X_AXIS].ticmode))
-		sp += sprintf(sp, xy1_format("dx="), DIST(real_x, ruler.x, FIRST_X_AXIS));
+		sprintf(sp, xy1_format("dx="), DIST(real_x, ruler.x, FIRST_X_AXIS)); sp += strlen(sp);
 	    if (TICS_ON(axis_array[FIRST_Y_AXIS].ticmode))
-		sp += sprintf(sp, xy1_format("dy="), DIST(real_y, ruler.y, FIRST_Y_AXIS));
+		sprintf(sp, xy1_format("dy="), DIST(real_y, ruler.y, FIRST_Y_AXIS)); sp += strlen(sp);
 	    if (TICS_ON(axis_array[SECOND_X_AXIS].ticmode))
-		sp += sprintf(sp, xy1_format("dx2="), DIST(real_x2, ruler.x2, SECOND_X_AXIS));
+		sprintf(sp, xy1_format("dx2="), DIST(real_x2, ruler.x2, SECOND_X_AXIS)); sp += strlen(sp);
 	    if (TICS_ON(axis_array[SECOND_Y_AXIS].ticmode))
-		sp += sprintf(sp, xy1_format("dy2="), DIST(real_y2, ruler.y2, SECOND_Y_AXIS));
+		sprintf(sp, xy1_format("dy2="), DIST(real_y2, ruler.y2, SECOND_Y_AXIS)); sp += strlen(sp);
 	}
 	*--sp = 0;		/* delete trailing space */
     }
