[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [44819] trunk/blender/source/blender/ blenlib/intern/string_cursor_utf8.c: text delimiter - convert to unicode before comparing characters.
Campbell Barton
ideasman42 at gmail.com
Mon Mar 12 01:03:49 CET 2012
Revision: 44819
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=44819
Author: campbellbarton
Date: 2012-03-12 00:03:42 +0000 (Mon, 12 Mar 2012)
Log Message:
-----------
text delimiter - convert to unicode before comparing characters.
Modified Paths:
--------------
trunk/blender/source/blender/blenlib/intern/string_cursor_utf8.c
Modified: trunk/blender/source/blender/blenlib/intern/string_cursor_utf8.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/string_cursor_utf8.c 2012-03-11 23:47:41 UTC (rev 44818)
+++ trunk/blender/source/blender/blenlib/intern/string_cursor_utf8.c 2012-03-12 00:03:42 UTC (rev 44819)
@@ -48,19 +48,21 @@
} 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 @@
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 @@
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 {
More information about the Bf-blender-cvs
mailing list