[R] Rewrote mk_wcwidth function

This commit is contained in:
seleznevae 2019-12-01 15:14:28 +03:00
parent 1e2d9611cf
commit 9266befd39
3 changed files with 23 additions and 6 deletions

View File

@ -8,6 +8,7 @@
- Fix compilation for compilers other than gcc, clang, msvc.
- Add build with tcc to CI.
- Rewrote `mk_wcwidth` function.
## v0.3.1

View File

@ -7180,8 +7180,8 @@ void vector_clear(f_vector_t *vector)
struct interval {
wchar_t first;
wchar_t last;
int32_t first;
int32_t last;
};
/* auxiliary function for binary search in interval table */
@ -7237,7 +7237,7 @@ static int bisearch(wchar_t ucs, const struct interval *table, int max)
* in ISO 10646.
*/
static int mk_wcwidth(wchar_t ucs)
static int mk_wcwidth(wchar_t wcs)
{
/* sorted list of non-overlapping intervals of non-spacing characters */
/* generated by "uniset +cat=Me +cat=Mn +cat=Cf -00AD +1160-11FF +200B c" */
@ -7292,6 +7292,14 @@ static int mk_wcwidth(wchar_t ucs)
{ 0xE0100, 0xE01EF }
};
/* We convert wchar_t to int32_t to avoid compiler warnings
* about implicit integer conversions
* https://github.com/seleznevae/libfort/issues/20
*
* note: didn't test if we can do it
*/
int32_t ucs = (int32_t)wcs;
/* test for 8-bit control characters */
if (ucs == 0)
return 0;

View File

@ -65,8 +65,8 @@
struct interval {
wchar_t first;
wchar_t last;
int32_t first;
int32_t last;
};
/* auxiliary function for binary search in interval table */
@ -122,7 +122,7 @@ static int bisearch(wchar_t ucs, const struct interval *table, int max)
* in ISO 10646.
*/
static int mk_wcwidth(wchar_t ucs)
static int mk_wcwidth(wchar_t wcs)
{
/* sorted list of non-overlapping intervals of non-spacing characters */
/* generated by "uniset +cat=Me +cat=Mn +cat=Cf -00AD +1160-11FF +200B c" */
@ -177,6 +177,14 @@ static int mk_wcwidth(wchar_t ucs)
{ 0xE0100, 0xE01EF }
};
/* We convert wchar_t to int32_t to avoid compiler warnings
* about implicit integer conversions
* https://github.com/seleznevae/libfort/issues/20
*
* note: didn't test if we can do it
*/
int32_t ucs = (int32_t)wcs;
/* test for 8-bit control characters */
if (ucs == 0)
return 0;