2014-09-08 05:47:20 -04:00
|
|
|
/**
|
|
|
|
* See Copyright Notice in picrin.h
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "picrin.h"
|
2016-02-20 10:58:58 -05:00
|
|
|
#include "picrin/extra.h"
|
2014-09-08 05:47:20 -04:00
|
|
|
|
2015-01-17 10:32:52 -05:00
|
|
|
void
|
2016-02-20 02:51:24 -05:00
|
|
|
pic_load(pic_state *pic, pic_value port)
|
2014-09-08 05:47:20 -04:00
|
|
|
{
|
2014-09-08 05:50:15 -04:00
|
|
|
pic_value form;
|
2016-02-19 02:17:13 -05:00
|
|
|
size_t ai = pic_enter(pic);
|
2014-09-08 05:47:20 -04:00
|
|
|
|
2016-02-18 06:15:42 -05:00
|
|
|
while (! pic_eof_p(pic, form = pic_read(pic, port))) {
|
2016-02-18 03:39:32 -05:00
|
|
|
pic_eval(pic, form, pic_current_library(pic));
|
2014-09-08 05:47:20 -04:00
|
|
|
|
2016-02-19 02:17:13 -05:00
|
|
|
pic_leave(pic, ai);
|
2014-09-08 05:50:15 -04:00
|
|
|
}
|
|
|
|
}
|
2014-09-08 05:47:20 -04:00
|
|
|
|
2014-09-08 05:50:15 -04:00
|
|
|
void
|
2016-02-18 15:54:50 -05:00
|
|
|
pic_load_cstr(pic_state *pic, const char *str)
|
2014-09-08 05:50:15 -04:00
|
|
|
{
|
2016-02-25 06:52:38 -05:00
|
|
|
pic_value e, port = pic_open_port(pic, xfopen_buf(pic, str, strlen(str), "r"));
|
2014-09-08 05:47:20 -04:00
|
|
|
|
2015-06-26 10:45:56 -04:00
|
|
|
pic_try {
|
2015-07-12 19:20:07 -04:00
|
|
|
pic_load(pic, port);
|
2015-06-26 10:45:56 -04:00
|
|
|
}
|
2016-02-25 06:52:38 -05:00
|
|
|
pic_catch(e) {
|
2015-06-26 10:45:56 -04:00
|
|
|
pic_close_port(pic, port);
|
2016-02-25 06:52:38 -05:00
|
|
|
pic_raise(pic, e);
|
2015-06-26 10:45:56 -04:00
|
|
|
}
|
2014-09-08 05:47:20 -04:00
|
|
|
|
2014-09-08 05:50:15 -04:00
|
|
|
pic_close_port(pic, port);
|
2014-09-08 05:47:20 -04:00
|
|
|
}
|