support #!fold-case directive
This commit is contained in:
parent
f639734cb1
commit
52aa837bea
|
@ -94,6 +94,7 @@ typedef struct {
|
|||
xhash macros;
|
||||
pic_value libs;
|
||||
|
||||
bool rfcase;
|
||||
xhash rlabels;
|
||||
|
||||
jmp_buf *jmp;
|
||||
|
|
10
src/read.c
10
src/read.c
|
@ -134,13 +134,13 @@ read_directive(pic_state *pic, struct pic_port *port, int c)
|
|||
switch ((char)peek(port)) {
|
||||
case 'n':
|
||||
if (expect(port, "no-fold-case")) {
|
||||
/* :FIXME: set no-fold-case flag */
|
||||
pic->rfcase = false;
|
||||
return pic_undef_value();
|
||||
}
|
||||
break;
|
||||
case 'f':
|
||||
if (expect(port, "fold-case")) {
|
||||
/* :FIXME: set fold-case flag */
|
||||
pic->rfcase = true;
|
||||
return pic_undef_value();
|
||||
}
|
||||
break;
|
||||
|
@ -191,13 +191,15 @@ read_symbol(pic_state *pic, struct pic_port *port, int c)
|
|||
if (len != 0) {
|
||||
c = next(port);
|
||||
}
|
||||
if (pic->rfcase) {
|
||||
c = tolower(c);
|
||||
}
|
||||
len += 1;
|
||||
buf = pic_realloc(pic, buf, len + 1);
|
||||
buf[len - 1] = (char)c;
|
||||
} while (! isdelim(peek(port)));
|
||||
|
||||
buf[len] = '\0';
|
||||
sym = pic_intern_cstr(pic, buf);
|
||||
sym = pic_intern(pic, buf, len);
|
||||
pic_free(pic, buf);
|
||||
|
||||
return pic_sym_value(sym);
|
||||
|
|
|
@ -59,6 +59,7 @@ pic_open(int argc, char *argv[], char **envp)
|
|||
pic->lib = NULL;
|
||||
|
||||
/* reader */
|
||||
pic->rfcase = false;
|
||||
xh_init_int(&pic->rlabels, sizeof(pic_value));
|
||||
|
||||
/* error handling */
|
||||
|
|
Loading…
Reference in New Issue