summaryrefslogtreecommitdiffstats
path: root/txr.1
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-04-20 05:13:19 -0700
committerKaz Kylheku <kaz@kylheku.com>2016-04-20 05:13:19 -0700
commit03213f2aa15930d7336f582238f8abfacf17584a (patch)
treeb06c13268925e3d9f40a45f041b1f6a3d2bfeb6c /txr.1
parent04575dff348209315fb24e3c809a93343f39783b (diff)
downloadtxr-03213f2aa15930d7336f582238f8abfacf17584a.tar.gz
txr-03213f2aa15930d7336f582238f8abfacf17584a.tar.bz2
txr-03213f2aa15930d7336f582238f8abfacf17584a.zip
read-until-match can optionally keep matched text.
* regex.c (read_until_match): New argument, include_match. Three times repeated termination code refactored into block reached by forward goto. (regex_init): Registration of read-until-match updated. * regex.h (read_until_match): Declaration updated. * stream.c (struct record_adapter_base): New member, include_match. (record_adapter_get_line): Pass match to read_until_match as new argument. (record_adapater): New argument, include_match. (stream_init): Update registration of record-adapter. * stream.h (record_adapter): Declaration updated. * txr.1: Updated.
Diffstat (limited to 'txr.1')
-rw-r--r--txr.136
1 files changed, 24 insertions, 12 deletions
diff --git a/txr.1 b/txr.1
index c07ca2c8..42558296 100644
--- a/txr.1
+++ b/txr.1
@@ -30574,7 +30574,7 @@ in the resulting string object that is processed by
.coNP Function @ read-until-match
.synb
-.mets (read-until-match < regex <> [ stream ])
+.mets (read-until-match < regex >> [ stream <> [ include-match ]])
.syne
.desc
The
@@ -30589,6 +30589,14 @@ then the
.code *std-input*
stream is used.
+The
+.meta include-match
+argument is Boolean, indicating whether the delimiting text
+matched by
+.meta regex
+is included in the returned string. It defaults to
+.codn nil .
+
The accumulation of characters is terminated by a match on
.metn regex ,
the end of the stream, or an error.
@@ -30608,12 +30616,11 @@ are accumulated, the function returns
When the accumulation of characters terminates by a match on
.metn regex ,
-reading characters from the stream continues. The longest
-possible prefix of the stream which matches
-.meta regex
-is read, and discarded. If an error is encountered, the
-matching procedure terminates and returns the previously
-accumulated string.
+the longest possible matching sequence of characters is
+removed from the stream. If
+.meta include-match
+is true, that matching text is included in
+the returned string. Otherwise, it is discarded.
.SS* Hashing Library
.coNP Functions @, make-hash and @ hash
@@ -34769,7 +34776,7 @@ terminal to terminate the expression.
.coNP Function @ record-adapter
.synb
-.mets (record-adapter < regex <> [ stream ])
+.mets (record-adapter < regex >> [ stream <> [ include-match ]])
.syne
.desc
The
@@ -34797,11 +34804,16 @@ function is used on the adapter, it behaves differently. A string is
extracted from
.metn stream ,
and returned. However, the string isn't a line delimited by a newline
-character, but a record delimited by
-.metn regex
-as if using the
+character, but rather a record delimited by
+.metn regex .
+This record is extracted as if by a call to the
.code read-until-match
-function.
+function, invoked with the
+.metn regex ,
+.meta stream
+and
+.meta include-match
+arguments.
All behavior which is built on the
.code get-lines