From 1b7465e893131c8a8b27078704223ecfb2311119 Mon Sep 17 00:00:00 2001 From: matz Date: Tue, 20 Jun 2006 18:02:17 +0000 Subject: * eval.c, file.c, etc.: code-cleanup patch from Stefan Huehner . [ruby-core:08029] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10351 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/strscan/strscan.c | 153 ++++++++++++++++---------------------------------- 1 file changed, 49 insertions(+), 104 deletions(-) (limited to 'ext/strscan/strscan.c') diff --git a/ext/strscan/strscan.c b/ext/strscan/strscan.c index 913c6b53c1..1dd61e5963 100644 --- a/ext/strscan/strscan.c +++ b/ext/strscan/strscan.c @@ -119,18 +119,14 @@ static VALUE inspect2 _((struct strscanner *p)); ======================================================================= */ static VALUE -infect(str, p) - VALUE str; - struct strscanner *p; +infect(VALUE str, struct strscanner *p) { OBJ_INFECT(str, p->str); return str; } static VALUE -extract_range(p, beg_i, end_i) - struct strscanner *p; - long beg_i, end_i; +extract_range(struct strscanner *p, long beg_i, long end_i) { if (beg_i > S_LEN(p)) return Qnil; if (end_i > S_LEN(p)) @@ -139,9 +135,7 @@ extract_range(p, beg_i, end_i) } static VALUE -extract_beg_len(p, beg_i, len) - struct strscanner *p; - long beg_i, len; +extract_beg_len(struct strscanner *p, long beg_i, long len) { if (beg_i > S_LEN(p)) return Qnil; if (beg_i + len > S_LEN(p)) @@ -154,23 +148,20 @@ extract_beg_len(p, beg_i, len) ======================================================================= */ static void -strscan_mark(p) - struct strscanner *p; +strscan_mark(struct strscanner *p) { rb_gc_mark(p->str); } static void -strscan_free(p) - struct strscanner *p; +strscan_free(struct strscanner *p) { onig_region_free(&(p->regs), 0); free(p); } static VALUE -strscan_s_allocate(klass) - VALUE klass; +strscan_s_allocate(VALUE klass) { struct strscanner *p; @@ -189,10 +180,7 @@ strscan_s_allocate(klass) * +dup+ argument is obsolete and not used now. */ static VALUE -strscan_initialize(argc, argv, self) - int argc; - VALUE *argv; - VALUE self; +strscan_initialize(int argc, VALUE *argv, VALUE self) { struct strscanner *p; VALUE str, need_dup; @@ -206,8 +194,7 @@ strscan_initialize(argc, argv, self) } void -check_strscan(obj) - VALUE obj; +check_strscan(VALUE obj) { if (TYPE(obj) != T_DATA || RDATA(obj)->dmark != (RUBY_DATA_FUNC)strscan_mark) { rb_raise(rb_eTypeError, @@ -224,8 +211,7 @@ check_strscan(obj) * Duplicates a StringScanner object. */ static VALUE -strscan_init_copy(vself, vorig) - VALUE vself, vorig; +strscan_init_copy(VALUE vself, VALUE vorig) { struct strscanner *self, *orig; @@ -253,8 +239,7 @@ strscan_init_copy(vself, vorig) * This method is defined for backward compatibility. */ static VALUE -strscan_s_mustc(self) - VALUE self; +strscan_s_mustc(VALUE self) { return self; } @@ -281,8 +266,7 @@ strscan_reset(VALUE self) * Set the scan pointer to the end of the string and clear matching data. */ static VALUE -strscan_terminate(self) - VALUE self; +strscan_terminate(VALUE self) { struct strscanner *p; @@ -297,8 +281,7 @@ strscan_terminate(self) * This method is obsolete; use #terminate instead. */ static VALUE -strscan_clear(self) - VALUE self; +strscan_clear(VALUE self) { rb_warning("StringScanner#clear is obsolete; use #terminate instead"); return strscan_terminate(self); @@ -308,8 +291,7 @@ strscan_clear(self) * Returns the string being scanned. */ static VALUE -strscan_get_string(self) - VALUE self; +strscan_get_string(VALUE self) { struct strscanner *p; @@ -324,8 +306,7 @@ strscan_get_string(self) * Returns +str+. */ static VALUE -strscan_set_string(self, str) - VALUE self, str; +strscan_set_string(VALUE self, VALUE str) { struct strscanner *p; @@ -353,8 +334,7 @@ strscan_set_string(self, str) * s.scan(/Dec/) # -> "Dec" */ static VALUE -strscan_concat(self, str) - VALUE self, str; +strscan_concat(VALUE self, VALUE str) { struct strscanner *p; @@ -379,8 +359,7 @@ strscan_concat(self, str) * s.pos # -> 11 */ static VALUE -strscan_get_pos(self) - VALUE self; +strscan_get_pos(VALUE self) { struct strscanner *p; @@ -398,8 +377,7 @@ strscan_get_pos(self) * s.rest # -> "ring" */ static VALUE -strscan_set_pos(self, v) - VALUE self, v; +strscan_set_pos(VALUE self, VALUE v) { struct strscanner *p; long i; @@ -417,9 +395,7 @@ strscan_set_pos(self, v) #define strscan_prepare_re(re) /* none */ static VALUE -strscan_do_scan(self, regex, succptr, getstr, headonly) - VALUE self, regex; - int succptr, getstr, headonly; +strscan_do_scan(VALUE self, VALUE regex, int succptr, int getstr, int headonly) { struct strscanner *p; int ret; @@ -479,8 +455,7 @@ strscan_do_scan(self, regex, succptr, getstr, headonly) * */ static VALUE -strscan_scan(self, re) - VALUE self, re; +strscan_scan(VALUE self, VALUE re) { return strscan_do_scan(self, re, 1, 1, 1); } @@ -497,8 +472,7 @@ strscan_scan(self, re) * p s.match?(/\s+/) # -> nil */ static VALUE -strscan_match_p(self, re) - VALUE self, re; +strscan_match_p(VALUE self, VALUE re) { return strscan_do_scan(self, re, 0, 0, 1); } @@ -521,8 +495,7 @@ strscan_match_p(self, re) * */ static VALUE -strscan_skip(self, re) - VALUE self, re; +strscan_skip(VALUE self, VALUE re) { return strscan_do_scan(self, re, 1, 0, 1); } @@ -543,8 +516,7 @@ strscan_skip(self, re) * Mnemonic: it "checks" to see whether a #scan will return a value. */ static VALUE -strscan_check(self, re) - VALUE self, re; +strscan_check(VALUE self, VALUE re) { return strscan_do_scan(self, re, 0, 1, 1); } @@ -560,8 +532,7 @@ strscan_check(self, re) * "full" means "#scan with full parameters". */ static VALUE -strscan_scan_full(self, re, s, f) - VALUE self, re, s, f; +strscan_scan_full(VALUE self, VALUE re, VALUE s, VALUE f) { return strscan_do_scan(self, re, RTEST(s), RTEST(f), 1); } @@ -579,8 +550,7 @@ strscan_scan_full(self, re, s, f) * s.scan_until(/XYZ/) # -> nil */ static VALUE -strscan_scan_until(self, re) - VALUE self, re; +strscan_scan_until(VALUE self, VALUE re) { return strscan_do_scan(self, re, 1, 1, 0); } @@ -621,8 +591,7 @@ strscan_exist_p(VALUE self, VALUE re) * s # */ static VALUE -strscan_skip_until(self, re) - VALUE self, re; +strscan_skip_until(VALUE self, VALUE re) { return strscan_do_scan(self, re, 1, 0, 0); } @@ -641,8 +610,7 @@ strscan_skip_until(self, re) * Mnemonic: it "checks" to see whether a #scan_until will return a value. */ static VALUE -strscan_check_until(self, re) - VALUE self, re; +strscan_check_until(VALUE self, VALUE re) { return strscan_do_scan(self, re, 0, 1, 0); } @@ -657,15 +625,13 @@ strscan_check_until(self, re) * This method does affect the match register. */ static VALUE -strscan_search_full(self, re, s, f) - VALUE self, re, s, f; +strscan_search_full(VALUE self, VALUE re, VALUE s, VALUE f) { return strscan_do_scan(self, re, RTEST(s), RTEST(f), 0); } static void -adjust_registers_to_matched(p) - struct strscanner *p; +adjust_registers_to_matched(struct strscanner *p) { onig_region_clear(&(p->regs)); onig_region_set(&(p->regs), 0, 0, p->curr - p->prev); @@ -686,8 +652,7 @@ adjust_registers_to_matched(p) * s.getch # => nil */ static VALUE -strscan_getch(self) - VALUE self; +strscan_getch(VALUE self) { struct strscanner *p; long len; @@ -726,8 +691,7 @@ strscan_getch(self) * s.get_byte # => nil */ static VALUE -strscan_get_byte(self) - VALUE self; +strscan_get_byte(VALUE self) { struct strscanner *p; @@ -749,8 +713,7 @@ strscan_get_byte(self) * This method is obsolete; use #get_byte instead. */ static VALUE -strscan_getbyte(self) - VALUE self; +strscan_getbyte(VALUE self) { rb_warning("StringScanner#getbyte is obsolete; use #get_byte instead"); return strscan_get_byte(self); @@ -768,8 +731,7 @@ strscan_getbyte(self) * */ static VALUE -strscan_peek(self, vlen) - VALUE self, vlen; +strscan_peek(VALUE self, VALUE vlen) { struct strscanner *p; long len; @@ -790,8 +752,7 @@ strscan_peek(self, vlen) * This method is obsolete; use #peek instead. */ static VALUE -strscan_peep(self, vlen) - VALUE self, vlen; +strscan_peep(VALUE self, VALUE vlen) { rb_warning("StringScanner#peep is obsolete; use #peek instead"); return strscan_peek(self, vlen); @@ -809,8 +770,7 @@ strscan_peep(self, vlen) * s.unscan # ScanError: unscan failed: previous match record not exist */ static VALUE -strscan_unscan(self) - VALUE self; +strscan_unscan(VALUE self) { struct strscanner *p; @@ -835,8 +795,7 @@ strscan_unscan(self) * s.bol? # => true */ static VALUE -strscan_bol_p(self) - VALUE self; +strscan_bol_p(VALUE self) { struct strscanner *p; @@ -857,8 +816,7 @@ strscan_bol_p(self) * p s.eos? # => true */ static VALUE -strscan_eos_p(self) - VALUE self; +strscan_eos_p(VALUE self) { struct strscanner *p; @@ -871,8 +829,7 @@ strscan_eos_p(self) * This method is obsolete, use #eos? instead. */ static VALUE -strscan_empty_p(self) - VALUE self; +strscan_empty_p(VALUE self) { rb_warning("StringScanner#empty? is obsolete; use #eos? instead"); return strscan_eos_p(self); @@ -887,8 +844,7 @@ strscan_empty_p(self) * s.rest? # are opposites. */ static VALUE -strscan_rest_p(self) - VALUE self; +strscan_rest_p(VALUE self) { struct strscanner *p; @@ -906,8 +862,7 @@ strscan_rest_p(self) * s.matched? # => false */ static VALUE -strscan_matched_p(self) - VALUE self; +strscan_matched_p(VALUE self) { struct strscanner *p; @@ -923,8 +878,7 @@ strscan_matched_p(self) * s.matched # -> "test" */ static VALUE -strscan_matched(self) - VALUE self; +strscan_matched(VALUE self) { struct strscanner *p; @@ -945,8 +899,7 @@ strscan_matched(self) * s.matched_size # -> nil */ static VALUE -strscan_matched_size(self) - VALUE self; +strscan_matched_size(VALUE self) { struct strscanner *p; @@ -981,8 +934,7 @@ strscan_matchedsize(VALUE self) * s.pre_match # -> "" */ static VALUE -strscan_aref(self, idx) - VALUE self, idx; +strscan_aref(VALUE self, VALUE idx) { struct strscanner *p; long i; @@ -1011,8 +963,7 @@ strscan_aref(self, idx) * s.post_match # -> "string" */ static VALUE -strscan_pre_match(self) - VALUE self; +strscan_pre_match(VALUE self) { struct strscanner *p; @@ -1031,8 +982,7 @@ strscan_pre_match(self) * s.post_match # -> "string" */ static VALUE -strscan_post_match(self) - VALUE self; +strscan_post_match(VALUE self) { struct strscanner *p; @@ -1046,8 +996,7 @@ strscan_post_match(self) * If there is no more data (eos? = true), it returns "". */ static VALUE -strscan_rest(self) - VALUE self; +strscan_rest(VALUE self) { struct strscanner *p; @@ -1062,8 +1011,7 @@ strscan_rest(self) * s.rest_size is equivalent to s.rest.size. */ static VALUE -strscan_rest_size(self) - VALUE self; +strscan_rest_size(VALUE self) { struct strscanner *p; long i; @@ -1102,8 +1050,7 @@ strscan_restsize(VALUE self) * s.inspect # -> '#' */ static VALUE -strscan_inspect(self) - VALUE self; +strscan_inspect(VALUE self) { struct strscanner *p; char buf[BUFSIZE]; @@ -1140,8 +1087,7 @@ strscan_inspect(self) } static VALUE -inspect1(p) - struct strscanner *p; +inspect1(struct strscanner *p) { char buf[BUFSIZE]; char *bp = buf; @@ -1160,8 +1106,7 @@ inspect1(p) } static VALUE -inspect2(p) - struct strscanner *p; +inspect2(struct strscanner *p) { char buf[BUFSIZE]; char *bp = buf; -- cgit v1.2.3