summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Newton <[email protected]>2024-09-11 10:42:08 -0400
committergit <[email protected]>2024-09-11 15:39:22 +0000
commit886fc69b1cfb20141608eb1f461b93e5a5464cf9 (patch)
tree6be13d13596c945d53fbbd5e4fa853ee58c7bb46
parent7facf2323206e244b53d3771a857a8f677d2ab3e (diff)
[ruby/prism] Parse tempfile
https://github.com/ruby/prism/commit/31154a389a
-rw-r--r--prism/util/pm_string.c4
-rw-r--r--test/prism/api/parse_test.rb8
2 files changed, 10 insertions, 2 deletions
diff --git a/prism/util/pm_string.c b/prism/util/pm_string.c
index 0a67accd86..4bd3dd8ef2 100644
--- a/prism/util/pm_string.c
+++ b/prism/util/pm_string.c
@@ -62,7 +62,7 @@ PRISM_EXPORTED_FUNCTION bool
pm_string_mapped_init(pm_string_t *string, const char *filepath) {
#ifdef _WIN32
// Open the file for reading.
- HANDLE file = CreateFile(filepath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ HANDLE file = CreateFile(filepath, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL);
if (file == INVALID_HANDLE_VALUE) {
return false;
@@ -156,7 +156,7 @@ PRISM_EXPORTED_FUNCTION bool
pm_string_file_init(pm_string_t *string, const char *filepath) {
#ifdef _WIN32
// Open the file for reading.
- HANDLE file = CreateFile(filepath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ HANDLE file = CreateFile(filepath, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL);
if (file == INVALID_HANDLE_VALUE) {
return false;
diff --git a/test/prism/api/parse_test.rb b/test/prism/api/parse_test.rb
index dda0d6959c..2e9722f5da 100644
--- a/test/prism/api/parse_test.rb
+++ b/test/prism/api/parse_test.rb
@@ -61,6 +61,14 @@ module Prism
end
end
+ def test_parse_tempfile
+ Tempfile.create(["test_parse_tempfile", ".rb"]) do |t|
+ t.puts ["begin\n", " end\n"]
+ t.flush
+ Prism.parse_file(t.path)
+ end
+ end
+
private
def find_source_file_node(program)