diff -ur ferret-0.11.6/ext/ferret.c ferret-0.11.6-rb19/ext/ferret.c --- ferret-0.11.6/ext/ferret.c 2007-10-08 10:47:04.000000000 +0200 +++ ferret-0.11.6-rb19/ext/ferret.c 2010-08-12 16:36:28.000000000 +0200 @@ -162,14 +162,14 @@ char * rs2s(VALUE rstr) { - return (char *)(RSTRING(rstr)->ptr ? RSTRING(rstr)->ptr : EMPTY_STRING); + return (char *)(RSTRING_PTR(rstr) ? RSTRING_PTR(rstr) : EMPTY_STRING); } char * nstrdup(VALUE rstr) { char *old = rs2s(rstr); - int len = RSTRING(rstr)->len; + int len = RSTRING_LEN(rstr); char *new = ALLOC_N(char, len + 1); memcpy(new, old, len + 1); return new; @@ -295,7 +295,7 @@ char *field = StringValuePtr(rfield); char *text = StringValuePtr(rtext); char *term_str = ALLOC_N(char, - 5 + RSTRING(rfield)->len + RSTRING(rtext)->len); + 5 + RSTRING_LEN(rfield) + RSTRING_LEN(rtext)); sprintf(term_str, "%s:%s", field, text); rstr = rb_str_new2(term_str); free(term_str); diff -ur ferret-0.11.6/ext/lang.h ferret-0.11.6-rb19/ext/lang.h --- ferret-0.11.6/ext/lang.h 2007-11-28 23:09:27.000000000 +0100 +++ ferret-0.11.6-rb19/ext/lang.h 2010-08-12 16:36:28.000000000 +0200 @@ -45,4 +45,22 @@ extern void V_FRT_EXIT(const char *err_type, const char *fmt, va_list args); #endif +#ifdef RUBY_RUBY_H +# define FRT_RUBY_VERSION_1_9 +#endif + +// ruby 1.8 compat with 1.9 to avoid ifdefs +#if !defined RSTRING_LEN +#define RSTRING_LEN(a) RSTRING(a)->len +#endif +#if !defined RSTRING_PTR +#define RSTRING_PTR(a) RSTRING(a)->ptr +#endif +#if !defined RARRAY_LEN +#define RARRAY_LEN(a) RARRAY(a)->len +#endif +#if !defined RARRAY_PTR +#define RARRAY_PTR(a) RARRAY(a)->ptr +#endif + #endif diff -ur ferret-0.11.6/ext/r_analysis.c ferret-0.11.6-rb19/ext/r_analysis.c --- ferret-0.11.6/ext/r_analysis.c 2007-10-09 02:44:32.000000000 +0200 +++ ferret-0.11.6-rb19/ext/r_analysis.c 2010-08-12 16:36:27.000000000 +0200 @@ -1,6 +1,11 @@ -#include +#include "lang.h" +#ifdef FRT_RUBY_VERSION_1_9 +# include +#else +# include +#endif #include -#include +#include #include "ferret.h" #include "analysis.h" @@ -47,13 +52,15 @@ static VALUE object_space; +#ifndef FRT_RUBY_VERSION_1_9 extern int ruby_re_search(struct re_pattern_buffer *, const char *, int, int, int, struct re_registers *); +#endif int frt_rb_hash_size(VALUE hash) { - return RHASH(hash)->tbl->num_entries; + return RHASH(hash)->ntbl->num_entries; } /**************************************************************************** @@ -69,11 +76,11 @@ int i, len; VALUE rstr; Check_Type(rstop_words, T_ARRAY); - len = RARRAY(rstop_words)->len; - stop_words = ALLOC_N(char *, RARRAY(rstop_words)->len + 1); + len = RARRAY_LEN(rstop_words); + stop_words = ALLOC_N(char *, RARRAY_LEN(rstop_words) + 1); stop_words[len] = NULL; for (i = 0; i < len; i++) { - rstr = rb_obj_as_string(RARRAY(rstop_words)->ptr[i]); + rstr = rb_obj_as_string(RARRAY_PTR(rstop_words)[i]); stop_words[i] = rs2s(rstr); } return stop_words; @@ -132,7 +139,7 @@ if (rt == Qnil) return NULL; Data_Get_Struct(rt, RToken, rtk); - tk_set(tk, rs2s(rtk->text), RSTRING(rtk->text)->len, + tk_set(tk, rs2s(rtk->text), RSTRING_LEN(rtk->text), rtk->start, rtk->end, rtk->pos_inc); return tk; } @@ -372,7 +379,7 @@ RToken *token; char *buf; GET_TK(token, self); - buf = alloca(RSTRING(token->text)->len + 80); + buf = alloca(RSTRING_LEN(token->text) + 80); sprintf(buf, "token[\"%s\":%d:%d:%d]", rs2s(token->text), token->start, token->end, token->pos_inc); return rb_str_new2(buf); @@ -621,7 +628,7 @@ VALUE rtext; VALUE regex; VALUE proc; - int curr_ind; + long curr_ind; } RegExpTokenStream; static void @@ -689,16 +696,82 @@ return RETS(ts)->rtext; } +#ifdef FRT_RUBY_VERSION_1_9 + +// partly lifted from ruby 1.9 string.c +#include +#define BEG(no) regs->beg[no] +#define END(no) regs->end[no] +#define STR_ENC_GET(str) rb_enc_from_index(ENCODING_GET(str)) +static VALUE + scan_once(VALUE str, VALUE pat, long *start) +{ + VALUE match; + struct re_registers *regs; + + if (rb_reg_search(pat, str, *start, 0) >= 0) { + match = rb_backref_get(); + regs = RMATCH_REGS(match); + if (BEG(0) == END(0)) { + rb_encoding *enc = STR_ENC_GET(str); + /* + * Always consume at least one character of the input string + */ + if (RSTRING_LEN(str) > END(0)) + *start = END(0)+rb_enc_mbclen(RSTRING_PTR(str)+END(0), + RSTRING_END(str), enc); + else + *start = END(0)+1; + } + else { + *start = END(0); + } + return rb_reg_nth_match(0, match); + } + return Qnil; +} +// + +static Token * + rets_next(TokenStream *ts) +{ + VALUE ret; + long rtok_len; + int beg, end; + Check_Type(RETS(ts)->regex, T_REGEXP); + ret = scan_once(RETS(ts)->rtext, RETS(ts)->regex, &(RETS(ts)->curr_ind)); + if (NIL_P(ret)) return NULL; + + Check_Type(ret, T_STRING); + rtok_len = RSTRING_LEN(ret); + beg = RETS(ts)->curr_ind - rtok_len; + end = RETS(ts)->curr_ind; + + if (NIL_P(RETS(ts)->proc)) { + return tk_set(&(CachedTS(ts)->token), rs2s(ret), rtok_len, + beg, end, 1); + } else { + VALUE rtok; + rtok = rb_funcall(RETS(ts)->proc, id_call, 1, ret); + return tk_set(&(CachedTS(ts)->token), rs2s(rtok), + RSTRING_LEN(rtok), beg, end, 1); + } +} + +#else + static Token * rets_next(TokenStream *ts) { static struct re_registers regs; int ret, beg, end; struct RString *rtext = RSTRING(RETS(ts)->rtext); + long rtext_len = RSTRING_LEN(RETS(ts)->rtext); + char *rtext_ptr = RSTRING_PTR(RETS(ts)->rtext); Check_Type(RETS(ts)->regex, T_REGEXP); ret = ruby_re_search(RREGEXP(RETS(ts)->regex)->ptr, - rtext->ptr, rtext->len, - RETS(ts)->curr_ind, rtext->len - RETS(ts)->curr_ind, + rtext_ptr, rtext_len, + RETS(ts)->curr_ind, rtext_len - RETS(ts)->curr_ind, ®s); if (ret == -2) rb_raise(rb_eStandardError, "regexp buffer overflow"); @@ -707,16 +780,19 @@ beg = regs.beg[0]; RETS(ts)->curr_ind = end = regs.end[0]; if (NIL_P(RETS(ts)->proc)) { - return tk_set(&(CachedTS(ts)->token), rtext->ptr + beg, end - beg, + return tk_set(&(CachedTS(ts)->token), rtext_ptr + beg, end - beg, beg, end, 1); } else { - VALUE rtok = rb_str_new(rtext->ptr + beg, end - beg); + VALUE rtok = rb_str_new(rtext_ptr + beg, end - beg); rtok = rb_funcall(RETS(ts)->proc, id_call, 1, rtok); return tk_set(&(CachedTS(ts)->token), rs2s(rtok), - RSTRING(rtok)->len, beg, end, 1); + RSTRING_LEN(rtok), beg, end, 1); } } +#endif + + static TokenStream * rets_reset(TokenStream *ts, char *text) { @@ -1029,8 +1105,8 @@ } if (TYPE(key) == T_ARRAY) { int i; - for (i = RARRAY(key)->len - 1; i >= 0; i--) { - frt_add_mapping_i(mf, RARRAY(key)->ptr[i], to); + for (i = RARRAY_LEN(key) - 1; i >= 0; i--) { + frt_add_mapping_i(mf, RARRAY_PTR(key)[i], to); } } else { diff -ur ferret-0.11.6/ext/r_index.c ferret-0.11.6-rb19/ext/r_index.c --- ferret-0.11.6/ext/r_index.c 2007-11-28 21:14:10.000000000 +0100 +++ ferret-0.11.6-rb19/ext/r_index.c 2010-08-12 16:36:28.000000000 +0200 @@ -1,6 +1,6 @@ #include "ferret.h" #include "index.h" -#include +#include VALUE mIndex; @@ -765,8 +765,8 @@ char *term; int term_cnt = 0; VALUE vals = rb_ary_new2(2); - RARRAY(vals)->len = 2; - rb_mem_clear(RARRAY(vals)->ptr, 2); + rb_ary_store(vals, 0, Qnil); + rb_ary_store(vals, 1, Qnil); /* each is being called so there will be no current term */ @@ -775,8 +775,8 @@ while (NULL != (term = te->next(te))) { term_cnt++; - RARRAY(vals)->ptr[0] = rb_str_new(term, te->curr_term_len); - RARRAY(vals)->ptr[1] = INT2FIX(te->curr_ti.doc_freq); + RARRAY_PTR(vals)[0] = rb_str_new(term, te->curr_term_len); + RARRAY_PTR(vals)[1] = INT2FIX(te->curr_ti.doc_freq); rb_yield(vals); } return INT2FIX(term_cnt); @@ -1040,13 +1040,13 @@ int doc_cnt = 0; TermDocEnum *tde = (TermDocEnum *)DATA_PTR(self); VALUE vals = rb_ary_new2(2); - RARRAY(vals)->len = 2; - rb_mem_clear(RARRAY(vals)->ptr, 2); + rb_ary_store(vals, 0, Qnil); + rb_ary_store(vals, 1, Qnil); while (tde->next(tde)) { doc_cnt++; - RARRAY(vals)->ptr[0] = INT2FIX(tde->doc_num(tde)); - RARRAY(vals)->ptr[1] = INT2FIX(tde->freq(tde)); + RARRAY_PTR(vals)[0] = INT2FIX(tde->doc_num(tde)); + RARRAY_PTR(vals)[1] = INT2FIX(tde->freq(tde)); rb_yield(vals); } @@ -1212,14 +1212,11 @@ VALUE rpositions = Qnil; rtext = rb_str_new2(tv_term->text); if (tv_term->positions) { - VALUE *rpos; int *positions = tv_term->positions; rpositions = rb_ary_new2(freq); - rpos = RARRAY(rpositions)->ptr; for (i = 0; i < freq; i++) { - rpos[i] = INT2FIX(positions[i]); + rb_ary_store(rpositions, i, INT2FIX(positions[i])); } - RARRAY(rpositions)->len = freq; } return rb_struct_new(cTVTerm, rtext, rpositions, NULL); } @@ -1237,25 +1234,20 @@ TVTerm *terms = tv->terms; const int t_cnt = tv->term_cnt; const int o_cnt = tv->offset_cnt; - VALUE rfield, rterms, *rts; + VALUE rfield, rterms; VALUE roffsets = Qnil; rfield = ID2SYM(rb_intern(tv->field)); rterms = rb_ary_new2(t_cnt); - rts = RARRAY(rterms)->ptr; for (i = 0; i < t_cnt; i++) { - rts[i] = frt_get_tv_term(&terms[i]); - RARRAY(rterms)->len++; + rb_ary_store(rterms, i, frt_get_tv_term(&terms[i])); } if (tv->offsets) { - VALUE *ros; Offset *offsets = tv->offsets; roffsets = rb_ary_new2(o_cnt); - ros = RARRAY(roffsets)->ptr; for (i = 0; i < o_cnt; i++) { - ros[i] = frt_get_tv_offsets(&offsets[i]); - RARRAY(roffsets)->len++; + rb_ary_store(roffsets, i, frt_get_tv_offsets(&offsets[i])); } } @@ -1458,19 +1450,19 @@ { int i; df->destroy_data = true; - for (i = 0; i < RARRAY(value)->len; i++) { - val = rb_obj_as_string(RARRAY(value)->ptr[i]); - df_add_data_len(df, nstrdup(val), RSTRING(val)->len); + for (i = 0; i < RARRAY_LEN(value); i++) { + val = rb_obj_as_string(RARRAY_PTR(value)[i]); + df_add_data_len(df, nstrdup(val), RSTRING_LEN(val)); } } break; case T_STRING: - df_add_data_len(df, rs2s(value), RSTRING(value)->len); + df_add_data_len(df, rs2s(value), RSTRING_LEN(value)); break; default: val = rb_obj_as_string(value); df->destroy_data = true; - df_add_data_len(df, nstrdup(val), RSTRING(val)->len); + df_add_data_len(df, nstrdup(val), RSTRING_LEN(val)); break; } doc_add_field(doc, df); @@ -1498,9 +1490,9 @@ int i; df = df_new("content"); df->destroy_data = true; - for (i = 0; i < RARRAY(rdoc)->len; i++) { - val = rb_obj_as_string(RARRAY(rdoc)->ptr[i]); - df_add_data_len(df, nstrdup(val), RSTRING(val)->len); + for (i = 0; i < RARRAY_LEN(rdoc); i++) { + val = rb_obj_as_string(RARRAY_PTR(rdoc)[i]); + df_add_data_len(df, nstrdup(val), RSTRING_LEN(val)); } doc_add_field(doc, df); } @@ -1511,13 +1503,13 @@ break; case T_STRING: df = df_add_data_len(df_new("content"), rs2s(rdoc), - RSTRING(rdoc)->len); + RSTRING_LEN(rdoc)); doc_add_field(doc, df); break; default: val = rb_obj_as_string(rdoc); df = df_add_data_len(df_new("content"), nstrdup(val), - RSTRING(val)->len); + RSTRING_LEN(val)); df->destroy_data = true; doc_add_field(doc, df); break; @@ -1597,14 +1589,14 @@ IndexReader **irs; Check_Type(rreaders, T_ARRAY); - irs = ALLOC_N(IndexReader *, RARRAY(rreaders)->len); - i = RARRAY(rreaders)->len; + irs = ALLOC_N(IndexReader *, RARRAY_LEN(rreaders)); + i = RARRAY_LEN(rreaders); while (i-- > 0) { IndexReader *ir; - Data_Get_Struct(RARRAY(rreaders)->ptr[i], IndexReader, ir); + Data_Get_Struct(RARRAY_PTR(rreaders)[i], IndexReader, ir); irs[i] = ir; } - iw_add_readers(iw, irs, RARRAY(rreaders)->len); + iw_add_readers(iw, irs, RARRAY_LEN(rreaders)); free(irs); return self; } @@ -1953,9 +1945,7 @@ rdata = rb_ary_new2(lazy_df->size); for (i = 0; i < lazy_df->size; i++) { char *data = lazy_df_get_data(lazy_df, i); - RARRAY(rdata)->ptr[i] = - rb_str_new(data, lazy_df->data[i].length); - RARRAY(rdata)->len++; + rb_ary_store(rdata, i, rb_str_new(data, lazy_df->data[i].length)); } } rb_hash_aset(self, rkey, rdata); @@ -2038,8 +2028,7 @@ rb_ivar_set(self, id_data, rdata); for (i = 0; i < lazy_doc->size; i++) { - RARRAY(rfields)->ptr[i] = ID2SYM(rb_intern(lazy_doc->fields[i]->name)); - RARRAY(rfields)->len++; + rb_ary_store(rfields, i, ID2SYM(rb_intern(lazy_doc->fields[i]->name))); } rb_ivar_set(self, id_fields, rfields); @@ -2115,11 +2104,11 @@ if (TYPE(rdir) == T_ARRAY) { VALUE rdirs = rdir; - const int reader_cnt = RARRAY(rdir)->len; + const int reader_cnt = RARRAY_LEN(rdir); IndexReader **sub_readers = ALLOC_N(IndexReader *, reader_cnt); int i; for (i = 0; i < reader_cnt; i++) { - rdir = RARRAY(rdirs)->ptr[i]; + rdir = RARRAY_PTR(rdirs)[i]; switch (TYPE(rdir)) { case T_DATA: if (CLASS_OF(rdir) == cIndexReader) { @@ -2235,11 +2224,11 @@ int offset; offset = FIX2INT(roffset); Check_Type(rnorms, T_STRING); - if (RSTRING(rnorms)->len < offset + ir->max_doc(ir)) { - rb_raise(rb_eArgError, "supplied a string of length:%d to " + if (RSTRING_LEN(rnorms) < offset + ir->max_doc(ir)) { + rb_raise(rb_eArgError, "supplied a string of length:%ld to " "IndexReader#get_norms_into but needed a string of length " "offset:%d + maxdoc:%d", - RSTRING(rnorms)->len, offset, ir->max_doc(ir)); + RSTRING_LEN(rnorms), offset, ir->max_doc(ir)); } ir_get_norms_into(ir, frt_field(rfield), @@ -2382,8 +2371,7 @@ len = max - pos; ary = rb_ary_new2(len); for (i = 0; i < len; i++) { - RARRAY(ary)->ptr[i] = frt_get_lazy_doc(ir->get_lazy_doc(ir, i + pos)); - RARRAY(ary)->len++; + rb_ary_store(ary, i, frt_get_lazy_doc(ir->get_lazy_doc(ir, i + pos))); } return ary; } @@ -2410,9 +2398,8 @@ pos = FIX2INT(arg1); pos = (pos < 0) ? (max + pos) : pos; if (pos < 0 || pos >= max) { - rb_raise(rb_eArgError, ":%d is out of range [%d..%d] for " - "IndexReader#[]", pos, 0, max, - rb_id2name(SYM2ID(argv))); + rb_raise(rb_eArgError, ":%ld is out of range [%d..%ld] for " + "IndexReader#[]", pos, 0, max); } return frt_get_lazy_doc(ir->get_lazy_doc(ir, pos)); } diff -ur ferret-0.11.6/ext/r_qparser.c ferret-0.11.6-rb19/ext/r_qparser.c --- ferret-0.11.6/ext/r_qparser.c 2007-10-09 09:38:08.000000000 +0200 +++ ferret-0.11.6-rb19/ext/r_qparser.c 2010-08-12 16:36:28.000000000 +0200 @@ -53,8 +53,8 @@ fields = hs_new_str(&free); if (TYPE(rfields) == T_ARRAY) { int i; - for (i = 0; i < RARRAY(rfields)->len; i++) { - rval = rb_obj_as_string(RARRAY(rfields)->ptr[i]); + for (i = 0; i < RARRAY_LEN(rfields); i++) { + rval = rb_obj_as_string(RARRAY_PTR(rfields)[i]); hs_add(fields, nstrdup(rval)); } } else { diff -ur ferret-0.11.6/ext/r_search.c ferret-0.11.6-rb19/ext/r_search.c --- ferret-0.11.6/ext/r_search.c 2007-11-24 00:26:33.000000000 +0100 +++ ferret-0.11.6-rb19/ext/r_search.c 2010-08-12 16:36:28.000000000 +0200 @@ -161,8 +161,7 @@ VALUE hit_ary = rb_ary_new2(td->size); for (i = 0; i < td->size; i++) { - RARRAY(hit_ary)->ptr[i] = frt_get_hit(td->hits[i]); - RARRAY(hit_ary)->len++; + rb_ary_store(hit_ary, i, frt_get_hit(td->hits[i])); } rtop_docs = rb_struct_new(cTopDocs, @@ -187,7 +186,7 @@ int i; VALUE rhits = rb_funcall(self, id_hits, 0); Searcher *sea = (Searcher *)DATA_PTR(rb_funcall(self, id_searcher, 0)); - const int len = RARRAY(rhits)->len; + const int len = RARRAY_LEN(rhits); char *str = ALLOC_N(char, len * 64 + 100); char *s = str; char *field = "id"; @@ -197,13 +196,13 @@ field = frt_field(argv[0]); } - sprintf(s, "TopDocs: total_hits = %ld, max_score = %f [\n", + sprintf(s, "TopDocs: total_hits = %d, max_score = %f [\n", FIX2INT(rb_funcall(self, id_total_hits, 0)), NUM2DBL(rb_funcall(self, id_max_score, 0))); s += strlen(s); for (i = 0; i < len; i++) { - VALUE rhit = RARRAY(rhits)->ptr[i]; + VALUE rhit = RARRAY_PTR(rhits)[i]; int doc_id = FIX2INT(rb_funcall(rhit, id_doc, 0)); char *value = ""; LazyDoc *lzd = sea->get_lazy_doc(sea, doc_id); @@ -280,7 +279,7 @@ VALUE rhit; LazyDoc *lzd; Searcher *sea = (Searcher *)DATA_PTR(rb_funcall(self, id_searcher, 0)); - const int num_hits = RARRAY(rhits)->len; + const int num_hits = RARRAY_LEN(rhits); int doc_id; int len = 32768; char *str = ALLOC_N(char, len); @@ -291,7 +290,7 @@ for (i = 0; i < num_hits; i++) { if (i) *(s++) = ','; *(s++) = '{'; - rhit = RARRAY(rhits)->ptr[i]; + rhit = RARRAY_PTR(rhits)[i]; doc_id = FIX2INT(rb_funcall(rhit, id_doc, 0)); lzd = sea->get_lazy_doc(sea, doc_id); s = frt_lzd_load_to_json(lzd, &str, s, &len); @@ -623,7 +622,7 @@ rb_raise(rb_eArgError, "%d <= 0. @@max_terms must be > 0", max_terms); } - rb_cvar_set(cMultiTermQuery, id_default_max_terms, rnum_terms, Qfalse); + rb_cvar_set(cMultiTermQuery, id_default_max_terms, rnum_terms); return rnum_terms; } @@ -1165,15 +1164,15 @@ { int i; char *t; - if (RARRAY(rterm)->len < 1) { + if (RARRAY_LEN(rterm) < 1) { rb_raise(rb_eArgError, "Cannot add empty array to a " "PhraseQuery. You must add either a string or " "an array of strings"); } - t = StringValuePtr(RARRAY(rterm)->ptr[0]); + t = StringValuePtr(RARRAY_PTR(rterm)[0]); phq_add_term(q, t, pos_inc); - for (i = 1; i < RARRAY(rterm)->len; i++) { - t = StringValuePtr(RARRAY(rterm)->ptr[i]); + for (i = 1; i < RARRAY_LEN(rterm); i++) { + t = StringValuePtr(RARRAY_PTR(rterm)[i]); phq_append_multi_term(q, t); } break; @@ -1426,7 +1425,7 @@ "%f < 0.0. :min_similarity must be > 0.0", min_sim); } qp_default_fuzzy_min_sim = (float)min_sim; - rb_cvar_set(cFuzzyQuery, id_default_min_similarity, val, Qfalse); + rb_cvar_set(cFuzzyQuery, id_default_min_similarity, val); return val; } @@ -1458,7 +1457,7 @@ "%d < 0. :prefix_length must be >= 0", pre_len); } qp_default_fuzzy_pre_len = pre_len; - rb_cvar_set(cFuzzyQuery, id_default_prefix_length, val, Qfalse); + rb_cvar_set(cFuzzyQuery, id_default_prefix_length, val); return val; } @@ -1591,8 +1590,8 @@ { Query *q = spanmtq_new(frt_field(rfield)); int i; - for (i = RARRAY(rterms)->len - 1; i >= 0; i--) { - spanmtq_add_term(q, StringValuePtr(RARRAY(rterms)->ptr[i])); + for (i = RARRAY_LEN(rterms) - 1; i >= 0; i--) { + spanmtq_add_term(q, StringValuePtr(RARRAY_PTR(rterms)[i])); } Frt_Wrap_Struct(self, NULL, &frt_q_free, q); object_add(q, self); @@ -1716,8 +1715,8 @@ int i; Query *clause; Check_Type(v, T_ARRAY); - for (i = 0; i < RARRAY(v)->len; i++) { - Data_Get_Struct(RARRAY(v)->ptr[i], Query, clause); + for (i = 0; i < RARRAY_LEN(v); i++) { + Data_Get_Struct(RARRAY_PTR(v)[i], Query, clause); spannq_add_clause(q, clause); } } @@ -1782,8 +1781,8 @@ int i; Query *clause; Check_Type(rclauses, T_ARRAY); - for (i = 0; i < RARRAY(rclauses)->len; i++) { - Data_Get_Struct(RARRAY(rclauses)->ptr[i], Query, clause); + for (i = 0; i < RARRAY_LEN(rclauses); i++) { + Data_Get_Struct(RARRAY_PTR(rclauses)[i], Query, clause); spanoq_add_clause(q, clause); } } @@ -2277,8 +2276,8 @@ case 1: if (TYPE(rfields) == T_ARRAY) { int i; - for (i = 0; i < RARRAY(rfields)->len; i++) { - frt_sort_add(sort, RARRAY(rfields)->ptr[i], reverse); + for (i = 0; i < RARRAY_LEN(rfields); i++) { + frt_sort_add(sort, RARRAY_PTR(rfields)[i], reverse); } } else { frt_sort_add(sort, rfields, reverse); @@ -2632,7 +2631,7 @@ rb_scan_args(argc, argv, "11", &rquery, &roptions); - rb_thread_critical = Qtrue; + //sds rb_thread_critical = Qtrue; Data_Get_Struct(rquery, Query, q); td = frt_sea_search_internal(q, roptions, sea); @@ -2648,7 +2647,7 @@ rtotal_hits = INT2FIX(td->total_hits); td_destroy(td); - rb_thread_critical = 0; + //sds rb_thread_critical = 0; return rtotal_hits; } @@ -2753,8 +2752,7 @@ VALUE rexcerpts = rb_ary_new2(size); for (i = 0; i < size; i++) { - RARRAY(rexcerpts)->ptr[i] = rb_str_new2(excerpts[i]); - RARRAY(rexcerpts)->len++; + rb_ary_store(rexcerpts, i, rb_str_new2(excerpts[i])); } ary_destroy(excerpts, &free); return rexcerpts; @@ -2870,10 +2868,10 @@ rsearcher = argv[i]; switch (TYPE(rsearcher)) { case T_ARRAY: - capa += RARRAY(rsearcher)->len; + capa += RARRAY_LEN(rsearcher); REALLOC_N(searchers, Searcher *, capa); - for (j = 0; j < RARRAY(rsearcher)->len; j++) { - VALUE rs = RARRAY(rsearcher)->ptr[j]; + for (j = 0; j < RARRAY_LEN(rsearcher); j++) { + VALUE rs = RARRAY_PTR(rsearcher)[j]; Data_Get_Struct(rs, Searcher, s); searchers[top++] = s; } @@ -3107,7 +3105,7 @@ cMultiTermQuery = rb_define_class_under(mSearch, "MultiTermQuery", cQuery); rb_define_alloc_func(cMultiTermQuery, frt_data_alloc); - rb_cvar_set(cMultiTermQuery, id_default_max_terms, INT2FIX(512), Qfalse); + rb_cvar_set(cMultiTermQuery, id_default_max_terms, INT2FIX(512)); rb_define_singleton_method(cMultiTermQuery, "default_max_terms", frt_mtq_get_dmt, 0); rb_define_singleton_method(cMultiTermQuery, "default_max_terms=", @@ -3416,9 +3414,9 @@ cFuzzyQuery = rb_define_class_under(mSearch, "FuzzyQuery", cQuery); rb_define_alloc_func(cFuzzyQuery, frt_data_alloc); rb_cvar_set(cFuzzyQuery, id_default_min_similarity, - rb_float_new(0.5), Qfalse); + rb_float_new(0.5)); rb_cvar_set(cFuzzyQuery, id_default_prefix_length, - INT2FIX(0), Qfalse); + INT2FIX(0)); rb_define_singleton_method(cFuzzyQuery, "default_min_similarity", frt_fq_get_dms, 0);