summaryrefslogtreecommitdiff
path: root/pkg/catgirl/patch/0001-Revert-Use-gnu-case-range-and-gnu-conditional-omitte.patch
blob: c77fc31db7d4a43268918bb37f0a78b5f548135f (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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
From beac90889183cb71ca3dfc8c9ada9175879b9c34 Mon Sep 17 00:00:00 2001
From: Michael Forney <mforney@mforney.org>
Date: Thu, 7 May 2020 00:36:14 -0700
Subject: [PATCH] Revert "Use gnu-case-range and
 gnu-conditional-omitted-operand extensions"

This reverts commit 75a6aa9258270169f43f56e063f1bfb57eebe56b.
---
 Makefile   |  2 --
 command.c  | 33 +++++++++++++++++++--------------
 complete.c |  4 ++--
 edit.c     |  2 +-
 handle.c   | 45 +++++++++++++++++++++++++++------------------
 input.c    |  7 ++++++-
 url.c      |  2 +-
 window.c   |  2 +-
 8 files changed, 57 insertions(+), 40 deletions(-)

diff --git a/Makefile b/Makefile
index 3abba03..9518cda 100644
--- a/Makefile
+++ b/Makefile
@@ -2,9 +2,7 @@ PREFIX ?= /usr/local
 BINDIR ?= ${PREFIX}/bin
 MANDIR ?= ${PREFIX}/man
 
-CEXTS = gnu-case-range gnu-conditional-omitted-operand
 CFLAGS += -std=c11 -Wall -Wextra -Wpedantic -Wmissing-prototypes
-CFLAGS += ${CEXTS:%=-Wno-%}
 LDADD.libtls = -ltls
 LDADD.ncursesw = -lncursesw
 
diff --git a/command.c b/command.c
index a127af3..f5be51b 100644
--- a/command.c
+++ b/command.c
@@ -68,8 +68,8 @@ static int splitChunk(const char *cmd, uint id) {
 	int overhead = snprintf(
 		NULL, 0, ":%s!%*s@%*s %s %s :\r\n",
 		self.nick,
-		(self.user ? 0 : network.userLen), (self.user ?: "*"),
-		(self.host ? 0 : network.hostLen), (self.host ?: "*"),
+		(self.user ? 0 : network.userLen), (self.user ? self.user : "*"),
+		(self.host ? 0 : network.hostLen), (self.host ? self.host : "*"),
 		cmd, idNames[id]
 	);
 	assert(overhead > 0 && overhead < 512);
@@ -171,7 +171,7 @@ static void commandPart(uint id, char *params) {
 
 static void commandQuit(uint id, char *params) {
 	(void)id;
-	set(&self.quit, (params ?: "nyaa~"));
+	set(&self.quit, (params ? params : "nyaa~"));
 }
 
 static void commandNick(uint id, char *params) {
@@ -275,7 +275,7 @@ static void commandOp(uint id, char *params) {
 }
 
 static void commandDeop(uint id, char *params) {
-	channelListMode(id, '-', 'o', (params ?: self.nick));
+	channelListMode(id, '-', 'o', (params ? params : self.nick));
 }
 
 static void commandVoice(uint id, char *params) {
@@ -287,7 +287,7 @@ static void commandVoice(uint id, char *params) {
 }
 
 static void commandDevoice(uint id, char *params) {
-	channelListMode(id, '-', 'v', (params ?: self.nick));
+	channelListMode(id, '-', 'v', (params ? params : self.nick));
 }
 
 static void commandBan(uint id, char *params) {
@@ -362,12 +362,12 @@ static void commandWhowas(uint id, char *params) {
 
 static void commandNS(uint id, char *params) {
 	(void)id;
-	ircFormat("NS %s\r\n", (params ?: "HELP"));
+	ircFormat("NS %s\r\n", (params ? params : "HELP"));
 }
 
 static void commandCS(uint id, char *params) {
 	(void)id;
-	ircFormat("CS %s\r\n", (params ?: "HELP"));
+	ircFormat("CS %s\r\n", (params ? params : "HELP"));
 }
 
 static void commandQuery(uint id, char *params) {
@@ -442,7 +442,8 @@ static void commandFilter(enum Heat heat, uint id, char *params) {
 		uiFormat(
 			id, Cold, NULL, "%sing \3%02d%s %s %s %s",
 			(heat == Hot ? "Highlight" : "Ignor"), Brown, filter.mask,
-			(filter.cmd ?: ""), (filter.chan ?: ""), (filter.mesg ?: "")
+			(filter.cmd ? filter.cmd : ""), (filter.chan ? filter.chan : ""),
+			(filter.mesg ? filter.mesg : "")
 		);
 	} else {
 		for (size_t i = 0; i < FilterCap && filters[i].mask; ++i) {
@@ -450,8 +451,9 @@ static void commandFilter(enum Heat heat, uint id, char *params) {
 			uiFormat(
 				Network, Warm, NULL, "%sing \3%02d%s %s %s %s",
 				(heat == Hot ? "Highlight" : "Ignor"), Brown, filters[i].mask,
-				(filters[i].cmd ?: ""), (filters[i].chan ?: ""),
-				(filters[i].mesg ?: "")
+				(filters[i].cmd ? filters[i].cmd : ""),
+				(filters[i].chan ? filters[i].chan : ""),
+				(filters[i].mesg ? filters[i].mesg : "")
 			);
 		}
 	}
@@ -464,8 +466,8 @@ static void commandUnfilter(enum Heat heat, uint id, char *params) {
 	uiFormat(
 		id, Cold, NULL, "%s %sing \3%02d%s %s %s %s",
 		(found ? "No longer" : "Not"), (heat == Hot ? "highlight" : "ignor"),
-		Brown, filter.mask, (filter.cmd ?: ""), (filter.chan ?: ""),
-		(filter.mesg ?: "")
+		Brown, filter.mask, (filter.cmd ? filter.cmd : ""),
+		(filter.chan ? filter.chan : ""), (filter.mesg ? filter.mesg : "")
 	);
 }
 
@@ -494,7 +496,9 @@ static void commandExec(uint id, char *params) {
 	dup2(execPipe[1], STDOUT_FILENO);
 	dup2(utilPipe[1], STDERR_FILENO);
 
-	const char *shell = getenv("SHELL") ?: "/bin/sh";
+	const char *shell = getenv("SHELL");
+	if (!shell)
+		shell = "/bin/sh";
 	execl(shell, shell, "-c", params, NULL);
 	warn("%s", shell);
 	_exit(EX_UNAVAILABLE);
@@ -519,7 +523,8 @@ static void commandHelp(uint id, char *params) {
 	if (pid) return;
 
 	char buf[256];
-	snprintf(buf, sizeof(buf), "%sp^COMMANDS$", (getenv("LESS") ?: ""));
+	const char *less = getenv("LESS");
+	snprintf(buf, sizeof(buf), "%sp^COMMANDS$", (less ? less : ""));
 	setenv("LESS", buf, 1);
 	execlp("man", "man", "1", "catgirl", NULL);
 	dup2(utilPipe[1], STDERR_FILENO);
diff --git a/complete.c b/complete.c
index 9e59db5..9ea1192 100644
--- a/complete.c
+++ b/complete.c
@@ -71,7 +71,7 @@ static struct Node *prepend(struct Node *node) {
 	node->next = head;
 	if (head) head->prev = node;
 	head = node;
-	tail = (tail ?: node);
+	if (!tail) tail = node;
 	return node;
 }
 
@@ -80,7 +80,7 @@ static struct Node *append(struct Node *node) {
 	node->prev = tail;
 	if (tail) tail->next = node;
 	tail = node;
-	head = (head ?: node);
+	if (!head) head = node;
 	return node;
 }
 
diff --git a/edit.c b/edit.c
index bb92edf..07705dd 100644
--- a/edit.c
+++ b/edit.c
@@ -69,7 +69,7 @@ int editReserve(struct Edit *e, size_t index, size_t count) {
 		return -1;
 	}
 	if (e->len + count > e->cap) {
-		size_t cap = (e->cap ?: 256);
+		size_t cap = (e->cap ? e->cap : 256);
 		while (cap < e->len + count) cap *= 2;
 		wchar_t *buf = realloc(e->buf, sizeof(*buf) * cap);
 		if (!buf) return -1;
diff --git a/handle.c b/handle.c
index 9f051c7..a4f1015 100644
--- a/handle.c
+++ b/handle.c
@@ -301,9 +301,9 @@ static void handleReplyISupport(struct Message *msg) {
 			set(&network.setParamModes, setParam);
 			set(&network.channelModes, channel);
 		} else if (!strcmp(key, "EXCEPTS")) {
-			network.excepts = (msg->params[i] ?: "e")[0];
+			network.excepts = (msg->params[i] ? msg->params[i][0] : 'e');
 		} else if (!strcmp(key, "INVEX")) {
-			network.invex = (msg->params[i] ?: "I")[0];
+			network.invex = (msg->params[i] ? msg->params[i][0] : 'I');
 		}
 	}
 }
@@ -356,7 +356,7 @@ static void handleJoin(struct Message *msg) {
 		"\3%02d%s\3\t%s%s%sarrives in \3%02d%s\3",
 		hash(msg->user), msg->nick,
 		(msg->params[2] ? "(" : ""),
-		(msg->params[2] ?: ""),
+		(msg->params[2] ? msg->params[2] : ""),
 		(msg->params[2] ? "\17) " : ""),
 		hash(msg->params[0]), msg->params[0]
 	);
@@ -388,12 +388,14 @@ static void handlePart(struct Message *msg) {
 		id, heat, tagTime(msg),
 		"\3%02d%s\3\tleaves \3%02d%s\3%s%s",
 		hash(msg->user), msg->nick, hash(msg->params[0]), msg->params[0],
-		(msg->params[1] ? ": " : ""), (msg->params[1] ?: "")
+		(msg->params[1] ? ": " : ""),
+		(msg->params[1] ? msg->params[1] : "")
 	);
 	logFormat(
 		id, tagTime(msg), "%s leaves %s%s%s",
 		msg->nick, msg->params[0],
-		(msg->params[1] ? ": " : ""), (msg->params[1] ?: "")
+		(msg->params[1] ? ": " : ""),
+		(msg->params[1] ? msg->params[1] : "")
 	);
 }
 
@@ -410,12 +412,14 @@ static void handleKick(struct Message *msg) {
 		hash(msg->user), msg->nick,
 		completeColor(id, msg->params[1]), msg->params[1],
 		hash(msg->params[0]), msg->params[0],
-		(msg->params[2] ? ": " : ""), (msg->params[2] ?: "")
+		(msg->params[2] ? ": " : ""),
+		(msg->params[2] ? msg->params[2] : "")
 	);
 	logFormat(
 		id, tagTime(msg), "%s kicks %s out of %s%s%s",
 		msg->nick, msg->params[1], msg->params[0],
-		(msg->params[2] ? ": " : ""), (msg->params[2] ?: "")
+		(msg->params[2] ? ": " : ""),
+		(msg->params[2] ? msg->params[2] : "")
 	);
 	completeRemove(id, msg->params[1]);
 	if (kicked) completeClear(id);
@@ -466,13 +470,15 @@ static void handleQuit(struct Message *msg) {
 			id, heat, tagTime(msg),
 			"\3%02d%s\3\tleaves%s%s",
 			hash(msg->user), msg->nick,
-			(msg->params[0] ? ": " : ""), (msg->params[0] ?: "")
+			(msg->params[0] ? ": " : ""),
+			(msg->params[0] ? msg->params[0] : "")
 		);
 		if (id == Network) continue;
 		logFormat(
 			id, tagTime(msg), "%s leaves%s%s",
 			msg->nick,
-			(msg->params[0] ? ": " : ""), (msg->params[0] ?: "")
+			(msg->params[0] ? ": " : ""),
+			(msg->params[0] ? msg->params[0] : "")
 		);
 	}
 	completeRemove(None, msg->nick);
@@ -734,7 +740,7 @@ static void handleReplyUserModeIs(struct Message *msg) {
 		if (*ch == '+') continue;
 		const char *name = UserModes[(byte)*ch];
 		ptr = seprintf(
-			ptr, end, ", +%c%s%s", *ch, (name ? " " : ""), (name ?: "")
+			ptr, end, ", +%c%s%s", *ch, (name ? " " : ""), (name ? name : "")
 		);
 	}
 	uiFormat(
@@ -774,13 +780,13 @@ static void handleReplyChannelModeIs(struct Message *msg) {
 			assert(param < ParamCap);
 			ptr = seprintf(
 				ptr, end, ", +%c%s%s %s",
-				*ch, (name ? " " : ""), (name ?: ""),
+				*ch, (name ? " " : ""), (name ? name : ""),
 				msg->params[param++]
 			);
 		} else {
 			ptr = seprintf(
 				ptr, end, ", +%c%s%s",
-				*ch, (name ? " " : ""), (name ?: "")
+				*ch, (name ? " " : ""), (name ? name : "")
 			);
 		}
 	}
@@ -807,7 +813,7 @@ static void handleMode(struct Message *msg) {
 				hash(msg->user), msg->nick,
 				(set ? "" : "un"),
 				self.color, msg->params[0],
-				set["-+"], *ch, (name ? " " : ""), (name ?: "")
+				set["-+"], *ch, (name ? " " : ""), (name ? name : "")
 			);
 		}
 		return;
@@ -964,7 +970,7 @@ static void handleErrorBanListFull(struct Message *msg) {
 	require(msg, false, 4);
 	uiFormat(
 		idFor(msg->params[1]), Warm, tagTime(msg),
-		"%s", (msg->params[4] ?: msg->params[3])
+		"%s", (msg->params[4] ? msg->params[4] : msg->params[3])
 	);
 }
 
@@ -1069,14 +1075,15 @@ static void handleReplyWhoisIdle(struct Message *msg) {
 		}
 	}
 	char signon[sizeof("0000-00-00 00:00:00")];
-	time_t time = strtol((msg->params[3] ?: ""), NULL, 10);
+	time_t time = (msg->params[3] ? strtol(msg->params[3], NULL, 10) : 0);
 	strftime(signon, sizeof(signon), "%F %T", localtime(&time));
 	uiFormat(
 		Network, Warm, tagTime(msg),
 		"\3%02d%s\3\tis idle for %lu %s%s%s%s",
 		completeColor(Network, msg->params[1]), msg->params[1],
 		idle, unit, (idle != 1 ? "s" : ""),
-		(msg->params[3] ? ", signed on " : ""), (msg->params[3] ? signon : "")
+		(msg->params[3] ? ", signed on " : ""),
+		(msg->params[3] ? signon : "")
 	);
 }
 
@@ -1111,7 +1118,9 @@ static void handleReplyWhoisGeneric(struct Message *msg) {
 		Network, Warm, tagTime(msg),
 		"\3%02d%s\3\t%s%s%s",
 		completeColor(Network, msg->params[1]), msg->params[1],
-		msg->params[2], (msg->params[3] ? " " : ""), (msg->params[3] ?: "")
+		msg->params[2],
+		(msg->params[3] ? " " : ""),
+		(msg->params[3] ? msg->params[3] : "")
 	);
 }
 
@@ -1186,7 +1195,7 @@ static bool isMention(const struct Message *msg) {
 	const char *match = msg->params[1];
 	while (NULL != (match = strstr(match, self.nick))) {
 		char a = (match > msg->params[1] ? match[-1] : ' ');
-		char b = (match[len] ?: ' ');
+		char b = (match[len] ? match[len] : ' ');
 		if ((isspace(a) || ispunct(a)) && (isspace(b) || ispunct(b))) {
 			return true;
 		}
diff --git a/input.c b/input.c
index f3813c4..820bf3c 100644
--- a/input.c
+++ b/input.c
@@ -417,7 +417,6 @@ static void keyCode(int code) {
 		break; case KeyMetaGt: windowScroll(ScrollAll, -1);
 		break; case KeyMetaLt: windowScroll(ScrollAll, +1);
 
-		break; case KeyMeta0 ... KeyMeta9: windowShow(code - KeyMeta0);
 		break; case KeyMetaA: windowAuto();
 		break; case KeyMetaB: error = editFn(edit, EditPrevWord);
 		break; case KeyMetaD: error = editFn(edit, EditDeleteNextWord);
@@ -448,6 +447,12 @@ static void keyCode(int code) {
 		break; case KEY_SEND: windowScroll(ScrollAll, -1);
 		break; case KEY_SHOME: windowScroll(ScrollAll, +1);
 		break; case KEY_UP: windowScroll(ScrollOne, +1);
+
+		break; default: {
+			if (code >= KeyMeta0 && code <= KeyMeta9) {
+				windowShow(code - KeyMeta0);
+			}
+		}
 	}
 	if (error) err(EX_OSERR, "editFn");
 }
diff --git a/url.c b/url.c
index 219a83c..9c721e0 100644
--- a/url.c
+++ b/url.c
@@ -249,7 +249,7 @@ int urlSave(FILE *file) {
 		if (!url->url) continue;
 		int error = 0
 			|| writeString(file, idNames[url->id])
-			|| writeString(file, (url->nick ?: ""))
+			|| writeString(file, (url->nick ? url->nick : ""))
 			|| writeString(file, url->url);
 		if (error) return error;
 	}
diff --git a/window.c b/window.c
index ee0911f..d7bc472 100644
--- a/window.c
+++ b/window.c
@@ -220,7 +220,7 @@ static size_t windowTop(const struct Window *window) {
 }
 
 static size_t windowBottom(const struct Window *window) {
-	size_t bottom = BufferCap - (window->scroll ?: 1);
+	size_t bottom = BufferCap - (window->scroll ? window->scroll : 1);
 	if (window->scroll) bottom -= SplitLines + MarkerLines;
 	return bottom;
 }
-- 
2.34.1