diff options
Diffstat (limited to 'generic/tclUtf.c')
-rw-r--r-- | generic/tclUtf.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/generic/tclUtf.c b/generic/tclUtf.c index 74e7888..fde80ae 100644 --- a/generic/tclUtf.c +++ b/generic/tclUtf.c @@ -1146,18 +1146,19 @@ Tcl_UniCharAtIndex( Tcl_UniChar ch = 0; int i = 0; - if (index != TCL_INDEX_NONE) { - while (index--) { - i = TclUtfToUniChar(src, &ch); - src += i; - } + if (index == TCL_INDEX_NONE) { + return -1; + } + while (index--) { + i = TclUtfToUniChar(src, &ch); + src += i; + } #if TCL_UTF_MAX <= 3 - if ((ch >= 0xD800) && (i < 3)) { - /* Index points at character following high Surrogate */ - return -1; - } -#endif + if ((ch >= 0xD800) && (i < 3)) { + /* Index points at character following high Surrogate */ + return -1; } +#endif TclUtfToUCS4(src, &i); return i; } |