summaryrefslogtreecommitdiff
path: root/regenc.c
diff options
context:
space:
mode:
Diffstat (limited to 'regenc.c')
-rw-r--r--regenc.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/regenc.c b/regenc.c
index 0afdf22cb7..c595f44b29 100644
--- a/regenc.c
+++ b/regenc.c
@@ -3,7 +3,7 @@
**********************************************************************/
/*-
* Copyright (c) 2002-2007 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
- * Copyright (c) 2011-2016 K.Takata <kentkt AT csc DOT jp>
+ * Copyright (c) 2011-2019 K.Takata <kentkt AT csc DOT jp>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -640,18 +640,19 @@ onigenc_single_byte_mbc_to_code(const UChar* p, const UChar* end ARG_UNUSED,
}
extern int
-onigenc_single_byte_code_to_mbclen(OnigCodePoint code ARG_UNUSED, OnigEncoding enc ARG_UNUSED)
+onigenc_single_byte_code_to_mbclen(OnigCodePoint code, OnigEncoding enc ARG_UNUSED)
{
+ if (code > 0xff)
+ return ONIGERR_INVALID_CODE_POINT_VALUE;
return 1;
}
extern int
onigenc_single_byte_code_to_mbc(OnigCodePoint code, UChar *buf, OnigEncoding enc ARG_UNUSED)
{
-#ifdef RUBY
- if (code > 0xff)
- rb_raise(rb_eRangeError, "%u out of char range", code);
-#endif
+ if (code > 0xff) {
+ return ONIGERR_INVALID_CODE_POINT_VALUE;
+ }
*buf = (UChar )(code & 0xff);
return 1;
}
@@ -966,6 +967,7 @@ onigenc_property_list_add_property(UChar* name, const OnigCodePoint* prop,
}
#endif
+#ifdef USE_CASE_MAP_API
extern int
onigenc_ascii_only_case_map(OnigCaseFoldType* flagP, const OnigUChar** pp, const OnigUChar* end,
OnigUChar* to, OnigUChar* to_end, const struct OnigEncodingTypeST* enc)
@@ -984,7 +986,7 @@ onigenc_ascii_only_case_map(OnigCaseFoldType* flagP, const OnigUChar** pp, const
if (code >= 'a' && code <= 'z' && (flags & ONIGENC_CASE_UPCASE)) {
flags |= ONIGENC_CASE_MODIFIED;
- code += 'A' - 'a';
+ code -= 'a' - 'A';
}
else if (code >= 'A' && code <= 'Z' &&
(flags & (ONIGENC_CASE_DOWNCASE | ONIGENC_CASE_FOLD))) {
@@ -1013,7 +1015,7 @@ onigenc_single_byte_ascii_only_case_map(OnigCaseFoldType* flagP, const OnigUChar
if (code >= 'a' && code <= 'z' && (flags & ONIGENC_CASE_UPCASE)) {
flags |= ONIGENC_CASE_MODIFIED;
- code += 'A' - 'a';
+ code -= 'a' - 'A';
}
else if (code >= 'A' && code <= 'Z' &&
(flags & (ONIGENC_CASE_DOWNCASE | ONIGENC_CASE_FOLD))) {
@@ -1027,3 +1029,4 @@ onigenc_single_byte_ascii_only_case_map(OnigCaseFoldType* flagP, const OnigUChar
*flagP = flags;
return (int )(to - to_start);
}
+#endif