summaryrefslogtreecommitdiff
path: root/include/shmbutil.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/shmbutil.h')
-rw-r--r--include/shmbutil.h17
1 files changed, 15 insertions, 2 deletions
diff --git a/include/shmbutil.h b/include/shmbutil.h
index 264cae33..36902f16 100644
--- a/include/shmbutil.h
+++ b/include/shmbutil.h
@@ -50,6 +50,10 @@ extern int locale_utf8locale; /* XXX */
#define MBLEN(s, n) ((MB_CUR_MAX > 1) ? mblen ((s), (n)) : 1)
#define MBRLEN(s, n, p) ((MB_CUR_MAX > 1) ? mbrlen ((s), (n), (p)) : 1)
+#define UTF8_SINGLEBYTE(c) (((c) & 0x80) == 0)
+#define UTF8_MBFIRSTCHAR(c) (((c) & 0xc0) == 0xc0)
+#define UTF8_MBCHAR(c) (((c) & 0xc0) == 0x80)
+
#else /* !HANDLE_MULTIBYTE */
#undef MB_LEN_MAX
@@ -75,6 +79,9 @@ extern int locale_utf8locale; /* XXX */
# define wchar_t int
#endif
+#define UTF8_SINGLEBYTE(c) (1)
+#define UTF8_MBFIRSTCHAR(c) (0)
+
#endif /* !HANDLE_MULTIBYTE */
/* Declare and initialize a multibyte state. Call must be terminated
@@ -111,7 +118,7 @@ extern int locale_utf8locale; /* XXX */
if (_f) \
mblength = 1; \
else if (locale_utf8locale && (((_str)[_i] & 0x80) == 0)) \
- mblength = 1; \
+ mblength = (_str)[_i] != 0; \
else \
{ \
state_bak = state; \
@@ -152,6 +159,8 @@ extern int locale_utf8locale; /* XXX */
_f = is_basic (*(_str)); \
if (_f) \
mblength = 1; \
+ else if (locale_utf8locale && ((*(_str) & 0x80) == 0)) \
+ mblength = *(_str) != 0; \
else \
{ \
state_bak = state; \
@@ -271,7 +280,7 @@ extern int locale_utf8locale; /* XXX */
if (_k) \
mblength = 1; \
else if (locale_utf8locale && ((*(_src) & 0x80) == 0)) \
- mblength = 1; \
+ mblength = *(_src) != 0; \
else \
{ \
state_bak = state; \
@@ -445,6 +454,8 @@ extern int locale_utf8locale; /* XXX */
i = is_basic (*((_src) + (_si))); \
if (i) \
mblength = 1; \
+ else if (locale_utf8locale && (((_src)[_si] & 0x80) == 0)) \
+ mblength = (_src)[_si] != 0; \
else \
{ \
state_bak = state; \
@@ -483,6 +494,8 @@ extern int locale_utf8locale; /* XXX */
i = is_basic (*((_src) + (_si))); \
if (i) \
mblength = 1; \
+ else if (locale_utf8locale && (((_src)[_si] & 0x80) == 0)) \
+ mblength = (_src)[_si] != 0; \
else \
{ \
state_bak = state; \