Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
cs24-19fa
git_rec_nano
Commits
8993c363
Commit
8993c363
authored
7 years ago
by
Benno Schulenberg
Browse files
Options
Download
Email Patches
Plain Diff
tweaks: reduce the number of additions that actual_x() performs
Replace them by a single subtraction.
parent
5c51d4ea
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/utils.c
+4
-5
src/utils.c
with
4 additions
and
5 deletions
+4
-5
src/utils.c
View file @
8993c363
...
...
@@ -392,10 +392,10 @@ size_t xplustabs(void)
* not overshoot the given column. */
size_t
actual_x
(
const
char
*
text
,
size_t
column
)
{
size_t
index
=
0
;
/*
The index
in t
ext, returned
. */
const
char
*
start
=
text
;
/*
From where we start walk
in
g
t
hrough the text
. */
size_t
width
=
0
;
/* The
screen display width to text[index]
, in columns. */
/* The
current accumulated span
, in columns. */
while
(
*
text
!=
'\0'
)
{
int
charlen
=
parse_mbchar
(
text
,
NULL
,
&
width
);
...
...
@@ -403,11 +403,10 @@ size_t actual_x(const char *text, size_t column)
if
(
width
>
column
)
break
;
index
+=
charlen
;
text
+=
charlen
;
}
return
index
;
return
(
text
-
start
)
;
}
/* A strnlen() with tabs and multicolumn characters factored in:
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment