From 7f04d84320ef08ae159b6c32b484c6732d8443ef Mon Sep 17 00:00:00 2001 From: hiro Date: Fri, 15 Feb 2013 05:52:17 +0000 Subject: optimized date string scan git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@3230 ee746299-78ed-0310-b773-934348b2243d --- ChangeLog | 4 ++++ libsylph/procheader.c | 32 ++++++++------------------------ 2 files changed, 12 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index f29ca997..be9eeaf3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2013-02-15 + + * procheader_scan_date_string(): optimized. + 2013-02-15 * libsylph/procheader.cprocheader_date_parse(): support ISO-type date diff --git a/libsylph/procheader.c b/libsylph/procheader.c index ec8667b4..a06ac701 100644 --- a/libsylph/procheader.c +++ b/libsylph/procheader.c @@ -809,34 +809,26 @@ static gint procheader_scan_date_string(const gchar *str, { gint result; + *zone = '\0'; result = sscanf(str, "%10s %d %9s %d %2d:%2d:%2d %5s", weekday, day, month, year, hh, mm, ss, zone); - if (result == 8) return 0; + if (result >= 7) return 0; result = sscanf(str, "%3s,%d %9s %d %2d:%2d:%2d %5s", weekday, day, month, year, hh, mm, ss, zone); - if (result == 8) return 0; + if (result >= 7) return 0; result = sscanf(str, "%3s,%d %9s %d %2d.%2d.%2d %5s", weekday, day, month, year, hh, mm, ss, zone); - if (result == 8) return 0; + if (result >= 7) return 0; result = sscanf(str, "%3s %d, %9s %d %2d:%2d:%2d %5s", weekday, day, month, year, hh, mm, ss, zone); - if (result == 8) return 0; + if (result >= 7) return 0; result = sscanf(str, "%d %9s %d %2d:%2d:%2d %5s", day, month, year, hh, mm, ss, zone); - if (result == 7) return 0; - - *zone = '\0'; - result = sscanf(str, "%10s %d %9s %d %2d:%2d:%2d", - weekday, day, month, year, hh, mm, ss); - if (result == 7) return 0; - - result = sscanf(str, "%d %9s %d %2d:%2d:%2d", - day, month, year, hh, mm, ss); - if (result == 6) return 0; + if (result >= 6) return 0; result = sscanf(str, "%d-%2s-%2d %2d:%2d:%2d", year, month, day, hh, mm, ss); @@ -845,19 +837,11 @@ static gint procheader_scan_date_string(const gchar *str, *ss = 0; result = sscanf(str, "%10s %d %9s %d %2d:%2d %5s", weekday, day, month, year, hh, mm, zone); - if (result == 7) return 0; + if (result >= 6) return 0; result = sscanf(str, "%d %9s %d %2d:%2d %5s", day, month, year, hh, mm, zone); - if (result == 6) return 0; - - result = sscanf(str, "%10s %d %9s %d %2d:%2d", - weekday, day, month, year, hh, mm); - if (result == 6) return 0; - - result = sscanf(str, "%d %9s %d %2d:%2d", - day, month, year, hh, mm); - if (result == 5) return 0; + if (result >= 5) return 0; return -1; } -- cgit v1.2.3