Skip to content

Commit f8a735f

Browse files
committed
Make fillcmd work with multiple Inputs.
It's not "per-Input", but it's largely equivalent, and I don't want to make Input a GC'd object just for a single field.
1 parent 2c74768 commit f8a735f

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

initial.es

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,11 +651,15 @@ if {~ <=$&primitives writehistory} {
651651
fn-%batch-loop = $&batchloop
652652
fn-%is-interactive = $&isinteractive
653653

654+
# NOTE: $&readline might not actually exist. we just assume it does for this
655+
# proof-of-concept.
656+
fn-%readline = $&readline
657+
654658
fn %parse {
655659
if %is-interactive {
656660
let (in = (); p = $*(1))
657661
let (code = <={$&parse {
658-
let (r = <={$&readline $p}) {
662+
let (r = <={%readline $p}) {
659663
in = $in $r
660664
p = $*(2)
661665
result $r

input.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,12 +219,20 @@ static int cmdfill(Input *in) {
219219
extern Tree *parse(List *fc) {
220220
int result;
221221
void *oldpspace;
222+
Ref(List *, oldfillcmd, fillcmd);
222223

223224
/* TODO: change this error message */
224225
if (input->parsing)
225226
fail("$&parse", "cannot perform nested parsing");
226227

227228
assert(input->error == NULL);
229+
230+
/* TODO: update this check --
231+
*
232+
* $ es -c '<={$&parse {result echo hello world}}'
233+
*
234+
* should work. also, ignoreeof
235+
*/
228236
if (ISEOF(input))
229237
throw(mklist(mkstr("eof"), NULL));
230238

@@ -250,7 +258,8 @@ extern Tree *parse(List *fc) {
250258
EndExceptionHandler
251259

252260
input->parsing = FALSE;
253-
fillcmd = NULL;
261+
fillcmd = oldfillcmd;
262+
RefEnd(oldfillcmd);
254263

255264
if (result || input->error != NULL) {
256265
const char *e = input->error;

0 commit comments

Comments
 (0)