summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2013-11-11 10:18:08 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2013-11-11 10:18:08 (GMT)
commit38b82010631e8ebde6b520bf6d5cd1c8265de2e0 (patch)
treedf51f468ddbcf96fddcb360128744946c1a034f2
parent1b16ec8bb53f4d1aa60ce4ba141e52c331de9427 (diff)
parent6d173aa6be98d083b288206ad2c036bc37799c89 (diff)
downloadtk-38b82010631e8ebde6b520bf6d5cd1c8265de2e0.zip
tk-38b82010631e8ebde6b520bf6d5cd1c8265de2e0.tar.gz
tk-38b82010631e8ebde6b520bf6d5cd1c8265de2e0.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.test9
3 files changed, 25 insertions, 10 deletions
diff --git a/generic/tkOption.c b/generic/tkOption.c
index 2a8d501..75dc3b9 100644
--- a/generic/tkOption.c
+++ b/generic/tkOption.c
@@ -1016,14 +1016,25 @@ AddFromString(
Tcl_SetErrorCode(interp, "TK", "OPTIONDB", "NEWLINE", NULL);
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 66df70c..23866d7 100644
--- a/tests/option.test
+++ b/tests/option.test
@@ -384,15 +384,18 @@ test option-15.6 {database files} -body {
option get . x6 color
} -result {}
test option-15.7 {database files} -body {
+ option read $option1
+ option get . x9 color
+} -result " \t\\A\n"
+test option-15.8 {database files} -body {
option read $option1 widget foo
} -returnCodes error -result {wrong # args: should be "option readfile fileName ?priority?"}
-
-test option-15.8 {database files} -body {
+test option-15.9 {database files} -body {
option add *x3 burgundy
catch {option read $option1 userDefault}
option get . x3 color
} -result burgundy
-test option-15.9 {database files} -body {
+test option-15.10 {database files} -body {
set option2 [file join [testsDirectory] option.file2]
option read $option2
} -returnCodes error -result {missing colon on line 2}