mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
changes from personal modifies -- matz
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1084 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ceec42bf8c
commit
08ec02b92b
13 changed files with 100 additions and 85 deletions
|
@ -1,9 +1,9 @@
|
||||||
|
.cvsignore
|
||||||
parse.c
|
parse.c
|
||||||
newver.rb
|
newver.rb
|
||||||
ruby
|
ruby
|
||||||
miniruby
|
miniruby
|
||||||
README.fat-patch
|
README.fat-patch
|
||||||
configure
|
|
||||||
config.cache
|
config.cache
|
||||||
config.h
|
config.h
|
||||||
config.log
|
config.log
|
||||||
|
@ -11,7 +11,6 @@ config.status
|
||||||
Makefile
|
Makefile
|
||||||
ppack
|
ppack
|
||||||
archive
|
archive
|
||||||
extmk.rb
|
|
||||||
*.orig
|
*.orig
|
||||||
*.rej
|
*.rej
|
||||||
*.bak
|
*.bak
|
||||||
|
|
2
ToDo
2
ToDo
|
@ -29,6 +29,8 @@ Language Spec.
|
||||||
* Regexp: make /o thread safe.
|
* Regexp: make /o thread safe.
|
||||||
* decide if begin with rescue or ensure make do..while loop.
|
* decide if begin with rescue or ensure make do..while loop.
|
||||||
* a +1 to be a+1, not a(+1).
|
* a +1 to be a+1, not a(+1).
|
||||||
|
* unify == and eql? again
|
||||||
|
* to_i returns nil if str contains no digit.
|
||||||
|
|
||||||
Hacking Interpreter
|
Hacking Interpreter
|
||||||
|
|
||||||
|
|
|
@ -10,9 +10,9 @@ BEGIN {
|
||||||
CONFIG['TEENY'] = $3
|
CONFIG['TEENY'] = $3
|
||||||
end
|
end
|
||||||
|
|
||||||
File.foreach($config || "config.status") do |$_|
|
File.foreach($config || "config.status") do |line|
|
||||||
next if /^#/
|
next if /^#/ =~ line
|
||||||
if /^s%@(\w+)@%(.*)%g/
|
if /^s%@(\w+)@%(.*)%g/ =~ line
|
||||||
name = $1
|
name = $1
|
||||||
val = $2 || ""
|
val = $2 || ""
|
||||||
next if /^(INSTALL|DEFS|configure_input|srcdir)$/ =~ name
|
next if /^(INSTALL|DEFS|configure_input|srcdir)$/ =~ name
|
||||||
|
|
|
@ -654,15 +654,15 @@ $static_ext = {}
|
||||||
for setup in ["@setup@", "#{$top_srcdir}/ext/@setup@"]
|
for setup in ["@setup@", "#{$top_srcdir}/ext/@setup@"]
|
||||||
if File.file? setup
|
if File.file? setup
|
||||||
f = open(setup)
|
f = open(setup)
|
||||||
while f.gets()
|
while line = f.gets()
|
||||||
$_.chomp!
|
line.chomp!
|
||||||
sub!(/#.*$/, '')
|
line.sub!(/#.*$/, '')
|
||||||
next if /^\s*$/
|
next if /^\s*$/ =~ line
|
||||||
if /^option +nodynamic/
|
if /^option +nodynamic/ =~ line
|
||||||
$nodynamic = true
|
$nodynamic = true
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
target = $_.split[0]
|
target = line.split[0]
|
||||||
target = target.downcase if /mswin32/ =~ RUBY_PLATFORM
|
target = target.downcase if /mswin32/ =~ RUBY_PLATFORM
|
||||||
$static_ext[target] = true
|
$static_ext[target] = true
|
||||||
end
|
end
|
||||||
|
|
|
@ -38,11 +38,11 @@ class Mail
|
||||||
def initialize(f)
|
def initialize(f)
|
||||||
@header = {}
|
@header = {}
|
||||||
@body = []
|
@body = []
|
||||||
while f.gets()
|
while line = f.gets()
|
||||||
$_.chop!
|
line.chop!
|
||||||
next if /^From / # skip From-line
|
next if /^From / =~ line # skip From-line
|
||||||
break if /^$/ # end of header
|
break if /^$/ =~ line # end of header
|
||||||
if /^(\S+):\s*(.*)/
|
if /^(\S+):\s*(.*)/ =~ line
|
||||||
@header[attr = $1.capitalize] = $2
|
@header[attr = $1.capitalize] = $2
|
||||||
elsif attr
|
elsif attr
|
||||||
sub(/^\s*/, '')
|
sub(/^\s*/, '')
|
||||||
|
@ -50,10 +50,10 @@ class Mail
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return if ! $_
|
return unless $_
|
||||||
|
|
||||||
while f.gets()
|
while line = f.gets()
|
||||||
break if /^From /
|
break if /^From / =~ line
|
||||||
@body.push($_)
|
@body.push($_)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -20,11 +20,11 @@ class Mail
|
||||||
def initialize(f)
|
def initialize(f)
|
||||||
@header = {}
|
@header = {}
|
||||||
@body = []
|
@body = []
|
||||||
while f.gets()
|
while line = f.gets()
|
||||||
$_.chop!
|
$_.chop!
|
||||||
next if /^From / # skip From-line
|
next if /^From / =~ line # skip From-line
|
||||||
break if /^$/ # end of header
|
break if /^$/ =~ line # end of header
|
||||||
if /^(\S+):\s*(.*)/
|
if /^(\S+):\s*(.*)/ =~ line
|
||||||
@header[attr = $1.capitalize] = $2
|
@header[attr = $1.capitalize] = $2
|
||||||
elsif attr
|
elsif attr
|
||||||
sub(/^\s*/, '')
|
sub(/^\s*/, '')
|
||||||
|
@ -32,10 +32,10 @@ class Mail
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return if ! $_
|
return unless $_
|
||||||
|
|
||||||
while f.gets()
|
while line = f.gets()
|
||||||
break if /^From /
|
break if /^From / =~ line
|
||||||
@body.push($_)
|
@body.push($_)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -54,7 +54,9 @@ class CGI
|
||||||
@output_cookies = [
|
@output_cookies = [
|
||||||
Cookie::new("name" => session_key,
|
Cookie::new("name" => session_key,
|
||||||
"value" => id,
|
"value" => id,
|
||||||
"path" => if ENV["SCRIPT_NAME"] then
|
"path" => if ENV["PATH_INFO"] then
|
||||||
|
File::dirname(ENV["PATH_INFO"])
|
||||||
|
elsif ENV["SCRIPT_NAME"] then
|
||||||
File::dirname(ENV["SCRIPT_NAME"])
|
File::dirname(ENV["SCRIPT_NAME"])
|
||||||
else
|
else
|
||||||
""
|
""
|
||||||
|
|
20
mkconfig.rb
20
mkconfig.rb
|
@ -26,18 +26,18 @@ v_fast = []
|
||||||
v_others = []
|
v_others = []
|
||||||
has_srcdir = false
|
has_srcdir = false
|
||||||
has_version = false
|
has_version = false
|
||||||
File.foreach "config.status" do |$_|
|
File.foreach "config.status" do |line|
|
||||||
next if /^#/
|
next if /^#/ =~ line
|
||||||
if /^s%@program_transform_name@%s,(.*)%g$/
|
if /^s%@program_transform_name@%s,(.*)%g$/ =~ line
|
||||||
next if $install_name
|
next if $install_name
|
||||||
ptn = $1.sub(/\$\$/, '$').split(/,/) #'
|
ptn = $1.sub(/\$\$/, '$').split(/,/) #'
|
||||||
v_fast << " CONFIG[\"ruby_install_name\"] = \"" + "ruby".sub(ptn[0],ptn[1]) + "\"\n"
|
v_fast << " CONFIG[\"ruby_install_name\"] = \"" + "ruby".sub(ptn[0],ptn[1]) + "\"\n"
|
||||||
elsif /^s%@(\w+)@%(.*)%g/
|
elsif /^s%@(\w+)@%(.*)%g/ =~ line
|
||||||
name = $1
|
name = $1
|
||||||
val = $2 || ""
|
val = $2 || ""
|
||||||
next if name =~ /^(INSTALL|DEFS|configure_input|srcdir|top_srcdir)$/
|
next if /^(INSTALL|DEFS|configure_input|srcdir|top_srcdir)$/ =~ name
|
||||||
next if $install_name and name =~ /^RUBY_INSTALL_NAME$/
|
next if $install_name and /^RUBY_INSTALL_NAME$/ =~ name
|
||||||
next if $so_name and name =~ /^RUBY_SO_NAME$/
|
next if $so_name and /^RUBY_SO_NAME$/ =~ name
|
||||||
v = " CONFIG[\"" + name + "\"] = " +
|
v = " CONFIG[\"" + name + "\"] = " +
|
||||||
val.sub(/^\s*(.*)\s*$/, '"\1"').gsub(/\$\{?(\w+)\}?/) {
|
val.sub(/^\s*(.*)\s*$/, '"\1"').gsub(/\$\{?(\w+)\}?/) {
|
||||||
"\#{CONFIG[\\\"#{$1}\\\"]}"
|
"\#{CONFIG[\\\"#{$1}\\\"]}"
|
||||||
|
@ -48,7 +48,7 @@ File.foreach "config.status" do |$_|
|
||||||
v_others << v
|
v_others << v
|
||||||
end
|
end
|
||||||
has_version = true if name == "MAJOR"
|
has_version = true if name == "MAJOR"
|
||||||
if /DEFS/
|
if /DEFS/ =~ line
|
||||||
val.split(/\s*-D/).each do |i|
|
val.split(/\s*-D/).each do |i|
|
||||||
if i =~ /(.*)=(\\")?([^\\]*)(\\")?/
|
if i =~ /(.*)=(\\")?([^\\]*)(\\")?/
|
||||||
key, val = $1, $3
|
key, val = $1, $3
|
||||||
|
@ -61,10 +61,10 @@ File.foreach "config.status" do |$_|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elsif /^ac_given_srcdir=(.*)/
|
elsif /^ac_given_srcdir=(.*)/ =~ line
|
||||||
v_fast << " CONFIG[\"srcdir\"] = \"" + File.expand_path($1) + "\"\n"
|
v_fast << " CONFIG[\"srcdir\"] = \"" + File.expand_path($1) + "\"\n"
|
||||||
has_srcdir = true
|
has_srcdir = true
|
||||||
elsif /^ac_given_INSTALL=(.*)/
|
elsif /^ac_given_INSTALL=(.*)/ =~ line
|
||||||
v_fast << " CONFIG[\"INSTALL\"] = " + $1 + "\n"
|
v_fast << " CONFIG[\"INSTALL\"] = " + $1 + "\n"
|
||||||
end
|
end
|
||||||
# break if /^CEOF/
|
# break if /^CEOF/
|
||||||
|
|
48
parse.y
48
parse.y
|
@ -4387,8 +4387,6 @@ void_stmts(node)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static NODE *cond2();
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
assign_in_cond(node)
|
assign_in_cond(node)
|
||||||
NODE *node;
|
NODE *node;
|
||||||
|
@ -4435,65 +4433,79 @@ assign_in_cond(node)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
warn_unless_e_option(str)
|
||||||
|
const char *str;
|
||||||
|
{
|
||||||
|
if (strcmp(ruby_sourcefile, "-e") != 0)
|
||||||
|
rb_warning(str);
|
||||||
|
}
|
||||||
|
|
||||||
static NODE*
|
static NODE*
|
||||||
cond0(node, log)
|
cond0(node, logop)
|
||||||
NODE *node;
|
NODE *node;
|
||||||
int log;
|
int logop;
|
||||||
{
|
{
|
||||||
enum node_type type = nd_type(node);
|
enum node_type type = nd_type(node);
|
||||||
|
|
||||||
assign_in_cond(node);
|
assign_in_cond(node);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case NODE_DSTR:
|
case NODE_DSTR:
|
||||||
if (log) break;
|
if (logop) break;
|
||||||
nd_set_type(node, NODE_DREGX);
|
nd_set_type(node, NODE_DREGX);
|
||||||
/* fall through */
|
/* fall through */
|
||||||
case NODE_DREGX:
|
case NODE_DREGX:
|
||||||
case NODE_DREGX_ONCE:
|
case NODE_DREGX_ONCE:
|
||||||
local_cnt('_');
|
local_cnt('_');
|
||||||
local_cnt('~');
|
local_cnt('~');
|
||||||
rb_warn("string/regex literal in condition");
|
warn_unless_e_option("string/regex literal in condition");
|
||||||
return NEW_MATCH2(node, NEW_GVAR(rb_intern("$_")));
|
return NEW_MATCH2(node, NEW_GVAR(rb_intern("$_")));
|
||||||
|
|
||||||
case NODE_DOT2:
|
case NODE_DOT2:
|
||||||
case NODE_DOT3:
|
case NODE_DOT3:
|
||||||
node->nd_beg = cond0(node->nd_beg, log);
|
node->nd_beg = cond0(node->nd_beg, logop);
|
||||||
node->nd_end = cond0(node->nd_end, log);
|
node->nd_end = cond0(node->nd_end, logop);
|
||||||
if (type == NODE_DOT2) nd_set_type(node,NODE_FLIP2);
|
if (type == NODE_DOT2) nd_set_type(node,NODE_FLIP2);
|
||||||
else if (type == NODE_DOT3) nd_set_type(node, NODE_FLIP3);
|
else if (type == NODE_DOT3) nd_set_type(node, NODE_FLIP3);
|
||||||
node->nd_cnt = local_append(0);
|
node->nd_cnt = local_append(0);
|
||||||
rb_warn("range literal in condition");
|
warn_unless_e_option("range literal in condition");
|
||||||
return node;
|
break;
|
||||||
|
|
||||||
case NODE_STR:
|
case NODE_STR:
|
||||||
if (log) break;
|
if (logop) break;
|
||||||
node->nd_lit = rb_reg_new(RSTRING(node->nd_lit)->ptr,RSTRING(node->nd_lit)->len,0);
|
node->nd_lit = rb_reg_new(RSTRING(node->nd_lit)->ptr,RSTRING(node->nd_lit)->len,0);
|
||||||
goto regexp;
|
goto regexp;
|
||||||
|
|
||||||
case NODE_LIT:
|
case NODE_LIT:
|
||||||
if (TYPE(node->nd_lit) == T_REGEXP) {
|
switch (TYPE(node->nd_lit)) {
|
||||||
|
case T_REGEXP:
|
||||||
regexp:
|
regexp:
|
||||||
nd_set_type(node, NODE_MATCH);
|
nd_set_type(node, NODE_MATCH);
|
||||||
local_cnt('_');
|
local_cnt('_');
|
||||||
local_cnt('~');
|
local_cnt('~');
|
||||||
rb_warn("string/regex literal in condition");
|
warn_unless_e_option("string/regex literal in condition");
|
||||||
return node;
|
break;
|
||||||
|
|
||||||
|
case T_FIXNUM:
|
||||||
|
if (logop) break;
|
||||||
|
warn_unless_e_option("integer literal in condition");
|
||||||
|
return call_op(node,tEQ,1,NEW_GVAR(rb_intern("$.")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
static NODE*
|
static NODE*
|
||||||
cond1(node, log)
|
cond1(node, logop)
|
||||||
NODE *node;
|
NODE *node;
|
||||||
int log;
|
int logop;
|
||||||
{
|
{
|
||||||
if (node == 0) return 0;
|
if (node == 0) return 0;
|
||||||
if (nd_type(node) == NODE_NEWLINE){
|
if (nd_type(node) == NODE_NEWLINE){
|
||||||
node->nd_next = cond0(node->nd_next, log);
|
node->nd_next = cond0(node->nd_next, logop);
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
return cond0(node, log);
|
return cond0(node, logop);
|
||||||
}
|
}
|
||||||
|
|
||||||
static NODE*
|
static NODE*
|
||||||
|
|
|
@ -8,16 +8,16 @@ end
|
||||||
|
|
||||||
if path == nil
|
if path == nil
|
||||||
path = ""
|
path = ""
|
||||||
elsif path !~ /\/$/
|
elsif path !~ %r|/$|
|
||||||
path += "/"
|
path += "/"
|
||||||
end
|
end
|
||||||
|
|
||||||
while gets()
|
while line = gets()
|
||||||
if /:$/
|
case line
|
||||||
|
when /:$/
|
||||||
path = $_.chop.chop + "/"
|
path = $_.chop.chop + "/"
|
||||||
elsif /^total/ || /^d/
|
when /^total/, /^d/
|
||||||
elsif /^(.*\d )(.+)$/
|
when /^(.*\d )(.+)$/
|
||||||
print($1, path, $2, "\n")
|
print($1, path, $2, "\n")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
$/ = nil
|
$/ = nil
|
||||||
while gets()
|
while line = gets()
|
||||||
if /^((void|VALUE|int|char *\*|ID|struct [\w_]+ *\*|st_table *\*) *)?\n([\w\d_]+)\(.*\)\n\s*((.+;\n)*)\{/
|
if /^((void|VALUE|int|char *\*|ID|struct [\w_]+ *\*|st_table *\*) *)?\n([\w\d_]+)\(.*\)\n\s*((.+;\n)*)\{/ =~ line
|
||||||
$_ = $'
|
$_ = $'
|
||||||
printf "%s %s(", $2, $3
|
printf "%s %s(", $2, $3
|
||||||
args = []
|
args = []
|
||||||
|
|
|
@ -116,21 +116,21 @@ tmp.close
|
||||||
tmp = open("while_tmp", "r")
|
tmp = open("while_tmp", "r")
|
||||||
test_ok(tmp.kind_of?(File))
|
test_ok(tmp.kind_of?(File))
|
||||||
|
|
||||||
while tmp.gets()
|
while line = tmp.gets()
|
||||||
break if /vt100/
|
break if /vt100/ =~ line
|
||||||
end
|
end
|
||||||
|
|
||||||
test_ok(!tmp.eof? && /vt100/)
|
test_ok(!tmp.eof? && /vt100/ =~ line)
|
||||||
tmp.close
|
tmp.close
|
||||||
|
|
||||||
# test next
|
# test next
|
||||||
$bad = false
|
$bad = false
|
||||||
tmp = open("while_tmp", "r")
|
tmp = open("while_tmp", "r")
|
||||||
while tmp.gets()
|
while line = tmp.gets()
|
||||||
next if /vt100/;
|
next if /vt100/ =~ line
|
||||||
$bad = 1 if /vt100/;
|
$bad = 1 if /vt100/ =~ line
|
||||||
end
|
end
|
||||||
test_ok(!(!tmp.eof? || /vt100/ || $bad))
|
test_ok(!(!tmp.eof? || /vt100/ =~ line || $bad))
|
||||||
tmp.close
|
tmp.close
|
||||||
|
|
||||||
# test redo
|
# test redo
|
||||||
|
@ -138,13 +138,13 @@ $bad = false
|
||||||
tmp = open("while_tmp", "r")
|
tmp = open("while_tmp", "r")
|
||||||
while tmp.gets()
|
while tmp.gets()
|
||||||
line = $_
|
line = $_
|
||||||
$_ = gsub(/vt100/, 'VT100')
|
gsub(/vt100/, 'VT100')
|
||||||
if $_ != line
|
if $_ != line
|
||||||
gsub!('VT100', 'Vt100')
|
$_.gsub!('VT100', 'Vt100')
|
||||||
redo;
|
redo
|
||||||
end
|
end
|
||||||
$bad = 1 if /vt100/
|
$bad = 1 if /vt100/ =~ $_
|
||||||
$bad = 1 if /VT100/
|
$bad = 1 if /VT100/ =~ $_
|
||||||
end
|
end
|
||||||
test_ok(tmp.eof? && !$bad)
|
test_ok(tmp.eof? && !$bad)
|
||||||
tmp.close
|
tmp.close
|
||||||
|
@ -162,11 +162,11 @@ test_ok(sum == 220)
|
||||||
# test interval
|
# test interval
|
||||||
$bad = false
|
$bad = false
|
||||||
tmp = open("while_tmp", "r")
|
tmp = open("while_tmp", "r")
|
||||||
while tmp.gets()
|
while line = tmp.gets()
|
||||||
break unless 1..2
|
break if 3
|
||||||
if /vt100/ || /Amiga/ || /paper/
|
case line
|
||||||
|
when /vt100/, /Amiga/, /paper/
|
||||||
$bad = true
|
$bad = true
|
||||||
break
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
test_ok(!$bad)
|
test_ok(!$bad)
|
||||||
|
|
|
@ -8,8 +8,8 @@ end
|
||||||
$sawbegin = 0
|
$sawbegin = 0
|
||||||
$sawend = 0
|
$sawend = 0
|
||||||
|
|
||||||
while gets()
|
while line = gets()
|
||||||
if /^begin\s*(\d*)\s*(\S*)/
|
if /^begin\s*(\d*)\s*(\S*)/ =~ line
|
||||||
$mode, $file = $1, $2
|
$mode, $file = $1, $2
|
||||||
$sawbegin+=1
|
$sawbegin+=1
|
||||||
if out_stdout
|
if out_stdout
|
||||||
|
@ -25,15 +25,15 @@ end
|
||||||
raise "missing begin" unless $sawbegin
|
raise "missing begin" unless $sawbegin
|
||||||
|
|
||||||
out.binmode
|
out.binmode
|
||||||
while gets()
|
while line = gets()
|
||||||
if /^end/
|
if /^end/ =~ line
|
||||||
$sawend+=1
|
$sawend+=1
|
||||||
out.close unless out_stdout
|
out.close unless out_stdout
|
||||||
File.chmod $mode.oct, $file unless out_stdout
|
File.chmod $mode.oct, $file unless out_stdout
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
sub(/[a-z]+$/, "") # handle stupid trailing lowercase letters
|
line.sub!(/[a-z]+$/, "") # handle stupid trailing lowercase letters
|
||||||
next if /[a-z]/
|
next if /[a-z]/ =~ line
|
||||||
next if !(((($_[0] - 32) & 077) + 2) / 3 == $_.length / 4)
|
next if !(((($_[0] - 32) & 077) + 2) / 3 == $_.length / 4)
|
||||||
out << $_.unpack("u") if $sawbegin > $sawend
|
out << $_.unpack("u") if $sawbegin > $sawend
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue