diff options
author | dgp <dgp@users.sourceforge.net> | 2003-08-27 19:55:50 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2003-08-27 19:55:50 (GMT) |
commit | 2d1fff2b097e69a3e630e3e4eef885ac6f661314 (patch) | |
tree | 377d7b194f6cb3b536c9a15957321c597f3ec7ed /generic/tclUtil.c | |
parent | b8856c8af163ca877ee68f3ad8203ba0ef73955d (diff) | |
download | tcl-2d1fff2b097e69a3e630e3e4eef885ac6f661314.zip tcl-2d1fff2b097e69a3e630e3e4eef885ac6f661314.tar.gz tcl-2d1fff2b097e69a3e630e3e4eef885ac6f661314.tar.bz2 |
Revert mistaken commit.
Diffstat (limited to 'generic/tclUtil.c')
-rw-r--r-- | generic/tclUtil.c | 56 |
1 files changed, 21 insertions, 35 deletions
diff --git a/generic/tclUtil.c b/generic/tclUtil.c index fc57ed0..fd58235 100644 --- a/generic/tclUtil.c +++ b/generic/tclUtil.c @@ -11,7 +11,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.39 2003/08/27 17:57:03 dgp Exp $ + * RCS: @(#) $Id: tclUtil.c,v 1.40 2003/08/27 19:55:50 dgp Exp $ */ #include "tclInt.h" @@ -2001,58 +2001,44 @@ TclNeedSpace(start, end) CONST char *end; /* End of string (place where space will * be added, if appropriate). */ { - /* - * Direct char comparisons to the character literals '{' and '\\' - * below are safe because these literals are characters in the - * ASCII subset, and so single-byte in UTF8. - */ + Tcl_UniChar ch; /* * A space is needed unless either * (a) we're at the start of the string, or + * (b) the trailing characters of the string consist of one or more + * open curly braces preceded by a space or extending back to + * the beginning of the string. + * (c) the trailing characters of the string consist of a space + * preceded by a character other than backslash. */ if (end == start) { return 0; } - end = Tcl_UtfPrev(end, start); if (*end != '{') { - Tcl_UniChar ch; Tcl_UtfToUniChar(end, &ch); - - /* - * (b) the trailing characters of the string consist of a - * list-element-separating space ( space, tab, carriage return, - * newline ) preceded by a character other than backslash, or - */ - - /* NOTE: (Bug 411825) The non-breaking space \u00a0 is not - * recognized by Tcl's script parser, nor its list element - * parser as a word separating character (Fits well with - * "non-breaking" doesn't it?), so the non-breaking space - * should not suppress the need of a space. Any other - * whitespace Unicode characters outside the ASCII subset are - * treated likewise. - */ - return (!Tcl_UniCharIsSpace(ch) || (*end >= 0x80) - || ((end > start) && (end[-1] == '\\'))); + /* + * 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; } - - /* - * (c) the trailing characters of the string consist of one or more - * open curly braces, and the beginning of the sequence of - * open curly braces represents the beginning of a list element - * (as tested by a recursive call to TclNeedSpace). - */ - do { if (end == start) { return 0; } - end--; + end = Tcl_UtfPrev(end, start); } while (*end == '{'); - return TclNeedSpace(start,end+1); + Tcl_UtfToUniChar(end, &ch); + if (Tcl_UniCharIsSpace(ch)) { + return 0; + } + return 1; } /* |