mirror of
https://github.com/oasislinux/oasis.git
synced 2026-06-21 15:37:15 +02:00
400 lines
13 KiB
Diff
400 lines
13 KiB
Diff
From 3da6204de2eb2d8c74ff3ee634baefe9e7660134 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 | 47 ++++++++++++++++++++++++++++-------------------
|
|
input.c | 7 ++++++-
|
|
url.c | 2 +-
|
|
window.c | 2 +-
|
|
8 files changed, 58 insertions(+), 41 deletions(-)
|
|
|
|
diff --git a/Makefile b/Makefile
|
|
index 66fb408..aacf43d 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 502ff17..d822187 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) {
|
|
@@ -304,7 +304,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) {
|
|
@@ -316,7 +316,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) {
|
|
@@ -391,12 +391,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) {
|
|
@@ -472,7 +472,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) {
|
|
@@ -480,8 +481,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 : "")
|
|
);
|
|
}
|
|
}
|
|
@@ -494,8 +496,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 : "")
|
|
);
|
|
}
|
|
|
|
@@ -524,7 +526,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);
|
|
@@ -549,7 +553,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 3552c7c..7d24c7c 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 effb623..3c503d1 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 5a2cf7c..b973161 100644
|
|
--- a/handle.c
|
|
+++ b/handle.c
|
|
@@ -332,9 +332,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');
|
|
}
|
|
}
|
|
}
|
|
@@ -387,7 +387,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]
|
|
);
|
|
@@ -419,12 +419,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] : "")
|
|
);
|
|
}
|
|
|
|
@@ -441,12 +443,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) completeRemove(id, NULL);
|
|
@@ -500,13 +504,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);
|
|
@@ -760,7 +766,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(
|
|
@@ -800,13 +806,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 : "")
|
|
);
|
|
}
|
|
}
|
|
@@ -833,7 +839,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;
|
|
@@ -996,7 +1002,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])
|
|
);
|
|
}
|
|
|
|
@@ -1061,7 +1067,7 @@ static void handleReplyList(struct Message *msg) {
|
|
"In \3%02d%s\3 are %ld under the banner: %s",
|
|
hash(msg->params[1]), msg->params[1],
|
|
strtol(msg->params[2], NULL, 10),
|
|
- (msg->params[3] ?: "")
|
|
+ (msg->params[3] ? msg->params[3] : "")
|
|
);
|
|
}
|
|
|
|
@@ -1101,14 +1107,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 : "")
|
|
);
|
|
}
|
|
|
|
@@ -1143,7 +1150,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] : "")
|
|
);
|
|
}
|
|
|
|
@@ -1213,7 +1222,7 @@ static bool matchWord(const char *str, const char *word) {
|
|
const char *match = str;
|
|
while (NULL != (match = strstr(match, word))) {
|
|
char a = (match > str ? 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 6b33b93..9334315 100644
|
|
--- a/input.c
|
|
+++ b/input.c
|
|
@@ -418,7 +418,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);
|
|
@@ -449,6 +448,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 7da0968..c1cb917 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 f700fd7..aadf646 100644
|
|
--- a/window.c
|
|
+++ b/window.c
|
|
@@ -221,7 +221,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.49.0
|
|
|