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
6 changes: 3 additions & 3 deletions common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -1639,9 +1639,9 @@ yes-test-bundler: $(PREPARE_BUNDLER)
$(gnumake_recursive)$(XRUBY) \
-r./$(arch)-fake \
-r$(tooldir)/lib/_tmpdir \
-e '$$no_report_tmpdir = true' \
-I$(srcdir)/spec/bundler -I$(srcdir)/spec/lib \
-e 'Dir.chdir(ARGV.shift); load("spec/bin/rspec")' $(srcdir) \
-e "Dir.chdir(ARGV.shift); load('spec/bin/rspec')" \
-s -- -no-report-tmpdir -- "$(srcdir)" \
-r spec_helper $(RSPECOPTS) spec/bundler/$(BUNDLER_SPECS)
no-test-bundler:

Expand All @@ -1651,12 +1651,12 @@ yes-test-bundler-parallel: $(PREPARE_BUNDLER)
$(gnumake_recursive)$(XRUBY) \
-r./$(arch)-fake \
-r$(tooldir)/lib/_tmpdir \
-e '$$no_report_tmpdir = true' \
-I$(srcdir)/spec/bundler \
-e "ruby = ENV['RUBY']" \
-e "ARGV[-1] = File.expand_path(ARGV[-1])" \
-e "ENV['RSPEC_EXECUTABLE'] = ruby + ARGV.shift" \
-e "load ARGV.shift" \
-s -- -no-report-tmpdir -- \
" -C $(srcdir) -Ispec/bundler -Ispec/lib .bundle/bin/rspec -r spec_helper" \
$(srcdir)/spec/bin/parallel_rspec $(RSPECOPTS) \
$(PARALLELRSPECOPTS) $(srcdir)/spec/bundler/$(BUNDLER_SPECS)
Expand Down
3 changes: 3 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -4680,6 +4680,9 @@ m4_foreach(parser, [available_parsers],
[AC_MSG_ERROR([Unknown parser: $with_parser])]
)

# Use the ruby allocator for prism. See prism/defines.h
RUBY_APPEND_OPTIONS(XCFLAGS, -DPRISM_XALLOCATOR)

arch_hdrdir="${EXTOUT}/include/${arch}/ruby"
AS_MKDIR_P("${arch_hdrdir}")
config_h="${arch_hdrdir}/config.h"
Expand Down
506 changes: 505 additions & 1 deletion depend

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion prism_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -11352,7 +11352,7 @@ pm_read_file(pm_string_t *string, const char *filepath)
}

size_t length = (size_t) len;
uint8_t *source = malloc(length); // FIXME: using raw malloc because that's what Prism uses.
uint8_t *source = xmalloc(length);
memcpy(source, RSTRING_PTR(contents), length);
*string = (pm_string_t) { .type = PM_STRING_OWNED, .source = source, .length = length };

Expand Down
6 changes: 6 additions & 0 deletions prism_xallocator.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef PRISM_XALLOCATOR_H
#define PRISM_XALLOCATOR_H

#include "ruby/internal/xmalloc.h"

#endif /* PRISM_XALLOCATOR_H */
26 changes: 22 additions & 4 deletions tool/lib/colorize.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Colorize
# Colorize.new(colorize = nil)
# Colorize.new(color: color, colors_file: colors_file)
def initialize(color = nil, opts = ((_, color = color, nil)[0] if Hash === color))
@colors = @reset = nil
@colors = nil
@color = opts && opts[:color] || color
if color or (color == nil && coloring?)
if (%w[smso so].any? {|attr| /\A\e\[.*m\z/ =~ IO.popen("tput #{attr}", "r", :err => IO::NULL, &:read)} rescue nil)
Expand All @@ -20,7 +20,6 @@ def initialize(color = nil, opts = ((_, color = color, nil)[0] if Hash === color
end
end
@colors = colors
@reset = "#{@beg}m"
end
end
self
Expand All @@ -30,7 +29,7 @@ def initialize(color = nil, opts = ((_, color = color, nil)[0] if Hash === color
# color names
"black"=>"30", "red"=>"31", "green"=>"32", "yellow"=>"33",
"blue"=>"34", "magenta"=>"35", "cyan"=>"36", "white"=>"37",
"bold"=>"1", "underline"=>"4", "reverse"=>"7",
"bold"=>"1", "faint"=>"2", "underline"=>"4", "reverse"=>"7",
"bright_black"=>"90", "bright_red"=>"91", "bright_green"=>"92", "bright_yellow"=>"93",
"bright_blue"=>"94", "bright_magenta"=>"95", "bright_cyan"=>"96", "bright_white"=>"97",

Expand All @@ -46,7 +45,7 @@ def coloring?
# colorize.decorate(str, name = color_name)
def decorate(str, name = @color)
if coloring? and color = resolve_color(name)
"#{@beg}#{color}m#{str}#{@reset}"
"#{@beg}#{color}m#{str}#{reset_color(color)}"
else
str
end
Expand All @@ -69,6 +68,25 @@ def resolve_color(color = @color, seen = {}, colors = nil)
end
end

def reset_color(colors)
resets = []
colors.scan(/\G;*\K(?:[34]8;5;\d+|2(?:;\d+){3}|\d+)/) do |c|
case c
when '1', '2'
resets << '22'
when '4'
resets << '24'
when '7'
resets << '27'
when /\A3\d\z/
resets << '39'
when /\A4\d\z/
resets << '49'
end
end
"#{@beg}#{resets.reverse.join(';')}m"
end

DEFAULTS.each_key do |name|
define_method(name) {|str|
decorate(str, name)
Expand Down
4 changes: 2 additions & 2 deletions tool/test-bundled-gems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@
ENV["RUBYLIB"] = rubylib
end

# 93(bright yellow) is copied from .github/workflows/mingw.yml
puts "#{github_actions ? "::group::\e\[93m" : "\n"}Testing the #{gem} gem#{github_actions ? "\e\[m" : ""}"
print (github_actions ? "::group::" : "\n")
puts colorize.decorate("Testing the #{gem} gem", "note")
print "[command]" if github_actions
p test_command
start_at = Process.clock_gettime(Process::CLOCK_MONOTONIC)
Expand Down
2 changes: 1 addition & 1 deletion vm_eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -1776,7 +1776,7 @@ pm_eval_make_iseq(VALUE src, VALUE fname, int line,
/* We need to duplicate the string because the Ruby string may
* be embedded so compaction could move the string and the pointer
* will change. */
char *name_dup = malloc(length + 1); // FIXME: using raw `malloc` because that is what Prism uses.
char *name_dup = xmalloc(length + 1);
strlcpy(name_dup, name, length + 1);

RB_GC_GUARD(name_obj);
Expand Down