summaryrefslogtreecommitdiff
path: root/sample
diff options
context:
space:
mode:
Diffstat (limited to 'sample')
-rw-r--r--sample/fullpath.rb12
-rw-r--r--sample/mkproto.rb4
-rw-r--r--sample/test.rb32
-rw-r--r--sample/uumerge.rb12
4 files changed, 30 insertions, 30 deletions
diff --git a/sample/fullpath.rb b/sample/fullpath.rb
index ce268e20b9..252e7dc217 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 3423a15905..e1d49be3e3 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 2aa598fe34..3d8ce723cc 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 418323c439..2576bcb864 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