<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -2,6 +2,14 @@
 #include &quot;windows.h&quot;
 #include &quot;ruby.h&quot;
 
+/* Workaround deprecated RString accessors */
+#ifndef RSTRING_PTR
+#define RSTRING_PTR(s) (RSTRING(s)-&gt;ptr)
+#endif
+#ifndef RSTRING_LEN
+#define RSTRING_LEN(s) (RSTRING(s)-&gt;len)
+#endif
+
 #ifdef WIN32
 #define CONSOLE_EXPORT __declspec(dllexport)
 #else
@@ -32,7 +40,6 @@ VALUE rb_mConstants;
 VALUE
 rb_getWin32Error()
 {
-   DWORD e = GetLastError();
    LPVOID lpMsgBuf;
    if (!FormatMessage( 
 		      FORMAT_MESSAGE_ALLOCATE_BUFFER | 
@@ -55,7 +62,7 @@ rb_getWin32Error()
    LocalFree( lpMsgBuf );
 
    // Raise exception
-   rb_raise(rb_eRuntimeError, RSTRING(t)-&gt;ptr);
+   rb_raise(rb_eRuntimeError, RSTRING_PTR(t));
    return Qnil;
 
 }
@@ -205,11 +212,11 @@ static VALUE rb_WriteConsole( VALUE self, VALUE hConsoleOutput,
 			      VALUE lpBuffer )
 {
    HANDLE handle = ULongToPtr( NUM2ULONG( hConsoleOutput ) );
-   DWORD nNumberOfCharsToWrite = RSTRING(lpBuffer)-&gt;len;
+   DWORD nNumberOfCharsToWrite = RSTRING_LEN(lpBuffer);
    
    DWORD lpNumberOfCharsWritten;
 
-   WriteConsole( handle, RSTRING(lpBuffer)-&gt;ptr,
+   WriteConsole( handle, RSTRING_PTR(lpBuffer),
 		 nNumberOfCharsToWrite,
 		 &amp;lpNumberOfCharsWritten, NULL );
    return UINT2NUM( lpNumberOfCharsWritten );
@@ -219,11 +226,11 @@ static VALUE rb_WriteFile( VALUE self, VALUE hConsoleOutput,
                VALUE lpBuffer )
 {
    HANDLE handle = ULongToPtr( NUM2ULONG( hConsoleOutput ) );
-   DWORD nNumberOfBytesToWrite = RSTRING(lpBuffer)-&gt;len;
+   DWORD nNumberOfBytesToWrite = RSTRING_LEN(lpBuffer);
 
    DWORD lpNumberOfBytesWritten;
 
-   WriteFile( handle, RSTRING(lpBuffer)-&gt;ptr,
+   WriteFile( handle, RSTRING_PTR(lpBuffer),
        nNumberOfBytesToWrite,
        &amp;lpNumberOfBytesWritten, NULL );
    return UINT2NUM( lpNumberOfBytesWritten );
@@ -332,9 +339,9 @@ static VALUE rb_ReadConsole( VALUE self, VALUE hConsoleOutput,
    DWORD nofread;
    Check_Type( buffer, T_STRING );
    int to_read = NUM2INT(numread);
-   if ( RSTRING(buffer)-&gt;len &gt; to_read )
+   if ( RSTRING_LEN(buffer) &gt; to_read )
       rb_raise(rb_eArgError, &quot;String is too small to read that many characters.&quot;);
-   if (ReadConsole(handle,(void *)RSTRING(buffer)-&gt;ptr, to_read,
+   if (ReadConsole(handle,(void *)RSTRING_PTR(buffer), to_read,
 		   &amp;nofread,NULL))
       return UINT2NUM(nofread);
    return rb_getWin32Error();
@@ -365,9 +372,9 @@ static VALUE rb_ReadConsoleOutputCharacter( VALUE self, VALUE hConsoleOutput,
    coords.X= NUM2UINT( x );
    coords.Y= NUM2UINT( y );
    int l = NUM2INT(len);
-   if ( RSTRING(charbuf)-&gt;len &lt; l*sizeof(TCHAR) )
+   if ( (unsigned long)RSTRING_LEN(charbuf) &lt; l*sizeof(TCHAR) )
       rb_raise(rb_eArgError, &quot;String is too small to read that many characters.&quot;);
-   if (ReadConsoleOutputCharacter(handle,RSTRING(charbuf)-&gt;ptr,l,
+   if (ReadConsoleOutputCharacter(handle,RSTRING_PTR(charbuf),l,
 				  coords,&amp;nofread))
       return UINT2NUM( nofread );
    return rb_getWin32Error();
@@ -413,10 +420,10 @@ static VALUE rb_ReadConsoleOutput( VALUE self, VALUE hConsoleOutput,
    from.Right  = NUM2INT( r );
    from.Bottom = NUM2INT( b );
    Check_Type( buffer, T_STRING );
-   if ( RSTRING(buffer)-&gt;len &lt; (sizeof(CHAR_INFO)*size.X*size.Y) )
+   if ( (unsigned long)RSTRING_LEN(buffer) &lt; (sizeof(CHAR_INFO)*size.X*size.Y) )
       rb_raise(rb_eArgError, &quot;string buffer is too small for reading that many characters.&quot;);
    HANDLE handle = ULongToPtr( NUM2ULONG( hConsoleOutput ) );
-   if (!ReadConsoleOutput(handle,(CHAR_INFO *)RSTRING(buffer)-&gt;ptr,size,coords,&amp;from))
+   if (!ReadConsoleOutput(handle,(CHAR_INFO *)RSTRING_PTR(buffer),size,coords,&amp;from))
       return rb_getWin32Error();
 
    VALUE ret = rb_ary_new();
@@ -739,7 +746,7 @@ not_there:
 VALUE rb_constant( VALUE self, VALUE name )
 {
    Check_Type( name, T_STRING );
-   return ULONG2NUM( c_constant( RSTRING(name)-&gt;ptr ) );
+   return ULONG2NUM( c_constant( RSTRING_PTR(name) ) );
 }
 
 
@@ -844,7 +851,7 @@ VALUE
 rb_SetConsoleTitle( VALUE self, VALUE title )
 {
    Check_Type( title, T_STRING );
-   if (SetConsoleTitle(RSTRING( title )-&gt;ptr))
+   if (SetConsoleTitle(RSTRING_PTR( title )))
       return NUM2UINT(1);
    return rb_getWin32Error();
 }
@@ -1081,7 +1088,7 @@ rb_WriteConsoleOutput(VALUE self, VALUE h, VALUE buffer,
     to.Top    = NUM2INT( t );
     to.Right  = NUM2INT( r );
     to.Bottom = NUM2INT( b );
-    if (WriteConsoleOutput(handle,(CHAR_INFO *)RSTRING(buffer)-&gt;ptr,
+    if (WriteConsoleOutput(handle,(CHAR_INFO *)RSTRING_PTR(buffer),
 			   size,coords,&amp;to)) {
        VALUE ret = rb_ary_new();
        rb_ary_push( ret, INT2FIX( to.Left   ) );
@@ -1104,9 +1111,9 @@ rb_WriteConsoleOutputAttribute(VALUE self, VALUE h, VALUE s,
     
     unsigned short buffer[80*999*sizeof(unsigned short)];
     DWORD written;
-    DWORD towrite = RSTRING(s)-&gt;len;
+    DWORD towrite = RSTRING_LEN(s);
     for(unsigned i=0; i&lt;towrite; i++) {
-        buffer[i] = (unsigned short)(RSTRING(s)-&gt;ptr[i]);
+        buffer[i] = (unsigned short)(RSTRING_PTR(s)[i]);
     }
     COORD coords;
     coords.X=NUM2INT( x );
@@ -1131,8 +1138,8 @@ rb_WriteConsoleOutputCharacter(VALUE self, VALUE h, VALUE s,
     COORD coords;
     coords.X=NUM2INT( x );
     coords.Y=NUM2INT( y );
-    if (WriteConsoleOutputCharacter(handle,(LPCTSTR)RSTRING(s)-&gt;ptr,
-				    RSTRING(s)-&gt;len,coords,&amp;written)) {
+    if (WriteConsoleOutputCharacter(handle,(LPCTSTR)RSTRING_PTR(s),
+				    RSTRING_LEN(s),coords,&amp;written)) {
        return UINT2NUM( written );
     }
     return rb_getWin32Error();</diff>
      <filename>ext/Console/Console.cpp</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>ceb2eecf18b43d2cb98efe1c003cc78c72ef5abb</id>
    </parent>
  </parents>
  <author>
    <name>Luis Lavena</name>
    <email>luislavena@gmail.com</email>
  </author>
  <url>http://github.com/luislavena/win32console/commit/aff082dbb8302846525d0ccaa08e4931e4067889</url>
  <id>aff082dbb8302846525d0ccaa08e4931e4067889</id>
  <committed-date>2009-04-10T08:48:30-07:00</committed-date>
  <authored-date>2009-04-10T08:48:30-07:00</authored-date>
  <message>Corrected deprected RSTRING macros and warnings.

This is to improve support on Ruby 1.9.</message>
  <tree>981061b0f61e43dd2e3f67617cc08528cc7e1936</tree>
  <committer>
    <name>Luis Lavena</name>
    <email>luislavena@gmail.com</email>
  </committer>
</commit>
