summaryrefslogtreecommitdiffstats
path: root/generic/tclUtil.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2018-11-09 15:39:26 (GMT)
committerdgp <dgp@users.sourceforge.net>2018-11-09 15:39:26 (GMT)
commit83ec300abdbc8486b4fd3272cd74a9c3f162ad7f (patch)
tree7259dfc25be52679d61b6a19fa3003d9fb768820 /generic/tclUtil.c
parentddae61a859c90b865bf0d82684638b80522d7922 (diff)
downloadtcl-83ec300abdbc8486b4fd3272cd74a9c3f162ad7f.zip
tcl-83ec300abdbc8486b4fd3272cd74a9c3f162ad7f.tar.gz
tcl-83ec300abdbc8486b4fd3272cd74a9c3f162ad7f.tar.bz2
Revise bug fix to support (length == 0) correctly.
Added comments and improved safety in caller.
Diffstat (limited to 'generic/tclUtil.c')
-rw-r--r--generic/tclUtil.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/generic/tclUtil.c b/generic/tclUtil.c
index 2a0d51a..d065069 100644
--- a/generic/tclUtil.c
+++ b/generic/tclUtil.c
@@ -944,10 +944,6 @@ TclScanElement(
int preferEscape = 0; /* Use preferences to track whether to use */
int preferBrace = 0; /* CONVERT_MASK mode. */
int braceCount = 0; /* Count of all braces '{' '}' seen. */
-
- if ((*src == '#') && !(*flagPtr & TCL_DONT_QUOTE_HASH)) {
- preferBrace = 1;
- }
#endif
if ((p == NULL) || (length == 0) || ((*p == '\0') && (length == -1))) {
@@ -956,6 +952,23 @@ TclScanElement(
return 2;
}
+#if COMPAT
+ /*
+ * We have an established history in TclConvertElement() when quoting
+ * because of a leading hash character to force what would be the
+ * CONVERT_MASK mode into the CONVERT_BRACE mode. That is, we format
+ * the element #{a"b} like this:
+ * {#{a"b}}
+ * and not like this:
+ * \#{a\"b}
+ * This is inconsistent with [list x{a"b}], but we will not change that now.
+ * Set that preference here so that we compute a tight size requirement.
+ */
+ if ((*src == '#') && !(*flagPtr & TCL_DONT_QUOTE_HASH)) {
+ preferBrace = 1;
+ }
+#endif
+
if ((*p == '{') || (*p == '"')) {
/*
* Must escape or protect so leading character of value is not