summaryrefslogtreecommitdiffstats
path: root/lib.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-09-11 21:02:32 -0700
committerKaz Kylheku <kaz@kylheku.com>2016-09-11 21:02:32 -0700
commit716e5255221344aaafc2c1d273832390c5ebb970 (patch)
treee4f6bd8a4033e6ece2db6a25ec6d175fcde4e35b /lib.c
parentd1e0e1f15227bd01dbbfcb0a77f261d01764e408 (diff)
downloadtxr-716e5255221344aaafc2c1d273832390c5ebb970.tar.gz
txr-716e5255221344aaafc2c1d273832390c5ebb970.tar.bz2
txr-716e5255221344aaafc2c1d273832390c5ebb970.zip
Semantics change in trim-str function.
* lib.c (trim_str): Trim only newlines and blanks, not carriage returns, vertical tabs and form feeds. This is subject to the compatibility option * txr.1: Doc updated and compatibility note added.
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib.c b/lib.c
index 61a43c01..5ca640c5 100644
--- a/lib.c
+++ b/lib.c
@@ -3916,11 +3916,19 @@ val trim_str(val str)
const wchar_t *start = c_str(str);
const wchar_t *end = start + c_num(length_str(str));
- while (start[0] && iswspace(start[0]))
- start++;
+ if (opt_compat && opt_compat <= 148) {
+ while (start[0] && iswspace(start[0]))
+ start++;
- while (end > start && iswspace(end[-1]))
- end--;
+ while (end > start && iswspace(end[-1]))
+ end--;
+ } else {
+ while (start[0] && wcschr(L" \t\n", start[0]))
+ start++;
+
+ while (end > start && wcschr(L" \t\n", end[-1]))
+ end--;
+ }
if (end == start) {
return null_string;