summaryrefslogtreecommitdiff
path: root/wm/tvtwm/patches/patch-aq
blob: 7279b035a7187a2ed47a9388e9dc21b26960c559 (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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
$NetBSD: patch-aq,v 1.1.1.1 2000/12/12 02:03:49 wiz Exp $

Index: parse.c
===================================================================
RCS file: /home/siren/src/tvtwm/parse.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- parse.c	1999/08/08 05:46:53	1.1.1.1
+++ parse.c	1999/08/08 05:56:55	1.2
@@ -41,6 +41,7 @@
 #include <errno.h>
 #include <X11/Xos.h>
 #include <X11/Xmu/CharSet.h>
+#include <X11/Xmu/SysUtil.h>
 #include "twm.h"
 #include "screen.h"
 #include "menus.h"
@@ -70,6 +71,10 @@
 #endif
 #define BUF_LEN 300
 
+#ifndef errno
+extern int errno;
+#endif
+
 static FILE *twmrc;
 static FILE *menufile;
 static int ptr = 0;
@@ -98,9 +103,10 @@
 static int twmFileInput(), twmStringListInput(), twmMenuInput();
 void twmUnput();
 int (*twmInputFunc)();
+char *m4_defs(Display *dpy, char *display_name);
 
 extern char *defTwmrc[];        /* default bindings */
-
+extern void yyparse(void);
 
 /***********************************************************************
  *
@@ -462,6 +468,7 @@
 
 void
 TwmOutput(c)
+	int c;
 {
     putchar(c);
 }
@@ -1420,6 +1427,7 @@
 /*
  * put_pixel_on_root() Save a pixel value in twm root window color property.
  */
+void
 put_pixel_on_root(pixel)                                 
     Pixel pixel;                                         
 {                                                        
@@ -1562,11 +1570,11 @@
     return -1;
 }
 
-
-do_squeeze_entry (list, name, type, justify, num, denom)
+void
+do_squeeze_entry (list, name, matchtype, justify, num, denom)
     name_list **list;			/* squeeze or dont-squeeze list */
     char *name;				/* window name */
-    short type;				/* match type */
+    short matchtype;			/* match type */
     int justify;			/* left, center, right */
     int num;				/* signed num */
     int denom;				/* 0 or indicates fraction denom */
@@ -1605,7 +1613,7 @@
 	sinfo->justify = justify;
 	sinfo->num = num;
 	sinfo->denom = denom;
-	AddToList (list, name, type, (char *)sinfo);
+	AddToList (list, name, matchtype, (char *)sinfo);
     }
 }
 
@@ -1614,27 +1622,29 @@
 {
 	int fno;
 	int fids[2];
-	int fres;		/* Fork result */
+	pid_t fres;		/* Fork result */
 
 	fno = fileno(fraw);
 	/* if (-1 == fcntl(fno, F_SETFD, 0)) perror("fcntl()"); */
-	pipe(fids);
+	if (pipe(fids) != 0) perror("pipe creation failed for m4");
+        
 	fres = fork();
 	if (fres < 0) {
-		perror("Fork for m4 failed");
+	perror("Fork for m4 failed");
 		exit(23);
 	}
 	if (fres == 0) {
 		extern Display *dpy;
 		extern char *display_name;
-		static char *m4_defs();
 		char *tmp_file;
-
+                
 		/* Child */
 		close(0);			/* stdin */
 		close(1);			/* stdout */
 		dup2(fno, 0);		/* stdin = fraw */
 		dup2(fids[1], 1);	/* stdout = pipe to parent */
+                close(fids[0]); /* read end of pipe */
+                close(fids[1]); /* write end of pipe - its been duped */
 		/* get_defs("m4", dpy, display_name) */
 		tmp_file = m4_defs(dpy, display_name);
 		execlp("m4", "m4", tmp_file, M4STDIN, NULL); 
@@ -1696,7 +1706,7 @@
 
 /* Make a definition, but quote the defined string... */
 
-static char *MkQte(name, def)
+char *MkQte(name, def)
 char *name, *def;
 {
 	char *cp, *cp2;
@@ -1714,7 +1724,7 @@
 	strcpy(cp + 1, def);
 	strcat(cp, "\'");
 	cp2 = MkDef(name, cp);
-	free(cp);		/* Not really needed, but good habits die hard... */
+	free(cp);  /*Not really needed, but good habits die hard... */
 	return(cp2);
 }
 
@@ -1741,24 +1751,29 @@
 }
 #endif
 
-static char *m4_defs(display, host)
+char *m4_defs(display, host)
 Display *display;
 char *host;
 {
 	extern int KeepTmpFile;
-	int i;
 	Screen *screen;
 	Visual *visual;
 	char client[MAXHOSTNAME], server[MAXHOSTNAME], *colon;
 	struct hostent *hostname;
 	char *vc;		/* Visual Class */
-	static char tmp_name[] = "/tmp/twmrcXXXXXX";
+	char *tmp_name, name[] = "/tmp/twmrcXXXXXX";
 	int fd;
 	FILE *tmpf;
 	char *sp;
 	char *getenv_res;	/* Result of a getenv() call */
 	Boolean tvtwm = False;
 
+	if ((tmp_name = malloc(sizeof(char)*strlen(name)+1)) == NULL) {
+		perror("Cannot malloc temp_name\n");
+		exit(2);
+	}
+	
+	strcpy(tmp_name, name);
 	fd = mkstemp(tmp_name);		/* I *hope* mkstemp exists, because */
 					/* I tried to find the "portable" */
 					/* mktmp... */
@@ -1864,7 +1879,7 @@
 {
 	struct group *g;
 	int           i, ngids, staffg = 10;
-#if defined(SYSV) || defined(SVR4)
+#if defined(SYSV) || defined(SVR4) || defined(__NetBSD__)
 	gid_t         gids[NGIDS];
 #else
 	int           gids[NGIDS];
@@ -1899,18 +1914,19 @@
 /* next release.                                                           */
 /*                                      <cross@eng.umd.edu>                */
 
-static int getmask()
+int getmask()
 {
+#define L 150				/* Length of a line in /etc/passwd */
+#ifdef NOT
 	int tuid;				/* target */
 	FILE *passwd2;
 	int lineno = 0;
 	int mask, uid, gid;
-#define L 150				/* Length of a line in /etc/passwd */
 	char line[L], bak[L];
 	char *uname, *pisswd, *gcos, *dir, *shell, *num, *end;
 	int ch;
-
-#if 0
+#endif
+#if NOT
     tuid = getuid();
     passwd2 = fopen("/usr/local/etc/passwd/passwd", "r");
     if (passwd2 == NULL) {
@@ -1952,7 +1968,7 @@
 #endif
 }
 
-def_netmask(tmpf)
+void def_netmask(tmpf)
 FILE *tmpf;
 {
 	int mask;