[libical] What I had to do to get the regression program to work on Windoze with libical-0.46.

andrew.marlow at uk.bnpparibas.com andrew.marlow at uk.bnpparibas.com
Tue Sep 7 04:07:50 PDT 2010


Now that I have got libical to build on windoze the next problem I found 
was that the regression test program core dumped. I have the fix, which 
involves changes to the file icaltimezone.c.

It was blowing up referencing through a null pointer because the routine 
icaltimezone_parse_zone_tab does not expect 
icaltzutil_get_zone_directory() or get_zone_directory() to return the null 
pointer. However, there might be no timezone information directories 
configured. Looking at this in the debugger revealed that it was going 
down the code path for UNIX timezone files.  It was calling set_zonedir, 
which has a list of UNIX directory names in which to look for zone.tab. 
This is wrong for Windoze, but revealed  icaltimezone_parse_zone_tab does 
not handle the case of no timezone files. I fixed it by changing the code 
to look like this:

    const char* zone_dir;

    icalerror_assert (builtin_timezones == NULL,
                      "Parsing zones.tab file multiple times");

    builtin_timezones = icalarray_new (sizeof (icaltimezone), 32);

#ifndef USE_BUILTIN_TZDATA
    zone_dir = icaltzutil_get_zone_directory();
    if (zone_dir == NULL)
    {
        return;
    }
    filename_len = strlen((char *)zone_dir) + strlen 
(ZONES_TAB_SYSTEM_FILENAME) + 2;
#else 
    zone_dir = get_zone_directory();
    if (zone_dir == NULL)
    {
        return;
    }
    filename_len = strlen(zone_dir) + strlen (ZONES_TAB_FILENAME) + 2;
#endif 

With this change in place, the regression test program ran ok. I would be 
grateful for peoples comments on this fix please. 
icaltzutil_get_zone_directory seems to expect that returning NULL is ok 
when there is no timezone directory. Otherwise it would raise an error, 
right?

I am also puzzled by why it doesn't call get_zone_directory, which has 
windoze-specific code for locating the directory. It looks like it might 
be to do with USE_BUILTIN_TZDATA not being defined. Also, it is looking 
for the file zone.tab, which does not seem to be in the distribution.

Regards,

Andrew Marlow

___________________________________________________________
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and delete this e-mail. Any unauthorised copying, disclosure or distribution of the material in this e-mail is prohibited.

Please refer to http://www.bnpparibas.co.uk/en/information/legal_information.asp?Code=ECAS-845C5H  for additional disclosures.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.infradead.org/pipermail/libical-interest/attachments/20100907/3f8a2886/attachment.html>


More information about the libical-interest mailing list