X-Git-Url: https://git.harvie.cz/?a=blobdiff_plain;ds=sidebyside;f=cll1.h;h=1d95db282f7c933a3218ddc412e6e444475b143b;hb=19c9d3652f0876a1f0fed0eb18c3bf9458ab3908;hp=08a9a8e37d2e4561b9cb2a83b7693fc0bf0e4f73;hpb=25a3f4304e39dce85a217fd3166df867a5d75b96;p=svn%2FCll1h%2F.git diff --git a/cll1.h b/cll1.h index 08a9a8e..1d95db2 100644 --- a/cll1.h +++ b/cll1.h @@ -53,7 +53,7 @@ #include #endif /* .----------------------------------------------------------------------. - / 2. C<<1 then buddhist section, updated 2008-01-26 xCh. + / 1. C<<1 then buddhist section, updated 2008-02-01 xCh. '----------------------------------------------------------------------- */ #ifndef DISABLE_MODULE_THEN_BUDDHISM #define then @@ -61,24 +61,27 @@ #define WHOKNOWS (int)(srandom((unsigned)time(NULL)),random()%2) #define create_var(ID,TYPE,EXPR) TYPE ID=(EXPR) #define def_var(ID,TYPE) TYPE ID -//#define _CLL1_YES char *YES="TRUE\nYES\nJA\nOUI\nDA\nANO\nY\n1"; +//#define _CLL1_YES str YES="TRUE\nYES\nJA\nOUI\nDA\nANO\nY\n1"; //#define atob(EXPR) (word_in_stri(YES,(EXPR))?1:0) //#else -#define _CLL1_YES char *YES="TRUE"; +#define _CLL1_YES str YES="TRUE"; #define atob(EXPR) (eqi((EXPR),YES)?1:0) #endif /* .----------------------------------------------------------------------. - / 1. C<<1 almost then buddhist section, updated 2008-01-26 xCh. + / 2. C<<1 almost then buddhist section, updated 2008-02-02 xCh. '----------------------------------------------------------------------- */ +typedef char * str; +typedef FILE * file; +typedef int bool; #define not ! #define and && #define or || -#define bool int #define TRUE 1 #define FALSE 0 +#define WEIRDINT (1<<(sizeof(int)*8-1)) #define btoa(EXPR) ((EXPR)?"TRUE":"FALSE") #define coalesce(VAR,EXPR) (VAR?VAR:(EXPR)) -#define _CLL1_GLOBALS char *NIL="NULL", *EOL="\n", *OFS=" ", *IFS=" \t\n"; unsigned RANDOM_SEED=0; +#define _CLL1_GLOBALS str NIL="NULL", EOL="\n", OFS=" ", IFS=" \t\n"; unsigned RANDOM_SEED=0; /* .----------------------------------------------------------------------. / 4. C<<1 data declaration and allocation, updated 2008-01-31 xCh. '----------------------------------------------------------------------- */ @@ -92,10 +95,6 @@ #define init_mem(...) _mem_##TYPE##_( _ARG2(__VA_ARGS__,,) - 0 ) #define construct_mem(TYPE) (struct TYPE *)_mem_##TYPE##_(void) { create_mem(this,TYPE);/* <-' */ _init_mem_##TYPE##_(this); return this; } _init_mem_##TYPE##_(this_is(TYPE)) #define create_list(ID1,I2,TYPE) create_mem(ID1,TYPE); struct TYPE *ID2=((ID1->__next=NULL),ID1) -#define create_str(ID,EXPR) char *ID=(EXPR) -#define new_str(ID,...) char *ID=_cll1_get_str(__VA_ARGS__,NIL) -#define def_str(ID) char *ID=NULL -#define get_str(...) _cll1_get_str(__VA_ARGS__,NIL) #define create_context(ID) create_mem(ID,_CTXAtom) #define def_context(ID) def_mem(ID,_CTXAtom) #define list(TYPE) struct TYPE *__next @@ -106,6 +105,7 @@ /* .----------------------------------------------------------------------. / 5. C<<1 string manipulation, updated 2008-01-26 xCh. '----------------------------------------------------------------------- */ +#define get_str(...) _cll1_get_str(__VA_ARGS__,NIL) #define eq(A,B) !_cll1_strcmp(A,B) #define eqi(A,B) !_cll1_strcmpi(A,B) #define in_str(A,B) _cll1_strstr(A,B) @@ -147,13 +147,13 @@ #define for_search(NODE,HEAD,EXPR) for_each(NODE,HEAD) if(EXPR) #define for_file_lines(STR,FNAME) /* _NEW(CTX,get_context()) file_read(FNAME) for(use_context(_CTX),STR=file_line(_F);release_context(_M),(*S && !feof(_F));STR=file_line(_F),end_context()) _CATCH */ #define for_input_lines(S,L) /* _NEW(CTX,get_context()) for(use_context(_CTX),STR=file_get_line(stdin);release_context(_M),(*S && !feof(stdin));STR=file_get_line(stdin)) _CATCH */ -#define for_ints(VAR,...) _NEW(I,0) while( (VAR=_cll1_for_ints(_I++,__VA_ARGS__,-1))>=0 ) +#define for_ints(VAR,...) _NEW(I,0) while( (VAR=_cll1_for_ints(_I++,__VA_ARGS__,WEIRDINT))!=WEIRDINT ) #define for_strs(VAR,...) _NEW(I,0) while( (VAR=(char *)_cll1_for_ptrs(_I++,__VA_ARGS__,NIL))!=NIL ) #define for_args _NEW(I,1) while(_I++1) #define switch_for_args for_args switch_str(this_arg) #define switch_str(STR) _NEW(S,STR) @@ -194,7 +194,7 @@ #define _ECHO void _cll1_echo(char *s,...) _CLL1_FECHO(stdout) #define _FECHO void _cll1_fecho(FILE *f,char *s,...) _CLL1_FECHO(f) #define _CLL1_OUT _PRINT _FPRINT _ECHO _FECHO -#define _FOR_INTS int _cll1_for_ints(int i, int n, ...) { int j=0;va_list ap; /* <-' */ va_start(ap,n); while(n>=0 && j++