Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/setup/directories/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ runs:
shell: bash
run: |
echo "git=`command -v git`" >> "$GITHUB_OUTPUT"
echo "sudo=`command -v sudo`" >> "$GITHUB_OUTPUT"
echo "sudo=`sudo true && command -v sudo`" >> "$GITHUB_OUTPUT"
echo "autoreconf=`command -v autoreconf`" >> "$GITHUB_OUTPUT"

- if: steps.which.outputs.git
Expand Down
1 change: 1 addition & 0 deletions common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7436,6 +7436,7 @@ file.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
file.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
file.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
file.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
file.$(OBJEXT): {$(VPATH)}internal/attr/nonstring.h
file.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
file.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
file.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
Expand Down
12 changes: 6 additions & 6 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2815,12 +2815,12 @@ AS_IF([test "$THREAD_MODEL" = pthread], [
], [
AC_DEFINE(NON_SCALAR_THREAD_ID)
])
AC_CHECK_FUNCS(sched_yield pthread_attr_setinheritsched \
pthread_attr_get_np pthread_attr_getstack pthread_attr_getguardsize \
pthread_get_stackaddr_np pthread_get_stacksize_np \
thr_stksegment pthread_stackseg_np pthread_getthrds_np \
pthread_condattr_setclock \
pthread_setname_np pthread_set_name_np)
AC_CHECK_FUNCS([sched_yield pthread_attr_setinheritsched
pthread_attr_get_np pthread_attr_getstack pthread_attr_getguardsize
pthread_get_stackaddr_np pthread_get_stacksize_np
thr_stksegment pthread_stackseg_np pthread_getthrds_np
pthread_condattr_setclock
pthread_setname_np pthread_set_name_np])
AS_CASE(["$target_os"],[emscripten*],[ac_cv_func_pthread_sigmask=no],[AC_CHECK_FUNCS(pthread_sigmask)])
AS_CASE(["$target_os"],[aix*],[ac_cv_func_pthread_getattr_np=no],[AC_CHECK_FUNCS(pthread_getattr_np)])
set_current_thread_name=
Expand Down
3 changes: 2 additions & 1 deletion file.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
**********************************************************************/

#include "ruby/internal/config.h"
#include "ruby/internal/attr/nonstring.h"

#ifdef _WIN32
# include "missing/file.h"
Expand Down Expand Up @@ -373,7 +374,7 @@ rb_str_normalize_ospath(const char *ptr, long len)
int r = rb_enc_precise_mbclen(p, e, enc);
if (!MBCLEN_CHARFOUND_P(r)) {
/* invalid byte shall not happen but */
static const char invalid[3] = "\xEF\xBF\xBD";
RBIMPL_ATTR_NONSTRING() static const char invalid[3] = "\xEF\xBF\xBD";
rb_str_append_normalized_ospath(str, p1, p-p1);
rb_str_cat(str, invalid, sizeof(invalid));
p += 1;
Expand Down
14 changes: 11 additions & 3 deletions gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2498,13 +2498,21 @@ count_objects(int argc, VALUE *argv, VALUE os)
{
struct count_objects_data data = { 0 };
VALUE hash = Qnil;
VALUE types[T_MASK + 1];

if (rb_check_arity(argc, 0, 1) == 1) {
hash = argv[0];
if (!RB_TYPE_P(hash, T_HASH))
rb_raise(rb_eTypeError, "non-hash given");
}

for (size_t i = 0; i <= T_MASK; i++) {
// type_sym can allocate an object,
// so we need to create all key symbols in advance
// not to disturb the result
types[i] = type_sym(i);
}

rb_gc_impl_each_object(rb_gc_get_objspace(), count_objects_i, &data);

if (NIL_P(hash)) {
Expand All @@ -2517,9 +2525,9 @@ count_objects(int argc, VALUE *argv, VALUE os)
rb_hash_aset(hash, ID2SYM(rb_intern("FREE")), SIZET2NUM(data.freed));

for (size_t i = 0; i <= T_MASK; i++) {
VALUE type = type_sym(i);
if (data.counts[i])
rb_hash_aset(hash, type, SIZET2NUM(data.counts[i]));
if (data.counts[i]) {
rb_hash_aset(hash, types[i], SIZET2NUM(data.counts[i]));
}
}

return hash;
Expand Down
21 changes: 20 additions & 1 deletion parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ struct lex_context {
unsigned int in_argdef: 1;
unsigned int in_def: 1;
unsigned int in_class: 1;
unsigned int has_trailing_semicolon: 1;
BITFIELD(enum rb_parser_shareability, shareable_constant_value, 2);
BITFIELD(enum rescue_context, in_rescue, 2);
unsigned int cant_return: 1;
Expand Down Expand Up @@ -4041,6 +4042,7 @@ arg : asgn(arg_rhs)
{
p->ctxt.in_defined = $3.in_defined;
$$ = new_defined(p, $4, &@$);
p->ctxt.has_trailing_semicolon = $3.has_trailing_semicolon;
/*% ripper: defined!($:4) %*/
}
| def_endless_method(endless_arg)
Expand Down Expand Up @@ -4428,6 +4430,7 @@ primary : inline_primary
{
p->ctxt.in_defined = $4.in_defined;
$$ = new_defined(p, $5, &@$);
p->ctxt.has_trailing_semicolon = $4.has_trailing_semicolon;
/*% ripper: defined!($:5) %*/
}
| keyword_not '(' expr rparen
Expand Down Expand Up @@ -6706,7 +6709,14 @@ trailer : '\n'?
| ','
;

term : ';' {yyerrok;token_flush(p);}
term : ';'
{
yyerrok;
token_flush(p);
if (p->ctxt.in_defined) {
p->ctxt.has_trailing_semicolon = 1;
}
}
| '\n'
{
@$.end_pos = @$.beg_pos;
Expand Down Expand Up @@ -13013,6 +13023,9 @@ kwd_append(rb_node_kw_arg_t *kwlist, rb_node_kw_arg_t *kw)
static NODE *
new_defined(struct parser_params *p, NODE *expr, const YYLTYPE *loc)
{
int had_trailing_semicolon = p->ctxt.has_trailing_semicolon;
p->ctxt.has_trailing_semicolon = 0;

NODE *n = expr;
while (n) {
if (nd_type_p(n, NODE_BEGIN)) {
Expand All @@ -13025,6 +13038,12 @@ new_defined(struct parser_params *p, NODE *expr, const YYLTYPE *loc)
break;
}
}

if (had_trailing_semicolon && !nd_type_p(expr, NODE_BLOCK)) {
NODE *block = NEW_BLOCK(expr, loc);
return NEW_DEFINED(block, loc);
}

return NEW_DEFINED(n, loc);
}

Expand Down
1 change: 0 additions & 1 deletion test/.excludes-parsey/TestDefined.rb

This file was deleted.