Using own versions of wide char classification funcs to disjoint code from LC_CTYPE
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2164 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -74,12 +74,6 @@ LoadJoystickAlpha (STRING String, int *count)
|
||||
return chars;
|
||||
}
|
||||
|
||||
static inline int
|
||||
IsPrintableChar (wchar_t ch)
|
||||
{
|
||||
return iswgraph (ch) || (ch == ' ');
|
||||
}
|
||||
|
||||
static int
|
||||
JoyCharFindIn (const joy_char_t *ch, const joy_char_t *set,
|
||||
int setsize)
|
||||
@@ -212,7 +206,7 @@ DoTextEntry (PTEXTENTRY_STATE pTES)
|
||||
pTES->JoystickMode = FALSE;
|
||||
|
||||
chsize = getStringFromChar (chbuf, sizeof (chbuf), ch);
|
||||
if (IsPrintableChar (ch) && chsize > 0
|
||||
if (isWidePrintChar (ch) && chsize > 0
|
||||
&& (pStr + len - pTES->BaseStr + chsize < pTES->MaxSize))
|
||||
{ // insert character
|
||||
memmove (pStr + chsize, pStr, len + 1);
|
||||
|
||||
@@ -407,3 +407,18 @@ getStringFromWide(unsigned char *ptr, size_t size, const wchar_t *wstr)
|
||||
|
||||
return getStringFromWideN(ptr, size, wstr, (end - wstr));
|
||||
}
|
||||
|
||||
int
|
||||
isWideGraphChar(wchar_t ch)
|
||||
{ // this is not technically sufficient, but close enough for us
|
||||
// we'll consider all non-control (CO and C1) chars in 'graph' class
|
||||
return (ch > 0xa0) || (ch > 0x20 && ch < 0x7f);
|
||||
}
|
||||
|
||||
int
|
||||
isWidePrintChar(wchar_t ch)
|
||||
{ // this is not technically sufficient, but close enough for us
|
||||
// chars in 'print' class are 'graph' + 'space' classes
|
||||
// the only space we currently have defined is 0x20
|
||||
return (ch == 0x20) || isWideGraphChar(ch);
|
||||
}
|
||||
|
||||
@@ -68,7 +68,8 @@ size_t getStringFromWideN(unsigned char *ptr, size_t size,
|
||||
const wchar_t *wstr, size_t count);
|
||||
size_t getStringFromWide(unsigned char *ptr, size_t size,
|
||||
const wchar_t *wstr);
|
||||
|
||||
int isWideGraphChar(wchar_t ch);
|
||||
int isWidePrintChar(wchar_t ch);
|
||||
|
||||
#endif /* _STRLIB_H */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user