commit 0a06e078319b64eca111f4d0b3b6500207a1faf1
parent 17276e506eb92884b003d625abe20cc30edbd91a
Author: Chris Allegretta <chrisa@asty.org>
Date: Tue, 23 Jan 2001 02:35:04 +0000
replace for loop for hline init with memset in init functions
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@501 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Diffstat:
2 files changed, 7 insertions(+), 14 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -21,6 +21,8 @@ General
- Added restoration of totsize after unjustify command.
usage()
- Add arg to -T help (Rocco).
+ global_init(), handle_sigwinch()
+ - Messy loops replaced with memset calls (Rocco).
nano 0.9.99pre1 - 01/17/2001
General
diff --git a/nano.c b/nano.c
@@ -167,8 +167,6 @@ void clear_filename(void)
/* Initialize global variables - no better way for now */
void global_init(void)
{
- int i;
-
current_x = 0;
current_y = 0;
@@ -190,11 +188,8 @@ void global_init(void)
die_too_small();
hblank = nmalloc(COLS + 1);
-
- /* Thanks BG for this bit... */
- for (i = 0; i <= COLS - 1; i++)
- hblank[i] = ' ';
- hblank[i] = 0;
+ memset(hblank, ' ', COLS);
+ hblank[COLS] = 0;
}
#ifndef DISABLE_HELP
@@ -1543,7 +1538,6 @@ void handle_sigwinch(int s)
char *tty = NULL;
int fd = 0;
int result = 0;
- int i = 0;
struct winsize win;
tty = ttyname(0);
@@ -1566,12 +1560,9 @@ void handle_sigwinch(int s)
if ((fill = COLS - CHARS_FROM_EOL) < MIN_FILL_LENGTH)
die_too_small();
- free(hblank);
- hblank = nmalloc(COLS + 1);
-
- for (i = 0; i <= COLS - 1; i++)
- hblank[i] = ' ';
- hblank[i] = 0;
+ hblank = nrealloc(hblank, COLS + 1);
+ memset(hblank, ' ', COLS);
+ hblank[COLS] = 0;
#ifdef HAVE_NCURSES_H
resizeterm(LINES, COLS);