diff options
author | Kevin Newton <[email protected]> | 2024-08-21 14:47:10 -0400 |
---|---|---|
committer | Kevin Newton <[email protected]> | 2024-08-21 16:59:03 -0400 |
commit | 773cf883ac75f0f207f8e468461d19f008dba118 (patch) | |
tree | 8010382c740658e3718821d4ec92f3850767e0bd /prism_compile.c | |
parent | f60499826f3a2845fced97556289c48f68be09e8 (diff) |
[PRISM] Reset $. when done reading STDIN
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/11425
Diffstat (limited to 'prism_compile.c')
-rw-r--r-- | prism_compile.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/prism_compile.c b/prism_compile.c index e72ce4957f..1b453b0ef4 100644 --- a/prism_compile.c +++ b/prism_compile.c @@ -10534,6 +10534,9 @@ pm_parse_stdin_fgets(char *string, int size, void *stream) return string; } +// We need access to this function when we're done parsing stdin. +void rb_reset_argf_lineno(long n); + /** * Parse the source off STDIN and store the resulting scope node in the given * parse result struct. It is assumed that the parse result object is zeroed @@ -10552,6 +10555,10 @@ pm_parse_stdin(pm_parse_result_t *result) // free the buffer itself. pm_string_owned_init(&result->input, (uint8_t *) pm_buffer_value(&buffer), pm_buffer_length(&buffer)); + // When we're done parsing, we reset $. because we don't want the fact that + // we went through an IO object to be visible to the user. + rb_reset_argf_lineno(0); + return pm_parse_process(result, node); } |