From 2c32a5c1ab3f0207a7a37762edcbde20c51dcdf8 Mon Sep 17 00:00:00 2001 From: Jean Guyader Date: Fri, 19 Jun 2009 14:25:53 +0100 Subject: [PATCH] Support for ruby 1.9. In ruby 1.9 "hello"[1] -> "e" In ruby 1.8 "hello"[1] -> 101 --- lib/dbus/auth.rb | 2 +- lib/dbus/marshall.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/dbus/auth.rb b/lib/dbus/auth.rb index 42a3243..9ae515a 100644 --- a/lib/dbus/auth.rb +++ b/lib/dbus/auth.rb @@ -30,7 +30,7 @@ module DBus # obtain for "1000" => 31303030 This is what the server is expecting. # Why? I dunno. How did I come to that conclusion? by looking at rbus # code. I have no idea how he found that out. - return Process.uid.to_s.split(//).collect { |a| "%x" % a[0] }.join + return Process.uid.to_s.split(//).collect { |a| "%x" % a[0].ord }.join end end diff --git a/lib/dbus/marshall.rb b/lib/dbus/marshall.rb index 23a0f3b..c2426d4 100644 --- a/lib/dbus/marshall.rb +++ b/lib/dbus/marshall.rb @@ -94,7 +94,7 @@ module DBus # Retrieve the series of bytes until the next NULL (\0) byte. def get_nul_terminated - raise IncompleteBufferException if not @buffy[@idx..-1] =~ /^([^\0]*)\0/ + raise IncompleteBufferException if not @buffy[@idx..-1].ord =~ /^([^\0]*)\0/ str = $1 raise IncompleteBufferException if @idx + str.size + 1 > @buffy.size @idx += str.size + 1 @@ -109,7 +109,7 @@ module DBus ret = @buffy.slice(@idx, str_sz) raise IncompleteBufferException if @idx + str_sz + 1 > @buffy.size @idx += str_sz - if @buffy[@idx] != 0 + if @buffy[@idx].ord != 0 raise InvalidPacketException, "String is not nul-terminated" end @idx += 1 @@ -124,7 +124,7 @@ module DBus ret = @buffy.slice(@idx, str_sz) raise IncompleteBufferException if @idx + str_sz + 1 >= @buffy.size @idx += str_sz - if @buffy[@idx] != 0 + if @buffy[@idx].ord != 0 raise InvalidPacketException, "Type is not nul-terminated" end @idx += 1 -- 2.39.5