nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 1861052234fd542e845d679387359bf7ba4c458d
parent 2307b31887bd85173e0a31948276ddb3af567249
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Mon, 30 Sep 2019 19:30:54 +0200

tweaks: avoid a comparison between signed and unsigned  [coverity]

Diffstat:
Msrc/global.c | 2+-
Msrc/nano.c | 9+++++----
Msrc/proto.h | 3++-
3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/global.c b/src/global.c @@ -89,7 +89,7 @@ int shiftaltleft, shiftaltright, shiftaltup, shiftaltdown; #ifdef ENABLED_WRAPORJUSTIFY ssize_t fill = -COLUMNS_FROM_EOL; /* The relative column where we will wrap lines. */ -ssize_t wrap_at = 0; +size_t wrap_at = 0; /* The actual column where we will wrap lines, based on fill. */ #endif diff --git a/src/nano.c b/src/nano.c @@ -649,11 +649,12 @@ void window_init(void) #ifdef ENABLED_WRAPORJUSTIFY /* Set up the wrapping point, accounting for screen width when negative. */ - wrap_at = fill; - if (wrap_at <= 0) - wrap_at += COLS; - if (wrap_at < 0) + if (COLS + fill < 0) wrap_at = 0; + else if (fill <= 0) + wrap_at = COLS + fill; + else + wrap_at = fill; #endif } diff --git a/src/proto.h b/src/proto.h @@ -77,7 +77,8 @@ extern int shiftaltup, shiftaltdown; #endif #ifdef ENABLED_WRAPORJUSTIFY -extern ssize_t fill, wrap_at; +extern ssize_t fill; +extern size_t wrap_at; #endif extern char *last_search;