summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornijtmans@users.sourceforge.net <jan.nijtmans>2013-11-11 10:05:55 (GMT)
committernijtmans@users.sourceforge.net <jan.nijtmans>2013-11-11 10:05:55 (GMT)
commit448c815d561c16084d95fed06d3c62b44cf66322 (patch)
tree9345a2f89657cf2a8c29be397c9cfb930f7f8fe3
parent20b15bf633f6153210e569165b9aae09729fb88a (diff)
downloadtk-448c815d561c16084d95fed06d3c62b44cf66322.zip
tk-448c815d561c16084d95fed06d3c62b44cf66322.tar.gz
tk-448c815d561c16084d95fed06d3c62b44cf66322.tar.bz2
Fix [0aa5e852dc]: Accept newline characters as value in Tk option files
-rw-r--r--generic/tkOption.c25
-rw-r--r--tests/option.file11
-rw-r--r--tests/option.test7
3 files changed, 23 insertions, 10 deletions
diff --git a/generic/tkOption.c b/generic/tkOption.c
index de92627..91a6cc0 100644
--- a/generic/tkOption.c
+++ b/generic/tkOption.c
@@ -1019,14 +1019,25 @@ AddFromString(
Tcl_SetResult(interp, buf, TCL_VOLATILE);
return TCL_ERROR;
}
- if ((src[0] == '\\') && (src[1] == '\n')) {
- src += 2;
- lineNum++;
- } else {
- *dst = *src;
- dst++;
- src++;
+ if (*src == '\\'){
+ if (src[1] == '\n') {
+ src += 2;
+ lineNum++;
+ continue;
+ } else if (src[1] == 'n') {
+ src += 2;
+ *dst++ = '\n';
+ continue;
+ } else if (src[1] == '\t' || src[1] == ' ' || src[1] == '\\') {
+ ++src;
+ } else if (src[1] >= '0' && src[1] <= '3' && src[2] >= '0' &&
+ src[2] <= '9' && src[3] >= '0' && src[3] <= '9') {
+ *dst++ = ((src[1]&7)<<6) | ((src[2]&7)<<3) | (src[3]&7);
+ src += 4;
+ continue;
+ }
}
+ *dst++ = *src++;
}
*dst = 0;
diff --git a/tests/option.file1 b/tests/option.file1
index e64b6cc..32b4a18 100644
--- a/tests/option.file1
+++ b/tests/option.file1
@@ -14,4 +14,5 @@ ple
# More comments, this time delimited by hash-marks.
# Comment-line with space.
*x6:
+*x9: \ \ \\\101\n
# comment line as last line of file.
diff --git a/tests/option.test b/tests/option.test
index 49d2975..1bfcb7c 100644
--- a/tests/option.test
+++ b/tests/option.test
@@ -197,13 +197,14 @@ test option-15.3 {database files} appNameIsTktest {option get . x2 color} green
test option-15.4 {database files} {option get . x3 color} purple
test option-15.5 {database files} {option get . {x 4} color} brown
test option-15.6 {database files} {option get . x6 color} {}
-test option-15.7 {database files} {
+test option-15.7 {database files} {option get . x9 color} " \t\\A\n"
+test option-15.8 {database files} {
list [catch {option read $option1 widget foo} msg] $msg
} {1 {wrong # args: should be "option readfile fileName ?priority?"}}
option add *x3 burgundy
catch {option read $option1 userDefault}
-test option-15.8 {database files} {option get . x3 color} burgundy
-test option-15.9 {database files} {
+test option-15.9 {database files} {option get . x3 color} burgundy
+test option-15.10 {database files} {
list [catch {option read $option2} msg] $msg
} {1 {missing colon on line 2}}