static VALUE
strscan_inspect(VALUE self)
{
struct strscanner *p;
char buf[BUFSIZE];
long len;
VALUE a, b;
Data_Get_Struct(self, struct strscanner, p);
if (NIL_P(p->str)) {
len = snprintf(buf, BUFSIZE, "#<%s (uninitialized)>",
rb_class2name(CLASS_OF(self)));
return infect(rb_str_new(buf, len), p);
}
if (EOS_P(p)) {
len = snprintf(buf, BUFSIZE, "#<%s fin>",
rb_class2name(CLASS_OF(self)));
return infect(rb_str_new(buf, len), p);
}
if (p->curr == 0) {
b = inspect2(p);
len = snprintf(buf, BUFSIZE, "#<%s %ld/%ld @ %s>",
rb_class2name(CLASS_OF(self)),
p->curr, S_LEN(p),
RSTRING_PTR(b));
return infect(rb_str_new(buf, len), p);
}
a = inspect1(p);
b = inspect2(p);
len = snprintf(buf, BUFSIZE, "#<%s %ld/%ld %s @ %s>",
rb_class2name(CLASS_OF(self)),
p->curr, S_LEN(p),
RSTRING_PTR(a),
RSTRING_PTR(b));
return infect(rb_str_new(buf, len), p);
}