From 4abffc416e2bc48547e7b8753643abce063dc729 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 8 Mar 2017 19:54:35 -0800 Subject: Drop the annoying need for - for standard input. * match.c (open_data_source): If there is nothing in the files array and data is t (indicating a request to open a data source), then use standard input. Subject to the compatibility option. * Makefile (txr-manpage.html): Drop use of the txr - argument in rule recipe. * txr.1: Document that - isn't necessary. Added to compatibility notes. --- Makefile | 2 +- match.c | 10 +++++++++- txr.1 | 18 ++++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 1024cf04..deef23f8 100644 --- a/Makefile +++ b/Makefile @@ -443,7 +443,7 @@ install-tests: # Generate web page from man page # txr-manpage.html: txr.1 genman.txr - man2html $< | $(TXR) genman.txr - > $@ + man2html $< | $(TXR) genman.txr > $@ txr-manpage.pdf: txr.1 checkman.txr $(TXR) checkman.txr $< diff --git a/match.c b/match.c index ef758580..f183c509 100644 --- a/match.c +++ b/match.c @@ -4427,7 +4427,15 @@ static void open_data_source(match_files_ctx *c) c->data = nil; } } else if (c->data == t && c->files == nil) { - c->data = nil; + if (opt_compat && opt_compat <= 170) { + c->data = nil; + } else { + spec_bind (specline, first_spec, c->spec); + debuglf(first_spec, lit("opening standard input as data source"), nao); + c->curfile = lit("-"); + c->data = lazy_stream_cons(std_input); + c->data_lineno = one; + } } } diff --git a/txr.1 b/txr.1 index 02961abe..e1894f19 100644 --- a/txr.1 +++ b/txr.1 @@ -864,6 +864,12 @@ or one of the related options. A file argument consisting of a single .code - means to read the standard input instead of opening a file. +Specifying standard input as a source with an explicit +.code - +argument is unnecessary. If no data source arguments are present, then +\*(TX scans standard input by default. This was not true in versions of \*(TX +prior to 171; see the COMPATIBILITY section. + .PP \*(TX begins by reading the script. In the case of the \*(TX pattern language, the entire query is scanned, internalized and then begins executing, if it is @@ -52657,6 +52663,18 @@ of these version values, the described behaviors are provided if is given an argument which is equal or lower. For instance .code "-C 103" selects the behaviors described below for version 105, but not those for 102. +.IP 170 +A value of 170 or lower disables the behavior that \*(TX scans standard input +when no input sources are specified on the command line. Standard input must +be requested explicitly using the +.code - +argument. This is how it was in all versions of \*(TX up to 170. +Some programs may behave differently because of this. Specifically, programs +which do not take any arguments, and do not select an input source using the +.code @(next) +directive, or suppress the use of an input source using +.codn "@(next nil)" , +may now accidentally read from standard input. .IP 165 A value of 165 restores the following behaviors, which changed starting in 166. There was a in Lisp evaluation support of the \*(TX pattern language. -- cgit v1.2.3