summaryrefslogtreecommitdiffstats
path: root/txr.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2011-11-23 13:36:27 -0800
committerKaz Kylheku <kaz@kylheku.com>2011-11-23 13:36:27 -0800
commit73126c7aff72a9eb688e29ea557780c4d9ba5f47 (patch)
tree7cdfe6f60a48d0ce02b327c54507b5a99b9de801 /txr.c
parent41fc1ec1db8a937c893520589fb5af5ae01c693b (diff)
downloadtxr-73126c7aff72a9eb688e29ea557780c4d9ba5f47.tar.gz
txr-73126c7aff72a9eb688e29ea557780c4d9ba5f47.tar.bz2
txr-73126c7aff72a9eb688e29ea557780c4d9ba5f47.zip
* 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).
Diffstat (limited to 'txr.c')
-rw-r--r--txr.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/txr.c b/txr.c
index 21e30f87..c8d7b5e9 100644
--- a/txr.c
+++ b/txr.c
@@ -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;