diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-01-16 12:13:05 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-01-16 12:13:05 +0000 |
commit | 3db12e8b236ac8f88db8eb4690d10e4a3b8dbcd4 (patch) | |
tree | b3c086e437cab449f90ba637710daed0ddfec4c4 /sample/uumerge.rb | |
parent | 392296c12de9d7f9be03a8205250ba0844cb9d38 (diff) | |
download | ruby-3db12e8b236ac8f88db8eb4690d10e4a3b8dbcd4.tar.gz |
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'sample/uumerge.rb')
-rw-r--r-- | sample/uumerge.rb | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/sample/uumerge.rb b/sample/uumerge.rb new file mode 100644 index 0000000000..297b08f26a --- /dev/null +++ b/sample/uumerge.rb @@ -0,0 +1,37 @@ +#!/usr/local/bin/ruby + +if ARGV[0] == "-c" + out_stdout = 1; + ARGV.shift +end + +while gets() + if /^begin\s*(\d*)\s*(\S*)/ + $mode, $file = $1, $2 + $sawbegin+=1 + break + end +end + +fail "missing begin" if ! $sawbegin; + +if out_stdout + out = STDOUT +else + out = open($file, "w") if $file != ""; +end + +while gets() + if /^end/ + $sawend+=1 + break + end + sub(/[a-z]+$/, ""); # handle stupid trailing lowercase letters + next if /[a-z]/ + next if !(((($_[0] - 32) & 077) + 2) / 3 == $_.length / 4) + out << $_.unpack("u"); +end + +fail "missing end" if !$sawend; +File.chmod $mode.oct, $file if ! out_stdout +exit 0; |