From 6e5dc94b1b87fc8246f4b7da32efab4f996fec2a Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Mon, 2 Mar 2015 19:47:04 +0200 Subject: [PATCH] [PATCH 4/4] parse-time-string: fix setting and rounding of seconds --- bc/ff1d044526e69ea2a82b249ea620c0a008abb7 | 113 ++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 bc/ff1d044526e69ea2a82b249ea620c0a008abb7 diff --git a/bc/ff1d044526e69ea2a82b249ea620c0a008abb7 b/bc/ff1d044526e69ea2a82b249ea620c0a008abb7 new file mode 100644 index 000000000..404a90925 --- /dev/null +++ b/bc/ff1d044526e69ea2a82b249ea620c0a008abb7 @@ -0,0 +1,113 @@ +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 50AA8429E34 + for ; Mon, 2 Mar 2015 10:14:31 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 1.738 +X-Spam-Level: * +X-Spam-Status: No, score=1.738 tagged_above=-999 required=5 + tests=[DNS_FROM_AHBL_RHSBL=2.438, RCVD_IN_DNSWL_LOW=-0.7] + 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 OPvrJ9lOSwsH for ; + Mon, 2 Mar 2015 10:14:28 -0800 (PST) +Received: from mail-wi0-f175.google.com (mail-wi0-f175.google.com + [209.85.212.175]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 215A3414B87 + for ; Mon, 2 Mar 2015 09:49:34 -0800 (PST) +Received: by widex7 with SMTP id ex7so15943858wid.1 + for ; Mon, 02 Mar 2015 09:46:54 -0800 (PST) +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=1e100.net; s=20130820; + h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to + :references; + bh=yX764r3Ad6gCozhZVgLh37yD1RZazCV359veLPiXW0A=; + b=GyjcNVx2jMzSIfkcaXsjqZHNIHFkq850YLbA1u2BZHJMz0CkidHPyZZQyujUpWMQ8q + y8Jqx4a0vZDSupQ7Up4lKXQcX88cSWasqSiNpD3VvuW7act+ZUAQHNegnQUtBj3xqgoj + 30c9+z+LfMp1t090hXslHQhEEALhT1FzL6Z6Z7YMP508DhHLiP9Vh5arNgd05o29dk0D + MeOXeLeoZTjLa5VF5X2DTaU5+/8GC8fFtyhtkn77v8pnfhz/J/6/WrKB79zQu9k2ByOA + oTuFmKtjpY9rgmH3ame67RMsJdKdPMQ01dlZgdbWZhSIHpNRj4Ut1yjaX6CzRegqE+hZ + Ec/w== +X-Gm-Message-State: + ALoCoQl1wjZNtzW4nsM/VnP92uKTFdLRGszlVbIXbj7hyv133Xowzr9/Ra/amFJXYw2bJMLUomcF +X-Received: by 10.194.104.99 with SMTP id gd3mr1156869wjb.114.1425318414038; + Mon, 02 Mar 2015 09:46:54 -0800 (PST) +Received: from localhost (mobile-internet-bcee3b-76.dhcp.inet.fi. + [188.238.59.76]) + by mx.google.com with ESMTPSA id u6sm17034127wix.12.2015.03.02.09.46.53 + (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); + Mon, 02 Mar 2015 09:46:53 -0800 (PST) +From: Jani Nikula +To: notmuch@notmuchmail.org +Subject: [PATCH 4/4] parse-time-string: fix setting and rounding of seconds +Date: Mon, 2 Mar 2015 19:47:04 +0200 +Message-Id: <1425318424-27017-4-git-send-email-jani@nikula.org> +X-Mailer: git-send-email 2.1.4 +In-Reply-To: <1425318424-27017-1-git-send-email-jani@nikula.org> +References: <1425318424-27017-1-git-send-email-jani@nikula.org> +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 18:14:31 -0000 + +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. +--- + 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 + -- 2.26.2