diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2001-09-19 08:52:46 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2001-09-19 08:52:46 (GMT) |
commit | 000f29b52802a11b293d0629589c2a7aa652cda7 (patch) | |
tree | 4c372cce312a5fa051b945de7d65071bb0925470 /generic/tclUtil.c | |
parent | b53d7f844a52e25261a68ee3e64737a00f818f27 (diff) | |
download | tcl-000f29b52802a11b293d0629589c2a7aa652cda7.zip tcl-000f29b52802a11b293d0629589c2a7aa652cda7.tar.gz tcl-000f29b52802a11b293d0629589c2a7aa652cda7.tar.bz2 |
TclNeedSpace is now UTF8-aware. (Bug #411825 from <arobert3434@users.sf.net>)
Diffstat (limited to 'generic/tclUtil.c')
-rw-r--r-- | generic/tclUtil.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/generic/tclUtil.c b/generic/tclUtil.c index 96deda9..0afef5c 100644 --- a/generic/tclUtil.c +++ b/generic/tclUtil.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclUtil.c,v 1.22 2001/08/31 17:53:57 hobbs Exp $ + * RCS: @(#) $Id: tclUtil.c,v 1.23 2001/09/19 08:52:46 dkf Exp $ */ #include "tclInt.h" @@ -1931,6 +1931,8 @@ TclNeedSpace(start, end) char *end; /* End of string (place where space will * be added, if appropriate). */ { + Tcl_UniChar ch; + /* * A space is needed unless either * (a) we're at the start of the string, or @@ -1944,10 +1946,14 @@ TclNeedSpace(start, end) if (end == start) { return 0; } - end--; + end = Tcl_UtfPrev(end, start); if (*end != '{') { - if (isspace(UCHAR(*end)) /* INTL: ISO space. */ - && ((end == start) || (end[-1] != '\\'))) { + Tcl_UtfToUniChar(end, &ch); + /* + * Direct char comparison on next line is safe as it is with + * a character in the ASCII subset, and so single-byte in UTF8. + */ + if (Tcl_UniCharIsSpace(ch) && ((end == start) || (end[-1] != '\\'))) { return 0; } return 1; @@ -1956,9 +1962,10 @@ TclNeedSpace(start, end) if (end == start) { return 0; } - end--; + end = Tcl_UtfPrev(end, start); } while (*end == '{'); - if (isspace(UCHAR(*end))) { /* INTL: ISO space. */ + Tcl_UtfToUniChar(end, &ch); + if (Tcl_UniCharIsSpace(ch)) { return 0; } return 1; |