X-Git-Url: http://git.harvie.cz/?p=svn%2FCll1h%2F.git;a=blobdiff_plain;f=crl1.h;fp=crl1.h;h=871ae969eb48196ba59650b6b4efe196f0ddabb9;hp=e97d0ffad91fe954c31a90cd3ea5e5166eea53ca;hb=241ad5f6ed3b16b03dd7d794ff7c376a04d767cb;hpb=9ca7f90d80df810e91d006b23bd9717136cf4e22 diff --git a/crl1.h b/crl1.h index e97d0ff..871ae96 100644 --- a/crl1.h +++ b/crl1.h @@ -161,10 +161,10 @@ unsigned RANDOM_SEED=0; #define _next_char_str(ONE,...) ONE=*(++_s) #define _count_char_str(S) strlen(S) #define _init_str_str(...) str _s=(__VA_ARGS__) -#define _head_str_str(ONE,ALL) ONE=utf8_copy(ONE,ALL),ALL +#define _head_str_str(ONE,ALL) ONE=_utf8_copy(ONE,ALL),ALL #define _test_str_str(ONE,...) *ONE #define _free_str_str(...) FALSE -#define _next_str_str(ONE,...) ONE=utf8_copy(ONE,(_s+=strlen(ONE))) +#define _next_str_str(ONE,...) ONE=_utf8_copy(ONE,(_s+=strlen(ONE))) #define _COUNT_STR_STR int _count_str_str(str S) { int l=0; str X=""; for_each2(str,X,str,S){l++;} return l; } #define _init_void_array(...) int _i=(__VA_ARGS__) #define _head_void_array(ONE,ALL,LEN) ONE=*ALL,0 @@ -183,7 +183,7 @@ unsigned RANDOM_SEED=0; #define _test_str_file(ONE,...) (!feof(_f)&&(ONE=fget_str(_f))) #define _free_str_file(...) fclose(_f) #define _next_str_file(...) -#define _COUNT_STR_FILE int _count_str_file(str F) { int l=0; str X; for_each2(str,X,file,F){l++;} return l; } +#define _COUNT_STR_FILE int _count_str_file(str F) { int l=0; str X; for_each(str,X,file,F){l++;} return l; } #define _init_str_stream(...) (__VA_ARGS__) #define _head_str_stream(ONE,ALL,LEN) (ONE=(str)get_buf(LEN)) && fgets(ONE,LEN,ALL) && strrchr(ONE,'\n') && (ONE[strlen(ONE)-1]=0) #define _test_str_stream(ONE,ALL,LEN) !feof(ALL) @@ -246,6 +246,8 @@ unsigned RANDOM_SEED=0; #define _STRCMPI _DECLARE_STRCMPI { if(a && b) return strcasecmp(a,b); else return (int)(a-b); } #define _DECLARE_STRSTR str _crl1_str_str(str h, str n) #define _STRSTR _DECLARE_STRSTR { if(h && n) return strstr(h,n); else return NULL; } +#define _EXPORT_UTF8 str _utf8_copy(str dst, str src) { unsigned char I=*src; if(I > 0 && I < 192 && I != 168 && I != 184) { dst=(str)get_buf(2); dst[0]=src[0]; dst[1]=0; } else if(I >= 224) { dst=(str)get_buf(4);dst[0]=src[0]; dst[1]=src[1]; dst[2]=src[2]; dst[3]=0; } else if(I) { dst=(str)get_buf(3); dst[0]=src[0]; dst[1]=src[1]; dst[2]=0; } else { dst=src; } return dst; } + // later... #define _WORDINSTR char *_crl1_wordinstr(char *a,char *b,int ign) { char *IFS=a; for(;a&&*a;a++) for(;*ifs||ifs=IFS;ifs++) if(*a=b);) for return strcasestr(a,b); else return NULL; } extern _DECLARE_PRINT; extern _DECLARE_FPRINT; @@ -406,7 +408,7 @@ obsolete / 98. We have have done our homework - now let's have some fun: '----------------------------------------------------------------------- */ #define _INIT_VARIABLES _EXPORT_GLOBALS _EXPORT_YES _EXPORT_STACKS _CGI_GLOBALS -#define _IMPLEMENT_FUNCTIONS /*_MALLOC*/ _EXPORT_OUTS _EXPORT_ARGS _EXPORT_STRS _EXPORT_COUNTERS +#define _IMPLEMENT_FUNCTIONS /*_MALLOC*/ _EXPORT_OUTS _EXPORT_ARGS _EXPORT_STRS _EXPORT_COUNTERS _EXPORT_UTF8 //#define _IMPL_INTERFACE //_SQL_IFC _CAKE_IFC _STD_IFC _X_IFC #define _IMPLEMENT_CRL1_LIBRARY _INIT_VARIABLES _IMPLEMENT_FUNCTIONS //_IMPL_INTERFACE //this will be probably accomplished some other way...