A few more bugfixes in ical import
This commit is contained in:
parent
9a97689c48
commit
152bf6fe75
@ -1,3 +1,10 @@
|
|||||||
|
2008-09-24 Frederic Culot <frederic@culot.org>
|
||||||
|
|
||||||
|
* src/io.c (ical_read_note): do not create note if it has zero
|
||||||
|
length
|
||||||
|
|
||||||
|
* src/io.c (ical_datetime2long): function rewritten
|
||||||
|
|
||||||
2008-09-23 Frederic Culot <frederic@culot.org>
|
2008-09-23 Frederic Culot <frederic@culot.org>
|
||||||
|
|
||||||
* src/io.c: some fixes after ical import tests
|
* src/io.c: some fixes after ical import tests
|
||||||
|
60
src/io.c
60
src/io.c
@ -1,4 +1,4 @@
|
|||||||
/* $calcurse: io.c,v 1.38 2008/09/23 17:31:56 culot Exp $ */
|
/* $calcurse: io.c,v 1.39 2008/09/24 19:06:02 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
@ -1595,31 +1595,29 @@ ical_chk_header (FILE *fd, unsigned *lineno)
|
|||||||
static long
|
static long
|
||||||
ical_datetime2long (char *datestr, ical_vevent_e *type)
|
ical_datetime2long (char *datestr, ical_vevent_e *type)
|
||||||
{
|
{
|
||||||
const int NOTFOUND = -1, APPOINT_AWAITED = 5, EVENT_AWAITED = 3;
|
const int NOTFOUND = 0, FORMAT_DATE = 3, FORMAT_DATETIME = 5;
|
||||||
date_t date;
|
date_t date;
|
||||||
unsigned hour, min;
|
unsigned hour, min;
|
||||||
long datelong;
|
long datelong;
|
||||||
|
int format;
|
||||||
|
|
||||||
if (strchr (datestr, 'T') == NULL)
|
format = sscanf (datestr, "%04u%02u%02uT%02u%02u",
|
||||||
|
&date.yyyy, &date.mm, &date.dd, &hour, &min);
|
||||||
|
if (format == FORMAT_DATE)
|
||||||
{
|
{
|
||||||
if (type)
|
if (type)
|
||||||
*type = EVENT;
|
*type = EVENT;
|
||||||
if (sscanf (datestr, "%04u%02u%02u",
|
datelong = date2sec (date, 0, 0);
|
||||||
&date.yyyy, &date.mm, &date.dd) != EVENT_AWAITED)
|
|
||||||
datelong = NOTFOUND;
|
|
||||||
else
|
|
||||||
datelong = date2sec (date, 0, 0);
|
|
||||||
}
|
}
|
||||||
else
|
else if (format == FORMAT_DATETIME)
|
||||||
{
|
{
|
||||||
if (type)
|
if (type)
|
||||||
*type = APPOINTMENT;
|
*type = APPOINTMENT;
|
||||||
if (sscanf (datestr, "%04u%02u%02uT%02u%02u",
|
datelong = date2sec (date, hour, min);
|
||||||
&date.yyyy, &date.mm, &date.dd, &hour, &min)
|
}
|
||||||
!= APPOINT_AWAITED)
|
else
|
||||||
datelong = NOTFOUND;
|
{
|
||||||
else
|
datelong = NOTFOUND;
|
||||||
datelong = date2sec (date, hour, min);
|
|
||||||
}
|
}
|
||||||
return datelong;
|
return datelong;
|
||||||
}
|
}
|
||||||
@ -1827,7 +1825,7 @@ ical_read_rrule (FILE *log, char *rrulestr, unsigned *noskipped,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
unsigned count;
|
unsigned count;
|
||||||
|
|
||||||
if (sscanf (p, "COUNT=%u", &count) != 1)
|
if (sscanf (p, "COUNT=%u", &count) != 1)
|
||||||
{
|
{
|
||||||
rpt->until = 0;
|
rpt->until = 0;
|
||||||
@ -1941,10 +1939,19 @@ ical_read_note (char *first_line, FILE *fdi, unsigned *noskipped,
|
|||||||
(*noskipped)++;
|
(*noskipped)++;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
fprintf (fdo, "%s", notestr);
|
else if (strlen (notestr) == 0)
|
||||||
fclose (fdo);
|
{
|
||||||
mem_free (notestr);
|
fclose (fdo);
|
||||||
return notename;
|
erase_note (¬ename, ERASE_FORCE);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf (fdo, "%s", notestr);
|
||||||
|
fclose (fdo);
|
||||||
|
mem_free (notestr);
|
||||||
|
return notename;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1975,7 +1982,6 @@ static void
|
|||||||
ical_read_event (FILE *fdi, FILE *log, unsigned *noevents, unsigned *noapoints,
|
ical_read_event (FILE *fdi, FILE *log, unsigned *noevents, unsigned *noapoints,
|
||||||
unsigned *noskipped, unsigned *lineno)
|
unsigned *noskipped, unsigned *lineno)
|
||||||
{
|
{
|
||||||
const int NOTFOUND = -1;
|
|
||||||
const int ITEMLINE = *lineno;
|
const int ITEMLINE = *lineno;
|
||||||
const string_t endevent = STRING_BUILD ("END:VEVENT");
|
const string_t endevent = STRING_BUILD ("END:VEVENT");
|
||||||
const string_t summary = STRING_BUILD ("SUMMARY:");
|
const string_t summary = STRING_BUILD ("SUMMARY:");
|
||||||
@ -2085,11 +2091,9 @@ ical_read_event (FILE *fdi, FILE *log, unsigned *noevents, unsigned *noapoints,
|
|||||||
{
|
{
|
||||||
if (strncmp (buf_upper, dtstart.str, dtstart.len) == 0)
|
if (strncmp (buf_upper, dtstart.str, dtstart.len) == 0)
|
||||||
{
|
{
|
||||||
if ((p = strchr (buf, ':')) == NULL)
|
if ((p = strchr (buf, ':')) != NULL)
|
||||||
vevent.start = NOTFOUND;
|
|
||||||
else
|
|
||||||
vevent.start = ical_datetime2long (++p, &vevent_type);
|
vevent.start = ical_datetime2long (++p, &vevent_type);
|
||||||
if (vevent.start == NOTFOUND)
|
if (!vevent.start)
|
||||||
{
|
{
|
||||||
ical_log (log, ICAL_VEVENT, ITEMLINE,
|
ical_log (log, ICAL_VEVENT, ITEMLINE,
|
||||||
_("could not retrieve event start time."));
|
_("could not retrieve event start time."));
|
||||||
@ -2098,11 +2102,9 @@ ical_read_event (FILE *fdi, FILE *log, unsigned *noevents, unsigned *noapoints,
|
|||||||
}
|
}
|
||||||
else if (strncmp (buf_upper, dtend.str, dtend.len) == 0)
|
else if (strncmp (buf_upper, dtend.str, dtend.len) == 0)
|
||||||
{
|
{
|
||||||
if ((p = strchr (buf, ':')) == NULL)
|
if ((p = strchr (buf, ':')) != NULL)
|
||||||
vevent.end = NOTFOUND;
|
|
||||||
else
|
|
||||||
vevent.end = ical_datetime2long (++p, &vevent_type);
|
vevent.end = ical_datetime2long (++p, &vevent_type);
|
||||||
if (vevent.end == NOTFOUND)
|
if (!vevent.end)
|
||||||
{
|
{
|
||||||
ical_log (log, ICAL_VEVENT, ITEMLINE,
|
ical_log (log, ICAL_VEVENT, ITEMLINE,
|
||||||
_("could not retrieve event end time."));
|
_("could not retrieve event end time."));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user