From 9a2b138a03e27d0f04101fe6ae3977d79518c513 Mon Sep 17 00:00:00 2001 From: Albert Cervin Date: Mon, 23 Jan 2023 23:56:38 +0100 Subject: Add more tests and documentation Both doxygen and man page --- src/command.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/command.c') diff --git a/src/command.c b/src/command.c index 93ede01..f8add1b 100644 --- a/src/command.c +++ b/src/command.c @@ -28,14 +28,14 @@ uint32_t hash_command_name(const char *name) { return hash; } -uint32_t register_command(struct commands *commands, struct command *command) { +uint32_t register_command(struct commands *commands, struct command command) { if (commands->ncommands == commands->capacity) { commands->capacity *= 2; commands->commands = realloc( commands->commands, sizeof(struct hashed_command) * commands->capacity); } - uint32_t hash = hash_command_name(command->name); + uint32_t hash = hash_command_name(command.name); commands->commands[commands->ncommands] = (struct hashed_command){.command = command, .hash = hash}; @@ -46,7 +46,7 @@ uint32_t register_command(struct commands *commands, struct command *command) { void register_commands(struct commands *command_list, struct command *commands, uint32_t ncommands) { for (uint32_t ci = 0; ci < ncommands; ++ci) { - register_command(command_list, &commands[ci]); + register_command(command_list, commands[ci]); } } @@ -60,7 +60,7 @@ struct command *lookup_command_by_hash(struct commands *commands, uint32_t hash) { for (uint32_t ci = 0; ci < commands->ncommands; ++ci) { if (commands->commands[ci].hash == hash) { - return commands->commands[ci].command; + return &commands->commands[ci].command; } } @@ -88,7 +88,7 @@ int32_t find_file(struct command_ctx ctx, int argc, const char *argv[]) { pth = argv[0]; ctx.active_window->buffer = buffers_add(ctx.buffers, buffer_from_file((char *)pth)); - minibuffer_echo_timeout(4, "buffer %s loaded", + minibuffer_echo_timeout(4, "buffer \"%s\" loaded", ctx.active_window->buffer->name); } else { minibuffer_prompt(ctx, "find file: "); -- cgit v1.2.3