mirror of
https://github.com/janet-lang/janet
synced 2025-12-07 09:08:07 +00:00
Readd the repl.
This commit is contained in:
@@ -422,7 +422,7 @@ static void dispatch_char(GstParser *p, uint8_t c) {
|
||||
}
|
||||
}
|
||||
/* Dispatch character to state */
|
||||
while (!done && (p->status == GST_PARSER_PENDING || p->status == GST_PARSER_ROOT)) {
|
||||
while (!done) {
|
||||
GstParseState *top = parser_peek(p);
|
||||
switch (top->type) {
|
||||
case PTYPE_ROOT:
|
||||
|
||||
16
core/stl.c
16
core/stl.c
@@ -391,6 +391,21 @@ int gst_stl_serialize(Gst *vm) {
|
||||
|
||||
/* TODO - add userdata to allow for manipulation of FILE pointers. */
|
||||
|
||||
int gst_stl_open(Gst *vm) {
|
||||
GstValue ret;
|
||||
const uint8_t *fname = gst_to_string(vm, gst_arg(vm, 0));
|
||||
const uint8_t *fmode = gst_to_string(vm, gst_arg(vm, 1));
|
||||
FILE *f;
|
||||
if (gst_count_args(vm) < 2)
|
||||
gst_c_throwc(vm, "expected filename and filemode");
|
||||
f = fopen((const char *)fname, (const char *)fmode);
|
||||
if (!f)
|
||||
gst_c_throwc(vm, "could not open file");
|
||||
ret.type = GST_USERDATA;
|
||||
ret.data.pointer = f;
|
||||
gst_c_return(vm, ret);
|
||||
}
|
||||
|
||||
/****/
|
||||
/* Bootstraping */
|
||||
/****/
|
||||
@@ -421,6 +436,7 @@ static const GstModuleItem const std_module[] = {
|
||||
{"rawset", gst_stl_rawset},
|
||||
{"error", gst_stl_error},
|
||||
{"serialize", gst_stl_serialize},
|
||||
{"open", gst_stl_open},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user