mirror of
git://git.sv.gnu.org/nano.git
synced 2024-11-22 21:01:24 +03:00
tweaks: simplify two fragments of code, eliding useless character copying
This commit is contained in:
parent
1c010d8ec9
commit
0dcac9188f
15
src/chars.c
15
src/chars.c
@ -648,20 +648,13 @@ char *mbrevstrpbrk(const char *head, const char *accept, const char *pointer)
|
|||||||
#endif /* !NANO_TINY */
|
#endif /* !NANO_TINY */
|
||||||
|
|
||||||
#if defined(ENABLE_NANORC) && (!defined(NANO_TINY) || defined(ENABLE_JUSTIFY))
|
#if defined(ENABLE_NANORC) && (!defined(NANO_TINY) || defined(ENABLE_JUSTIFY))
|
||||||
/* Return TRUE if the given string contains at least one blank character,
|
/* Return TRUE if the given string contains at least one blank character. */
|
||||||
* and FALSE otherwise. */
|
|
||||||
bool has_blank_char(const char *string)
|
bool has_blank_char(const char *string)
|
||||||
{
|
{
|
||||||
char symbol[MAXCHARLEN];
|
while (*string != '\0' && !is_blank_char(string))
|
||||||
|
string += char_length(string);
|
||||||
|
|
||||||
while (*string != '\0') {
|
return *string;
|
||||||
string += collect_char(string, symbol);
|
|
||||||
|
|
||||||
if (is_blank_char(symbol))
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
#endif /* ENABLE_NANORC && (!NANO_TINY || ENABLE_JUSTIFY) */
|
#endif /* ENABLE_NANORC && (!NANO_TINY || ENABLE_JUSTIFY) */
|
||||||
|
|
||||||
|
17
src/text.c
17
src/text.c
@ -1453,21 +1453,12 @@ ssize_t break_line(const char *textstart, ssize_t goal, bool snap_at_nl)
|
|||||||
* "indentation" of a line is the leading consecutive whitespace. */
|
* "indentation" of a line is the leading consecutive whitespace. */
|
||||||
size_t indent_length(const char *line)
|
size_t indent_length(const char *line)
|
||||||
{
|
{
|
||||||
size_t len = 0;
|
const char *start = line;
|
||||||
char onechar[MAXCHARLEN];
|
|
||||||
int charlen;
|
|
||||||
|
|
||||||
while (*line != '\0') {
|
while (*line != '\0' && is_blank_char(line))
|
||||||
charlen = collect_char(line, onechar);
|
line += char_length(line);
|
||||||
|
|
||||||
if (!is_blank_char(onechar))
|
return (line - start);
|
||||||
break;
|
|
||||||
|
|
||||||
line += charlen;
|
|
||||||
len += charlen;
|
|
||||||
}
|
|
||||||
|
|
||||||
return len;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user