From 9ae3b2218ffacd28b7bfccaa23d804fb0d399f9b Mon Sep 17 00:00:00 2001 From: xchaos Date: Fri, 1 Feb 2008 22:57:18 +0000 Subject: [PATCH] WEIRDINT constant added -> for_ints() interator now accepts negative integers git-svn-id: https://dev.arachne.cz/repos/cll1h/trunk@53 4bb87942-c103-4e5a-b51c-0ebff58f8515 --- cll1.h | 5 +++-- demos/for_ints_strs.c | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/cll1.h b/cll1.h index 08a9a8e..b3c65a4 100644 --- a/cll1.h +++ b/cll1.h @@ -76,6 +76,7 @@ #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; @@ -147,7 +148,7 @@ #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++=0 && j++