•GetLine

This commit is contained in:
dzaima 2021-07-25 20:02:48 +03:00
parent 64b3a4ae6a
commit 25c89c06b1
2 changed files with 16 additions and 1 deletions

View File

@ -452,6 +452,19 @@ B delay_c1(B t, B x) {
B exit_c1(B t, B x) {
bqn_exit(q_i32(x)? o2i(x) : 0);
}
B getLine_c1(B t, B x) {
dec(x);
char* ln = NULL;
size_t gl = 0;
i64 read = getline(&ln, &gl, stdin);
if (read<=0 || ln[0]==0) {
if (ln) free(ln);
return m_c32(0);
}
B r = fromUTF8(ln, strlen(ln)-1);
free(ln);
return r;
}
B getInternalNS(void);
B getMathNS(void);
@ -468,6 +481,7 @@ B sys_c1(B t, B x) {
if (eqStr(c, U"out")) r.a[i] = inc(bi_out);
else if (eqStr(c, U"show")) r.a[i] = inc(bi_show);
else if (eqStr(c, U"exit")) r.a[i] = inc(bi_exit);
else if (eqStr(c, U"getline")) r.a[i] = inc(bi_getLine);
else if (eqStr(c, U"file")) {
if(fileNS.u==m_f64(0).u) {
#define F(X) m_nfn(X##Desc, path_dir(inc(comp_currPath))),

View File

@ -7,7 +7,8 @@
/* sfns.c*/A(shape,"") A(pick,"") A(pair,"{𝕨‿𝕩}") A(select,"") A(slash,"/") A(join,"") A(couple,"") A(shiftb,"»") A(shifta,"«") A(take,"") A(drop,"") A(group,"") A(reverse,"") \
/* sort.c*/A(gradeUp,"") A(gradeDown,"") \
/* sysfn.c*/M(type,"•Type") M(decp,"•Decompose") M(primInd,"•PrimInd") M(glyph,"•Glyph") A(fill,"•FillFn") M(sys,"•getsys") A(grLen,"•GroupLen") D(grOrd,"•groupOrd") \
/* sysfn.c*/M(repr,"•Repr") A(asrt,"!") A(casrt,"!") M(out,"•Out") M(show,"•Show") M(bqn,"•BQN") D(cmp,"•Cmp") A(hash,"•Hash") M(delay,"•Delay") M(makeRand,"•MakeRand") M(exit,"•Exit") \
/* sysfn.c*/M(repr,"•Repr") A(asrt,"!") A(casrt,"!") M(out,"•Out") M(show,"•Show") M(bqn,"•BQN") \
/* sysfn.c*/D(cmp,"•Cmp") A(hash,"•Hash") M(delay,"•Delay") M(makeRand,"•MakeRand") M(exit,"•Exit") M(getLine,"•GetLine") \
/*internal.c*/M(itype,"•internal.Type") M(refc,"•internal.Refc") M(squeeze,"•internal.Squeeze") M(isPure,"•internal.IsPure") A(info,"•internal.Info") \
/*internal.c*/D(variation,"•internal.Variation") A(listVariations,"•internal.ListVariations") M(clearRefs,"•internal.ClearRefs") M(unshare,"•internal.Unshare")