#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 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)
{
const bool t = TRUE, f = FALSE;
bool l, m = MAYBE;
- def_str(s);
+ str s;
print("TRUE and FALSE =", btoa(t and f) );
print("TRUE or FALSE =", btoa(t or f) );
for_strs(s, "TRUE","false","yes","NO","True","FALSE","YES","no","Yes","No","1","0","abc","xyz","Eyes","Ears","rue","alse","oui","no","ano","ne"," ","NULL",NULL,EOL,"","ano","ne")
{
l = atob(s);
- echo("\"", s, "\"\tmeans ", btoa(l),EOL);
+ echo("\"", s, "\"\tmeans ", btoa(l), EOL);
}
}
program
{
int i;
- char *s;
+ str s;
echo("for_ints(i, 8,1,-2,745,-32,-64,27,4) ): ");
for_ints(i, 8,1,-2,745,-32,-64,27,4 ) printf(" [%d]",i);
mem Zaznam
{
int i;
- char *j;
+ str s;
list(Zaznam);
};
print("4x insert(zaznam,zaznamy,order_by,i);");
zaznam=get_mem(Zaznam);
zaznam->i=1;
- zaznam->j="ddd";
+ zaznam->s="ddd";
insert(zaznam,zaznamy,order_by,i);
zaznam=get_mem(Zaznam);
zaznam->i=3;
- zaznam->j="bbbbb";
+ zaznam->s="bbbbb";
insert(zaznam,zaznamy,order_by,i);
zaznam=get_mem(Zaznam);
zaznam->i=4;
- zaznam->j="e";
+ zaznam->s="e";
insert(zaznam,zaznamy,order_by,i);
zaznam=get_mem(Zaznam);
zaznam->i=2;
- zaznam->j="aaaa";
+ zaznam->s="aaaa";
insert(zaznam,zaznamy,order_by,i);
- for_each(zaznam,zaznamy) printf("i=%d, j=%s\n",zaznam->i,zaznam->j);
+ for_each(zaznam,zaznamy) printf("i=%d, s=%s\n",zaznam->i,zaznam->s);
print("1x append(zaznam,zaznamy);");
zaznam=get_mem(Zaznam);
zaznam->i=0;
- zaznam->j="ccc";
+ zaznam->s="ccc";
append(zaznam,zaznamy);
- for_each(zaznam,zaznamy) printf("i=%d, j=%s\n",zaznam->i,zaznam->j);
+ for_each(zaznam,zaznamy) printf("i=%d, s=%s\n",zaznam->i,zaznam->s);
print("sort(zaznam,zaznamy,desc_order_by,i);");
sort(zaznam,zaznamy,desc_order_by,i);
- for_each(zaznam,zaznamy) printf("i=%d, j=%s\n",zaznam->i,zaznam->j);
+ for_each(zaznam,zaznamy) printf("i=%d, s=%s\n",zaznam->i,zaznam->s);
- print("sort(zaznam,zaznamy,sort_by,j);");
- sort(zaznam,zaznamy,sort_by,j);
- for_each(zaznam,zaznamy) printf("i=%d, j=%s\n",zaznam->i,zaznam->j);
+ print("sort(zaznam,zaznamy,sort_by,s);");
+ sort(zaznam,zaznamy,sort_by,s);
+ for_each(zaznam,zaznamy) printf("i=%d, s=%s\n",zaznam->i,zaznam->s);
print("remove(zaznam,zaznamy,zaznam->i==1);");
remove(zaznam,zaznamy,zaznam->i==1);
- for_each(zaznam,zaznamy) printf("i=%d, j=%s\n",zaznam->i,zaznam->j);
+ for_each(zaznam,zaznamy) printf("i=%d, s=%s\n",zaznam->i,zaznam->s);
print("drop(zaznam,zaznamy);");
drop(zaznam,zaznamy);
- for_each(zaznam,zaznamy) printf("i=%d, j=%s\n",zaznam->i,zaznam->j);
+ for_each(zaznam,zaznamy) printf("i=%d, s=%s\n",zaznam->i,zaznam->s);
}