From 4643aeafd08c5503aaa7d5960b3e74ad2e63becb Mon Sep 17 00:00:00 2001 From: xchaos Date: Mon, 4 Feb 2008 01:46:42 +0000 Subject: [PATCH] lot of work - def_mem(), uses locale.h + strcoll(), etc. git-svn-id: https://dev.arachne.cz/repos/cll1h/trunk@57 4bb87942-c103-4e5a-b51c-0ebff58f8515 --- cll1.h | 155 ++++++++++++++++++++++++++++---------------------- demos/eq.c | 27 +++++++++ demos/hello.c | 3 +- demos/lists.c | 95 ++++++++++++++++--------------- 4 files changed, 165 insertions(+), 115 deletions(-) create mode 100644 demos/eq.c diff --git a/cll1.h b/cll1.h index 1d95db2..eaff9a1 100644 --- a/cll1.h +++ b/cll1.h @@ -18,7 +18,6 @@ You should have received a copy of the GNU Lesser General Public License along with C<<1 header file; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ #ifndef _CLL1_H #define _CLL1_H @@ -43,6 +42,7 @@ #include #include #include +#include #ifdef USE_LIBRARY_FASTCGI #include #else @@ -53,26 +53,34 @@ #include #endif /* .----------------------------------------------------------------------. - / 1. C<<1 then buddhist section, updated 2008-02-01 xCh. + / 0. C<<1 typedefs and public gloabl variables, updated 2008-02-03 xCh. + '----------------------------------------------------------------------- */ +typedef char * str; +/* Note: we may later #ifdef USE_MODULE_UNICODE .. typedef wchar_t * str; */ +typedef char * buffer; +/* Note: this could be buf instead of buffer, like str instead of string. */ +typedef FILE * file; +typedef int bool; +extern str NIL,EOL,OFS,IFS; +extern unsigned RANDOM_SEED; +#define _EXPORT_GLOBALS str NIL="NULL", EOL="\n", OFS=" ", IFS=" \t\n"; unsigned RANDOM_SEED=0; +/* .----------------------------------------------------------------------. + / 1. C<<1 then buddhist section, updated 2008-02-03 xCh. '----------------------------------------------------------------------- */ #ifndef DISABLE_MODULE_THEN_BUDDHISM #define then #define MAYBE (int)((long)(RANDOM_SEED?random():((RANDOM_SEED=(unsigned)time(NULL)),srandom(RANDOM_SEED),random()))%2) #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 str YES="TRUE\nYES\nJA\nOUI\nDA\nANO\nY\n1"; +#define samsara(MIND,SOUL) for(MIND=SOUL; MIND || ((MIND->__next=SOUL),0) ; MIND=MIND->__next) //#define atob(EXPR) (word_in_stri(YES,(EXPR))?1:0) +//#define _EXPORT_YES str YES="TRUE\nYES\nJA\nOUI\nDA\nANO\nY\n1"; //#else -#define _CLL1_YES str YES="TRUE"; #define atob(EXPR) (eqi((EXPR),YES)?1:0) +#define _EXPORT_YES str YES="TRUE"; #endif /* .----------------------------------------------------------------------. / 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 || @@ -81,34 +89,29 @@ typedef int bool; #define WEIRDINT (1<<(sizeof(int)*8-1)) #define btoa(EXPR) ((EXPR)?"TRUE":"FALSE") #define coalesce(VAR,EXPR) (VAR?VAR:(EXPR)) -#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 mem struct -#define this_is(TYPE) struct *TYPE this -#define create_mem(ID,...) struct _ARG1(__VA_ARGS__,) *ID=get_mem(__VA_ARGS__) -#define new_mem(ID,...) struct _ARG1(__VA_ARGS__,) *ID=init_mem(__VA_ARGS__) -#define def_mem(ID,TYPE) struct TYPE *ID=NULL -#define def_mems(ID1,ID2,TYPE) struct TYPE *ID1=NULL, *ID2=NULL -#define get_mem(...) (struct _ARG1(__VA_ARGS__,)*)_cll1_malloc(sizeof(struct _ARG1(__VA_ARGS__,)), _ARG2(__VA_ARGS__,,) - 0 ) -#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_context(ID) create_mem(ID,_CTXAtom) -#define def_context(ID) def_mem(ID,_CTXAtom) -#define list(TYPE) struct TYPE *__next -#define tree(TYPE) struct TYPE *__next; struct TYPE *__seek -#define dictionary(TYPE) struct TYPE *__next; struct TYPE *__seek; char *__key -#define array(TYPE) struct TYPE *__next; struct TYPE *__seek; int __key +#define def_mem(TYPE) typedef struct _##TYPE##_t * TYPE; struct _##TYPE##_t +#define get_mem(...) _GET_MEM(__VA_ARGS__,NULL) +#define create_mem(ID,...) _ARG1(__VA_ARGS__,) ID=_GET_MEM(__VA_ARGS__,NULL) +#define new_mem(ID,...) _ARG1(__VA_ARGS__,) ID=init_mem(__VA_ARGS__) +#define init_mem(...) _ARG1(__VA_ARGS__,)_construct( _ARG2(__VA_ARGS__,,) - 0 ) +#define construct_mem(TYPE) TYPE TYPE##_init(void) { create_mem(this,TYPE); /* <-' */ _##TYPE##_init(this); return this; } _##TYPE##_init(TYPE this) +#define list(TYPE) TYPE __next +#define tree(TYPE) TYPE __next; TYPE __seek +#define dictionary(TYPE) TYPE __next; TYPE __seek; str __key +#define array(TYPE) struct TYPE __next; TYPE __seek; int __key #define interface(TYPE) struct TYPE *__interface +#define this_must_be(TYPE) TYPE this /* .----------------------------------------------------------------------. / 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 len(...) __cll1__strlen(__VA_ARGS__,NIL) +#define eq(A,B) (A && ((B && !strcmp(A,B)) || !B)) +#define eqi(A,B) (A && ((B && !strcasecmp(A,B)) || !B)) +#define in_str(A,B) _cll1_str_str(A,B) #define word_in_str(A,B) _cll1_wordinstr(A,B,0) #define print(...) _cll1_print(__VA_ARGS__,NIL) #define fprint(...) _cll1_fprint(__VA_ARGS__,NIL) @@ -129,12 +132,13 @@ typedef int bool; #define drop(NODE,HEAD) for( NODE=HEAD; NODE || (HEAD=NULL); HEAD=NODE, NODE=NODE->__next, free(HEAD) ) //to do: seek //to do: store +#define count(NODE,HEAD,VAR) { _NEW(I,0) for(NODE=HEAD; NODE || ((VAR=_I),0) ; (NODE=NODE->__next)?(_I++):0 ); } #define order_by(K1,K2) (K1>K2) #define desc_order_by(K1,K2) (K10) -#define desc_sort_by(K1,K2) (_cll1_strcmpi(K1,K2)<0) -#define ascii_by(K1,K2) (_cll1_strcmp(K1,K2)>0) -#define desc_ascii_by(K1,K2) (_cll1_strcmp(K1,K2)<0) +#define sort_by(K1,K2) (_cll1_str_cmp(K1,K2)>0) +#define desc_sort_by(K1,K2) (_cll1_str_cmp(K1,K2)<0) +#define ascii_by(K1,K2) (strcmp(K1,K2)>0) +#define desc_ascii_by(K1,K2) (strcmp(K1,K2)<0) #define insert(NODE,HEAD,EXP,K) { if(HEAD) { void **_L=NULL, *H=HEAD; /* <-' */ for_search(HEAD,H,EXP(HEAD->K,NODE->K)) { if(_L) {*_L=NODE; NODE->__next=HEAD; } else push(NODE,H); break; } else _L=(void *)&(HEAD->__next); if(!HEAD)*_L=NODE; HEAD=H; } else if (NODE) { push(NODE,HEAD); HEAD->__next=NULL; } } #define sort(NODE,HEAD,EXP,K) { void *_NEXT; /* <-' */ NODE=HEAD; HEAD=NULL; do { _NEXT=NODE->__next; NODE->__next=NULL; insert(NODE,HEAD,EXP,K); NODE=_NEXT; } while(_NEXT); } /* .----------------------------------------------------------------------. @@ -168,18 +172,18 @@ typedef int bool; /* .----------------------------------------------------------------------. / 8. C<<1 object oriented infrastructure, updated 2008-01-31 '----------------------------------------------------------------------- */ -#define my_self(TYPE) struct *TYPE self, void *_method -#define we_are(TYPE) struct *TYPE _self, void *_method -#define anonymous void *_self, void *_method -#define I_am(TYPE) struct TYPE *self=(struct TYPE *)_self -#define def_community(METATYPE,ITYPE) struct METATYPE { struct ITYPE *__interface; }; -#define construct_interface(MTYPE,ITYPE) struct ITYPE *_interface_##MTYPE##ITYPE(void *dummy, ...) { def_mem(_FACE,ITYPE); va_list(ap); _bind_##MTYPE##ITYPE(_FACE); return _FACE; } void _bind_##MTYPE##ITYPE(struct IFACE *_FACE) +#define I_must_be(TYPE) TYPE self, void *_method +#define we_can_be(TYPE) TYPE _we, void *_method +#define we_can_be_whatever void *_we, void *_method +#define I_am(TYPE) TYPE self=(TYPE)_we +#define def_community(METATYPE,ITYPE) def_mem(METATYPE) { ITYPE __interface; }; +#define construct_interface(MTYPE,ITYPE) ITYPE _init_##MTYPE##ITYPE(void *dummy, ...) { new_mem(_FACE,ITYPE); va_list(ap); _##MTYPE##ITYPE##_init(_FACE); return _FACE; } void _##MTYPE##ITYPE##_init(struct IFACE *_FACE) #define bind_method(METHOD,FUNCTION) _FACE->METHOD=FUNCTION -#define new_interface(ID,MTYPE,...) struct _ARG1(__VA_ARGS__,) *ID=_interface_##MTYPE##_ARG1(__VA_ARGS__,) ((void *)__get_##TYPE##__VA_ARGS__,) +#define new_interface(ID,MTYPE,...) _ARG1(__VA_ARGS__,) ID=_init_##MTYPE##_ARG1(__VA_ARGS__,) ((void *)init_##MTYPE##__VA_ARGS__,) #define init_interface(TYPE,...) -#define construct_object(TYPE,...) (struct _ARG2(__VA_ARGS__,TYPE,) *)_object_##TYPE##_() -#define init_object(TYPE,...) (struct TYPE *)_object_##TYPE##_(__VA_ARGS__) -#define init_polymorph(TYPE,...) _object_##TYPE##_(__VA_ARGS__) +#define construct_object(TYPE,...) (struct _ARG2(__VA_ARGS__,TYPE,) *)_init_##TYPE##_() +#define init_object(TYPE,...) (TYPE)_init_##TYPE##_(__VA_ARGS__) +#define init_polymorph(TYPE,...) _init_##TYPE##_(__VA_ARGS__) #define _(OBJECT,...) ( _ASSERT(OBJECT), (*( OBJECT->interface->_ARG1(__VA_ARGS__,) )) ( OBJECT,OBJECT->interface->__VA_ARGS__ ) ) #define __(OBJECT,...) ( _ASSERT(OBJECT), (*( __cll1_seekmethod(OBJECT->interface,_ARG1(__VA_ARGS__,)) )) ( OBJECT,OBJECT->interface->__VA_ARGS__ ) ) #define call(OBJTYPE,METHOD,...) { int _N=0; struct OBJTYPE *_OBJ; /* <-' */ while( (_OBJ=(struct OBJTYPE *)_cll1_for_ptrs(_N++,__VA_ARGS__,NIL))!=(struct OBJTYPE *)NIL ) _(_OBJ,METHOD); } @@ -188,36 +192,51 @@ typedef int bool; '----------------------------------------------------------------------- */ #define _MALLOC void *_cll1_malloc(size_t size,...) { /*temporary solution*/ return malloc(size); } #define _CLL1_FPRINT(IOSTREAM) { int ofs=0; va_list ap; /* <-' */ for(va_start(ap,s);s!=NIL;s=va_arg(ap,char *)) { if(ofs)fputs(OFS,IOSTREAM);else ofs=1;/**/fputs(coalesce(s,NIL),IOSTREAM); } va_end(ap); fputs(EOL,IOSTREAM); } -#define _PRINT void _cll1_print(char *s,...) _CLL1_FPRINT(stdout) -#define _FPRINT void _cll1_fprint(FILE *f,char *s,...) _CLL1_FPRINT(f) +#define _DECLARE_PRINT void _cll1_print(char *s,...) +#define _PRINT _DECLARE_PRINT _CLL1_FPRINT(stdout) +#define _DECLARE_FPRINT void _cll1_fprint(FILE *f,char *s,...) +#define _FPRINT _DECLARE_FPRINT _CLL1_FPRINT(f) #define _CLL1_FECHO(IOSTREAM) { va_list ap; /* <-' */ for(va_start(ap,s);s!=NIL;s=va_arg(ap,char *)) fputs(coalesce(s,NIL),IOSTREAM); va_end(ap); } #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!=WEIRDINT && j++NAME=(VALUE),_##NAME##atom->C=1,push(_##NAME##atom,_##NAME##stack);_##NAME##atom->C||(pop(_##NAME##atom,_##NAME##stack),0);_##NAME##atom->C--) #define _I (_Iatom->I) #define _S (_Satom->S) -#define _F (_Satom->F) +#define _F (_Fatom->F) #define _CTX (_CTXatom->CTX) +#define _ARG1(ARG1,...) ARG1 +#define _ARG2(ARG1,ARG2,...) ARG2 +#define _GET_MEM(TYPE,CTX) ((TYPE)_cll1_malloc(sizeof(struct _##TYPE##_t),CTX)) +#define _ANYATOM(TYPE,NAME) def_mem(_##NAME##Atom ) { TYPE NAME; int c; list( _##NAME##Atom ); } #define _FOR_COLUMNS(A,B,C) _NEW(I,0) for( prefix(A,B,C) ; A ; ((A!=B)&&prefix(A,B,C)||(A=NULL) ),_I++ ) #define _FOR_VALID_COLUMNS(A,B,C) _NEW(I,0) for( prefix(A,B,C) ; A ; ((A!=B)&&prefix(A,B,C))||(A=NULL) ) if(*A&&++_I) +#define _NEW(NAME,VALUE) for(_##NAME##atom=get_mem(_##NAME##Atom),_##NAME##atom->NAME=(VALUE),_##NAME##atom->c=1,push(_##NAME##atom,_##NAME##stack);_##NAME##atom->c||(pop(_##NAME##atom,_##NAME##stack),0);_##NAME##atom->c--) +#define _ANYSTACK(NAME) _##NAME##Atom _##NAME##atom,_##NAME##stack=NULL; +#define _EXPORT_STACKS _ANYSTACK(I) _ANYSTACK(S) _ANYSTACK(F) _ANYSTACK(CTX) +_ANYATOM(int,I); +_ANYATOM(str,S); +_ANYATOM(FILE *,F); +_ANYATOM(void *,CTX); +/* .----------------------------------------------------------------------. + / 11. C<<1 memory contexts - alternative to garbage collection + '----------------------------------------------------------------------- */ +typedef _CTXAtom * context; +#define create_context(ID) create_mem(ID,context) /* .----------------------------------------------------------------------. - / 11. C<<1 CGI and FASTCGI handling, updated 2008-01-16 by xCh. + / 12. C<<1 CGI and FASTCGI handling, updated 2008-01-16 by xCh. '----------------------------------------------------------------------- */ #ifdef USE_LIBRARY_FASTCGI #define while_fastcgi_accept while(FCGI_Accept()>=0) @@ -232,7 +251,7 @@ typedef int bool; #define _CGI_GLOBALS #endif /* .----------------------------------------------------------------------. - / 12. MySQL wrappers + SQL object interface, updated 2007-12-19 by xCh. + / 13. MySQL wrappers + SQL object interface, updated 2007-12-19 by xCh. '----------------------------------------------------------------------- */ #ifdef USE_LIBRARY_MYSQL #define def_sql(CONN) MYSQL *CONN @@ -258,6 +277,7 @@ typedef int bool; //todo #define _SQL_OBJECT mem Sql { interface(SqlInterface); char *hostname; char *username; char *password; char *database; } //todo #define _SQL_CONSTRUCT def_construct(Sql) { self->hostname="localhost"; } //#endif + /* ------------------------------------------------------------------- */ /* old - from version 0.6 */ /* =================================================================== */ @@ -308,24 +328,23 @@ obsolete /* Useful structures, updated 2003-05-29 by xCh. */ //#define date(S) { time_t _T; _T=time(NULL); duplicate(ctime(&_T),S); } -/* ------------------------------------------------------------------- */ + /* some general ideas, unfinished */ //bind_exception, unbind_exception //#define _CLL1_THROW(ERR) //#define _CLL1_TRY _NEW_E for(bind_exception(0,NULL);;) if () {.... if(_Eatom->SYS) { if(_Eatom->RET) return; else break;} else { } //#define _ASSERT(EXPR) assert(EXPR) -/* =================================================================== */ /* .----------------------------------------------------------------------. / 99. We have have done our homework - now let's have some fun: '----------------------------------------------------------------------- */ -#define _DEF_VARIABLES _CLL1_GLOBALS _CLL1_YES _CLL1_STACKS _SQL_GLOBALS _CGI_GLOBALS -#define _DEF_FUNCTIONS _MALLOC _CLL1_OUT _CLL1_ARGS _CLL1_STRS // _GET_MEM -#define _DEF_INTERFACE //_SQL_IFC _CAKE_IFC _STD_IFC _X_IFC -#define _IMPLEMENT_CLL1_LIBRARY _DEF_VARIABLES _DEF_FUNCTIONS _DEF_INTERFACE +#define _INIT_VARIABLES _EXPORT_GLOBALS _EXPORT_YES _EXPORT_STACKS _SQL_GLOBALS _CGI_GLOBALS +#define _IMPL_FUNCTIONS _MALLOC _EXPORT_OUTS _EXPORT_ARGS _EXPORT_STRS +#define _IMPL_INTERFACE //_SQL_IFC _CAKE_IFC _STD_IFC _X_IFC +#define _IMPLEMENT_CLL1_LIBRARY _INIT_VARIABLES _IMPL_FUNCTIONS _IMPL_INTERFACE #ifdef USE_PREPROCESSOR #include "_include.c" #endif -#define program _IMPLEMENT_CLL1_LIBRARY int main(int argc, char **argv) -/* #ifndef _CLL1_H */ + +#define program _IMPLEMENT_CLL1_LIBRARY void _program(int argc, char **argv); int main(int argc, char **argv) { setlocale(LC_ALL, ""); _program(argc,argv); return 0; } void _program(int argc, char **argv) #endif diff --git a/demos/eq.c b/demos/eq.c new file mode 100644 index 0000000..730d0a7 --- /dev/null +++ b/demos/eq.c @@ -0,0 +1,27 @@ +#include "cll1.h" + +program +{ + str a,b; + + a="¾luklý"; + b="®LUKLÝ"; + printf("strcoll(\"%s\",\"%s\")=%d\n",a,b,strcoll(a,b)); + printf("eq(\"%s\",\"%s\")=%s\n",a,b,btoa(eq(a,b))); + printf("eqi(\"%s\",\"%s\")=%s\n",a,b,btoa(eqi(a,b))); + a="aabc"; + b="axyz"; + printf("strcoll(\"%s\",\"%s\")=%d\n",a,b,strcoll(a,b)); + printf("eq(\"%s\",\"%s\")=%s\n",a,b,btoa(eq(a,b))); + printf("eqi(\"%s\",\"%s\")=%s\n",a,b,btoa(eqi(a,b))); + a="ABC"; + b="abc"; + printf("strcoll(\"%s\",\"%s\")=%d\n",a,b,strcoll(a,b)); + printf("eq(\"%s\",\"%s\")=%s\n",a,b,btoa(eq(a,b))); + printf("eqi(\"%s\",\"%s\")=%s\n",a,b,btoa(eqi(a,b))); + a="abc"; + b="abc"; + printf("strcoll(\"%s\",\"%s\")=%d\n",a,b,strcoll(a,b)); + printf("eq(\"%s\",\"%s\")=%s\n",a,b,btoa(eq(a,b))); + printf("eqi(\"%s\",\"%s\")=%s\n",a,b,btoa(eqi(a,b))); +} diff --git a/demos/hello.c b/demos/hello.c index 1212211..be92852 100644 --- a/demos/hello.c +++ b/demos/hello.c @@ -2,6 +2,5 @@ program { - echo("Hello ",NULL,"world"," ! "); - print("Hello","world",NULL,"!"); + print("Vale Mundum!"); } diff --git a/demos/lists.c b/demos/lists.c index 2cc0c52..0f36e64 100644 --- a/demos/lists.c +++ b/demos/lists.c @@ -1,55 +1,60 @@ #include "cll1.h" -mem Zaznam +def_mem(Record) { int i; str s; - list(Zaznam); + list(Record); }; program { - def_mems(zaznam,zaznamy,Zaznam); - - print("4x insert(zaznam,zaznamy,order_by,i);"); - zaznam=get_mem(Zaznam); - zaznam->i=1; - zaznam->s="ddd"; - insert(zaznam,zaznamy,order_by,i); - zaznam=get_mem(Zaznam); - zaznam->i=3; - zaznam->s="bbbbb"; - insert(zaznam,zaznamy,order_by,i); - zaznam=get_mem(Zaznam); - zaznam->i=4; - zaznam->s="e"; - insert(zaznam,zaznamy,order_by,i); - zaznam=get_mem(Zaznam); - zaznam->i=2; - zaznam->s="aaaa"; - insert(zaznam,zaznamy,order_by,i); - 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->s="ccc"; - append(zaznam,zaznamy); - 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, s=%s\n",zaznam->i,zaznam->s); - - 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, s=%s\n",zaznam->i,zaznam->s); - - print("drop(zaznam,zaznamy);"); - drop(zaznam,zaznamy); - for_each(zaznam,zaznamy) printf("i=%d, s=%s\n",zaznam->i,zaznam->s); + Record record,records=NULL; + + print("4x insert(record,records ,order_by,i);"); + + record=get_mem(Record); + record->i=1; + record->s="ddd"; + insert(record,records ,order_by,i); + + record=get_mem(Record); + record->i=3; + record->s="bbbbb"; + insert(record,records ,order_by,i); + + record=get_mem(Record); + record->i=4; + record->s="e"; + insert(record,records ,order_by,i); + + record=get_mem(Record); + record->i=2; + record->s="aaaa"; + insert(record,records ,order_by,i); + + for_each(record,records ) printf("i=%d, s=%s\n",record->i,record->s); + + print("1x append(record,records );"); + record=get_mem(Record); + record->i=0; + record->s="ccc"; + append(record,records ); + for_each(record,records ) printf("i=%d, s=%s\n",record->i,record->s); + + print("sort(record,records ,desc_order_by,i);"); + sort(record,records ,desc_order_by,i); + for_each(record,records ) printf("i=%d, s=%s\n",record->i,record->s); + + print("sort(record,records ,sort_by,s);"); + sort(record,records ,sort_by,s); + for_each(record,records ) printf("i=%d, s=%s\n",record->i,record->s); + + print("remove(record,records ,record->i==1);"); + remove(record,records ,record->i==1); + for_each(record,records ) printf("i=%d, s=%s\n",record->i,record->s); + + print("drop(record,records );"); + drop(record,records ); + for_each(record,records ) printf("i=%d, s=%s\n",record->i,record->s); } -- 2.30.2