summaryrefslogtreecommitdiff
path: root/ext
AgeCommit message (Collapse)Author
2024-10-15[ruby/json] Update gemspec filesJean Boussier
https://github.com/ruby/json/commit/0f9564104f
2024-10-12[DOC] Fix spellingJohn Bampton
Notes: Merged: https://github.com/ruby/ruby/pull/11884 Merged-By: nobu <nobu@ruby-lang.org>
2024-10-12Support `IO#timeout` for `rsock_connect`. (#11880)Samuel Williams
Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2024-10-11Fix an implicit conversion that loses integer precisionNobuyoshi Nakada
Both `rb_ensure` and `udp_bind_internal` return `VALUE`.
2024-10-11Update `rsock_connect` to take `VALUE io` argument. (#11847)Samuel Williams
Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2024-10-10[ruby/fiddle] Cast via `VALUE` function pointer between objectNobuyoshi Nakada
pointer (https://github.com/ruby/fiddle/pull/150) With gcc 13 and -pedantic: ``` ../../../src/ext/fiddle/function.c: In function ‘function_call’: ../../../src/ext/fiddle/function.c:374:15: error: ISO C forbids conversion of object pointer to function pointer type [-Wpedantic] 374 | args.fn = (void(*)(void))NUM2PTR(cfunc); | ^ ../../../src/ext/fiddle/pointer.c: In function ‘rb_fiddle_ptr_inspect’: ../../../src/ext/fiddle/pointer.c:573:84: error: ISO C forbids conversion of function pointer to object pointer type [-Wpedantic] 573 | RB_OBJ_CLASSNAME(self), (void *)data, data->ptr, data->size, (void *)data->free); | ^ ``` https://github.com/ruby/fiddle/commit/6421e317a1
2024-10-10[ruby/digest] Cast via `uintptr_t` function pointer between object pointerNobuyoshi Nakada
https://github.com/ruby/digest/commit/661d4643ef
2024-10-10Move directives outside `rb_ary_new3` callNobuyoshi Nakada
This function may be a macro for optimization, which will be expanded to `rb_ary_new_from_values`. ``` ext/socket/ancdata.c: In function ‘bsock_recvmsg_internal’: ext/socket/ancdata.c:1648:1: error: embedding a directive within macro arguments is not portable 1648 | #if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL) | ^ ext/socket/ancdata.c:1650:1: error: embedding a directive within macro arguments is not portable 1650 | #else | ^ ext/socket/ancdata.c:1652:1: error: embedding a directive within macro arguments is not portable 1652 | #endif | ^ ```
2024-10-10Cast via `uintptr_t` function pointer between object pointerNobuyoshi Nakada
2024-10-10Import JRuby implementation (#147)Sutou Kouhei
Fix GH-104 lib/fiddle/jruby.rb is based on https://github.com/jruby/jruby/blob/master/lib/ruby/stdlib/fiddle/jruby.rb . Here are changes for it: * Move `Fiddle::TYPE_*` to `Fiddle::Types::*` * Add `Fiddle::Types::VARIADIC` * Add `Fiddle::Types::CONST_STRING` * Add `Fiddle::Types::BOOL` * Add `Fiddle::Types::INT8_T` * Add `Fiddle::Types::UINT8_T` * Add `Fiddle::Types::INT16_T` * Add `Fiddle::Types::UINT16_T` * Add `Fiddle::Types::INT32_T` * Add `Fiddle::Types::UINT32_T` * Add `Fiddle::Types::INT64_T` * Add `Fiddle::Types::UINT64_T` * Add more `Fiddle::ALIGN_*` for the above new `Fiddle::Types::*` * Add more `Fiddle::SIZEOF_*` for the above new `Fiddle::Types::*` * Add support for specifying type as not only `Fiddle::Types::*` but also `Symbol` like `:int` * Add support for variable size arguments in `Fiddle::Function` * Add `Fiddle::Closure#free` * Add `Fiddle::Closure#freed?` * Add `Fiddle::Error` as base the error class * Add `Fiddle::Pointer#call_free` and stop using `FFI::AutoPointer` in `Fiddle::Pointer` * Add support for `Fiddle::Pointer.malloc {}` `Fiddle::Pointer` * Add support for `Fiddle::Pointer#free=` * Add `Fiddle::Pointer#freed?` * Use binary string not C string for `Fiddle::Pointer#[]` * Add `Fiddle::Handle.sym_defined?` * Add `Fiddle::Handle#sym_defined?` * Add `Fiddle::Handle::DEFAULT` * Add `Fiddle::ClearedReferenceError` * Add no-op `Fiddle::Pinned` Some features are still "not implemented". So there are some "omit"s for JRuby in tests. Notes: Merged: https://github.com/ruby/ruby/pull/11860
2024-10-09Update `Socket#recvfrom` to use `rb_io_blocking_region`.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/11844
2024-10-09Update `Socket#accept` to use `rb_io_blocking_region`.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/11844
2024-10-09Update `UDPSocket#send` to use `rb_io_blocking_region`.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/11844
2024-10-09Update `IPSocket` to use `rb_io_descriptor` and `rb_io_mode`.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/11796
2024-10-09Update `UNIXSocket` to use `rb_io_blocking_region`.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/11796
2024-10-09Update `BasicSocket` to use `rb_io_blocking_region`.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/11796
2024-10-09Sync from ruby/win32-registryHiroshi SHIBATA
Notes: Merged: https://github.com/ruby/ruby/pull/11791
2024-10-08Cast via `uintptr_t` function pointer between object pointerNobuyoshi Nakada
- ISO C forbids conversion of function pointer to object pointer type - ISO C forbids conversion of object pointer to function pointer type
2024-10-08[ruby/json] generator.c: better fix for comparison of integers of different ↵Jean Boussier
signs https://github.com/ruby/json/commit/c372dc9268
2024-10-08Extract ext/win32/lib/win32/sspi.rb to ruby/win32-sspiHiroshi SHIBATA
Notes: Merged: https://github.com/ruby/ruby/pull/11829
2024-10-08Fixed C23 compilation error with ruby/ruby masterHiroshi SHIBATA
2024-10-08[ruby/json] Unicode string like § is not allowed in C files at ruby/ruby repoHiroshi SHIBATA
https://github.com/ruby/json/commit/53409bcc74
2024-10-08[ruby/json] Fix compilation warningJean Boussier
``` generator.c:69:27: warning: comparison of integers of different signs: 'short' and 'unsigned long' [-Wsign-compare] for (i = 1; i < ch_len; i++) { ``` https://github.com/ruby/json/commit/ff8edcd47c
2024-10-08[ruby/json] generator.c: Optimize by combining calls to fbuffer_appendLuke T. Shumaker
https://github.com/ruby/json/commit/62301c0bc3
2024-10-08[ruby/json] Adjust to the CVTUTF code being goneLuke T. Shumaker
I, Luke T. Shumaker, am the sole author of the added code. I did not reference CVTUTF when writing it. I did reference the Unicode standard (15.0.0), the Wikipedia article on UTF-8, and the Wikipedia article on UTF-16. When I saw some tests fail, I did reference the old deleted code (but a JSON-specific part, inherently not as based on CVTUTF) to determine that script_safe should also escape U+2028 and U+2029. I targeted simplicity and clarity when writing the code--it can likely be optimized. In my mind, the obvious next optimization is to have it combine contiguous non-escaped characters into just one call to fbuffer_append(), instead of calling fbuffer_append() for each character. Regarding the use of the "modern" types `uint32_t`, `uint16_t`, and `bool`: - ruby.h is guaranteed to give us uint32_t and uint16_t. - Since Ruby 3.0.0, ruby.h is guaranteed to give us bool... but we support down to Ruby 2.3. But, ruby.h is guaranteed to give us HAVE_STDBOOL_H for the C99 stdbool.h; so use that to include stdbool.h if we can, and if not then fall back to a copy of the same bool definition that Ruby 3.0.5 uses with C89. https://github.com/ruby/json/commit/c96351f874
2024-10-08[ruby/json] Delete code that is based on CVTUTFLuke T. Shumaker
I did this based on manual inspection, comparing the code to my re-created history of CVTUTF at https://git.lukeshu.com/2git/cvtutf/ (created by the scripts at https://git.lukeshu.com/2git/cvtutf-make/) https://github.com/ruby/json/commit/0819553144
2024-10-08[ruby/json] Update all links to the repository following transfertJean Boussier
https://github.com/ruby/json/commit/1edfeb8f10
2024-10-07[DOC] Add some descriptions for options of `Socket::tcp`v3_4_0_preview2Misaki Shioi
Notes: Merged: https://github.com/ruby/ruby/pull/11813 Merged-By: nobu <nobu@ruby-lang.org>
2024-10-04Allow method chaining with Pathname#mkpathschneems
Currently in my code when I want to create a pathname object and create a path at the same time I must use tap ``` path = Pathname.new("/tmp/new").tap(&:mkpath) ``` I think it would be cleaner to be able to chain on the results of these methods instead: ``` path = Pathname.new("/tmp/new").mkpath ``` Notes: Merged: https://github.com/ruby/ruby/pull/3705
2024-10-04Introduce Pathname.mktmpdirschneems
When I want to create a tmpdir I often want to manipulate it as a pathname. By introducing Pathname.mktmpdir I can get this behavior. Currently I must: ```ruby Dir.mktmpdir do |dir| dir = Pathname(dir) # ... code end ``` I would like to be able to instead: ```ruby Pathname.mktmpdir do |dir| # ... code end ``` Notes: Merged: https://github.com/ruby/ruby/pull/3709
2024-10-03[flori/json] Optimize key type check in `json_object_i`Jean Boussier
Rather than checking the class we can check the type. This is very subtly different for String subclasses, but I think it's OK. We also save on checking the type again in the fast path. https://github.com/flori/json/commit/772a0201ab Notes: Merged: https://github.com/ruby/ruby/pull/11775
2024-10-03[flori/json] Optimize `fbuffer_inc_capa`Jean Boussier
On my `JSON.dump` benchmark it shows up as 6% of runtime, compared to 40% for `convert_UTF8_to_JSON`. Since the vast majority of the time this function is called we still have some buffer capacity, we might as well check that first and skip the expensive loop etc. With this change my profiler now report this function as 0.7%, so almost 10x better. https://github.com/flori/json/commit/a7206bf2db Notes: Merged: https://github.com/ruby/ruby/pull/11775
2024-10-03[flori/json] JSON.dump: avoid redundant UTF-8 validationJean Boussier
Given that we called `rb_enc_str_asciionly_p`, if the string encoding isn't valid UTF-8, we can't know it very cheaply by checking the encoding and coderange that was just computed by Ruby, rather than to do it ourselves. Also Ruby might have already computed that earlier. https://github.com/flori/json/commit/4b04c469d5 Notes: Merged: https://github.com/ruby/ruby/pull/11775
2024-10-03[DOC] [pty] Add clean up to `PTY.spawn`Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/11773
2024-09-29win32/sspi: Use `start_with?` to see prefixNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/11722
2024-09-29win32/sspi: Rafactor pack/unpackNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/11722
2024-09-29win32/sspi: For Ractor use a constant instead of a class variableNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/11722
2024-09-29win32/sspi: Fix missing A suffix in an API constant nameNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/11722
2024-09-29win32/sspi: Fix Win32::SSPI::SSPIResult#== with IntegerNobuyoshi Nakada
The values of `@@map` are `Symbol`s and `@value` should be an `Integer` since unpacked as unsigned long, so this comparison should be false always. Probably comparison with `Symbol` was intended. Notes: Merged: https://github.com/ruby/ruby/pull/11722
2024-09-29win32/sspi: Already Fixnum has been removed years agoNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/11722
2024-09-26[ruby/digest] Import patches for old macOS from MacPortsNobuyoshi Nakada
https://github.com/ruby/digest/commit/07a5db2f77
2024-09-25Fix memory leak in Ripper for indented heredocsPeter Zhu
The allocated parser string is never freed, which causes a memory leak. The following code leaks memory: Ripper.sexp_raw(DATA.read) __END__ <<~EOF a #{1} a EOF Notes: Merged: https://github.com/ruby/ruby/pull/11669
2024-09-25[win32/registry] Fallback to UTF-8 for unknown codepagesJosh Cooper
There are some codepages like cp708 for which no ruby encoding exists: $ ruby -e "Encoding.find('cp708')" Traceback (most recent call last): 1: from -e:1:in `<main>' -e:1:in `find': unknown encoding name - cp708 (ArgumentError) win32/registry uses ENCODING to transcode error messages and expand environment variables from UTF-16LE, so using UTF-8 seems like the best choice and is better than a hard failure. This should resolve [Bug #13831] Notes: Merged: https://github.com/ruby/ruby/pull/7366
2024-09-24[ruby/psych] Use `String#match?` over `String#=~` when applicableJean Boussier
Save on allocating useless `MatchData` instances. https://github.com/ruby/psych/commit/b2d9f16e58
2024-09-22Reuse dedent_string function in rb_ruby_ripper_dedent_string functionS-H-GAMELINKS
This change is reduce Ruby C API dependency for Universal Parser. Reuse dedent_string functions in rb_ruby_ripper_dedent_string functions and remove dependencies on rb_str_modify and rb_str_set_len from the parser. Notes: Merged: https://github.com/ruby/ruby/pull/11658
2024-09-17[ruby/strscan] Accept String as a pattern at non headNAITOH Jun
(https://github.com/ruby/strscan/pull/106) It supports non-head match cases such as StringScanner#scan_until. If we use a String as a pattern, we can improve match performance. Here is a result of the including benchmark. ## CRuby It shows String as a pattern is 1.18x faster than Regexp as a pattern. ``` $ benchmark-driver benchmark/check_until.yaml Warming up -------------------------------------- regexp 9.403M i/s - 9.548M times in 1.015459s (106.35ns/i) regexp_var 9.162M i/s - 9.248M times in 1.009479s (109.15ns/i) string 8.966M i/s - 9.274M times in 1.034343s (111.54ns/i) string_var 11.051M i/s - 11.190M times in 1.012538s (90.49ns/i) Calculating ------------------------------------- regexp 10.319M i/s - 28.209M times in 2.733707s (96.91ns/i) regexp_var 10.032M i/s - 27.485M times in 2.739807s (99.68ns/i) string 9.681M i/s - 26.897M times in 2.778397s (103.30ns/i) string_var 12.162M i/s - 33.154M times in 2.726046s (82.22ns/i) Comparison: string_var: 12161920.6 i/s regexp: 10318949.7 i/s - 1.18x slower regexp_var: 10031617.6 i/s - 1.21x slower string: 9680843.7 i/s - 1.26x slower ``` ## JRuby It shows String as a pattern is 2.11x faster than Regexp as a pattern. ``` $ benchmark-driver benchmark/check_until.yaml Warming up -------------------------------------- regexp 7.591M i/s - 7.544M times in 0.993780s (131.74ns/i) regexp_var 6.143M i/s - 6.125M times in 0.997038s (162.77ns/i) string 14.135M i/s - 14.079M times in 0.996067s (70.75ns/i) string_var 14.079M i/s - 14.057M times in 0.998420s (71.03ns/i) Calculating ------------------------------------- regexp 9.409M i/s - 22.773M times in 2.420268s (106.28ns/i) regexp_var 10.116M i/s - 18.430M times in 1.821820s (98.85ns/i) string 21.389M i/s - 42.404M times in 1.982519s (46.75ns/i) string_var 20.897M i/s - 42.237M times in 2.021187s (47.85ns/i) Comparison: string: 21389191.1 i/s string_var: 20897327.5 i/s - 1.02x slower regexp_var: 10116464.7 i/s - 2.11x slower regexp: 9409222.3 i/s - 2.27x slower ``` See: https://github.com/jruby/jruby/blob/be7815ec02356a58891c8727bb448f0c6a826d96/core/src/main/java/org/jruby/util/StringSupport.java#L1706-L1736 --------- https://github.com/ruby/strscan/commit/f9d96c446a Co-authored-by: Sutou Kouhei <kou@clear-code.com>
2024-09-13Prevent warnings "the block passed to ... may be ignored"Yusuke Endoh
Notes: Merged: https://github.com/ruby/ruby/pull/11611
2024-09-11[ruby/psych] Ensure strings with only underscores are not processed as IntegerJohn Meade
A string similar to "0x____" should be treated as a string. Currently it is processed as an Integer. This alters the regex specified by http://yaml.org/type/int.html to ensure at least one numerical symbol is present in the string before converting to Integer. https://github.com/ruby/psych/commit/81479b203e
2024-09-11[ruby/pathname] use delete_prefix instead of sub in find methodIvan Kuchin
delete_prefix with a string is easier to read than a regular expression also it should be faster. It is available since ruby 2.5 and the gem requires ruby 2.7. https://github.com/ruby/pathname/commit/0070f43f19
2024-09-10[ruby/resolv] Add spec extensionsNobuyoshi Nakada
https://github.com/ruby/resolv/commit/3189d16b69