зеркало из https://github.com/github/ruby.git
Avoid diffutils 3.8 bug#61193 [ci skip]
This commit is contained in:
Родитель
3733ee835b
Коммит
eab1f1ef18
|
@ -10,9 +10,22 @@
|
|||
# ruby1.9 tool/enc-unicode.rb data_dir > enc/unicode/name2ctype.kwd
|
||||
# You can get source file for gperf. After this, simply make ruby.
|
||||
|
||||
if ARGV[0] == "--header"
|
||||
header = true
|
||||
ARGV.shift
|
||||
while arg = ARGV.shift
|
||||
case arg
|
||||
when "--"
|
||||
break
|
||||
when "--header"
|
||||
header = true
|
||||
when "--diff"
|
||||
diff = ARGV.shift or abort "#{$0}: --diff=DIFF-COMMAND"
|
||||
when /\A--diff=(.+)/m
|
||||
diff = $1
|
||||
when /\A-/
|
||||
abort "#{$0}: unknown option #{arg}"
|
||||
else
|
||||
ARGV.unshift(arg)
|
||||
break
|
||||
end
|
||||
end
|
||||
unless ARGV.size == 2
|
||||
abort "Usage: #{$0} data_directory emoji_data_directory"
|
||||
|
@ -544,6 +557,47 @@ output.restore
|
|||
if header
|
||||
require 'tempfile'
|
||||
|
||||
def diff_args(diff)
|
||||
ok = IO.popen([diff, "-DDIFF_TEST", IO::NULL, "-"], "r+") do |f|
|
||||
f.puts "Test for diffutils 3.8"
|
||||
f.close_write
|
||||
/^#if/ =~ f.read
|
||||
end
|
||||
if ok
|
||||
proc {|macro, *inputs|
|
||||
[diff, "-D#{macro}", *inputs]
|
||||
}
|
||||
else
|
||||
IO.popen([diff, "--old-group-format=%<", "--new-group-format=%>", IO::NULL, IO::NULL], err: %i[child out], &:read)
|
||||
unless $?.success?
|
||||
abort "#{$0}: #{diff} -D does not work"
|
||||
end
|
||||
warn "Avoiding diffutils 3.8 bug#61193"
|
||||
proc {|macro, *inputs|
|
||||
[diff] + [
|
||||
"--old-group-format=" \
|
||||
"#ifndef @\n" \
|
||||
"%<" \
|
||||
"#endif /* ! @ */\n",
|
||||
|
||||
"--new-group-format=" \
|
||||
"#ifdef @\n" \
|
||||
"%>" \
|
||||
"#endif /* @ */\n",
|
||||
|
||||
"--changed-group-format=" \
|
||||
"#ifndef @\n" \
|
||||
"%<" \
|
||||
"#else /* @ */\n" \
|
||||
"%>" \
|
||||
"#endif /* @ */\n"
|
||||
].map {|opt| opt.gsub(/@/) {macro}} + inputs
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
ifdef = diff_args(diff || "diff")
|
||||
|
||||
NAME2CTYPE = %w[gperf -7 -c -j1 -i1 -t -C -P -T -H uniname2ctype_hash -Q uniname2ctype_pool -N uniname2ctype_p]
|
||||
|
||||
fds = []
|
||||
|
@ -554,8 +608,8 @@ if header
|
|||
end while syms.pop
|
||||
fds.each(&:close)
|
||||
ff = nil
|
||||
IO.popen(%W[diff -DUSE_UNICODE_AGE_PROPERTIES #{fds[1].path} #{fds[0].path}], "r") {|age|
|
||||
IO.popen(%W[diff -DUSE_UNICODE_PROPERTIES #{fds[2].path} -], "r", in: age) {|f|
|
||||
IO.popen(ifdef["USE_UNICODE_AGE_PROPERTIES", fds[1].path, fds[0].path], "r") {|age|
|
||||
IO.popen(ifdef["USE_UNICODE_PROPERTIES", fds[2].path, "-"], "r", in: age) {|f|
|
||||
ansi = false
|
||||
f.each {|line|
|
||||
if /ANSI-C code produced by gperf/ =~ line
|
||||
|
|
Загрузка…
Ссылка в новой задаче