0001-Revert-Use-gnu-case-range-and-gnu-conditional-omitte.patch (13080B)
- 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