diff options
author | Kevin Newton <[email protected]> | 2024-09-11 16:49:08 -0400 |
---|---|---|
committer | Kevin Newton <[email protected]> | 2024-09-12 13:43:04 -0400 |
commit | 38ba15beed5eb9f3a4923f9a215473965f31a7bc () | |
tree | d08a137031db3343d37d733c57347d3ce8569f59 /lib/prism/ffi.rb | |
parent | ca61729fa7713f650c7e4144daa08932f8b66454 (diff) |
[ruby/prism] Check errno for parsing directory
https://.com/ruby/prism/commit/d68ea29d04
Notes: Merged: https://.com/ruby/ruby/pull/11497
-rw-r--r-- | lib/prism/ffi.rb | 18 |
1 files changed, 16 insertions, 2 deletions
@@ -72,6 +72,7 @@ module Prism end callback :pm_parse_stream_fgets_t, [:pointer, :int, :pointer], :pointer load_exported_functions_from( "prism.h", @@ -176,13 +177,26 @@ module Prism def self.with_file(filepath) raise TypeError unless filepath.is_a?(String) FFI::MemoryPointer.new(SIZEOF) do |pm_string| - if LibRubyParser.pm_string_mapped_init(pm_string, filepath) pointer = LibRubyParser.pm_string_source(pm_string) length = LibRubyParser.pm_string_length(pm_string) return yield new(pointer, length, false) - else raise SystemCallError.new(filepath, FFI.errno) end ensure LibRubyParser.pm_string_free(pm_string) |