1053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project/* 2053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project * Copyright (C) 2008,2009 OMRON SOFTWARE Co., Ltd. 3053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project * 4053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project * Licensed under the Apache License, Version 2.0 (the "License"); 5053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project * you may not use this file except in compliance with the License. 6053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project * You may obtain a copy of the License at 7053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project * 8053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project * http://www.apache.org/licenses/LICENSE-2.0 9053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project * 10053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project * Unless required by applicable law or agreed to in writing, software 11053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project * distributed under the License is distributed on an "AS IS" BASIS, 12053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project * See the License for the specific language governing permissions and 14053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project * limitations under the License. 15053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project */ 16053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 17053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#include "nj_lib.h" 18053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#include "nj_err.h" 19053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#include "nj_ext.h" 20053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#include "nj_dic.h" 21053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#include "njd.h" 22053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#ifdef NJ_LEARN_MUHENKAN_DEBUG 23053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#include <stdio.h> 24053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#include <def_mojicode.h> 25053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#endif 26053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#ifdef NJ_AWNN22_DEBUG 27053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#include <stdio.h> 28053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#include <def_mojicode.h> 29053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#endif 30053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 31053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#define QUE_TYPE_EMPTY 0 32053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#define QUE_TYPE_NEXT 0 33053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#define QUE_TYPE_JIRI 1 34053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#define QUE_TYPE_FZK 2 35053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#define POS_DATA_OFFSET 0x20 36053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#define POS_LEARN_WORD 0x24 37053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#define POS_MAX_WORD 0x28 38053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#define POS_QUE_SIZE 0x2C 39053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#define POS_NEXT_QUE 0x30 40053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#define POS_WRITE_FLG 0x34 41053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#define POS_INDEX_OFFSET 0x3C 42053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#define POS_INDEX_OFFSET2 0x40 43053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 44053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#define LEARN_INDEX_TOP_ADDR(x) ((x) + (NJ_INT32_READ((x) + POS_INDEX_OFFSET))) 45053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#define LEARN_INDEX_TOP_ADDR2(x) ((x) + (NJ_INT32_READ((x) + POS_INDEX_OFFSET2))) 46053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#define LEARN_DATA_TOP_ADDR(x) ((x) + (NJ_INT32_READ((x) + POS_DATA_OFFSET))) 47053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 48053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#define LEARN_INDEX_BOTTOM_ADDR(x) (LEARN_DATA_TOP_ADDR(x) - 1) 49053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 50053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#define LEARN_QUE_STRING_OFFSET 5 51053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 52053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#define ADDRESS_TO_POS(x,adr) (((adr) - LEARN_DATA_TOP_ADDR(x)) / QUE_SIZE(x)) 53053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#define POS_TO_ADDRESS(x,pos) (LEARN_DATA_TOP_ADDR(x) + QUE_SIZE(x) * (pos)) 54053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 55053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#define GET_UINT16(ptr) ((((NJ_UINT16)(*(ptr))) << 8) | (*((ptr) + 1) & 0x00ff)) 56053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 57053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#define GET_FPOS_FROM_DATA(x) ((NJ_UINT16)NJ_INT16_READ((x)+1) >> 7) 58053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#define GET_YSIZE_FROM_DATA(x) ((NJ_UINT8)((NJ_UINT16)NJ_INT16_READ((x)+1) & 0x7F)) 59053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#define GET_BPOS_FROM_DATA(x) ((NJ_UINT16)NJ_INT16_READ((x)+3) >> 7) 60053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#define GET_KSIZE_FROM_DATA(x) ((NJ_UINT8)((NJ_UINT16)NJ_INT16_READ((x)+3) & 0x7F)) 61053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#define GET_BPOS_FROM_EXT_DATA(x) ((NJ_UINT16)NJ_INT16_READ(x) >> 7) 62053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#define GET_YSIZE_FROM_EXT_DATA(x) ((NJ_UINT8)((NJ_UINT16)NJ_INT16_READ(x) & 0x7F)) 63053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 64053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#define SET_BPOS_AND_YSIZE(x,bpos,ysize) \ 65053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_INT16_WRITE((x), ((NJ_UINT16)((bpos) << 7) | ((ysize) & 0x7F))) 66053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#define SET_FPOS_AND_YSIZE(x,fpos,ysize) \ 67053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_INT16_WRITE(((x)+1), ((NJ_UINT16)((fpos) << 7) | ((ysize) & 0x7F))) 68053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#define SET_BPOS_AND_KSIZE(x,bpos,ksize) \ 69053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_INT16_WRITE(((x)+3), ((NJ_UINT16)((bpos) << 7) | ((ksize) & 0x7F))) 70053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 71053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#define GET_TYPE_FROM_DATA(x) (*(x) & 0x03) 72053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#define GET_UFLG_FROM_DATA(x) (*(x) >> 7) 73053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#define GET_FFLG_FROM_DATA(x) ((*(x) >> 6) & 0x01) 74053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#define GET_MFLG_FROM_DATA(x) (*(x) & 0x10) 75053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 76053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#define SET_TYPE_UFLG_FFLG(x,type,u,f) \ 77053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project (*(x) = (NJ_UINT8)(((type) & 0x03) | \ 78053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project (((u) & 0x01) << 7) | (((f) & 0x01) << 6))) 79053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#define SET_TYPE_ALLFLG(x,type,u,f,m) \ 80053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project (*(x) = (NJ_UINT8)(((type) & 0x03) | \ 81053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project (((u) & 0x01) << 7) | (((f) & 0x01) << 6) | (((m) & 0x01) << 4))) 82053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 83053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#define RESET_FFLG(x) (*(x) &= 0xbf) 84053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 85053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#define STATE_COPY(to, from) \ 86053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project { ((NJ_UINT8*)(to))[0] = ((NJ_UINT8*)(from))[0]; \ 87053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ((NJ_UINT8*)(to))[1] = ((NJ_UINT8*)(from))[1]; \ 88053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ((NJ_UINT8*)(to))[2] = ((NJ_UINT8*)(from))[2]; \ 89053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ((NJ_UINT8*)(to))[3] = ((NJ_UINT8*)(from))[3]; } 90053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 91053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#define USE_QUE_NUM(que_size, str_size) \ 92053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ( (((str_size) % ((que_size) - 1)) == 0) \ 93053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ? ((str_size) / ((que_size) - 1)) \ 94053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project : ((str_size) / ((que_size) - 1) + 1) ) 95053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 96053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#define NEXT_QUE(que, max) ( ((que) < ((max) - 1)) ? ((que) + 1) : 0 ) 97053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 98053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#define PREV_QUE(que, max) ( ((que) == 0) ? ((max) - 1) : ((que) - 1) ) 99053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 100053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#define COPY_QUE(handle, src, dst) \ 101053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project nj_memcpy(POS_TO_ADDRESS((handle), (dst)), POS_TO_ADDRESS((handle), (src)), QUE_SIZE(handle)) 102053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 103053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 104053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#define INIT_HINDO (-10000) 105053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 106053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#define LOC_CURRENT_NO_ENTRY 0xffffffffU 107053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 108053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 109053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 110053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Projectstatic NJ_WQUE *get_que(NJ_CLASS *iwnn, NJ_DIC_HANDLE handle, NJ_UINT16 que_id); 111053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Projectstatic NJ_INT16 is_continued(NJ_CLASS *iwnn, NJ_DIC_HANDLE handle, NJ_UINT16 que_id); 112053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Projectstatic NJ_UINT16 search_next_que(NJ_DIC_HANDLE handle, NJ_UINT16 que_id); 113053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Projectstatic NJ_INT16 que_strcmp_complete_with_hyouki(NJ_CLASS *iwnn, NJ_DIC_HANDLE handle, NJ_UINT16 que_id, NJ_CHAR *yomi, NJ_UINT16 yomi_len, NJ_CHAR *hyouki, NJ_UINT8 multi_flg); 114053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Projectstatic NJ_CHAR *get_string(NJ_CLASS *iwnn, NJ_DIC_HANDLE handle, NJ_UINT16 que_id, NJ_UINT8 *slen); 115053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Projectstatic NJ_CHAR *get_hyouki(NJ_CLASS *iwnn, NJ_DIC_HANDLE handle, NJ_UINT16 que_id, NJ_UINT8 *slen); 116053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Projectstatic NJ_INT16 get_cand_by_sequential(NJ_CLASS *iwnn, NJ_SEARCH_CONDITION *cond, NJ_SEARCH_LOCATION_SET *loctset, NJ_UINT8 search_pattern, NJ_UINT8 comp_flg); 117053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Projectstatic NJ_INT16 get_cand_by_evaluate(NJ_CLASS *iwnn, NJ_SEARCH_CONDITION *cond, NJ_SEARCH_LOCATION_SET *loctset, NJ_UINT8 search_pattern); 118053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Projectstatic NJ_INT16 get_cand_by_evaluate2(NJ_CLASS *iwnn, NJ_SEARCH_CONDITION *cond, NJ_SEARCH_LOCATION_SET *loctset, NJ_UINT8 search_pattern, NJ_UINT16 hIdx); 119053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Projectstatic NJ_INT16 search_range_by_yomi(NJ_CLASS *iwnn, NJ_DIC_HANDLE handle, NJ_UINT8 op, NJ_CHAR *yomi, NJ_UINT16 ylen, NJ_UINT16 *from, NJ_UINT16 *to, NJ_UINT8 *forward_flag); 120053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Projectstatic NJ_INT16 search_range_by_yomi2(NJ_CLASS *iwnn, NJ_DIC_HANDLE handle, NJ_UINT8 op, NJ_CHAR *yomi, NJ_UINT16 ylen, NJ_UINT16 sfrom, NJ_UINT16 sto, NJ_UINT16 *from, NJ_UINT16 *to, 121053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT8 *forward_flag); 122053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Projectstatic NJ_INT16 search_range_by_yomi_multi(NJ_CLASS *iwnn, NJ_DIC_HANDLE handle, NJ_CHAR *yomi, NJ_UINT16 ylen, NJ_UINT16 *from, NJ_UINT16 *to); 123053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Projectstatic NJ_INT16 str_que_cmp(NJ_CLASS *iwnn, NJ_DIC_HANDLE handle, NJ_CHAR *yomi, NJ_UINT16 yomiLen, NJ_UINT16 que_id, NJ_UINT8 mode); 124053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Projectstatic NJ_WQUE *get_que_type_and_next(NJ_CLASS *iwnn, NJ_DIC_HANDLE handle, NJ_UINT16 que_id); 125053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Projectstatic NJ_WQUE *get_que_allHinsi(NJ_CLASS *iwnn, NJ_DIC_HANDLE handle, NJ_UINT16 que_id); 126053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Projectstatic NJ_WQUE *get_que_yomiLen_and_hyoukiLen(NJ_CLASS *iwnn, NJ_DIC_HANDLE handle, NJ_UINT16 que_id); 127053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Projectstatic NJ_INT16 continue_cnt(NJ_CLASS *iwnn, NJ_DIC_HANDLE handle, NJ_UINT16 que_id); 128053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 129053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Projectstatic NJ_UINT8 *get_search_index_address(NJ_DIC_HANDLE handle, NJ_UINT8 search_pattern); 130053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 131053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Projectstatic NJ_HINDO get_hindo(NJ_CLASS *iwnn, NJ_SEARCH_LOCATION_SET *loctset, NJ_UINT8 search_pattern); 132053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 133053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Projectstatic NJ_HINDO calculate_hindo(NJ_DIC_HANDLE handle, NJ_INT32 freq, NJ_DIC_FREQ *dic_freq, NJ_INT16 freq_max, NJ_INT16 freq_min); 134053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Projectstatic NJ_INT16 que_strcmp_include(NJ_CLASS *iwnn, NJ_DIC_HANDLE handle, NJ_UINT16 que_id, NJ_CHAR *yomi); 135053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 136053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#define GET_LEARN_MAX_WORD_COUNT(h) ((NJ_UINT16)NJ_INT32_READ((h) + POS_MAX_WORD)) 137053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 138053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#define GET_LEARN_WORD_COUNT(h) \ 139053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ((NJ_UINT16)NJ_INT32_READ((h) + POS_LEARN_WORD)) 140053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#define SET_LEARN_WORD_COUNT(h, n) \ 141053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_INT32_WRITE((h)+POS_LEARN_WORD, (NJ_UINT32)(n)) 142053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#define GET_LEARN_NEXT_WORD_POS(h) \ 143053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ((NJ_UINT16)NJ_INT32_READ((h) + POS_NEXT_QUE)) 144053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#define SET_LEARN_NEXT_WORD_POS(h, id) \ 145053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_INT32_WRITE((h)+POS_NEXT_QUE, (NJ_UINT32)(id)) 146053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#define QUE_SIZE(h) ((NJ_UINT16)NJ_INT32_READ((h) + POS_QUE_SIZE)) 147053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 148053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#define COPY_UINT16(dst,src) (*(NJ_UINT16 *)(dst) = *(NJ_UINT16 *)(src)) 149053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 150053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Projectstatic NJ_UINT8 *get_search_index_address(NJ_DIC_HANDLE handle, NJ_UINT8 search_pattern) { 151053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 152053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 153053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 154053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return LEARN_INDEX_TOP_ADDR(handle); 155053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project} 156053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 157053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source ProjectNJ_INT16 njd_l_search_word(NJ_CLASS *iwnn, NJ_SEARCH_CONDITION *con, 158053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_SEARCH_LOCATION_SET *loctset, 159053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT8 comp_flg) { 160053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 161053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 word_count; 162053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT32 type; 163053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_DIC_INFO *pdicinfo; 164053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 hIdx; 165053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_INT16 ret; 166053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 167053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 168053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project word_count = GET_LEARN_WORD_COUNT(loctset->loct.handle); 169053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (word_count == 0) { 170053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 171053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project loctset->loct.status = NJ_ST_SEARCH_END_EXT; 172053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return 0; 173053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 174053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 175053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project type = NJ_GET_DIC_TYPE_EX(loctset->loct.type, loctset->loct.handle); 176053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 177053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (type == NJ_DIC_TYPE_CUSTOM_INCOMPRESS) { 178053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if ((con->operation == NJ_CUR_OP_COMP) || 179053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project (con->operation == NJ_CUR_OP_FORE)){ 180053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 181053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (con->ylen > NJ_GET_MAX_YLEN(loctset->loct.handle)) { 182053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project loctset->loct.status = NJ_ST_SEARCH_END_EXT; 183053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return 0; 184053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 185053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 186053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 187053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 188053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 189053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project switch (con->operation) { 190053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project case NJ_CUR_OP_COMP: 191053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (con->mode != NJ_CUR_MODE_FREQ) { 192053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 193053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project loctset->loct.status = NJ_ST_SEARCH_END_EXT; 194053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project break; 195053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 196053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 197053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 198053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return get_cand_by_sequential(iwnn, con, loctset, con->operation, comp_flg); 199053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 200053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project case NJ_CUR_OP_FORE: 201053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 202053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (con->mode == NJ_CUR_MODE_YOMI) { 203053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 204053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return get_cand_by_sequential(iwnn, con, loctset, con->operation, 0); 205053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 206053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 207053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 208053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project pdicinfo = con->ds->dic; 209053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project for (hIdx = 0; (hIdx < NJ_MAX_DIC) && (pdicinfo->handle != loctset->loct.handle); hIdx++) { 210053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project pdicinfo++; 211053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 212053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 213053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (hIdx == NJ_MAX_DIC) { 214053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 215053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project loctset->loct.status = NJ_ST_SEARCH_END; 216053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return 0; 217053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 218053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 219053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 220053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 221053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if ((con->ds->dic[hIdx].srhCache == NULL) || (con->ylen == 0) || 222053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project !(con->ds->mode & 0x0001)) { 223053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return get_cand_by_evaluate(iwnn, con, loctset, con->operation); 224053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 225053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ret = get_cand_by_evaluate2(iwnn, con, loctset, con->operation, hIdx); 226053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (ret == NJ_SET_ERR_VAL(NJ_FUNC_SEARCH_RANGE_BY_YOMI, NJ_ERR_CACHE_NOT_ENOUGH)) { 227053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 228053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_SET_CACHEOVER_TO_SCACHE(con->ds->dic[hIdx].srhCache); 229053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ret = get_cand_by_evaluate2(iwnn, con, loctset, con->operation, hIdx); 230053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 231053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return ret; 232053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 233053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 234053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 235053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project case NJ_CUR_OP_LINK: 236053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 237053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (NJ_GET_DIC_TYPE_EX(loctset->loct.type, loctset->loct.handle) == NJ_DIC_TYPE_USER) { 238053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 239053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project loctset->loct.status = NJ_ST_SEARCH_END_EXT; 240053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project break; 241053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 242053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (con->mode != NJ_CUR_MODE_FREQ) { 243053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 244053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project loctset->loct.status = NJ_ST_SEARCH_END_EXT; 245053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project break; 246053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 247053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 248053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (comp_flg == 0) { 249053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 250053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return get_cand_by_sequential(iwnn, con, loctset, con->operation, 0); 251053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 252053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 253053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return get_cand_by_evaluate(iwnn, con, loctset, con->operation); 254053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 255053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 256053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project default: 257053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project loctset->loct.status = NJ_ST_SEARCH_END_EXT; 258053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 259053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 260053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return 0; 261053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project} 262053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 263053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Projectstatic NJ_WQUE *get_que_type_and_next(NJ_CLASS *iwnn, NJ_DIC_HANDLE handle, 264053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 que_id) { 265053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT8 *ptr; 266053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_WQUE *que = &(iwnn->que_tmp); 267053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 268053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 269053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (que_id >= GET_LEARN_MAX_WORD_COUNT(handle)) { 270053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NULL; 271053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 272053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 273053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ptr = POS_TO_ADDRESS(handle, que_id); 274053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 275053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que->type = GET_TYPE_FROM_DATA(ptr); 276053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que->next_flag = GET_FFLG_FROM_DATA(ptr); 277053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 278053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project switch (que->type) { 279053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project case QUE_TYPE_EMPTY: 280053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project case QUE_TYPE_JIRI: 281053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project case QUE_TYPE_FZK: 282053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return que; 283053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project default: 284053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project break; 285053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 286053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#ifdef LEARN_DEBUG 287053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project printf("FATAL : Illegal que was gotten (que_id=%d)\n", que_id); 288053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#endif 289053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NULL; 290053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project} 291053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 292053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Projectstatic NJ_WQUE *get_que_yomiLen_and_hyoukiLen(NJ_CLASS *iwnn, NJ_DIC_HANDLE handle, 293053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 que_id) { 294053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT8 *ptr; 295053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_WQUE *que = &(iwnn->que_tmp); 296053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 297053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 298053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (que_id >= GET_LEARN_MAX_WORD_COUNT(handle)) { 299053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NULL; 300053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 301053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 302053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ptr = POS_TO_ADDRESS(handle, que_id); 303053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 304053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que->type = GET_TYPE_FROM_DATA(ptr); 305053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que->yomi_byte = GET_YSIZE_FROM_DATA(ptr); 306053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que->yomi_len = que->yomi_byte / sizeof(NJ_CHAR); 307053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que->hyouki_byte = GET_KSIZE_FROM_DATA(ptr); 308053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que->hyouki_len = que->hyouki_byte / sizeof(NJ_CHAR); 309053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 310053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project switch (que->type) { 311053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project case QUE_TYPE_JIRI: 312053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project case QUE_TYPE_FZK: 313053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return que; 314053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project default: 315053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project break; 316053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 317053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#ifdef LEARN_DEBUG 318053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project printf("FATAL : Illegal que was gotten (que_id=%d)\n", que_id); 319053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#endif 320053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NULL; 321053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project} 322053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 323053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Projectstatic NJ_WQUE *get_que_allHinsi(NJ_CLASS *iwnn, NJ_DIC_HANDLE handle, 324053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 que_id) { 325053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT8 *ptr; 326053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_WQUE *que = &(iwnn->que_tmp); 327053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 328053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 329053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (que_id >= GET_LEARN_MAX_WORD_COUNT(handle)) { 330053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NULL; 331053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 332053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 333053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ptr = POS_TO_ADDRESS(handle, que_id); 334053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 335053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que->type = GET_TYPE_FROM_DATA(ptr); 336053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que->mae_hinsi = GET_FPOS_FROM_DATA(ptr); 337053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que->ato_hinsi = GET_BPOS_FROM_DATA(ptr); 338053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 339053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project switch (que->type) { 340053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project case QUE_TYPE_JIRI: 341053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project case QUE_TYPE_FZK: 342053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return que; 343053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project default: 344053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project break; 345053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 346053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#ifdef LEARN_DEBUG 347053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project printf("FATAL : Illegal que was gotten (que_id=%d)\n", que_id); 348053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#endif 349053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NULL; 350053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project} 351053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 352053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Projectstatic NJ_WQUE *get_que(NJ_CLASS *iwnn, NJ_DIC_HANDLE handle, NJ_UINT16 que_id) { 353053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT8 *ptr; 354053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_WQUE *que = &(iwnn->que_tmp); 355053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 356053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 357053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (que_id >= GET_LEARN_MAX_WORD_COUNT(handle)) { 358053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NULL; 359053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 360053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 361053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ptr = POS_TO_ADDRESS(handle, que_id); 362053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 363053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que->entry = que_id; 364053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que->type = GET_TYPE_FROM_DATA(ptr); 365053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que->mae_hinsi = GET_FPOS_FROM_DATA(ptr); 366053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que->ato_hinsi = GET_BPOS_FROM_DATA(ptr); 367053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que->yomi_byte = GET_YSIZE_FROM_DATA(ptr); 368053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que->yomi_len = que->yomi_byte / sizeof(NJ_CHAR); 369053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que->hyouki_byte= GET_KSIZE_FROM_DATA(ptr); 370053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que->hyouki_len = que->hyouki_byte / sizeof(NJ_CHAR); 371053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que->next_flag = GET_FFLG_FROM_DATA(ptr); 372053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 373053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project switch (que->type) { 374053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project case QUE_TYPE_JIRI: 375053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project case QUE_TYPE_FZK: 376053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return que; 377053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project default: 378053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project break; 379053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 380053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#ifdef LEARN_DEBUG 381053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project printf("FATAL : Illegal que was gotten (que_id=%d)\n", que_id); 382053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#endif 383053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NULL; 384053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project} 385053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 386053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Projectstatic NJ_INT16 is_continued(NJ_CLASS *iwnn, NJ_DIC_HANDLE handle, NJ_UINT16 que_id) { 387053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_WQUE *que; 388053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 i; 389053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 max, end; 390053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 391053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 392053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project max = GET_LEARN_MAX_WORD_COUNT(handle); 393053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project end = GET_LEARN_NEXT_WORD_POS(handle); 394053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 395053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project for (i = 0; i < max; i++) { 396053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que_id++; 397053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (que_id >= GET_LEARN_MAX_WORD_COUNT(handle)) { 398053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 399053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que_id = 0; 400053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 401053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 402053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 403053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (que_id == end) { 404053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 405053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return 0; 406053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 407053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 408053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que = get_que_type_and_next(iwnn, handle, que_id); 409053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#ifdef IWNN_ERR_CHECK 410053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (iwnn->err_check_flg == 1) { 411053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que = NULL; 412053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 413053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#endif 414053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (que == NULL) { 415053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NJ_SET_ERR_VAL(NJ_FUNC_IS_CONTINUED, NJ_ERR_DIC_BROKEN); 416053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 417053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (que->type != QUE_TYPE_EMPTY) { 418053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 419053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (que->next_flag != 0) { 420053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 421053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return 1; 422053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 423053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 424053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return 0; 425053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 426053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 427053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 428053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 429053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 430053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return 0; 431053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project} 432053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 433053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Projectstatic NJ_INT16 continue_cnt(NJ_CLASS *iwnn, NJ_DIC_HANDLE handle, NJ_UINT16 que_id) { 434053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_WQUE *que; 435053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 i; 436053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 max, end; 437053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_INT16 cnt = 0; 438053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 439053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 440053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project max = GET_LEARN_MAX_WORD_COUNT(handle); 441053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project end = GET_LEARN_NEXT_WORD_POS(handle); 442053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 443053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project for (i = 0; i < max; i++) { 444053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que_id++; 445053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (que_id >= max) { 446053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 447053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que_id = 0; 448053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 449053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 450053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 451053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (que_id == end) { 452053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 453053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return cnt; 454053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 455053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 456053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que = get_que_type_and_next(iwnn, handle, que_id); 457053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (que == NULL) { 458053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NJ_SET_ERR_VAL(NJ_FUNC_CONTINUE_CNT, NJ_ERR_DIC_BROKEN); 459053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 460053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (que->type != QUE_TYPE_EMPTY) { 461053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 462053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (que->next_flag != 0) { 463053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 464053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project cnt++; 465053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 466053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 467053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (cnt >= (NJD_MAX_CONNECT_CNT - 1)) { 468053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return cnt; 469053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 470053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 471053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 472053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return cnt; 473053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 474053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 475053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 476053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 477053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 478053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return 0; 479053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project} 480053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 481053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Projectstatic NJ_UINT16 search_next_que(NJ_DIC_HANDLE handle, NJ_UINT16 que_id) { 482053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 max; 483053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 i; 484053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 485053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 486053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project max = GET_LEARN_MAX_WORD_COUNT(handle); 487053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 488053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project for (i = 0; i < max; i++) { 489053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que_id++; 490053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (que_id >= max) { 491053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 492053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que_id = 0; 493053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 494053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 495053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (GET_TYPE_FROM_DATA(POS_TO_ADDRESS(handle, que_id)) != QUE_TYPE_EMPTY) { 496053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 497053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return que_id; 498053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 499053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 500053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 501053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 502053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return 0; 503053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project} 504053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 505053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Projectstatic NJ_INT16 que_strcmp_complete_with_hyouki(NJ_CLASS *iwnn, NJ_DIC_HANDLE handle, 506053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 que_id, NJ_CHAR *yomi, NJ_UINT16 yomi_len, NJ_CHAR *hyouki, 507053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT8 multi_flg) { 508053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_CHAR *str; 509053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_INT16 ret; 510053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT8 slen; 511053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 hyouki_len; 512053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 que_yomilen, que_hyoukilen; 513053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_INT16 que_count = 1; 514053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_INT16 cnt = 0; 515053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 516053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 517053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 518053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project hyouki_len = nj_strlen(hyouki); 519053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 520053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (multi_flg == 0) { 521053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 522053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project cnt = 1; 523053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 524053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 525053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 526053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project cnt = GET_LEARN_WORD_COUNT(handle); 527053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 528053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 529053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project while (cnt--) { 530053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project str = get_string(iwnn, handle, que_id, &slen); 531053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (str == NULL) { 532053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NJ_SET_ERR_VAL(NJ_FUNC_QUE_STRCMP_COMPLETE_WITH_HYOUKI, 533053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_ERR_DIC_BROKEN); 534053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 535053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que_yomilen = slen; 536053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 537053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ret = nj_strncmp(yomi, str, que_yomilen); 538053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (ret != 0) { 539053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 540053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return 0; 541053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 542053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 543053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project str = get_hyouki(iwnn, handle, que_id, &slen); 544053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (str == NULL) { 545053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NJ_SET_ERR_VAL(NJ_FUNC_QUE_STRCMP_COMPLETE_WITH_HYOUKI, 546053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_ERR_DIC_BROKEN); 547053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 548053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que_hyoukilen = slen; 549053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 550053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ret = nj_strncmp(hyouki, str, que_hyoukilen); 551053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (ret != 0) { 552053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 553053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return 0; 554053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 555053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 556053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if ((yomi_len == que_yomilen) && 557053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project (hyouki_len == que_hyoukilen)) { 558053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 559053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return que_count; 560053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 561053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 562053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if ((que_yomilen > yomi_len) || 563053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project (que_hyoukilen > hyouki_len)) { 564053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 565053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return 0; 566053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 567053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 568053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ret = is_continued(iwnn, handle, que_id); 569053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (ret <= 0) { 570053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 571053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return ret; 572053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 573053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 574053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 575053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (que_count >= (NJD_MAX_CONNECT_CNT - 1)) { 576053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 577053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return 0; 578053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 579053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 580053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project yomi_len -= que_yomilen; 581053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project yomi += que_yomilen; 582053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 583053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project hyouki_len -= que_hyoukilen; 584053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project hyouki += que_hyoukilen; 585053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 586053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 587053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que_id = search_next_que(handle, que_id); 588053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que_count++; 589053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 590053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return 0; 591053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project} 592053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 593053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Projectstatic NJ_INT16 que_strcmp_include(NJ_CLASS *iwnn, NJ_DIC_HANDLE handle, 594053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 que_id, NJ_CHAR *yomi) { 595053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_CHAR *str; 596053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 que_len; 597053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 yomi_len; 598053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_INT16 ret; 599053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_INT16 que_count = 1; 600053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 i = 0; 601053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT8 slen; 602053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 603053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 604053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#ifdef LEARN_DEBUG 605053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project printf("que_strcmp_include(que_id=%d, yomi=[%s])\n", que_id, yomi); 606053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#endif 607053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project yomi_len = nj_strlen(yomi); 608053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (yomi_len == 0) { 609053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return que_count; 610053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 611053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 612053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project i = GET_LEARN_WORD_COUNT(handle); 613053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 614053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project while (--i) { 615053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 616053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 617053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ret = is_continued(iwnn, handle, que_id); 618053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (ret < 0) { 619053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 620053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return ret; 621053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else if (ret == 0) { 622053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 623053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return que_count; 624053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 625053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 626053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 627053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que_id = search_next_que(handle, que_id); 628053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 629053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project str = get_string(iwnn, handle, que_id, &slen); 630053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#ifdef IWNN_ERR_CHECK 631053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (iwnn->err_check_flg == 2) { 632053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project str = NULL; 633053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 634053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#endif 635053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (str == NULL) { 636053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NJ_SET_ERR_VAL(NJ_FUNC_QUE_STRCMP_INCLUDE, NJ_ERR_DIC_BROKEN); 637053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 638053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que_len = slen; 639053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 640053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 641053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (que_len > yomi_len) { 642053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#ifdef LEARN_DEBUG 643053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project printf(" >> mismatch [%s] (que_len > yomi_len)\n", str); 644053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#endif 645053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return que_count; 646053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 647053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 648053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 649053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ret = nj_strncmp(yomi, str, que_len); 650053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (ret != 0) { 651053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#ifdef LEARN_DEBUG 652053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project printf(" >> mismatch [%s]\n", str); 653053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#endif 654053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 655053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return que_count; 656053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 657053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 658053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 659053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (que_len == yomi_len) { 660053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#ifdef LEARN_DEBUG 661053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project printf(" >> match! [%s](%d)\n", str, que_count); 662053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#endif 663053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return (que_count + 1); 664053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 665053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 666053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que_count++; 667053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (que_count >= NJD_MAX_CONNECT_CNT) { 668053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 669053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return que_count; 670053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 671053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 672053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 673053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project yomi_len -= que_len; 674053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project yomi += que_len; 675053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 676053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 677053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return que_count; 678053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project} 679053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 680053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Projectstatic NJ_CHAR *get_string(NJ_CLASS *iwnn, NJ_DIC_HANDLE handle, 681053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 que_id, NJ_UINT8 *slen) { 682053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT8 *src, *dst; 683053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT8 copy_size, size; 684053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT8 i; 685053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT8 *top_addr; 686053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT8 *bottom_addr; 687053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 que_size; 688053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 689053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 690053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project src = POS_TO_ADDRESS(handle, que_id); 691053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project switch (GET_TYPE_FROM_DATA(src)) { 692053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project case QUE_TYPE_JIRI: 693053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project case QUE_TYPE_FZK: 694053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project size = GET_YSIZE_FROM_DATA(src); 695053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project *slen = (NJ_UINT8)(size / sizeof(NJ_CHAR)); 696053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project break; 697053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 698053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project default: 699053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#ifdef LEARN_DEBUG 700053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project printf("get_string(handle=%p, que_id=%d) : broken que\n", handle, que_id); 701053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#endif 702053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NULL; 703053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 704053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 705053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (NJ_GET_DIC_TYPE(handle) == NJ_DIC_TYPE_USER) { 706053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (*slen > NJ_MAX_USER_LEN) { 707053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NULL; 708053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 709053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 710053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (*slen > NJ_MAX_LEN) { 711053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NULL; 712053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 713053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 714053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 715053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 716053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project src += LEARN_QUE_STRING_OFFSET; 717053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 718053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que_size = QUE_SIZE(handle); 719053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 720053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 721053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project copy_size = (NJ_UINT8)que_size - LEARN_QUE_STRING_OFFSET; 722053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project dst = (NJ_UINT8*)&(iwnn->learn_string_tmp[0]); 723053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (copy_size > size) { 724053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 725053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project copy_size = size; 726053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 727053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project for (i = 0; i < copy_size; i++) { 728053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project *dst++ = *src++; 729053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 730053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 731053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 732053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project top_addr = LEARN_DATA_TOP_ADDR(handle); 733053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project bottom_addr = top_addr; 734053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project bottom_addr += que_size * GET_LEARN_MAX_WORD_COUNT(handle) - 1; 735053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 736053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project while (size -= copy_size) { 737053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 738053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (src >= bottom_addr) { 739053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project src = top_addr; 740053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 741053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 742053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 743053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (*src != QUE_TYPE_NEXT) { 744053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#ifdef LEARN_DEBUG 745053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project printf("FATAL: src que was broken(not QUE_TYPE_NEXT) [src=%x]\n", src); 746053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#endif 747053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NULL; 748053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 749053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 750053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project src++; 751053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (size < que_size) { 752053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 753053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project copy_size = size; 754053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 755053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project copy_size = (NJ_UINT8)(que_size - 1); 756053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 757053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project for (i = 0; i < copy_size; i++) { 758053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project *dst++ = *src++; 759053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 760053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 761053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project iwnn->learn_string_tmp[*slen] = NJ_CHAR_NUL; 762053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 763053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return &(iwnn->learn_string_tmp[0]); 764053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project} 765053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 766053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Projectstatic NJ_CHAR *get_hyouki(NJ_CLASS *iwnn, NJ_DIC_HANDLE handle, 767053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 que_id, NJ_UINT8 *slen) { 768053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT8 *src, *dst; 769053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_WQUE *que; 770053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT8 copy_size, size; 771053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT8 i; 772053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT8 *top_addr; 773053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT8 *bottom_addr; 774053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_CHAR *hira; 775053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 que_size; 776053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT32 dictype; 777053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 778053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 779053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que = get_que_yomiLen_and_hyoukiLen(iwnn, handle, que_id); 780053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (que == NULL) { 781053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NULL; 782053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 783053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 784053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project dictype = NJ_GET_DIC_TYPE(handle); 785053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (dictype == NJ_DIC_TYPE_USER) { 786053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (que->yomi_len > NJ_MAX_USER_LEN) { 787053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NULL; 788053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 789053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (que->hyouki_len > NJ_MAX_USER_KOUHO_LEN) { 790053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NULL; 791053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 792053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 793053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (que->yomi_len > NJ_MAX_LEN) { 794053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NULL; 795053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 796053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (que->hyouki_len > NJ_MAX_RESULT_LEN) { 797053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NULL; 798053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 799053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 800053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 801053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project src = POS_TO_ADDRESS(handle, que_id); 802053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 803053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (que->hyouki_len == 0) { 804053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project hira = get_string(iwnn, handle, que_id, slen); 805053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (hira == NULL) { 806053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NULL; 807053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 808053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 809053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (GET_MFLG_FROM_DATA(src) != 0) { 810053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project *slen = (NJ_UINT8)nje_convert_hira_to_kata(hira, &(iwnn->muhenkan_tmp[0]), *slen); 811053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return &(iwnn->muhenkan_tmp[0]); 812053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 813053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return hira; 814053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 815053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 816053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 817053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project src += LEARN_QUE_STRING_OFFSET; 818053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 819053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que_size = QUE_SIZE(handle); 820053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 821053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 822053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project size = que->yomi_byte; 823053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project copy_size = (NJ_UINT8)que_size - LEARN_QUE_STRING_OFFSET; 824053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project dst = (NJ_UINT8*)&(iwnn->learn_string_tmp[0]); 825053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (copy_size > size) { 826053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 827053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project copy_size = size; 828053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 829053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 830053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 831053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project top_addr = LEARN_DATA_TOP_ADDR(handle); 832053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project bottom_addr = top_addr; 833053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project bottom_addr += que_size * GET_LEARN_MAX_WORD_COUNT(handle) - 1; 834053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 835053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project src += copy_size; 836053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project while (size -= copy_size) { 837053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 838053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 839053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (src >= bottom_addr) { 840053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project src = top_addr; 841053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 842053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 843053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 844053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (*src != QUE_TYPE_NEXT) { 845053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#ifdef LEARN_DEBUG 846053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project printf("FATAL: src que was broken(not QUE_TYPE_NEXT) [src=%x]\n", src); 847053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#endif 848053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NULL; 849053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 850053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 851053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project src++; 852053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (size < que_size) { 853053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 854053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project copy_size = size; 855053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 856053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project copy_size = (NJ_UINT8)(que_size - 1); 857053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 858053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project src += copy_size; 859053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 860053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 861053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 862053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 863053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (((src - top_addr) % que_size) == 0) { 864053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 865053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (src >= bottom_addr) { 866053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project src = top_addr; 867053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 868053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 869053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (*src++ != QUE_TYPE_NEXT) { 870053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#ifdef LEARN_DEBUG 871053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project printf("FATAL: src que was broken(QUE_TYPE_NEXT) [src=%x]\n", src - 1); 872053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#endif 873053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NULL; 874053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 875053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 876053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 877053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project size = que->hyouki_byte; 878053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 879053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 880053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project copy_size = (NJ_UINT8)(que_size); 881053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project copy_size -= (NJ_UINT8)((src - top_addr) % que_size); 882053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (copy_size > size) { 883053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 884053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project copy_size = size; 885053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 886053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project for (i = 0; i < copy_size; i++) { 887053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project *dst++ = *src++; 888053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 889053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 890053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project while (size -= copy_size) { 891053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 892053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 893053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (src >= bottom_addr) { 894053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project src = top_addr; 895053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 896053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 897053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 898053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (*src != QUE_TYPE_NEXT) { 899053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#ifdef LEARN_DEBUG 900053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project printf("FATAL: src que was broken(not QUE_TYPE_NEXT) [src=%x]\n", src); 901053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#endif 902053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NULL; 903053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 904053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 905053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project src++; 906053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (size < que_size) { 907053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 908053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project copy_size = size; 909053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 910053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project copy_size = (NJ_UINT8)(que_size - 1); 911053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 912053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 913053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project for (i = 0; i < copy_size; i++) { 914053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project *dst++ = *src++; 915053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 916053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 917053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 918053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project *slen = que->hyouki_len; 919053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project iwnn->learn_string_tmp[*slen] = NJ_CHAR_NUL; 920053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 921053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return &(iwnn->learn_string_tmp[0]); 922053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project} 923053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 924053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Projectstatic NJ_INT16 get_cand_by_sequential(NJ_CLASS *iwnn, NJ_SEARCH_CONDITION *cond, 925053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_SEARCH_LOCATION_SET *loctset, NJ_UINT8 search_pattern, 926053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT8 comp_flg) { 927053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 current, from, to; 928053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 que_id; 929053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT8 *ptr, *p; 930053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_INT16 ret, num_count; 931053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_CHAR *yomi; 932053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_WQUE *que; 933053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT8 forward_flag = 0; 934053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 935053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 936053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 937053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (GET_LOCATION_STATUS(loctset->loct.status) == NJ_ST_SEARCH_NO_INIT) { 938053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 939053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ret = search_range_by_yomi(iwnn, loctset->loct.handle, search_pattern, 940053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project cond->yomi, cond->ylen, &from, &to, &forward_flag); 941053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (ret < 0) { 942053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return ret; 943053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 944053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (ret == 0) { 945053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (forward_flag) { 946053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project loctset->loct.status = NJ_ST_SEARCH_END; 947053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 948053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project loctset->loct.status = NJ_ST_SEARCH_END_EXT; 949053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 950053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return 0; 951053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 952053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project loctset->loct.top = from; 953053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project loctset->loct.bottom = to; 954053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project current = from; 955053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else if (GET_LOCATION_STATUS(loctset->loct.status) == NJ_ST_SEARCH_READY) { 956053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 957053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project current = (NJ_UINT16)(loctset->loct.current + 1); 958053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 959053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project loctset->loct.status = NJ_ST_SEARCH_END; 960053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return 0; 961053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 962053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 963053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 964053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ptr = get_search_index_address(loctset->loct.handle, cond->operation); 965053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project p = ptr + (current * NJ_INDEX_SIZE); 966053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 967053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project while (current <= loctset->loct.bottom) { 968053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que_id = GET_UINT16(p); 969053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (search_pattern == NJ_CUR_OP_COMP) { 970053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 971053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ret = str_que_cmp(iwnn, loctset->loct.handle, cond->yomi, cond->ylen, que_id, 1); 972053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 973053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 974053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (ret == 2) { 975053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ret = 0; 976053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 977053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else if (search_pattern == NJ_CUR_OP_FORE) { 978053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 979053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ret = str_que_cmp(iwnn, loctset->loct.handle, cond->yomi, cond->ylen, que_id, 2); 980053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 981053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 982053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (ret == 2) { 983053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ret = 0; 984053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 985053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 986053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 987053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 988053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 989053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ret = que_strcmp_complete_with_hyouki(iwnn, loctset->loct.handle, que_id, 990053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project cond->yomi, cond->ylen, cond->kanji, 0); 991053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 992053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 993053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (ret < 0) { 994053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return ret; 995053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 996053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (ret > 0) { 997053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (search_pattern == NJ_CUR_OP_LINK) { 998053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 999053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1000053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project num_count = continue_cnt(iwnn, loctset->loct.handle, que_id); 1001053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (num_count < 0) { 1002053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1003053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return num_count; 1004053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1005053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1006053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1007053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (num_count >= ret) { 1008053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1009053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project loctset->loct.current_info = (NJ_UINT8)(((num_count + 1) << 4) | ret); 1010053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project loctset->loct.current = current; 1011053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project loctset->loct.status = NJ_ST_SEARCH_READY; 1012053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project loctset->cache_freq = get_hindo(iwnn, loctset, search_pattern); 1013053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return 1; 1014053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1015053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 1016053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1017053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1018053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1019053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1020053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1021053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1022053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que = get_que_allHinsi(iwnn, loctset->loct.handle, que_id); 1023053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (njd_connect_test(cond, que->mae_hinsi, que->ato_hinsi)) { 1024053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1025053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1026053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project switch (NJ_GET_DIC_TYPE_EX(loctset->loct.type, loctset->loct.handle)) { 1027053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project case NJ_DIC_TYPE_CUSTOM_INCOMPRESS: 1028053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if ((search_pattern == NJ_CUR_OP_COMP) && (comp_flg == 1)) { 1029053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project yomi = cond->yomi + cond->ylen; 1030053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ret = que_strcmp_include(iwnn, loctset->loct.handle, que_id, yomi); 1031053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (ret < 0) { 1032053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return ret; 1033053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1034053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1035053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project break; 1036053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project default: 1037053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project break; 1038053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1039053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project loctset->loct.current = current; 1040053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project loctset->loct.status = NJ_ST_SEARCH_READY; 1041053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1042053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project loctset->loct.current_info = (ret & 0x0f) << 4; 1043053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project loctset->cache_freq = get_hindo(iwnn, loctset, search_pattern); 1044053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return 1; 1045053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1046053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1047053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1048053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project p += NJ_INDEX_SIZE; 1049053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project current++; 1050053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1051053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1052053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1053053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project loctset->loct.status = NJ_ST_SEARCH_END; 1054053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return 0; 1055053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project} 1056053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1057053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Projectstatic NJ_INT16 get_cand_by_evaluate(NJ_CLASS *iwnn, NJ_SEARCH_CONDITION *cond, 1058053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_SEARCH_LOCATION_SET *loctset, NJ_UINT8 search_pattern) { 1059053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 from, to, i; 1060053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 que_id, oldest; 1061053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT32 max_value, eval, current; 1062053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT8 *ptr, *p; 1063053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_WQUE *que; 1064053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_INT16 ret, num_count; 1065053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_INT32 found = 0; 1066053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT8 forward_flag = 0; 1067053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_INT32 is_first_search, is_better_freq; 1068053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1069053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1070053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1071053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ptr = get_search_index_address(loctset->loct.handle, cond->operation); 1072053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1073053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1074053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project oldest = GET_LEARN_NEXT_WORD_POS(loctset->loct.handle); 1075053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1076053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1077053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project current = 0; 1078053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (GET_LOCATION_STATUS(loctset->loct.status) == NJ_ST_SEARCH_NO_INIT) { 1079053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (search_pattern == NJ_CUR_OP_LINK) { 1080053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1081053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1082053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1083053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ret = search_range_by_yomi_multi(iwnn, loctset->loct.handle, 1084053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project cond->yomi, cond->ylen, &from, &to); 1085053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 1086053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1087053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1088053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ret = search_range_by_yomi(iwnn, loctset->loct.handle, search_pattern, 1089053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project cond->yomi, cond->ylen, &from, &to, &forward_flag); 1090053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1091053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (ret <= 0) { 1092053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project loctset->loct.status = NJ_ST_SEARCH_END; 1093053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return ret; 1094053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1095053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project loctset->loct.top = from; 1096053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project loctset->loct.bottom = to; 1097053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project is_first_search = 1; 1098053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else if (GET_LOCATION_STATUS(loctset->loct.status) == NJ_ST_SEARCH_READY) { 1099053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project current = GET_UINT16(ptr + (loctset->loct.current * NJ_INDEX_SIZE)); 1100053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (current < oldest) { 1101053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project current += GET_LEARN_MAX_WORD_COUNT(loctset->loct.handle); 1102053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1103053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project is_first_search = 0; 1104053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 1105053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project loctset->loct.status = NJ_ST_SEARCH_END; 1106053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return 0; 1107053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1108053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1109053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1110053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project max_value = oldest; 1111053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1112053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project p = ptr + (loctset->loct.top * NJ_INDEX_SIZE); 1113053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project eval = current; 1114053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project for (i = (NJ_UINT16)loctset->loct.top; i <= (NJ_UINT16)loctset->loct.bottom; i++) { 1115053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que_id = GET_UINT16(p); 1116053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (que_id < oldest) { 1117053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project eval = que_id + GET_LEARN_MAX_WORD_COUNT(loctset->loct.handle); 1118053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 1119053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project eval = que_id; 1120053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1121053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#ifdef LEARN_DEBUG 1122053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project printf("que(%d) : eval = %d\n", que_id, eval); 1123053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#endif 1124053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project is_better_freq = ((eval >= max_value) && ((is_first_search) || (eval < current))) ? 1 : 0; 1125053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1126053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (is_better_freq) { 1127053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1128053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (search_pattern == NJ_CUR_OP_LINK) { 1129053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1130053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ret = que_strcmp_complete_with_hyouki(iwnn, loctset->loct.handle, que_id, 1131053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project cond->yomi, cond->ylen, cond->kanji, 1); 1132053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 1133053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1134053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ret = str_que_cmp(iwnn, loctset->loct.handle, cond->yomi, cond->ylen, que_id, 2); 1135053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1136053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (ret == 2) { 1137053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ret = 0; 1138053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1139053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1140053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (ret < 0) { 1141053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return ret; 1142053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1143053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (ret >= 1) { 1144053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (search_pattern == NJ_CUR_OP_LINK) { 1145053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1146053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1147053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project num_count = continue_cnt(iwnn, loctset->loct.handle, que_id); 1148053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (num_count < 0) { 1149053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1150053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return num_count; 1151053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1152053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1153053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1154053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (num_count >= ret) { 1155053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1156053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project loctset->loct.current_info = (NJ_UINT8)(((num_count + 1) << 4) | ret); 1157053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project loctset->loct.current = i; 1158053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project max_value = eval; 1159053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project found = 1; 1160053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1161053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 1162053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1163053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1164053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1165053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1166053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1167053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que = get_que_allHinsi(iwnn, loctset->loct.handle, que_id); 1168053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (njd_connect_test(cond, que->mae_hinsi, que->ato_hinsi)) { 1169053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1170053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project loctset->loct.current_info = (NJ_UINT8)0x10; 1171053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project loctset->loct.current = i; 1172053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project max_value = eval; 1173053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project found = 1; 1174053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#ifdef LEARN_DEBUG 1175053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project printf("---keep."); 1176053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#endif 1177053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1178053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1179053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1180053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1181053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project p += NJ_INDEX_SIZE; 1182053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1183053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1184053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1185053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (found == 0) { 1186053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project loctset->loct.status = NJ_ST_SEARCH_END; 1187053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return 0; 1188053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 1189053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project loctset->loct.status = NJ_ST_SEARCH_READY; 1190053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project loctset->cache_freq = get_hindo(iwnn, loctset, search_pattern); 1191053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return 1; 1192053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1193053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1194053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project} 1195053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1196053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Projectstatic NJ_INT16 search_range_by_yomi(NJ_CLASS *iwnn, NJ_DIC_HANDLE handle, NJ_UINT8 op, 1197053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_CHAR *yomi, NJ_UINT16 len, NJ_UINT16 *from, NJ_UINT16 *to, 1198053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT8 *forward_flag) { 1199053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 right, mid = 0, left, max; 1200053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 que_id; 1201053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT8 *ptr, *p; 1202053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_CHAR *str; 1203053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_INT16 ret = 0; 1204053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_INT32 found = 0; 1205053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT8 slen; 1206053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_INT32 cmp; 1207053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1208053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1209053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1210053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ptr = get_search_index_address(handle, op); 1211053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1212053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project max = GET_LEARN_WORD_COUNT(handle); 1213053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1214053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project right = max - 1; 1215053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project left = 0; 1216053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1217053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#ifdef LEARN_DEBUG 1218053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project printf("src:[%s]\n", yomi); 1219053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#endif 1220053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1221053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project *forward_flag = 0; 1222053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1223053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1224053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project switch (op) { 1225053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project case NJ_CUR_OP_COMP: 1226053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project case NJ_CUR_OP_LINK: 1227053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project case NJ_CUR_OP_FORE: 1228053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1229053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1230053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1231053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project break; 1232053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project default: 1233053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NJ_SET_ERR_VAL(NJ_FUNC_SEARCH_RANGE_BY_YOMI, NJ_ERR_PARAM_OPERATION); 1234053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1235053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1236053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project while (left <= right) { 1237053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project mid = left + ((right - left) / 2); 1238053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project p = ptr + (mid * NJ_INDEX_SIZE); 1239053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que_id = GET_UINT16(p); 1240053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project str = get_string(iwnn, handle, que_id, &slen); 1241053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1242053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#ifdef IWNN_ERR_CHECK 1243053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (iwnn->err_check_flg == 3) { 1244053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project str = NULL; 1245053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1246053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#endif 1247053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (str == NULL) { 1248053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NJ_SET_ERR_VAL(NJ_FUNC_SEARCH_RANGE_BY_YOMI, NJ_ERR_DIC_BROKEN); 1249053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1250053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1251053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ret = nj_strncmp(yomi, str, len); 1252053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (op != NJ_CUR_OP_FORE) { 1253053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1254053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1255053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (ret == 0) { 1256053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if ((*forward_flag == 0) && (len <= (NJ_UINT16)slen)) { 1257053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1258053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project *forward_flag = 1; 1259053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1260053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (len > (NJ_UINT16)slen) { 1261053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ret = 1; 1262053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else if (len < (NJ_UINT16)slen) { 1263053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ret = -1; 1264053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1265053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1266053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1267053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#ifdef LEARN_DEBUG 1268053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project printf(" [%d][%d][%d]COMPARE:[%s] = %d\n", left, mid, right, str, ret); 1269053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#endif 1270053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (ret == 0) { 1271053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1272053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project found = 1; 1273053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project break; 1274053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else if (ret < 0) { 1275053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1276053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project right = mid - 1; 1277053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (mid == 0) { 1278053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project break; 1279053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1280053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 1281053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1282053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project left = mid + 1; 1283053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1284053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1285053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1286053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (!found) { 1287053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return 0; 1288053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1289053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1290053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (mid == 0) { 1291053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project *from = mid; 1292053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 1293053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1294053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project p = ((mid - 1) * NJ_INDEX_SIZE) + ptr; 1295053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1296053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project for (cmp = mid - 1; cmp >= 0; cmp--) { 1297053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que_id = GET_UINT16(p); 1298053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project str = get_string(iwnn, handle, que_id, &slen); 1299053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1300053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#ifdef IWNN_ERR_CHECK 1301053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (iwnn->err_check_flg == 4) { 1302053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project str = NULL; 1303053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1304053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#endif 1305053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (str == NULL) { 1306053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NJ_SET_ERR_VAL(NJ_FUNC_SEARCH_RANGE_BY_YOMI, NJ_ERR_DIC_BROKEN); 1307053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1308053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1309053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (op != NJ_CUR_OP_FORE) { 1310053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ret = nj_strncmp(yomi, str, len); 1311053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (ret == 0) { 1312053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (len > (NJ_UINT16)slen) { 1313053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ret = 1; 1314053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else if (len < (NJ_UINT16)slen) { 1315053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ret = -1; 1316053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1317053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1318053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (ret > 0) { 1319053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1320053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project break; 1321053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1322053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 1323053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1324053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (nj_strncmp(yomi, str, len) != 0) { 1325053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project break; 1326053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1327053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1328053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project p -= NJ_INDEX_SIZE; 1329053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1330053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (cmp < 0) { 1331053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project *from = 0; 1332053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 1333053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project *from = (NJ_UINT16)cmp + 1; 1334053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1335053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1336053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1337053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#ifdef LEARN_DEBUG 1338053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project printf(" >> from:(%d)\n", *from); 1339053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#endif 1340053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1341053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#ifdef IWNN_ERR_CHECK 1342053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (iwnn->err_check_flg == 5) { 1343053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project mid = max - 2; 1344053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1345053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#endif 1346053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if ((mid + 1) >= max) { 1347053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project *to = mid; 1348053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 1349053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1350053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project p = ((mid + 1) * NJ_INDEX_SIZE) + ptr; 1351053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1352053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project for (right = mid + 1; right < max; right++) { 1353053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que_id = GET_UINT16(p); 1354053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project str = get_string(iwnn, handle, que_id, &slen); 1355053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1356053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#ifdef IWNN_ERR_CHECK 1357053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (iwnn->err_check_flg == 5) { 1358053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project str = NULL; 1359053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1360053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#endif 1361053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (str == NULL) { 1362053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NJ_SET_ERR_VAL(NJ_FUNC_SEARCH_RANGE_BY_YOMI, NJ_ERR_DIC_BROKEN); 1363053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1364053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1365053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (op != NJ_CUR_OP_FORE) { 1366053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ret = nj_strncmp(yomi, str, len); 1367053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (ret == 0) { 1368053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (len > (NJ_UINT16)slen) { 1369053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ret = 1; 1370053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else if (len < (NJ_UINT16)slen) { 1371053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ret = -1; 1372053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1373053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1374053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (ret < 0) { 1375053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1376053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project break; 1377053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1378053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 1379053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1380053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (nj_strncmp(yomi, str, len) != 0) { 1381053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project break; 1382053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1383053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1384053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project p += NJ_INDEX_SIZE; 1385053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1386053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project *to = right - 1; 1387053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1388053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1389053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#ifdef LEARN_DEBUG 1390053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project printf(" >> to:(%d)\n", *to); 1391053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#endif 1392053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return 1; 1393053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project} 1394053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1395053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Projectstatic NJ_INT16 search_range_by_yomi_multi(NJ_CLASS *iwnn, NJ_DIC_HANDLE handle, 1396053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_CHAR *yomi, NJ_UINT16 len, NJ_UINT16 *from, NJ_UINT16 *to) { 1397053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 right, mid = 0, left, max = 0; 1398053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 que_id; 1399053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT8 *ptr, *p; 1400053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_INT16 ret = 0; 1401053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 comp_len; 1402053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 i, char_len; 1403053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_INT32 found = 0; 1404053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_INT32 cmp; 1405053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_CHAR comp_yomi[NJ_MAX_LEN + NJ_TERM_LEN]; 1406053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_CHAR *pYomi; 1407053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1408053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1409053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1410053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1411053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ptr = LEARN_INDEX_TOP_ADDR(handle); 1412053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1413053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1414053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project max = GET_LEARN_WORD_COUNT(handle); 1415053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1416053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#ifdef LEARN_DEBUG 1417053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project printf("src:[%s]\n", yomi); 1418053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#endif 1419053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1420053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project comp_len = 0; 1421053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project pYomi = &yomi[0]; 1422053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project while (comp_len < len) { 1423053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1424053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1425053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project char_len = NJ_CHAR_LEN(pYomi); 1426053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project for (i = 0; i < char_len; i++) { 1427053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project *(comp_yomi + comp_len) = *pYomi; 1428053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project comp_len++; 1429053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project pYomi++; 1430053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1431053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project *(comp_yomi + comp_len) = NJ_CHAR_NUL; 1432053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1433053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project right = max - 1; 1434053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project left = 0; 1435053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project while (left <= right) { 1436053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project mid = left + ((right - left) / 2); 1437053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project p = ptr + (mid * NJ_INDEX_SIZE); 1438053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que_id = GET_UINT16(p); 1439053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1440053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1441053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ret = str_que_cmp(iwnn, handle, comp_yomi, comp_len, que_id, 1); 1442053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (ret < 0) { 1443053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NJ_SET_ERR_VAL(NJ_FUNC_SEARCH_RANGE_BY_YOMI_MULTI, NJ_ERR_DIC_BROKEN); 1444053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1445053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1446053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#ifdef LEARN_DEBUG 1447053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project printf(" [%d][%d][%d]COMPARE:[%s] = %d\n", left, mid, right, str, ret); 1448053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#endif 1449053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (ret == 1) { 1450053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1451053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project found = 1; 1452053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project break; 1453053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else if (ret == 0) { 1454053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1455053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project right = mid - 1; 1456053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (mid == 0) { 1457053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project break; 1458053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1459053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 1460053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1461053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project left = mid + 1; 1462053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1463053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1464053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1465053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (found) { 1466053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project break; 1467053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1468053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1469053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1470053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (!found) { 1471053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1472053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return 0; 1473053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1474053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1475053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1476053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (mid == 0) { 1477053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project *from = mid; 1478053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 1479053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1480053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project p = ((mid - 1) * NJ_INDEX_SIZE) + ptr; 1481053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1482053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project for (cmp = mid - 1; cmp >= 0; cmp--) { 1483053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que_id = GET_UINT16(p); 1484053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ret = str_que_cmp(iwnn, handle, comp_yomi, comp_len, que_id, 1); 1485053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (ret < 0) { 1486053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NJ_SET_ERR_VAL(NJ_FUNC_SEARCH_RANGE_BY_YOMI_MULTI, NJ_ERR_DIC_BROKEN); 1487053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1488053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (ret == 2) { 1489053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project break; 1490053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1491053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project p -= NJ_INDEX_SIZE; 1492053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1493053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (cmp < 0) { 1494053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project *from = 0; 1495053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 1496053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project *from = (NJ_UINT16)cmp + 1; 1497053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1498053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1499053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1500053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#ifdef LEARN_DEBUG 1501053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project printf(" >> from:(%d)\n", *from); 1502053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#endif 1503053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1504053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1505053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if ((mid + 1) >= max) { 1506053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project *to = mid; 1507053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 1508053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1509053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project p = ((mid + 1) * NJ_INDEX_SIZE) + ptr; 1510053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1511053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project for (right = mid + 1; right < max; right++) { 1512053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que_id = GET_UINT16(p); 1513053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ret = str_que_cmp(iwnn, handle, yomi, len, que_id, 1); 1514053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (ret < 0) { 1515053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NJ_SET_ERR_VAL(NJ_FUNC_SEARCH_RANGE_BY_YOMI_MULTI, NJ_ERR_DIC_BROKEN); 1516053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1517053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (ret == 0) { 1518053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project break; 1519053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1520053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project p += NJ_INDEX_SIZE; 1521053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1522053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project *to = right - 1; 1523053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1524053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1525053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#ifdef LEARN_DEBUG 1526053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project printf(" >> to:(%d)\n", *to); 1527053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#endif 1528053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return 1; 1529053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project} 1530053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1531053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Projectstatic NJ_INT16 str_que_cmp(NJ_CLASS *iwnn, NJ_DIC_HANDLE handle, NJ_CHAR *yomi, 1532053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 yomiLen, NJ_UINT16 que_id, NJ_UINT8 mode) { 1533053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT8 *queYomi; 1534053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT8 *yomiPtr; 1535053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 yomiByte; 1536053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 yomiPos; 1537053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT8 queYomiByte, queKouhoByte; 1538053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT8 queYomiPos, queYomiSearchArea; 1539053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_INT16 complete; 1540053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT8 *top_addr; 1541053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT8 *bottom_addr; 1542053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 que_size; 1543053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1544053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1545053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#ifdef IWNN_ERR_CHECK 1546053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (iwnn->err_check_flg == 6) { 1547053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que_id = GET_LEARN_MAX_WORD_COUNT(handle); 1548053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1549053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#endif 1550053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (que_id >= GET_LEARN_MAX_WORD_COUNT(handle)) { 1551053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1552053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NJ_SET_ERR_VAL(NJ_FUNC_STR_QUE_CMP, NJ_ERR_DIC_BROKEN); 1553053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1554053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1555053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project queYomi = POS_TO_ADDRESS(handle, que_id); 1556053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#ifdef IWNN_ERR_CHECK 1557053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (iwnn->err_check_flg == 7) { 1558053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project *queYomi = 0x03; 1559053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1560053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#endif 1561053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project switch (GET_TYPE_FROM_DATA(queYomi)) { 1562053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project case QUE_TYPE_EMPTY: 1563053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project case QUE_TYPE_JIRI: 1564053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project case QUE_TYPE_FZK: 1565053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project break; 1566053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project default: 1567053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1568053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NJ_SET_ERR_VAL(NJ_FUNC_STR_QUE_CMP, NJ_ERR_DIC_BROKEN); 1569053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1570053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1571053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1572053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if ((mode == 2) && (yomiLen == 0)) { 1573053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return 1; 1574053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1575053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1576053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1577053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project queYomiByte = GET_YSIZE_FROM_DATA(queYomi); 1578053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project queKouhoByte= GET_KSIZE_FROM_DATA(queYomi); 1579053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1580053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project top_addr = LEARN_DATA_TOP_ADDR(handle); 1581053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que_size = QUE_SIZE(handle); 1582053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1583053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1584053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project queYomi += LEARN_QUE_STRING_OFFSET; 1585053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project queYomiSearchArea = (NJ_UINT8)(QUE_SIZE(handle) - LEARN_QUE_STRING_OFFSET); 1586053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1587053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project complete = 0; 1588053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project yomiPos = 0; queYomiPos = 0; 1589053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project yomiPtr = (NJ_UINT8*)yomi; 1590053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project yomiByte = yomiLen * sizeof(NJ_CHAR); 1591053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1592053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1593053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project while ((complete = (*yomiPtr - *queYomi)) == 0) { 1594053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project yomiPos++; queYomiPos++; 1595053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1596053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (queYomiPos >= queYomiByte) { 1597053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (queYomiByte == yomiByte) { 1598053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1599053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return 1; 1600053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else if (mode == 2) { 1601053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1602053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return 2; 1603053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 1604053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1605053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return (mode + 1); 1606053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1607053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1608053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (yomiPos >= yomiByte) { 1609053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1610053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project break; 1611053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 1612053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project yomiPtr++; queYomi++; 1613053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#ifdef IWNN_ERR_CHECK 1614053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (iwnn->err_check_flg == 8) { 1615053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project queYomiPos = queYomiSearchArea; 1616053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1617053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#endif 1618053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (queYomiPos >= queYomiSearchArea) { 1619053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1620053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project bottom_addr = top_addr; 1621053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project bottom_addr += que_size * GET_LEARN_MAX_WORD_COUNT(handle) - 1; 1622053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (queYomi >= bottom_addr) { 1623053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project queYomi = top_addr; 1624053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1625053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1626053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1627053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (*queYomi++ != QUE_TYPE_NEXT) { 1628053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1629053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NJ_SET_ERR_VAL(NJ_FUNC_STR_QUE_CMP, NJ_ERR_DIC_BROKEN); 1630053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1631053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project queYomiSearchArea += (NJ_UINT8)(que_size - 1); 1632053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1633053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1634053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1635053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (complete == 0) { 1636053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (yomiByte < queYomiByte) { 1637053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1638053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (mode == 2) { 1639053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return 1; 1640053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1641053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1642053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return 0; 1643053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 1644053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1645053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return 2; 1646053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1647053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else if (complete < 0) { 1648053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1649053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return 0; 1650053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 1651053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1652053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return 2; 1653053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1654053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project} 1655053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1656053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Projectstatic NJ_HINDO calculate_hindo(NJ_DIC_HANDLE handle, NJ_INT32 freq, NJ_DIC_FREQ *dic_freq, NJ_INT16 freq_max, NJ_INT16 freq_min) { 1657053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 max; 1658053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_HINDO hindo; 1659053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1660053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1661053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project max = GET_LEARN_MAX_WORD_COUNT(handle); 1662053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1663053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1664053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1665053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1666053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (NJ_GET_DIC_TYPE(handle) == NJ_DIC_TYPE_USER) { 1667053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1668053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project hindo = (NJ_INT16)dic_freq->base; 1669053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 1670053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1671053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (max > 1) { 1672053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1673053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project hindo = CALCULATE_HINDO(freq, dic_freq->base, dic_freq->high, (max-1)); 1674053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 1675053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1676053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project hindo = (NJ_INT16)dic_freq->high; 1677053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1678053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1679053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NORMALIZE_HINDO(hindo, freq_max, freq_min); 1680053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project} 1681053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1682053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Projectstatic NJ_HINDO get_hindo(NJ_CLASS *iwnn, NJ_SEARCH_LOCATION_SET *loctset, 1683053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT8 search_pattern) { 1684053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_WQUE *que; 1685053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 que_id, oldest; 1686053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT8 offset; 1687053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_INT32 dic_freq; 1688053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 max; 1689053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT8 *learn_index_top_addr; 1690053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1691053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1692053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1693053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project learn_index_top_addr = get_search_index_address(loctset->loct.handle, search_pattern); 1694053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1695053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que_id = (NJ_UINT16)GET_UINT16(learn_index_top_addr + 1696053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ((loctset->loct.current & 0xffffU) * NJ_INDEX_SIZE)); 1697053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project oldest = GET_LEARN_NEXT_WORD_POS(loctset->loct.handle); 1698053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1699053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project offset = (loctset->loct.current_info & 0x0f); 1700053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project while (offset--) { 1701053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que_id = search_next_que(loctset->loct.handle, que_id); 1702053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1703053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1704053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que = get_que(iwnn, loctset->loct.handle, que_id); 1705053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (que == NULL) { 1706053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return INIT_HINDO; 1707053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1708053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1709053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project max = GET_LEARN_MAX_WORD_COUNT(loctset->loct.handle); 1710053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (que_id >= oldest) { 1711053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project dic_freq = que_id - oldest; 1712053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 1713053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project dic_freq = que_id - oldest + max; 1714053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1715053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1716053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1717d56eddfd5e0f193359f93e7ef665338cace9e2e9Daisuke Miyakawa return calculate_hindo(loctset->loct.handle, dic_freq, &(loctset->dic_freq), 1000, 0); 1718053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project} 1719053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1720053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source ProjectNJ_INT16 njd_l_get_word(NJ_CLASS *iwnn, NJ_SEARCH_LOCATION_SET *loctset, NJ_WORD *word) { 1721053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_WQUE *que; 1722053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 que_id; 1723053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT8 offset; 1724053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT8 *learn_index_top_addr; 1725053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1726053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1727053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1728053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project learn_index_top_addr = get_search_index_address(loctset->loct.handle, GET_LOCATION_OPERATION(loctset->loct.status)); 1729053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1730053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que_id = (NJ_UINT16)GET_UINT16(learn_index_top_addr + 1731053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ((loctset->loct.current & 0xffff) * NJ_INDEX_SIZE)); 1732053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1733053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project offset = (loctset->loct.current_info & 0x0f); 1734053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project while (offset--) { 1735053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que_id = search_next_que(loctset->loct.handle, que_id); 1736053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1737053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1738053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que = get_que(iwnn, loctset->loct.handle, que_id); 1739053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (que == NULL) { 1740053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NJ_SET_ERR_VAL(NJ_FUNC_NJD_L_GET_WORD, NJ_ERR_CANNOT_GET_QUE); 1741053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1742053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1743053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project word->stem.loc = loctset->loct; 1744053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1745053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project word->stem.loc.current &= 0x0000ffff; 1746053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project word->stem.loc.current |= ((NJ_UINT32)que_id << 16); 1747053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1748053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1749053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project word->stem.hindo = loctset->cache_freq; 1750053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1751053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_SET_FPOS_TO_STEM(word, que->mae_hinsi); 1752053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_SET_YLEN_TO_STEM(word, que->yomi_len); 1753053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (que->hyouki_len > 0) { 1754053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_SET_KLEN_TO_STEM(word, que->hyouki_len); 1755053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 1756053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1757053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_SET_KLEN_TO_STEM(word, que->yomi_len); 1758053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1759053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_SET_BPOS_TO_STEM(word, que->ato_hinsi); 1760053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1761053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1762053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project word->stem.type = 0; 1763053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1764053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return 1; 1765053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project} 1766053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1767053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source ProjectNJ_INT16 njd_l_get_stroke(NJ_CLASS *iwnn, NJ_WORD *word, NJ_CHAR *stroke, NJ_UINT16 size) { 1768053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 que_id; 1769053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_CHAR *str; 1770053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT8 slen; 1771053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT8 ylen; 1772053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1773053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1774053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que_id = (NJ_UINT16)(word->stem.loc.current >> 16); 1775053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1776053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1777053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ylen = (NJ_UINT8)NJ_GET_YLEN_FROM_STEM(word); 1778053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1779053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if ((NJ_UINT16)((ylen+ NJ_TERM_LEN)*sizeof(NJ_CHAR)) > size) { 1780053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1781053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NJ_SET_ERR_VAL(NJ_FUNC_NJD_L_GET_STROKE, NJ_ERR_BUFFER_NOT_ENOUGH); 1782053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1783053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (ylen == 0) { 1784053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NJ_SET_ERR_VAL(NJ_FUNC_NJD_L_GET_STROKE, NJ_ERR_INVALID_RESULT); 1785053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1786053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project str = get_string(iwnn, word->stem.loc.handle, que_id, &slen); 1787053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1788053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#ifdef IWNN_ERR_CHECK 1789053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (iwnn->err_check_flg == 9) { 1790053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project str = NULL; 1791053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1792053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#endif 1793053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1794053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (str == NULL) { 1795053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NJ_SET_ERR_VAL(NJ_FUNC_NJD_L_GET_STROKE, NJ_ERR_DIC_BROKEN); 1796053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1797053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1798053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1799053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project nj_strcpy(stroke, str); 1800053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1801053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return slen; 1802053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project} 1803053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1804053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source ProjectNJ_INT16 njd_l_get_candidate(NJ_CLASS *iwnn, NJ_WORD *word, 1805053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_CHAR *candidate, NJ_UINT16 size) { 1806053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 que_id; 1807053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_CHAR *str; 1808053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 klen; 1809053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT8 slen; 1810053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1811053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1812053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que_id = (NJ_UINT16)(word->stem.loc.current >> 16); 1813053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1814053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1815053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project klen = NJ_GET_KLEN_FROM_STEM(word); 1816053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1817053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (size < ((klen+NJ_TERM_LEN)*sizeof(NJ_CHAR))) { 1818053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1819053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NJ_SET_ERR_VAL(NJ_FUNC_NJD_L_GET_CANDIDATE, NJ_ERR_BUFFER_NOT_ENOUGH); 1820053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1821053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project str = get_hyouki(iwnn, word->stem.loc.handle, que_id, &slen); 1822053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#ifdef IWNN_ERR_CHECK 1823053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (iwnn->err_check_flg == 10) { 1824053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project str = NULL; 1825053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1826053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#endif 1827053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (str == NULL) { 1828053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1829053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NJ_SET_ERR_VAL(NJ_FUNC_NJD_L_GET_CANDIDATE, NJ_ERR_DIC_BROKEN); 1830053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1831053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1832053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1833053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project nj_strcpy(candidate, str); 1834053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1835053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return klen; 1836053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project} 1837053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1838053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source ProjectNJ_INT16 njd_l_check_dic(NJ_CLASS *iwnn, NJ_DIC_HANDLE handle) { 1839053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 flg; 1840053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 word_cnt, max; 1841053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT8 *ptr; 1842053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 target_id; 1843053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 i; 1844053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 id1 = 0; 1845053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT8 slen; 1846053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1847053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1848053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1849053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if ((NJ_GET_DIC_TYPE(handle) != NJ_DIC_TYPE_USER)) { 1850053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1851053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NJ_SET_ERR_VAL(NJ_FUNC_NJD_L_CHECK_DIC, NJ_ERR_DIC_TYPE_INVALID); 1852053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1853053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1854053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1855053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project word_cnt = GET_LEARN_WORD_COUNT(handle); 1856053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project max = GET_LEARN_MAX_WORD_COUNT(handle); 1857053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (word_cnt > max) { 1858053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1859053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NJ_SET_ERR_VAL(NJ_FUNC_NJD_L_CHECK_DIC, 1860053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_ERR_DIC_BROKEN); 1861053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1862053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1863053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ptr = LEARN_INDEX_TOP_ADDR(handle); 1864053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project for (i = 0; i < word_cnt; i++) { 1865053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project id1 = GET_UINT16(ptr); 1866053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1867053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (id1 >= max) { 1868053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NJ_SET_ERR_VAL(NJ_FUNC_NJD_L_CHECK_DIC, 1869053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_ERR_DIC_BROKEN); 1870053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1871053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ptr += NJ_INDEX_SIZE; 1872053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1873053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1874053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1875053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ptr = LEARN_INDEX_TOP_ADDR2(handle); 1876053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project for (i = 0; i < word_cnt; i++) { 1877053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project id1 = GET_UINT16(ptr); 1878053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1879053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (id1 >= max) { 1880053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NJ_SET_ERR_VAL(NJ_FUNC_NJD_L_CHECK_DIC, 1881053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_ERR_DIC_BROKEN); 1882053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1883053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ptr += NJ_INDEX_SIZE; 1884053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1885053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1886053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1887053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project flg = GET_UINT16(handle + POS_WRITE_FLG); 1888053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1889053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project target_id = GET_UINT16(handle + POS_WRITE_FLG + 2); 1890053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1891053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1892053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1893053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (((flg != word_cnt) && (flg != (word_cnt + 1)) && (flg != (word_cnt - 1))) || 1894053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project (target_id >= max)) { 1895053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NJ_SET_ERR_VAL(NJ_FUNC_NJD_L_CHECK_DIC, 1896053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_ERR_DIC_BROKEN); 1897053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1898053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1899053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1900053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (flg == (word_cnt + 1)) { 1901053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NJ_SET_ERR_VAL(NJ_FUNC_NJD_L_CHECK_DIC, NJ_ERR_DIC_BROKEN); 1902053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else if (flg == (word_cnt - 1)) { 1903053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NJ_SET_ERR_VAL(NJ_FUNC_NJD_L_CHECK_DIC, NJ_ERR_DIC_BROKEN); 1904053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1905053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1906053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project word_cnt = GET_LEARN_WORD_COUNT(handle); 1907053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1908053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ptr = LEARN_INDEX_TOP_ADDR(handle); 1909053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project for (i = 0; i < word_cnt; i++) { 1910053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project id1 = GET_UINT16(ptr); 1911053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (get_hyouki(iwnn, handle, id1, &slen) == NULL) { 1912053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NJ_SET_ERR_VAL(NJ_FUNC_NJD_L_CHECK_DIC, 1913053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_ERR_DIC_BROKEN); 1914053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1915053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ptr += NJ_INDEX_SIZE; 1916053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1917053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1918053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ptr = LEARN_INDEX_TOP_ADDR2(handle); 1919053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project for (i = 0; i < word_cnt; i++) { 1920053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project id1 = GET_UINT16(ptr); 1921053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1922053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (id1 >= max) { 1923053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NJ_SET_ERR_VAL(NJ_FUNC_NJD_L_CHECK_DIC, 1924053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_ERR_DIC_BROKEN); 1925053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1926053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ptr += NJ_INDEX_SIZE; 1927053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1928053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1929053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return 0; 1930053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project} 1931053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1932053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Projectstatic NJ_INT16 get_cand_by_evaluate2(NJ_CLASS *iwnn, NJ_SEARCH_CONDITION *cond, 1933053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_SEARCH_LOCATION_SET *loctset, 1934053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT8 search_pattern, 1935053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 idx) { 1936053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 from, to, i; 1937053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 que_id, oldest; 1938053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT32 max_value, eval, current; 1939053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT8 *ptr, *p; 1940053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_WQUE *que; 1941053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_INT16 ret = 0; 1942053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_INT32 found = 0; 1943053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT8 forward_flag = 0; 1944053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1945053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1946053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 abIdx; 1947053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 abIdx_old; 1948053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 tmp_len; 1949053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 yomi_clen; 1950053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 j,l,m; 1951053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT8 cmpflg; 1952053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT8 endflg = 0; 1953053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_CHAR *str; 1954053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_CHAR *key; 1955053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_CHAR char_tmp[NJ_MAX_LEN + NJ_TERM_LEN]; 1956053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_CHAR *pchar_tmp; 1957053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_SEARCH_CACHE *psrhCache = cond->ds->dic[idx].srhCache; 1958053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 endIdx; 1959053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT8 slen; 1960053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 addcnt = 0; 1961053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_CHAR *yomi; 1962053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT8 aimai_flg = 0x01; 1963053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_CHARSET *pCharset = cond->charset; 1964053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1965053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1966053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (NJ_GET_CACHEOVER_FROM_SCACHE(psrhCache)) { 1967053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project aimai_flg = 0x00; 1968053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1969053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1970053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1971053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ptr = get_search_index_address(loctset->loct.handle, cond->operation); 1972053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1973053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1974053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project oldest = GET_LEARN_NEXT_WORD_POS(loctset->loct.handle); 1975053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project max_value = oldest; 1976053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1977053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1978053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project current = 0; 1979053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (GET_LOCATION_STATUS(loctset->loct.status) == NJ_ST_SEARCH_NO_INIT) { 1980053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1981053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1982053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project key = cond->ds->keyword; 1983053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project yomi = cond->yomi; 1984053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project yomi_clen = cond->yclen; 1985053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1986053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1987053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project endflg = 0x00; 1988053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1989053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (psrhCache->keyPtr[0] == 0xFFFF) { 1990053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project cmpflg = 0x01; 1991053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project psrhCache->keyPtr[0] = 0x0000; 1992053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 1993053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project cmpflg = 0x00; 1994053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 1995053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1996053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project for (i = 0; i < yomi_clen; i++) { 1997053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project j = i; 1998053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 1999053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2000053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (!cmpflg) { 2001053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2002053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (((j != 0) && (psrhCache->keyPtr[j] == 0)) || (psrhCache->keyPtr[j+1] == 0)) { 2003053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2004053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project cmpflg = 0x01; 2005053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 2006053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2007053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2008053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2009053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2010053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (cmpflg) { 2011053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2012053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (!j) { 2013053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2014053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project abIdx = 0; 2015053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project addcnt = 0; 2016053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project nj_charncpy(char_tmp, yomi, 1); 2017053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project tmp_len = nj_strlen(char_tmp); 2018053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ret = search_range_by_yomi(iwnn, loctset->loct.handle, search_pattern, 2019053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project char_tmp, tmp_len, &from, 2020053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project &to, &forward_flag); 2021053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (ret < 0) { 2022053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2023053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2024053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project psrhCache->keyPtr[j+1] = abIdx; 2025053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project loctset->loct.status = NJ_ST_SEARCH_END; 2026053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return ret; 2027053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else if (ret > 0) { 2028053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2029053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project psrhCache->storebuff[abIdx].top = from; 2030053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project psrhCache->storebuff[abIdx].bottom = to; 2031053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project psrhCache->storebuff[abIdx].idx_no = (NJ_INT8)tmp_len; 2032053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project addcnt++; 2033053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project abIdx++; 2034053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project psrhCache->keyPtr[j+1] = abIdx; 2035053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 2036053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project psrhCache->keyPtr[j+1] = abIdx; 2037053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2038053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2039053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if ((!endflg) && (pCharset != NULL) && aimai_flg) { 2040053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2041053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project for (l = 0; l < pCharset->charset_count; l++) { 2042053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2043053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (nj_charncmp(yomi, pCharset->from[l], 1) == 0) { 2044053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2045053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project nj_strcpy(char_tmp, pCharset->to[l]); 2046053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project tmp_len = nj_strlen(char_tmp); 2047053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ret = search_range_by_yomi(iwnn, loctset->loct.handle, search_pattern, 2048053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project char_tmp, tmp_len, &from, &to, &forward_flag); 2049053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (ret < 0) { 2050053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2051053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2052053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project psrhCache->keyPtr[j+1] = abIdx; 2053053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project loctset->loct.status = NJ_ST_SEARCH_END; 2054053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return ret; 2055053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else if (ret > 0) { 2056053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2057053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2058053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (abIdx >= NJ_SEARCH_CACHE_SIZE) { 2059053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project psrhCache->keyPtr[j+1] = 0; 2060053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NJ_SET_ERR_VAL(NJ_FUNC_SEARCH_RANGE_BY_YOMI, NJ_ERR_CACHE_NOT_ENOUGH); 2061053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2062053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project psrhCache->storebuff[abIdx].top = from; 2063053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project psrhCache->storebuff[abIdx].bottom = to; 2064053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project psrhCache->storebuff[abIdx].idx_no = (NJ_INT8)tmp_len; 2065053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (addcnt == 0) { 2066053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project psrhCache->keyPtr[j] = abIdx; 2067053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2068053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project abIdx++; 2069053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project addcnt++; 2070053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project psrhCache->keyPtr[j+1] = abIdx; 2071053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 2072053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project psrhCache->keyPtr[j+1] = abIdx; 2073053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2074053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2075053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2076053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2077053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 2078053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2079053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (psrhCache->keyPtr[j] == psrhCache->keyPtr[j-1]) { 2080053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2081053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project psrhCache->keyPtr[j+1] = psrhCache->keyPtr[j-1]; 2082053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project endflg = 0x01; 2083053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 2084053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2085053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project endIdx = psrhCache->keyPtr[j]; 2086053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project abIdx_old = psrhCache->keyPtr[j-1]; 2087053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2088053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (NJ_GET_CACHEOVER_FROM_SCACHE(psrhCache)) { 2089053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project abIdx = psrhCache->keyPtr[j - 1]; 2090053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project psrhCache->keyPtr[j] = abIdx; 2091053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 2092053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project abIdx = psrhCache->keyPtr[j]; 2093053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2094053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project addcnt = 0; 2095053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2096053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if ((abIdx > NJ_SEARCH_CACHE_SIZE) || (abIdx_old >= NJ_SEARCH_CACHE_SIZE) || 2097053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project (endIdx > NJ_SEARCH_CACHE_SIZE)) { 2098053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2099053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NJ_SET_ERR_VAL(NJ_FUNC_SEARCH_RANGE_BY_YOMI, NJ_ERR_CACHE_BROKEN); 2100053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2101053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project for (m = abIdx_old; m < endIdx; m++) { 2102053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2103053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project p = ptr + (psrhCache->storebuff[m].top * NJ_INDEX_SIZE); 2104053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que_id = GET_UINT16(p); 2105053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2106053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2107053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project str = get_string(iwnn, loctset->loct.handle, que_id, &slen); 2108053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2109053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (str == NULL) { 2110053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NJ_SET_ERR_VAL(NJ_FUNC_SEARCH_RANGE_BY_YOMI, NJ_ERR_DIC_BROKEN); 2111053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2112053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2113053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2114053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project nj_strncpy(char_tmp, str, psrhCache->storebuff[m].idx_no); 2115053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project char_tmp[psrhCache->storebuff[m].idx_no] = NJ_CHAR_NUL; 2116053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2117053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project pchar_tmp = &char_tmp[psrhCache->storebuff[m].idx_no]; 2118053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project nj_charncpy(pchar_tmp, yomi, 1); 2119053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project tmp_len = nj_strlen(char_tmp); 2120053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2121053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2122053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ret = search_range_by_yomi2(iwnn, loctset->loct.handle, search_pattern, 2123053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project char_tmp, tmp_len, 2124053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project (NJ_UINT16)(psrhCache->storebuff[m].top), 2125053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project (NJ_UINT16)(psrhCache->storebuff[m].bottom), 2126053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project &from, &to, &forward_flag); 2127053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (ret < 0) { 2128053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2129053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2130053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project psrhCache->keyPtr[j+1] = abIdx; 2131053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project loctset->loct.status = NJ_ST_SEARCH_END; 2132053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return ret; 2133053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else if (ret > 0) { 2134053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2135053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2136053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (abIdx >= NJ_SEARCH_CACHE_SIZE) { 2137053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project psrhCache->keyPtr[j+1] = 0; 2138053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NJ_SET_ERR_VAL(NJ_FUNC_SEARCH_RANGE_BY_YOMI, NJ_ERR_CACHE_NOT_ENOUGH); 2139053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2140053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project psrhCache->storebuff[abIdx].top = from; 2141053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project psrhCache->storebuff[abIdx].bottom = to; 2142053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project psrhCache->storebuff[abIdx].idx_no = (NJ_INT8)tmp_len; 2143053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (addcnt == 0) { 2144053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project psrhCache->keyPtr[j] = abIdx; 2145053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2146053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project abIdx++; 2147053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project addcnt++; 2148053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project psrhCache->keyPtr[j+1] = abIdx; 2149053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 2150053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project psrhCache->keyPtr[j+1] = abIdx; 2151053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2152053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2153053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if ((!endflg) && (pCharset != NULL) && aimai_flg) { 2154053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2155053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project for (l = 0; l < pCharset->charset_count; l++) { 2156053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2157053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (nj_charncmp(yomi, pCharset->from[l], 1) == 0) { 2158053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2159053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project tmp_len = nj_strlen(pCharset->to[l]); 2160053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2161053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project nj_strncpy(pchar_tmp, pCharset->to[l], tmp_len); 2162053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project *(pchar_tmp + tmp_len) = NJ_CHAR_NUL; 2163053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project tmp_len = nj_strlen(char_tmp); 2164053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ret = search_range_by_yomi2(iwnn, loctset->loct.handle, search_pattern, 2165053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project char_tmp, tmp_len, 2166053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project (NJ_UINT16)(psrhCache->storebuff[m].top), 2167053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project (NJ_UINT16)(psrhCache->storebuff[m].bottom), 2168053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project &from, &to, &forward_flag); 2169053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (ret < 0) { 2170053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2171053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2172053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project psrhCache->keyPtr[j+1] = abIdx; 2173053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project loctset->loct.status = NJ_ST_SEARCH_END; 2174053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return ret; 2175053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else if (ret > 0) { 2176053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2177053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2178053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (abIdx >= NJ_SEARCH_CACHE_SIZE) { 2179053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project psrhCache->keyPtr[j+1] = 0; 2180053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NJ_SET_ERR_VAL(NJ_FUNC_SEARCH_RANGE_BY_YOMI, NJ_ERR_CACHE_NOT_ENOUGH); 2181053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2182053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project psrhCache->storebuff[abIdx].top = from; 2183053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project psrhCache->storebuff[abIdx].bottom = to; 2184053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project psrhCache->storebuff[abIdx].idx_no = (NJ_INT8)tmp_len; 2185053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project abIdx++; 2186053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project addcnt++; 2187053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project psrhCache->keyPtr[j+1] = abIdx; 2188053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 2189053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project psrhCache->keyPtr[j+1] = abIdx; 2190053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2191053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2192053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2193053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2194053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2195053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2196053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2197053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2198053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project yomi += UTL_CHAR(yomi); 2199053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project key += UTL_CHAR(key); 2200053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2201053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2202053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2203053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if ((addcnt == 0) && (psrhCache->keyPtr[yomi_clen - 1] == psrhCache->keyPtr[yomi_clen])) { 2204053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project endflg = 0x01; 2205053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2206053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2207053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (endflg) { 2208053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project loctset->loct.status = NJ_ST_SEARCH_END; 2209053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return 0; 2210053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2211053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else if (GET_LOCATION_STATUS(loctset->loct.status) == NJ_ST_SEARCH_READY) { 2212053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project current = GET_UINT16(ptr + (loctset->loct.current * NJ_INDEX_SIZE)); 2213053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (current < oldest) { 2214053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project current += GET_LEARN_MAX_WORD_COUNT(loctset->loct.handle); 2215053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2216053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 2217053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project loctset->loct.status = NJ_ST_SEARCH_END; 2218053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return 0; 2219053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2220053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2221053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2222053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project j = cond->yclen - 1; 2223053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2224053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project abIdx = psrhCache->keyPtr[j]; 2225053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project abIdx_old = psrhCache->keyPtr[j+1]; 2226053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2227053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project endIdx = abIdx_old; 2228053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if ((abIdx >= NJ_SEARCH_CACHE_SIZE) || (abIdx_old > NJ_SEARCH_CACHE_SIZE)) { 2229053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2230053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NJ_SET_ERR_VAL(NJ_FUNC_SEARCH_RANGE_BY_YOMI, NJ_ERR_CACHE_BROKEN); 2231053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2232053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project p = ptr + (psrhCache->storebuff[abIdx].top * NJ_INDEX_SIZE); 2233053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que_id = GET_UINT16(p); 2234053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project eval = current; 2235053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2236053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2237053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2238053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (psrhCache->keyPtr[j] < psrhCache->keyPtr[j + 1]) { 2239053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (GET_LOCATION_STATUS(loctset->loct.status) == NJ_ST_SEARCH_NO_INIT) { 2240053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project endIdx = abIdx + 1; 2241053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_SET_AIMAI_TO_SCACHE(psrhCache); 2242053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2243053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2244053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project for (m = abIdx; m < endIdx; m++) { 2245053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project p = ptr + (psrhCache->storebuff[m].top * NJ_INDEX_SIZE); 2246053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que_id = GET_UINT16(p); 2247053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project eval = current; 2248053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2249053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project for (i = (NJ_UINT16)psrhCache->storebuff[m].top; i <= (NJ_UINT16)psrhCache->storebuff[m].bottom; i++) { 2250053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que_id = GET_UINT16(p); 2251053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (que_id < oldest) { 2252053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project eval = que_id + GET_LEARN_MAX_WORD_COUNT(loctset->loct.handle); 2253053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 2254053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project eval = que_id; 2255053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2256053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#ifdef LEARN_DEBUG 2257053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project printf("que(%d) : eval = %d : %d\n", que_id, eval, i); 2258053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#endif 2259053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (eval >= max_value) { 2260053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if ((GET_LOCATION_STATUS(loctset->loct.status) == NJ_ST_SEARCH_NO_INIT) 2261053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project || ((GET_LOCATION_STATUS(loctset->loct.status) == NJ_ST_SEARCH_READY) 2262053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project && (NJ_GET_AIMAI_FROM_SCACHE(psrhCache))) 2263053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project || (eval < current)) { 2264053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2265053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2266053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2267053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project str = get_string(iwnn, loctset->loct.handle, que_id, &slen); 2268053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (str == NULL) { 2269053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NJ_SET_ERR_VAL(NJ_FUNC_SEARCH_RANGE_BY_YOMI, NJ_ERR_DIC_BROKEN); 2270053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2271053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2272053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2273053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2274053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que = get_que_allHinsi(iwnn, loctset->loct.handle, que_id); 2275053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (njd_connect_test(cond, que->mae_hinsi, que->ato_hinsi)) { 2276053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2277053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project loctset->loct.current_info = (NJ_UINT8)0x10; 2278053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project loctset->loct.current = i; 2279053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project max_value = eval; 2280053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project found = 1; 2281053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#ifdef LEARN_DEBUG 2282053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project printf("---keep."); 2283053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#endif 2284053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2285053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2286053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2287053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project p += NJ_INDEX_SIZE; 2288053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2289053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2290053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2291053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2292053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (GET_LOCATION_STATUS(loctset->loct.status) != NJ_ST_SEARCH_NO_INIT) { 2293053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UNSET_AIMAI_TO_SCACHE(psrhCache); 2294053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2295053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2296053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2297053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (found == 0) { 2298053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project loctset->loct.status = NJ_ST_SEARCH_END; 2299053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return 0; 2300053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 2301053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project loctset->loct.status = NJ_ST_SEARCH_READY; 2302053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project loctset->cache_freq = get_hindo(iwnn, loctset, search_pattern); 2303053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return 1; 2304053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2305053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project} 2306053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2307053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Projectstatic NJ_INT16 search_range_by_yomi2(NJ_CLASS *iwnn, NJ_DIC_HANDLE handle, NJ_UINT8 op, 2308053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_CHAR *yomi, NJ_UINT16 len, 2309053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 sfrom, NJ_UINT16 sto, 2310053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 *from, NJ_UINT16 *to, 2311053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT8 *forward_flag) { 2312053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 right, mid = 0, left, max; 2313053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT16 que_id; 2314053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT8 *ptr, *p; 2315053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_CHAR *str; 2316053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_INT16 ret = 0; 2317053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_INT32 found = 0; 2318053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_UINT8 slen; 2319053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project NJ_INT32 cmp; 2320053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2321053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2322053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2323053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ptr = get_search_index_address(handle, op); 2324053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2325053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project max = GET_LEARN_WORD_COUNT(handle); 2326053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2327053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project right = sto; 2328053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project left = sfrom; 2329053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2330053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#ifdef LEARN_DEBUG 2331053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project printf("src:[%s]\n", yomi); 2332053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#endif 2333053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2334053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project *forward_flag = 0; 2335053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2336053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project while (left <= right) { 2337053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project mid = left + ((right - left) / 2); 2338053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project p = ptr + (mid * NJ_INDEX_SIZE); 2339053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que_id = GET_UINT16(p); 2340053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project str = get_string(iwnn, handle, que_id, &slen); 2341053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (str == NULL) { 2342053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NJ_SET_ERR_VAL(NJ_FUNC_SEARCH_RANGE_BY_YOMI, NJ_ERR_DIC_BROKEN); 2343053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2344053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2345053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2346053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project ret = nj_strncmp(yomi, str, len); 2347053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2348053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#ifdef LEARN_DEBUG 2349053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project printf(" [%d][%d][%d]COMPARE:[%s] = %d\n", left, mid, right, str, ret); 2350053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#endif 2351053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (ret == 0) { 2352053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2353053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project found = 1; 2354053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project break; 2355053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else if (ret < 0) { 2356053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2357053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project right = mid - 1; 2358053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (mid == 0) { 2359053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project break; 2360053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2361053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 2362053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2363053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project left = mid + 1; 2364053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2365053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2366053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2367053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (!found) { 2368053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return 0; 2369053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2370053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2371053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (mid == 0) { 2372053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project *from = mid; 2373053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 2374053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2375053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project p = ((mid - 1) * NJ_INDEX_SIZE) + ptr; 2376053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2377053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project for (cmp = mid - 1; cmp >= 0; cmp--) { 2378053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que_id = GET_UINT16(p); 2379053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project str = get_string(iwnn, handle, que_id, &slen); 2380053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (str == NULL) { 2381053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NJ_SET_ERR_VAL(NJ_FUNC_SEARCH_RANGE_BY_YOMI, NJ_ERR_DIC_BROKEN); 2382053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2383053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2384053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2385053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (nj_strncmp(yomi, str, len) != 0) { 2386053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project break; 2387053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2388053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project p -= NJ_INDEX_SIZE; 2389053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2390053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (cmp < 0) { 2391053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project *from = 0; 2392053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 2393053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project *from = (NJ_UINT16)cmp + 1; 2394053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2395053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2396053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2397053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#ifdef LEARN_DEBUG 2398053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project printf(" >> from:(%d)\n", *from); 2399053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#endif 2400053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2401053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if ((mid + 1) >= max) { 2402053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project *to = mid; 2403053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } else { 2404053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2405053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project p = ((mid + 1) * NJ_INDEX_SIZE) + ptr; 2406053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2407053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project for (right = mid + 1; right < max; right++) { 2408053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project que_id = GET_UINT16(p); 2409053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project str = get_string(iwnn, handle, que_id, &slen); 2410053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (str == NULL) { 2411053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return NJ_SET_ERR_VAL(NJ_FUNC_SEARCH_RANGE_BY_YOMI, NJ_ERR_DIC_BROKEN); 2412053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2413053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2414053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2415053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project if (nj_strncmp(yomi, str, len) != 0) { 2416053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project break; 2417053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2418053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project p += NJ_INDEX_SIZE; 2419053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2420053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project *to = right - 1; 2421053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project } 2422053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2423053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#ifdef LEARN_DEBUG 2424053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project printf(" >> to:(%d)\n", *to); 2425053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project#endif 2426053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project return 1; 2427053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project} 2428053d50935e0e311286543bd7c535ae2c863c0deThe Android Open Source Project 2429