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");