config parser
Peter Kümmel
syntheticpp at gmx.net
Tue Jun 26 03:51:34 PDT 2007
Havoc Pennington wrote:
> Hi,
>
> Peter Kümmel wrote:
>> Could we apply this patch?
>> We need the second NULL because we use [1] later on.
>> It also makes the code more readable.
>>
>
> I think two NULLs at the end is pretty weird; isn't there a better
> solution?
There will be only one NULL at the end, see
test_service_dir_matches[1] = _dbus_string_get_const_data(&progs);
static const char *test_service_dir_matches[] =
{
#ifdef DBUS_UNIX
"/testusr/testlocal/testshare/dbus-1/services",
"/testusr/testshare/dbus-1/services",
DBUS_DATADIR"/dbus-1/services",
"/testhome/foo/.testlocal/testshare/dbus-1/services",
NULL,
#else
DBUS_DATADIR"/dbus-1/services",
NULL,
NULL
#endif
};
static dbus_bool_t
test_default_session_servicedirs (void)
{
DBusList *dirs;
DBusList *link;
DBusString progs;
const char *common_progs;
int i;
/* On Unix we don't actually use this variable, but it's easier to handle the
* deallocation if we always allocate it, whether needed or not */
if (!_dbus_string_init (&progs))
_dbus_assert_not_reached ("OOM allocating progs");
common_progs = _dbus_getenv ("CommonProgramFiles");
#ifndef DBUS_UNIX
if (common_progs)
{
if (!_dbus_string_append (&progs, common_progs))
{
_dbus_string_free (&progs);
return FALSE;
}
if (!_dbus_string_append (&progs, "/dbus-1/services"))
{
_dbus_string_free (&progs);
return FALSE;
}
test_service_dir_matches[1] = _dbus_string_get_const_data(&progs);
}
#endif
And the Null is needed, i = 2:
if (test_service_dir_matches[i] != NULL)
{
printf ("extra data %s in the match set was not matched\n",
test_service_dir_matches[i]);
_dbus_string_free (&progs);
return FALSE;
}
>
> I'm not looking at the code right now, I'm on vacation until the end of
> the week.
>
> Havoc
>
--
Peter Kümmel
More information about the dbus
mailing list