From a1a5ceb78518372bf6ec3db00717c7b28a7613e5 Mon Sep 17 00:00:00 2001 From: Lawrence Pan Date: Wed, 26 Sep 2018 08:39:00 -0700 Subject: [PATCH] rename command_stack to command_log --- src/commands.c | 10 +++++----- src/commands.h | 14 +++++++------- src/controller.c | 6 +++--- src/state.c | 8 ++++---- src/state.h | 4 ++-- tests/commands-test.c | 8 ++++---- 6 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/commands.c b/src/commands.c index b7922cd..6b82aa0 100644 --- a/src/commands.c +++ b/src/commands.c @@ -4,15 +4,15 @@ #include "commands.h" #include "controller.h" -command_stack_t *init_command_stack(void) { - command_stack_t *cs = malloc(sizeof(command_stack_t)); +command_log_t *init_command_log(void) { + command_log_t *cs = malloc(sizeof(command_log_t)); cs->top = NULL; cs->bottom = NULL; return cs; } -void destroy_command_stack(command_stack_t *cs) { +void destroy_command_log(command_log_t *cs) { command_t *c = cs->bottom, *tmp; while (c) { @@ -40,7 +40,7 @@ bool is_nav_command(command_t *c) { // ------------------------- // -- History Stack methods // ------------------------- -command_t *append_command(command_stack_t *cs, command_t *c) { +command_t *append_command(command_log_t *cs, command_t *c) { // assert valid state assert((!cs->top && !cs->bottom) || (cs->top && cs->bottom)); @@ -61,7 +61,7 @@ command_t *append_command(command_stack_t *cs, command_t *c) { return c; } -command_t *pop_command(command_stack_t *cs) { +command_t *pop_command(command_log_t *cs) { assert((!cs->top && !cs->bottom) || (cs->top && cs->bottom)); if (!cs->top && !cs->bottom) { diff --git a/src/commands.h b/src/commands.h index 8edce62..1e28461 100644 --- a/src/commands.h +++ b/src/commands.h @@ -28,21 +28,21 @@ typedef struct command { struct command *prev; } command_t; -typedef struct command_stack { +typedef struct command_log { struct command *bottom; struct command *top; -} command_stack_t; +} command_log_t; -command_stack_t *init_command_stack(void); +command_log_t *init_command_log(void); -void destroy_command_stack(command_stack_t *cs); +void destroy_command_log(command_log_t *); command_t *init_command(COMMAND_TYPE t, COMMAND_PAYLOAD p); -bool is_nav_command(command_t *c); +bool is_nav_command(command_t *); -command_t *append_command(command_stack_t *cs, command_t *c); +command_t *append_command(command_log_t *cs, command_t *c); -command_t *pop_command(command_stack_t *cs); +command_t *pop_command(command_log_t *cs); #endif diff --git a/src/controller.c b/src/controller.c index ee3485f..96d2886 100644 --- a/src/controller.c +++ b/src/controller.c @@ -185,7 +185,7 @@ static void dispatch_command(state_t *st, command_t *c) { } void replay_history(state_t *st) { - command_stack_t *hs = st->hs; + command_log_t *hs = st->hs; command_t *c = hs->bottom; // TODO copy init buffer but not reconstruct it @@ -210,8 +210,8 @@ void apply_command(state_t *st, COMMAND_TYPE t, COMMAND_PAYLOAD p) { dispatch_command(st, c); // FIXME kill this when implemented redo - destroy_command_stack(st->rs); - st->rs = init_command_stack(); + destroy_command_log(st->rs); + st->rs = init_command_log(); } /* diff --git a/src/state.c b/src/state.c index 0d261da..4b27055 100644 --- a/src/state.c +++ b/src/state.c @@ -15,9 +15,9 @@ state_t *init_state(const char *filename) { st->scr = init_screen(LINES); // history stack - st->hs = init_command_stack(); + st->hs = init_command_log(); // redo stack - st->rs = init_command_stack(); + st->rs = init_command_log(); st->status_row = init_row(NULL); st->prev_key = '\0'; @@ -31,8 +31,8 @@ void destroy_state(state_t *st) { destroy_buffer(st->buf); destroy_screen(st->scr); destroy_row(st->status_row); - destroy_command_stack(st->hs); - destroy_command_stack(st->rs); + destroy_command_log(st->hs); + destroy_command_log(st->rs); free(st); } diff --git a/src/state.h b/src/state.h index bbff8ba..cd10d66 100644 --- a/src/state.h +++ b/src/state.h @@ -12,8 +12,8 @@ typedef struct state { buffer_t *buf; screen_t *scr; - command_stack_t *hs; - command_stack_t *rs; + command_log_t *hs; + command_log_t *rs; size_t cx, cy; size_t top_row; diff --git a/tests/commands-test.c b/tests/commands-test.c index db7b2ab..07d5573 100644 --- a/tests/commands-test.c +++ b/tests/commands-test.c @@ -4,8 +4,8 @@ #include "../src/commands.h" -static void test_command_stack(void) { - command_stack_t *cs = init_command_stack(); +static void test_command_log(void) { + command_log_t *cs = init_command_log(); COMMAND_PAYLOAD p; COMMAND_TYPE t1 = HANDLE_APPEND_ROW; @@ -76,11 +76,11 @@ static void test_command_stack(void) { assert(c1->next == NULL); free(tmp); - destroy_command_stack(cs); + destroy_command_log(cs); } int main(void) { - test_command_stack(); + test_command_log(); return 0; }