From owner-svn-src-all@FreeBSD.ORG Sat Feb 2 06:06:40 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id CC678D00; Sat, 2 Feb 2013 06:06:40 +0000 (UTC) (envelope-from kientzle@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 9B691164; Sat, 2 Feb 2013 06:06:40 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r1266eCt027037; Sat, 2 Feb 2013 06:06:40 GMT (envelope-from kientzle@svn.freebsd.org) Received: (from kientzle@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r1266eFA027035; Sat, 2 Feb 2013 06:06:40 GMT (envelope-from kientzle@svn.freebsd.org) Message-Id: <201302020606.r1266eFA027035@svn.freebsd.org> From: Tim Kientzle Date: Sat, 2 Feb 2013 06:06:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r246229 - in head/contrib/libarchive/libarchive: . test X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Feb 2013 06:06:40 -0000 Author: kientzle Date: Sat Feb 2 06:06:39 2013 New Revision: 246229 URL: http://svnweb.freebsd.org/changeset/base/246229 Log: Fix an obvious typo that broke time specifications of the form "2 hours ago". Modified: head/contrib/libarchive/libarchive/archive_getdate.c head/contrib/libarchive/libarchive/test/test_archive_getdate.c Modified: head/contrib/libarchive/libarchive/archive_getdate.c ============================================================================== --- head/contrib/libarchive/libarchive/archive_getdate.c Sat Feb 2 06:01:57 2013 (r246228) +++ head/contrib/libarchive/libarchive/archive_getdate.c Sat Feb 2 06:06:39 2013 (r246229) @@ -369,8 +369,8 @@ relunitphrase(struct gdstate *gds) && gds->tokenp[1].token == tSEC_UNIT) { /* "1 day" */ gds->HaveRel++; - gds->RelSeconds += gds->tokenp[1].value * gds->tokenp[2].value; - gds->tokenp += 3; + gds->RelSeconds += gds->tokenp[0].value * gds->tokenp[1].value; + gds->tokenp += 2; return 1; } if (gds->tokenp[0].token == '-' @@ -403,7 +403,7 @@ relunitphrase(struct gdstate *gds) /* "now", "tomorrow" */ gds->HaveRel++; gds->RelSeconds += gds->tokenp[0].value; - ++gds->tokenp; + gds->tokenp += 1; return 1; } if (gds->tokenp[0].token == tMONTH_UNIT) { @@ -1022,10 +1022,11 @@ int main(int argc, char **argv) { time_t d; + time_t now = time(NULL); while (*++argv != NULL) { (void)printf("Input: %s\n", *argv); - d = get_date(*argv); + d = get_date(now, *argv); if (d == -1) (void)printf("Bad format - couldn't convert.\n"); else Modified: head/contrib/libarchive/libarchive/test/test_archive_getdate.c ============================================================================== --- head/contrib/libarchive/libarchive/test/test_archive_getdate.c Sat Feb 2 06:01:57 2013 (r246228) +++ head/contrib/libarchive/libarchive/test/test_archive_getdate.c Sat Feb 2 06:06:39 2013 (r246229) @@ -43,6 +43,8 @@ DEFINE_TEST(test_archive_getdate) assertEqualInt(get_date(now, "2004/01/29 513 mest"), 1075345980); assertEqualInt(get_date(now, "99/02/17 7pm utc"), 919278000); assertEqualInt(get_date(now, "02/17/99 7:11am est"), 919253460); + assertEqualInt(get_date(now, "now - 2 hours"), + get_date(now, "2 hours ago")); /* It's important that we handle ctime() format. */ assertEqualInt(get_date(now, "Sun Feb 22 17:38:26 PST 2009"), 1235353106); @@ -77,5 +79,6 @@ DEFINE_TEST(test_archive_getdate) /* "last tuesday" is one week before "tuesday" */ assertEqualInt(get_date(now, "last tuesday UTC"), now - 6 * 24 * 60 * 60); + /* TODO: Lots more tests here. */ }