Skip to content

Commit

Permalink
GH-64 Fix misplaced return stack underflow check. Fix Post4.repl()
Browse files Browse the repository at this point in the history
forgot to set the initial input source to standard input.  Remove
Post4.repl() loop around p4Repl().
  • Loading branch information
SirWumpus committed Nov 9, 2024
1 parent 1396cdc commit 82d237a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
1 change: 1 addition & 0 deletions jni/Post4.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ Java_post4_jni_Post4_repl(JNIEnv *env, jobject self)
ctx->jenv = env;
sig_init();
rc = SETJMP(sig_break_glass);
p4ResetInput(ctx, stdin);
rc = p4Repl(ctx, P4_THROW_OK);
sig_fini();
return rc;
Expand Down
5 changes: 1 addition & 4 deletions jni/Post4.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ protected void finalize()

public static void main(String[] args)
{
int rc;
Post4 p4 = new Post4(args);

if (0 < args.length) {
Expand All @@ -76,9 +75,7 @@ public static void main(String[] args)
"""
);

while ((rc = p4.repl()) != Post4Exception.THROW_OK) {
; // Remain in the REPL until EOF or BYE.
}
p4.repl();
} catch (Exception e) {
// Something else happened on this day, lost in time.
System.err.println(e);
Expand Down
3 changes: 1 addition & 2 deletions src/post4.c
Original file line number Diff line number Diff line change
Expand Up @@ -1331,7 +1331,6 @@ _quit: P4_RESET(ctx->rs);
;
}
ip = (P4_Cell *)(repl+1);

// (S: -- )
_interpret:
P4_PUSH(ctx->rs, ip);
Expand Down Expand Up @@ -1387,8 +1386,8 @@ _forth: exec[0].xt = word;
(void) printf(ANSI_CYAN"ok "ANSI_NORMAL);
(void) fflush(stdout);
}
p4StackIsEmpty(ctx, &ctx->rs, P4_THROW_RS_UNDER);
} while (p4Refill(ctx->input));
p4StackIsEmpty(ctx, &ctx->rs, P4_THROW_RS_UNDER);
ip = P4_POP(ctx->rs).p;
NEXT;

Expand Down

0 comments on commit 82d237a

Please sign in to comment.