Commit graph

8776 commits

Author SHA1 Message Date
Nobuyoshi Nakada
d12fce7af3 [ruby/date] Check time zone offset elements
Too big parts of fractional hour time zone offset can cause assertion
failures.

06bcfb2729
2022-09-28 21:07:00 +09:00
Maciej Rzasa
b8e804e410 [ruby/bigdecimal] Document precision=0 and ndigits=0 for converting from Float
4f0894c6c0
2022-09-28 09:29:49 +09:00
Chad Wilson
1a06bc94d9 [ruby/psych] Bump snakeyaml from 1.31 to 1.33
8a761cdfb7
2022-09-28 00:11:05 +09:00
Aaron Patterson
06abfa5be6
Revert this until we can figure out WB issues or remove shapes from GC
Revert "* expand tabs. [ci skip]"

This reverts commit 830b5b5c35.

Revert "This commit implements the Object Shapes technique in CRuby."

This reverts commit 9ddfd2ca00.
2022-09-26 16:10:11 -07:00
Jemma Issroff
9ddfd2ca00 This commit implements the Object Shapes technique in CRuby.
Object Shapes is used for accessing instance variables and representing the
"frozenness" of objects.  Object instances have a "shape" and the shape
represents some attributes of the object (currently which instance variables are
set and the "frozenness").  Shapes form a tree data structure, and when a new
instance variable is set on an object, that object "transitions" to a new shape
in the shape tree.  Each shape has an ID that is used for caching. The shape
structure is independent of class, so objects of different types can have the
same shape.

For example:

```ruby
class Foo
  def initialize
    # Starts with shape id 0
    @a = 1 # transitions to shape id 1
    @b = 1 # transitions to shape id 2
  end
end

class Bar
  def initialize
    # Starts with shape id 0
    @a = 1 # transitions to shape id 1
    @b = 1 # transitions to shape id 2
  end
end

foo = Foo.new # `foo` has shape id 2
bar = Bar.new # `bar` has shape id 2
```

Both `foo` and `bar` instances have the same shape because they both set
instance variables of the same name in the same order.

This technique can help to improve inline cache hits as well as generate more
efficient machine code in JIT compilers.

This commit also adds some methods for debugging shapes on objects.  See
`RubyVM::Shape` for more details.

