summaryrefslogtreecommitdiff
path: root/x11/blt/patches/patch-src_bltScrollbar.c
blob: 9a368ae65f2de349618f1d5414fca62f7eec5888 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
$NetBSD: patch-src_bltScrollbar.c,v 1.1 2022/06/06 04:27:14 dholland Exp $

Update for tcl 8.6 (?) and don't use sprintf.

--- src/bltScrollbar.c~	2002-07-17 22:38:54.000000000 +0000
+++ src/bltScrollbar.c
@@ -534,7 +534,8 @@ ScrollbarWidgetCmd(clientData, interp, a
 	} else {
 	    fraction = ((double)pixels / (double)barWidth);
 	}
-	sprintf(interp->result, "%g", fraction);
+	snprintf(string, sizeof(string), "%g", fraction);
+	Tcl_SetResult(interp, string, TCL_VOLATILE);
     } else if ((c == 'f') && (strncmp(argv[1], "fraction", length) == 0)) {
 	int x, y, pos, barWidth;
 	double fraction;
@@ -567,7 +568,7 @@ ScrollbarWidgetCmd(clientData, interp, a
 	} else if (fraction > 1.0) {
 	    fraction = 1.0;
 	}
-	sprintf(string, "%g", fraction);
+	snprintf(string, sizeof(string), "%g", fraction);
 	Tcl_SetResult(interp, string, TCL_VOLATILE);
     } else if ((c == 'g') && (strncmp(argv[1], "get", length) == 0)) {
 	if (argc != 2) {
@@ -582,7 +583,8 @@ ScrollbarWidgetCmd(clientData, interp, a
 	    Tcl_PrintDouble(interp, scrollPtr->lastFraction, last);
 	    Tcl_AppendResult(interp, first, " ", last, (char *)NULL);
 	} else {
-	    sprintf(string, "%d %d %d %d", scrollPtr->totalUnits,
+	    snprintf(string, sizeof(string),
+	        "%d %d %d %d", scrollPtr->totalUnits,
 		scrollPtr->windowUnits, scrollPtr->firstUnit,
 		scrollPtr->lastUnit);
 	    Tcl_SetResult(interp, string, TCL_VOLATILE);