Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-03-12 04:03:42 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-03-12 04:03:42 +0400
commit7afeb21a419a86aef36bcded1470b941a40f27c9 (patch)
tree9fb54f22f8535ea8922d1ae5f8c006b8a67866c2 /source/blender/blenlib/intern/string_cursor_utf8.c
parentcae11a98f98cf0fc299dbb641c6a748b83589054 (diff)
text delimiter - convert to unicode before comparing characters.
Diffstat (limited to 'source/blender/blenlib/intern/string_cursor_utf8.c')
-rw-r--r--source/blender/blenlib/intern/string_cursor_utf8.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/source/blender/blenlib/intern/string_cursor_utf8.c b/source/blender/blenlib/intern/string_cursor_utf8.c
index baf52d92230..97559d6ba10 100644
--- a/source/blender/blenlib/intern/string_cursor_utf8.c
+++ b/source/blender/blenlib/intern/string_cursor_utf8.c
@@ -48,19 +48,21 @@ typedef enum strCursorDelimType {
} strCursorDelimType;
/* return 1 if char ch is special character, otherwise return 0 */
-static strCursorDelimType test_special_char(const char ch)
+static strCursorDelimType test_special_char(const char *ch_utf8)
{
- /* TODO - use BLI_str_utf8_as_unicode rather then assuming ascii */
+ /* for full unicode support we really need to have large lookup tables to figure
+ * out whats what in every possible char set - and python, glib both have these. */
+ unsigned int uch = BLI_str_utf8_as_unicode(ch_utf8);
- if ((ch >= 'a' && ch <= 'z') ||
- (ch >= 'A' && ch <= 'Z') ||
- (ch == '_') /* not quite correct but allow for python, could become configurable */
+ if ((uch >= 'a' && uch <= 'z') ||
+ (uch >= 'A' && uch <= 'Z') ||
+ (uch == '_') /* not quite correct but allow for python, could become configurable */
)
{
return STRCUR_DELIM_ALPHA;
}
- switch (ch) {
+ switch (uch) {
case ',':
case '.':
return STRCUR_DELIM_PUNCT;
@@ -150,13 +152,13 @@ void BLI_str_cursor_step_utf8(const char *str, size_t maxlen,
BLI_str_cursor_step_next_utf8(str, maxlen, pos);
if (jump != STRCUR_JUMP_NONE) {
- const strCursorDelimType is_special = (*pos) < maxlen ? test_special_char(str[(*pos)]) : STRCUR_DELIM_NONE;
+ const strCursorDelimType is_special = (*pos) < maxlen ? test_special_char(&str[*pos]) : STRCUR_DELIM_NONE;
/* jump between special characters (/,\,_,-, etc.),
* look at function test_special_char() for complete
* list of special character, ctr -> */
while ((*pos) < maxlen) {
if (BLI_str_cursor_step_next_utf8(str, maxlen, pos)) {
- if ((jump != STRCUR_JUMP_ALL) && (is_special != test_special_char(str[(*pos)])))
+ if ((jump != STRCUR_JUMP_ALL) && (is_special != test_special_char(&str[*pos])))
break;
}
else {
@@ -169,13 +171,13 @@ void BLI_str_cursor_step_utf8(const char *str, size_t maxlen,
BLI_str_cursor_step_prev_utf8(str, maxlen, pos);
if (jump != STRCUR_JUMP_NONE) {
- const strCursorDelimType is_special = (*pos) > 1 ? test_special_char(str[(*pos) - 1]) : STRCUR_DELIM_NONE;
+ const strCursorDelimType is_special = (*pos) > 1 ? test_special_char(&str[(*pos) - 1]) : STRCUR_DELIM_NONE;
/* jump between special characters (/,\,_,-, etc.),
* look at function test_special_char() for complete
* list of special character, ctr -> */
while ((*pos) > 0) {
if (BLI_str_cursor_step_prev_utf8(str, maxlen, pos)) {
- if ((jump != STRCUR_JUMP_ALL) && (is_special != test_special_char(str[(*pos)])))
+ if ((jump != STRCUR_JUMP_ALL) && (is_special != test_special_char(&str[*pos])))
break;
}
else {