For more context on Object Shapes, see [Feature: #18776]

Co-Authored-By: Aaron Patterson <tenderlove@ruby-lang.org>
Co-Authored-By: Eileen M. Uchitelle <eileencodes@gmail.com>
Co-Authored-By: John Hawthorn <john@hawthorn.email>
2022-09-26 09:21:30 -07:00
Samuel Williams
a95b741a97 [ruby/bigdecimal] Remove trailing whitespace.
223d193f01
2022-09-25 19:34:27 +09:00
Maciek Rząsa
8e2c425183 [ruby/bigdecimal] Improve documentation of BigDecimal#sign
Fixes https://github.com/ruby/bigdecimal/issues/78 by describing behaviour for positive and negative zero in the docs.

5415b120ab
2022-09-25 16:51:17 +09:00
David Carlier
d35bc88b37
sockopt adding Linux constants, SO_INCOMING_CPU/SO_INCOMING_NAPI_ID. 2022-09-21 17:15:54 +09:00
David Carlier
8cbbc061c4 openbsd sockets add SO_RTABLE constant 2022-09-21 17:10:36 +09:00
David Carlier
ec2d13567e Introduces FreeBSD's SO_USER_COOKIE among socketopt's options. 2022-09-21 15:48:34 +09:00
David CARLIER
8a9dfb676b sockets add TCP_CONNECTION_INFO and TCP_KEEPALIVE constants. 2022-09-21 15:23:50 +09:00
David CARLIER
017573c3b3 socket add FreeBSD's SO_SETFIB constant. 2022-09-21 15:22:47 +09:00
卜部昌平
7060b23ffa proper function prototypes for openssl
Just to reroute compiler warnings.
2022-09-21 11:44:09 +09:00
卜部昌平
437800d3b0 getenv: is in stdlib.h
getenv is a very basic function that has been in stdlib.h since
ISO/IEC 9899:1990.  There is absolutely zero need for us to redeclare.

pty.c already includes stdlib.h out of the box so we need nothing.
2022-09-21 11:44:09 +09:00
卜部昌平
45741918e1 reserved_word: just use gperf 3.1 declaration
The reason why this was commented out was because of gperf 3.0 vs 3.1
differences (see [Feature #13883]).  Five years passed, I am pretty
confident that we can drop support of old versions here.

Ditto for uniname2ctype_p(), onig_jis_property(), and zonetab().
2022-09-21 11:44:09 +09:00
Sutou Kouhei
e40fa6c480
[DOC] socket: fix wrong sample addresses (#6372)
IPv6 link local address is fe80::/10 not ff80::/10:

https://www.rfc-editor.org/rfc/rfc4291.html

    Link-Local unicast   1111111010           FE80::/10       2.5.6

IPv6 (deprecated) site local address is fec0::/10 not ffc0::/10:

https://www.rfc-editor.org/rfc/rfc3513.html

    Site-local unicast   1111111011           FEC0::/10       2.5.6
2022-09-20 16:09:42 +09:00
Nobuyoshi Nakada
9de11fe796
Quiet if the target is already linked the same source 2022-09-20 12:54:08 +09:00
Aaron Patterson
26135312f6 [ruby/psych] Convert some of Parser#parse to Ruby
This commit just converts some of the parse method to Ruby

bca7d2c549
2022-09-20 00:44:30 +09:00
Peter Zhu
12889fad41 [ruby/bigdecimal] Remove symbol defs in missing.h for old Rubies
Commit 2885514 added these to support Ruby 2.1. The rb_sym2str function
is defined since Ruby 2.2.

be366c9cf2
2022-09-19 23:40:49 +09:00
Peter Zhu
a44f48cadc [ruby/bigdecimal] Remove array defs in missing.h for old Rubies
Commit 02b6053 added these to support Ruby 2.0.0. The rb_array_const_ptr
function is defined since Ruby 2.3.

678699ca1b
2022-09-19 23:40:48 +09:00
Takashi Kokubun
106744107b
[ruby/fiddle] Fix PACK_MAP for unsigned types (https://github.com/ruby/fiddle/pull/110)
4a71246645
2022-09-11 15:30:49 +09:00
Nobuyoshi Nakada
e4f5296f06
No longer bundle external library sources 2022-09-09 01:33:53 +09:00
Nobuyoshi Nakada
bcf82b7c26
Process token IDs from id.def without id.h
Fixes id.h error during updating ripper.c by `make after-update`.

While it used to update id.h in the build directory, but was trying to
update ripper.c in the source directory.  In principle, files in the
source directory can or should not depend on files in the build
directory.
2022-09-08 18:22:47 +09:00
Chad Wilson
1b034d66f5 [ruby/psych] Bump snakeyaml from 1.28 to 1.31
Resolves CVE-2022-25857, among other fixes.

918cd25d37
2022-09-07 09:51:57 +09:00
Nobuyoshi Nakada
cbdde8e0c5 [ruby/psych] Dump Date/DateTime as proleptic Gregorian date as well as Time
Fix ruby/psych#572

92304269bc
2022-09-07 09:44:14 +09:00
Nobuyoshi Nakada
725626d890 [Bug #18964] Update the code range of appended portion 2022-08-18 14:57:08 +09:00
Yusuke Endoh
2a55c61ee7 ext/pty/extconf.rb: Try libutil only on OpenBSD
icc now seems to provide libutil.so that is not related to pty.
This extconf.rb wrongly finds it and adds `-lutil`, but `ruby -rpty`
fails because it cannot find libutil.so on the runtime.

20220815T210005Z.fail.html.gz
```
Exception raised:
<#<LoadError: libutil.so: cannot open shared object file: No such file or directory - /home/chkbuild/chkbuild/tmp/build/20220815T210005Z/ruby/.ext/x86_64-linux/pty.so>>
```

This change makes extconf.rb check libutil only on OpenBSD.
2022-08-18 12:46:24 +09:00
Jean Boussier
3850113e20 [ruby/cgi] Implement CGI.url_encode and CGI.url_decode
[Feature #18822]

Ruby is somewhat missing an RFC 3986 compliant escape method.

c2729c7f33
2022-08-16 19:12:03 +09:00
Burdette Lamar
8d40ede2e0 [ruby/date] [DOC] Enhanced intro for Date (https://github.com/ruby/date/pull/72)
59a6673221
2022-08-15 22:16:23 +09:00
Nobuyoshi Nakada
cd1a0b3caa Stop defining RUBY_ABI_VERSION if released versions
As commented in include/ruby/internal/abi.h, since teeny versions of
Ruby should guarantee ABI compatibility, `RUBY_ABI_VERSION` has no role
in released versions of Ruby.
2022-08-12 15:57:25 +09:00
Jeremy Evans
cfb9624460
Fix Array#[] with ArithmeticSequence with negative steps (#5739)
* Fix Array#[] with ArithmeticSequence with negative steps

Previously, Array#[] when called with an ArithmeticSequence
with a negative step did not handle all cases correctly,
especially cases involving infinite ranges, inverted ranges,
and/or exclusive ends.

Fixes [Bug #18247]

* Add Array#slice tests for ArithmeticSequence with negative step to test_array

Add tests of rb_arithmetic_sequence_beg_len_step C-API function.

* Fix ext/-test-/arith_seq/beg_len_step/depend

* Rename local variables

* Fix a variable name

Co-authored-by: Kenta Murata <3959+mrkn@users.noreply.github.com>
2022-08-11 19:16:49 +09:00
Alexander Momchilov
9c13a6ce5f [ruby/psych] Raise specific error when an anchor isn't defined
98fbd5247a
2022-08-09 01:33:34 +09:00
Alexander Momchilov
54219ae8c4 [ruby/psych] Raise specific error when aliases are not enabled
0c11ddcf46
2022-08-09 01:32:47 +09:00
Nobuyoshi Nakada
5c9ce54757 [ruby/date] bump up to 3.2.3
dff37b3dd1
2022-08-08 23:59:12 +09:00
Nobuyoshi Nakada
e07d450dea [ruby/date] Fix Time#to_datetime before calendar reform
Time is always in the proleptic Gregorian calendar.
Also DateTime#to_time should convert to the Gregorian calendar first,
before extracting its components.

https://bugs.ruby-lang.org/issues/18946#change-98527

b2aee75248
2022-08-08 23:50:17 +09:00
Burdette Lamar
1607c6d281 [DOC] New doc about Julian/Gregorian (#70) 2022-08-07 20:42:31 -04:00
Nobuyoshi Nakada
e5e6b87e26
Create temporary file exclusively and clean 2022-08-07 18:25:10 +09:00
Yuta Saito
6d8b9a9d61 Resolve abi symbol references from miniruby to avoid circular deps
Adding `ruby` to `PREP` causes the following circular dependencies
because `PREP` is used as a prerequisite by some targets required to
build `ruby` target itself.
```
make: Circular .rbconfig.time <- ruby dependency dropped.
make: Circular builtin_binary.inc <- ruby dependency dropped.
make: Circular ext/extinit.c <- ruby dependency dropped.
make: Circular ruby <- ruby dependency dropped.
```

Adding a new Make variable like `EXTPREP` only for exts may be also
reasonable, but it would introduce another complexity into our build
system. `-bundle_loader` doesn't care that link-time and run-time
loader executables are different as long as bound symbols are provided,
so it's ok to resolve from miniruby to simplify our build.
2022-08-04 16:29:22 +09:00
Alan Wu
e5a3f23256 Use $(bindir) for path to executable in mkmf
For the macOS -bundle_loader linker option, we need a path to the
Ruby exectuable. $(RUBY) is not necessarily a path since it could
be a command line invocation. That happens during build with
runruby.rb and can happen post installation if the user passes
the --ruby option to a extconf.rb. Use $(bindir) to locate
the executable instead.

Before installation, $(bindir) doesn't exist, so we need to be
able to override $(BUILTRUBY) in such situations so test-spec
and bundled extensions could build. Use a new mkmf global,
$builtruby, to do this; set it in fake.rb and in extmk.rb.

Our build system is quite complex...
2022-08-04 16:29:22 +09:00
Yuta Saito
50d81bfbc1 Link ext bundles with bundle loader option for newer ld64
ld64 shipped with Xcode 14 emits a warning when using `-undefined
dynamic_lookup`.

```
ld: warning: -undefined dynamic_lookup may not work with chained fixups
```

Actually, `-undefined dynamic_lookup` doesn't work when:

1. Link a *shared library* with the option
2. Link it with a program that uses the chained-fixup introduced from
   macOS 12 and iOS 15
because `-undefined dynamic_lookup` uses lazy-bindings and they won't be
bound while dyld fixes-up by traversing chained-fixup info.

However, we build exts as *bundles* and they are loaded only through
`dlopen`, so it's safe to use `-undefined dynamic_lookup` in theory.
So the warning produced by ld64 is false-positive, and it results
failure of option checking in configuration. Therefore, it would be an
option to ignore the warning during our configuration.

On the other hand, `-undefined dynamic_lookup` is already deprecated on
all darwin platforms except for macOS, so it's good time to get rid of
the option. ld64 also provides `-bundle_loader <executable>` option,
which allows to resolve symbols defined in the executable symtab while
linking. It behaves almost the same with `-undefined dynamic_lookup`,
but it makes the following changes:

1. Require that unresolved symbols among input objects must be defined
   in the executable.
2. Lazy symbol binding will lookup only the symtab of the bundle loader
   executable. (`-undefined dynamic_lookup` lookups all symtab as flat
   namespace)

This patch adds `-bundle_loader $(RUBY)` when non-EXTSTATIC
configuration by assuming ruby executable can be linked before building
exts.

See "New Features" subsection under "Linking" section for chained fixup
https://developer.apple.com/documentation/xcode-release-notes/xcode-13-release-notes
2022-08-04 16:29:22 +09:00
Thomas Winsnes
8a1be433e8 [ruby/bigdecimal] Updated to use the correct spec for muilti license
13165b29b8
2022-08-03 11:04:31 +09:00
Thomas Winsnes
f33b2ae918
Updated to use multiple licenses
Co-authored-by: Hiroshi SHIBATA <hsbt@ruby-lang.org>
2022-08-03 11:04:20 +09:00
Burdette Lamar
eaf6189fe5 [ruby/date] Enhanced RDoc (https://github.com/ruby/date/pull/69)
Treats:
    ::_strptime
    ::strptime
Adds 'Related' entry to some methods' doc.

a6c2129273
2022-08-03 05:17:55 +09:00
Burdette Lamar
d8ea3a20fa [ruby/date] [DOC] Enhanced RDoc for parser methods (https://github.com/ruby/date/pull/68)
Treats:
    ::_httpdate
    ::_iso8601
    ::_jisx0301
    ::_parse
    ::_rfc2822
    ::_rfc3339
    ::_xmlschema
    ::httpdate
    ::iso8601
    ::jisx0301
    ::parse
    ::rfc2822
    ::rfc3339
    ::xmlschema

24bdab600a
2022-08-03 02:28:12 +09:00
Koichi Sasada
5bbba76489 respect current frame of rb_eval_string
`self` is nearest Ruby method's `self`.
If there is no ruby frame, use toplevel `self` (`main`).

https://bugs.ruby-lang.org/issues/18780
2022-08-01 17:48:05 +09:00
Burdette Lamar
4efbeb1190 [ruby/date] Enhanced RDoc (https://github.com/ruby/date/pull/67)
Treats:
    ::httpdate
    #to_date
    #to_time
    #to_datetime
In behalf of ::httpdate, I've introduced section "Argument limit" that can be pointed to by various Date methods (similar to existing section "Argument start"). This will involve 8 already-enhanced methods plus 8 more not yet done.

00326ff99c
2022-07-31 03:18:45 +09:00
Nobuyoshi Nakada
4ba2c66761
Revert "* expand tabs. [ci skip]"
This reverts commit 0d842fecb4.
2022-07-30 17:29:56 +09:00
git
0d842fecb4 * expand tabs. [ci skip]
Tabs were expanded because the file did not have any tab indentation in unedited lines.
Please update your editor config, and use misc/expand_tabs.rb in the pre-commit hook.
2022-07-30 17:26:37 +09:00
Nobuyoshi Nakada
f28287d34c
[ruby/io-nonblock] Revert tab expansion 2022-07-30 17:24:43 +09:00
Hiroshi SHIBATA
39dc9f9093
Revert "* expand tabs. [ci skip]"
This reverts commit 8a65cf3b61.
2022-07-30 17:03:13 +09:00