ok, let's start making sense now: typdef char * str;
[svn/Cll1h/.git] / cll1.h
diff --git a/cll1.h b/cll1.h
index 08a9a8e37d2e4561b9cb2a83b7693fc0bf0e4f73..1d95db282f7c933a3218ddc412e6e444475b143b 100644 (file)
--- a/cll1.h
+++ b/cll1.h
@@ -53,7 +53,7 @@
 #include <mysql/mysql.h>
 #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
 #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.
  '----------------------------------------------------------------------- */
 #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
 /* .----------------------------------------------------------------------.
   /  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)
 #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++<argc)
 #define this_arg argv[_I]
 #define next_arg ((_I+1<argc)?argv[_I]:NULL)
 #define skip_next _I++
-#define if_exists(A,B,C) for_search(A,B,C) break; if(A)
+#define if_exists(NODE,HEAD,EXPR) for_search(NODE,HEAD,EXPR) break; if(NODE)
 #define if_args if(argc>1)
 #define switch_for_args  for_args switch_str(this_arg)
 #define switch_str(STR) _NEW(S,STR)
 #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++<i) n=va_arg(ap,int); return n; }
+#define _FOR_INTS int _cll1_for_ints(int i, int n, ...) { int j=0;va_list ap; /* <-' */ va_start(ap,n); while(n!=WEIRDINT && j++<i) n=va_arg(ap,int); return n; }
 #define _FOR_PTRS void *_cll1_for_ptrs(int i, void *v, ...) { int j=0;va_list ap; /* <-' */ va_start(ap,v); while(v!=(void *)NIL && j++<i) v=va_arg(ap,void *); return v; }
 #define _CLL1_ARGS _FOR_INTS _FOR_PTRS
 #define _STRCMP int _cll1_strcmp(char *a,char *b) { if(a && b) return strcmp(a,b); else return (int)(a-b); }
This page took 0.152679 seconds and 4 git commands to generate.