summaryrefslogtreecommitdiff
path: root/sample/uumerge.rb
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-01-16 12:19:22 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-01-16 12:19:22 +0000
commitfd1d8cdc09ed86e4a0812120a17ff0d7b04adcaf (patch)
tree341289a84a427f1e92425c7ebf82d2f1733e9a40 /sample/uumerge.rb
parentf12baed5df6d3c213dd75d2f0d9f36bb179fb843 (diff)
*** empty log message ***
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/RUBY@11 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'sample/uumerge.rb')
-rw-r--r--sample/uumerge.rb36
1 files changed, 21 insertions, 15 deletions
diff --git a/sample/uumerge.rb b/sample/uumerge.rb
index 297b08f..26f2892 100644
--- a/sample/uumerge.rb
+++ b/sample/uumerge.rb
@@ -1,37 +1,43 @@
#!/usr/local/bin/ruby
if ARGV[0] == "-c"
- out_stdout = 1;
+ out_stdout = 1
ARGV.shift
end
+$sawbegin = 0
+$sawend = 0
+
while gets()
if /^begin\s*(\d*)\s*(\S*)/
$mode, $file = $1, $2
$sawbegin+=1
- break
+ if out_stdout
+ out = STDOUT
+ else
+ out = open($file, "w") if $file != ""
+ end
+ out.binmode
+ next
end
end
-fail "missing begin" if ! $sawbegin;
-
-if out_stdout
- out = STDOUT
-else
- out = open($file, "w") if $file != "";
-end
+raise "missing begin" unless $sawbegin
+out.binmode
while gets()
if /^end/
$sawend+=1
- break
+ out.close unless out_stdout
+ File.chmod $mode.oct, $file unless out_stdout
+ next
end
- sub(/[a-z]+$/, ""); # handle stupid trailing lowercase letters
+ sub(/[a-z]+$/, "") # handle stupid trailing lowercase letters
next if /[a-z]/
next if !(((($_[0] - 32) & 077) + 2) / 3 == $_.length / 4)
- out << $_.unpack("u");
+ out << $_.unpack("u") if $sawbegin > $sawend
end
-fail "missing end" if !$sawend;
-File.chmod $mode.oct, $file if ! out_stdout
-exit 0;
+raise "missing end" if $sawbegin > $sawend
+raise "missing begin" if ! $sawbegin
+exit 0