Merge pull request #23 from seleznevae/wchar-mk_wcwidth
[R] Rewrote `mk_wcwidth` function
This commit is contained in:
commit
3ec64691ca
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
- Fix compilation for compilers other than gcc, clang, msvc.
|
- Fix compilation for compilers other than gcc, clang, msvc.
|
||||||
- Add build with tcc to CI.
|
- Add build with tcc to CI.
|
||||||
|
- Rewrote `mk_wcwidth` function.
|
||||||
|
|
||||||
## v0.3.1
|
## v0.3.1
|
||||||
|
|
||||||
|
16
lib/fort.c
16
lib/fort.c
@ -7180,12 +7180,12 @@ void vector_clear(f_vector_t *vector)
|
|||||||
|
|
||||||
|
|
||||||
struct interval {
|
struct interval {
|
||||||
wchar_t first;
|
int32_t first;
|
||||||
wchar_t last;
|
int32_t last;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* auxiliary function for binary search in interval table */
|
/* auxiliary function for binary search in interval table */
|
||||||
static int bisearch(wchar_t ucs, const struct interval *table, int max)
|
static int bisearch(int32_t ucs, const struct interval *table, int max)
|
||||||
{
|
{
|
||||||
int min = 0;
|
int min = 0;
|
||||||
|
|
||||||
@ -7237,7 +7237,7 @@ static int bisearch(wchar_t ucs, const struct interval *table, int max)
|
|||||||
* in ISO 10646.
|
* 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 */
|
/* sorted list of non-overlapping intervals of non-spacing characters */
|
||||||
/* generated by "uniset +cat=Me +cat=Mn +cat=Cf -00AD +1160-11FF +200B c" */
|
/* 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 }
|
{ 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 */
|
/* test for 8-bit control characters */
|
||||||
if (ucs == 0)
|
if (ucs == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -65,12 +65,12 @@
|
|||||||
|
|
||||||
|
|
||||||
struct interval {
|
struct interval {
|
||||||
wchar_t first;
|
int32_t first;
|
||||||
wchar_t last;
|
int32_t last;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* auxiliary function for binary search in interval table */
|
/* auxiliary function for binary search in interval table */
|
||||||
static int bisearch(wchar_t ucs, const struct interval *table, int max)
|
static int bisearch(int32_t ucs, const struct interval *table, int max)
|
||||||
{
|
{
|
||||||
int min = 0;
|
int min = 0;
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ static int bisearch(wchar_t ucs, const struct interval *table, int max)
|
|||||||
* in ISO 10646.
|
* 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 */
|
/* sorted list of non-overlapping intervals of non-spacing characters */
|
||||||
/* generated by "uniset +cat=Me +cat=Mn +cat=Cf -00AD +1160-11FF +200B c" */
|
/* 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 }
|
{ 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 */
|
/* test for 8-bit control characters */
|
||||||
if (ucs == 0)
|
if (ucs == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user