diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-04-26 07:05:54 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-04-26 07:05:54 -0700 |
commit | 59a96304bd8716eb68c672ab6970111565e3f269 (patch) | |
tree | 88627b28154f4de368887c6b142e7e07d9f77622 | |
parent | 5917bcb01bff764b0734e45cc86f9e19e20ba984 (diff) | |
download | txr-59a96304bd8716eb68c672ab6970111565e3f269.tar.gz txr-59a96304bd8716eb68c672ab6970111565e3f269.tar.bz2 txr-59a96304bd8716eb68c672ab6970111565e3f269.zip |
match-str: return useful position instead of t.
* lib.c (match_str): The match_str function is hereby altered
to return an integer instead of the symbol t in the matching case.
* txr.1: Updated.
-rw-r--r-- | lib.c | 4 | ||||
-rw-r--r-- | txr.1 | 26 |
2 files changed, 22 insertions, 8 deletions
@@ -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; } } @@ -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 ]) |