+added case-insensitive type name string comparison support.

This commit is contained in:
paladin-t 2016-01-01 11:17:07 +08:00
parent eeff6d28d2
commit 42a602d8a3
4 changed files with 21 additions and 19 deletions

View File

@ -1,5 +1,6 @@
Jan. 1 2016 Version 1.2 Jan. 1 2016 Version 1.2
Added a new sample script source file Added a new sample script source file
Added case-insensitive type name string comparison support
Dec. 30 2015 Dec. 30 2015
Improved error handling with sub routine and class Improved error handling with sub routine and class

View File

@ -1146,10 +1146,18 @@ static char* _extract_string(_object_t* obj);
case _DT_DICT: \ case _DT_DICT: \
_gc_add(&(__o)->data.dict->ref, (__o)->data.dict, (__g)); \ _gc_add(&(__o)->data.dict->ref, (__o)->data.dict, (__g)); \
break; break;
# define _UNREF_COLL_IT(__o) \
case _DT_LIST_IT: \
_destroy_list_it(obj->data.list_it); \
break; \
case _DT_DICT_IT: \
_destroy_dict_it(obj->data.dict_it); \
break;
#else /* MB_ENABLE_COLLECTION_LIB */ #else /* MB_ENABLE_COLLECTION_LIB */
# define _REF_COLL(__o) ((void)(__o)); # define _REF_COLL(__o) ((void)(__o));
# define _UNREF_COLL(__o) ((void)(__o)); # define _UNREF_COLL(__o) ((void)(__o));
# define _ADDGC_COLL(__o, __g) ((void)(__o)); ((void)(__g)); # define _ADDGC_COLL(__o, __g) ((void)(__o)); ((void)(__g));
# define _UNREF_COLL_IT(__o) ((void)(__o));
#endif /* MB_ENABLE_COLLECTION_LIB */ #endif /* MB_ENABLE_COLLECTION_LIB */
#ifdef MB_ENABLE_CLASS #ifdef MB_ENABLE_CLASS
# define _REF_CLASS(__o) \ # define _REF_CLASS(__o) \
@ -6331,16 +6339,7 @@ int _dispose_object(_object_t* obj) {
_UNREF_ARRAY(obj) _UNREF_ARRAY(obj)
_UNREF_COLL(obj) _UNREF_COLL(obj)
_UNREF_CLASS(obj) _UNREF_CLASS(obj)
#ifdef MB_ENABLE_COLLECTION_LIB _UNREF_COLL_IT(obj)
case _DT_LIST_IT:
_destroy_list_it(obj->data.list_it);
break;
case _DT_DICT_IT:
_destroy_dict_it(obj->data.dict_it);
break;
#endif /* MB_ENABLE_COLLECTION_LIB */
case _DT_LABEL: case _DT_LABEL:
if(!obj->ref) { if(!obj->ref) {
safe_free(obj->data.label->name); safe_free(obj->data.label->name);
@ -11123,7 +11122,7 @@ int _core_type(mb_interpreter_t* s, void** l) {
if(arg.type == MB_DT_STRING) { if(arg.type == MB_DT_STRING) {
for(i = 0; i < sizeof(mb_data_e) * 8; i++) { for(i = 0; i < sizeof(mb_data_e) * 8; i++) {
e = 1 << i; e = 1 << i;
if(!strcmp(mb_get_type_string((mb_data_e)e), arg.value.string)) { if(!mb_stricmp(mb_get_type_string((mb_data_e)e), arg.value.string)) {
arg.value.type = (mb_data_e)e; arg.value.type = (mb_data_e)e;
arg.type = MB_DT_TYPE; arg.type = MB_DT_TYPE;

View File

@ -143,17 +143,19 @@ extern "C" {
# define MB_NULL_STRING "(empty)" # define MB_NULL_STRING "(empty)"
#endif /* MB_NULL_STRING */ #endif /* MB_NULL_STRING */
#ifndef _MSC_VER #ifndef mb_stricmp
# ifndef _strcmpi # ifdef _MSC_VER
# define mb_stricmp _strcmpi
# else /* _MSC_VER */
# ifdef __BORLANDC__ # ifdef __BORLANDC__
# define _strcmpi stricmp # define mb_stricmp stricmp
# elif defined __POCC__ # elif defined __POCC__
# define _strcmpi _stricmp # define mb_stricmp _stricmp
# else # else
# define _strcmpi strcasecmp # define mb_stricmp strcasecmp
# endif # endif
# endif /* _strcmpi */ # endif /* _MSC_VER */
#endif /* _MSC_VER */ #endif /* mb_stricmp */
#ifndef mb_assert #ifndef mb_assert
# define mb_assert(__a) do { ((void)(__a)); assert(__a); } while(0) # define mb_assert(__a) do { ((void)(__a)); assert(__a); } while(0)

View File

@ -82,7 +82,7 @@ extern "C" {
#define _USE_MEM_POOL 1 #define _USE_MEM_POOL 1
#define _MAX_LINE_LENGTH 256 #define _MAX_LINE_LENGTH 256
#define _str_eq(__str1, __str2) (_strcmpi(__str1, __str2) == 0) #define _str_eq(__str1, __str2) (mb_stricmp(__str1, __str2) == 0)
#define _LINE_INC_STEP 16 #define _LINE_INC_STEP 16