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
c5f49167
Commit
c5f49167
authored
8 years ago
by
Benno Schulenberg
Browse files
Options
Download
Email Patches
Plain Diff
tweaks: write two pieces of conditionalized code like all others
Also trim or improve a few comments.
parent
9765c2fa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/chars.c
+19
-20
src/chars.c
with
19 additions
and
20 deletions
+19
-20
src/chars.c
View file @
c5f49167
...
...
@@ -320,21 +320,21 @@ int mbwidth(const char *c)
return
1
;
}
/* Return the maximum
wid
th in bytes of a
multibyte
character. */
/* Return the maximum
leng
th
(
in bytes
)
of a character. */
int
mb_cur_max
(
void
)
{
return
#ifdef ENABLE_UTF8
use_utf8
?
MB_CUR_MAX
:
if
(
use_utf8
)
return
MB_CUR_MAX
;
else
#endif
1
;
return
1
;
}
/* Convert the Unicode value in chr to a multibyte character with the
* same wide character value as chr, if possible. If the conversion
* succeeds, return the (dynamically allocated) multibyte character and
* its length. Otherwise, return an undefined (dynamically allocated)
* multibyte character and a length of zero. */
/* Convert the Unicode value in chr to a multibyte character, if possible.
* If the conversion succeeds, return the (dynamically allocated) multibyte
* character and its length. Otherwise, return an undefined (dynamically
* allocated) multibyte character and a length of zero. */
char
*
make_mbchar
(
long
chr
,
int
*
chr_mb_len
)
{
char
*
chr_mb
;
...
...
@@ -363,8 +363,7 @@ char *make_mbchar(long chr, int *chr_mb_len)
/* Parse a multibyte character from buf. Return the number of bytes
* used. If chr isn't NULL, store the multibyte character in it. If
* col isn't NULL, store the new display width in it. If *buf is '\t',
* we expect col to have the current display width. */
* col isn't NULL, add the character's width (in columns) to it. */
int
parse_mbchar
(
const
char
*
buf
,
char
*
chr
,
size_t
*
col
)
{
int
length
;
...
...
@@ -390,9 +389,9 @@ int parse_mbchar(const char *buf, char *chr, size_t *col)
chr
[
i
]
=
buf
[
i
];
}
/* When requested,
store
the width of the
wide
character
in
col. */
/* When requested,
add
the width of the character
to
col. */
if
(
col
!=
NULL
)
{
/* If we have a tab,
get
its width in columns
using
the
/* If we have a tab,
compute
its width in columns
based on
the
* current value of col. */
if
(
*
buf
==
'\t'
)
*
col
+=
tabsize
-
*
col
%
tabsize
;
...
...
@@ -400,8 +399,7 @@ int parse_mbchar(const char *buf, char *chr, size_t *col)
* column for the "^", and one for the visible character. */
else
if
(
is_cntrl_mbchar
(
buf
))
{
*
col
+=
2
;
/* If we have a normal character, get its width in columns
* normally. */
/* If we have a normal character, get its width normally. */
}
else
*
col
+=
mbwidth
(
buf
);
}
...
...
@@ -415,9 +413,9 @@ int parse_mbchar(const char *buf, char *chr, size_t *col)
if
(
chr
!=
NULL
)
*
chr
=
*
buf
;
/* When requested,
store
the width of the
wide
character
in
col. */
/* When requested,
add
the width of the character
to
col. */
if
(
col
!=
NULL
)
{
/* If we have a tab,
get
its width in columns using the
/* If we have a tab,
compute
its width in columns using the
* current value of col. */
if
(
*
buf
==
'\t'
)
*
col
+=
tabsize
-
*
col
%
tabsize
;
...
...
@@ -908,10 +906,11 @@ bool is_valid_mbstring(const char *s)
{
assert
(
s
!=
NULL
);
return
#ifdef ENABLE_UTF8
use_utf8
?
(
mbstowcs
(
NULL
,
s
,
0
)
!=
(
size_t
)
-
1
)
:
if
(
use_utf8
)
return
(
mbstowcs
(
NULL
,
s
,
0
)
!=
(
size_t
)
-
1
);
else
#endif
TRUE
;
return
TRUE
;
}
#endif
/* !DISABLE_NANORC */
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