gawk

[old] Sed-like interface to the Gopher protocol
Log | Files | Refs | LICENSE

commit 0391badc787ad74ae3b4295f13b9a3a3faa6d357
parent 8ecbb70ebe5c8d7bda3f54227f55b1b48afaefb0
Author: Jacob R. Edwards <jacobouno@protonmail.com>
Date:   Tue,  5 Jan 2021 22:03:16 -0800

Handle commands which have too many arguments

Diffstat:
Mmain.c | 10++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/main.c b/main.c @@ -262,7 +262,7 @@ gphsplit(char const **item, int size, char *buf) } command * -get_command(char const *s, const struct command *commands, int size) +get_command(char const *s, struct command const *commands, int size) { int i; @@ -341,13 +341,15 @@ execute(char const *cache, char *input, int depth, char const **addr) cbufslen = argsplit(cbufs, LEN(cbufs), input, separators[1], 0); for (i = 0; i < cbufslen; ++i) { - if (i >= MY_PIPE_MAX) { + if (i >= LEN(avs)) { warn(0, "Pipeline too long."); return ERROR; } acs[i] = argsplit(avs[i], LEN(avs[i]), cbufs[i], separators[2], 1); - if (acs[i] == 0) { - warn(0, "Empty pipe (#%d).", ++i); + if (acs[i] < 1) { + if (acs[i] == 0) + warn(0, "Empty pipe (#%d)", ++i); + else warn(E2BIG, "'%s'", avs[i][0]); return ERROR; } }