Skip to content

Commit 31154a3

Browse files
committed
Parse tempfile
1 parent 30ab410 commit 31154a3

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/util/pm_string.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ PRISM_EXPORTED_FUNCTION bool
6262
pm_string_mapped_init(pm_string_t *string, const char *filepath) {
6363
#ifdef _WIN32
6464
// Open the file for reading.
65-
HANDLE file = CreateFile(filepath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
65+
HANDLE file = CreateFile(filepath, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL);
6666

6767
if (file == INVALID_HANDLE_VALUE) {
6868
return false;
@@ -156,7 +156,7 @@ PRISM_EXPORTED_FUNCTION bool
156156
pm_string_file_init(pm_string_t *string, const char *filepath) {
157157
#ifdef _WIN32
158158
// Open the file for reading.
159-
HANDLE file = CreateFile(filepath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
159+
HANDLE file = CreateFile(filepath, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL);
160160

161161
if (file == INVALID_HANDLE_VALUE) {
162162
return false;

test/prism/api/parse_test.rb

+8
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ def test_parse_file
6161
end
6262
end
6363

64+
def test_parse_tempfile
65+
Tempfile.create(["test_parse_tempfile", ".rb"]) do |t|
66+
t.puts ["begin\n", " end\n"]
67+
t.flush
68+
Prism.parse_file(t.path)
69+
end
70+
end
71+
6472
private
6573

6674
def find_source_file_node(program)

0 commit comments

Comments
 (0)