Re: More string stuff (was Nautilus Gtk stuff inventory)



Joe Shaw <joe@helixcode.com> writes:

> > -----------------
> > nautilus-string.h
> > -----------------
> >     nautilus_strlen (returns 0 for NULL, following g_strdup's lead of
> > allowing NULL)
> 
> Along these same lines, it seems that doing a g_strdup_printf("%s",
> NULL) crashes on some machines (Solaris). Seeing as glib is supposed to
> provide consistent results across architectures, this should probably be
> changed to return "(null)" or possibly "". It goes along with g_strdup's
> lead of allowing NULL.
> 
> Jacob seems to think that this is a severe enough problem that we might
> want to backport it to 1.2, since most developers probably assume this
> behavior and don't test on Solaris. It crashes on Solaris 2.7, but not on
> Linux x86, apparently.

I don't know of many people that expect sprintf("%s", NULL) to work
except maybe in debugging code.

Unfortunately, it's very hard to fix this without reimplementing
sprintf(), and reimplementing sprintf() is serious heavy stuff
when you worry about things like getting %f correct. (glibc uses
a multi-precision library for that)

[ As for lacks in cross-platform sprintf(), my concern would not be
  this, but the fact we can't rely on %1$s which is very useful for
  internationalization. ]

Regards,
                                        Owen




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