Initializing a variable to avoid a compiler warning, renaming it,
adding and tweaking some comments, and removing an unneeded 'if'. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4771 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Этот коммит содержится в:
родитель
1e3f6bc00b
Коммит
cd634e074c
@ -5,6 +5,9 @@
|
|||||||
and subsequently from parse_browser_input() and parse_help_input().
|
and subsequently from parse_browser_input() and parse_help_input().
|
||||||
* src/*: Whitespace adjustments, plus a few comment tweaks.
|
* src/*: Whitespace adjustments, plus a few comment tweaks.
|
||||||
* src/winio.c (getfuncfromkey): Elide variable and condense comment.
|
* src/winio.c (getfuncfromkey): Elide variable and condense comment.
|
||||||
|
* src/text.c (break_line): Initialize a variable to avoid a compiler
|
||||||
|
warning, rename it to be more apt, add a comment, tweak some others,
|
||||||
|
and remove an unneeded 'if'.
|
||||||
|
|
||||||
2014-04-13 Benno Schulenberg <bensberg@justemail.net>
|
2014-04-13 Benno Schulenberg <bensberg@justemail.net>
|
||||||
* proto.h, global.c, rcfile.c: Remove the unused parameter 'menu'
|
* proto.h, global.c, rcfile.c: Remove the unused parameter 'menu'
|
||||||
|
39
src/text.c
39
src/text.c
@ -1350,7 +1350,7 @@ bool do_wrap(filestruct *line, bool undoing)
|
|||||||
* that the display length to there is at most (goal + 1). If there is
|
* that the display length to there is at most (goal + 1). If there is
|
||||||
* 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 newln is TRUE. */
|
||||||
ssize_t break_line(const char *line, ssize_t goal
|
ssize_t break_line(const char *line, ssize_t goal
|
||||||
#ifndef DISABLE_HELP
|
#ifndef DISABLE_HELP
|
||||||
, bool newln
|
, bool newln
|
||||||
@ -1364,12 +1364,13 @@ ssize_t break_line(const char *line, ssize_t goal
|
|||||||
/* Current index in line. */
|
/* Current index in line. */
|
||||||
size_t cur_pos = 0;
|
size_t cur_pos = 0;
|
||||||
/* Current column position in line. */
|
/* Current column position in line. */
|
||||||
int line_len;
|
int char_len = 0;
|
||||||
|
/* Length of current character, in bytes. */
|
||||||
|
|
||||||
assert(line != NULL);
|
assert(line != NULL);
|
||||||
|
|
||||||
while (*line != '\0' && goal >= cur_pos) {
|
while (*line != '\0' && goal >= cur_pos) {
|
||||||
line_len = parse_mbchar(line, NULL, &cur_pos);
|
char_len = parse_mbchar(line, NULL, &cur_pos);
|
||||||
|
|
||||||
if (is_blank_mbchar(line)
|
if (is_blank_mbchar(line)
|
||||||
#ifndef DISABLE_HELP
|
#ifndef DISABLE_HELP
|
||||||
@ -1384,8 +1385,8 @@ ssize_t break_line(const char *line, ssize_t goal
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
line += line_len;
|
line += char_len;
|
||||||
cur_loc += line_len;
|
cur_loc += char_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (goal >= cur_pos)
|
if (goal >= cur_pos)
|
||||||
@ -1394,34 +1395,34 @@ ssize_t break_line(const char *line, ssize_t goal
|
|||||||
|
|
||||||
#ifndef DISABLE_HELP
|
#ifndef DISABLE_HELP
|
||||||
if (newln && blank_loc <= 0) {
|
if (newln && blank_loc <= 0) {
|
||||||
/* If blank was not found or was found only first character,
|
/* If no blank was found, or was found only as the first
|
||||||
* force line break. */
|
* character, force a line break. */
|
||||||
cur_loc -= line_len;
|
cur_loc -= char_len;
|
||||||
return cur_loc;
|
return cur_loc;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (blank_loc == -1) {
|
if (blank_loc == -1) {
|
||||||
/* No blank was found that was short enough. */
|
/* No blank was found within the goal width,
|
||||||
|
* so now try and find a blank beyond it. */
|
||||||
bool found_blank = FALSE;
|
bool found_blank = FALSE;
|
||||||
ssize_t found_blank_loc = 0;
|
ssize_t found_blank_loc = 0;
|
||||||
|
|
||||||
while (*line != '\0') {
|
while (*line != '\0') {
|
||||||
line_len = parse_mbchar(line, NULL, NULL);
|
char_len = parse_mbchar(line, NULL, NULL);
|
||||||
|
|
||||||
if (is_blank_mbchar(line)
|
if (is_blank_mbchar(line)
|
||||||
#ifndef DISABLE_HELP
|
#ifndef DISABLE_HELP
|
||||||
|| (newln && *line == '\n')
|
|| (newln && *line == '\n')
|
||||||
#endif
|
#endif
|
||||||
) {
|
) {
|
||||||
if (!found_blank)
|
found_blank = TRUE;
|
||||||
found_blank = TRUE;
|
|
||||||
found_blank_loc = cur_loc;
|
found_blank_loc = cur_loc;
|
||||||
} else if (found_blank)
|
} else if (found_blank)
|
||||||
return found_blank_loc;
|
return found_blank_loc;
|
||||||
|
|
||||||
line += line_len;
|
line += char_len;
|
||||||
cur_loc += line_len;
|
cur_loc += char_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
@ -1430,8 +1431,8 @@ ssize_t break_line(const char *line, ssize_t goal
|
|||||||
/* Move to the last blank after blank_loc, if there is one. */
|
/* Move to the last blank after blank_loc, if there is one. */
|
||||||
line -= cur_loc;
|
line -= cur_loc;
|
||||||
line += blank_loc;
|
line += blank_loc;
|
||||||
line_len = parse_mbchar(line, NULL, NULL);
|
char_len = parse_mbchar(line, NULL, NULL);
|
||||||
line += line_len;
|
line += char_len;
|
||||||
|
|
||||||
while (*line != '\0' && (is_blank_mbchar(line)
|
while (*line != '\0' && (is_blank_mbchar(line)
|
||||||
#ifndef DISABLE_HELP
|
#ifndef DISABLE_HELP
|
||||||
@ -1443,10 +1444,10 @@ ssize_t break_line(const char *line, ssize_t goal
|
|||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
line_len = parse_mbchar(line, NULL, NULL);
|
char_len = parse_mbchar(line, NULL, NULL);
|
||||||
|
|
||||||
line += line_len;
|
line += char_len;
|
||||||
blank_loc += line_len;
|
blank_loc += char_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
return blank_loc;
|
return blank_loc;
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user