Hi, Thanks, I don't see how I could use memcmp() for most cases, except a few. Probably something distracted me in the middle. However, this means that all timestamps in September, October, November and December will be parsed incorrectly. Good catch. Applied to 3.3. On Sat, 2011-09-03 at 00:39 +0200, Gergely Nagy wrote:
When parsing the month name in scan_month_abbrev(), use memcmp() in all cases to compare only the first three chars. Using strcmp() will always result in us taking the false branch on well-formed timestamps, as it will scan past the 3-char length.
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org> --- lib/str-format.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/str-format.c b/lib/str-format.c index 6c974ba..9011461 100644 --- a/lib/str-format.c +++ b/lib/str-format.c @@ -200,19 +200,19 @@ scan_month_abbrev(const gchar **buf, gint *left, gint *mon) *mon = 7; break; case 'S': - if (strcmp(*buf, "Sep") == 0) + if (memcmp(*buf, "Sep", 3) == 0) *mon = 8; break; case 'O': - if (strcmp(*buf, "Oct") == 0) + if (memcmp(*buf, "Oct", 3) == 0) *mon = 9; break; case 'N': - if (strcmp(*buf, "Nov") == 0) + if (memcmp(*buf, "Nov",3 ) == 0) *mon = 10; break; case 'D': - if (strcmp(*buf, "Dec") == 0) + if (memcmp(*buf, "Dec", 3) == 0) *mon = 11; break; default:
-- Bazsi