-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GH-62 Fix
ACCEPT
to read from standard input when the input source
a string or block.
- Loading branch information
Showing
4 changed files
with
46 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -654,35 +654,22 @@ p4Divs(P4_Int dend0, P4_Int dend1, P4_Int dsor, P4_Int *rem) | |
} | ||
|
||
/*********************************************************************** | ||
*** Input / Ouput | ||
*** Core | ||
***********************************************************************/ | ||
|
||
int | ||
p4Accept(P4_Input *input, char *buf, P4_Size size) | ||
{ | ||
if (input->fp == (FILE *) -1) { | ||
return EOF; | ||
} | ||
return alineInput(input->fp, "", buf, (size_t) size); | ||
} | ||
|
||
P4_Int | ||
p4Refill(P4_Input *input) | ||
{ | ||
int n; | ||
if (P4_INPUT_IS_STR(input) | ||
|| (n = p4Accept(input, input->buffer, P4_INPUT_SIZE)) < 0) { | ||
if (P4_INPUT_IS_EVAL(input) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
SirWumpus
Author
Owner
|
||
|| (n = alineInput(input->fp, "", input->buffer, P4_INPUT_SIZE)) < 0) { | ||
return P4_FALSE; | ||
} | ||
input->length = n; | ||
input->offset = 0; | ||
return P4_TRUE; | ||
} | ||
|
||
/*********************************************************************** | ||
*** Core | ||
***********************************************************************/ | ||
|
||
void | ||
p4WordFree(P4_Word *word) | ||
{ | ||
|
@@ -1110,6 +1097,8 @@ p4Repl(P4_Ctx *ctx, int thrown) | |
P4_WORD("fs>rs", &&_fs_to_rs, 0, 0x100100), // p4 | ||
P4_WORD("rs>fs", &&_rs_to_fs, 0, 0x011000), // p4 | ||
#endif | ||
P4_WORD("stdin", &&_fa_stdin, 0, 0x01), // p4 | ||
P4_WORD("stdout", &&_fa_stdout, 0, 0x01), // p4 | ||
P4_WORD("BIN", &&_fa_bin, 0, 0x01), | ||
P4_WORD("CLOSE-FILE", &&_fa_close, 0, 0x11), | ||
P4_WORD("CREATE-FILE", &&_fa_create, 0, 0x22), | ||
|
@@ -1962,7 +1951,7 @@ _source_id: P4_PUSH(ctx->ds, (P4_Int)(ctx->input->fp == stdin ? NULL : ctx->inpu | |
|
||
// ( caddr +n1 -- +n2 ) | ||
_accept: w = P4_DROPTOP(ctx->ds); | ||
if ((x.n = p4Accept(ctx->input, w.s, x.z)) < 0) { | ||
if ((x.n = alineInput(stdin, "", w.s, x.z)) < 0) { | ||
THROW(P4_THROW_BAD_EOF); | ||
} | ||
P4_TOP(ctx->ds) = x; | ||
|
@@ -2076,6 +2065,14 @@ _stack_dump: P4_DROP(ctx->ds, 1); | |
FILE *fp; | ||
struct stat sb; | ||
|
||
// ( -- fd ) | ||
_fa_stdin: P4_PUSH(ctx->ds, (void *) stdin); | ||
NEXT; | ||
|
||
// ( -- fd ) | ||
_fa_stdout: P4_PUSH(ctx->ds, (void *) stdout); | ||
NEXT; | ||
|
||
// ( fam1 -- fam2 ) | ||
_fa_bin: P4_TOP(ctx->ds).u = x.u | 2; | ||
NEXT; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
P4_INPUT_IS_EVAL
is true when the input source is a block. Thus,p4Refill
returns false in this case.But
REFILL
shall work for blocks, see 7.6.2.2125 REFILLPerhaps
REFILL
should be redefined insrc/post4.p4
to work correctly when the input source is a block.