summaryrefslogtreecommitdiff
path: root/sample/uumerge.rb
diff options
context:
space:
mode:
authorYukihiro Matsumoto <matz@ruby-lang.org>1994-10-13 21:19:03 (GMT)
committerTakashi Kokubun <takashikkbn@gmail.com>2019-08-17 13:09:30 (GMT)
commit29f237a8b1df650089b54447f070726c75706b6f (patch)
treee6ee836a39a5f2f1d433d6532de32471b655fb6d /sample/uumerge.rb
parent173976c97c9426aa8d96e53aef6c0e570c5fdfda (diff)
version 0.54v0_54
https://cache.ruby-lang.org/pub/ruby/1.0/ruby-0.54.tar.gz
Diffstat (limited to 'sample/uumerge.rb')
-rwxr-xr-xsample/uumerge.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/sample/uumerge.rb b/sample/uumerge.rb
new file mode 100755
index 0000000..420a392
--- /dev/null
+++ b/sample/uumerge.rb
@@ -0,0 +1,27 @@
+#!/usr/local/bin/ruby
+
+while gets()
+ if /^begin\s*(\d*)\s*(\S*)/
+ $mode, $file = $1, $2
+ $sawbegin+=1
+ break
+ end
+end
+
+fail "missing begin" unless $sawbegin;
+OUT = open($file, "w") if $file != "";
+
+while gets()
+ if /^end/
+ $sawend+=1
+ break
+ end
+ sub(/[a-z]+$/, ""); # handle stupid trailing lowercase letters
+ continue if /[a-z]/
+ continue unless ((($_[0] - 32) & 077) + 2) / 3 == $_.length / 4
+ OUT << $_.unpack("u");
+end
+
+fail "missing end" unless $sawend;
+File.chmod $mode.oct, $file;
+exit 0;