From 0f60536a86f4a8e1c657d9d31348a366d74d5e3b Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?=
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
---
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 tDAY_UNIT
+%token tDAY_UNIT tDAY_SHIFT
%token tDAY tDAYZONE tLOCAL_ZONE tMERIDIAN
%token 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