summaryrefslogtreecommitdiff
path: root/cad/spice/patches/patch-am
blob: 3349bac71cf361c604c7c533c2fef77a4dc5ed20 (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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
$NetBSD: patch-am,v 1.3 2013/03/02 17:51:49 joerg Exp $

--- src/lib/fte/x11.c.orig	1993-04-14 19:44:56.000000000 +0000
+++ src/lib/fte/x11.c
@@ -12,6 +12,7 @@ Author: 1988 Jeffrey M. Hsu
 #ifdef HAS_X11
 
 #  include <sys/time.h>
+#  include <sys/select.h>
 
 #  include "util.h"
 
@@ -39,7 +40,7 @@ extern int _Xdebug;
 /* forward declarations */
 extern void handlebuttonev(), handlekeypressed(), killwin(), hardcopy(),
 	    redraw(), resize();
-int errorhandler();
+static void errorhandler(Display *display, XErrorEvent *errorev);
 
 #define RAD_TO_DEG	(180.0 / M_PI)
 
@@ -62,6 +63,12 @@ typedef struct x11info {
 #define DEVDEP(g) (*((X11devdep *) (g)->devdep))
 
 static void linear_arc( );
+static void initlinestyles( );
+static void initcolors( );
+static void X_ScreentoData( );
+
+static void slopelocation(GRAPH *graph, int x0, int y0);
+
 static Display *display;
 static GC xorgc;
 static char *xlinestyles[NUMLINESTYLES] = {	/* test patterns XXX */
@@ -145,10 +152,8 @@ X11_Init()
 
 }
 
-int
-errorhandler(display, errorev)
-Display *display;
-XErrorEvent *errorev;
+static void
+errorhandler(Display *display, XErrorEvent *errorev)
 {
 	XGetErrorText(display, errorev->error_code, ErrorMessage, 1024);
 	externalerror(ErrorMessage);
@@ -302,7 +307,7 @@ GRAPH *graph;
 	return (0);
 }
 
-static
+static void
 initlinestyles()
 {
 
@@ -318,7 +323,7 @@ initlinestyles()
 	return;
 }
 
-static
+static void
 initcolors(graph)
     GRAPH *graph;
 {
@@ -405,9 +410,7 @@ int x1, y1, x2, y2;
 }
 
 /*ARGSUSED*/
-X11_Arc(x0, y0, radius, theta1, theta2)
-int x0, y0, radius;
-double theta1, theta2;
+void X11_Arc(int x0, int y0, int radius, double theta1, double theta2)
 {
 
     int	t1, t2;
@@ -612,9 +615,7 @@ caddr_t clientdata, calldata;
 }
 #  endif
 
-slopelocation(graph, x0, y0)
-GRAPH *graph;
-int x0, y0;         /* initial position of mouse */
+static void slopelocation(GRAPH *graph, int x0, int y0)
 {
 
 	int x1, y1;
@@ -773,12 +774,15 @@ GRAPH *graph;
 	        graph->commandline, fx0, fx1, fy0, fy1);
 	}
 
+/* don't use the following if using GNU Readline - AV */
+#ifndef HAS_GNUREADLINE
 	/* hack for Gordon Jacobs */
 	/* add to history list if plothistory is set */
 	if (cp_getvar("plothistory", VT_BOOL, (char *) &dummy)) {
 	  wl = cp_parse(buf);
 	  (void) cp_addhistent(cp_event++, wl);
 	}
+#endif /* HAS_GNUREADLINE */
 
 	(void) cp_evloop(buf);
 
@@ -915,13 +919,12 @@ static int inchar(fp)
 }
 #  endif
 
-X11_Input(request, response)
-    REQUEST *request;
-    RESPONSE *response;
+void X11_Input(REQUEST *request, RESPONSE *response)
 {
 
 	XEvent ev;
-	int nfds, readfds;
+	int nfds;
+	fd_set readfds;
 
 	switch (request->option) {
 	  case char_option:
@@ -938,14 +941,15 @@ X11_Input(request, response)
 	        XtDispatchEvent(&ev);
 	      }
 
-	      readfds = 1 << fileno(request->fp) |
-	            1 << ConnectionNumber(display);
+              FD_ZERO(&readfds);
+	      FD_SET(fileno(request->fp), &readfds);
+	      FD_SET(ConnectionNumber(display), &readfds);
 
 	      /* block on ConnectionNumber and request->fp */
-	      select(nfds + 1, &readfds, (int *) NULL, (int *) NULL, NULL);
+	      select(nfds + 1, &readfds, NULL, NULL, NULL);
 
 	      /* handle X events first */
-	      if (readfds & (1 << ConnectionNumber(display))) {
+	      if (FD_ISSET(ConnectionNumber(display),&readfds)) {
 		    /* handle ALL X events */
 		    while (XtPending()) {
 			  XtNextEvent(&ev);
@@ -953,7 +957,7 @@ X11_Input(request, response)
 		    }
 	      }
 
-	      if (readfds & (1 << fileno(request->fp))) {
+	      if (FD_ISSET(fileno(request->fp), &readfds)) {
 		    response->reply.ch = inchar(request->fp);
 		    goto out;
 	      }
@@ -995,10 +999,11 @@ out:
 
 }
 
-static X_ScreentoData(graph, x, y, fx, fy)
-GRAPH *graph;
-int x,y;
-double *fx, *fy;
+static void
+X_ScreentoData(graph, x, y, fx, fy)
+    GRAPH *graph;
+    int x,y;
+    double *fx, *fy;
 {
 	double	lmin, lmax;