#include "ruby/ruby.h"
#include "ruby/re.h"
#include "ruby/encoding.h"
Include dependency graph for strscan.c:
Go to the source code of this file.
Data Structures | |
struct | strscanner |
Defines | |
#define | STRSCAN_VERSION "0.7.0" |
#define | FLAG_MATCHED (1 << 0) |
#define | MATCHED_P(s) ((s)->flags & FLAG_MATCHED) |
#define | MATCHED(s) (s)->flags |= FLAG_MATCHED |
#define | CLEAR_MATCH_STATUS(s) (s)->flags &= ~FLAG_MATCHED |
#define | S_PBEG(s) (RSTRING_PTR((s)->str)) |
#define | S_LEN(s) (RSTRING_LEN((s)->str)) |
#define | S_PEND(s) (S_PBEG(s) + S_LEN(s)) |
#define | CURPTR(s) (S_PBEG(s) + (s)->curr) |
#define | S_RESTLEN(s) (S_LEN(s) - (s)->curr) |
#define | EOS_P(s) ((s)->curr >= RSTRING_LEN(p->str)) |
#define | GET_SCANNER(obj, var) |
#define | INSPECT_LENGTH 5 |
#define | BUFSIZE 256 |
Functions | |
static VALUE infect | _ ((VALUE str, struct strscanner *p)) |
static VALUE extract_range | _ ((struct strscanner *p, long beg_i, long end_i)) |
static VALUE extract_beg_len | _ ((struct strscanner *p, long beg_i, long len)) |
void check_strscan | _ ((VALUE obj)) |
static void strscan_mark | _ ((struct strscanner *p)) |
static VALUE strscan_s_allocate | _ ((VALUE klass)) |
static VALUE strscan_initialize | _ ((int argc, VALUE *argv, VALUE self)) |
static VALUE strscan_init_copy | _ ((VALUE vself, VALUE vorig)) |
static VALUE strscan_s_mustc | _ ((VALUE self)) |
static VALUE strscan_set_string | _ ((VALUE self, VALUE str)) |
static VALUE strscan_set_pos | _ ((VALUE self, VALUE pos)) |
static VALUE strscan_do_scan | _ ((VALUE self, VALUE regex, int succptr, int getstr, int headonly)) |
static VALUE strscan_scan | _ ((VALUE self, VALUE re)) |
static VALUE strscan_scan_full | _ ((VALUE self, VALUE re, VALUE succp, VALUE getp)) |
static VALUE strscan_peek | _ ((VALUE self, VALUE len)) |
static VALUE strscan_aref | _ ((VALUE self, VALUE idx)) |
static VALUE | infect (VALUE str, struct strscanner *p) |
static VALUE | str_new (struct strscanner *p, const char *ptr, long len) |
static VALUE | extract_range (struct strscanner *p, long beg_i, long end_i) |
static VALUE | extract_beg_len (struct strscanner *p, long beg_i, long len) |
static void | strscan_mark (struct strscanner *p) |
static void | strscan_free (struct strscanner *p) |
static VALUE | strscan_s_allocate (VALUE klass) |
static VALUE | strscan_initialize (int argc, VALUE *argv, VALUE self) |
void | check_strscan (VALUE obj) |
static VALUE | strscan_init_copy (VALUE vself, VALUE vorig) |
static VALUE | strscan_s_mustc (VALUE self) |
static VALUE | strscan_reset (VALUE self) |
static VALUE | strscan_terminate (VALUE self) |
static VALUE | strscan_clear (VALUE self) |
static VALUE | strscan_get_string (VALUE self) |
static VALUE | strscan_set_string (VALUE self, VALUE str) |
static VALUE | strscan_concat (VALUE self, VALUE str) |
static VALUE | strscan_get_pos (VALUE self) |
static VALUE | strscan_set_pos (VALUE self, VALUE v) |
static VALUE | strscan_do_scan (VALUE self, VALUE regex, int succptr, int getstr, int headonly) |
static VALUE | strscan_scan (VALUE self, VALUE re) |
static VALUE | strscan_match_p (VALUE self, VALUE re) |
static VALUE | strscan_skip (VALUE self, VALUE re) |
static VALUE | strscan_check (VALUE self, VALUE re) |
static VALUE | strscan_scan_full (VALUE self, VALUE re, VALUE s, VALUE f) |
static VALUE | strscan_scan_until (VALUE self, VALUE re) |
static VALUE | strscan_exist_p (VALUE self, VALUE re) |
static VALUE | strscan_skip_until (VALUE self, VALUE re) |
static VALUE | strscan_check_until (VALUE self, VALUE re) |
static VALUE | strscan_search_full (VALUE self, VALUE re, VALUE s, VALUE f) |
static void | adjust_registers_to_matched (struct strscanner *p) |
static VALUE | strscan_getch (VALUE self) |
static VALUE | strscan_get_byte (VALUE self) |
static VALUE | strscan_getbyte (VALUE self) |
static VALUE | strscan_peek (VALUE self, VALUE vlen) |
static VALUE | strscan_peep (VALUE self, VALUE vlen) |
static VALUE | strscan_unscan (VALUE self) |
static VALUE | strscan_bol_p (VALUE self) |
static VALUE | strscan_eos_p (VALUE self) |
static VALUE | strscan_empty_p (VALUE self) |
static VALUE | strscan_rest_p (VALUE self) |
static VALUE | strscan_matched_p (VALUE self) |
static VALUE | strscan_matched (VALUE self) |
static VALUE | strscan_matched_size (VALUE self) |
static VALUE | strscan_aref (VALUE self, VALUE idx) |
static VALUE | strscan_pre_match (VALUE self) |
static VALUE | strscan_post_match (VALUE self) |
static VALUE | strscan_rest (VALUE self) |
static VALUE | strscan_rest_size (VALUE self) |
static VALUE | strscan_restsize (VALUE self) |
static VALUE | strscan_inspect (VALUE self) |
static VALUE | inspect1 (struct strscanner *p) |
static VALUE | inspect2 (struct strscanner *p) |
void | Init_strscan () |
Variables | |
static VALUE | StringScanner |
static VALUE | ScanError |
#define CLEAR_MATCH_STATUS | ( | s | ) | (s)->flags &= ~FLAG_MATCHED |
Definition at line 43 of file strscan.c.
Referenced by strscan_do_scan(), strscan_get_byte(), strscan_getch(), strscan_reset(), strscan_s_allocate(), strscan_set_string(), strscan_terminate(), and strscan_unscan().
#define CURPTR | ( | s | ) | (S_PBEG(s) + (s)->curr) |
Definition at line 48 of file strscan.c.
Referenced by inspect1(), inspect2(), strscan_bol_p(), strscan_do_scan(), and strscan_getch().
#define EOS_P | ( | s | ) | ((s)->curr >= RSTRING_LEN(p->str)) |
Definition at line 51 of file strscan.c.
Referenced by inspect2(), strscan_eos_p(), strscan_get_byte(), strscan_getch(), strscan_inspect(), strscan_peek(), strscan_rest(), strscan_rest_p(), and strscan_rest_size().
#define GET_SCANNER | ( | obj, | |||
var | ) |
Value:
do {\ Data_Get_Struct(obj, struct strscanner, var);\ if (NIL_P(var->str)) rb_raise(rb_eArgError, "uninitialized StringScanner object");\ } while (0)
Definition at line 53 of file strscan.c.
Referenced by strscan_aref(), strscan_bol_p(), strscan_concat(), strscan_do_scan(), strscan_eos_p(), strscan_get_byte(), strscan_get_pos(), strscan_get_string(), strscan_getch(), strscan_matched(), strscan_matched_p(), strscan_matched_size(), strscan_peek(), strscan_post_match(), strscan_pre_match(), strscan_reset(), strscan_rest(), strscan_rest_p(), strscan_rest_size(), strscan_set_pos(), strscan_terminate(), and strscan_unscan().
#define INSPECT_LENGTH 5 |
#define MATCHED | ( | s | ) | (s)->flags |= FLAG_MATCHED |
Definition at line 42 of file strscan.c.
Referenced by strscan_do_scan(), strscan_get_byte(), and strscan_getch().
#define MATCHED_P | ( | s | ) | ((s)->flags & FLAG_MATCHED) |
Definition at line 41 of file strscan.c.
Referenced by strscan_aref(), strscan_matched(), strscan_matched_p(), strscan_matched_size(), strscan_post_match(), strscan_pre_match(), and strscan_unscan().
#define S_LEN | ( | s | ) | (RSTRING_LEN((s)->str)) |
Definition at line 46 of file strscan.c.
Referenced by extract_beg_len(), extract_range(), inspect2(), strscan_getch(), strscan_inspect(), strscan_peek(), strscan_post_match(), strscan_rest(), strscan_rest_size(), strscan_set_pos(), and strscan_terminate().
#define S_PBEG | ( | s | ) | (RSTRING_PTR((s)->str)) |
#define S_PEND | ( | s | ) | (S_PBEG(s) + S_LEN(s)) |
#define S_RESTLEN | ( | s | ) | (S_LEN(s) - (s)->curr) |
#define STRSCAN_VERSION "0.7.0" |
static VALUE strscan_do_scan _ | ( | (VALUE self, VALUE regex, int succptr, int getstr, int headonly) | ) | [static] |
static VALUE inspect2 _ | ( | (struct strscanner *p) | ) | [static] |
void check_strscan _ | ( | (VALUE obj) | ) |
static VALUE extract_beg_len _ | ( | (struct strscanner *p, long beg_i, long len) | ) | [static] |
static VALUE extract_range _ | ( | (struct strscanner *p, long beg_i, long end_i) | ) | [static] |
static VALUE infect _ | ( | (VALUE str, struct strscanner *p) | ) | [static] |
static void adjust_registers_to_matched | ( | struct strscanner * | p | ) | [static] |
Definition at line 655 of file strscan.c.
References strscanner::curr, onig_region_clear(), onig_region_set(), strscanner::prev, and strscanner::regs.
Referenced by strscan_get_byte(), and strscan_getch().
void check_strscan | ( | VALUE | obj | ) |
Definition at line 206 of file strscan.c.
References rb_eTypeError, rb_obj_classname(), rb_raise(), RDATA, strscan_mark(), T_DATA, and TYPE.
Referenced by strscan_init_copy().
static VALUE extract_beg_len | ( | struct strscanner * | p, | |
long | beg_i, | |||
long | len | |||
) | [static] |
Definition at line 147 of file strscan.c.
References infect(), Qnil, S_LEN, S_PBEG, and str_new().
Referenced by strscan_do_scan(), and strscan_peek().
static VALUE extract_range | ( | struct strscanner * | p, | |
long | beg_i, | |||
long | end_i | |||
) | [static] |
Definition at line 138 of file strscan.c.
References infect(), Qnil, S_LEN, S_PBEG, and str_new().
Referenced by strscan_aref(), strscan_get_byte(), strscan_getch(), strscan_matched(), strscan_post_match(), strscan_pre_match(), and strscan_rest().
static VALUE infect | ( | VALUE | str, | |
struct strscanner * | p | |||
) | [static] |
Definition at line 123 of file strscan.c.
References OBJ_INFECT, and strscanner::str.
Referenced by extract_beg_len(), extract_range(), strscan_inspect(), strscan_peek(), and strscan_rest().
void Init_strscan | ( | ) |
Definition at line 1246 of file strscan.c.
References rb_alias(), rb_cObject, rb_const_defined(), rb_const_set(), rb_define_alloc_func(), rb_define_class(), rb_define_class_under(), rb_define_method(), rb_define_private_method(), rb_define_singleton_method(), rb_eStandardError, rb_intern, rb_obj_freeze(), rb_str_new2, ScanError, StringScanner, strscan_aref(), strscan_bol_p(), strscan_check(), strscan_check_until(), strscan_clear(), strscan_concat(), strscan_empty_p(), strscan_eos_p(), strscan_exist_p(), strscan_get_byte(), strscan_get_pos(), strscan_get_string(), strscan_getbyte(), strscan_getch(), strscan_init_copy(), strscan_initialize(), strscan_inspect(), strscan_match_p(), strscan_matched(), strscan_matched_p(), strscan_matched_size(), strscan_peek(), strscan_peep(), strscan_post_match(), strscan_pre_match(), strscan_reset(), strscan_rest(), strscan_rest_p(), strscan_rest_size(), strscan_restsize(), strscan_s_allocate(), strscan_s_mustc(), strscan_scan(), strscan_scan_full(), strscan_scan_until(), strscan_search_full(), strscan_set_pos(), strscan_set_string(), strscan_skip(), strscan_skip_until(), strscan_terminate(), strscan_unscan(), and STRSCAN_VERSION.
static VALUE inspect1 | ( | struct strscanner * | p | ) | [static] |
Definition at line 1100 of file strscan.c.
References bp, buf, BUFSIZE, CURPTR, strscanner::curr, INSPECT_LENGTH, len, rb_str_dump(), rb_str_new(), and rb_str_new2.
Referenced by strscan_inspect().
static VALUE inspect2 | ( | struct strscanner * | p | ) | [static] |
Definition at line 1119 of file strscan.c.
References bp, buf, BUFSIZE, CURPTR, strscanner::curr, EOS_P, INSPECT_LENGTH, len, rb_str_dump(), rb_str_new(), rb_str_new2, and S_LEN.
Referenced by strscan_inspect().
static VALUE str_new | ( | struct strscanner * | p, | |
const char * | ptr, | |||
long | len | |||
) | [static] |
Definition at line 130 of file strscan.c.
References rb_enc_copy(), rb_str_new(), and strscanner::str.
Referenced by extract_beg_len(), extract_range(), rb_str_new(), rb_str_new_frozen(), RUBY_ALIAS_FUNCTION(), strscan_peek(), and strscan_rest().
Definition at line 947 of file strscan.c.
References re_registers::beg, re_registers::end, extract_range(), GET_SCANNER, MATCHED_P, NUM2LONG(), re_registers::num_regs, strscanner::prev, Qnil, and strscanner::regs.
Referenced by Init_strscan().
Definition at line 819 of file strscan.c.
References CURPTR, strscanner::curr, GET_SCANNER, Qfalse, Qnil, Qtrue, and S_PEND.
Referenced by Init_strscan().
Definition at line 540 of file strscan.c.
References strscan_do_scan().
Referenced by Init_strscan().
Definition at line 634 of file strscan.c.
References strscan_do_scan().
Referenced by Init_strscan().
Definition at line 293 of file strscan.c.
References rb_warning(), and strscan_terminate().
Referenced by Init_strscan().
Definition at line 345 of file strscan.c.
References GET_SCANNER, rb_str_append(), strscanner::str, and StringValue.
Referenced by Init_strscan().
static VALUE strscan_do_scan | ( | VALUE | self, | |
VALUE | regex, | |||
int | succptr, | |||
int | getstr, | |||
int | headonly | |||
) | [static] |
Definition at line 403 of file strscan.c.
References Check_Type, CLEAR_MATCH_STATUS, CURPTR, strscanner::curr, re_registers::end, extract_beg_len(), GET_SCANNER, INT2FIX, MATCHED, onig_free(), onig_match(), ONIG_OPTION_NONE, onig_search(), strscanner::prev, Qnil, rb_raise(), rb_reg_prepare_re(), strscanner::regs, RREGEXP, S_RESTLEN, ScanError, strscanner::str, T_REGEXP, and UChar.
Referenced by strscan_check(), strscan_check_until(), strscan_exist_p(), strscan_match_p(), strscan_scan(), strscan_scan_full(), strscan_scan_until(), strscan_search_full(), strscan_skip(), and strscan_skip_until().
Definition at line 853 of file strscan.c.
References rb_warning(), and strscan_eos_p().
Referenced by Init_strscan().
Definition at line 840 of file strscan.c.
References EOS_P, GET_SCANNER, Qfalse, and Qtrue.
Referenced by Init_strscan(), and strscan_empty_p().
Definition at line 593 of file strscan.c.
References strscan_do_scan().
Referenced by Init_strscan().
static void strscan_free | ( | struct strscanner * | p | ) | [static] |
Definition at line 166 of file strscan.c.
References onig_region_free(), strscanner::regs, and ruby_xfree().
Referenced by strscan_s_allocate().
Definition at line 715 of file strscan.c.
References adjust_registers_to_matched(), re_registers::beg, CLEAR_MATCH_STATUS, strscanner::curr, re_registers::end, EOS_P, extract_range(), GET_SCANNER, MATCHED, strscanner::prev, Qnil, and strscanner::regs.
Referenced by Init_strscan(), and strscan_getbyte().
Definition at line 370 of file strscan.c.
References strscanner::curr, GET_SCANNER, and INT2FIX.
Referenced by Init_strscan().
Definition at line 303 of file strscan.c.
References GET_SCANNER, and strscanner::str.
Referenced by Init_strscan().
Definition at line 737 of file strscan.c.
References rb_warning(), and strscan_get_byte().
Referenced by Init_strscan().
Definition at line 676 of file strscan.c.
References adjust_registers_to_matched(), re_registers::beg, CLEAR_MATCH_STATUS, CURPTR, strscanner::curr, re_registers::end, EOS_P, extract_range(), GET_SCANNER, len, MATCHED, strscanner::prev, Qnil, rb_enc_get(), rb_enc_mbclen(), strscanner::regs, S_LEN, S_PEND, and strscanner::str.
Referenced by Init_strscan().
Definition at line 223 of file strscan.c.
References check_strscan(), strscanner::curr, Data_Get_Struct, strscanner::flags, onig_region_copy(), strscanner::prev, strscanner::regs, and strscanner::str.
Referenced by Init_strscan().
Definition at line 192 of file strscan.c.
References Data_Get_Struct, rb_scan_args(), strscanner::str, and StringValue.
Referenced by Init_strscan().
Definition at line 1063 of file strscan.c.
References a(), b(), buf, BUFSIZE, CLASS_OF, strscanner::curr, Data_Get_Struct, EOS_P, infect(), inspect1(), inspect2(), len, NIL_P, rb_class2name(), rb_str_new(), RSTRING_PTR, S_LEN, snprintf, and strscanner::str.
Referenced by Init_strscan().
static void strscan_mark | ( | struct strscanner * | p | ) | [static] |
Definition at line 160 of file strscan.c.
References rb_gc_mark(), and strscanner::str.
Referenced by check_strscan(), and strscan_s_allocate().
Definition at line 496 of file strscan.c.
References strscan_do_scan().
Referenced by Init_strscan().
Definition at line 902 of file strscan.c.
References re_registers::beg, re_registers::end, extract_range(), GET_SCANNER, MATCHED_P, strscanner::prev, Qnil, and strscanner::regs.
Referenced by Init_strscan().
Definition at line 886 of file strscan.c.
References GET_SCANNER, MATCHED_P, Qfalse, and Qtrue.
Referenced by Init_strscan().
Definition at line 923 of file strscan.c.
References re_registers::beg, re_registers::end, GET_SCANNER, INT2NUM(), MATCHED_P, Qnil, and strscanner::regs.
Referenced by Init_strscan().
Definition at line 755 of file strscan.c.
References EOS_P, extract_beg_len(), GET_SCANNER, infect(), len, NUM2LONG(), S_LEN, and str_new().
Referenced by Init_strscan(), and strscan_peep().
Definition at line 776 of file strscan.c.
References rb_warning(), and strscan_peek().
Referenced by Init_strscan().
Definition at line 995 of file strscan.c.
References re_registers::end, extract_range(), GET_SCANNER, MATCHED_P, strscanner::prev, Qnil, strscanner::regs, and S_LEN.
Referenced by Init_strscan().
Definition at line 976 of file strscan.c.
References re_registers::beg, extract_range(), GET_SCANNER, MATCHED_P, strscanner::prev, Qnil, and strscanner::regs.
Referenced by Init_strscan().
Definition at line 260 of file strscan.c.
References CLEAR_MATCH_STATUS, strscanner::curr, and GET_SCANNER.
Referenced by Init_strscan().
Definition at line 1009 of file strscan.c.
References strscanner::curr, EOS_P, extract_range(), GET_SCANNER, infect(), S_LEN, and str_new().
Referenced by Init_strscan().
Definition at line 868 of file strscan.c.
References EOS_P, GET_SCANNER, Qfalse, and Qtrue.
Referenced by Init_strscan().
Definition at line 1024 of file strscan.c.
References strscanner::curr, EOS_P, GET_SCANNER, INT2FIX, and S_LEN.
Referenced by Init_strscan(), and strscan_restsize().
Definition at line 1042 of file strscan.c.
References rb_warning(), and strscan_rest_size().
Referenced by Init_strscan().
Definition at line 173 of file strscan.c.
References ALLOC, CLEAR_MATCH_STATUS, Data_Wrap_Struct, MEMZERO, onig_region_init(), Qnil, strscanner::regs, strscanner::str, strscan_free(), and strscan_mark().
Referenced by Init_strscan().
Definition at line 479 of file strscan.c.
References strscan_do_scan().
Referenced by Init_strscan().
Definition at line 556 of file strscan.c.
References RTEST, and strscan_do_scan().
Referenced by Init_strscan().
Definition at line 574 of file strscan.c.
References strscan_do_scan().
Referenced by Init_strscan().
Definition at line 649 of file strscan.c.
References RTEST, and strscan_do_scan().
Referenced by Init_strscan().
Definition at line 388 of file strscan.c.
References strscanner::curr, GET_SCANNER, INT2NUM(), NUM2INT, rb_eRangeError, rb_raise(), and S_LEN.
Referenced by Init_strscan().
Definition at line 318 of file strscan.c.
References CLEAR_MATCH_STATUS, strscanner::curr, Data_Get_Struct, strscanner::str, and StringValue.
Referenced by Init_strscan().
Definition at line 519 of file strscan.c.
References strscan_do_scan().
Referenced by Init_strscan().
Definition at line 615 of file strscan.c.
References strscan_do_scan().
Referenced by Init_strscan().
Definition at line 278 of file strscan.c.
References CLEAR_MATCH_STATUS, strscanner::curr, GET_SCANNER, and S_LEN.
Referenced by Init_strscan(), and strscan_clear().
Definition at line 794 of file strscan.c.
References CLEAR_MATCH_STATUS, strscanner::curr, GET_SCANNER, MATCHED_P, strscanner::prev, rb_raise(), and ScanError.
Referenced by Init_strscan().
Definition at line 22 of file strscan.c.
Referenced by Init_strscan(), strscan_do_scan(), and strscan_unscan().
VALUE StringScanner [static] |