On Mon, 18 Aug 2008 10:32:56 +0200, "Nick Schermer" <[EMAIL PROTECTED]> wrote:
> 2008/8/18 Jean-François Wauthy <[EMAIL PROTECTED]>:
> > On Thu, 2008-08-14 at 14:33 +0300, Jari Rahkonen wrote:
> >
> >> + if(value && value != "") {
> >
> > FYI, you're comparing pointers here.
> > strlen (value) > 0 would be better IMO.
>
> Is strlen NULL safe then?
>
> if (value && *value != '\0') is also a good way to check if the string
> is 'empty'.
Yeah, that's probably the best and most easy way and avoids any
problems with strlen() implementations which might crash on passed NULL
pointers (remember not everyone is using glibc).
In Geany, we have a little convenience macro for this:
#define NZV(ptr) ((ptr) && (ptr)[0])
NZV means non-zero-value and can be used as simple as this:
> + if(NZV(value)) {
maybe it's worth to add something similar to libxfce4util or so.
Regards,
Enrico
--
Get my GPG key from http://www.uvena.de/pub.asc
pgpC5LxZhFfby.pgp
Description: PGP signature
_______________________________________________ Xfce-i18n mailing list [email protected] http://foo-projects.org/mailman/listinfo/xfce-i18n
