From ec7552f87eb959b007bd0ed3642e5ccc2faa4d39 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Mon, 29 Feb 2016 22:10:09 +0100 Subject: [PATCH] gui.c: Constify local variables of add_spaces(). There is no need to modify the all-spaces string as we can as well print its end in order to output the desired number of spaces. This allows to make the array variable const, along with "sz", which stores the length of the string. --- gui.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/gui.c b/gui.c index 14214890..6f688e0b 100644 --- a/gui.c +++ b/gui.c @@ -246,8 +246,8 @@ static char *km_keyname(int c) /* Print given number of spaces to curses window. */ static void add_spaces(WINDOW* win, unsigned int num) { - char space[] = " "; - unsigned sz = sizeof(space) - 1; /* number of spaces */ + const char space[] = " "; + const unsigned sz = sizeof(space) - 1; /* number of spaces */ while (num >= sz) { waddstr(win, space); @@ -255,8 +255,7 @@ static void add_spaces(WINDOW* win, unsigned int num) } if (num > 0) { assert(num < sz); - space[num] = '\0'; - waddstr(win, space); + waddstr(win, space + sz - num); } } -- 2.39.5