From bdca633bbd41747d238c8d397ebc2017f0e41fd4 Mon Sep 17 00:00:00 2001 From: zhengchao Date: Sun, 18 Sep 2016 12:44:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E9=AB=98MAAT=5FSET=5FSCAN=5FDISTRICT?= =?UTF-8?q?=E9=80=89=E9=A1=B9=E7=9A=84=E5=8F=82=E6=95=B0=E8=A6=81=E6=B1=82?= =?UTF-8?q?=EF=BC=8C=E4=B8=8D=E5=86=8D=E8=A6=81=E6=B1=82=E2=80=98\0?= =?UTF-8?q?=E2=80=99=E7=BB=93=E6=9D=9F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inc/Maat_rule.h | 2 +- src/entry/Maat_api.cpp | 2 +- src/entry/Maat_rule.cpp | 2 +- src/entry/map_str2int.cpp | 18 ++++++++++++++++++ src/entry/map_str2int.h | 1 + test/maat_test.cpp | 2 +- 6 files changed, 23 insertions(+), 4 deletions(-) diff --git a/inc/Maat_rule.h b/inc/Maat_rule.h index f7399c1..a9fed65 100644 --- a/inc/Maat_rule.h +++ b/inc/Maat_rule.h @@ -161,7 +161,7 @@ int Maat_table_callback_register(Maat_feather_t feather,short table_id, enum MAAT_SCAN_OPT { - MAAT_SET_SCAN_DISTRICT=1 //VALUE is a const char*,MUST end with '\0',SIZE= strlen(string+'\0')+1.DEFAULT: no default. + MAAT_SET_SCAN_DISTRICT=1 //VALUE is a const char*,SIZE= strlen(string).DEFAULT: no default. }; //return 0 if success, return -1 when failed; int Maat_set_scan_status(Maat_feather_t feather,scan_status_t* mid,enum MAAT_SCAN_OPT type,const void* value,int size); diff --git a/src/entry/Maat_api.cpp b/src/entry/Maat_api.cpp index 44da318..c522b29 100644 --- a/src/entry/Maat_api.cpp +++ b/src/entry/Maat_api.cpp @@ -1491,7 +1491,7 @@ int Maat_set_scan_status(Maat_feather_t feather,scan_status_t* mid,enum MAAT_SCA { return -1; } - map_ret=map_str2int(_feather->scanner->district_map,(const char*)value,&(_mid->district_id)); + map_ret=map_unNullstr2int(_feather->scanner->district_map,(const char*)value,size,&(_mid->district_id)); if(map_ret<0) { //May be the district is not effected yet. diff --git a/src/entry/Maat_rule.cpp b/src/entry/Maat_rule.cpp index f460534..789e97c 100644 --- a/src/entry/Maat_rule.cpp +++ b/src/entry/Maat_rule.cpp @@ -26,7 +26,7 @@ #include "mesa_fuzzy.h" #include "great_index_engine.h" -int MAAT_FRAME_VERSION_1_8_20160909_TABLE_CONJ=1; +int MAAT_FRAME_VERSION_1_8_20160918_TABLE_CONJ=1; const char *maat_module="MAAT Frame"; const char* CHARSET_STRING[]={"NONE","gbk","big5","unicode","utf8","bin", diff --git a/src/entry/map_str2int.cpp b/src/entry/map_str2int.cpp index f8cf554..0d1ce51 100644 --- a/src/entry/map_str2int.cpp +++ b/src/entry/map_str2int.cpp @@ -75,6 +75,24 @@ int map_str2int(MESA_htable_handle handle,const char* string,int* value) return -1; } } +int map_unNullstr2int(MESA_htable_handle handle,const char* string,int len,int* value) +{ + int *data=NULL; + long cb_ret=0; + + data=(int*)MESA_htable_search_cb(handle,(unsigned char*)string,len, + read_map_val,value,&cb_ret); + +// data=(int*)MESA_htable_search(handle,(unsigned char*)string,len); + if(cb_ret>0) + { + return 1; + } + else + { + return -1; + } +} void duplicate_func(const uchar * key, uint size, void * data, void * user) { MESA_htable_handle target=(MESA_htable_handle)user; diff --git a/src/entry/map_str2int.h b/src/entry/map_str2int.h index 132a1e0..54e93cd 100644 --- a/src/entry/map_str2int.h +++ b/src/entry/map_str2int.h @@ -4,6 +4,7 @@ MESA_htable_handle map_create(void); void map_destroy(MESA_htable_handle p); int map_register(MESA_htable_handle handle,const char* string,int value); int map_str2int(MESA_htable_handle handle,const char* string,int* value); +int map_unNullstr2int(MESA_htable_handle handle,const char* string,int size,int* value); MESA_htable_handle map_duplicate(MESA_htable_handle origin_map); #endif diff --git a/test/maat_test.cpp b/test/maat_test.cpp index bb3ecc9..96ae1f7 100644 --- a/test/maat_test.cpp +++ b/test/maat_test.cpp @@ -415,7 +415,7 @@ int test_expr_plus(Maat_feather_t feather,const char* table_name,scan_status_t* printf("Should not hit without setting district.\n"); return -1; } - ret=Maat_set_scan_status(feather, mid, MAAT_SET_SCAN_DISTRICT,region_name,strlen(region_name)+1); + ret=Maat_set_scan_status(feather, mid, MAAT_SET_SCAN_DISTRICT,region_name,strlen(region_name)); if(ret<0) { printf("set MAAT_SET_SCAN_DISTRICT failed.\n");