Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
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
fbd817fb
Commit
fbd817fb
authored
8 years ago
by
Benno Schulenberg
Browse files
Options
Download
Email Patches
Plain Diff
utils: rename some variables, to match those in strnlenpt()
parent
e3e3f655
master
feature/match-parens
refactor/readbility
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/utils.c
+15
-17
src/utils.c
with
15 additions
and
17 deletions
+15
-17
src/utils.c
View file @
fbd817fb
...
...
@@ -461,29 +461,28 @@ size_t xplustabs(void)
return
strnlenpt
(
openfile
->
current
->
data
,
openfile
->
current_x
);
}
/* Return the index in s of the character displayed at the given column,
* i.e. the largest value such that strnlenpt(s, actual_x(s, column)) <=
* column. */
size_t
actual_x
(
const
char
*
s
,
size_t
column
)
/* Return the index in text of the character that (when displayed) will
* not overshoot the given column. */
size_t
actual_x
(
const
char
*
text
,
size_t
column
)
{
size_t
i
=
0
;
/* The
position in s
, returned. */
size_t
len
=
0
;
/* The screen display width to
s[i]
. */
size_t
i
ndex
=
0
;
/* The
index in text
, returned. */
size_t
width
=
0
;
/* The screen display width to
text[index], in columns
. */
assert
(
s
!=
NULL
);
assert
(
text
!=
NULL
);
while
(
*
s
!=
'\0'
)
{
int
s_
len
=
parse_mbchar
(
s
,
NULL
,
&
len
);
while
(
*
text
!=
'\0'
)
{
int
char
len
=
parse_mbchar
(
text
,
NULL
,
&
width
);
if
(
len
>
column
)
if
(
width
>
column
)
break
;
i
+=
s_
len
;
s
+=
s_
len
;
i
ndex
+=
char
len
;
text
+=
char
len
;
}
return
i
;
return
i
ndex
;
}
/* A strnlen() with tabs and multicolumn characters factored in:
...
...
@@ -501,12 +500,11 @@ size_t strnlenpt(const char *text, size_t maxlen)
while
(
*
text
!=
'\0'
)
{
int
charlen
=
parse_mbchar
(
text
,
NULL
,
&
width
);
text
+=
charlen
;
if
(
maxlen
<=
charlen
)
break
;
maxlen
-=
charlen
;
text
+=
charlen
;
}
return
width
;
...
...
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
Menu
Projects
Groups
Snippets
Help