aboutsummaryrefslogtreecommitdiff
path: root/libsylph/procheader.c
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2013-02-15 05:52:17 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2013-02-15 05:52:17 +0000
commit7f04d84320ef08ae159b6c32b484c6732d8443ef (patch)
tree659568cfd2f4f45efa3e6bf42a9408ad8a0d2409 /libsylph/procheader.c
parent58c6dc0f1481791c028fc61975f3d917c3053d45 (diff)
optimized date string scan
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@3230 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'libsylph/procheader.c')
-rw-r--r--libsylph/procheader.c32
1 files changed, 8 insertions, 24 deletions
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;
}