summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib.c4
-rw-r--r--txr.126
2 files changed, 22 insertions, 8 deletions
diff --git a/lib.c b/lib.c
index 917a59e1..ea90164b 100644
--- a/lib.c
+++ b/lib.c
@@ -4511,7 +4511,7 @@ val match_str(val bigstr, val str, val pos)
return nil;
}
- return length_str_le(str, i) ? t : nil;
+ return length_str_le(str, i) ? succ(i) : nil;
} else {
pos = plus(pos, length(bigstr));
pos = plus(minus(pos, length(str)), one);
@@ -4524,7 +4524,7 @@ val match_str(val bigstr, val str, val pos)
return nil;
}
- return minusp(i);
+ return minusp(i) ? pos : nil;
}
}
diff --git a/txr.1 b/txr.1
index 1589215e..88663164 100644
--- a/txr.1
+++ b/txr.1
@@ -23606,12 +23606,7 @@ argument, the
function determines whether
.meta littlestring
is a prefix of
-.metn bigstring ,
-returning a
-.code t
-or
-.code nil
-indication.
+.metn bigstring .
If the
.meta start
@@ -23648,6 +23643,25 @@ then this corresponds to testing whether
is a suffix of
.metn bigstring .
+The
+.code match-str
+function returns
+.code nil
+if there is no match.
+
+If a prefix match is successful,
+then an integer value is returned indicating the position, inside
+.metn bigstring ,
+one character past the matching prefix. If the entire string is matched, then
+this value corresponds to the length of
+.metn bigstring .
+
+If a suffix match is successful, the return value is the position within
+.meta bigstring
+where the leftmost character of
+.meta littlestring
+matched.
+
.coNP Function @ match-str-tree
.synb
.mets (match-str-tree < bigstring < tree <> [ start ])