🚀 input now can choose `std::getline` to read one line.
This commit is contained in:
parent
c0862704f0
commit
52fcc9118c
4
lib.nas
4
lib.nas
|
@ -25,8 +25,8 @@ var system=func(str){
|
|||
}
|
||||
|
||||
# input uses std::cin and returns what we input.
|
||||
var input=func(){
|
||||
return __input();
|
||||
var input=func(end=nil){
|
||||
return __input(end);
|
||||
}
|
||||
|
||||
# split a string by separator for example:
|
||||
|
|
|
@ -277,8 +277,12 @@ nas_ref builtin_system(nas_ref* local,nasal_gc& gc)
|
|||
}
|
||||
nas_ref builtin_input(nas_ref* local,nasal_gc& gc)
|
||||
{
|
||||
nas_ref end=local[1];
|
||||
nas_ref ret=gc.alloc(vm_str);
|
||||
std::cin>>ret.str();
|
||||
if(end.type!=vm_str || end.str().length()>1)
|
||||
std::cin>>ret.str();
|
||||
else
|
||||
std::getline(std::cin,ret.str(),end.str()[0]);
|
||||
return ret;
|
||||
}
|
||||
nas_ref builtin_fin(nas_ref* local,nasal_gc& gc)
|
||||
|
|
|
@ -25,8 +25,8 @@ var system=func(str){
|
|||
}
|
||||
|
||||
# input uses std::cin and returns what we input.
|
||||
var input=func(){
|
||||
return __input();
|
||||
var input=func(end=nil){
|
||||
return __input(end);
|
||||
}
|
||||
|
||||
# split a string by separator for example:
|
||||
|
|
Loading…
Reference in New Issue