/*
* Set the scan pointer to the previous position. Only one previous position is
* remembered, and it changes with each scanning operation.
*
* s = StringScanner.new('test string')
* s.scan(/\w+/) # => "test"
* s.unscan
* s.scan(/../) # => "te"
* s.scan(/\d/) # => nil
* s.unscan # ScanError: can't unscan: prev match had failed
*/
static VALUE
strscan_unscan(self)
VALUE self;
{
struct strscanner *p;
GET_SCANNER(self, p);
if (! MATCHED_P(p))
rb_raise(ScanError, "can't unscan: prev match had failed");
p->curr = p->prev;
CLEAR_MATCH_STATUS(p);
return self;
}