From: xchaos Date: Tue, 22 Jan 2008 09:49:53 +0000 (+0000) Subject: print and echo can now skip NULL strings... X-Git-Url: https://git.harvie.cz/?a=commitdiff_plain;h=dfe0680a93f0d1fd2cd668f3facd6c803af318ea;p=svn%2FCll1h%2F.git print and echo can now skip NULL strings... git-svn-id: https://dev.arachne.cz/repos/cll1h/trunk@21 4bb87942-c103-4e5a-b51c-0ebff58f8515 --- diff --git a/cll1.h b/cll1.h index 5305e3c..a5c4c9d 100644 --- a/cll1.h +++ b/cll1.h @@ -101,9 +101,9 @@ /* ------------------------------------------------------------------- */ /* 6. C<<1 va_list based library functions, updated 2008-01-22 by xCh. */ /* ------------------------------------------------------------------- */ -#define _ECHO void _echo(char *s, ... ) { va_list ap; for(va_start(ap,s);s;s=va_arg(ap,char *)) fputs(s,stdout); va_end(ap); } -#define print(...) _echo(__VA_ARGS__,"\n",NULL) -#define echo(...) _echo(__VA_ARGS__,NULL) +#define _ECHO void _cll1_print(int nl,char *s, ... ) { va_list ap; for(va_start(ap,s);s!=(void *)&_cll1_print;s=va_arg(ap,char *)) fputs(s?s:"",stdout); va_end(ap); if(nl) putchar('\n');} +#define print(...) _cll1_print(1,__VA_ARGS__,(void *)&_cll1_print) +#define echo(...) _cll1_print(0,__VA_ARGS__,(void *)&_cll1_print) /* ------------------------------------------------------------------- */ /* 8. C<<1 CGI and FASTCGI handling, updated 2008-01-16 by xCh. */ /* ------------------------------------------------------------------- */ diff --git a/demos/hello.c b/demos/hello.c index b59bc77..1713533 100644 --- a/demos/hello.c +++ b/demos/hello.c @@ -2,6 +2,6 @@ program { - echo("Hello ","world","! "); - print("Hello ","world","!"); + echo("Hello ","world",NULL,"! "); + print("Hello ",NULL,"world","!"); } diff --git a/demos/performance/test-performance b/demos/performance/test-performance index c752da4..8a69fac 100755 --- a/demos/performance/test-performance +++ b/demos/performance/test-performance @@ -6,19 +6,19 @@ make fputs clear cat print.py echo "Running..." -time ./print.py &> /dev/null +time ./print.py > /dev/null cat print.pl echo "Running..." -time ./print.pl &> /dev/null +time ./print.pl > /dev/null cat cll1-print.c echo "Running..." -time ./cll1-print &> /dev/null +time ./cll1-print > /dev/null cat printf.c echo "Running..." -time ./printf &> /dev/null +time ./printf > /dev/null cat puts.c echo "Running..." -time ./puts &> /dev/null +time ./puts > /dev/null cat fputs.c echo "Running..." -time ./fputs &> /dev/null +time ./fputs > /dev/null