Ondřej Vašík wrote: > Jim Meyering wrote: > > Would you mind separating that into a few separate change sets? > ... > I hope I will do the rest of patches ( 1 or 2 more > are still necessary to cover all the issues I found).
Here is the second set of patches. First one (getdate_4) addresses issue with countable dayshift (like "next yesterday, last tomorrow etc." . I dropped the change of adding tWEEK_UNIT as this is not necessary for functionality of the changes. Second one (getdate_5) addresses signed relative time offset issue. That was not possible until time zone is specified(only case where it was allowed was the hybrid section solution). Grammar before the patch handles any signed number as timezone (as empty o_colon_minutes and o_merid section handles anything like valid). I added grammar for signed numbers without time offset unit (which will handle old required behaviour of o_colon_minutes and o_merid) and added grammar for signed relative time offset. date_2 patch is for coreutils and mentions changes in NEWS and adds one test (getdate_5 patch related). Total number of shift/reduce conflicts is 32 (which is 4 lower than 36 in the first all-in-one patch - as there is no tWEEK_UNIT token type). Increase of the shift/reduce conflicts is caused by o_colon_minutes and o_merid change - which was required for the functionality of the patch_5. Greetings, Ondrej Vasik
From 0f60536a86f4a8e1c657d9d31348a366d74d5e3b Mon Sep 17 00:00:00 2001 From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= <[EMAIL PROTECTED]> Date: Mon, 30 Jun 2008 16:48:17 +0200 Subject: [PATCH] *lib/getdate.y: prevent usage of invalid date syntax of countable ordinal dayshift e.g. "40 yesterday" or "next yesterday" Signed-off-by: Ondřej Vašík <[EMAIL PROTECTED]> --- lib/getdate.y | 12 +++++++----- 1 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/getdate.y b/lib/getdate.y index f33c0a4..93e8e6f 100644 --- a/lib/getdate.y +++ b/lib/getdate.y @@ -292,7 +292,7 @@ extract_hhmmss (parser_control *pc, long int ho, long int mi, time_t sec, long i %token tAGO tDST %token tYEAR_UNIT tMONTH_UNIT tHOUR_UNIT tMINUTE_UNIT tSEC_UNIT -%token <intval> tDAY_UNIT +%token <intval> tDAY_UNIT tDAY_SHIFT %token <intval> tDAY tDAYZONE tLOCAL_ZONE tMERIDIAN %token <intval> tMONTH tORDINAL tZONE @@ -522,6 +522,8 @@ relunit: { $$ = RELATIVE_TIME_0; $$.day = $1.value * $2; } | tDAY_UNIT { $$ = RELATIVE_TIME_0; $$.day = $1; } + | tDAY_SHIFT + { $$ = RELATIVE_TIME_0; $$.day = $1; } | tORDINAL tHOUR_UNIT { $$ = RELATIVE_TIME_0; $$.hour = $1; } | tUNUMBER tHOUR_UNIT @@ -668,10 +670,10 @@ static table const time_units_table[] = /* Assorted relative-time words. */ static table const relative_time_table[] = { - { "TOMORROW", tDAY_UNIT, 1 }, - { "YESTERDAY",tDAY_UNIT, -1 }, - { "TODAY", tDAY_UNIT, 0 }, - { "NOW", tDAY_UNIT, 0 }, + { "TOMORROW", tDAY_SHIFT, 1 }, + { "YESTERDAY",tDAY_SHIFT, -1 }, + { "TODAY", tDAY_SHIFT, 0 }, + { "NOW", tDAY_SHIFT, 0 }, { "LAST", tORDINAL, -1 }, { "THIS", tORDINAL, 0 }, { "NEXT", tORDINAL, 1 }, -- 1.5.2.2
From 4a31fd8c749229be352d2045d4aecd3a125bbad7 Mon Sep 17 00:00:00 2001 From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= <[EMAIL PROTECTED]> Date: Mon, 30 Jun 2008 17:32:28 +0200 Subject: [PATCH] *lib/getdate.y: Allow usage of relative signed time offset even before time zone is specified. Signed-off-by: Ondřej Vašík <[EMAIL PROTECTED]> --- lib/getdate.y | 56 +++++++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 45 insertions(+), 11 deletions(-) diff --git a/lib/getdate.y b/lib/getdate.y index 93e8e6f..ff7850c 100644 --- a/lib/getdate.y +++ b/lib/getdate.y @@ -1,8 +1,8 @@ %{ /* Parse a string into an internal time stamp. - Copyright (C) 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007 Free Software - Foundation, Inc. + Copyright (C) 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007, 2008 + Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -278,8 +278,8 @@ extract_hhmmss (parser_control *pc, long int ho, long int mi, time_t sec, long i %parse-param { parser_control *pc } %lex-param { parser_control *pc } -/* This grammar has 20 shift/reduce conflicts. */ -%expect 20 +/* This grammar has 32 shift/reduce conflicts. */ +%expect 32 %union { @@ -371,7 +371,43 @@ time: pc->zones_seen++; pc->time_zone = time_zone_hhmm (pc, $6, $7); } - ; + | tUNUMBER ':' tUNUMBER relunit_snumber + { + extract_hhmmss (pc, $1.value, $3.value, 0, 0); + pc->meridian = MER24; + extract_relative_time (pc, $4, 1); + } + | tUNUMBER ':' tUNUMBER ':' unsigned_seconds relunit_snumber + { + extract_hhmmss (pc, $1.value, $3.value, $5.tv_sec, $5.tv_nsec); + pc->meridian = MER24; + extract_relative_time (pc, $6, 1); + } + | tUNUMBER ':' tUNUMBER + { + extract_hhmmss (pc, $1.value, $3.value, 0, 0); + pc->meridian = MER24; + } + | tUNUMBER ':' tUNUMBER tSNUMBER + { + extract_hhmmss (pc, $1.value, $3.value, 0, 0); + pc->meridian = MER24; + pc->zones_seen++; + pc->time_zone = time_zone_hhmm (pc, $4, -1); + } + | tUNUMBER ':' tUNUMBER ':' unsigned_seconds + { + extract_hhmmss (pc, $1.value, $3.value, $5.tv_sec, $5.tv_nsec); + pc->meridian = MER24; + } + | tUNUMBER ':' tUNUMBER ':' unsigned_seconds tSNUMBER + { + extract_hhmmss (pc, $1.value, $3.value, $5.tv_sec, $5.tv_nsec); + pc->meridian = MER24; + pc->zones_seen++; + pc->time_zone = time_zone_hhmm (pc, $6, -1); + } + ; local_zone: tLOCAL_ZONE @@ -394,6 +430,8 @@ zone: extract_relative_time (pc, $2, 1); } | tZONE tSNUMBER o_colon_minutes { pc->time_zone = $1 + time_zone_hhmm (pc, $2, $3); } + | tZONE tSNUMBER + { pc->time_zone = $1 + time_zone_hhmm (pc, $2, -1); } | tDAYZONE { pc->time_zone = $1 + 60; } | tZONE tDST @@ -594,16 +632,12 @@ hybrid: ; o_colon_minutes: - /* empty */ - { $$ = -1; } - | ':' tUNUMBER + ':' tUNUMBER { $$ = $2.value; } ; o_merid: - /* empty */ - { $$ = MER24; } - | tMERIDIAN + tMERIDIAN { $$ = $1; } ; -- 1.5.2.2
From 51be4ab38710f289c145bdff608ba6c59060757e Mon Sep 17 00:00:00 2001 From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= <[EMAIL PROTECTED]> Date: Mon, 30 Jun 2008 17:42:38 +0200 Subject: [PATCH] *tests/misc/date: test if signed relative time offset is handled correctly before TZ is specified. *NEWS: mention changes in date behaviour Signed-off-by: Ondřej Vašík <[EMAIL PROTECTED]> --- NEWS | 8 +++++++- tests/misc/date | 2 ++ 2 files changed, 9 insertions(+), 1 deletions(-) diff --git a/NEWS b/NEWS index b8e6f07..8e7fd45 100644 --- a/NEWS +++ b/NEWS @@ -31,9 +31,15 @@ GNU coreutils NEWS -*- outline -*- chcon --verbose now prints a newline after each message - date will no longer ignore specified timezone when relative day,month + date will no longer ignore specified timezone when relative day, month or year offset is specified. + date will now allow usage of signed relative time offset even if timezone + is not specified + + date will no longer allow format with countable/ordinal dayshift + e.g. "40 yesterday" or "next yesterday" + od no longer suffers from platform bugs in printf(3). This is probably most noticeable when using 'od -tfL' to print long doubles. diff --git a/tests/misc/date b/tests/misc/date index 96c7fa6..d79f79b 100755 --- a/tests/misc/date +++ b/tests/misc/date @@ -120,6 +120,8 @@ my @Tests = ['rel-plus1', "-d '20050101 +1 day' +%F", {OUT=>"2005-01-02"}], # up to 6.12, specified TZ was ignored with relative day offset ['rel-plusTZ6d', "-d '20070101 12:40 UTC+4 +6 day' $fmt", {OUT=>"2007-01-07 08:40:00"}], + # up to 6.12, signed relative time offset was not allowed before TZ + ['rel-plus60m', "-d '11:40 + 60 minute' +%T", {OUT=>"12:40:00"}], ['next-s', "-d '$d1 next second' '+%Y-%m-%d %T'", {OUT=>"$d0 $ts"}], ['next-m', "-d '$d1 next minute' '+%Y-%m-%d %T'", {OUT=>"$d0 $tm"}], -- 1.5.2.2
signature.asc
Description: Toto je digitálně podepsaná část zprávy