Skip to content

Commit 4ff56a7

Browse files
author
Kadir Selçuk
authored
Merge pull request ruby#72 from ruby/master
[pull] master from ruby:master
2 parents fb11310 + cfb9624 commit 4ff56a7

File tree

139 files changed

+1904
-937
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

139 files changed

+1904
-937
lines changed

.github/workflows/compilers.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ jobs:
147147
- { name: disable-dln, env: { append_configure: '--disable-dln' } }
148148
- { name: enable-mkmf-verbose, env: { append_configure: '--enable-mkmf-verbose' } }
149149
- { name: disable-rubygems, env: { append_configure: '--disable-rubygems' } }
150+
- { name: RUBY_DEVEL, env: { append_configure: '--enable-devel' } }
150151

151152
- { name: OPT_THREADED_CODE=1, env: { cppflags: '-DOPT_THREADED_CODE=1' } }
152153
- { name: OPT_THREADED_CODE=2, env: { cppflags: '-DOPT_THREADED_CODE=2' } }

NEWS.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ Note: We're only listing outstanding class updates.
158158
* bigdecimal 3.1.2
159159
* bundler 2.4.0.dev
160160
* cgi 0.3.2
161+
* date 3.2.3
162+
* error_highlight 0.4.0
161163
* etc 1.4.0
162164
* io-console 0.5.11
163165
* io-nonblock 0.1.1
@@ -178,7 +180,7 @@ Note: We're only listing outstanding class updates.
178180
* net-imap 0.2.3
179181
* rbs 2.6.0
180182
* typeprof 0.21.3
181-
* debug 1.6.1
183+
* debug 1.6.2
182184
* The following default gems are now bundled gems.
183185
184186
## Compatibility issues

array.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1373,13 +1373,16 @@ ary_make_partial_step(VALUE ary, VALUE klass, long offset, long len, long step)
13731373
const VALUE *values = RARRAY_CONST_PTR_TRANSIENT(ary);
13741374
const long orig_len = len;
13751375

1376-
if ((step > 0 && step >= len) || (step < 0 && (step < -len))) {
1376+
if (step > 0 && step >= len) {
13771377
VALUE result = ary_new(klass, 1);
13781378
VALUE *ptr = (VALUE *)ARY_EMBED_PTR(result);
13791379
RB_OBJ_WRITE(result, ptr, values[offset]);
13801380
ARY_SET_EMBED_LEN(result, 1);
13811381
return result;
13821382
}
1383+
else if (step < 0 && step < -len) {
1384+
step = -len;
1385+
}
13831386

13841387
long ustep = (step < 0) ? -step : step;
13851388
len = (len + ustep - 1) / ustep;

benchmark/buffer_get.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
prelude: |
2+
# frozen_string_literal: true
3+
Warning[:experimental] = false
4+
buffer = IO::Buffer.new(32, IO::Buffer::MAPPED)
5+
string = "\0" * 32
16
benchmark:
2-
- name: buffer.get
3-
prelude: buffer = IO::Buffer.new(32, IO::Buffer::MAPPED)
4-
script: buffer.get(:U32, 0)
5-
loop_count: 20000000
6-
- name: string.unpack
7-
prelude: string = "\0" * 32
8-
script: string.unpack("C")
9-
loop_count: 20000000
7+
buffer.get_value: |
8+
buffer.get_value(:U32, 0)
9+
string.unpack1: |
10+
string.unpack1("N")

benchmark/masgn.yml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
prelude: |
22
a = [nil] * 3
33
b = Class.new{attr_writer :a, :b, :c}.new
4-
c, d, e, f = nil, nil, nil, nil
4+
c = d = e = f = g = h = i = nil
55
benchmark:
66
array2_2: "c = (a[0], a[1] = 1, 2)"
77
array2_3: "c = (a[0], a[1] = 1, 2, 3)"
@@ -27,3 +27,27 @@ benchmark:
2727
lvar2_3p: "(d, e = 1, 2, 3; nil)"
2828
lvar3_2p: "(d, e, f = 1, 2; nil)"
2929
lvar3_3p: "(d, e, f = 1, 2, 3; nil)"
30+
array2_2lv: "c = (a[0], a[1] = g, h)"
31+
array2_ilv: "c = (a[0], a[1] = g, h, i)"
32+
arrayi_2lv: "c = (a[0], a[1], a[2] = g, h)"
33+
arrayi_ilv: "c = (a[0], a[1], a[2] = g, h, i)"
34+
attr2_2lv: "c = (b.a, b.b = g, h)"
35+
attr2_ilv: "c = (b.a, b.b = g, h, i)"
36+
attri_2lv: "c = (b.a, b.b, b.c = g, h)"
37+
attri_ilv: "c = (b.a, b.b, b.c = g, h, i)"
38+
lvar2_2lv: "c = (d, e = g, h)"
39+
lvar2_ilv: "c = (d, e = g, h, i)"
40+
lvari_2lv: "c = (d, e, f = g, h)"
41+
lvari_ilv: "c = (d, e, f = g, h, i)"
42+
array2_2plv: "(a[0], a[1] = g, h; nil)"
43+
array2_iplv: "(a[0], a[1] = g, h, i; nil)"
44+
arrayi_2plv: "(a[0], a[1], a[2] = g, h; nil)"
45+
arrayi_iplv: "(a[0], a[1], a[2] = g, h, i; nil)"
46+
attr2_2plv: "(b.a, b.b = g, h; nil)"
47+
attr2_iplv: "(b.a, b.b = g, h, i; nil)"
48+
attri_2plv: "(b.a, b.b, b.c = g, h; nil)"
49+
attri_iplv: "(b.a, b.b, b.c = g, h, i; nil)"
50+
lvar2_2plv: "(d, e = g, h; nil)"
51+
lvar2_iplv: "(d, e = g, h, i; nil)"
52+
lvari_2plv: "(d, e, f = g, h; nil)"
53+
lvari_iplv: "(d, e, f = g, h, i; nil)"

common.mk

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -687,18 +687,18 @@ realclean-platform: distclean-platform
687687
realclean-spec: distclean-spec
688688
realclean-rubyspec: realclean-spec
689689

690-
clean-ext:: ext/clean gems/clean timestamp/clean
691-
distclean-ext:: ext/distclean gems/distclean timestamp/distclean
692-
realclean-ext:: ext/realclean gems/realclean timestamp/realclean
690+
clean-ext:: ext/clean .bundle/clean timestamp/clean
691+
distclean-ext:: ext/distclean .bundle/distclean timestamp/distclean
692+
realclean-ext:: ext/realclean .bundle/realclean timestamp/realclean
693693

694694
ext/clean.mk ext/distclean.mk ext/realclean.mk::
695695
ext/clean:: ext/clean.mk
696696
ext/distclean:: ext/distclean.mk
697697
ext/realclean:: ext/realclean.mk
698698

699-
timestamp/clean:: ext/clean gems/clean
700-
timestamp/distclean:: ext/distclean gems/distclean
701-
timestamp/realclean:: ext/realclean gems/realclean
699+
timestamp/clean:: ext/clean .bundle/clean
700+
timestamp/distclean:: ext/distclean .bundle/distclean
701+
timestamp/realclean:: ext/realclean .bundle/realclean
702702

703703
timestamp/clean timestamp/distclean timestamp/realclean::
704704
$(Q)$(RM) $(TIMESTAMPDIR)/.*.time $(TIMESTAMPDIR)/$(arch)/.time

compile.c

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3332,6 +3332,84 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
33323332
}
33333333
}
33343334

