Skip to content

Commit 3262247

Browse files
committed
Prepended PDC_ to the IS*_SURROGATE Unicode surrogate test macros.
There have been occasional problems with the fact that Microsoft(R) has similar macros to ours. This change should avoid collisions in the future.
1 parent e23eb34 commit 3262247

4 files changed

Lines changed: 9 additions & 13 deletions

File tree

curspriv.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,9 @@ bool PDC_touched_range( const WINDOW *win, const int y, int *firstch, int *la
116116
int PDC_wscrl(WINDOW *win, const int top, const int bottom, int n);
117117

118118
#ifdef PDC_WIDE
119-
#ifndef IS_LOW_SURROGATE /* Microsoft(R) Windows redefines these */
120-
#define IS_LOW_SURROGATE( c) ((c) >= 0xdc00 && (c) < 0xe000)
121-
#define IS_SURROGATE( x) ((x) >= 0xd800 && (x) < 0xe000)
122-
#define IS_HIGH_SURROGATE( c) ((c) >= 0xd800 && (c) < 0xdc00)
123-
#endif
119+
#define PDC_IS_LOW_SURROGATE( c) ((c) >= 0xdc00 && (c) < 0xe000)
120+
#define PDC_IS_SURROGATE( x) ((x) >= 0xd800 && (x) < 0xe000)
121+
#define PDC_IS_HIGH_SURROGATE( c) ((c) >= 0xd800 && (c) < 0xdc00)
124122

125123
int PDC_mbtowc(wchar_t *, const char *, size_t);
126124
size_t PDC_mbstowcs(wchar_t *, const char *, size_t);

pdcurses/addch.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ int waddch( WINDOW *win, const chtype ch)
536536
if( x || y)
537537
{
538538
const bool is_combining = (text && !text_width);
539-
const bool is_low_surrogate = IS_LOW_SURROGATE( text);
539+
const bool is_low_surrogate = PDC_IS_LOW_SURROGATE( text);
540540

541541
if( is_combining || is_low_surrogate)
542542
{
@@ -553,7 +553,7 @@ int waddch( WINDOW *win, const chtype ch)
553553
if( is_combining)
554554
text = COMBINED_CHAR_START
555555
+ PDC_find_combined_char_idx( prev_char, text);
556-
else if( IS_HIGH_SURROGATE( prev_char))
556+
else if( PDC_IS_HIGH_SURROGATE( prev_char))
557557
text = 0x10000 + ((prev_char - 0xd800) << 10) + (text - 0xdc00);
558558
else /* low surrogate after a non-high surrogate; not */
559559
text = prev_char; /* supposed to happen */
@@ -586,8 +586,6 @@ int waddch( WINDOW *win, const chtype ch)
586586
if (!SP->raw_out)
587587
x = 0;
588588

589-
/* Had this commented out. I think it matters in */
590-
/* wide, non-UTF8 mode on some platforms. */
591589
wclrtoeol(win);
592590

593591
if (++y > win->_bmarg)

pdcurses/getch.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -662,11 +662,11 @@ static int _raw_wgetch( WINDOW *win)
662662
int rval = _raw_wgetch_no_surrogate_pairs( win);
663663

664664
#ifdef PDC_WIDE
665-
if( IS_HIGH_SURROGATE( rval))
665+
if( PDC_IS_HIGH_SURROGATE( rval))
666666
{
667667
const int c = _raw_wgetch_no_surrogate_pairs( win);
668668

669-
if( IS_LOW_SURROGATE( c))
669+
if( PDC_IS_LOW_SURROGATE( c))
670670
rval = ((rval - 0xd800) << 10) + 0x10000 + c - 0xdc00;
671671
}
672672
#endif

pdcurses/util.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,9 @@ static int _wchar_to_int32_array( int32_t *obuff, const int obuffsize, const wch
201201

202202
for( i = 0; i < obuffsize && *wch; i++)
203203
{
204-
if( IS_SURROGATE( wch[0]))
204+
if( PDC_IS_SURROGATE( wch[0]))
205205
{
206-
if( IS_LOW_SURROGATE( wch[1]) && IS_HIGH_SURROGATE( wch[0]))
206+
if( PDC_IS_LOW_SURROGATE( wch[1]) && PDC_IS_HIGH_SURROGATE( wch[0]))
207207
obuff[i] = (((int32_t)wch[0] - 0xd800) << 10) + 0x10000
208208
+ (int32_t)wch[1] - 0xdc00;
209209
else /* malformed surrogate pair */

0 commit comments

Comments
 (0)