From a9f52f78abae798a11d7a5a8a2a2564384831ea9 Mon Sep 17 00:00:00 2001 From: Tomi Ollila Date: Mon, 2 Mar 2015 22:03:55 +0200 Subject: [PATCH] Re: [PATCH 4/4] parse-time-string: fix setting and rounding of seconds --- 85/85adefb81133f7a787c9342b7ec090b5e8212d | 116 ++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 85/85adefb81133f7a787c9342b7ec090b5e8212d diff --git a/85/85adefb81133f7a787c9342b7ec090b5e8212d b/85/85adefb81133f7a787c9342b7ec090b5e8212d new file mode 100644 index 000000000..d640a7c4f --- /dev/null +++ b/85/85adefb81133f7a787c9342b7ec090b5e8212d @@ -0,0 +1,116 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 0872D431FAF + for ; Mon, 2 Mar 2015 12:06:59 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 2.438 +X-Spam-Level: ** +X-Spam-Status: No, score=2.438 tagged_above=-999 required=5 + tests=[DNS_FROM_AHBL_RHSBL=2.438] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 21kVHJyYQ9Uj for ; + Mon, 2 Mar 2015 12:06:55 -0800 (PST) +Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) + by olra.theworths.org (Postfix) with ESMTP id AD8AC431FAE + for ; Mon, 2 Mar 2015 12:06:55 -0800 (PST) +Received: from guru.guru-group.fi (localhost [IPv6:::1]) + by guru.guru-group.fi (Postfix) with ESMTP id B86521000E7; + Mon, 2 Mar 2015 22:03:55 +0200 (EET) +From: Tomi Ollila +To: Jani Nikula , notmuch@notmuchmail.org +Subject: Re: [PATCH 4/4] parse-time-string: fix setting and rounding of + seconds +In-Reply-To: <1425318424-27017-4-git-send-email-jani@nikula.org> +References: <1425318424-27017-1-git-send-email-jani@nikula.org> + <1425318424-27017-4-git-send-email-jani@nikula.org> +User-Agent: Notmuch/0.19+53~gb45d2f9 (http://notmuchmail.org) Emacs/24.3.1 + (x86_64-unknown-linux-gnu) +X-Face: HhBM'cA~ +MIME-Version: 1.0 +Content-Type: text/plain +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Mon, 02 Mar 2015 20:06:59 -0000 + +On Mon, Mar 02 2015, Jani Nikula wrote: + +> If seconds are not specified in the string to be parsed, they're not +> set according to the reference time (in the no rounding case) nor +> rounded properly (in the rounding up cases). Fix this. +> +> The bug caused searches such as date:10:30..10:30 to match messages +> with date exactly 10:30:00 only, and not in range 10:30:00..10:30:59 +> (inclusive) as documented. +> +> Note that date searches referring "noon" or "5pm" will still be +> interpreted as exact to the second. + +Although I don't fully understands how these changes do the trick (and I +only looked the context) the changes *look* good, and presumably fix +the problem in question (I could check intermediate output but i am just +lazy). + +Tests pass and I don't see why anything could get broken by this so +1 + +Tomi + + +> --- +> parse-time-string/parse-time-string.c | 4 ++-- +> test/T490-parse-time-string.sh | 1 - +> 2 files changed, 2 insertions(+), 3 deletions(-) +> +> diff --git a/parse-time-string/parse-time-string.c b/parse-time-string/parse-time-string.c +> index ccad422b3c8d..1cef47d4b0bd 100644 +> --- a/parse-time-string/parse-time-string.c +> +++ b/parse-time-string/parse-time-string.c +> @@ -1081,10 +1081,10 @@ parse_time (struct state *state, char sep, +> return set_user_tz (state, state->delim, v1, v2); +> } +> +> - if (!is_valid_time (v1, v2, v3)) +> + if (!is_valid_time (v1, v2, n3 ? v3 : 0)) +> return -PARSE_TIME_ERR_INVALIDTIME; +> +> - return set_abs_time (state, v1, v2, n3 ? v3 : 0); +> + return set_abs_time (state, v1, v2, n3 ? (int) v3 : UNSET); +> } +> +> /* strtoul helper that assigns length. */ +> diff --git a/test/T490-parse-time-string.sh b/test/T490-parse-time-string.sh +> index 9247bdf89543..6aa9d433bfd4 100755 +> --- a/test/T490-parse-time-string.sh +> +++ b/test/T490-parse-time-string.sh +> @@ -79,7 +79,6 @@ ${TEST_DIRECTORY}/parse-time --ref=${REFERENCE} < INPUT > OUTPUT +> test_expect_equal_file INPUT OUTPUT +> +> test_begin_subtest "Second rounding tests" +> -test_subtest_known_broken +> REFERENCE=$(_date Tue Jan 11 12:13:14 +0000 2011) +> cat < INPUT +> 9:15 ==> Tue Jan 11 09:15:14 +0000 2011 +> -- +> 2.1.4 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch -- 2.26.2