]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
gui.c: Constify local variables of add_spaces().
authorAndre Noll <maan@tuebingen.mpg.de>
Mon, 29 Feb 2016 21:10:09 +0000 (22:10 +0100)
committerAndre Noll <maan@tuebingen.mpg.de>
Sun, 13 Mar 2016 17:11:32 +0000 (18:11 +0100)
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

diff --git a/gui.c b/gui.c
index 1421489013dfd56ef6f60bc427ee2e5ad0ae64da..6f688e0be6832c39dbcb5d620b2b6dfac96510c1 100644 (file)
--- 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);
        }
 }