From 977c46591583a59f8d51773ffaba08b5076a426e Mon Sep 17 00:00:00 2001 From: HampusM Date: Fri, 7 Jan 2022 12:56:37 +0100 Subject: style: fix minor code formatting issues --- .clang-format | 1 + src/grid.c | 3 +-- src/grid.h | 1 - src/maze.c | 9 ++++----- src/maze.h | 2 +- src/mazerator.c | 6 +++--- src/position.c | 1 - src/position.h | 1 - src/utils.c | 7 +++---- 9 files changed, 13 insertions(+), 18 deletions(-) diff --git a/.clang-format b/.clang-format index cf1698f..b380384 100644 --- a/.clang-format +++ b/.clang-format @@ -4,6 +4,7 @@ IndentWidth: 4 TabWidth: 4 BreakBeforeBraces: Allman AllowShortIfStatementsOnASingleLine: false +AllowShortFunctionsOnASingleLine: None IndentCaseLabels: false ColumnLimit: 90 AccessModifierOffset: -4 diff --git a/src/grid.c b/src/grid.c index 372ea7e..3554779 100644 --- a/src/grid.c +++ b/src/grid.c @@ -1,7 +1,7 @@ #include "grid.h" #include "utils.h" -#include #include +#include Grid grid_create(unsigned int width, unsigned int height, char *fill) { @@ -53,4 +53,3 @@ void grid_destroy(Grid grid) free(grid.grid); } - diff --git a/src/grid.h b/src/grid.h index 65fa01a..262035e 100644 --- a/src/grid.h +++ b/src/grid.h @@ -56,4 +56,3 @@ void grid_print(Grid grid); void grid_destroy(Grid grid); #endif - diff --git a/src/maze.c b/src/maze.c index bae1ba4..5a59c76 100644 --- a/src/maze.c +++ b/src/maze.c @@ -1,10 +1,10 @@ #include "maze.h" #include "grid.h" #include "position.h" +#include #include #include #include -#include int is_pos_empty(Grid grid, Position pos) { @@ -15,10 +15,10 @@ void add_neighbour(Position neighbours[], uint8_t *neighbour_cnt, Position neigh { neighbours[*neighbour_cnt] = neighbour_pos; (*neighbour_cnt)++; - } -void get_neighbours(Grid grid, Position pos, Position neighbours[], uint8_t *neighbour_cnt) +void get_neighbours(Grid grid, Position pos, Position neighbours[], + uint8_t *neighbour_cnt) { if (pos.y != 1) { @@ -96,7 +96,7 @@ void grid_to_maze(Grid grid, Position start_pos) Position next_pos = neighbours[rand() % neighbour_cnt]; Position between_pos = position_create(pos.x, pos.y); - + if (next_pos.y != pos.y) between_pos.y += next_pos.y > pos.y ? 1 : -1; @@ -110,4 +110,3 @@ void grid_to_maze(Grid grid, Position start_pos) pos_stack_destroy(path); } - diff --git a/src/maze.h b/src/maze.h index 1a3937f..a3c932c 100644 --- a/src/maze.h +++ b/src/maze.h @@ -1,8 +1,8 @@ #ifndef MAZE_H #define MAZE_H -#include "position_stack.h" #include "grid.h" +#include "position_stack.h" /** * Creates a maze from a grid diff --git a/src/mazerator.c b/src/mazerator.c index 593d518..c624dc3 100644 --- a/src/mazerator.c +++ b/src/mazerator.c @@ -1,5 +1,5 @@ -#include "maze.h" #include "grid.h" +#include "maze.h" #include "position.h" #include "utils.h" #include @@ -68,7 +68,7 @@ int main(int argc, char *argv[]) { case 'w': maze_width = str_to_uint(optarg, &err); - + if (err != NULL) optarg_error(arg, err); @@ -78,7 +78,7 @@ int main(int argc, char *argv[]) break; case 'h': maze_height = str_to_uint(optarg, &err); - + if (err != NULL) optarg_error(arg, err); diff --git a/src/position.c b/src/position.c index 937edd5..a7465ab 100644 --- a/src/position.c +++ b/src/position.c @@ -6,4 +6,3 @@ Position position_create(unsigned int x, unsigned int y) return pos; } - diff --git a/src/position.h b/src/position.h index d1bc9eb..05d21fa 100644 --- a/src/position.h +++ b/src/position.h @@ -10,4 +10,3 @@ typedef struct Position Position position_create(unsigned int x, unsigned int y); #endif - diff --git a/src/utils.c b/src/utils.c index 2657a00..5fc27d3 100644 --- a/src/utils.c +++ b/src/utils.c @@ -1,9 +1,9 @@ #include "utils.h" #include -#include -#include -#include #include +#include +#include +#include void *malloc_s(unsigned long amount) { @@ -43,4 +43,3 @@ unsigned int str_to_uint(char *str, char **err) return (unsigned int)num; } - -- cgit v1.2.3-18-g5258