diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2011-11-23 10:46:32 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2011-11-23 10:46:32 -0800 |
commit | c1202a71a068c13a17b69348a6d7736b8855be0c (patch) | |
tree | eb2121adb2e75b6d2a0838d152a8c5b6c161ac1f /txr.c | |
parent | e1174f5ea6ff0a51738830e10a92819135a22b32 (diff) | |
download | txr-c1202a71a068c13a17b69348a6d7736b8855be0c.tar.gz txr-c1202a71a068c13a17b69348a6d7736b8855be0c.tar.bz2 txr-c1202a71a068c13a17b69348a6d7736b8855be0c.zip |
Semantics change. If a variable is followed by a mixture
of text and regular expressions, that whole mixture is
considered to follow the variable and used for matching.
The earlier semantics change whereby a single unescaped
space denotes the regular expression / +/ broke the
simple case @a word. It caused the @a to be followed
not by the text " word" but by just the regular expression
element.
With this change @a word means that a is followed by
the regex / +/ and "word".
* match.c (text_s): New symbol variable.
(h_text): New function.
(syms_init): Initialize new symbol variable.
(dir_tables_init): Hook h_text into horizontal directives table.
* match.h (text_s): Declared.
* parser.y (text, texts): New nonterminals.
(elem): TEXT, SPACE and regex are now handled under texts
grammar production. All texts are run together and produce
an item which looks like (text items ...).
* txr.1, RELNOTES: Updated.
* txr.c (remove_hash_bang_line): Updated to find #! buried
in (text ...) syntax.
Diffstat (limited to 'txr.c')
-rw-r--r-- | txr.c | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -130,11 +130,15 @@ static val remove_hash_bang_line(val spec) { val shbang = string(L"#!"); val firstline = first(spec); - - if (stringp(first(firstline))) { - val twochars = sub_str(first(firstline), zero, two); - if (equal(twochars, shbang)) - return rest(spec); + val firstelem = first(firstline); + + if (consp(firstelem) && first(firstelem) == text_s) { + val item = second(firstelem); + if (stringp(item)) { + val twochars = sub_str(item, zero, two); + if (equal(twochars, shbang)) + return rest(spec); + } } return spec; |