in break_line(), only include the newline parameter if DISABLE_HELP

isn't defined, as it's only used then


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3209 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
David Lawrence Ramsey 2005-11-22 21:13:36 +00:00
parent 708de360dc
commit b9b2fd52ff
3 changed files with 40 additions and 9 deletions

View File

@ -178,6 +178,9 @@ CVS code -
- Only include the whole_word parameter when DISABLE_SPELLER - Only include the whole_word parameter when DISABLE_SPELLER
isn't defined, as it's only used then. (DLR) isn't defined, as it's only used then. (DLR)
- text.c: - text.c:
break_line()
- Only include the newline parameter if DISABLE_HELP isn't
defined, as it's only used then. (DLR)
begpar() begpar()
- Return FALSE if foo is NULL, as inpar() does. (DLR) - Return FALSE if foo is NULL, as inpar() does. (DLR)
backup_lines() backup_lines()

View File

@ -563,7 +563,11 @@ void wrap_reset(void);
bool do_wrap(filestruct *line); bool do_wrap(filestruct *line);
#endif #endif
#if !defined(DISABLE_HELP) || !defined(DISABLE_JUSTIFY) || !defined(DISABLE_WRAPPING) #if !defined(DISABLE_HELP) || !defined(DISABLE_JUSTIFY) || !defined(DISABLE_WRAPPING)
ssize_t break_line(const char *line, ssize_t goal, bool newline); ssize_t break_line(const char *line, ssize_t goal
#ifndef DISABLE_HELP
, bool newline
#endif
);
#endif #endif
#if !defined(NANO_TINY) || !defined(DISABLE_JUSTIFY) #if !defined(NANO_TINY) || !defined(DISABLE_JUSTIFY)
size_t indent_length(const char *line); size_t indent_length(const char *line);

View File

@ -389,7 +389,11 @@ bool do_wrap(filestruct *line)
line_len = strlen(line->data); line_len = strlen(line->data);
/* Find the last blank where we can break the line. */ /* Find the last blank where we can break the line. */
wrap_loc = break_line(line->data, fill, FALSE); wrap_loc = break_line(line->data, fill
#ifndef DISABLE_HELP
, FALSE
#endif
);
/* If we couldn't break the line, or we've reached the end of it, we /* If we couldn't break the line, or we've reached the end of it, we
* don't wrap. */ * don't wrap. */
@ -565,7 +569,11 @@ bool do_wrap(filestruct *line)
* no such blank, then we find the first blank. We then take the last * no such blank, then we find the first blank. We then take the last
* blank in that group of blanks. The terminating '\0' counts as a * blank in that group of blanks. The terminating '\0' counts as a
* blank, as does a '\n' if newline is TRUE. */ * blank, as does a '\n' if newline is TRUE. */
ssize_t break_line(const char *line, ssize_t goal, bool newline) ssize_t break_line(const char *line, ssize_t goal
#ifndef DISABLE_HELP
, bool newline
#endif
)
{ {
ssize_t blank_loc = -1; ssize_t blank_loc = -1;
/* Current tentative return value. Index of the last blank we /* Current tentative return value. Index of the last blank we
@ -581,11 +589,17 @@ ssize_t break_line(const char *line, ssize_t goal, bool newline)
line_len = parse_mbchar(line, NULL, &pos); line_len = parse_mbchar(line, NULL, &pos);
if (is_blank_mbchar(line) || (newline && *line == '\n')) { if (is_blank_mbchar(line)
#ifndef DISABLE_HELP
|| (newline && *line == '\n')
#endif
) {
blank_loc = cur_loc; blank_loc = cur_loc;
#ifndef DISABLE_HELP
if (newline && *line == '\n') if (newline && *line == '\n')
break; break;
#endif
} }
goal -= pos; goal -= pos;
@ -605,7 +619,11 @@ ssize_t break_line(const char *line, ssize_t goal, bool newline)
while (*line != '\0') { while (*line != '\0') {
line_len = parse_mbchar(line, NULL, NULL); line_len = parse_mbchar(line, NULL, NULL);
if (is_blank_mbchar(line) || (newline && *line == '\n')) { if (is_blank_mbchar(line)
#ifndef DISABLE_HELP
|| (newline && *line == '\n')
#endif
) {
if (!found_blank) if (!found_blank)
found_blank = TRUE; found_blank = TRUE;
found_blank_loc = cur_loc; found_blank_loc = cur_loc;
@ -625,8 +643,11 @@ ssize_t break_line(const char *line, ssize_t goal, bool newline)
line_len = parse_mbchar(line, NULL, NULL); line_len = parse_mbchar(line, NULL, NULL);
line += line_len; line += line_len;
while (*line != '\0' && (is_blank_mbchar(line) || while (*line != '\0' && (is_blank_mbchar(line)
(newline && *line == '\n'))) { #ifndef DISABLE_HELP
|| (newline && *line == '\n')
#endif
)) {
line_len = parse_mbchar(line, NULL, NULL); line_len = parse_mbchar(line, NULL, NULL);
line += line_len; line += line_len;
@ -1322,8 +1343,11 @@ void do_justify(bool full_justify)
/* If this line is too long, try to wrap it to the next line /* If this line is too long, try to wrap it to the next line
* to make it short enough. */ * to make it short enough. */
break_pos = break_line(openfile->current->data + indent_len, break_pos = break_line(openfile->current->data + indent_len,
fill - strnlenpt(openfile->current->data, indent_len), fill - strnlenpt(openfile->current->data, indent_len)
FALSE); #ifndef DISABLE_HELP
, FALSE
#endif
);
/* We can't break the line, or don't need to, so get out. */ /* We can't break the line, or don't need to, so get out. */
if (break_pos == -1 || break_pos + indent_len == line_len) if (break_pos == -1 || break_pos + indent_len == line_len)