Changeset 158

Show
Ignore:
Timestamp:
12/26/2007 11:42:19 (11 months ago)
Author:
why
Message:

* ext/hpricot_scan/hpricot_scan.rl: using RSTRING_PTR and RSTRING_LEN to support Ruby 1.9, thanks manveru!

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/ext/hpricot_scan/hpricot_scan.rl

    r117 r158  
    88 */ 
    99#include <ruby.h> 
     10 
     11#ifndef RARRAY_LEN 
     12#define RARRAY_LEN(arr)  RARRAY(arr)->len 
     13#define RSTRING_LEN(str) RSTRING(str)->len 
     14#define RSTRING_PTR(str) RSTRING(str)->ptr 
     15#endif 
    1016 
    1117#define NO_WAY_SERIOUSLY "*** This should not happen, please send a bug report with the HTML you're parsing to why@whytheluckystiff.net.  So sorry!" 
     
    170176       * prefix that must be preserved.  Likely caused by super-long attributes. 
    171177       * See ticket #13. */ 
    172       rb_raise(rb_eHpricotParseError, "ran out of buffer space on element <%s>, starting on line %d.", RSTRING(tag)->ptr, curline); 
     178      rb_raise(rb_eHpricotParseError, "ran out of buffer space on element <%s>, starting on line %d.", RSTRING_PTR(tag), curline); 
    173179    } 
    174180 
     
    183189 
    184190    StringValue(str); 
    185     memcpy( p, RSTRING(str)->ptr, RSTRING(str)->len ); 
    186     len = RSTRING(str)->len; 
     191    memcpy( p, RSTRING_PTR(str), RSTRING_LEN(str) ); 
     192    len = RSTRING_LEN(str); 
    187193    nread += len; 
    188194 
     
    200206      if ( !NIL_P(tag) ) 
    201207      { 
    202         rb_raise(rb_eHpricotParseError, "parse error on element <%s>, starting on line %d.\n" NO_WAY_SERIOUSLY, RSTRING(tag)->ptr, curline); 
     208        rb_raise(rb_eHpricotParseError, "parse error on element <%s>, starting on line %d.\n" NO_WAY_SERIOUSLY, RSTRING_PTR(tag), curline); 
    203209      } 
    204210      else