summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2011-09-27 13:29:49 -0700
committerKaz Kylheku <kaz@kylheku.com>2011-09-27 13:29:49 -0700
commit0a4e0f2ff76761efe933d4ccae4c17efa286f4e3 (patch)
treebb5230f4d00084d5216438f56df0779efc1391b7
parent2722c5140685064be3df771eb9c0e0feff4fded0 (diff)
downloadtxr-0a4e0f2ff76761efe933d4ccae4c17efa286f4e3.tar.gz
txr-0a4e0f2ff76761efe933d4ccae4c17efa286f4e3.tar.bz2
txr-0a4e0f2ff76761efe933d4ccae4c17efa286f4e3.zip
* lib.c (eof_s): New symbol variable.
(obj_init): New variable initialized. * lib.h (eof_s): Declared. * match.c (match_files): New @(eof) directive explicitly matches end of data. * txr.1: Updated.
-rw-r--r--ChangeLog12
-rw-r--r--lib.c3
-rw-r--r--lib.h2
-rw-r--r--match.c8
-rw-r--r--txr.14
5 files changed, 27 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 6b89939f..a9b65e4a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2011-09-27 Kaz Kylheku <kaz@kylheku.com>
+
+ * lib.c (eof_s): New symbol variable.
+ (obj_init): New variable initialized.
+
+ * lib.h (eof_s): Declared.
+
+ * match.c (match_files): New @(eof) directive explicitly
+ matches end of data.
+
+ * txr.1: Updated.
+
2011-09-26 Kaz Kylheku <kaz@kylheku.com>
Version 037
diff --git a/lib.c b/lib.c
index a1b74624..d4918993 100644
--- a/lib.c
+++ b/lib.c
@@ -60,7 +60,7 @@ val all_s, some_s, none_s, maybe_s, cases_s, collect_s, until_s, coll_s;
val define_s, output_s, single_s, first_s, last_s, empty_s;
val repeat_s, rep_s, flatten_s, forget_s;
val local_s, merge_s, bind_s, cat_s;
-val try_s, catch_s, finally_s, throw_s, defex_s, deffilter_s;
+val try_s, catch_s, finally_s, throw_s, defex_s, deffilter_s, eof_s;
val error_s, type_error_s, internal_error_s;
val numeric_error_s, range_error_s;
val query_error_s, file_error_s, process_error_s;
@@ -2132,6 +2132,7 @@ static void obj_init(void)
throw_s = intern(lit("throw"), user_package);
defex_s = intern(lit("defex"), user_package);
deffilter_s = intern(lit("deffilter"), user_package);
+ eof_s = intern(lit("eof"), user_package);
error_s = intern(lit("error"), user_package);
type_error_s = intern(lit("type_error"), user_package);
internal_error_s = intern(lit("internal_error"), user_package);
diff --git a/lib.h b/lib.h
index 6c538aeb..1ffbc2e9 100644
--- a/lib.h
+++ b/lib.h
@@ -227,7 +227,7 @@ extern val all_s, some_s, none_s, maybe_s, cases_s, collect_s, until_s, coll_s;
extern val define_s, output_s, single_s, first_s, last_s, empty_s;
extern val repeat_s, rep_s, flatten_s, forget_s;
extern val local_s, merge_s, bind_s, cat_s;
-extern val try_s, catch_s, finally_s, throw_s, defex_s, deffilter_s;
+extern val try_s, catch_s, finally_s, throw_s, defex_s, deffilter_s, eof_s;
extern val error_s, type_error_s, internal_error_s;
extern val numeric_error_s, range_error_s;
extern val query_error_s, file_error_s, process_error_s;
diff --git a/match.c b/match.c
index a7284f19..73435770 100644
--- a/match.c
+++ b/match.c
@@ -1707,6 +1707,14 @@ repeat_spec_same_data:
if ((spec = rest(spec)) == nil)
break;
goto repeat_spec_same_data;
+ } else if (sym == eof_s) {
+ if (data) {
+ debugf(lit("eof failed to match at ~a"), num(data_lineno), nao);
+ return nil;
+ }
+ if ((spec = rest(spec)) == nil)
+ break;
+ goto repeat_spec_same_data;
} else {
val func = uw_get_func(sym);
diff --git a/txr.1 b/txr.1
index 917b0fff..90efb34e 100644
--- a/txr.1
+++ b/txr.1
@@ -854,6 +854,10 @@ argument material. Most directives must be the first item of a line.
A summary of the available directives follows:
+.IP @(eof)
+Explicitly match the end of file. Fails if unmatched data remains in
+the input stream.
+
.IP @(next)
Continue matching in another file.