Ignore shebang only when it's at the first line and allow reader directives at other places whlile ignores them for now
This commit is contained in:
parent
124ad994b2
commit
fe30beadf1
38
src/read.c
38
src/read.c
|
@ -114,6 +114,35 @@ read_datum_comment(pic_state *pic, struct pic_port *port, char c)
|
||||||
return pic_undef_value();
|
return pic_undef_value();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static pic_value
|
||||||
|
read_directive(pic_state *pic, struct pic_port *port, char c)
|
||||||
|
{
|
||||||
|
c = next(port);
|
||||||
|
|
||||||
|
if (c == 'n') {
|
||||||
|
if(expect(port, "o-fold-case")){
|
||||||
|
/* :FIXME: set no-fold-case flag */
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
goto abort;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (c == 'f') {
|
||||||
|
if(expect(port, "old-case")){
|
||||||
|
/* :FIXME: set fold-case flag */
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
goto abort;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
abort:
|
||||||
|
pic_error(pic, "unknown directive");
|
||||||
|
}
|
||||||
|
|
||||||
|
return pic_undef_value();
|
||||||
|
}
|
||||||
|
|
||||||
static pic_value
|
static pic_value
|
||||||
read_quote(pic_state *pic, struct pic_port *port, char c)
|
read_quote(pic_state *pic, struct pic_port *port, char c)
|
||||||
{
|
{
|
||||||
|
@ -541,7 +570,7 @@ read_dispatch(pic_state *pic, struct pic_port *port, char c)
|
||||||
|
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case '!':
|
case '!':
|
||||||
return read_comment(pic, port, c);
|
return read_directive(pic, port, c);
|
||||||
case '|':
|
case '|':
|
||||||
return read_block_comment(pic, port, c);
|
return read_block_comment(pic, port, c);
|
||||||
case ';':
|
case ';':
|
||||||
|
@ -675,6 +704,13 @@ pic_parse_file(pic_state *pic, FILE *file)
|
||||||
port->flags = PIC_PORT_OUT | PIC_PORT_TEXT;
|
port->flags = PIC_PORT_OUT | PIC_PORT_TEXT;
|
||||||
port->status = PIC_PORT_OPEN;
|
port->status = PIC_PORT_OPEN;
|
||||||
|
|
||||||
|
if(xfgetc(port->file) == '#' && xfgetc(port->file) == '!'){
|
||||||
|
while(xfgetc(port->file) != '\n');
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
xfseek(port->file, 0, SEEK_SET);
|
||||||
|
}
|
||||||
|
|
||||||
return pic_parse(pic, port);
|
return pic_parse(pic, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue