lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


In message <bnoobt$nhg$1@sea.gmane.org>, Philipp Janda writes:
> 
> > as we noted some time ago, the LuaCheia code has had this functionality. 
> > The code is still there, but currently not used (as it is pending to be 
> > made into a module)
> > http://cvs.sourceforge.net/viewcvs.py/luacheia/luacheia/src/libcheia/cheiaf
>>s.c?rev=1.17&view=auto 
> 
> I spotted a minor bug in the code above:
> 
> #define LC_ISPATHSEP(C) (C=="/" ? 1 : 0 )
>                           ^^^^^^
> should probably be C=='/' or strcmp( C, "/" )!=0
> 
> And the same for
> #define LC_ISPATHSEP(C) (C!="\\" ? (C=="/" ? 1 : 0 ) : 1)
>                           ^^^^^^^    ^^^^^^
> #define LC_ISPATHSEP(C) (C==":" ? 1 : 0 )
>                           ^^^^^^

I realise this is a lua list not a C list but aren't the above (aside
from the bug you pointed out) better written as:

#define LC_ISPATHSEP(C) ((C)=='/')
#define LC_ISPATHSEP(C) ((C)=='\\'||(C)=='/')
#define LC_ISPATHSEP(C) ((C)==':')

The middle one has a multiple evaluation issue which I won't bother
addressing.

Cheers,
 drj