getdate.c 70 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471
  1. /* A Bison parser, made by GNU Bison 1.875a. */
  2. /* Skeleton parser for Yacc-like parsing with Bison,
  3. Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 59 Temple Place - Suite 330,
  15. Boston, MA 02111-1307, USA. */
  16. /* As a special exception, when this file is copied by Bison into a
  17. Bison output file, you may use that output file without restriction.
  18. This special exception was added by the Free Software Foundation
  19. in version 1.24 of Bison. */
  20. /* Written by Richard Stallman by simplifying the original so called
  21. ``semantic'' parser. */
  22. /* All symbols defined below should begin with yy or YY, to avoid
  23. infringing on user name space. This should be done even for local
  24. variables, as they might otherwise be expanded by user macros.
  25. There are some unavoidable exceptions within include files to
  26. define necessary library symbols; they are noted "INFRINGES ON
  27. USER NAME SPACE" below. */
  28. /* Identify Bison output. */
  29. #define YYBISON 1
  30. /* Skeleton name. */
  31. #define YYSKELETON_NAME "yacc.c"
  32. /* Pure parsers. */
  33. #define YYPURE 1
  34. /* Using locations. */
  35. #define YYLSP_NEEDED 0
  36. /* Tokens. */
  37. #ifndef YYTOKENTYPE
  38. # define YYTOKENTYPE
  39. /* Put the tokens into the symbol table, so that GDB and other debuggers
  40. know about them. */
  41. enum yytokentype {
  42. tAGO = 258,
  43. tDAY = 259,
  44. tDAY_UNIT = 260,
  45. tDAYZONE = 261,
  46. tDST = 262,
  47. tHOUR_UNIT = 263,
  48. tID = 264,
  49. tMERIDIAN = 265,
  50. tMINUTE_UNIT = 266,
  51. tMONTH = 267,
  52. tMONTH_UNIT = 268,
  53. tSEC_UNIT = 269,
  54. tSNUMBER = 270,
  55. tUNUMBER = 271,
  56. tYEAR_UNIT = 272,
  57. tZONE = 273
  58. };
  59. #endif
  60. #define tAGO 258
  61. #define tDAY 259
  62. #define tDAY_UNIT 260
  63. #define tDAYZONE 261
  64. #define tDST 262
  65. #define tHOUR_UNIT 263
  66. #define tID 264
  67. #define tMERIDIAN 265
  68. #define tMINUTE_UNIT 266
  69. #define tMONTH 267
  70. #define tMONTH_UNIT 268
  71. #define tSEC_UNIT 269
  72. #define tSNUMBER 270
  73. #define tUNUMBER 271
  74. #define tYEAR_UNIT 272
  75. #define tZONE 273
  76. /* Copy the first part of user declarations. */
  77. #line 1 "getdate.y"
  78. /*
  79. ** Originally written by Steven M. Bellovin <[email protected]> while
  80. ** at the University of North Carolina at Chapel Hill. Later tweaked by
  81. ** a couple of people on Usenet. Completely overhauled by Rich $alz
  82. ** <[email protected]> and Jim Berets <[email protected]> in August, 1990.
  83. **
  84. ** This code has been modified since it was included in curl, to make it
  85. ** thread-safe and to make compilers complain less about it.
  86. **
  87. ** This code is in the public domain and has no copyright.
  88. */
  89. #include "setup.h"
  90. # ifdef HAVE_ALLOCA_H
  91. # include <alloca.h>
  92. # endif
  93. # ifdef HAVE_TIME_H
  94. # include <time.h>
  95. # endif
  96. #ifndef YYDEBUG
  97. /* to satisfy gcc -Wundef, we set this to 0 */
  98. #define YYDEBUG 0
  99. #endif
  100. #ifndef YYSTACK_USE_ALLOCA
  101. /* to satisfy gcc -Wundef, we set this to 0 */
  102. #define YYSTACK_USE_ALLOCA 0
  103. #endif
  104. /* Since the code of getdate.y is not included in the Emacs executable
  105. itself, there is no need to #define static in this file. Even if
  106. the code were included in the Emacs executable, it probably
  107. wouldn't do any harm to #undef it here; this will only cause
  108. problems if we try to write to a static variable, which I don't
  109. think this code needs to do. */
  110. #ifdef emacs
  111. # undef static
  112. #endif
  113. #ifdef __APPLE__
  114. #include <sys/types.h>
  115. #include <sys/malloc.h>
  116. #else
  117. #endif
  118. #include <string.h>
  119. #include <stdio.h>
  120. #include <ctype.h>
  121. #if HAVE_STDLIB_H
  122. # include <stdlib.h> /* for `free'; used by Bison 1.27 */
  123. #else
  124. #ifdef HAVE_MALLOC_H
  125. #include <malloc.h>
  126. #endif
  127. #endif
  128. #if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII))
  129. # define IN_CTYPE_DOMAIN(c) 1
  130. #else
  131. # define IN_CTYPE_DOMAIN(c) isascii(c)
  132. #endif
  133. #define ISSPACE(c) (IN_CTYPE_DOMAIN (c) && isspace (c))
  134. #define ISALPHA(c) (IN_CTYPE_DOMAIN (c) && isalpha (c))
  135. #define ISUPPER(c) (IN_CTYPE_DOMAIN (c) && isupper (c))
  136. #define ISDIGIT_LOCALE(c) (IN_CTYPE_DOMAIN (c) && isdigit (c))
  137. /* ISDIGIT differs from ISDIGIT_LOCALE, as follows:
  138. - Its arg may be any int or unsigned int; it need not be an unsigned char.
  139. - It's guaranteed to evaluate its argument exactly once.
  140. - It's typically faster.
  141. Posix 1003.2-1992 section 2.5.2.1 page 50 lines 1556-1558 says that
  142. only '0' through '9' are digits. Prefer ISDIGIT to ISDIGIT_LOCALE unless
  143. it's important to use the locale's definition of `digit' even when the
  144. host does not conform to Posix. */
  145. #define ISDIGIT(c) ((unsigned) (c) - '0' <= 9)
  146. #if defined (STDC_HEADERS) || defined (USG)
  147. # include <string.h>
  148. #endif
  149. #include "curl_memory.h"
  150. /* The last #include file should be: */
  151. #include "memdebug.h"
  152. #ifndef YYMAXDEPTH
  153. #define YYMAXDEPTH 0
  154. #endif
  155. #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
  156. # define __attribute__(x)
  157. #endif
  158. #ifndef ATTRIBUTE_UNUSED
  159. # define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
  160. #endif
  161. /* Some old versions of bison generate parsers that use bcopy.
  162. That loses on systems that don't provide the function, so we have
  163. to redefine it here. */
  164. #if !defined (HAVE_BCOPY) && defined (HAVE_MEMCPY) && !defined (bcopy)
  165. # define bcopy(from, to, len) memcpy ((to), (from), (len))
  166. #endif
  167. /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
  168. as well as gratuitiously global symbol names, so we can have multiple
  169. yacc generated parsers in the same program. Note that these are only
  170. the variables produced by yacc. If other parser generators (bison,
  171. byacc, etc) produce additional global names that conflict at link time,
  172. then those parser generators need to be fixed instead of adding those
  173. names to this list. */
  174. #define yymaxdepth Curl_gd_maxdepth
  175. #define yyparse Curl_gd_parse
  176. #define yylex Curl_gd_lex
  177. #define yyerror Curl_gd_error
  178. #define yylval Curl_gd_lval
  179. #define yychar Curl_gd_char
  180. #define yydebug Curl_gd_debug
  181. #define yypact Curl_gd_pact
  182. #define yyr1 Curl_gd_r1
  183. #define yyr2 Curl_gd_r2
  184. #define yydef Curl_gd_def
  185. #define yychk Curl_gd_chk
  186. #define yypgo Curl_gd_pgo
  187. #define yyact Curl_gd_act
  188. #define yyexca Curl_gd_exca
  189. #define yyerrflag Curl_gd_errflag
  190. #define yynerrs Curl_gd_nerrs
  191. #define yyps Curl_gd_ps
  192. #define yypv Curl_gd_pv
  193. #define yys Curl_gd_s
  194. #define yy_yys Curl_gd_yys
  195. #define yystate Curl_gd_state
  196. #define yytmp Curl_gd_tmp
  197. #define yyv Curl_gd_v
  198. #define yy_yyv Curl_gd_yyv
  199. #define yyval Curl_gd_val
  200. #define yylloc Curl_gd_lloc
  201. #define yyreds Curl_gd_reds /* With YYDEBUG defined */
  202. #define yytoks Curl_gd_toks /* With YYDEBUG defined */
  203. #define yylhs Curl_gd_yylhs
  204. #define yylen Curl_gd_yylen
  205. #define yydefred Curl_gd_yydefred
  206. #define yydgoto Curl_gd_yydgoto
  207. #define yysindex Curl_gd_yysindex
  208. #define yyrindex Curl_gd_yyrindex
  209. #define yygindex Curl_gd_yygindex
  210. #define yytable Curl_gd_yytable
  211. #define yycheck Curl_gd_yycheck
  212. #define EPOCH 1970
  213. #define HOUR(x) ((x) * 60)
  214. #define MAX_BUFF_LEN 128 /* size of buffer to read the date into */
  215. /*
  216. ** An entry in the lexical lookup table.
  217. */
  218. typedef struct _TABLE {
  219. const char *name;
  220. int type;
  221. int value;
  222. } TABLE;
  223. /*
  224. ** Meridian: am, pm, or 24-hour style.
  225. */
  226. typedef enum _MERIDIAN {
  227. MERam, MERpm, MER24
  228. } MERIDIAN;
  229. /* parse results and input string */
  230. typedef struct _CURL_CONTEXT {
  231. const char *yyInput;
  232. int yyDayOrdinal;
  233. int yyDayNumber;
  234. int yyHaveDate;
  235. int yyHaveDay;
  236. int yyHaveRel;
  237. int yyHaveTime;
  238. int yyHaveZone;
  239. int yyTimezone;
  240. int yyDay;
  241. int yyHour;
  242. int yyMinutes;
  243. int yyMonth;
  244. int yySeconds;
  245. int yyYear;
  246. MERIDIAN yyMeridian;
  247. int yyRelDay;
  248. int yyRelHour;
  249. int yyRelMinutes;
  250. int yyRelMonth;
  251. int yyRelSeconds;
  252. int yyRelYear;
  253. } CURL_CONTEXT;
  254. /* enable use of extra argument to yyparse and yylex which can be used to pass
  255. ** in a user defined value (CURL_CONTEXT struct in our case)
  256. */
  257. #define YYPARSE_PARAM cookie
  258. #define YYLEX_PARAM cookie
  259. #define context ((CURL_CONTEXT *) cookie)
  260. /* Enabling traces. */
  261. #ifndef YYDEBUG
  262. # define YYDEBUG 0
  263. #endif
  264. /* Enabling verbose error messages. */
  265. #ifdef YYERROR_VERBOSE
  266. # undef YYERROR_VERBOSE
  267. # define YYERROR_VERBOSE 1
  268. #else
  269. # define YYERROR_VERBOSE 0
  270. #endif
  271. #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
  272. #line 223 "getdate.y"
  273. typedef union YYSTYPE {
  274. int Number;
  275. enum _MERIDIAN Meridian;
  276. } YYSTYPE;
  277. /* Line 191 of yacc.c. */
  278. #line 331 "y.tab.c"
  279. # define yystype YYSTYPE /* obsolescent; will be withdrawn */
  280. # define YYSTYPE_IS_DECLARED 1
  281. # define YYSTYPE_IS_TRIVIAL 1
  282. #endif
  283. /* Copy the second part of user declarations. */
  284. #line 228 "getdate.y"
  285. static int yylex (YYSTYPE *yylval, void *cookie);
  286. static int yyerror (const char *s);
  287. /* Line 214 of yacc.c. */
  288. #line 347 "y.tab.c"
  289. #if ! defined (yyoverflow) || YYERROR_VERBOSE
  290. /* The parser invokes alloca or malloc; define the necessary symbols. */
  291. # if YYSTACK_USE_ALLOCA
  292. # define YYSTACK_ALLOC alloca
  293. # else
  294. # ifndef YYSTACK_USE_ALLOCA
  295. # if defined (alloca) || defined (_ALLOCA_H)
  296. # define YYSTACK_ALLOC alloca
  297. # else
  298. # ifdef __GNUC__
  299. # define YYSTACK_ALLOC __builtin_alloca
  300. # endif
  301. # endif
  302. # endif
  303. # endif
  304. # ifdef YYSTACK_ALLOC
  305. /* Pacify GCC's `empty if-body' warning. */
  306. # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
  307. # else
  308. # if defined (__STDC__) || defined (__cplusplus)
  309. # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
  310. # define YYSIZE_T size_t
  311. # endif
  312. # define YYSTACK_ALLOC malloc
  313. # define YYSTACK_FREE free
  314. # endif
  315. #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
  316. #if (! defined (yyoverflow) \
  317. && (! defined (__cplusplus) \
  318. || (YYSTYPE_IS_TRIVIAL)))
  319. /* A type that is properly aligned for any stack member. */
  320. union yyalloc
  321. {
  322. short yyss;
  323. YYSTYPE yyvs;
  324. };
  325. /* The size of the maximum gap between one aligned stack and the next. */
  326. # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
  327. /* The size of an array large to enough to hold all stacks, each with
  328. N elements. */
  329. # define YYSTACK_BYTES(N) \
  330. ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
  331. + YYSTACK_GAP_MAXIMUM)
  332. /* Copy COUNT objects from FROM to TO. The source and destination do
  333. not overlap. */
  334. # ifndef YYCOPY
  335. # if 1 < __GNUC__
  336. # define YYCOPY(To, From, Count) \
  337. __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
  338. # else
  339. # define YYCOPY(To, From, Count) \
  340. do \
  341. { \
  342. register YYSIZE_T yyi; \
  343. for (yyi = 0; yyi < (Count); yyi++) \
  344. (To)[yyi] = (From)[yyi]; \
  345. } \
  346. while (0)
  347. # endif
  348. # endif
  349. /* Relocate STACK from its old location to the new one. The
  350. local variables YYSIZE and YYSTACKSIZE give the old and new number of
  351. elements in the stack, and YYPTR gives the new location of the
  352. stack. Advance YYPTR to a properly aligned location for the next
  353. stack. */
  354. # define YYSTACK_RELOCATE(Stack) \
  355. do \
  356. { \
  357. YYSIZE_T yynewbytes; \
  358. YYCOPY (&yyptr->Stack, Stack, yysize); \
  359. Stack = &yyptr->Stack; \
  360. yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
  361. yyptr += yynewbytes / sizeof (*yyptr); \
  362. (void)yyptr; \
  363. } \
  364. while (0)
  365. #endif
  366. #if defined (__STDC__) || defined (__cplusplus)
  367. typedef signed char yysigned_char;
  368. #else
  369. typedef short yysigned_char;
  370. #endif
  371. /* YYFINAL -- State number of the termination state. */
  372. #define YYFINAL 2
  373. /* YYLAST -- Last index in YYTABLE. */
  374. #define YYLAST 50
  375. /* YYNTOKENS -- Number of terminals. */
  376. #define YYNTOKENS 22
  377. /* YYNNTS -- Number of nonterminals. */
  378. #define YYNNTS 11
  379. /* YYNRULES -- Number of rules. */
  380. #define YYNRULES 51
  381. /* YYNRULES -- Number of states. */
  382. #define YYNSTATES 61
  383. /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
  384. #define YYUNDEFTOK 2
  385. #define YYMAXUTOK 273
  386. #define YYTRANSLATE(YYX) \
  387. ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
  388. /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
  389. static const unsigned char yytranslate[] =
  390. {
  391. 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  392. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  393. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  394. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  395. 2, 2, 2, 2, 20, 2, 2, 21, 2, 2,
  396. 2, 2, 2, 2, 2, 2, 2, 2, 19, 2,
  397. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  398. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  399. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  400. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  401. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  402. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  403. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  404. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  405. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  406. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  407. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  408. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  409. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  410. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  411. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  412. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  413. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  414. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  415. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  416. 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
  417. 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
  418. 15, 16, 17, 18
  419. };
  420. #if YYDEBUG
  421. /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
  422. YYRHS. */
  423. static const unsigned char yyprhs[] =
  424. {
  425. 0, 0, 3, 4, 7, 9, 11, 13, 15, 17,
  426. 19, 22, 27, 32, 39, 46, 48, 50, 53, 55,
  427. 58, 61, 65, 71, 75, 79, 82, 87, 90, 94,
  428. 97, 99, 102, 105, 107, 110, 113, 115, 118, 121,
  429. 123, 126, 129, 131, 134, 137, 139, 142, 145, 147,
  430. 149, 150
  431. };
  432. /* YYRHS -- A `-1'-separated list of the rules' RHS. */
  433. static const yysigned_char yyrhs[] =
  434. {
  435. 23, 0, -1, -1, 23, 24, -1, 25, -1, 26,
  436. -1, 28, -1, 27, -1, 29, -1, 31, -1, 16,
  437. 10, -1, 16, 19, 16, 32, -1, 16, 19, 16,
  438. 15, -1, 16, 19, 16, 19, 16, 32, -1, 16,
  439. 19, 16, 19, 16, 15, -1, 18, -1, 6, -1,
  440. 18, 7, -1, 4, -1, 4, 20, -1, 16, 4,
  441. -1, 16, 21, 16, -1, 16, 21, 16, 21, 16,
  442. -1, 16, 15, 15, -1, 16, 12, 15, -1, 12,
  443. 16, -1, 12, 16, 20, 16, -1, 16, 12, -1,
  444. 16, 12, 16, -1, 30, 3, -1, 30, -1, 16,
  445. 17, -1, 15, 17, -1, 17, -1, 16, 13, -1,
  446. 15, 13, -1, 13, -1, 16, 5, -1, 15, 5,
  447. -1, 5, -1, 16, 8, -1, 15, 8, -1, 8,
  448. -1, 16, 11, -1, 15, 11, -1, 11, -1, 16,
  449. 14, -1, 15, 14, -1, 14, -1, 16, -1, -1,
  450. 10, -1
  451. };
  452. /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
  453. static const unsigned short yyrline[] =
  454. {
  455. 0, 244, 244, 245, 248, 251, 254, 257, 260, 263,
  456. 266, 272, 278, 287, 293, 305, 308, 312, 317, 321,
  457. 325, 331, 335, 353, 359, 365, 369, 374, 378, 385,
  458. 393, 396, 399, 402, 405, 408, 411, 414, 417, 420,
  459. 423, 426, 429, 432, 435, 438, 441, 444, 447, 452,
  460. 487, 490
  461. };
  462. #endif
  463. #if YYDEBUG || YYERROR_VERBOSE
  464. /* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
  465. First, the terminals, then, starting at YYNTOKENS, nonterminals. */
  466. static const char *const yytname[] =
  467. {
  468. "$end", "error", "$undefined", "tAGO", "tDAY", "tDAY_UNIT", "tDAYZONE",
  469. "tDST", "tHOUR_UNIT", "tID", "tMERIDIAN", "tMINUTE_UNIT", "tMONTH",
  470. "tMONTH_UNIT", "tSEC_UNIT", "tSNUMBER", "tUNUMBER", "tYEAR_UNIT",
  471. "tZONE", "':'", "','", "'/'", "$accept", "spec", "item", "time", "zone",
  472. "day", "date", "rel", "relunit", "number", "o_merid", 0
  473. };
  474. #endif
  475. # ifdef YYPRINT
  476. /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
  477. token YYLEX-NUM. */
  478. static const unsigned short yytoknum[] =
  479. {
  480. 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
  481. 265, 266, 267, 268, 269, 270, 271, 272, 273, 58,
  482. 44, 47
  483. };
  484. # endif
  485. /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
  486. static const unsigned char yyr1[] =
  487. {
  488. 0, 22, 23, 23, 24, 24, 24, 24, 24, 24,
  489. 25, 25, 25, 25, 25, 26, 26, 26, 27, 27,
  490. 27, 28, 28, 28, 28, 28, 28, 28, 28, 29,
  491. 29, 30, 30, 30, 30, 30, 30, 30, 30, 30,
  492. 30, 30, 30, 30, 30, 30, 30, 30, 30, 31,
  493. 32, 32
  494. };
  495. /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
  496. static const unsigned char yyr2[] =
  497. {
  498. 0, 2, 0, 2, 1, 1, 1, 1, 1, 1,
  499. 2, 4, 4, 6, 6, 1, 1, 2, 1, 2,
  500. 2, 3, 5, 3, 3, 2, 4, 2, 3, 2,
  501. 1, 2, 2, 1, 2, 2, 1, 2, 2, 1,
  502. 2, 2, 1, 2, 2, 1, 2, 2, 1, 1,
  503. 0, 1
  504. };
  505. /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
  506. STATE-NUM when YYTABLE doesn't specify something else to do. Zero
  507. means the default is an error. */
  508. static const unsigned char yydefact[] =
  509. {
  510. 2, 0, 1, 18, 39, 16, 42, 45, 0, 36,
  511. 48, 0, 49, 33, 15, 3, 4, 5, 7, 6,
  512. 8, 30, 9, 19, 25, 38, 41, 44, 35, 47,
  513. 32, 20, 37, 40, 10, 43, 27, 34, 46, 0,
  514. 31, 0, 0, 17, 29, 0, 24, 28, 23, 50,
  515. 21, 26, 51, 12, 0, 11, 0, 50, 22, 14,
  516. 13
  517. };
  518. /* YYDEFGOTO[NTERM-NUM]. */
  519. static const yysigned_char yydefgoto[] =
  520. {
  521. -1, 1, 15, 16, 17, 18, 19, 20, 21, 22,
  522. 55
  523. };
  524. /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
  525. STATE-NUM. */
  526. #define YYPACT_NINF -20
  527. static const yysigned_char yypact[] =
  528. {
  529. -20, 0, -20, -19, -20, -20, -20, -20, -13, -20,
  530. -20, 30, 15, -20, 14, -20, -20, -20, -20, -20,
  531. -20, 19, -20, -20, 4, -20, -20, -20, -20, -20,
  532. -20, -20, -20, -20, -20, -20, -6, -20, -20, 16,
  533. -20, 17, 23, -20, -20, 24, -20, -20, -20, 27,
  534. 28, -20, -20, -20, 29, -20, 32, -8, -20, -20,
  535. -20
  536. };
  537. /* YYPGOTO[NTERM-NUM]. */
  538. static const yysigned_char yypgoto[] =
  539. {
  540. -20, -20, -20, -20, -20, -20, -20, -20, -20, -20,
  541. -7
  542. };
  543. /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
  544. positive, shift that token. If negative, reduce the rule which
  545. number is the opposite. If zero, do what YYDEFACT says.
  546. If YYTABLE_NINF, syntax error. */
  547. #define YYTABLE_NINF -1
  548. static const unsigned char yytable[] =
  549. {
  550. 2, 23, 52, 24, 3, 4, 5, 59, 6, 46,
  551. 47, 7, 8, 9, 10, 11, 12, 13, 14, 31,
  552. 32, 43, 44, 33, 45, 34, 35, 36, 37, 38,
  553. 39, 48, 40, 49, 41, 25, 42, 52, 26, 50,
  554. 51, 27, 53, 28, 29, 57, 54, 30, 58, 56,
  555. 60
  556. };
  557. static const unsigned char yycheck[] =
  558. {
  559. 0, 20, 10, 16, 4, 5, 6, 15, 8, 15,
  560. 16, 11, 12, 13, 14, 15, 16, 17, 18, 4,
  561. 5, 7, 3, 8, 20, 10, 11, 12, 13, 14,
  562. 15, 15, 17, 16, 19, 5, 21, 10, 8, 16,
  563. 16, 11, 15, 13, 14, 16, 19, 17, 16, 21,
  564. 57
  565. };
  566. /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
  567. symbol of state STATE-NUM. */
  568. static const unsigned char yystos[] =
  569. {
  570. 0, 23, 0, 4, 5, 6, 8, 11, 12, 13,
  571. 14, 15, 16, 17, 18, 24, 25, 26, 27, 28,
  572. 29, 30, 31, 20, 16, 5, 8, 11, 13, 14,
  573. 17, 4, 5, 8, 10, 11, 12, 13, 14, 15,
  574. 17, 19, 21, 7, 3, 20, 15, 16, 15, 16,
  575. 16, 16, 10, 15, 19, 32, 21, 16, 16, 15,
  576. 32
  577. };
  578. #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
  579. # define YYSIZE_T __SIZE_TYPE__
  580. #endif
  581. #if ! defined (YYSIZE_T) && defined (size_t)
  582. # define YYSIZE_T size_t
  583. #endif
  584. #if ! defined (YYSIZE_T)
  585. # if defined (__STDC__) || defined (__cplusplus)
  586. # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
  587. # define YYSIZE_T size_t
  588. # endif
  589. #endif
  590. #if ! defined (YYSIZE_T)
  591. # define YYSIZE_T unsigned int
  592. #endif
  593. #define yyerrok (yyerrstatus = 0)
  594. #define yyclearin (yychar = YYEMPTY)
  595. #define YYEMPTY (-2)
  596. #define YYEOF 0
  597. #define YYACCEPT goto yyacceptlab
  598. #define YYABORT goto yyabortlab
  599. #define YYERROR goto yyerrlab1
  600. /* Like YYERROR except do call yyerror. This remains here temporarily
  601. to ease the transition to the new meaning of YYERROR, for GCC.
  602. Once GCC version 2 has supplanted version 1, this can go. */
  603. #define YYFAIL goto yyerrlab
  604. #define YYRECOVERING() (!!yyerrstatus)
  605. #define YYBACKUP(Token, Value) \
  606. do \
  607. if (yychar == YYEMPTY && yylen == 1) \
  608. { \
  609. yychar = (Token); \
  610. yylval = (Value); \
  611. yytoken = YYTRANSLATE (yychar); \
  612. YYPOPSTACK; \
  613. goto yybackup; \
  614. } \
  615. else \
  616. { \
  617. yyerror ("syntax error: cannot back up");\
  618. YYERROR; \
  619. } \
  620. while (0)
  621. #define YYTERROR 1
  622. #define YYERRCODE 256
  623. /* YYLLOC_DEFAULT -- Compute the default location (before the actions
  624. are run). */
  625. #ifndef YYLLOC_DEFAULT
  626. # define YYLLOC_DEFAULT(Current, Rhs, N) \
  627. Current.first_line = Rhs[1].first_line; \
  628. Current.first_column = Rhs[1].first_column; \
  629. Current.last_line = Rhs[N].last_line; \
  630. Current.last_column = Rhs[N].last_column;
  631. #endif
  632. /* YYLEX -- calling `yylex' with the right arguments. */
  633. #ifdef YYLEX_PARAM
  634. # define YYLEX yylex (&yylval, YYLEX_PARAM)
  635. #else
  636. # define YYLEX yylex (&yylval)
  637. #endif
  638. /* Enable debugging if requested. */
  639. #if YYDEBUG
  640. # ifndef YYFPRINTF
  641. # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
  642. # define YYFPRINTF fprintf
  643. # endif
  644. # define YYDPRINTF(Args) \
  645. do { \
  646. if (yydebug) \
  647. YYFPRINTF Args; \
  648. } while (0)
  649. # define YYDSYMPRINT(Args) \
  650. do { \
  651. if (yydebug) \
  652. yysymprint Args; \
  653. } while (0)
  654. # define YYDSYMPRINTF(Title, Token, Value, Location) \
  655. do { \
  656. if (yydebug) \
  657. { \
  658. YYFPRINTF (stderr, "%s ", Title); \
  659. yysymprint (stderr, \
  660. Token, Value); \
  661. YYFPRINTF (stderr, "\n"); \
  662. } \
  663. } while (0)
  664. /*------------------------------------------------------------------.
  665. | yy_stack_print -- Print the state stack from its BOTTOM up to its |
  666. | TOP (cinluded). |
  667. `------------------------------------------------------------------*/
  668. #if defined (__STDC__) || defined (__cplusplus)
  669. static void
  670. yy_stack_print (short *bottom, short *top)
  671. #else
  672. static void
  673. yy_stack_print (bottom, top)
  674. short *bottom;
  675. short *top;
  676. #endif
  677. {
  678. YYFPRINTF (stderr, "Stack now");
  679. for (/* Nothing. */; bottom <= top; ++bottom)
  680. YYFPRINTF (stderr, " %d", *bottom);
  681. YYFPRINTF (stderr, "\n");
  682. }
  683. # define YY_STACK_PRINT(Bottom, Top) \
  684. do { \
  685. if (yydebug) \
  686. yy_stack_print ((Bottom), (Top)); \
  687. } while (0)
  688. /*------------------------------------------------.
  689. | Report that the YYRULE is going to be reduced. |
  690. `------------------------------------------------*/
  691. #if defined (__STDC__) || defined (__cplusplus)
  692. static void
  693. yy_reduce_print (int yyrule)
  694. #else
  695. static void
  696. yy_reduce_print (yyrule)
  697. int yyrule;
  698. #endif
  699. {
  700. int yyi;
  701. unsigned int yylineno = yyrline[yyrule];
  702. YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
  703. yyrule - 1, yylineno);
  704. /* Print the symbols being reduced, and their result. */
  705. for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
  706. YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]);
  707. YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]);
  708. }
  709. # define YY_REDUCE_PRINT(Rule) \
  710. do { \
  711. if (yydebug) \
  712. yy_reduce_print (Rule); \
  713. } while (0)
  714. /* Nonzero means print parse trace. It is left uninitialized so that
  715. multiple parsers can coexist. */
  716. int yydebug;
  717. #else /* !YYDEBUG */
  718. # define YYDPRINTF(Args)
  719. # define YYDSYMPRINT(Args)
  720. # define YYDSYMPRINTF(Title, Token, Value, Location)
  721. # define YY_STACK_PRINT(Bottom, Top)
  722. # define YY_REDUCE_PRINT(Rule)
  723. #endif /* !YYDEBUG */
  724. /* YYINITDEPTH -- initial size of the parser's stacks. */
  725. #ifndef YYINITDEPTH
  726. # define YYINITDEPTH 200
  727. #endif
  728. /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
  729. if the built-in stack extension method is used).
  730. Do not make this value too large; the results are undefined if
  731. SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
  732. evaluated with infinite-precision integer arithmetic. */
  733. #if YYMAXDEPTH == 0
  734. # undef YYMAXDEPTH
  735. #endif
  736. #ifndef YYMAXDEPTH
  737. # define YYMAXDEPTH 10000
  738. #endif
  739. #if YYERROR_VERBOSE
  740. # ifndef yystrlen
  741. # if defined (__GLIBC__) && defined (_STRING_H)
  742. # define yystrlen strlen
  743. # else
  744. /* Return the length of YYSTR. */
  745. static YYSIZE_T
  746. # if defined (__STDC__) || defined (__cplusplus)
  747. yystrlen (const char *yystr)
  748. # else
  749. yystrlen (yystr)
  750. const char *yystr;
  751. # endif
  752. {
  753. register const char *yys = yystr;
  754. while (*yys++ != '\0')
  755. continue;
  756. return yys - yystr - 1;
  757. }
  758. # endif
  759. # endif
  760. # ifndef yystpcpy
  761. # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
  762. # define yystpcpy stpcpy
  763. # else
  764. /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
  765. YYDEST. */
  766. static char *
  767. # if defined (__STDC__) || defined (__cplusplus)
  768. yystpcpy (char *yydest, const char *yysrc)
  769. # else
  770. yystpcpy (yydest, yysrc)
  771. char *yydest;
  772. const char *yysrc;
  773. # endif
  774. {
  775. register char *yyd = yydest;
  776. register const char *yys = yysrc;
  777. while ((*yyd++ = *yys++) != '\0')
  778. continue;
  779. return yyd - 1;
  780. }
  781. # endif
  782. # endif
  783. #endif /* !YYERROR_VERBOSE */
  784. #if YYDEBUG
  785. /*--------------------------------.
  786. | Print this symbol on YYOUTPUT. |
  787. `--------------------------------*/
  788. #if defined (__STDC__) || defined (__cplusplus)
  789. static void
  790. yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
  791. #else
  792. static void
  793. yysymprint (yyoutput, yytype, yyvaluep)
  794. FILE *yyoutput;
  795. int yytype;
  796. YYSTYPE *yyvaluep;
  797. #endif
  798. {
  799. /* Pacify ``unused variable'' warnings. */
  800. (void) yyvaluep;
  801. if (yytype < YYNTOKENS)
  802. {
  803. YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
  804. # ifdef YYPRINT
  805. YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
  806. # endif
  807. }
  808. else
  809. YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
  810. switch (yytype)
  811. {
  812. default:
  813. break;
  814. }
  815. YYFPRINTF (yyoutput, ")");
  816. }
  817. #endif /* ! YYDEBUG */
  818. /*-----------------------------------------------.
  819. | Release the memory associated to this symbol. |
  820. `-----------------------------------------------*/
  821. #if defined (__STDC__) || defined (__cplusplus)
  822. static void
  823. yydestruct (int yytype, YYSTYPE *yyvaluep)
  824. #else
  825. static void
  826. yydestruct (yytype, yyvaluep)
  827. int yytype;
  828. YYSTYPE *yyvaluep;
  829. #endif
  830. {
  831. /* Pacify ``unused variable'' warnings. */
  832. (void) yyvaluep;
  833. switch (yytype)
  834. {
  835. default:
  836. break;
  837. }
  838. }
  839. /* Prevent warnings from -Wmissing-prototypes. */
  840. #ifdef YYPARSE_PARAM
  841. # if defined (__STDC__) || defined (__cplusplus)
  842. int yyparse (void *YYPARSE_PARAM);
  843. # else
  844. int yyparse ();
  845. # endif
  846. #else /* ! YYPARSE_PARAM */
  847. #if defined (__STDC__) || defined (__cplusplus)
  848. int yyparse (void);
  849. #else
  850. int yyparse ();
  851. #endif
  852. #endif /* ! YYPARSE_PARAM */
  853. /*----------.
  854. | yyparse. |
  855. `----------*/
  856. #ifdef YYPARSE_PARAM
  857. # if defined (__STDC__) || defined (__cplusplus)
  858. int yyparse (void *YYPARSE_PARAM)
  859. # else
  860. int yyparse (YYPARSE_PARAM)
  861. void *YYPARSE_PARAM;
  862. # endif
  863. #else /* ! YYPARSE_PARAM */
  864. #if defined (__STDC__) || defined (__cplusplus)
  865. int
  866. yyparse (void)
  867. #else
  868. int
  869. yyparse ()
  870. #endif
  871. #endif
  872. {
  873. /* The lookahead symbol. */
  874. int yychar;
  875. /* The semantic value of the lookahead symbol. */
  876. YYSTYPE yylval;
  877. /* Number of syntax errors so far. */
  878. int yynerrs;
  879. register int yystate;
  880. register int yyn;
  881. int yyresult;
  882. /* Number of tokens to shift before error messages enabled. */
  883. int yyerrstatus;
  884. /* Lookahead token as an internal (translated) token number. */
  885. int yytoken = 0;
  886. /* Three stacks and their tools:
  887. `yyss': related to states,
  888. `yyvs': related to semantic values,
  889. `yyls': related to locations.
  890. Refer to the stacks thru separate pointers, to allow yyoverflow
  891. to reallocate them elsewhere. */
  892. /* The state stack. */
  893. short yyssa[YYINITDEPTH];
  894. short *yyss = yyssa;
  895. register short *yyssp;
  896. /* The semantic value stack. */
  897. YYSTYPE yyvsa[YYINITDEPTH];
  898. YYSTYPE *yyvs = yyvsa;
  899. register YYSTYPE *yyvsp;
  900. #define YYPOPSTACK (yyvsp--, yyssp--)
  901. YYSIZE_T yystacksize = YYINITDEPTH;
  902. /* The variables used to return semantic value and location from the
  903. action routines. */
  904. YYSTYPE yyval;
  905. /* When reducing, the number of symbols on the RHS of the reduced
  906. rule. */
  907. int yylen;
  908. YYDPRINTF ((stderr, "Starting parse\n"));
  909. yystate = 0;
  910. yyerrstatus = 0;
  911. yynerrs = 0;
  912. yychar = YYEMPTY; /* Cause a token to be read. */
  913. /* Initialize stack pointers.
  914. Waste one element of value and location stack
  915. so that they stay on the same level as the state stack.
  916. The wasted elements are never initialized. */
  917. yyssp = yyss;
  918. yyvsp = yyvs;
  919. goto yysetstate;
  920. /*------------------------------------------------------------.
  921. | yynewstate -- Push a new state, which is found in yystate. |
  922. `------------------------------------------------------------*/
  923. yynewstate:
  924. /* In all cases, when you get here, the value and location stacks
  925. have just been pushed. so pushing a state here evens the stacks.
  926. */
  927. yyssp++;
  928. yysetstate:
  929. *yyssp = yystate;
  930. if (yyss + yystacksize - 1 <= yyssp)
  931. {
  932. /* Get the current used size of the three stacks, in elements. */
  933. YYSIZE_T yysize = (YYSIZE_T)(yyssp - yyss + 1);
  934. #ifdef yyoverflow
  935. {
  936. /* Give user a chance to reallocate the stack. Use copies of
  937. these so that the &'s don't force the real ones into
  938. memory. */
  939. YYSTYPE *yyvs1 = yyvs;
  940. short *yyss1 = yyss;
  941. /* Each stack pointer address is followed by the size of the
  942. data in use in that stack, in bytes. This used to be a
  943. conditional around just the two extra args, but that might
  944. be undefined if yyoverflow is a macro. */
  945. yyoverflow ("parser stack overflow",
  946. &yyss1, yysize * sizeof (*yyssp),
  947. &yyvs1, yysize * sizeof (*yyvsp),
  948. &yystacksize);
  949. yyss = yyss1;
  950. yyvs = yyvs1;
  951. }
  952. #else /* no yyoverflow */
  953. # ifndef YYSTACK_RELOCATE
  954. goto yyoverflowlab;
  955. # else
  956. /* Extend the stack our own way. */
  957. if (YYMAXDEPTH <= yystacksize)
  958. goto yyoverflowlab;
  959. yystacksize *= 2;
  960. if (YYMAXDEPTH < yystacksize)
  961. yystacksize = YYMAXDEPTH;
  962. {
  963. short *yyss1 = yyss;
  964. union yyalloc *yyptr =
  965. (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
  966. if (! yyptr)
  967. goto yyoverflowlab;
  968. YYSTACK_RELOCATE (yyss);
  969. YYSTACK_RELOCATE (yyvs);
  970. # undef YYSTACK_RELOCATE
  971. if (yyss1 != yyssa)
  972. YYSTACK_FREE (yyss1);
  973. }
  974. # endif
  975. #endif /* no yyoverflow */
  976. yyssp = yyss + yysize - 1;
  977. yyvsp = yyvs + yysize - 1;
  978. YYDPRINTF ((stderr, "Stack size increased to %lu\n",
  979. (unsigned long int) yystacksize));
  980. if (yyss + yystacksize - 1 <= yyssp)
  981. YYABORT;
  982. }
  983. YYDPRINTF ((stderr, "Entering state %d\n", yystate));
  984. goto yybackup;
  985. /*-----------.
  986. | yybackup. |
  987. `-----------*/
  988. yybackup:
  989. /* Do appropriate processing given the current state. */
  990. /* Read a lookahead token if we need one and don't already have one. */
  991. /* yyresume: */
  992. /* First try to decide what to do without reference to lookahead token. */
  993. yyn = yypact[yystate];
  994. if (yyn == YYPACT_NINF)
  995. goto yydefault;
  996. /* Not known => get a lookahead token if don't already have one. */
  997. /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
  998. if (yychar == YYEMPTY)
  999. {
  1000. YYDPRINTF ((stderr, "Reading a token: "));
  1001. yychar = YYLEX;
  1002. }
  1003. if (yychar <= YYEOF)
  1004. {
  1005. yychar = yytoken = YYEOF;
  1006. YYDPRINTF ((stderr, "Now at end of input.\n"));
  1007. }
  1008. else
  1009. {
  1010. yytoken = YYTRANSLATE (yychar);
  1011. YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc);
  1012. }
  1013. /* If the proper action on seeing token YYTOKEN is to reduce or to
  1014. detect an error, take that action. */
  1015. yyn += yytoken;
  1016. if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
  1017. goto yydefault;
  1018. yyn = yytable[yyn];
  1019. if (yyn <= 0)
  1020. {
  1021. if (yyn == 0 || yyn == YYTABLE_NINF)
  1022. goto yyerrlab;
  1023. yyn = -yyn;
  1024. goto yyreduce;
  1025. }
  1026. if (yyn == YYFINAL)
  1027. YYACCEPT;
  1028. /* Shift the lookahead token. */
  1029. YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken]));
  1030. /* Discard the token being shifted unless it is eof. */
  1031. if (yychar != YYEOF)
  1032. yychar = YYEMPTY;
  1033. *++yyvsp = yylval;
  1034. /* Count tokens shifted since error; after three, turn off error
  1035. status. */
  1036. if (yyerrstatus)
  1037. yyerrstatus--;
  1038. yystate = yyn;
  1039. goto yynewstate;
  1040. /*-----------------------------------------------------------.
  1041. | yydefault -- do the default action for the current state. |
  1042. `-----------------------------------------------------------*/
  1043. yydefault:
  1044. yyn = yydefact[yystate];
  1045. if (yyn == 0)
  1046. goto yyerrlab;
  1047. goto yyreduce;
  1048. /*-----------------------------.
  1049. | yyreduce -- Do a reduction. |
  1050. `-----------------------------*/
  1051. yyreduce:
  1052. /* yyn is the number of a rule to reduce with. */
  1053. yylen = yyr2[yyn];
  1054. /* If YYLEN is nonzero, implement the default value of the action:
  1055. `$$ = $1'.
  1056. Otherwise, the following line sets YYVAL to garbage.
  1057. This behavior is undocumented and Bison
  1058. users should not rely upon it. Assigning to YYVAL
  1059. unconditionally makes the parser a bit smaller, and it avoids a
  1060. GCC warning that YYVAL may be used uninitialized. */
  1061. yyval = yyvsp[1-yylen];
  1062. YY_REDUCE_PRINT (yyn);
  1063. switch (yyn)
  1064. {
  1065. case 4:
  1066. #line 248 "getdate.y"
  1067. {
  1068. context->yyHaveTime++;
  1069. }
  1070. break;
  1071. case 5:
  1072. #line 251 "getdate.y"
  1073. {
  1074. context->yyHaveZone++;
  1075. }
  1076. break;
  1077. case 6:
  1078. #line 254 "getdate.y"
  1079. {
  1080. context->yyHaveDate++;
  1081. }
  1082. break;
  1083. case 7:
  1084. #line 257 "getdate.y"
  1085. {
  1086. context->yyHaveDay++;
  1087. }
  1088. break;
  1089. case 8:
  1090. #line 260 "getdate.y"
  1091. {
  1092. context->yyHaveRel++;
  1093. }
  1094. break;
  1095. case 10:
  1096. #line 266 "getdate.y"
  1097. {
  1098. context->yyHour = yyvsp[-1].Number;
  1099. context->yyMinutes = 0;
  1100. context->yySeconds = 0;
  1101. context->yyMeridian = yyvsp[0].Meridian;
  1102. }
  1103. break;
  1104. case 11:
  1105. #line 272 "getdate.y"
  1106. {
  1107. context->yyHour = yyvsp[-3].Number;
  1108. context->yyMinutes = yyvsp[-1].Number;
  1109. context->yySeconds = 0;
  1110. context->yyMeridian = yyvsp[0].Meridian;
  1111. }
  1112. break;
  1113. case 12:
  1114. #line 278 "getdate.y"
  1115. {
  1116. context->yyHour = yyvsp[-3].Number;
  1117. context->yyMinutes = yyvsp[-1].Number;
  1118. context->yyMeridian = MER24;
  1119. context->yyHaveZone++;
  1120. context->yyTimezone = (yyvsp[0].Number < 0
  1121. ? -yyvsp[0].Number % 100 + (-yyvsp[0].Number / 100) * 60
  1122. : - (yyvsp[0].Number % 100 + (yyvsp[0].Number / 100) * 60));
  1123. }
  1124. break;
  1125. case 13:
  1126. #line 287 "getdate.y"
  1127. {
  1128. context->yyHour = yyvsp[-5].Number;
  1129. context->yyMinutes = yyvsp[-3].Number;
  1130. context->yySeconds = yyvsp[-1].Number;
  1131. context->yyMeridian = yyvsp[0].Meridian;
  1132. }
  1133. break;
  1134. case 14:
  1135. #line 293 "getdate.y"
  1136. {
  1137. context->yyHour = yyvsp[-5].Number;
  1138. context->yyMinutes = yyvsp[-3].Number;
  1139. context->yySeconds = yyvsp[-1].Number;
  1140. context->yyMeridian = MER24;
  1141. context->yyHaveZone++;
  1142. context->yyTimezone = (yyvsp[0].Number < 0
  1143. ? -yyvsp[0].Number % 100 + (-yyvsp[0].Number / 100) * 60
  1144. : - (yyvsp[0].Number % 100 + (yyvsp[0].Number / 100) * 60));
  1145. }
  1146. break;
  1147. case 15:
  1148. #line 305 "getdate.y"
  1149. {
  1150. context->yyTimezone = yyvsp[0].Number;
  1151. }
  1152. break;
  1153. case 16:
  1154. #line 308 "getdate.y"
  1155. {
  1156. context->yyTimezone = yyvsp[0].Number - 60;
  1157. }
  1158. break;
  1159. case 17:
  1160. #line 312 "getdate.y"
  1161. {
  1162. context->yyTimezone = yyvsp[-1].Number - 60;
  1163. }
  1164. break;
  1165. case 18:
  1166. #line 317 "getdate.y"
  1167. {
  1168. context->yyDayOrdinal = 1;
  1169. context->yyDayNumber = yyvsp[0].Number;
  1170. }
  1171. break;
  1172. case 19:
  1173. #line 321 "getdate.y"
  1174. {
  1175. context->yyDayOrdinal = 1;
  1176. context->yyDayNumber = yyvsp[-1].Number;
  1177. }
  1178. break;
  1179. case 20:
  1180. #line 325 "getdate.y"
  1181. {
  1182. context->yyDayOrdinal = yyvsp[-1].Number;
  1183. context->yyDayNumber = yyvsp[0].Number;
  1184. }
  1185. break;
  1186. case 21:
  1187. #line 331 "getdate.y"
  1188. {
  1189. context->yyMonth = yyvsp[-2].Number;
  1190. context->yyDay = yyvsp[0].Number;
  1191. }
  1192. break;
  1193. case 22:
  1194. #line 335 "getdate.y"
  1195. {
  1196. /* Interpret as YYYY/MM/DD if $1 >= 1000, otherwise as MM/DD/YY.
  1197. The goal in recognizing YYYY/MM/DD is solely to support legacy
  1198. machine-generated dates like those in an RCS log listing. If
  1199. you want portability, use the ISO 8601 format. */
  1200. if (yyvsp[-4].Number >= 1000)
  1201. {
  1202. context->yyYear = yyvsp[-4].Number;
  1203. context->yyMonth = yyvsp[-2].Number;
  1204. context->yyDay = yyvsp[0].Number;
  1205. }
  1206. else
  1207. {
  1208. context->yyMonth = yyvsp[-4].Number;
  1209. context->yyDay = yyvsp[-2].Number;
  1210. context->yyYear = yyvsp[0].Number;
  1211. }
  1212. }
  1213. break;
  1214. case 23:
  1215. #line 353 "getdate.y"
  1216. {
  1217. /* ISO 8601 format. yyyy-mm-dd. */
  1218. context->yyYear = yyvsp[-2].Number;
  1219. context->yyMonth = -yyvsp[-1].Number;
  1220. context->yyDay = -yyvsp[0].Number;
  1221. }
  1222. break;
  1223. case 24:
  1224. #line 359 "getdate.y"
  1225. {
  1226. /* e.g. 17-JUN-1992. */
  1227. context->yyDay = yyvsp[-2].Number;
  1228. context->yyMonth = yyvsp[-1].Number;
  1229. context->yyYear = -yyvsp[0].Number;
  1230. }
  1231. break;
  1232. case 25:
  1233. #line 365 "getdate.y"
  1234. {
  1235. context->yyMonth = yyvsp[-1].Number;
  1236. context->yyDay = yyvsp[0].Number;
  1237. }
  1238. break;
  1239. case 26:
  1240. #line 369 "getdate.y"
  1241. {
  1242. context->yyMonth = yyvsp[-3].Number;
  1243. context->yyDay = yyvsp[-2].Number;
  1244. context->yyYear = yyvsp[0].Number;
  1245. }
  1246. break;
  1247. case 27:
  1248. #line 374 "getdate.y"
  1249. {
  1250. context->yyMonth = yyvsp[0].Number;
  1251. context->yyDay = yyvsp[-1].Number;
  1252. }
  1253. break;
  1254. case 28:
  1255. #line 378 "getdate.y"
  1256. {
  1257. context->yyMonth = yyvsp[-1].Number;
  1258. context->yyDay = yyvsp[-2].Number;
  1259. context->yyYear = yyvsp[0].Number;
  1260. }
  1261. break;
  1262. case 29:
  1263. #line 385 "getdate.y"
  1264. {
  1265. context->yyRelSeconds = -context->yyRelSeconds;
  1266. context->yyRelMinutes = -context->yyRelMinutes;
  1267. context->yyRelHour = -context->yyRelHour;
  1268. context->yyRelDay = -context->yyRelDay;
  1269. context->yyRelMonth = -context->yyRelMonth;
  1270. context->yyRelYear = -context->yyRelYear;
  1271. }
  1272. break;
  1273. case 31:
  1274. #line 396 "getdate.y"
  1275. {
  1276. context->yyRelYear += yyvsp[-1].Number * yyvsp[0].Number;
  1277. }
  1278. break;
  1279. case 32:
  1280. #line 399 "getdate.y"
  1281. {
  1282. context->yyRelYear += yyvsp[-1].Number * yyvsp[0].Number;
  1283. }
  1284. break;
  1285. case 33:
  1286. #line 402 "getdate.y"
  1287. {
  1288. context->yyRelYear += yyvsp[0].Number;
  1289. }
  1290. break;
  1291. case 34:
  1292. #line 405 "getdate.y"
  1293. {
  1294. context->yyRelMonth += yyvsp[-1].Number * yyvsp[0].Number;
  1295. }
  1296. break;
  1297. case 35:
  1298. #line 408 "getdate.y"
  1299. {
  1300. context->yyRelMonth += yyvsp[-1].Number * yyvsp[0].Number;
  1301. }
  1302. break;
  1303. case 36:
  1304. #line 411 "getdate.y"
  1305. {
  1306. context->yyRelMonth += yyvsp[0].Number;
  1307. }
  1308. break;
  1309. case 37:
  1310. #line 414 "getdate.y"
  1311. {
  1312. context->yyRelDay += yyvsp[-1].Number * yyvsp[0].Number;
  1313. }
  1314. break;
  1315. case 38:
  1316. #line 417 "getdate.y"
  1317. {
  1318. context->yyRelDay += yyvsp[-1].Number * yyvsp[0].Number;
  1319. }
  1320. break;
  1321. case 39:
  1322. #line 420 "getdate.y"
  1323. {
  1324. context->yyRelDay += yyvsp[0].Number;
  1325. }
  1326. break;
  1327. case 40:
  1328. #line 423 "getdate.y"
  1329. {
  1330. context->yyRelHour += yyvsp[-1].Number * yyvsp[0].Number;
  1331. }
  1332. break;
  1333. case 41:
  1334. #line 426 "getdate.y"
  1335. {
  1336. context->yyRelHour += yyvsp[-1].Number * yyvsp[0].Number;
  1337. }
  1338. break;
  1339. case 42:
  1340. #line 429 "getdate.y"
  1341. {
  1342. context->yyRelHour += yyvsp[0].Number;
  1343. }
  1344. break;
  1345. case 43:
  1346. #line 432 "getdate.y"
  1347. {
  1348. context->yyRelMinutes += yyvsp[-1].Number * yyvsp[0].Number;
  1349. }
  1350. break;
  1351. case 44:
  1352. #line 435 "getdate.y"
  1353. {
  1354. context->yyRelMinutes += yyvsp[-1].Number * yyvsp[0].Number;
  1355. }
  1356. break;
  1357. case 45:
  1358. #line 438 "getdate.y"
  1359. {
  1360. context->yyRelMinutes += yyvsp[0].Number;
  1361. }
  1362. break;
  1363. case 46:
  1364. #line 441 "getdate.y"
  1365. {
  1366. context->yyRelSeconds += yyvsp[-1].Number * yyvsp[0].Number;
  1367. }
  1368. break;
  1369. case 47:
  1370. #line 444 "getdate.y"
  1371. {
  1372. context->yyRelSeconds += yyvsp[-1].Number * yyvsp[0].Number;
  1373. }
  1374. break;
  1375. case 48:
  1376. #line 447 "getdate.y"
  1377. {
  1378. context->yyRelSeconds += yyvsp[0].Number;
  1379. }
  1380. break;
  1381. case 49:
  1382. #line 453 "getdate.y"
  1383. {
  1384. if (context->yyHaveTime && context->yyHaveDate &&
  1385. !context->yyHaveRel)
  1386. context->yyYear = yyvsp[0].Number;
  1387. else
  1388. {
  1389. if (yyvsp[0].Number>10000)
  1390. {
  1391. context->yyHaveDate++;
  1392. context->yyDay= (yyvsp[0].Number)%100;
  1393. context->yyMonth= (yyvsp[0].Number/100)%100;
  1394. context->yyYear = yyvsp[0].Number/10000;
  1395. }
  1396. else
  1397. {
  1398. context->yyHaveTime++;
  1399. if (yyvsp[0].Number < 100)
  1400. {
  1401. context->yyHour = yyvsp[0].Number;
  1402. context->yyMinutes = 0;
  1403. }
  1404. else
  1405. {
  1406. context->yyHour = yyvsp[0].Number / 100;
  1407. context->yyMinutes = yyvsp[0].Number % 100;
  1408. }
  1409. context->yySeconds = 0;
  1410. context->yyMeridian = MER24;
  1411. }
  1412. }
  1413. }
  1414. break;
  1415. case 50:
  1416. #line 487 "getdate.y"
  1417. {
  1418. yyval.Meridian = MER24;
  1419. }
  1420. break;
  1421. case 51:
  1422. #line 491 "getdate.y"
  1423. {
  1424. yyval.Meridian = yyvsp[0].Meridian;
  1425. }
  1426. break;
  1427. }
  1428. /* Line 999 of yacc.c. */
  1429. #line 1688 "y.tab.c"
  1430. yyvsp -= yylen;
  1431. yyssp -= yylen;
  1432. YY_STACK_PRINT (yyss, yyssp);
  1433. *++yyvsp = yyval;
  1434. /* Now `shift' the result of the reduction. Determine what state
  1435. that goes to, based on the state we popped back to and the rule
  1436. number reduced by. */
  1437. yyn = yyr1[yyn];
  1438. yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
  1439. if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
  1440. yystate = yytable[yystate];
  1441. else
  1442. yystate = yydefgoto[yyn - YYNTOKENS];
  1443. goto yynewstate;
  1444. /*------------------------------------.
  1445. | yyerrlab -- here on detecting error |
  1446. `------------------------------------*/
  1447. yyerrlab:
  1448. /* If not already recovering from an error, report this error. */
  1449. if (!yyerrstatus)
  1450. {
  1451. ++yynerrs;
  1452. #if YYERROR_VERBOSE
  1453. yyn = yypact[yystate];
  1454. if (YYPACT_NINF < yyn && yyn < YYLAST)
  1455. {
  1456. YYSIZE_T yysize = 0;
  1457. int yytype = YYTRANSLATE (yychar);
  1458. char *yymsg;
  1459. int yyx, yycount;
  1460. yycount = 0;
  1461. /* Start YYX at -YYN if negative to avoid negative indexes in
  1462. YYCHECK. */
  1463. for (yyx = yyn < 0 ? -yyn : 0;
  1464. yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
  1465. if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
  1466. yysize += yystrlen (yytname[yyx]) + 15, yycount++;
  1467. yysize += yystrlen ("syntax error, unexpected ") + 1;
  1468. yysize += yystrlen (yytname[yytype]);
  1469. yymsg = (char *) YYSTACK_ALLOC (yysize);
  1470. if (yymsg != 0)
  1471. {
  1472. char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
  1473. yyp = yystpcpy (yyp, yytname[yytype]);
  1474. if (yycount < 5)
  1475. {
  1476. yycount = 0;
  1477. for (yyx = yyn < 0 ? -yyn : 0;
  1478. yyx < (int) (sizeof (yytname) / sizeof (char *));
  1479. yyx++)
  1480. if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
  1481. {
  1482. const char *yyq = ! yycount ? ", expecting " : " or ";
  1483. yyp = yystpcpy (yyp, yyq);
  1484. yyp = yystpcpy (yyp, yytname[yyx]);
  1485. yycount++;
  1486. }
  1487. }
  1488. yyerror (yymsg);
  1489. YYSTACK_FREE (yymsg);
  1490. }
  1491. else
  1492. yyerror ("syntax error; also virtual memory exhausted");
  1493. }
  1494. else
  1495. #endif /* YYERROR_VERBOSE */
  1496. yyerror ("syntax error");
  1497. }
  1498. (void)yynerrs;
  1499. if (yyerrstatus == 3)
  1500. {
  1501. /* If just tried and failed to reuse lookahead token after an
  1502. error, discard it. */
  1503. /* Return failure if at end of input. */
  1504. if (yychar == YYEOF)
  1505. {
  1506. /* Pop the error token. */
  1507. YYPOPSTACK;
  1508. /* Pop the rest of the stack. */
  1509. while (yyss < yyssp)
  1510. {
  1511. YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
  1512. yydestruct (yystos[*yyssp], yyvsp);
  1513. YYPOPSTACK;
  1514. }
  1515. YYABORT;
  1516. }
  1517. YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc);
  1518. yydestruct (yytoken, &yylval);
  1519. yychar = YYEMPTY;
  1520. }
  1521. /* Else will try to reuse lookahead token after shifting the error
  1522. token. */
  1523. goto yyerrlab1;
  1524. /*----------------------------------------------------.
  1525. | yyerrlab1 -- error raised explicitly by an action. |
  1526. `----------------------------------------------------*/
  1527. yyerrlab1:
  1528. yyerrstatus = 3; /* Each real token shifted decrements this. */
  1529. for (;;)
  1530. {
  1531. yyn = yypact[yystate];
  1532. if (yyn != YYPACT_NINF)
  1533. {
  1534. yyn += YYTERROR;
  1535. if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
  1536. {
  1537. yyn = yytable[yyn];
  1538. if (0 < yyn)
  1539. break;
  1540. }
  1541. }
  1542. /* Pop the current state because it cannot handle the error token. */
  1543. if (yyssp == yyss)
  1544. YYABORT;
  1545. YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
  1546. yydestruct (yystos[yystate], yyvsp);
  1547. yyvsp--;
  1548. yystate = *--yyssp;
  1549. YY_STACK_PRINT (yyss, yyssp);
  1550. }
  1551. if (yyn == YYFINAL)
  1552. YYACCEPT;
  1553. YYDPRINTF ((stderr, "Shifting error token, "));
  1554. *++yyvsp = yylval;
  1555. yystate = yyn;
  1556. goto yynewstate;
  1557. /*-------------------------------------.
  1558. | yyacceptlab -- YYACCEPT comes here. |
  1559. `-------------------------------------*/
  1560. yyacceptlab:
  1561. yyresult = 0;
  1562. goto yyreturn;
  1563. /*-----------------------------------.
  1564. | yyabortlab -- YYABORT comes here. |
  1565. `-----------------------------------*/
  1566. yyabortlab:
  1567. yyresult = 1;
  1568. goto yyreturn;
  1569. #ifndef yyoverflow
  1570. /*----------------------------------------------.
  1571. | yyoverflowlab -- parser overflow comes here. |
  1572. `----------------------------------------------*/
  1573. yyoverflowlab:
  1574. yyerror ("parser stack overflow");
  1575. yyresult = 2;
  1576. /* Fall through. */
  1577. #endif
  1578. yyreturn:
  1579. #ifndef yyoverflow
  1580. if (yyss != yyssa)
  1581. YYSTACK_FREE (yyss);
  1582. #endif
  1583. return yyresult;
  1584. }
  1585. #line 496 "getdate.y"
  1586. /* Include this file down here because bison inserts code above which
  1587. may define-away `const'. We want the prototype for get_date to have
  1588. the same signature as the function definition does. */
  1589. #include "getdate.h"
  1590. #ifndef WIN32 /* the windows dudes don't need these, does anyone really? */
  1591. extern struct tm *gmtime (const time_t *);
  1592. extern struct tm *localtime (const time_t *);
  1593. extern time_t mktime (struct tm *);
  1594. #endif
  1595. /* Month and day table. */
  1596. static TABLE const MonthDayTable[] = {
  1597. { "january", tMONTH, 1 },
  1598. { "february", tMONTH, 2 },
  1599. { "march", tMONTH, 3 },
  1600. { "april", tMONTH, 4 },
  1601. { "may", tMONTH, 5 },
  1602. { "june", tMONTH, 6 },
  1603. { "july", tMONTH, 7 },
  1604. { "august", tMONTH, 8 },
  1605. { "september", tMONTH, 9 },
  1606. { "sept", tMONTH, 9 },
  1607. { "october", tMONTH, 10 },
  1608. { "november", tMONTH, 11 },
  1609. { "december", tMONTH, 12 },
  1610. { "sunday", tDAY, 0 },
  1611. { "monday", tDAY, 1 },
  1612. { "tuesday", tDAY, 2 },
  1613. { "tues", tDAY, 2 },
  1614. { "wednesday", tDAY, 3 },
  1615. { "wednes", tDAY, 3 },
  1616. { "thursday", tDAY, 4 },
  1617. { "thur", tDAY, 4 },
  1618. { "thurs", tDAY, 4 },
  1619. { "friday", tDAY, 5 },
  1620. { "saturday", tDAY, 6 },
  1621. { NULL, 0, 0 }
  1622. };
  1623. /* Time units table. */
  1624. static TABLE const UnitsTable[] = {
  1625. { "year", tYEAR_UNIT, 1 },
  1626. { "month", tMONTH_UNIT, 1 },
  1627. { "fortnight", tDAY_UNIT, 14 },
  1628. { "week", tDAY_UNIT, 7 },
  1629. { "day", tDAY_UNIT, 1 },
  1630. { "hour", tHOUR_UNIT, 1 },
  1631. { "minute", tMINUTE_UNIT, 1 },
  1632. { "min", tMINUTE_UNIT, 1 },
  1633. { "second", tSEC_UNIT, 1 },
  1634. { "sec", tSEC_UNIT, 1 },
  1635. { NULL, 0, 0 }
  1636. };
  1637. /* Assorted relative-time words. */
  1638. static TABLE const OtherTable[] = {
  1639. { "tomorrow", tMINUTE_UNIT, 1 * 24 * 60 },
  1640. { "yesterday", tMINUTE_UNIT, -1 * 24 * 60 },
  1641. { "today", tMINUTE_UNIT, 0 },
  1642. { "now", tMINUTE_UNIT, 0 },
  1643. { "last", tUNUMBER, -1 },
  1644. { "this", tMINUTE_UNIT, 0 },
  1645. { "next", tUNUMBER, 1 },
  1646. { "first", tUNUMBER, 1 },
  1647. /* { "second", tUNUMBER, 2 }, */
  1648. { "third", tUNUMBER, 3 },
  1649. { "fourth", tUNUMBER, 4 },
  1650. { "fifth", tUNUMBER, 5 },
  1651. { "sixth", tUNUMBER, 6 },
  1652. { "seventh", tUNUMBER, 7 },
  1653. { "eighth", tUNUMBER, 8 },
  1654. { "ninth", tUNUMBER, 9 },
  1655. { "tenth", tUNUMBER, 10 },
  1656. { "eleventh", tUNUMBER, 11 },
  1657. { "twelfth", tUNUMBER, 12 },
  1658. { "ago", tAGO, 1 },
  1659. { NULL, 0, 0 }
  1660. };
  1661. /* The timezone table. */
  1662. static TABLE const TimezoneTable[] = {
  1663. { "gmt", tZONE, HOUR ( 0) }, /* Greenwich Mean */
  1664. { "ut", tZONE, HOUR ( 0) }, /* Universal (Coordinated) */
  1665. { "utc", tZONE, HOUR ( 0) },
  1666. { "wet", tZONE, HOUR ( 0) }, /* Western European */
  1667. { "bst", tDAYZONE, HOUR ( 0) }, /* British Summer */
  1668. { "wat", tZONE, HOUR ( 1) }, /* West Africa */
  1669. { "at", tZONE, HOUR ( 2) }, /* Azores */
  1670. #if 0
  1671. /* For completeness. BST is also British Summer, and GST is
  1672. * also Guam Standard. */
  1673. { "bst", tZONE, HOUR ( 3) }, /* Brazil Standard */
  1674. { "gst", tZONE, HOUR ( 3) }, /* Greenland Standard */
  1675. #endif
  1676. #if 0
  1677. { "nft", tZONE, HOUR (3.5) }, /* Newfoundland */
  1678. { "nst", tZONE, HOUR (3.5) }, /* Newfoundland Standard */
  1679. { "ndt", tDAYZONE, HOUR (3.5) }, /* Newfoundland Daylight */
  1680. #endif
  1681. { "ast", tZONE, HOUR ( 4) }, /* Atlantic Standard */
  1682. { "adt", tDAYZONE, HOUR ( 4) }, /* Atlantic Daylight */
  1683. { "est", tZONE, HOUR ( 5) }, /* Eastern Standard */
  1684. { "edt", tDAYZONE, HOUR ( 5) }, /* Eastern Daylight */
  1685. { "cst", tZONE, HOUR ( 6) }, /* Central Standard */
  1686. { "cdt", tDAYZONE, HOUR ( 6) }, /* Central Daylight */
  1687. { "mst", tZONE, HOUR ( 7) }, /* Mountain Standard */
  1688. { "mdt", tDAYZONE, HOUR ( 7) }, /* Mountain Daylight */
  1689. { "pst", tZONE, HOUR ( 8) }, /* Pacific Standard */
  1690. { "pdt", tDAYZONE, HOUR ( 8) }, /* Pacific Daylight */
  1691. { "yst", tZONE, HOUR ( 9) }, /* Yukon Standard */
  1692. { "ydt", tDAYZONE, HOUR ( 9) }, /* Yukon Daylight */
  1693. { "hst", tZONE, HOUR (10) }, /* Hawaii Standard */
  1694. { "hdt", tDAYZONE, HOUR (10) }, /* Hawaii Daylight */
  1695. { "cat", tZONE, HOUR (10) }, /* Central Alaska */
  1696. { "ahst", tZONE, HOUR (10) }, /* Alaska-Hawaii Standard */
  1697. { "nt", tZONE, HOUR (11) }, /* Nome */
  1698. { "idlw", tZONE, HOUR (12) }, /* International Date Line West */
  1699. { "cet", tZONE, -HOUR (1) }, /* Central European */
  1700. { "met", tZONE, -HOUR (1) }, /* Middle European */
  1701. { "mewt", tZONE, -HOUR (1) }, /* Middle European Winter */
  1702. { "mest", tDAYZONE, -HOUR (1) }, /* Middle European Summer */
  1703. { "mesz", tDAYZONE, -HOUR (1) }, /* Middle European Summer */
  1704. { "swt", tZONE, -HOUR (1) }, /* Swedish Winter */
  1705. { "sst", tDAYZONE, -HOUR (1) }, /* Swedish Summer */
  1706. { "fwt", tZONE, -HOUR (1) }, /* French Winter */
  1707. { "fst", tDAYZONE, -HOUR (1) }, /* French Summer */
  1708. { "eet", tZONE, -HOUR (2) }, /* Eastern Europe, USSR Zone 1 */
  1709. { "bt", tZONE, -HOUR (3) }, /* Baghdad, USSR Zone 2 */
  1710. #if 0
  1711. { "it", tZONE, -HOUR (3.5) },/* Iran */
  1712. #endif
  1713. { "zp4", tZONE, -HOUR (4) }, /* USSR Zone 3 */
  1714. { "zp5", tZONE, -HOUR (5) }, /* USSR Zone 4 */
  1715. #if 0
  1716. { "ist", tZONE, -HOUR (5.5) },/* Indian Standard */
  1717. #endif
  1718. { "zp6", tZONE, -HOUR (6) }, /* USSR Zone 5 */
  1719. #if 0
  1720. /* For completeness. NST is also Newfoundland Standard, and SST is
  1721. * also Swedish Summer. */
  1722. { "nst", tZONE, -HOUR (6.5) },/* North Sumatra */
  1723. { "sst", tZONE, -HOUR (7) }, /* South Sumatra, USSR Zone 6 */
  1724. #endif /* 0 */
  1725. { "wast", tZONE, -HOUR (7) }, /* West Australian Standard */
  1726. { "wadt", tDAYZONE, -HOUR (7) }, /* West Australian Daylight */
  1727. #if 0
  1728. { "jt", tZONE, -HOUR (7.5) },/* Java (3pm in Cronusland!) */
  1729. #endif
  1730. { "cct", tZONE, -HOUR (8) }, /* China Coast, USSR Zone 7 */
  1731. { "jst", tZONE, -HOUR (9) }, /* Japan Standard, USSR Zone 8 */
  1732. #if 0
  1733. { "cast", tZONE, -HOUR (9.5) },/* Central Australian Standard */
  1734. { "cadt", tDAYZONE, -HOUR (9.5) },/* Central Australian Daylight */
  1735. #endif
  1736. { "east", tZONE, -HOUR (10) }, /* Eastern Australian Standard */
  1737. { "eadt", tDAYZONE, -HOUR (10) }, /* Eastern Australian Daylight */
  1738. { "gst", tZONE, -HOUR (10) }, /* Guam Standard, USSR Zone 9 */
  1739. { "nzt", tZONE, -HOUR (12) }, /* New Zealand */
  1740. { "nzst", tZONE, -HOUR (12) }, /* New Zealand Standard */
  1741. { "nzdt", tDAYZONE, -HOUR (12) }, /* New Zealand Daylight */
  1742. { "idle", tZONE, -HOUR (12) }, /* International Date Line East */
  1743. { NULL, 0, 0 }
  1744. };
  1745. /* Military timezone table. */
  1746. static TABLE const MilitaryTable[] = {
  1747. { "a", tZONE, HOUR ( 1) },
  1748. { "b", tZONE, HOUR ( 2) },
  1749. { "c", tZONE, HOUR ( 3) },
  1750. { "d", tZONE, HOUR ( 4) },
  1751. { "e", tZONE, HOUR ( 5) },
  1752. { "f", tZONE, HOUR ( 6) },
  1753. { "g", tZONE, HOUR ( 7) },
  1754. { "h", tZONE, HOUR ( 8) },
  1755. { "i", tZONE, HOUR ( 9) },
  1756. { "k", tZONE, HOUR ( 10) },
  1757. { "l", tZONE, HOUR ( 11) },
  1758. { "m", tZONE, HOUR ( 12) },
  1759. { "n", tZONE, HOUR (- 1) },
  1760. { "o", tZONE, HOUR (- 2) },
  1761. { "p", tZONE, HOUR (- 3) },
  1762. { "q", tZONE, HOUR (- 4) },
  1763. { "r", tZONE, HOUR (- 5) },
  1764. { "s", tZONE, HOUR (- 6) },
  1765. { "t", tZONE, HOUR (- 7) },
  1766. { "u", tZONE, HOUR (- 8) },
  1767. { "v", tZONE, HOUR (- 9) },
  1768. { "w", tZONE, HOUR (-10) },
  1769. { "x", tZONE, HOUR (-11) },
  1770. { "y", tZONE, HOUR (-12) },
  1771. { "z", tZONE, HOUR ( 0) },
  1772. { NULL, 0, 0 }
  1773. };
  1774. /* ARGSUSED */
  1775. static int
  1776. yyerror (const char *s ATTRIBUTE_UNUSED)
  1777. {
  1778. return 0;
  1779. }
  1780. static int
  1781. ToHour (int Hours, MERIDIAN Meridian)
  1782. {
  1783. switch (Meridian)
  1784. {
  1785. case MER24:
  1786. if (Hours < 0 || Hours > 23)
  1787. return -1;
  1788. return Hours;
  1789. case MERam:
  1790. if (Hours < 1 || Hours > 12)
  1791. return -1;
  1792. if (Hours == 12)
  1793. Hours = 0;
  1794. return Hours;
  1795. case MERpm:
  1796. if (Hours < 1 || Hours > 12)
  1797. return -1;
  1798. if (Hours == 12)
  1799. Hours = 0;
  1800. return Hours + 12;
  1801. default:
  1802. break; /* used to do abort() here */
  1803. }
  1804. /* NOTREACHED - but make gcc happy! */
  1805. return -1;
  1806. }
  1807. static int
  1808. ToYear (int Year)
  1809. {
  1810. if (Year < 0)
  1811. Year = -Year;
  1812. /* XPG4 suggests that years 00-68 map to 2000-2068, and
  1813. years 69-99 map to 1969-1999. */
  1814. if (Year < 69)
  1815. Year += 2000;
  1816. else if (Year < 100)
  1817. Year += 1900;
  1818. return Year;
  1819. }
  1820. static int
  1821. LookupWord (YYSTYPE *yylval, char *buff)
  1822. {
  1823. char *p;
  1824. char *q;
  1825. const TABLE *tp;
  1826. size_t i;
  1827. int abbrev;
  1828. /* Make it lowercase. */
  1829. for (p = buff; *p; p++)
  1830. if (ISUPPER ((unsigned char) *p))
  1831. *p = tolower ((int)*p);
  1832. if (strcmp (buff, "am") == 0 || strcmp (buff, "a.m.") == 0)
  1833. {
  1834. yylval->Meridian = MERam;
  1835. return tMERIDIAN;
  1836. }
  1837. if (strcmp (buff, "pm") == 0 || strcmp (buff, "p.m.") == 0)
  1838. {
  1839. yylval->Meridian = MERpm;
  1840. return tMERIDIAN;
  1841. }
  1842. /* See if we have an abbreviation for a month. */
  1843. if (strlen (buff) == 3)
  1844. abbrev = 1;
  1845. else if (strlen (buff) == 4 && buff[3] == '.')
  1846. {
  1847. abbrev = 1;
  1848. buff[3] = '\0';
  1849. }
  1850. else
  1851. abbrev = 0;
  1852. for (tp = MonthDayTable; tp->name; tp++)
  1853. {
  1854. if (abbrev)
  1855. {
  1856. if (strncmp (buff, tp->name, 3) == 0)
  1857. {
  1858. yylval->Number = tp->value;
  1859. return tp->type;
  1860. }
  1861. }
  1862. else if (strcmp (buff, tp->name) == 0)
  1863. {
  1864. yylval->Number = tp->value;
  1865. return tp->type;
  1866. }
  1867. }
  1868. for (tp = TimezoneTable; tp->name; tp++)
  1869. if (strcmp (buff, tp->name) == 0)
  1870. {
  1871. yylval->Number = tp->value;
  1872. return tp->type;
  1873. }
  1874. if (strcmp (buff, "dst") == 0)
  1875. return tDST;
  1876. for (tp = UnitsTable; tp->name; tp++)
  1877. if (strcmp (buff, tp->name) == 0)
  1878. {
  1879. yylval->Number = tp->value;
  1880. return tp->type;
  1881. }
  1882. /* Strip off any plural and try the units table again. */
  1883. i = strlen (buff) - 1;
  1884. if (buff[i] == 's')
  1885. {
  1886. buff[i] = '\0';
  1887. for (tp = UnitsTable; tp->name; tp++)
  1888. if (strcmp (buff, tp->name) == 0)
  1889. {
  1890. yylval->Number = tp->value;
  1891. return tp->type;
  1892. }
  1893. buff[i] = 's'; /* Put back for "this" in OtherTable. */
  1894. }
  1895. for (tp = OtherTable; tp->name; tp++)
  1896. if (strcmp (buff, tp->name) == 0)
  1897. {
  1898. yylval->Number = tp->value;
  1899. return tp->type;
  1900. }
  1901. /* Military timezones. */
  1902. if (buff[1] == '\0' && ISALPHA ((unsigned char) *buff))
  1903. {
  1904. for (tp = MilitaryTable; tp->name; tp++)
  1905. if (strcmp (buff, tp->name) == 0)
  1906. {
  1907. yylval->Number = tp->value;
  1908. return tp->type;
  1909. }
  1910. }
  1911. /* Drop out any periods and try the timezone table again. */
  1912. for (i = 0, p = q = buff; *q; q++)
  1913. if (*q != '.')
  1914. *p++ = *q;
  1915. else
  1916. i++;
  1917. *p = '\0';
  1918. if (i)
  1919. for (tp = TimezoneTable; tp->name; tp++)
  1920. if (strcmp (buff, tp->name) == 0)
  1921. {
  1922. yylval->Number = tp->value;
  1923. return tp->type;
  1924. }
  1925. return tID;
  1926. }
  1927. static int
  1928. yylex (YYSTYPE *yylval, void *cookie)
  1929. {
  1930. register unsigned char c;
  1931. register char *p;
  1932. char buff[20];
  1933. int Count;
  1934. int sign;
  1935. for (;;)
  1936. {
  1937. while (ISSPACE ((unsigned char) *context->yyInput))
  1938. context->yyInput++;
  1939. if (ISDIGIT (c = *context->yyInput) || c == '-' || c == '+')
  1940. {
  1941. if (c == '-' || c == '+')
  1942. {
  1943. sign = c == '-' ? -1 : 1;
  1944. if (!ISDIGIT (*++context->yyInput))
  1945. /* skip the '-' sign */
  1946. continue;
  1947. }
  1948. else
  1949. sign = 0;
  1950. for (yylval->Number = 0; ISDIGIT (c = *context->yyInput++);)
  1951. yylval->Number = 10 * yylval->Number + c - '0';
  1952. context->yyInput--;
  1953. if (sign < 0)
  1954. yylval->Number = -yylval->Number;
  1955. return sign ? tSNUMBER : tUNUMBER;
  1956. }
  1957. if (ISALPHA (c))
  1958. {
  1959. for (p = buff; (c = *context->yyInput++, ISALPHA (c)) || c == '.';)
  1960. if (p < &buff[sizeof buff - 1])
  1961. *p++ = c;
  1962. *p = '\0';
  1963. context->yyInput--;
  1964. return LookupWord (yylval, buff);
  1965. }
  1966. if (c != '(')
  1967. return *context->yyInput++;
  1968. Count = 0;
  1969. do
  1970. {
  1971. c = *context->yyInput++;
  1972. if (c == '\0')
  1973. return c;
  1974. if (c == '(')
  1975. Count++;
  1976. else if (c == ')')
  1977. Count--;
  1978. }
  1979. while (Count > 0);
  1980. }
  1981. }
  1982. #define TM_YEAR_ORIGIN 1900
  1983. /* Yield A - B, measured in seconds. */
  1984. static long
  1985. difftm (struct tm *a, struct tm *b)
  1986. {
  1987. int ay = a->tm_year + (TM_YEAR_ORIGIN - 1);
  1988. int by = b->tm_year + (TM_YEAR_ORIGIN - 1);
  1989. long days = (
  1990. /* difference in day of year */
  1991. a->tm_yday - b->tm_yday
  1992. /* + intervening leap days */
  1993. + ((ay >> 2) - (by >> 2))
  1994. - (ay / 100 - by / 100)
  1995. + ((ay / 100 >> 2) - (by / 100 >> 2))
  1996. /* + difference in years * 365 */
  1997. + (long) (ay - by) * 365
  1998. );
  1999. return (60 * (60 * (24 * days + (a->tm_hour - b->tm_hour))
  2000. + (a->tm_min - b->tm_min))
  2001. + (a->tm_sec - b->tm_sec));
  2002. }
  2003. time_t
  2004. curl_getdate (const char *p, const time_t *now)
  2005. {
  2006. struct tm tm, tm0, *tmp;
  2007. time_t Start;
  2008. CURL_CONTEXT cookie;
  2009. #ifdef HAVE_LOCALTIME_R
  2010. struct tm keeptime;
  2011. #endif
  2012. cookie.yyInput = p;
  2013. Start = now ? *now : time ((time_t *) NULL);
  2014. #ifdef HAVE_LOCALTIME_R
  2015. tmp = (struct tm *)localtime_r(&Start, &keeptime);
  2016. #else
  2017. tmp = localtime (&Start);
  2018. #endif
  2019. if (!tmp)
  2020. return -1;
  2021. cookie.yyYear = tmp->tm_year + TM_YEAR_ORIGIN;
  2022. cookie.yyMonth = tmp->tm_mon + 1;
  2023. cookie.yyDay = tmp->tm_mday;
  2024. cookie.yyHour = tmp->tm_hour;
  2025. cookie.yyMinutes = tmp->tm_min;
  2026. cookie.yySeconds = tmp->tm_sec;
  2027. tm.tm_isdst = tmp->tm_isdst;
  2028. cookie.yyMeridian = MER24;
  2029. cookie.yyRelSeconds = 0;
  2030. cookie.yyRelMinutes = 0;
  2031. cookie.yyRelHour = 0;
  2032. cookie.yyRelDay = 0;
  2033. cookie.yyRelMonth = 0;
  2034. cookie.yyRelYear = 0;
  2035. cookie.yyHaveDate = 0;
  2036. cookie.yyHaveDay = 0;
  2037. cookie.yyHaveRel = 0;
  2038. cookie.yyHaveTime = 0;
  2039. cookie.yyHaveZone = 0;
  2040. if (yyparse ((void*)&cookie)
  2041. || cookie.yyHaveTime > 1 || cookie.yyHaveZone > 1 ||
  2042. cookie.yyHaveDate > 1 || cookie.yyHaveDay > 1)
  2043. return -1;
  2044. tm.tm_year = ToYear (cookie.yyYear) - TM_YEAR_ORIGIN + cookie.yyRelYear;
  2045. tm.tm_mon = cookie.yyMonth - 1 + cookie.yyRelMonth;
  2046. tm.tm_mday = cookie.yyDay + cookie.yyRelDay;
  2047. if (cookie.yyHaveTime ||
  2048. (cookie.yyHaveRel && !cookie.yyHaveDate && !cookie.yyHaveDay))
  2049. {
  2050. tm.tm_hour = ToHour (cookie.yyHour, cookie.yyMeridian);
  2051. if (tm.tm_hour < 0)
  2052. return -1;
  2053. tm.tm_min = cookie.yyMinutes;
  2054. tm.tm_sec = cookie.yySeconds;
  2055. }
  2056. else
  2057. {
  2058. tm.tm_hour = tm.tm_min = tm.tm_sec = 0;
  2059. }
  2060. tm.tm_hour += cookie.yyRelHour;
  2061. tm.tm_min += cookie.yyRelMinutes;
  2062. tm.tm_sec += cookie.yyRelSeconds;
  2063. /* Let mktime deduce tm_isdst if we have an absolute timestamp,
  2064. or if the relative timestamp mentions days, months, or years. */
  2065. if (cookie.yyHaveDate | cookie.yyHaveDay | cookie.yyHaveTime |
  2066. cookie.yyRelDay | cookie.yyRelMonth | cookie.yyRelYear)
  2067. tm.tm_isdst = -1;
  2068. tm0 = tm;
  2069. Start = mktime (&tm);
  2070. if (Start == (time_t) -1)
  2071. {
  2072. /* Guard against falsely reporting errors near the time_t boundaries
  2073. when parsing times in other time zones. For example, if the min
  2074. time_t value is 1970-01-01 00:00:00 UTC and we are 8 hours ahead
  2075. of UTC, then the min localtime value is 1970-01-01 08:00:00; if
  2076. we apply mktime to 1970-01-01 00:00:00 we will get an error, so
  2077. we apply mktime to 1970-01-02 08:00:00 instead and adjust the time
  2078. zone by 24 hours to compensate. This algorithm assumes that
  2079. there is no DST transition within a day of the time_t boundaries. */
  2080. if (cookie.yyHaveZone)
  2081. {
  2082. tm = tm0;
  2083. if (tm.tm_year <= EPOCH - TM_YEAR_ORIGIN)
  2084. {
  2085. tm.tm_mday++;
  2086. cookie.yyTimezone -= 24 * 60;
  2087. }
  2088. else
  2089. {
  2090. tm.tm_mday--;
  2091. cookie.yyTimezone += 24 * 60;
  2092. }
  2093. Start = mktime (&tm);
  2094. }
  2095. if (Start == (time_t) -1)
  2096. return Start;
  2097. }
  2098. if (cookie.yyHaveDay && !cookie.yyHaveDate)
  2099. {
  2100. tm.tm_mday += ((cookie.yyDayNumber - tm.tm_wday + 7) % 7
  2101. + 7 * (cookie.yyDayOrdinal - (0 < cookie.yyDayOrdinal)));
  2102. Start = mktime (&tm);
  2103. if (Start == (time_t) -1)
  2104. return Start;
  2105. }
  2106. if (cookie.yyHaveZone)
  2107. {
  2108. long delta;
  2109. struct tm *gmt;
  2110. #ifdef HAVE_GMTIME_R
  2111. /* thread-safe version */
  2112. struct tm keeptime2;
  2113. gmt = (struct tm *)gmtime_r(&Start, &keeptime2);
  2114. #else
  2115. gmt = gmtime(&Start);
  2116. #endif
  2117. if (!gmt)
  2118. return -1;
  2119. delta = cookie.yyTimezone * 60L + difftm (&tm, gmt);
  2120. if ((Start + delta < Start) != (delta < 0))
  2121. return -1; /* time_t overflow */
  2122. Start += delta;
  2123. }
  2124. return Start;
  2125. }