<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,5 +1,6 @@
-require 'util'
-require 'constants'
-require 'messages'
-require 'connection'
+%w[util
+   constants
+   messages
+   connection].each {|f| require &quot;#{ File.dirname(__FILE__) }/#{ f }&quot; }
+
 </diff>
      <filename>asymy.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,46 +1,49 @@
-require 'asymy'
+require File.dirname(__FILE__) + '/asymy'
+
 require 'stringio'
 
-# XXX for debugging
+# XXX for debugging --- ditch both these methods when we're done
 
 class Fixnum; def printable?; self &gt;= 0x20 &amp;&amp; self &lt;= 0x7e; end; end
 
 class String
-    def hexdump(capture=false)
-        sio = StringIO.new
-        rem = size - 1
-        off = 0
-
-        while rem &gt; 0
-            pbuf = &quot;&quot;
-            pad = (15 - rem) if rem &lt; 16
-            pad ||= 0
-
-            sio.write((&quot;0&quot; * (8 - (x = off.to_s(16)).size)) + x + &quot;  &quot;)
-
-            0.upto(15-pad) do |i|
-                c = self[off]
-                x = c.to_s(16)
-                sio.write((&quot;0&quot; * (2 - x.size)) + x + &quot; &quot;)
-                if c.printable?
-                    pbuf &lt;&lt; c
-                else
-                    pbuf &lt;&lt; &quot;.&quot;
+    if RUBY_VERSION[0..2] != '1.9'
+        def hexdump(capture=false)
+            sio = StringIO.new
+            rem = size - 1
+            off = 0
+
+            while rem &gt; 0
+                pbuf = &quot;&quot;
+                pad = (15 - rem) if rem &lt; 16
+                pad ||= 0
+
+                sio.write((&quot;0&quot; * (8 - (x = off.to_s(16)).size)) + x + &quot;  &quot;)
+
+                0.upto(15-pad) do |i|
+                    c = self[off]
+                    x = c.to_s(16)
+                    sio.write((&quot;0&quot; * (2 - x.size)) + x + &quot; &quot;)
+                    if c.printable?
+                        pbuf &lt;&lt; c
+                    else
+                        pbuf &lt;&lt; &quot;.&quot;
+                    end
+                    off += 1
+                    rem -= 1
+                    sio.write(&quot; &quot;) if i == 7
                 end
-                off += 1
-                rem -= 1
-                sio.write(&quot; &quot;) if i == 7
-            end
 
-            sio.write(&quot;-- &quot; * pad) if pad &gt; 0
-            sio.write(&quot; |#{ pbuf }|\n&quot;)
-        end
+                sio.write(&quot;-- &quot; * pad) if pad &gt; 0
+                sio.write(&quot; |#{ pbuf }|\n&quot;)
+            end
 
-        sio.rewind()
-        if capture
-            sio.read()
-        else
-            puts sio.read()
+            sio.rewind()
+            if capture
+                sio.read()
+            else
+                puts sio.read()
+            end
         end
     end
 end
@@ -117,7 +120,7 @@ module Asymy
             def receive_packet(num, packet)
                 # special case errors until I waste the time to scan them to see if they're
                 # 4.0 or 4.1 packets. XXX
-                if packet[0] == 0xFF
+                if packet[0].ord == 0xFF
                     self.error = packet[3..-1]
                     self.state = :error
                 end
@@ -142,13 +145,13 @@ module Asymy
                     # XXX just ignore for now
                     self.state = :awaiting_fields
                 when :awaiting_fields
-                    if packet[0] == 0xfe
+                    if packet[0].ord == 0xfe
                         self.state = :awaiting_rows
                     else
                         handle_field(num, Packets::Field.new(packet))
                     end
                 when :awaiting_rows
-                    if packet[0] == 0xfe
+                    if packet[0].ord == 0xfe
                         @cb.call(@fields, @rows)
                         @fields = nil
                         @rows = nil</diff>
      <filename>connection.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,21 +1,21 @@
-require 'asymy'
+require File.dirname(__FILE__) + '/asymy'
 
 module Asymy
     class Framer &lt; String
         include StringX
-        
+
         def complete?
             return false if (sz = size()) &lt; 4
             return false if sz &lt; (to_l24() + 4)
             return true
         end
-        
+
         def next_buffer
             sz = shift_l24()
-            num = slice!(0)
+            num = slice!(0).ord
             return num, slice!(0, sz).extend(StringX)
-        end        
-    end    
+        end
+    end
 
     module Packets
         class Packet
@@ -23,18 +23,18 @@ module Asymy
                 @@fields ||= Hash.new {|h, k| h[k] = []}
                 @@fields[self] &lt;&lt; [n, t, default]
                 attr_accessor n
-            end                       
-            
-            def initialize(buf=nil)                
+            end
+
+            def initialize(buf=nil)
                 if buf
                     @@fields[self.class].each do |tup|
                         sym = &quot;@#{ tup[0] }&quot;.intern
-                        if (t = tup[1].to_s)[0].chr == &quot;r&quot;
+                        if (t = tup[1].to_s)[0].ord.chr == &quot;r&quot;
                             instance_variable_set sym, buf.shift_r(t[1..-1].to_i)
                         else
                             instance_variable_set sym, buf.send(&quot;shift_#{ t }&quot;)
                         end
-                    end 
+                    end
                 else
                     @@fields[self.class].each do |tup|
                         if tup[2]
@@ -44,19 +44,19 @@ module Asymy
                     end
                 end
             end
-            
+
             def marshall(num=0)
                 m = @@fields[self.class].map do |tup|
                     sym = &quot;@#{ tup[0] }&quot;.intern
                     t = tup[1].to_s
-                    t = &quot;r&quot; if t[0].chr == &quot;r&quot;
+                    t = &quot;r&quot; if t[0].ord.chr == &quot;r&quot;
                     instance_variable_get(sym).send(&quot;to_#{ t }&quot;)
                 end.join(&quot;&quot;)
 
                 (m.size.to_l24 + num.chr + m).extend(StringX)
             end
         end
-        
+
         class Greeting &lt; Packet
             field :protocol_version, :l8
             field :server_version, :asciiz
@@ -69,7 +69,7 @@ module Asymy
             field :padding, :r13
             field :challenge_tail, :r12
         end
-        
+
         class Authenticate &lt; Packet
             field :client_flags, :l32
             field :max_packet_size, :l32, 0x1000000
@@ -88,7 +88,7 @@ module Asymy
             field :warning_count, :l16
             field :message, :asciiz
         end
-        
+
         class Error &lt; Packet
             field :field_count, :l8
             field :errno, :l16
@@ -96,12 +96,12 @@ module Asymy
             field :sqlstate, :r5
             field :message, :asciiz
         end
-        
+
         class ResultSet &lt; Packet
             field :field_count, :lcb_int
             field :extra, :lcb_int
         end
-        
+
         class Field &lt; Packet
             field :catalog, :lcstring
             field :db, :lcstring
@@ -118,16 +118,16 @@ module Asymy
             field :z2, :l16
             field :default, :lcstring
         end
-        
+
         class EOF &lt; Packet
             field :field_count, :l8
             field :warning_count, :l16
             field :status_flags, :l16
         end
-        
+
         class RowData &lt; Packet
         end
-        
+
         class ChangeUser &lt; Packet
             field :command, :l8, Commands::CHANGE_USER
             field :name, :asciiz
@@ -135,16 +135,16 @@ module Asymy
             field :database, :asciiz
             field :charset, :l16, 0x8
         end
-        
+
         class ProcessKill &lt; Packet
             field :command, :l8, Commands::PROCESS_KILL
             field :process, :l32
         end
-        
+
         class Command &lt; Packet
             field :command, :l8
             field :arg, :asciiz
         end
-    end    
-    
+    end
+
 end</diff>
      <filename>messages.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,3 +1,5 @@
+# XXX monkeying with Numeric, shameful.
+
 class Numeric
     def to_lcb_int
         case self
@@ -17,6 +19,8 @@ class Numeric
     def to_l16; [self].pack(&quot;v&quot;); end
     def to_l64; [self].pack(&quot;Q&quot;); end
     def to_l24; self.to_l32[0,3]; end
+
+    def ord; self; end unless RUBY_VERSION[0..2] == '1.9'
 end
 
 module Asymy
@@ -24,14 +28,14 @@ module Asymy
         def crypt(nonce)
             sha = lambda {|k| OpenSSL::Digest::SHA1.new(k).digest }
             h3 = sha.call(nonce + sha.call((h1 = sha.call(self))))
-            (0...h3.size).map {|i| (h3[i] ^ h1[i]).chr }.join(&quot;&quot;).extend(StringX)
+            (0...h3.size).map {|i| (h3[i].ord ^ h1[i].ord).chr }.join(&quot;&quot;).extend(StringX)
         end
 
         def to_lcb_int(sz=false)
             s = 1
-            case self[0]
+            case (r = self.to_l8())
             when 0..250
-                r = self[0]
+                r
             when 251
                 r = :null
             when 252
@@ -54,29 +58,30 @@ module Asymy
             end
         end
 
+        def to_l8; unpack(&quot;C&quot;).first; end
         def to_l16; unpack(&quot;v&quot;).first; end
         def to_l32; unpack(&quot;L&quot;).first; end
         def to_l64; unpack(&quot;Q&quot;).first; end ## XXX endian
         def to_l24; (self[0,3] + &quot;\x00&quot;).unpack(&quot;L&quot;).first; end # XXX cheat
 
         def shift_lcb_int
-            case (x = slice!(0))
+            case (x = shift_l8())
             when 0..250
                 x
             when 251
                 :null
             when 252
-                slice!(0..2).extend(StringX).to_l16
+                shift_l16()
             when 253
-                slice!(0..4).extend(StringX).to_l32
+                shift_l32()
             when 254
-                slice!(0..8).extend(StringX).to_l64
+                shift_l64()
             else
                 raise &quot;invalid discriminator&quot;
             end
         end
 
-        def shift_l8; slice!(0); end
+        def shift_l8; slice!(0..0).extend(StringX).to_l8; end
         def shift_l16; slice!(0...2).extend(StringX).to_l16; end
         def shift_l24; slice!(0...3).extend(StringX).to_l24; end
         def shift_l32; slice!(0...4).extend(StringX).to_l32; end</diff>
      <filename>util.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>fd3bfcd8c3c3b2fe48b4bfb841389f902202a370</id>
    </parent>
  </parents>
  <author>
    <name>Thomas Ptacek</name>
    <email>tqbf@matasano.com</email>
  </author>
  <url>http://github.com/tqbf/asymy/commit/ef447a762996c83b4b6e83dd63fddb8810d3ef96</url>
  <id>ef447a762996c83b4b6e83dd63fddb8810d3ef96</id>
  <committed-date>2008-06-12T22:18:09-07:00</committed-date>
  <authored-date>2008-06-12T22:18:09-07:00</authored-date>
  <message>Bunch of 1.9 fixes from Roger</message>
  <tree>a32313904f0d06fb201bf41612486a1e029aa1ab</tree>
  <committer>
    <name>Thomas Ptacek</name>
    <email>tqbf@matasano.com</email>
  </committer>
</commit>
