summarylogtreecommitdiffstats
path: root/tcl-interp-result.patch
blob: ec3809a02346d90e8471d7f902913d36d5fcdf7b (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
From 165c7c95ba65d8b83eccae4b0b82ea274b137bb1 Mon Sep 17 00:00:00 2001
From: Colin Watson <cjwatson@ubuntu.com>
Date: Thu, 2 Jan 2014 06:14:30 +0000
Subject: Tcl 8.6 disallows direct access to TclInterp.result

Forwarded: no
Last-Update: 2012-12-21

Patch-Name: tcl-interp-result.patch
---
 ex/ex_tcl.c   |  3 ++-
 tcl_api/tcl.c | 12 +++++++++---
 tk/tk_main.c  |  7 +++++--
 vigor/vigor.c |  6 +++---
 4 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/ex/ex_tcl.c b/ex/ex_tcl.c
index 06736a7..92ab679 100644
--- a/ex/ex_tcl.c
+++ b/ex/ex_tcl.c
@@ -71,7 +71,8 @@ ex_tcl(sp, cmdp)
 	    Tcl_Eval(gp->tcl_interp, cmdp->argv[0]->bp) == TCL_OK)
 		return (0);
 
-	msgq(sp, M_ERR, "Tcl: %s", ((Tcl_Interp *)gp->tcl_interp)->result);
+	msgq(sp, M_ERR, "Tcl: %s",
+	    Tcl_GetStringResult((Tcl_Interp *)gp->tcl_interp));
 	return (1);
 #else
 	msgq(sp, M_ERR, "302|Vi was not loaded with a Tcl interpreter");
diff --git a/tcl_api/tcl.c b/tcl_api/tcl.c
index 8f4a430..a58ddb5 100644
--- a/tcl_api/tcl.c
+++ b/tcl_api/tcl.c
@@ -64,6 +64,7 @@ tcl_fscreen(clientData, interp, argc, argv)
 	char **argv;
 {
 	SCR *sp;
+	char buf[20];
 
 	if (argc != 2) {
 		Tcl_SetResult(interp, "Usage: viFindScreen file", TCL_STATIC);
@@ -73,7 +74,8 @@ tcl_fscreen(clientData, interp, argc, argv)
 	if (getscreenid(interp, &sp, NULL, argv[1]))
 		return (TCL_ERROR);
 
-	(void)sprintf(interp->result, "%d", sp->id);
+	(void)snprintf(buf, sizeof(buf), "%d", sp->id);
+	Tcl_SetResult(interp, buf, TCL_VOLATILE);
 	return (TCL_OK);
 }
 
@@ -240,6 +242,7 @@ tcl_lline(clientData, interp, argc, argv)
 	recno_t last;
 	void (*scr_msg) __P((SCR *, mtype_t, char *, size_t));
 	int rval;
+	char buf[40];
 
 	if (argc != 2) {
 		Tcl_SetResult(interp, "Usage: viLastLine screenId", TCL_STATIC);
@@ -254,7 +257,8 @@ tcl_lline(clientData, interp, argc, argv)
 	if (rval)
 		return (TCL_ERROR);
 
-	(void)sprintf(interp->result, "%lu", (unsigned long)last);
+	(void)snprintf(buf, sizeof(buf), "%lu", (unsigned long)last);
+	Tcl_SetResult(interp, buf, TCL_VOLATILE);
 	return (TCL_OK);
 }
 
@@ -504,6 +508,7 @@ tcl_iscreen(clientData, interp, argc, argv)
 	SCR *sp, *nsp;
 	void (*scr_msg) __P((SCR *, mtype_t, char *, size_t));
 	int rval;
+	char buf[20];
 
 	if (argc != 2 && argc != 3) {
 		Tcl_SetResult(interp,
@@ -520,7 +525,8 @@ tcl_iscreen(clientData, interp, argc, argv)
 	if (rval)
 		return (TCL_ERROR);
 
-	(void)sprintf(interp->result, "%d", nsp->id);
+	(void)snprintf(buf, sizeof(buf), "%d", nsp->id);
+	Tcl_SetResult(interp, buf, TCL_VOLATILE);
 	return (TCL_OK);
 }
 
diff --git a/tk/tk_main.c b/tk/tk_main.c
index c2f34e7..6149e72 100644
--- a/tk/tk_main.c
+++ b/tk/tk_main.c
@@ -306,8 +306,11 @@ static void
 tcl_err(tkp)
 	TK_PRIVATE *tkp;
 {
-	(void)fprintf(stderr, "%s\n", tkp->interp->result != NULL ?
-	    tkp->interp->result : "Tcl/Tk: initialization error");
+	const char *result;
+
+	result = Tcl_GetStringResult(tkp->interp);
+	(void)fprintf(stderr, "%s\n", result != NULL ?
+	    result : "Tcl/Tk: initialization error");
 	(void)tk_usage();
 	exit (1);
 }
diff --git a/vigor/vigor.c b/vigor/vigor.c
index 987d019..b233a9e 100644
--- a/vigor/vigor.c
+++ b/vigor/vigor.c
@@ -78,7 +78,7 @@ vigor_init(gp)
 	 * to want tk's main window cluttering up the place.  I should
 	 * use a wm_withdraw instead. */
 	if (Tk_Init(vigor_interp) == TCL_ERROR) {
-		fprintf(stderr, "%s\n", vigor_interp->result);		
+		fprintf(stderr, "%s\n", Tcl_GetStringResult(vigor_interp));
 		return (1);
 	}
 
@@ -87,7 +87,7 @@ vigor_init(gp)
 		return (1);
 #endif
 	if (Tcl_Eval(vigor_interp, vigor_tcl) == TCL_ERROR) {
-		fprintf(stderr, "%s\n", vigor_interp->result);
+		fprintf(stderr, "%s\n", Tcl_GetStringResult(vigor_interp));
 		return (1);
 	}
 
@@ -127,7 +127,7 @@ vigor_init(gp)
 	init_vigor_phrases();
 
 	if (Tcl_Eval(vigor_interp, "vigor_init") == TCL_ERROR) {
-		fprintf(stderr, "%s\n", vigor_interp->result);
+		fprintf(stderr, "%s\n", Tcl_GetStringResult(vigor_interp));
 	        return (1);
 	}