+added a SYS statement to the shell.

This commit is contained in:
paladin-t 2016-02-18 19:19:46 +08:00
parent a786ec13c3
commit 65f50ebeca
2 changed files with 21 additions and 1 deletions

View File

@ -1,5 +1,6 @@
Feb. 18 2016
Added a generic iterator type
Added a SYS statement to the shell
Fixed a wrong list linkage bug with list sorting
Feb. 16 2016

View File

@ -1102,7 +1102,7 @@ static int_t _ticks(void) {
clock_gettime(CLOCK_MONOTONIC, &ts);
return ts.tv_sec * 1000 + ts.tv_nsec / 1000000;
return (int_t)(ts.tv_sec * 1000 + ts.tv_nsec / 1000000);
}
#else /* _MSC_VER */
# undef _HAS_TICKS
@ -1171,6 +1171,24 @@ static int set_importing_dirs(struct mb_interpreter_t* s, void** l) {
return result;
}
static int sys(struct mb_interpreter_t* s, void** l) {
int result = MB_FUNC_OK;
char* arg = 0;
mb_assert(s && l);
mb_check(mb_attempt_open_bracket(s, l));
mb_check(mb_pop_string(s, l, &arg));
mb_check(mb_attempt_close_bracket(s, l));
if(arg)
system(arg);
return result;
}
static int trace(struct mb_interpreter_t* s, void** l) {
int result = MB_FUNC_OK;
char* frames[16];
@ -1300,6 +1318,7 @@ static void _on_startup(void) {
#endif /* _HAS_TICKS */
mb_reg_fun(bas, now);
mb_reg_fun(bas, set_importing_dirs);
mb_reg_fun(bas, sys);
mb_reg_fun(bas, trace);
mb_reg_fun(bas, gc);
mb_reg_fun(bas, beep);