summaryrefslogtreecommitdiff
path: root/misc/splitvt/patches/patch-ab
blob: 6015ff8172ce657a544576996f637a5d52c01039 (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
$NetBSD: patch-ab,v 1.2 2008/07/25 03:38:01 tonnerre Exp $

--- vtmouse.c.orig	2007-04-01 19:58:22.000000000 +0200
+++ vtmouse.c
@@ -83,7 +83,7 @@ int main(int argc, char *argv[])
 #endif
 
 /* I/O streams default to stdin and stdout. */
-static FILE *xt_input, *xt_output;
+static FILE *xt_input = NULL, *xt_output = NULL;
 static int have_xterm=0;
 static int set_title=0;
 static char *old_title=NULL;
@@ -120,6 +120,9 @@ static char *get_xtitle()
 static void set_xtitle(titlebar)
 char *titlebar;
 {
+	if (xt_output == NULL)
+		xt_output = stdout;
+
 	fprintf(xt_output, "\033]0;%s\07", titlebar);
 	fflush(xt_output);
 }
@@ -168,6 +171,11 @@ struct event *X_event;
 	window *thiswin;
 #endif
 
+	if (xt_input == NULL)
+		xt_input = stdin;
+	if (xt_output == NULL)
+		xt_output = stdout;
+
 	X_event->happening=0;
 
 	if ( have_xterm ) {
@@ -279,6 +287,9 @@ struct event *X_event;
 
 void event_quit()
 {
+	if (xt_output == NULL)
+		xt_output = stdout;
+
 	if ( have_xterm ) {
 #ifdef REPORT_SELECTION
 		fprintf(xt_output, "\033[?1001l");