diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | txr.c | 21 |
2 files changed, 20 insertions, 8 deletions
@@ -1,5 +1,12 @@ 2011-11-23 Kaz Kylheku <kaz@kylheku.com> + * txr.c (remove_hash_bang_line): Recognize multiple + syntax possibilities. A hash bang could be buried in a (text ...) + compound, or it could just be a string (thanks to the text form + optimization). + +2011-11-23 Kaz Kylheku <kaz@kylheku.com> + Optimization: if all the elements of (text ...) are strings, then replace the (text ...) by the catenation of those strings. @@ -131,14 +131,19 @@ static val remove_hash_bang_line(val spec) val shbang = string(L"#!"); val firstline = first(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); - } + val item; + + if (stringp(firstelem)) + item = firstelem; + else if (consp(firstelem) && first(firstelem) == text_s) + item = second(firstelem); + else + return spec; + + if (stringp(item)) { + val twochars = sub_str(item, zero, two); + if (equal(twochars, shbang)) + return rest(spec); } return spec; |