diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2000-12-28 05:00:47 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2000-12-28 05:00:47 +0000 |
commit | 31b9d2870e10dd0de788f9cfbf2d759cf3cbb8bf (patch) | |
tree | 571574af57859810d146f28177c240f1fe04e4f7 /sample | |
parent | 6202f851c777a8327491ddca8f2df39b20ff9b5a (diff) | |
download | ruby-31b9d2870e10dd0de788f9cfbf2d759cf3cbb8bf.tar.gz ruby-31b9d2870e10dd0de788f9cfbf2d759cf3cbb8bf.tar.xz ruby-31b9d2870e10dd0de788f9cfbf2d759cf3cbb8bf.zip |
changes from personal modifies -- matz
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@1084 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'sample')
-rw-r--r-- | sample/fullpath.rb | 12 | ||||
-rw-r--r-- | sample/mkproto.rb | 4 | ||||
-rw-r--r-- | sample/test.rb | 32 | ||||
-rw-r--r-- | sample/uumerge.rb | 12 |
4 files changed, 30 insertions, 30 deletions
diff --git a/sample/fullpath.rb b/sample/fullpath.rb index ce268e20b..252e7dc21 100644 --- a/sample/fullpath.rb +++ b/sample/fullpath.rb @@ -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 - diff --git a/sample/mkproto.rb b/sample/mkproto.rb index 3423a1590..e1d49be3e 100644 --- a/sample/mkproto.rb +++ b/sample/mkproto.rb @@ -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 = [] diff --git a/sample/test.rb b/sample/test.rb index 2aa598fe3..3d8ce723c 100644 --- a/sample/test.rb +++ b/sample/test.rb @@ -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) diff --git a/sample/uumerge.rb b/sample/uumerge.rb index 418323c43..2576bcb86 100644 --- a/sample/uumerge.rb +++ b/sample/uumerge.rb @@ -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 |