3335+
if (IS_INSN_ID(iobj, newarray)) {
3336+
LINK_ELEMENT *next = iobj->link.next;
3337+
if (IS_INSN(next) && IS_INSN_ID(next, expandarray) &&
3338+
OPERAND_AT(next, 1) == INT2FIX(0)) {
3339+
VALUE op1, op2;
3340+
op1 = OPERAND_AT(iobj, 0);
3341+
op2 = OPERAND_AT(next, 0);
3342+
ELEM_REMOVE(next);
3343+
3344+
if (op1 == op2) {
3345+
/*
3346+
* newarray 2
3347+
* expandarray 2, 0
3348+
* =>
3349+
* swap
3350+
*/
3351+
if (op1 == INT2FIX(2)) {
3352+
INSN_OF(iobj) = BIN(swap);
3353+
iobj->operand_size = 0;
3354+
}
3355+
/*
3356+
* newarray X
3357+
* expandarray X, 0
3358+
* =>
3359+
* opt_reverse X
3360+
*/
3361+
else {
3362+
INSN_OF(iobj) = BIN(opt_reverse);
3363+
}
3364+
}
3365+
else {
3366+
NODE dummy_line_node = generate_dummy_line_node(iobj->insn_info.line_no, iobj->insn_info.node_id);
3367+
long diff = FIX2LONG(op1) - FIX2LONG(op2);
3368+
INSN_OF(iobj) = BIN(opt_reverse);
3369+
OPERAND_AT(iobj, 0) = OPERAND_AT(next, 0);
3370+
3371+
if (op1 > op2) {
3372+
/* X > Y
3373+
* newarray X
3374+
* expandarray Y, 0
3375+
* =>
3376+
* pop * (Y-X)
3377+
* opt_reverse Y
3378+
*/
3379+
for (; diff > 0; diff--) {
3380+
INSERT_BEFORE_INSN(iobj, &dummy_line_node, pop);
3381+
}
3382+
}
3383+
else { /* (op1 < op2) */
3384+
/* X < Y
3385+
* newarray X
3386+
* expandarray Y, 0
3387+
* =>
3388+
* putnil * (Y-X)
3389+
* opt_reverse Y
3390+
*/
3391+
for (; diff < 0; diff++) {
3392+
INSERT_BEFORE_INSN(iobj, &dummy_line_node, putnil);
3393+
}
3394+
}
3395+
}
3396+
}
3397+
}
3398+
3399+
if (IS_INSN_ID(iobj, duparray)) {
3400+
LINK_ELEMENT *next = iobj->link.next;
3401+
/*
3402+
* duparray obj
3403+
* expandarray X, 0
3404+
* =>
3405+
* putobject obj
3406+
* expandarray X, 0
3407+
*/
3408+
if (IS_INSN(next) && IS_INSN_ID(next, expandarray)) {
3409+
INSN_OF(iobj) = BIN(putobject);
3410+
}
3411+
}
3412+
33353413
if (IS_INSN_ID(iobj, anytostring)) {
33363414
LINK_ELEMENT *next = iobj->link.next;
33373415
/*

configure.ac

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -622,9 +622,13 @@ AS_IF([test "$fdeclspec" = yes], [
622622
RUBY_APPEND_OPTIONS(CXXFLAGS, -fdeclspec)
623623
])
624624

625-
AS_CASE([$RUBY_PATCHLEVEL], [-*],
626-
[RUBY_DEVEL=yes], [RUBY_DEVEL=no])
627-
particular_werror_flags=$RUBY_DEVEL
625+
AC_ARG_ENABLE(devel,
626+
AS_HELP_STRING([--enable-devel], [enable development build]),
627+
[RUBY_DEVEL=$enableval],
628+
[AS_IF([test "x${RUBY_DEVEL-no}" != xyes], [RUBY_DEVEL=])]
629+
)dnl
630+
AC_SUBST(RUBY_DEVEL)
631+
particular_werror_flags=${RUBY_DEVEL:-no}
628632
AC_ARG_ENABLE(werror,
629633
AS_HELP_STRING([--disable-werror],
630634
[don't make warnings into errors
@@ -868,7 +872,6 @@ AS_IF([test "$GCC" = yes], [
868872
test "${debugflags+set}" || {RUBY_TRY_CFLAGS(-g3, [debugflags=-g3])}
869873
])
870874
test $ac_cv_prog_cc_g = yes && : ${debugflags=-g}
871-
AS_IF([test "x$RUBY_DEVEL" = xyes], [RUBY_APPEND_OPTION(XCFLAGS, -DRUBY_DEVEL=1)])
872875

873876
AS_IF([test "$GCC" = ""], [
874877
AS_CASE(["$target_os"],[aix*],[warnflags="$warnflags -qinfo=por" rb_cv_warnflags="$rb_cv_warnflags -qinfo=por"])

doc/date/calendars.rdoc

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
== Julian and Gregorian Calendars
2+
3+
The difference between the
4+
{Julian calendar}[https://en.wikipedia.org/wiki/Julian_calendar]
5+
and the
6+
{Gregorian calendar}[https://en.wikipedia.org/wiki/Gregorian_calendar]
7+
may matter to your program if it uses dates before the switchovers.
8+
9+
- October 15, 1582.
10+
- September 14, 1752.
11+
12+
A date will be different in the two calendars, in general.
13+
14+
=== Different switchover dates
15+
16+
The reasons for the difference are religious/political histories.
17+
18+
- On October 15, 1582, several countries changed
19+
from the Julian calendar to the Gregorian calendar;
20+
these included Italy, Poland, Portugal, and Spain.
21+
Other contries in the Western world retained the Julian calendar.
22+
- On September 14, 1752, most of the British empire
23+
changed from the Julian calendar to the Gregorian calendar.
24+
25+
When your code uses a date before these switchover dates,
26+
it will matter whether it considers the switchover date
27+
to be the earlier date or the later date (or neither).
28+
29+
See also {a concrete example here}[rdoc-ref:DateTime@When+should+you+use+DateTime+and+when+should+you+use+Time-3F].
30+
31+
=== Argument +start+
32+
33+
Certain methods in class \Date handle differences in the
34+
{Julian and Gregorian calendars}[rdoc-ref:calendars.rdoc@Julian+and+Gregorian+Calendars]
35+
by accepting an optional argument +start+, whose value may be:
36+
37+
- Date::ITALY (the default): the created date is Julian
38+
if before October 15, 1582, Gregorian otherwise:
39+
40+
d = Date.new(1582, 10, 15)
41+
d.prev_day.julian? # => true
42+
d.julian? # => false
43+
d.gregorian? # => true
44+
45+
- Date::ENGLAND: the created date is Julian if before September 14, 1752,
46+
Gregorian otherwise:
47+
48+
d = Date.new(1752, 9, 14, Date::ENGLAND)
49+
d.prev_day.julian? # => true
50+
d.julian? # => false
51+
d.gregorian? # => true
52+
53+
- Date::JULIAN: the created date is Julian regardless of its value:
54+
55+
d = Date.new(1582, 10, 15, Date::JULIAN)
56+
d.julian? # => true
57+
58+
- Date::GREGORIAN: the created date is Gregorian regardless of its value:
59+
60+
d = Date.new(1752, 9, 14, Date::GREGORIAN)
61+
d.prev_day.gregorian? # => true
62+

0 commit comments

Comments
 (0)