Show
Ignore:
Timestamp:
03/28/06 13:48:18 (6 years ago)
Author:
knok
Message:

Added maxget parameter.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • Search-Namazu/trunk/Search-Namazu/Namazu.xs

    r217 r244  
    5959static int status = 0; 
    6060 
    61 AV * call_search_main_c(char *query) 
     61AV * call_search_main_c(char *query, int maxget) 
    6262{ 
    6363        AV *retar; 
     
    6767        status = 0; 
    6868        retar = newAV(); 
     69        av_extend(retar, hlist.num - 1); 
    6970        hlist = nmz_search(query); 
    7071        status = hlist.stat; 
    7172        for (i = 0; i < hlist.num; i ++) { 
     73            if (i < maxget) { 
    7274                SV *ohlist = perl_eval_pv("new Search::Namazu::Result", TRUE); 
    7375                dSP; 
     
    9294                perl_call_method("set", G_DISCARD); 
    9395                SvREFCNT_inc(ohlist); 
    94                 av_push(retar, ohlist); 
     96                av_store(retar, i, ohlist); 
    9597                FREETMPS; 
    9698                LEAVE; 
     99            } else { 
     100                av_store(retar, i, &PL_sv_undef); 
     101            }       
    97102        } 
    98103        nmz_free_hlist(hlist); 
     
    105110 
    106111void 
    107 call_search_main(query) 
     112call_search_main(query, maxget) 
    108113        SV *query 
     114        int maxget 
    109115 
    110116        PPCODE: 
     
    117123                nmz_codeconv_query(qstr); 
    118124                strcpy(cqstr, qstr); 
    119                 retar = call_search_main_c(cqstr); 
     125                retar = call_search_main_c(cqstr, maxget); 
    120126#if ! defined(PERL_VERSION) 
    121127                { /* workaround for only one result */ 
     
    130136 
    131137SV* 
    132 call_search_main_ref(query) 
     138call_search_main_ref(query, maxget) 
    133139        SV *query 
     140        int maxget 
    134141 
    135142        CODE: 
     
    142149                nmz_codeconv_query(qstr); 
    143150                strcpy(cqstr, qstr); 
    144                 retar = call_search_main_c(cqstr); 
     151                retar = call_search_main_c(cqstr, maxget); 
    145152                nmz_free_internal(); 
    146153                RETVAL = newRV_inc((SV*) retar); 
     
    203210void 
    204211nmz_setmaxhit(max) 
    205         int max; 
     212        int max 
    206213 
    207214        CODE: