summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--sample/cal.rb10
-rw-r--r--sample/coverage.rb2
-rw-r--r--sample/drb/dbiff.rb22
-rw-r--r--sample/drb/dchats.rb20
-rw-r--r--sample/drb/dlogd.rb4
-rw-r--r--sample/drb/http0.rb60
-rw-r--r--sample/drb/http0serv.rb106
-rw-r--r--sample/drb/old_tuplespace.rb74
-rw-r--r--sample/drb/simpletuple.rb8
-rw-r--r--sample/dualstack-fetch.rb2
-rw-r--r--sample/dualstack-httpd.rb32
-rw-r--r--sample/fib.awk8
-rw-r--r--sample/fib.pl4
-rw-r--r--sample/fib.scm4
-rw-r--r--sample/from.rb38
-rw-r--r--sample/mkproto.rb22
-rw-r--r--sample/observ.rb8
-rw-r--r--sample/occur.pl8
-rw-r--r--sample/openssl/c_rehash.rb38
-rw-r--r--sample/openssl/certstore.rb52
-rw-r--r--sample/openssl/crlstore.rb32
-rwxr-xr-xsample/optparse/opttest.rb12
-rw-r--r--sample/rcs.awk54
-rw-r--r--sample/trojan.rb2
25 files changed, 316 insertions, 311 deletions
diff --git a/ChangeLog b/ChangeLog
index 0330d09acd..b6017c8af1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sat Jul 20 22:39:56 2013 Zachary Scott <e@zzak.io>
+
+ * sample/*: whitespace patch by Sergio Campama [Fixes GH-364]
+ https://github.com/ruby/ruby/pull/364
+
Sat Jul 20 22:33:13 2013 Zachary Scott <e@zzak.io>
* doc/regexp.rdoc: [DOC] Fix typo in example [Fixes GH-365]
diff --git a/sample/cal.rb b/sample/cal.rb
index 387657490f..97f75bcf1c 100644
--- a/sample/cal.rb
+++ b/sample/cal.rb
@@ -71,7 +71,7 @@ class Cal
ta = gr.collect{|xs| xs.join(' ')}
ca = %w(January February March April May June July
- August September October November December)[m - 1]
+ August September October November December)[m - 1]
ca = ca + ' ' + y.to_s if !@opt_y
ca = ca.center(@mw)
@@ -132,10 +132,10 @@ if __FILE__ == $0
begin
GetoptLong.new(['-c', GetoptLong::REQUIRED_ARGUMENT],
- ['-j', GetoptLong::NO_ARGUMENT],
- ['-m', GetoptLong::NO_ARGUMENT],
- ['-t', GetoptLong::NO_ARGUMENT],
- ['-y', GetoptLong::NO_ARGUMENT]).
+ ['-j', GetoptLong::NO_ARGUMENT],
+ ['-m', GetoptLong::NO_ARGUMENT],
+ ['-t', GetoptLong::NO_ARGUMENT],
+ ['-y', GetoptLong::NO_ARGUMENT]).
each do |opt, arg|
case opt
when '-c'; cal.opt_c(arg) || raise
diff --git a/sample/coverage.rb b/sample/coverage.rb
index 1e036f95f9..8e8d6167e2 100644
--- a/sample/coverage.rb
+++ b/sample/coverage.rb
@@ -38,7 +38,7 @@ at_exit do
end
cov
else
- p line
+ p line
warn("coverage file corrupted, ignoring: #{ cfile }")
break []
end
diff --git a/sample/drb/dbiff.rb b/sample/drb/dbiff.rb
index b50edc0898..290eb1d28b 100644
--- a/sample/drb/dbiff.rb
+++ b/sample/drb/dbiff.rb
@@ -19,18 +19,18 @@ class Biff
last = Time.now
while true
begin
- sleep(@interval)
- current = File::mtime(@filename)
- if current > last
- changed
- begin
- notify_observers(@filename, current)
- rescue Error
- end
- last = current
- end
+ sleep(@interval)
+ current = File::mtime(@filename)
+ if current > last
+ changed
+ begin
+ notify_observers(@filename, current)
+ rescue Error
+ end
+ last = current
+ end
rescue
- next
+ next
end
end
end
diff --git a/sample/drb/dchats.rb b/sample/drb/dchats.rb
index ccb2c7c9c5..c07f748e99 100644
--- a/sample/drb/dchats.rb
+++ b/sample/drb/dchats.rb
@@ -47,16 +47,16 @@ class ChatServer
msg2 = ">#{name}< #{str}"
@mutex.synchronize do
for m in @members.keys
- begin
- if m == there
- @members[m].listen(msg2)
- else
- @members[m].listen(msg)
- end
- rescue
- p $!
- @members.delete(m)
- end
+ begin
+ if m == there
+ @members[m].listen(msg2)
+ else
+ @members[m].listen(msg)
+ end
+ rescue
+ p $!
+ @members.delete(m)
+ end
end
end
end
diff --git a/sample/drb/dlogd.rb b/sample/drb/dlogd.rb
index fef7ca0f1d..42f302e64e 100644
--- a/sample/drb/dlogd.rb
+++ b/sample/drb/dlogd.rb
@@ -21,8 +21,8 @@ class Logger
def flush
begin
while(1)
- @fp.puts(@queue.pop)
- @fp.flush
+ @fp.puts(@queue.pop)
+ @fp.flush
end
ensure
@fp.close
diff --git a/sample/drb/http0.rb b/sample/drb/http0.rb
index d4c9f6b7fb..e40d810311 100644
--- a/sample/drb/http0.rb
+++ b/sample/drb/http0.rb
@@ -6,20 +6,20 @@ module DRb
module HTTP0
class StrStream
def initialize(str='')
- @buf = str
+ @buf = str
end
attr_reader :buf
def read(n)
- begin
- return @buf[0,n]
- ensure
- @buf[0,n] = ''
- end
+ begin
+ return @buf[0,n]
+ ensure
+ @buf[0,n] = ''
+ end
end
def write(s)
- @buf.concat s
+ @buf.concat s
end
end
@@ -29,47 +29,47 @@ module DRb
def self.open(uri, config)
unless /^http:/ =~ uri
- raise(DRbBadScheme, uri) unless uri =~ /^http:/
- raise(DRbBadURI, 'can\'t parse uri:' + uri)
+ raise(DRbBadScheme, uri) unless uri =~ /^http:/
+ raise(DRbBadURI, 'can\'t parse uri:' + uri)
end
ClientSide.new(uri, config)
end
class ClientSide
def initialize(uri, config)
- @uri = uri
- @res = nil
- @config = config
- @msg = DRbMessage.new(config)
- @proxy = ENV['HTTP_PROXY']
+ @uri = uri
+ @res = nil
+ @config = config
+ @msg = DRbMessage.new(config)
+ @proxy = ENV['HTTP_PROXY']
end
def close; end
def alive?; false; end
def send_request(ref, msg_id, *arg, &b)
- stream = StrStream.new
- @msg.send_request(stream, ref, msg_id, *arg, &b)
- @reply_stream = StrStream.new
- post(@uri, stream.buf)
+ stream = StrStream.new
+ @msg.send_request(stream, ref, msg_id, *arg, &b)
+ @reply_stream = StrStream.new
+ post(@uri, stream.buf)
end
def recv_reply
- @msg.recv_reply(@reply_stream)
+ @msg.recv_reply(@reply_stream)
end
def post(url, data)
- it = URI.parse(url)
- path = [(it.path=='' ? '/' : it.path), it.query].compact.join('?')
- http = Net::HTTP.new(it.host, it.port)
- sio = StrStream.new
- http.post(path, data, {'Content-Type'=>'application/octetstream;'}) do |str|
- sio.write(str)
- if @config[:load_limit] < sio.buf.size
- raise TypeError, 'too large packet'
- end
- end
- @reply_stream = sio
+ it = URI.parse(url)
+ path = [(it.path=='' ? '/' : it.path), it.query].compact.join('?')
+ http = Net::HTTP.new(it.host, it.port)
+ sio = StrStream.new
+ http.post(path, data, {'Content-Type'=>'application/octetstream;'}) do |str|
+ sio.write(str)
+ if @config[:load_limit] < sio.buf.size
+ raise TypeError, 'too large packet'
+ end
+ end
+ @reply_stream = sio
end
end
end
diff --git a/sample/drb/http0serv.rb b/sample/drb/http0serv.rb
index 8318123fa9..9503a1790c 100644
--- a/sample/drb/http0serv.rb
+++ b/sample/drb/http0serv.rb
@@ -8,111 +8,111 @@ module DRb
def self.open_server(uri, config)
unless /^http:/ =~ uri
- raise(DRbBadScheme, uri) unless uri =~ /^http:/
- raise(DRbBadURI, 'can\'t parse uri:' + uri)
+ raise(DRbBadScheme, uri) unless uri =~ /^http:/
+ raise(DRbBadURI, 'can\'t parse uri:' + uri)
end
Server.new(uri, config)
end
class Callback < WEBrick::HTTPServlet::AbstractServlet
def initialize(config, drb)
- @config = config
- @drb = drb
- @queue = Queue.new
+ @config = config
+ @drb = drb
+ @queue = Queue.new
end
def do_POST(req, res)
- @req = req
- @res = res
- @drb.push(self)
- @res.body = @queue.pop
- @res['content-type'] = 'application/octet-stream;'
+ @req = req
+ @res = res
+ @drb.push(self)
+ @res.body = @queue.pop
+ @res['content-type'] = 'application/octet-stream;'
end
def req_body
- @req.body
+ @req.body
end
def reply(body)
- @queue.push(body)
+ @queue.push(body)
end
def close
- @queue.push('')
+ @queue.push('')
end
end
class Server
def initialize(uri, config)
- @uri = uri
- @config = config
- @queue = Queue.new
- setup_webrick(uri)
+ @uri = uri
+ @config = config
+ @queue = Queue.new
+ setup_webrick(uri)
end
attr_reader :uri
def close
- @server.shutdown if @server
- @server = nil
+ @server.shutdown if @server
+ @server = nil
end
def push(callback)
- @queue.push(callback)
+ @queue.push(callback)
end
def accept
- client = @queue.pop
- ServerSide.new(client, @config)
+ client = @queue.pop
+ ServerSide.new(client, @config)
end
def setup_webrick(uri)
- logger = WEBrick::Log::new($stderr, WEBrick::Log::FATAL)
- u = URI.parse(uri)
- s = WEBrick::HTTPServer.new(:Port => u.port,
- :AddressFamily => Socket::AF_INET,
- :BindAddress => u.host,
- :Logger => logger,
- :ServerType => Thread)
- s.mount(u.path, Callback, self)
- @server = s
- s.start
+ logger = WEBrick::Log::new($stderr, WEBrick::Log::FATAL)
+ u = URI.parse(uri)
+ s = WEBrick::HTTPServer.new(:Port => u.port,
+ :AddressFamily => Socket::AF_INET,
+ :BindAddress => u.host,
+ :Logger => logger,
+ :ServerType => Thread)
+ s.mount(u.path, Callback, self)
+ @server = s
+ s.start
end
end
class ServerSide
def initialize(callback, config)
- @callback = callback
- @config = config
- @msg = DRbMessage.new(@config)
- @req_stream = StrStream.new(@callback.req_body)
+ @callback = callback
+ @config = config
+ @msg = DRbMessage.new(@config)
+ @req_stream = StrStream.new(@callback.req_body)
end
def close
- @callback.close if @callback
- @callback = nil
+ @callback.close if @callback
+ @callback = nil
end
def alive?; false; end
def recv_request
- begin
- @msg.recv_request(@req_stream)
- rescue
- close
- raise $!
- end
+ begin
+ @msg.recv_request(@req_stream)
+ rescue
+ close
+ raise $!
+ end
end
def send_reply(succ, result)
- begin
- return unless @callback
- stream = StrStream.new
- @msg.send_reply(stream, succ, result)
- @callback.reply(stream.buf)
- rescue
- close
- raise $!
- end
+ begin
+ return unless @callback
+ stream = StrStream.new
+ @msg.send_reply(stream, succ, result)
+ @callback.reply(stream.buf)
+ rescue
+ close
+ raise $!
+ end
end
end
end
diff --git a/sample/drb/old_tuplespace.rb b/sample/drb/old_tuplespace.rb
index 0da9fa84c3..9c10a34527 100644
--- a/sample/drb/old_tuplespace.rb
+++ b/sample/drb/old_tuplespace.rb
@@ -11,7 +11,7 @@ class TupleSpace
@list = list
@check_idx = []
@list.each_with_index do |x, i|
- @check_idx.push i if x
+ @check_idx.push i if x
end
@size = @list.size
end
@@ -22,9 +22,9 @@ class TupleSpace
def match(tuple)
return nil if tuple.size != self.size
@check_idx.each do |i|
- unless @list[i] === tuple[i]
- return false
- end
+ unless @list[i] === tuple[i]
+ return false
+ end
end
return true
end
@@ -47,13 +47,13 @@ class TupleSpace
found = false
@waiting[sz] = @waiting[sz].find_all { |x|
if x[0].match(tuple)
- begin
- x[1].wakeup
- rescue ThreadError
- end
- false
+ begin
+ x[1].wakeup
+ rescue ThreadError
+ end
+ false
else
- true
+ true
end
}
end
@@ -77,8 +77,8 @@ class TupleSpace
found = false
@que[sz].each_with_index do |x, i|
if template.match(x)
- found = true
- break
+ found = true
+ break
end
end
return nil unless found
@@ -110,17 +110,17 @@ class TupleSpace
def in(template, non_block=false)
begin
loop do
- Thread.critical = true
- tuple = get_que(template)
- unless tuple
- if non_block
- raise ThreadError, "queue empty"
- end
- put_waiting(template, Thread.current)
- Thread.stop
- else
- return tuple
- end
+ Thread.critical = true
+ tuple = get_que(template)
+ unless tuple
+ if non_block
+ raise ThreadError, "queue empty"
+ end
+ put_waiting(template, Thread.current)
+ Thread.stop
+ else
+ return tuple
+ end
end
ensure
Thread.critical = false
@@ -155,11 +155,11 @@ if __FILE__ == $0
def server(ts, id)
Thread.start {
loop do
- req = ts.in(['req', nil, nil])
- ac = req[1]
- num = req[2]
- sleep id
- ts.out([ac, id, num, num * num])
+ req = ts.in(['req', nil, nil])
+ ac = req[1]
+ num = req[2]
+ sleep id
+ ts.out([ac, id, num, num * num])
end
}
end
@@ -168,14 +168,14 @@ if __FILE__ == $0
Thread.start {
ac = Object.new
tuples = (1..10).collect { |i|
- ['req', ac, i * 10 + n]
+ ['req', ac, i * 10 + n]
}
ts.out(*tuples)
ts.out(tuples[0])
puts "out: #{n}"
11.times do |i|
- ans = ts.in([ac, nil, nil, nil])
- puts "client(#{n}) server(#{ans[1]}) #{ans[2]} #{ans[3]}"
+ ans = ts.in([ac, nil, nil, nil])
+ puts "client(#{n}) server(#{ans[1]}) #{ans[2]} #{ans[3]}"
end
}
end
@@ -183,12 +183,12 @@ if __FILE__ == $0
def watcher(ts)
Thread.start {
loop do
- begin
- sleep 1
- p ts.rd(['req', nil, nil], true)
- rescue ThreadError
- puts "'req' not found."
- end
+ begin
+ sleep 1
+ p ts.rd(['req', nil, nil], true)
+ rescue ThreadError
+ puts "'req' not found."
+ end
end
}
end
diff --git a/sample/drb/simpletuple.rb b/sample/drb/simpletuple.rb
index 1b9b7a35a7..bfbd86e665 100644
--- a/sample/drb/simpletuple.rb
+++ b/sample/drb/simpletuple.rb
@@ -58,10 +58,10 @@ if __FILE__ == $0
def server(ts)
Thread.start {
loop do
- req = ts.in('req')
- ac = req[0]
- num = req[1]
- ts.out(ac, num * num)
+ req = ts.in('req')
+ ac = req[0]
+ num = req[1]
+ ts.out(ac, num * num)
end
}
end
diff --git a/sample/dualstack-fetch.rb b/sample/dualstack-fetch.rb
index 1897a3d8e9..18d33cc45a 100644
--- a/sample/dualstack-fetch.rb
+++ b/sample/dualstack-fetch.rb
@@ -38,7 +38,7 @@ end
STDERR.print "conntecting to #{host} port #{port}\n"
c = TCPSocket.new(host, port)
dest = Socket.getnameinfo(c.getpeername,
- Socket::NI_NUMERICHOST|Socket::NI_NUMERICSERV)
+ Socket::NI_NUMERICHOST|Socket::NI_NUMERICSERV)
STDERR.print "conntected to #{dest[0]} port #{dest[1]}\n"
c.print "GET #{path} HTTP/1.0\n"
c.print "Host: #{host}\n"
diff --git a/sample/dualstack-httpd.rb b/sample/dualstack-httpd.rb
index 11c5201d74..a6d4d3a2c2 100644
--- a/sample/dualstack-httpd.rb
+++ b/sample/dualstack-httpd.rb
@@ -29,22 +29,22 @@ end
while true
as = ls.accept
Thread.start do
- STDERR.print "socket #{myname} accepted, thread ", Thread.current, "\n"
- s = as # copy to dynamic variable
- str = ''
- while line = s.gets
- break if line == "\r\n" or line == "\n"
- str << line
- end
- STDERR.print "socket #{myname} got string\n"
- s.write("HTTP/1.0 200 OK\n")
- s.write("Content-type: text/plain\n\n")
- s.write("this is test: my name is #{myname}, you sent:\n")
- s.write("---start\n")
- s.write(str)
- s.write("---end\n")
- s.close
- STDERR.print "socket #{myname} processed, thread ", Thread.current, " terminating\n"
+ STDERR.print "socket #{myname} accepted, thread ", Thread.current, "\n"
+ s = as # copy to dynamic variable
+ str = ''
+ while line = s.gets
+ break if line == "\r\n" or line == "\n"
+ str << line
+ end
+ STDERR.print "socket #{myname} got string\n"
+ s.write("HTTP/1.0 200 OK\n")
+ s.write("Content-type: text/plain\n\n")
+ s.write("this is test: my name is #{myname}, you sent:\n")
+ s.write("---start\n")
+ s.write(str)
+ s.write("---end\n")
+ s.close
+ STDERR.print "socket #{myname} processed, thread ", Thread.current, " terminating\n"
end
end
end
diff --git a/sample/fib.awk b/sample/fib.awk
index 7ebe8930f5..9589f97965 100644
--- a/sample/fib.awk
+++ b/sample/fib.awk
@@ -1,5 +1,5 @@
- function fib(n) {
- if ( n<2 ) return n; else return fib(n-2) + fib(n-1)
- }
+function fib(n) {
+ if ( n<2 ) return n; else return fib(n-2) + fib(n-1)
+}
- BEGIN { print fib(20); }
+BEGIN { print fib(20); }
diff --git a/sample/fib.pl b/sample/fib.pl
index 945a4929a7..4c35eaae31 100644
--- a/sample/fib.pl
+++ b/sample/fib.pl
@@ -1,10 +1,10 @@
sub fib {
my($n)=@_;
if ($n<2) {
- return $n;
+ return $n;
}
else {
- return fib($n-2)+fib($n-1);
+ return fib($n-2)+fib($n-1);
}
}
diff --git a/sample/fib.scm b/sample/fib.scm
index b246ca50ac..d2dc770282 100644
--- a/sample/fib.scm
+++ b/sample/fib.scm
@@ -1,7 +1,7 @@
(define (fib n)
(if (< n 2)
- n
- (+ (fib (- n 2)) (fib (- n 1)))))
+ n
+ (+ (fib (- n 2)) (fib (- n 1)))))
(display (fib 20))
(newline)
diff --git a/sample/from.rb b/sample/from.rb
index 918745e55f..db1299c869 100644
--- a/sample/from.rb
+++ b/sample/from.rb
@@ -43,8 +43,8 @@ def get_mailfile(user)
[ENV['SPOOLDIR'], '/usr/spool', '/var/spool', '/usr', '/var'].each do |m|
path = "#{m}/mail/#{user}"
if File.exist?(path)
- file = path
- break
+ file = path
+ break
end
end
end
@@ -64,23 +64,23 @@ def from_main
mtime = File.mtime(file)
open(file, "r") do |f|
until f.eof?
- header = {}
- f.each_line do |line|
- next if /^From / =~ line # skip From-line
- break if /^$/ =~ line # end of header
-
- if /^(?<attr>\S+?):\s*(?<value>.*)/ =~ line
- attr.capitalize!
- header[attr] = value
- elsif attr
- header[attr] += "\n" + line.lstrip
- end
- end
-
- f.each_line do |line|
- break if /^From / =~ line
- end
- outcount += fromout(header['Date'], header['From'], header['Subject'])
+ header = {}
+ f.each_line do |line|
+ next if /^From / =~ line # skip From-line
+ break if /^$/ =~ line # end of header
+
+ if /^(?<attr>\S+?):\s*(?<value>.*)/ =~ line
+ attr.capitalize!
+ header[attr] = value
+ elsif attr
+ header[attr] += "\n" + line.lstrip
+ end
+ end
+
+ f.each_line do |line|
+ break if /^From / =~ line
+ end
+ outcount += fromout(header['Date'], header['From'], header['Subject'])
end
end
File.utime(atime, mtime, file)
diff --git a/sample/mkproto.rb b/sample/mkproto.rb
index 6e7fc0f788..e650fe8d47 100644
--- a/sample/mkproto.rb
+++ b/sample/mkproto.rb
@@ -7,18 +7,18 @@ while line = gets()
for arg in $4.split(/;\n\s*/)
arg.gsub!(/ +/, ' ')
if arg =~ /,/
- if arg =~ /(([^*]+) *\** *\w+),/
- type = $2.strip
- args.push $1.strip
- arg = $'
- else
- type = ""
- end
- while arg.sub!(/(\** *\w+)(,|$)/, "") && $~
- args.push type + " " + $1.strip
- end
+ if arg =~ /(([^*]+) *\** *\w+),/
+ type = $2.strip
+ args.push $1.strip
+ arg = $'
+ else
+ type = ""
+ end
+ while arg.sub!(/(\** *\w+)(,|$)/, "") && $~
+ args.push type + " " + $1.strip
+ end
else
- args.push arg.strip
+ args.push arg.strip
end
end
printf "%s);\n", args.join(', ')
diff --git a/sample/observ.rb b/sample/observ.rb
index 72e5178b38..061e3c6a10 100644
--- a/sample/observ.rb
+++ b/sample/observ.rb
@@ -8,10 +8,10 @@ class Tick
def initialize
Thread.start do
loop do
- sleep 0.999
- now = Time.now
- changed
- notify_observers(now.hour, now.min, now.sec)
+ sleep 0.999
+ now = Time.now
+ changed
+ notify_observers(now.hour, now.min, now.sec)
end
end
end
diff --git a/sample/occur.pl b/sample/occur.pl
index 1f5fcf27a4..331ce50211 100644
--- a/sample/occur.pl
+++ b/sample/occur.pl
@@ -1,9 +1,9 @@
while (<>) {
- for (split(/\W+/)) {
- $freq{$_}++;
- }
+ for (split(/\W+/)) {
+ $freq{$_}++;
+ }
}
for (sort keys %freq) {
- print "$_ -- $freq{$_}\n";
+ print "$_ -- $freq{$_}\n";
}
diff --git a/sample/openssl/c_rehash.rb b/sample/openssl/c_rehash.rb
index afbb654517..cd6c9d5fd4 100644
--- a/sample/openssl/c_rehash.rb
+++ b/sample/openssl/c_rehash.rb
@@ -54,13 +54,13 @@ class CHashDir
OpenSSL::X509::Certificate.new(str)
rescue
begin
- OpenSSL::X509::CRL.new(str)
+ OpenSSL::X509::CRL.new(str)
rescue
- begin
- OpenSSL::X509::Request.new(str)
- rescue
- nil
- end
+ begin
+ OpenSSL::X509::Request.new(str)
+ rescue
+ nil
+ end
end
end
end
@@ -75,15 +75,15 @@ private
Dir.chdir(@dirpath) do
delete_symlink
Dir.glob('*.pem') do |pemfile|
- cert = load_pem_file(pemfile)
- case cert
- when OpenSSL::X509::Certificate
- link_hash_cert(pemfile, cert)
- when OpenSSL::X509::CRL
- link_hash_crl(pemfile, cert)
- else
- STDERR.puts("WARNING: #{pemfile} does not contain a certificate or CRL: skipping") unless @silent
- end
+ cert = load_pem_file(pemfile)
+ case cert
+ when OpenSSL::X509::Certificate
+ link_hash_cert(pemfile, cert)
+ when OpenSSL::X509::CRL
+ link_hash_crl(pemfile, cert)
+ else
+ STDERR.puts("WARNING: #{pemfile} does not contain a certificate or CRL: skipping") unless @silent
+ end
end
end
end
@@ -103,7 +103,7 @@ private
}
unless filepath
unless @silent
- STDERR.puts("WARNING: Skipping duplicate certificate #{org_filename}")
+ STDERR.puts("WARNING: Skipping duplicate certificate #{org_filename}")
end
else
(@cert_cache[name_hash] ||= []) << path(filepath)
@@ -118,7 +118,7 @@ private
}
unless filepath
unless @silent
- STDERR.puts("WARNING: Skipping duplicate CRL #{org_filename}")
+ STDERR.puts("WARNING: Skipping duplicate CRL #{org_filename}")
end
else
(@crl_cache[name_hash] ||= []) << path(filepath)
@@ -132,7 +132,7 @@ private
filepath = yield(idx)
break unless FileTest.symlink?(filepath) or FileTest.exist?(filepath)
if @fingerprint_cache[filepath] == fingerprint
- return false
+ return false
end
idx += 1
end
@@ -147,7 +147,7 @@ private
File.symlink(from, to)
rescue
File.open(to, "w") do |f|
- f << File.read(from)
+ f << File.read(from)
end
end
end
diff --git a/sample/openssl/certstore.rb b/sample/openssl/certstore.rb
index c0bc21bcbb..c6e8f816bc 100644
--- a/sample/openssl/certstore.rb
+++ b/sample/openssl/certstore.rb
@@ -76,27 +76,27 @@ private
result = @x509store.verify(cert) do |ok, ctx|
cert = ctx.current_cert
if ctx.current_crl
- crl_map[cert.subject] = true
+ crl_map[cert.subject] = true
end
if ok
- if !ctx.current_crl
- if crl = @crl_store.find_crl(cert)
- crl_map[cert.subject] = true
- if crl.revoked.find { |revoked| revoked.serial == cert.serial }
- ok = false
- error_string = 'certification revoked'
- end
- end
- end
+ if !ctx.current_crl
+ if crl = @crl_store.find_crl(cert)
+ crl_map[cert.subject] = true
+ if crl.revoked.find { |revoked| revoked.serial == cert.serial }
+ ok = false
+ error_string = 'certification revoked'
+ end
+ end
+ end
end
error_map[cert.subject] = error_string if error_string
ok
end
error = if result
- nil
- else
- error_map[cert.subject] || @x509store.error_string
- end
+ nil
+ else
+ error_map[cert.subject] || @x509store.error_string
+ end
return error, crl_map
end
@@ -105,13 +105,13 @@ private
cert = generate_cert(certfile)
case guess_cert_type(cert)
when CERT_TYPE_SELF_SIGNED
- @self_signed_ca << cert
+ @self_signed_ca << cert
when CERT_TYPE_OTHER
- @other_ca << cert
+ @other_ca << cert
when CERT_TYPE_EE
- @ee << cert
+ @ee << cert
else
- raise "Unknown cert type."
+ raise "Unknown cert type."
end
end
@c_store.get_crls.each do |crlfile|
@@ -128,21 +128,21 @@ private
# Ignores criticality of extensions. It's 'guess'ing.
case ext.oid
when 'basicConstraints'
- /CA:(TRUE|FALSE), pathlen:(\d+)/ =~ ext.value
- ca = ($1 == 'TRUE') unless ca
+ /CA:(TRUE|FALSE), pathlen:(\d+)/ =~ ext.value
+ ca = ($1 == 'TRUE') unless ca
when 'keyUsage'
- usage = ext.value.split(/\s*,\s*/)
- ca = usage.include?('Certificate Sign') unless ca
+ usage = ext.value.split(/\s*,\s*/)
+ ca = usage.include?('Certificate Sign') unless ca
when 'nsCertType'
- usage = ext.value.split(/\s*,\s*/)
- ca = usage.include?('SSL CA') unless ca
+ usage = ext.value.split(/\s*,\s*/)
+ ca = usage.include?('SSL CA') unless ca
end
end
if ca
if self_signed
- CERT_TYPE_SELF_SIGNED
+ CERT_TYPE_SELF_SIGNED
else
- CERT_TYPE_OTHER
+ CERT_TYPE_OTHER
end
else
CERT_TYPE_EE
diff --git a/sample/openssl/crlstore.rb b/sample/openssl/crlstore.rb
index b305913eb0..e3a592567c 100644
--- a/sample/openssl/crlstore.rb
+++ b/sample/openssl/crlstore.rb
@@ -24,22 +24,22 @@ private
end
unless crlfiles = @c_store.get_crls(ca.subject)
if crl = renew_crl(cert, ca)
- @c_store.add_crl(crl)
- return crl
+ @c_store.add_crl(crl)
+ return crl
end
return nil
end
crlfiles.each do |crlfile|
next unless crl = load_crl(crlfile)
if crl.next_update < Time.now
- if new_crl = renew_crl(cert, ca)
- @c_store.delete_crl(crl)
- @c_store.add_crl(new_crl)
- crl = new_crl
- end
+ if new_crl = renew_crl(cert, ca)
+ @c_store.delete_crl(crl)
+ @c_store.add_crl(new_crl)
+ crl = new_crl
+ end
end
if check_valid(crl, ca)
- return crl
+ return crl
end
end
nil
@@ -49,7 +49,7 @@ private
@c_store.get_certs(cert.issuer).each do |cafile|
ca = load_cert(cafile)
if cert.verify(ca.public_key)
- return ca
+ return ca
end
end
nil
@@ -58,10 +58,10 @@ private
def fetch(location)
if /\AURI:(.*)\z/ =~ location
begin
- c = HTTPAccess2::Client.new(ENV['http_proxy'] || ENV['HTTP_PROXY'])
- c.get_content($1)
+ c = HTTPAccess2::Client.new(ENV['http_proxy'] || ENV['HTTP_PROXY'])
+ c.get_content($1)
rescue NameError, StandardError
- nil
+ nil
end
else
nil
@@ -103,10 +103,10 @@ private
def renew_crl(cert, ca)
if cdp = get_cdp(cert)
if new_crl_str = fetch(cdp)
- new_crl = load_crl_str(new_crl_str)
- if check_valid(new_crl, ca)
- return new_crl
- end
+ new_crl = load_crl_str(new_crl_str)
+ if check_valid(new_crl, ca)
+ return new_crl
+ end
end
end
false
diff --git a/sample/optparse/opttest.rb b/sample/optparse/opttest.rb
index 9247af494f..6f80a85e5d 100755
--- a/sample/optparse/opttest.rb
+++ b/sample/optparse/opttest.rb
@@ -22,13 +22,13 @@ ARGV.options do
# mandatory argument
opts.on("-r", "--require=LIBRARY", String,
- "require the LIBRARY, before",
- "executing your script") {|lib|@library=lib}
+ "require the LIBRARY, before",
+ "executing your script") {|lib|@library=lib}
# optional argument
opts.on("-i", "--inplace=[EXTENSION]",
- "edit ARGV files in place", # multiline description
- "(make backup if EXTENSION supplied)") {|inplace| @inplace = inplace || ''}
+ "edit ARGV files in place", # multiline description
+ "(make backup if EXTENSION supplied)") {|inplace| @inplace = inplace || ''}
opts.on("-N=[NUM]", Integer) {|num|@number=num}
@@ -37,7 +37,7 @@ ARGV.options do
# limit argument syntax
opts.on("-[0-7]", "-F", "--irs=[OCTAL]", OptionParser::OctalInteger,
- "specify record separator", "(\\0, if no argument)") {|irs|@irs=irs}
+ "specify record separator", "(\\0, if no argument)") {|irs|@irs=irs}
# boolean switch(default true)
@exec = true
@@ -51,7 +51,7 @@ ARGV.options do
# keyword completion
opts.on("--code=CODE", CODES, CODE_ALIASES, "select coding system",
- "("+CODES.join(",")+",", " "+CODE_ALIASES.keys.join(",")+")") {|c|@code=c}
+ "("+CODES.join(",")+",", " "+CODE_ALIASES.keys.join(",")+")") {|c|@code=c}
# optional argument with keyword completion
opts.on("--type[=TYPE]", [:text, :binary], "select type(text, binary)") {|t|@type=t}
diff --git a/sample/rcs.awk b/sample/rcs.awk
index 08979285c9..e64af5b628 100644
--- a/sample/rcs.awk
+++ b/sample/rcs.awk
@@ -1,33 +1,33 @@
BEGIN {
- sw = 40.0;
- dw = 78.0;
- hdw = dw / 2.0;
- w = 20.0;
- h =1.0;
- d = 0.2;
- ss="abcdefghijklmnopqrstuvwxyz0123456789!#$%^&*()-=\\[];'`,./";
- rnd = srand();
+ sw = 40.0;
+ dw = 78.0;
+ hdw = dw / 2.0;
+ w = 20.0;
+ h =1.0;
+ d = 0.2;
+ ss="abcdefghijklmnopqrstuvwxyz0123456789!#$%^&*()-=\\[];'`,./";
+ rnd = srand();
}
{
- xr = -hdw; y = h * 1.0; maxxl = -999;
- s = "";
- while (xr < hdw) {
- x = xr * (1 + y) - y * w / 2;
- i = (x / (1 + h) + sw /2);
- c = (0 < i && i < length($0)) ? substr($0, i, 1) : "0";
- y = h - d * c;
- xl = xr - w * y / (1 + y);
- if (xl < -hdw || xl >= hdw || xl <= maxxl) {
- t = rand() * length(ss);
- c = substr(ss, t, 1);
- }
- else {
- c = substr(s, xl + hdw, 1);
- maxxl = xl;
- }
- s = s c;
- xr = xr + 1;
+ xr = -hdw; y = h * 1.0; maxxl = -999;
+ s = "";
+ while (xr < hdw) {
+ x = xr * (1 + y) - y * w / 2;
+ i = (x / (1 + h) + sw /2);
+ c = (0 < i && i < length($0)) ? substr($0, i, 1) : "0";
+ y = h - d * c;
+ xl = xr - w * y / (1 + y);
+ if (xl < -hdw || xl >= hdw || xl <= maxxl) {
+ t = rand() * length(ss);
+ c = substr(ss, t, 1);
}
- print s;
+ else {
+ c = substr(s, xl + hdw, 1);
+ maxxl = xl;
+ }
+ s = s c;
+ xr = xr + 1;
+ }
+ print s;
}
diff --git a/sample/trojan.rb b/sample/trojan.rb
index 2be9567b98..cea0dae098 100644
--- a/sample/trojan.rb
+++ b/sample/trojan.rb
@@ -7,7 +7,7 @@ for dir in path
for f in d = Dir.open(dir)
fpath = File.join(dir, f)
if File.file?(fpath) && (File.stat(fpath).mode & 022) != 0
- printf("file %s is writable from other users\n", fpath)
+ printf("file %s is writable from other users\n", fpath)
end
end
d.close