diff --git a/ChangeLog b/ChangeLog index a0e0d205..1234eb3f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -71,6 +71,10 @@ CVS code - do_para_begin(), do_para_end() - Maintain current_y's value when moving up or down lines so that smooth scrolling works correctly. (DLR) + breakable(), break_line() + - Make goal a ssize_t instead of an int, since fill is now a + ssize_t, and the position at which a line is broken can be + greater than COLS. (DLR) - nano.h: - Add WIDTH_OF_TAB #define, containing the default width of a tab. (DLR) diff --git a/configure.ac b/configure.ac index 88620570..a91ec585 100644 --- a/configure.ac +++ b/configure.ac @@ -312,8 +312,6 @@ AC_FUNC_VPRINTF AC_CHECK_FUNCS(getopt_long) dnl Checks for libraries. - - if eval "test x$CURSES_LIB_NAME = x" then AC_CHECK_HEADERS(curses.h ncurses.h) @@ -349,7 +347,7 @@ fi AC_CHECK_LIB([$CURSES_LIB_NAME], use_default_colors, AC_DEFINE(HAVE_USE_DEFAULT_COLORS, 1, [Define this if your curses library has the use_default_colors command.])) -dnl Parse any configure options +dnl Parse any configure options. LIBS="$LIBS $CURSES_LIB" diff --git a/src/nano.c b/src/nano.c index a2943cea..6941da63 100644 --- a/src/nano.c +++ b/src/nano.c @@ -2137,7 +2137,7 @@ filestruct *backup_lines(filestruct *first_line, size_t par_len, size_t } /* Is it possible to break line at or before goal? */ -bool breakable(const char *line, int goal) +bool breakable(const char *line, ssize_t goal) { for (; *line != '\0' && goal >= 0; line++) { if (isblank(*line)) @@ -2158,14 +2158,12 @@ bool breakable(const char *line, int goal) * such space, and force is TRUE, then we find the first space. Anyway, * we then take the last space in that group of spaces. The terminating * '\0' counts as a space. */ -int break_line(const char *line, int goal, bool force) +int break_line(const char *line, ssize_t goal, bool force) { - /* Note that we use int instead of size_t, since goal is at most - * COLS, the screen width, which will always be reasonably small. */ - int space_loc = -1; + ssize_t space_loc = -1; /* Current tentative return value. Index of the last space we * found with short enough display width. */ - int cur_loc = 0; + ssize_t cur_loc = 0; /* Current index in line. */ assert(line != NULL); @@ -2391,7 +2389,7 @@ void do_justify(bool full_justify) size_t line_len; size_t display_len; /* The width of current in screen columns. */ - int break_pos; + ssize_t break_pos; /* Where we will break the line. */ /* We'll be moving to the next line after justifying the diff --git a/src/nano.h b/src/nano.h index 1470278c..b5f95040 100644 --- a/src/nano.h +++ b/src/nano.h @@ -34,22 +34,23 @@ #include #endif -/* Macros for the flags long... */ +/* Macros for the flags long. */ #define SET(bit) flags |= bit #define UNSET(bit) flags &= ~bit #define ISSET(bit) ((flags & bit) != 0) #define TOGGLE(bit) flags ^= bit -/* Define charalloc as a macro rather than duplicating code */ +/* Macros for character allocation. */ #define charalloc(howmuch) (char *)nmalloc((howmuch) * sizeof(char)) #define charealloc(ptr, howmuch) (char *)nrealloc(ptr, (howmuch) * sizeof(char)) #define charmove(dest, src, n) memmove(dest, src, (n) * sizeof(char)) + #ifdef BROKEN_REGEXEC #define regexec(preg, string, nmatch, pmatch, eflags) regexec_safe(preg, string, nmatch, pmatch, eflags) #endif #ifndef NANO_SMALL -/* For the backup file copy ... */ +/* For the backup file copy. */ #define COPYFILEBLOCKSIZE 1024 #endif diff --git a/src/proto.h b/src/proto.h index ab91b640..d41fa5f9 100644 --- a/src/proto.h +++ b/src/proto.h @@ -344,8 +344,8 @@ bool inpar(const char *str); void do_para_end(void); filestruct *backup_lines(filestruct *first_line, size_t par_len, size_t quote_len); -bool breakable(const char *line, int goal); -int break_line(const char *line, int goal, bool force); +bool breakable(const char *line, ssize_t goal); +ssize_t break_line(const char *line, ssize_t goal, bool force); bool do_para_search(size_t *const quote, size_t *const par); void do_justify(bool full_justify); void do_justify_void(void);