diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-04-10 06:51:24 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-04-10 06:51:24 +0400 |
commit | 3c6239f8beca61ba6488b16c2b2a019316dbfbae (patch) | |
tree | 121bc93533a7b17d8837c13730adea107485a667 /source/blender/blenkernel | |
parent | 7f8aaaf10083b8f8e221631fd880b95074a3d014 (diff) |
fix for unit system incorrectly replacint 'um' (unicode 'u'). with meters.
result was editing number buttons with um would give a python error.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/intern/unit.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index fba0cba42e0..b3c979afac4 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -33,6 +33,7 @@ #include "BLI_math.h" #include "BLI_string.h" +#include "BLI_string_utf8.h" #include "BLI_winstuff.h" #define TEMP_STR_SIZE 256 @@ -418,6 +419,11 @@ void bUnit_AsString(char *str, int len_max, double value, int prec, int system, unit_as_string(str, len_max, value, prec, usys, NULL, pad ? ' ' : '\0'); } +BLI_INLINE int isalpha_or_utf8(const int ch) +{ + return (ch >= 128 || isalpha(ch)); +} + static const char *unit_find_str(const char *str, const char *substr) { const char *str_found; @@ -426,11 +432,15 @@ static const char *unit_find_str(const char *str, const char *substr) str_found = strstr(str, substr); if (str_found) { /* previous char cannot be a letter */ - if (str_found == str || isalpha(*(str_found-1)) == 0) { + if (str_found == str || + /* weak unicode support!, so "µm" won't match up be replaced by "m" + * since non ascii utf8 values will NEVER return TRUE */ + isalpha_or_utf8(*BLI_str_prev_char_utf8(str_found)) == 0) + { /* next char cannot be alphanum */ int len_name = strlen(substr); - if (!isalpha(*(str_found+len_name))) { + if (!isalpha_or_utf8(*(str_found + len_name))) { return str_found; } } |