From 2e4f58d5654a9445cf1e452d8540fc0d62e7d562 Mon Sep 17 00:00:00 2001 From: Ben Kibbey Date: Fri, 1 Jan 2010 14:51:46 -0800 Subject: [PATCH] $scroll fix for a text length <= length This fixes $scroll to only scroll when the text length is greater than the specified length; hopefully without breaking anything. Signed-off-by: Brenden Matthews --- src/scroll.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/scroll.c b/src/scroll.c index fdef84f..e46dd0f 100644 --- a/src/scroll.c +++ b/src/scroll.c @@ -60,10 +60,16 @@ void parse_scroll_arg(struct text_object *obj, const char *arg, void *free_at_cr sd->step = 1; } sd->text = malloc(strlen(arg + n1) + sd->show + 1); - for(n2 = 0; (unsigned int) n2 < sd->show; n2++) { - sd->text[n2] = ' '; + + if (strlen(arg) > sd->show) { + for(n2 = 0; (unsigned int) n2 < sd->show; n2++) { + sd->text[n2] = ' '; + } + sd->text[n2] = 0; } - sd->text[n2] = 0; + else + sd->text[0] = 0; + strcat(sd->text, arg + n1); sd->start = 0; obj->sub = malloc(sizeof(struct text_object)); @@ -136,7 +142,7 @@ void print_scroll(struct text_object *obj, char *p, int p_max_size, struct infor free(pwithcolors); //scroll sd->start += sd->step; - if(buf[sd->start] == 0){ + if(buf[sd->start] == 0 || sd->start > strlen(buf)){ sd->start = 0; } #ifdef X11 -- 1.7.9.5