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