Skip to content

Commit

Permalink
FIXED: Issue#474 (Windows) several issues due to sizeof(wint_t) == 2
Browse files Browse the repository at this point in the history
  • Loading branch information
JanWielemaker authored and keriharris committed Jun 18, 2019
1 parent adcfd20 commit 2e5ab87
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/os/pl-ctype.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ char_type_by_name(atom_t name, int arity)
static int
advanceGen(generator *gen)
{ if ( gen->do_enum & ENUM_CHAR )
{ if ( ++gen->current > 0x10ffff )
{ if ( ++gen->current > PLMAXWCHAR )
fail;
} else
{ gen->class++;
Expand Down
2 changes: 1 addition & 1 deletion src/pl-arith.c
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,7 @@ arithChar(Word p ARG_LD)
if ( isInteger(*p) )
{ intptr_t chr = valInt(*p);

if ( chr >= 0 && chr <= 0x10ffff ) /* UNICODE_MAX */
if ( chr >= 0 && chr <= PLMAXWCHAR )
return (int)chr;
} else if ( isAtom(*p) )
{ PL_chars_t txt;
Expand Down
10 changes: 2 additions & 8 deletions src/pl-prims.c
Original file line number Diff line number Diff line change
Expand Up @@ -3719,12 +3719,6 @@ PRED_IMPL("number_string", 2, number_string, 0)
}


#if SIZEOF_WCHAR_T == 2
#define CHARCODE_MAX 0xffff
#else
#define CHARCODE_MAX 0x10ffff
#endif

static
PRED_IMPL("char_code", 2, char_code, PL_FA_ISO)
{ PRED_LD
Expand Down Expand Up @@ -3755,7 +3749,7 @@ PRED_IMPL("char_code", 2, char_code, PL_FA_ISO)
{ if ( !PL_get_integer_ex(chr, &n) )
fail;

if ( n >= 0 && n <= CHARCODE_MAX )
if ( n >= 0 && n <= PLMAXWCHAR )
cchr = n;
else if ( n < 0 || n > 0x10ffff )
return PL_type_error("character_code", chr);
Expand All @@ -3782,7 +3776,7 @@ is_code(word w)
{ if ( isTaggedInt(w) )
{ intptr_t code = valInt(w);

return code >= 0 && code <= CHARCODE_MAX;
return code >= 0 && code <= PLMAXWCHAR;
}

return FALSE;
Expand Down
2 changes: 1 addition & 1 deletion src/pl-read.c
Original file line number Diff line number Diff line change
Expand Up @@ -5250,7 +5250,7 @@ PRED_IMPL("$code_class", 2, code_class, 0)
!PL_get_atom_ex(A2, &class) )
return FALSE;

if ( code > 0x10ffff )
if ( code > PLMAXWCHAR )
PL_error(NULL, 0, NULL, ERR_TYPE, ATOM_character, A1);

c = PL_atom_chars(class);
Expand Down

0 comments on commit 2e5ab87

Please sign in to comment.