diff options
author | Jannis Hoffmann <jannis@fehcom.de> | 2024-07-03 15:52:39 +0200 |
---|---|---|
committer | Jannis Hoffmann <jannis@fehcom.de> | 2024-07-03 15:52:39 +0200 |
commit | a6a7d6ce079cabdaf2fa502b2e2cf15e5428ac6f (patch) | |
tree | b88cc7a8457658d67e0321718556ac807f6bccf3 /src/commands.c | |
parent | 00be7622c428f279872f84569f098ce16150f8a8 (diff) |
format files
Diffstat (limited to 'src/commands.c')
-rw-r--r-- | src/commands.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/commands.c b/src/commands.c index 8602f7c..8cb81de 100644 --- a/src/commands.c +++ b/src/commands.c @@ -1,38 +1,40 @@ #include "commands.h" + #include "buffer.h" -#include "stralloc.h" -#include "str.h" #include "case.h" +#include "str.h" +#include "stralloc.h" static stralloc cmd = {0}; -int commands(buffer *b,struct commands *c) +int commands(buffer *b, struct commands *c) { int i; char *arg; for (;;) { - if (!stralloc_copys(&cmd,"")) return -1; + if (!stralloc_copys(&cmd, "")) return -1; for (;;) { - if (!stralloc_readyplus(&cmd,1)) return -1; - i = buffer_get(b,cmd.s + cmd.len,1); + if (!stralloc_readyplus(&cmd, 1)) return -1; + i = buffer_get(b, cmd.s + cmd.len, 1); if (i != 1) return i; if (cmd.s[cmd.len] == '\n') break; ++cmd.len; } - if (cmd.len > 0) if (cmd.s[cmd.len - 1] == '\r') --cmd.len; + if (cmd.len > 0) + if (cmd.s[cmd.len - 1] == '\r') --cmd.len; cmd.s[cmd.len] = 0; - i = str_chr(cmd.s,' '); + i = str_chr(cmd.s, ' '); arg = cmd.s + i; while (*arg == ' ') ++arg; cmd.s[i] = 0; - for (i = 0; c[i].text; ++i) - if (case_equals(c[i].text,cmd.s)) break; + for (i = 0; c[i].text; ++i) + if (case_equals(c[i].text, cmd.s)) break; c[i].fun(arg); if (c[i].flush) c[i].flush(); |