change directive reader to ignore shebang
This commit is contained in:
parent
fe30beadf1
commit
bbeee8f10e
19
src/read.c
19
src/read.c
|
@ -117,6 +117,8 @@ read_datum_comment(pic_state *pic, struct pic_port *port, char c)
|
||||||
static pic_value
|
static pic_value
|
||||||
read_directive(pic_state *pic, struct pic_port *port, char c)
|
read_directive(pic_state *pic, struct pic_port *port, char c)
|
||||||
{
|
{
|
||||||
|
UNUSED(pic);
|
||||||
|
|
||||||
c = next(port);
|
c = next(port);
|
||||||
|
|
||||||
if (c == 'n') {
|
if (c == 'n') {
|
||||||
|
@ -124,7 +126,8 @@ read_directive(pic_state *pic, struct pic_port *port, char c)
|
||||||
/* :FIXME: set no-fold-case flag */
|
/* :FIXME: set no-fold-case flag */
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
goto abort;
|
xfseek(port->file, -1, SEEK_CUR);
|
||||||
|
goto shebang;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (c == 'f') {
|
else if (c == 'f') {
|
||||||
|
@ -132,12 +135,13 @@ read_directive(pic_state *pic, struct pic_port *port, char c)
|
||||||
/* :FIXME: set fold-case flag */
|
/* :FIXME: set fold-case flag */
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
goto abort;
|
xfseek(port->file, -1, SEEK_CUR);
|
||||||
|
goto shebang;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
abort:
|
shebang:
|
||||||
pic_error(pic, "unknown directive");
|
while(xfgetc(port->file) != '\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
return pic_undef_value();
|
return pic_undef_value();
|
||||||
|
@ -704,13 +708,6 @@ 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