PageRenderTime 59ms CodeModel.GetById 30ms RepoModel.GetById 1ms app.codeStats 0ms

/opensource.apple.com/source/curl/curl-15/curl/lib/getdate.y

#
Happy | 1130 lines | 1037 code | 93 blank | 0 comment | 0 complexity | e7ad7027c6d11ce8f0bc48b467264582 MD5 | raw file
Possible License(s): LGPL-2.0, MPL-2.0, GPL-2.0, ISC, LGPL-2.1, Apache-2.0, MPL-2.0-no-copyleft-exception, BSD-3-Clause, WTFPL, MIT, AGPL-1.0, AGPL-3.0
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  4. <head>
  5. <title>getdate.y</title>
  6. <style type="text/css">
  7. .enscript-comment { font-style: italic; color: rgb(178,34,34); }
  8. .enscript-function-name { font-weight: bold; color: rgb(0,0,255); }
  9. .enscript-variable-name { font-weight: bold; color: rgb(184,134,11); }
  10. .enscript-keyword { font-weight: bold; color: rgb(160,32,240); }
  11. .enscript-reference { font-weight: bold; color: rgb(95,158,160); }
  12. .enscript-string { font-weight: bold; color: rgb(188,143,143); }
  13. .enscript-builtin { font-weight: bold; color: rgb(218,112,214); }
  14. .enscript-type { font-weight: bold; color: rgb(34,139,34); }
  15. .enscript-highlight { text-decoration: underline; color: 0; }
  16. </style>
  17. </head>
  18. <body id="top">
  19. <h1 style="margin:8px;" id="f1">getdate.y&nbsp;&nbsp;&nbsp;<span style="font-weight: normal; font-size: 0.5em;">[<a href="?txt">plain text</a>]</span></h1>
  20. <hr/>
  21. <div></div>
  22. <pre>
  23. %{
  24. /*
  25. ** Originally written by Steven M. Bellovin &lt;<a href="mailto:smb@research.att.com">smb@research.att.com</a>&gt; while
  26. ** at the University of North Carolina at Chapel Hill. Later tweaked by
  27. ** a couple of people on Usenet. Completely overhauled by Rich $alz
  28. ** &lt;<a href="mailto:rsalz@bbn.com">rsalz@bbn.com</a>&gt; and Jim Berets &lt;<a href="mailto:jberets@bbn.com">jberets@bbn.com</a>&gt; in August, 1990.
  29. **
  30. ** This code is in the public domain and has no copyright.
  31. */
  32. #include &quot;setup.h&quot;
  33. # ifdef HAVE_ALLOCA_H
  34. # include &lt;alloca.h&gt;
  35. # endif
  36. # ifdef HAVE_TIME_H
  37. # include &lt;time.h&gt;
  38. # endif
  39. #ifndef YYDEBUG
  40. /* to satisfy gcc -Wundef, we set this to 0 */
  41. #define YYDEBUG 0
  42. #endif
  43. /* Since the code of getdate.y is not included in the Emacs executable
  44. itself, there is no need to #define static in this file. Even if
  45. the code were included in the Emacs executable, it probably
  46. wouldn't do any harm to #undef it here; this will only cause
  47. problems if we try to write to a static variable, which I don't
  48. think this code needs to do. */
  49. #ifdef emacs
  50. # undef static
  51. #endif
  52. #ifdef __APPLE__
  53. #include &lt;sys/types.h&gt;
  54. #include &lt;sys/malloc.h&gt;
  55. #else
  56. #endif
  57. #include &lt;string.h&gt;
  58. #include &lt;stdio.h&gt;
  59. #include &lt;ctype.h&gt;
  60. #if HAVE_STDLIB_H
  61. # include &lt;stdlib.h&gt; /* for `free'; used by Bison 1.27 */
  62. #else
  63. #ifdef HAVE_MALLOC_H
  64. #include &lt;malloc.h&gt;
  65. #endif
  66. #endif
  67. #if defined (STDC_HEADERS) || (!defined (isascii) &amp;&amp; !defined (HAVE_ISASCII))
  68. # define IN_CTYPE_DOMAIN(c) 1
  69. #else
  70. # define IN_CTYPE_DOMAIN(c) isascii(c)
  71. #endif
  72. #define ISSPACE(c) (IN_CTYPE_DOMAIN (c) &amp;&amp; isspace (c))
  73. #define ISALPHA(c) (IN_CTYPE_DOMAIN (c) &amp;&amp; isalpha (c))
  74. #define ISUPPER(c) (IN_CTYPE_DOMAIN (c) &amp;&amp; isupper (c))
  75. #define ISDIGIT_LOCALE(c) (IN_CTYPE_DOMAIN (c) &amp;&amp; isdigit (c))
  76. /* ISDIGIT differs from ISDIGIT_LOCALE, as follows:
  77. - Its arg may be any int or unsigned int; it need not be an unsigned char.
  78. - It's guaranteed to evaluate its argument exactly once.
  79. - It's typically faster.
  80. Posix 1003.2-1992 section 2.5.2.1 page 50 lines 1556-1558 says that
  81. only '0' through '9' are digits. Prefer ISDIGIT to ISDIGIT_LOCALE unless
  82. it's important to use the locale's definition of `digit' even when the
  83. host does not conform to Posix. */
  84. #define ISDIGIT(c) ((unsigned) (c) - '0' &lt;= 9)
  85. #if defined (STDC_HEADERS) || defined (USG)
  86. # include &lt;string.h&gt;
  87. #endif
  88. /* The last #include file should be: */
  89. #ifdef MALLOCDEBUG
  90. #include &quot;memdebug.h&quot;
  91. #endif
  92. #if __GNUC__ &lt; 2 || (__GNUC__ == 2 &amp;&amp; __GNUC_MINOR__ &lt; 7)
  93. # define __attribute__(x)
  94. #endif
  95. #ifndef ATTRIBUTE_UNUSED
  96. # define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
  97. #endif
  98. /* Some old versions of bison generate parsers that use bcopy.
  99. That loses on systems that don't provide the function, so we have
  100. to redefine it here. */
  101. #if !defined (HAVE_BCOPY) &amp;&amp; defined (HAVE_MEMCPY) &amp;&amp; !defined (bcopy)
  102. # define bcopy(from, to, len) memcpy ((to), (from), (len))
  103. #endif
  104. /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
  105. as well as gratuitiously global symbol names, so we can have multiple
  106. yacc generated parsers in the same program. Note that these are only
  107. the variables produced by yacc. If other parser generators (bison,
  108. byacc, etc) produce additional global names that conflict at link time,
  109. then those parser generators need to be fixed instead of adding those
  110. names to this list. */
  111. #define yymaxdepth Curl_gd_maxdepth
  112. #define yyparse Curl_gd_parse
  113. #define yylex Curl_gd_lex
  114. #define yyerror Curl_gd_error
  115. #define yylval Curl_gd_lval
  116. #define yychar Curl_gd_char
  117. #define yydebug Curl_gd_debug
  118. #define yypact Curl_gd_pact
  119. #define yyr1 Curl_gd_r1
  120. #define yyr2 Curl_gd_r2
  121. #define yydef Curl_gd_def
  122. #define yychk Curl_gd_chk
  123. #define yypgo Curl_gd_pgo
  124. #define yyact Curl_gd_act
  125. #define yyexca Curl_gd_exca
  126. #define yyerrflag Curl_gd_errflag
  127. #define yynerrs Curl_gd_nerrs
  128. #define yyps Curl_gd_ps
  129. #define yypv Curl_gd_pv
  130. #define yys Curl_gd_s
  131. #define yy_yys Curl_gd_yys
  132. #define yystate Curl_gd_state
  133. #define yytmp Curl_gd_tmp
  134. #define yyv Curl_gd_v
  135. #define yy_yyv Curl_gd_yyv
  136. #define yyval Curl_gd_val
  137. #define yylloc Curl_gd_lloc
  138. #define yyreds Curl_gd_reds /* With YYDEBUG defined */
  139. #define yytoks Curl_gd_toks /* With YYDEBUG defined */
  140. #define yylhs Curl_gd_yylhs
  141. #define yylen Curl_gd_yylen
  142. #define yydefred Curl_gd_yydefred
  143. #define yydgoto Curl_gd_yydgoto
  144. #define yysindex Curl_gd_yysindex
  145. #define yyrindex Curl_gd_yyrindex
  146. #define yygindex Curl_gd_yygindex
  147. #define yytable Curl_gd_yytable
  148. #define yycheck Curl_gd_yycheck
  149. static int yylex ();
  150. static int yyerror ();
  151. #define EPOCH 1970
  152. #define HOUR(x) ((x) * 60)
  153. #define MAX_BUFF_LEN 128 /* size of buffer to read the date into */
  154. /*
  155. ** An entry in the lexical lookup table.
  156. */
  157. typedef struct _TABLE {
  158. const char *name;
  159. int type;
  160. int value;
  161. } TABLE;
  162. /*
  163. ** Meridian: am, pm, or 24-hour style.
  164. */
  165. typedef enum _MERIDIAN {
  166. MERam, MERpm, MER24
  167. } MERIDIAN;
  168. /* parse results and input string */
  169. typedef struct _CONTEXT {
  170. const char *yyInput;
  171. int yyDayOrdinal;
  172. int yyDayNumber;
  173. int yyHaveDate;
  174. int yyHaveDay;
  175. int yyHaveRel;
  176. int yyHaveTime;
  177. int yyHaveZone;
  178. int yyTimezone;
  179. int yyDay;
  180. int yyHour;
  181. int yyMinutes;
  182. int yyMonth;
  183. int yySeconds;
  184. int yyYear;
  185. MERIDIAN yyMeridian;
  186. int yyRelDay;
  187. int yyRelHour;
  188. int yyRelMinutes;
  189. int yyRelMonth;
  190. int yyRelSeconds;
  191. int yyRelYear;
  192. } CONTEXT;
  193. /* enable use of extra argument to yyparse and yylex which can be used to pass
  194. ** in a user defined value (CONTEXT struct in our case)
  195. */
  196. #define YYPARSE_PARAM cookie
  197. #define YYLEX_PARAM cookie
  198. #define context ((CONTEXT *) cookie)
  199. %}
  200. /* This grammar has 13 shift/reduce conflicts. */
  201. %expect 13
  202. /* turn global variables into locals, additionally enable extra arguments
  203. ** for yylex (pointer to yylval and user defined value)
  204. */
  205. %pure_parser
  206. %union {
  207. int Number;
  208. enum _MERIDIAN Meridian;
  209. }
  210. %token tAGO tDAY tDAY_UNIT tDAYZONE tDST tHOUR_UNIT tID
  211. %token tMERIDIAN tMINUTE_UNIT tMONTH tMONTH_UNIT
  212. %token tSEC_UNIT tSNUMBER tUNUMBER tYEAR_UNIT tZONE
  213. %type &lt;Number&gt; tDAY tDAY_UNIT tDAYZONE tHOUR_UNIT tMINUTE_UNIT
  214. %type &lt;Number&gt; tMONTH tMONTH_UNIT
  215. %type &lt;Number&gt; tSEC_UNIT tSNUMBER tUNUMBER tYEAR_UNIT tZONE
  216. %type &lt;Meridian&gt; tMERIDIAN o_merid
  217. %%
  218. spec : /* NULL */
  219. | spec item
  220. ;
  221. item : time {
  222. context-&gt;yyHaveTime++;
  223. }
  224. | zone {
  225. context-&gt;yyHaveZone++;
  226. }
  227. | date {
  228. context-&gt;yyHaveDate++;
  229. }
  230. | day {
  231. context-&gt;yyHaveDay++;
  232. }
  233. | rel {
  234. context-&gt;yyHaveRel++;
  235. }
  236. | number
  237. ;
  238. time : tUNUMBER tMERIDIAN {
  239. context-&gt;yyHour = $1;
  240. context-&gt;yyMinutes = 0;
  241. context-&gt;yySeconds = 0;
  242. context-&gt;yyMeridian = $2;
  243. }
  244. | tUNUMBER ':' tUNUMBER o_merid {
  245. context-&gt;yyHour = $1;
  246. context-&gt;yyMinutes = $3;
  247. context-&gt;yySeconds = 0;
  248. context-&gt;yyMeridian = $4;
  249. }
  250. | tUNUMBER ':' tUNUMBER tSNUMBER {
  251. context-&gt;yyHour = $1;
  252. context-&gt;yyMinutes = $3;
  253. context-&gt;yyMeridian = MER24;
  254. context-&gt;yyHaveZone++;
  255. context-&gt;yyTimezone = ($4 &lt; 0
  256. ? -$4 % 100 + (-$4 / 100) * 60
  257. : - ($4 % 100 + ($4 / 100) * 60));
  258. }
  259. | tUNUMBER ':' tUNUMBER ':' tUNUMBER o_merid {
  260. context-&gt;yyHour = $1;
  261. context-&gt;yyMinutes = $3;
  262. context-&gt;yySeconds = $5;
  263. context-&gt;yyMeridian = $6;
  264. }
  265. | tUNUMBER ':' tUNUMBER ':' tUNUMBER tSNUMBER {
  266. context-&gt;yyHour = $1;
  267. context-&gt;yyMinutes = $3;
  268. context-&gt;yySeconds = $5;
  269. context-&gt;yyMeridian = MER24;
  270. context-&gt;yyHaveZone++;
  271. context-&gt;yyTimezone = ($6 &lt; 0
  272. ? -$6 % 100 + (-$6 / 100) * 60
  273. : - ($6 % 100 + ($6 / 100) * 60));
  274. }
  275. ;
  276. zone : tZONE {
  277. context-&gt;yyTimezone = $1;
  278. }
  279. | tDAYZONE {
  280. context-&gt;yyTimezone = $1 - 60;
  281. }
  282. |
  283. tZONE tDST {
  284. context-&gt;yyTimezone = $1 - 60;
  285. }
  286. ;
  287. day : tDAY {
  288. context-&gt;yyDayOrdinal = 1;
  289. context-&gt;yyDayNumber = $1;
  290. }
  291. | tDAY ',' {
  292. context-&gt;yyDayOrdinal = 1;
  293. context-&gt;yyDayNumber = $1;
  294. }
  295. | tUNUMBER tDAY {
  296. context-&gt;yyDayOrdinal = $1;
  297. context-&gt;yyDayNumber = $2;
  298. }
  299. ;
  300. date : tUNUMBER '/' tUNUMBER {
  301. context-&gt;yyMonth = $1;
  302. context-&gt;yyDay = $3;
  303. }
  304. | tUNUMBER '/' tUNUMBER '/' tUNUMBER {
  305. /* Interpret as YYYY/MM/DD if $1 &gt;= 1000, otherwise as MM/DD/YY.
  306. The goal in recognizing YYYY/MM/DD is solely to support legacy
  307. machine-generated dates like those in an RCS log listing. If
  308. you want portability, use the ISO 8601 format. */
  309. if ($1 &gt;= 1000)
  310. {
  311. context-&gt;yyYear = $1;
  312. context-&gt;yyMonth = $3;
  313. context-&gt;yyDay = $5;
  314. }
  315. else
  316. {
  317. context-&gt;yyMonth = $1;
  318. context-&gt;yyDay = $3;
  319. context-&gt;yyYear = $5;
  320. }
  321. }
  322. | tUNUMBER tSNUMBER tSNUMBER {
  323. /* ISO 8601 format. yyyy-mm-dd. */
  324. context-&gt;yyYear = $1;
  325. context-&gt;yyMonth = -$2;
  326. context-&gt;yyDay = -$3;
  327. }
  328. | tUNUMBER tMONTH tSNUMBER {
  329. /* e.g. 17-JUN-1992. */
  330. context-&gt;yyDay = $1;
  331. context-&gt;yyMonth = $2;
  332. context-&gt;yyYear = -$3;
  333. }
  334. | tMONTH tUNUMBER {
  335. context-&gt;yyMonth = $1;
  336. context-&gt;yyDay = $2;
  337. }
  338. | tMONTH tUNUMBER ',' tUNUMBER {
  339. context-&gt;yyMonth = $1;
  340. context-&gt;yyDay = $2;
  341. context-&gt;yyYear = $4;
  342. }
  343. | tUNUMBER tMONTH {
  344. context-&gt;yyMonth = $2;
  345. context-&gt;yyDay = $1;
  346. }
  347. | tUNUMBER tMONTH tUNUMBER {
  348. context-&gt;yyMonth = $2;
  349. context-&gt;yyDay = $1;
  350. context-&gt;yyYear = $3;
  351. }
  352. ;
  353. rel : relunit tAGO {
  354. context-&gt;yyRelSeconds = -context-&gt;yyRelSeconds;
  355. context-&gt;yyRelMinutes = -context-&gt;yyRelMinutes;
  356. context-&gt;yyRelHour = -context-&gt;yyRelHour;
  357. context-&gt;yyRelDay = -context-&gt;yyRelDay;
  358. context-&gt;yyRelMonth = -context-&gt;yyRelMonth;
  359. context-&gt;yyRelYear = -context-&gt;yyRelYear;
  360. }
  361. | relunit
  362. ;
  363. relunit : tUNUMBER tYEAR_UNIT {
  364. context-&gt;yyRelYear += $1 * $2;
  365. }
  366. | tSNUMBER tYEAR_UNIT {
  367. context-&gt;yyRelYear += $1 * $2;
  368. }
  369. | tYEAR_UNIT {
  370. context-&gt;yyRelYear += $1;
  371. }
  372. | tUNUMBER tMONTH_UNIT {
  373. context-&gt;yyRelMonth += $1 * $2;
  374. }
  375. | tSNUMBER tMONTH_UNIT {
  376. context-&gt;yyRelMonth += $1 * $2;
  377. }
  378. | tMONTH_UNIT {
  379. context-&gt;yyRelMonth += $1;
  380. }
  381. | tUNUMBER tDAY_UNIT {
  382. context-&gt;yyRelDay += $1 * $2;
  383. }
  384. | tSNUMBER tDAY_UNIT {
  385. context-&gt;yyRelDay += $1 * $2;
  386. }
  387. | tDAY_UNIT {
  388. context-&gt;yyRelDay += $1;
  389. }
  390. | tUNUMBER tHOUR_UNIT {
  391. context-&gt;yyRelHour += $1 * $2;
  392. }
  393. | tSNUMBER tHOUR_UNIT {
  394. context-&gt;yyRelHour += $1 * $2;
  395. }
  396. | tHOUR_UNIT {
  397. context-&gt;yyRelHour += $1;
  398. }
  399. | tUNUMBER tMINUTE_UNIT {
  400. context-&gt;yyRelMinutes += $1 * $2;
  401. }
  402. | tSNUMBER tMINUTE_UNIT {
  403. context-&gt;yyRelMinutes += $1 * $2;
  404. }
  405. | tMINUTE_UNIT {
  406. context-&gt;yyRelMinutes += $1;
  407. }
  408. | tUNUMBER tSEC_UNIT {
  409. context-&gt;yyRelSeconds += $1 * $2;
  410. }
  411. | tSNUMBER tSEC_UNIT {
  412. context-&gt;yyRelSeconds += $1 * $2;
  413. }
  414. | tSEC_UNIT {
  415. context-&gt;yyRelSeconds += $1;
  416. }
  417. ;
  418. number : tUNUMBER
  419. {
  420. if (context-&gt;yyHaveTime &amp;&amp; context-&gt;yyHaveDate &amp;&amp;
  421. !context-&gt;yyHaveRel)
  422. context-&gt;yyYear = $1;
  423. else
  424. {
  425. if ($1&gt;10000)
  426. {
  427. context-&gt;yyHaveDate++;
  428. context-&gt;yyDay= ($1)%100;
  429. context-&gt;yyMonth= ($1/100)%100;
  430. context-&gt;yyYear = $1/10000;
  431. }
  432. else
  433. {
  434. context-&gt;yyHaveTime++;
  435. if ($1 &lt; 100)
  436. {
  437. context-&gt;yyHour = $1;
  438. context-&gt;yyMinutes = 0;
  439. }
  440. else
  441. {
  442. context-&gt;yyHour = $1 / 100;
  443. context-&gt;yyMinutes = $1 % 100;
  444. }
  445. context-&gt;yySeconds = 0;
  446. context-&gt;yyMeridian = MER24;
  447. }
  448. }
  449. }
  450. ;
  451. o_merid : /* NULL */
  452. {
  453. $$ = MER24;
  454. }
  455. | tMERIDIAN
  456. {
  457. $$ = $1;
  458. }
  459. ;
  460. %%
  461. /* Include this file down here because bison inserts code above which
  462. may define-away `const'. We want the prototype for get_date to have
  463. the same signature as the function definition does. */
  464. #include &quot;getdate.h&quot;
  465. #ifndef WIN32 /* the windows dudes don't need these, does anyone really? */
  466. extern struct tm *gmtime ();
  467. extern struct tm *localtime ();
  468. extern time_t mktime ();
  469. #endif
  470. /* Month and day table. */
  471. static TABLE const MonthDayTable[] = {
  472. { &quot;january&quot;, tMONTH, 1 },
  473. { &quot;february&quot;, tMONTH, 2 },
  474. { &quot;march&quot;, tMONTH, 3 },
  475. { &quot;april&quot;, tMONTH, 4 },
  476. { &quot;may&quot;, tMONTH, 5 },
  477. { &quot;june&quot;, tMONTH, 6 },
  478. { &quot;july&quot;, tMONTH, 7 },
  479. { &quot;august&quot;, tMONTH, 8 },
  480. { &quot;september&quot;, tMONTH, 9 },
  481. { &quot;sept&quot;, tMONTH, 9 },
  482. { &quot;october&quot;, tMONTH, 10 },
  483. { &quot;november&quot;, tMONTH, 11 },
  484. { &quot;december&quot;, tMONTH, 12 },
  485. { &quot;sunday&quot;, tDAY, 0 },
  486. { &quot;monday&quot;, tDAY, 1 },
  487. { &quot;tuesday&quot;, tDAY, 2 },
  488. { &quot;tues&quot;, tDAY, 2 },
  489. { &quot;wednesday&quot;, tDAY, 3 },
  490. { &quot;wednes&quot;, tDAY, 3 },
  491. { &quot;thursday&quot;, tDAY, 4 },
  492. { &quot;thur&quot;, tDAY, 4 },
  493. { &quot;thurs&quot;, tDAY, 4 },
  494. { &quot;friday&quot;, tDAY, 5 },
  495. { &quot;saturday&quot;, tDAY, 6 },
  496. { NULL, 0, 0 }
  497. };
  498. /* Time units table. */
  499. static TABLE const UnitsTable[] = {
  500. { &quot;year&quot;, tYEAR_UNIT, 1 },
  501. { &quot;month&quot;, tMONTH_UNIT, 1 },
  502. { &quot;fortnight&quot;, tDAY_UNIT, 14 },
  503. { &quot;week&quot;, tDAY_UNIT, 7 },
  504. { &quot;day&quot;, tDAY_UNIT, 1 },
  505. { &quot;hour&quot;, tHOUR_UNIT, 1 },
  506. { &quot;minute&quot;, tMINUTE_UNIT, 1 },
  507. { &quot;min&quot;, tMINUTE_UNIT, 1 },
  508. { &quot;second&quot;, tSEC_UNIT, 1 },
  509. { &quot;sec&quot;, tSEC_UNIT, 1 },
  510. { NULL, 0, 0 }
  511. };
  512. /* Assorted relative-time words. */
  513. static TABLE const OtherTable[] = {
  514. { &quot;tomorrow&quot;, tMINUTE_UNIT, 1 * 24 * 60 },
  515. { &quot;yesterday&quot;, tMINUTE_UNIT, -1 * 24 * 60 },
  516. { &quot;today&quot;, tMINUTE_UNIT, 0 },
  517. { &quot;now&quot;, tMINUTE_UNIT, 0 },
  518. { &quot;last&quot;, tUNUMBER, -1 },
  519. { &quot;this&quot;, tMINUTE_UNIT, 0 },
  520. { &quot;next&quot;, tUNUMBER, 1 },
  521. { &quot;first&quot;, tUNUMBER, 1 },
  522. /* { &quot;second&quot;, tUNUMBER, 2 }, */
  523. { &quot;third&quot;, tUNUMBER, 3 },
  524. { &quot;fourth&quot;, tUNUMBER, 4 },
  525. { &quot;fifth&quot;, tUNUMBER, 5 },
  526. { &quot;sixth&quot;, tUNUMBER, 6 },
  527. { &quot;seventh&quot;, tUNUMBER, 7 },
  528. { &quot;eighth&quot;, tUNUMBER, 8 },
  529. { &quot;ninth&quot;, tUNUMBER, 9 },
  530. { &quot;tenth&quot;, tUNUMBER, 10 },
  531. { &quot;eleventh&quot;, tUNUMBER, 11 },
  532. { &quot;twelfth&quot;, tUNUMBER, 12 },
  533. { &quot;ago&quot;, tAGO, 1 },
  534. { NULL, 0, 0 }
  535. };
  536. /* The timezone table. */
  537. static TABLE const TimezoneTable[] = {
  538. { &quot;gmt&quot;, tZONE, HOUR ( 0) }, /* Greenwich Mean */
  539. { &quot;ut&quot;, tZONE, HOUR ( 0) }, /* Universal (Coordinated) */
  540. { &quot;utc&quot;, tZONE, HOUR ( 0) },
  541. { &quot;wet&quot;, tZONE, HOUR ( 0) }, /* Western European */
  542. { &quot;bst&quot;, tDAYZONE, HOUR ( 0) }, /* British Summer */
  543. { &quot;wat&quot;, tZONE, HOUR ( 1) }, /* West Africa */
  544. { &quot;at&quot;, tZONE, HOUR ( 2) }, /* Azores */
  545. #if 0
  546. /* For completeness. BST is also British Summer, and GST is
  547. * also Guam Standard. */
  548. { &quot;bst&quot;, tZONE, HOUR ( 3) }, /* Brazil Standard */
  549. { &quot;gst&quot;, tZONE, HOUR ( 3) }, /* Greenland Standard */
  550. #endif
  551. #if 0
  552. { &quot;nft&quot;, tZONE, HOUR (3.5) }, /* Newfoundland */
  553. { &quot;nst&quot;, tZONE, HOUR (3.5) }, /* Newfoundland Standard */
  554. { &quot;ndt&quot;, tDAYZONE, HOUR (3.5) }, /* Newfoundland Daylight */
  555. #endif
  556. { &quot;ast&quot;, tZONE, HOUR ( 4) }, /* Atlantic Standard */
  557. { &quot;adt&quot;, tDAYZONE, HOUR ( 4) }, /* Atlantic Daylight */
  558. { &quot;est&quot;, tZONE, HOUR ( 5) }, /* Eastern Standard */
  559. { &quot;edt&quot;, tDAYZONE, HOUR ( 5) }, /* Eastern Daylight */
  560. { &quot;cst&quot;, tZONE, HOUR ( 6) }, /* Central Standard */
  561. { &quot;cdt&quot;, tDAYZONE, HOUR ( 6) }, /* Central Daylight */
  562. { &quot;mst&quot;, tZONE, HOUR ( 7) }, /* Mountain Standard */
  563. { &quot;mdt&quot;, tDAYZONE, HOUR ( 7) }, /* Mountain Daylight */
  564. { &quot;pst&quot;, tZONE, HOUR ( 8) }, /* Pacific Standard */
  565. { &quot;pdt&quot;, tDAYZONE, HOUR ( 8) }, /* Pacific Daylight */
  566. { &quot;yst&quot;, tZONE, HOUR ( 9) }, /* Yukon Standard */
  567. { &quot;ydt&quot;, tDAYZONE, HOUR ( 9) }, /* Yukon Daylight */
  568. { &quot;hst&quot;, tZONE, HOUR (10) }, /* Hawaii Standard */
  569. { &quot;hdt&quot;, tDAYZONE, HOUR (10) }, /* Hawaii Daylight */
  570. { &quot;cat&quot;, tZONE, HOUR (10) }, /* Central Alaska */
  571. { &quot;ahst&quot;, tZONE, HOUR (10) }, /* Alaska-Hawaii Standard */
  572. { &quot;nt&quot;, tZONE, HOUR (11) }, /* Nome */
  573. { &quot;idlw&quot;, tZONE, HOUR (12) }, /* International Date Line West */
  574. { &quot;cet&quot;, tZONE, -HOUR (1) }, /* Central European */
  575. { &quot;met&quot;, tZONE, -HOUR (1) }, /* Middle European */
  576. { &quot;mewt&quot;, tZONE, -HOUR (1) }, /* Middle European Winter */
  577. { &quot;mest&quot;, tDAYZONE, -HOUR (1) }, /* Middle European Summer */
  578. { &quot;mesz&quot;, tDAYZONE, -HOUR (1) }, /* Middle European Summer */
  579. { &quot;swt&quot;, tZONE, -HOUR (1) }, /* Swedish Winter */
  580. { &quot;sst&quot;, tDAYZONE, -HOUR (1) }, /* Swedish Summer */
  581. { &quot;fwt&quot;, tZONE, -HOUR (1) }, /* French Winter */
  582. { &quot;fst&quot;, tDAYZONE, -HOUR (1) }, /* French Summer */
  583. { &quot;eet&quot;, tZONE, -HOUR (2) }, /* Eastern Europe, USSR Zone 1 */
  584. { &quot;bt&quot;, tZONE, -HOUR (3) }, /* Baghdad, USSR Zone 2 */
  585. #if 0
  586. { &quot;it&quot;, tZONE, -HOUR (3.5) },/* Iran */
  587. #endif
  588. { &quot;zp4&quot;, tZONE, -HOUR (4) }, /* USSR Zone 3 */
  589. { &quot;zp5&quot;, tZONE, -HOUR (5) }, /* USSR Zone 4 */
  590. #if 0
  591. { &quot;ist&quot;, tZONE, -HOUR (5.5) },/* Indian Standard */
  592. #endif
  593. { &quot;zp6&quot;, tZONE, -HOUR (6) }, /* USSR Zone 5 */
  594. #if 0
  595. /* For completeness. NST is also Newfoundland Standard, and SST is
  596. * also Swedish Summer. */
  597. { &quot;nst&quot;, tZONE, -HOUR (6.5) },/* North Sumatra */
  598. { &quot;sst&quot;, tZONE, -HOUR (7) }, /* South Sumatra, USSR Zone 6 */
  599. #endif /* 0 */
  600. { &quot;wast&quot;, tZONE, -HOUR (7) }, /* West Australian Standard */
  601. { &quot;wadt&quot;, tDAYZONE, -HOUR (7) }, /* West Australian Daylight */
  602. #if 0
  603. { &quot;jt&quot;, tZONE, -HOUR (7.5) },/* Java (3pm in Cronusland!) */
  604. #endif
  605. { &quot;cct&quot;, tZONE, -HOUR (8) }, /* China Coast, USSR Zone 7 */
  606. { &quot;jst&quot;, tZONE, -HOUR (9) }, /* Japan Standard, USSR Zone 8 */
  607. #if 0
  608. { &quot;cast&quot;, tZONE, -HOUR (9.5) },/* Central Australian Standard */
  609. { &quot;cadt&quot;, tDAYZONE, -HOUR (9.5) },/* Central Australian Daylight */
  610. #endif
  611. { &quot;east&quot;, tZONE, -HOUR (10) }, /* Eastern Australian Standard */
  612. { &quot;eadt&quot;, tDAYZONE, -HOUR (10) }, /* Eastern Australian Daylight */
  613. { &quot;gst&quot;, tZONE, -HOUR (10) }, /* Guam Standard, USSR Zone 9 */
  614. { &quot;nzt&quot;, tZONE, -HOUR (12) }, /* New Zealand */
  615. { &quot;nzst&quot;, tZONE, -HOUR (12) }, /* New Zealand Standard */
  616. { &quot;nzdt&quot;, tDAYZONE, -HOUR (12) }, /* New Zealand Daylight */
  617. { &quot;idle&quot;, tZONE, -HOUR (12) }, /* International Date Line East */
  618. { NULL, 0, 0 }
  619. };
  620. /* Military timezone table. */
  621. static TABLE const MilitaryTable[] = {
  622. { &quot;a&quot;, tZONE, HOUR ( 1) },
  623. { &quot;b&quot;, tZONE, HOUR ( 2) },
  624. { &quot;c&quot;, tZONE, HOUR ( 3) },
  625. { &quot;d&quot;, tZONE, HOUR ( 4) },
  626. { &quot;e&quot;, tZONE, HOUR ( 5) },
  627. { &quot;f&quot;, tZONE, HOUR ( 6) },
  628. { &quot;g&quot;, tZONE, HOUR ( 7) },
  629. { &quot;h&quot;, tZONE, HOUR ( 8) },
  630. { &quot;i&quot;, tZONE, HOUR ( 9) },
  631. { &quot;k&quot;, tZONE, HOUR ( 10) },
  632. { &quot;l&quot;, tZONE, HOUR ( 11) },
  633. { &quot;m&quot;, tZONE, HOUR ( 12) },
  634. { &quot;n&quot;, tZONE, HOUR (- 1) },
  635. { &quot;o&quot;, tZONE, HOUR (- 2) },
  636. { &quot;p&quot;, tZONE, HOUR (- 3) },
  637. { &quot;q&quot;, tZONE, HOUR (- 4) },
  638. { &quot;r&quot;, tZONE, HOUR (- 5) },
  639. { &quot;s&quot;, tZONE, HOUR (- 6) },
  640. { &quot;t&quot;, tZONE, HOUR (- 7) },
  641. { &quot;u&quot;, tZONE, HOUR (- 8) },
  642. { &quot;v&quot;, tZONE, HOUR (- 9) },
  643. { &quot;w&quot;, tZONE, HOUR (-10) },
  644. { &quot;x&quot;, tZONE, HOUR (-11) },
  645. { &quot;y&quot;, tZONE, HOUR (-12) },
  646. { &quot;z&quot;, tZONE, HOUR ( 0) },
  647. { NULL, 0, 0 }
  648. };
  649. /* ARGSUSED */
  650. static int
  651. yyerror (s)
  652. char *s ATTRIBUTE_UNUSED;
  653. {
  654. return 0;
  655. }
  656. static int
  657. ToHour (Hours, Meridian)
  658. int Hours;
  659. MERIDIAN Meridian;
  660. {
  661. switch (Meridian)
  662. {
  663. case MER24:
  664. if (Hours &lt; 0 || Hours &gt; 23)
  665. return -1;
  666. return Hours;
  667. case MERam:
  668. if (Hours &lt; 1 || Hours &gt; 12)
  669. return -1;
  670. if (Hours == 12)
  671. Hours = 0;
  672. return Hours;
  673. case MERpm:
  674. if (Hours &lt; 1 || Hours &gt; 12)
  675. return -1;
  676. if (Hours == 12)
  677. Hours = 0;
  678. return Hours + 12;
  679. default:
  680. abort ();
  681. }
  682. /* NOTREACHED */
  683. }
  684. static int
  685. ToYear (Year)
  686. int Year;
  687. {
  688. if (Year &lt; 0)
  689. Year = -Year;
  690. /* XPG4 suggests that years 00-68 map to 2000-2068, and
  691. years 69-99 map to 1969-1999. */
  692. if (Year &lt; 69)
  693. Year += 2000;
  694. else if (Year &lt; 100)
  695. Year += 1900;
  696. return Year;
  697. }
  698. static int
  699. LookupWord (yylval, buff)
  700. YYSTYPE *yylval;
  701. char *buff;
  702. {
  703. register char *p;
  704. register char *q;
  705. register const TABLE *tp;
  706. int i;
  707. int abbrev;
  708. /* Make it lowercase. */
  709. for (p = buff; *p; p++)
  710. if (ISUPPER ((unsigned char) *p))
  711. *p = tolower (*p);
  712. if (strcmp (buff, &quot;am&quot;) == 0 || strcmp (buff, &quot;a.m.&quot;) == 0)
  713. {
  714. yylval-&gt;Meridian = MERam;
  715. return tMERIDIAN;
  716. }
  717. if (strcmp (buff, &quot;pm&quot;) == 0 || strcmp (buff, &quot;p.m.&quot;) == 0)
  718. {
  719. yylval-&gt;Meridian = MERpm;
  720. return tMERIDIAN;
  721. }
  722. /* See if we have an abbreviation for a month. */
  723. if (strlen (buff) == 3)
  724. abbrev = 1;
  725. else if (strlen (buff) == 4 &amp;&amp; buff[3] == '.')
  726. {
  727. abbrev = 1;
  728. buff[3] = '\0';
  729. }
  730. else
  731. abbrev = 0;
  732. for (tp = MonthDayTable; tp-&gt;name; tp++)
  733. {
  734. if (abbrev)
  735. {
  736. if (strncmp (buff, tp-&gt;name, 3) == 0)
  737. {
  738. yylval-&gt;Number = tp-&gt;value;
  739. return tp-&gt;type;
  740. }
  741. }
  742. else if (strcmp (buff, tp-&gt;name) == 0)
  743. {
  744. yylval-&gt;Number = tp-&gt;value;
  745. return tp-&gt;type;
  746. }
  747. }
  748. for (tp = TimezoneTable; tp-&gt;name; tp++)
  749. if (strcmp (buff, tp-&gt;name) == 0)
  750. {
  751. yylval-&gt;Number = tp-&gt;value;
  752. return tp-&gt;type;
  753. }
  754. if (strcmp (buff, &quot;dst&quot;) == 0)
  755. return tDST;
  756. for (tp = UnitsTable; tp-&gt;name; tp++)
  757. if (strcmp (buff, tp-&gt;name) == 0)
  758. {
  759. yylval-&gt;Number = tp-&gt;value;
  760. return tp-&gt;type;
  761. }
  762. /* Strip off any plural and try the units table again. */
  763. i = strlen (buff) - 1;
  764. if (buff[i] == 's')
  765. {
  766. buff[i] = '\0';
  767. for (tp = UnitsTable; tp-&gt;name; tp++)
  768. if (strcmp (buff, tp-&gt;name) == 0)
  769. {
  770. yylval-&gt;Number = tp-&gt;value;
  771. return tp-&gt;type;
  772. }
  773. buff[i] = 's'; /* Put back for &quot;this&quot; in OtherTable. */
  774. }
  775. for (tp = OtherTable; tp-&gt;name; tp++)
  776. if (strcmp (buff, tp-&gt;name) == 0)
  777. {
  778. yylval-&gt;Number = tp-&gt;value;
  779. return tp-&gt;type;
  780. }
  781. /* Military timezones. */
  782. if (buff[1] == '\0' &amp;&amp; ISALPHA ((unsigned char) *buff))
  783. {
  784. for (tp = MilitaryTable; tp-&gt;name; tp++)
  785. if (strcmp (buff, tp-&gt;name) == 0)
  786. {
  787. yylval-&gt;Number = tp-&gt;value;
  788. return tp-&gt;type;
  789. }
  790. }
  791. /* Drop out any periods and try the timezone table again. */
  792. for (i = 0, p = q = buff; *q; q++)
  793. if (*q != '.')
  794. *p++ = *q;
  795. else
  796. i++;
  797. *p = '\0';
  798. if (i)
  799. for (tp = TimezoneTable; tp-&gt;name; tp++)
  800. if (strcmp (buff, tp-&gt;name) == 0)
  801. {
  802. yylval-&gt;Number = tp-&gt;value;
  803. return tp-&gt;type;
  804. }
  805. return tID;
  806. }
  807. static int
  808. yylex (yylval, cookie)
  809. YYSTYPE *yylval;
  810. void *cookie;
  811. {
  812. register unsigned char c;
  813. register char *p;
  814. char buff[20];
  815. int Count;
  816. int sign;
  817. for (;;)
  818. {
  819. while (ISSPACE ((unsigned char) *context-&gt;yyInput))
  820. context-&gt;yyInput++;
  821. if (ISDIGIT (c = *context-&gt;yyInput) || c == '-' || c == '+')
  822. {
  823. if (c == '-' || c == '+')
  824. {
  825. sign = c == '-' ? -1 : 1;
  826. if (!ISDIGIT (*++context-&gt;yyInput))
  827. /* skip the '-' sign */
  828. continue;
  829. }
  830. else
  831. sign = 0;
  832. for (yylval-&gt;Number = 0; ISDIGIT (c = *context-&gt;yyInput++);)
  833. yylval-&gt;Number = 10 * yylval-&gt;Number + c - '0';
  834. context-&gt;yyInput--;
  835. if (sign &lt; 0)
  836. yylval-&gt;Number = -yylval-&gt;Number;
  837. return sign ? tSNUMBER : tUNUMBER;
  838. }
  839. if (ISALPHA (c))
  840. {
  841. for (p = buff; (c = *context-&gt;yyInput++, ISALPHA (c)) || c == '.';)
  842. if (p &lt; &amp;buff[sizeof buff - 1])
  843. *p++ = c;
  844. *p = '\0';
  845. context-&gt;yyInput--;
  846. return LookupWord (yylval, buff);
  847. }
  848. if (c != '(')
  849. return *context-&gt;yyInput++;
  850. Count = 0;
  851. do
  852. {
  853. c = *context-&gt;yyInput++;
  854. if (c == '\0')
  855. return c;
  856. if (c == '(')
  857. Count++;
  858. else if (c == ')')
  859. Count--;
  860. }
  861. while (Count &gt; 0);
  862. }
  863. }
  864. #define TM_YEAR_ORIGIN 1900
  865. /* Yield A - B, measured in seconds. */
  866. static long
  867. difftm (struct tm *a, struct tm *b)
  868. {
  869. int ay = a-&gt;tm_year + (TM_YEAR_ORIGIN - 1);
  870. int by = b-&gt;tm_year + (TM_YEAR_ORIGIN - 1);
  871. long days = (
  872. /* difference in day of year */
  873. a-&gt;tm_yday - b-&gt;tm_yday
  874. /* + intervening leap days */
  875. + ((ay &gt;&gt; 2) - (by &gt;&gt; 2))
  876. - (ay / 100 - by / 100)
  877. + ((ay / 100 &gt;&gt; 2) - (by / 100 &gt;&gt; 2))
  878. /* + difference in years * 365 */
  879. + (long) (ay - by) * 365
  880. );
  881. return (60 * (60 * (24 * days + (a-&gt;tm_hour - b-&gt;tm_hour))
  882. + (a-&gt;tm_min - b-&gt;tm_min))
  883. + (a-&gt;tm_sec - b-&gt;tm_sec));
  884. }
  885. time_t
  886. curl_getdate (const char *p, const time_t *now)
  887. {
  888. struct tm tm, tm0, *tmp;
  889. time_t Start;
  890. CONTEXT cookie;
  891. #ifdef HAVE_LOCALTIME_R
  892. struct tm keeptime;
  893. #endif
  894. cookie.yyInput = p;
  895. Start = now ? *now : time ((time_t *) NULL);
  896. #ifdef HAVE_LOCALTIME_R
  897. tmp = (struct tm *)localtime_r(&amp;Start, &amp;keeptime);
  898. #else
  899. tmp = localtime (&amp;Start);
  900. #endif
  901. if (!tmp)
  902. return -1;
  903. cookie.yyYear = tmp-&gt;tm_year + TM_YEAR_ORIGIN;
  904. cookie.yyMonth = tmp-&gt;tm_mon + 1;
  905. cookie.yyDay = tmp-&gt;tm_mday;
  906. cookie.yyHour = tmp-&gt;tm_hour;
  907. cookie.yyMinutes = tmp-&gt;tm_min;
  908. cookie.yySeconds = tmp-&gt;tm_sec;
  909. tm.tm_isdst = tmp-&gt;tm_isdst;
  910. cookie.yyMeridian = MER24;
  911. cookie.yyRelSeconds = 0;
  912. cookie.yyRelMinutes = 0;
  913. cookie.yyRelHour = 0;
  914. cookie.yyRelDay = 0;
  915. cookie.yyRelMonth = 0;
  916. cookie.yyRelYear = 0;
  917. cookie.yyHaveDate = 0;
  918. cookie.yyHaveDay = 0;
  919. cookie.yyHaveRel = 0;
  920. cookie.yyHaveTime = 0;
  921. cookie.yyHaveZone = 0;
  922. if (yyparse (&amp;cookie)
  923. || cookie.yyHaveTime &gt; 1 || cookie.yyHaveZone &gt; 1 ||
  924. cookie.yyHaveDate &gt; 1 || cookie.yyHaveDay &gt; 1)
  925. return -1;
  926. tm.tm_year = ToYear (cookie.yyYear) - TM_YEAR_ORIGIN + cookie.yyRelYear;
  927. tm.tm_mon = cookie.yyMonth - 1 + cookie.yyRelMonth;
  928. tm.tm_mday = cookie.yyDay + cookie.yyRelDay;
  929. if (cookie.yyHaveTime ||
  930. (cookie.yyHaveRel &amp;&amp; !cookie.yyHaveDate &amp;&amp; !cookie.yyHaveDay))
  931. {
  932. tm.tm_hour = ToHour (cookie.yyHour, cookie.yyMeridian);
  933. if (tm.tm_hour &lt; 0)
  934. return -1;
  935. tm.tm_min = cookie.yyMinutes;
  936. tm.tm_sec = cookie.yySeconds;
  937. }
  938. else
  939. {
  940. tm.tm_hour = tm.tm_min = tm.tm_sec = 0;
  941. }
  942. tm.tm_hour += cookie.yyRelHour;
  943. tm.tm_min += cookie.yyRelMinutes;
  944. tm.tm_sec += cookie.yyRelSeconds;
  945. /* Let mktime deduce tm_isdst if we have an absolute timestamp,
  946. or if the relative timestamp mentions days, months, or years. */
  947. if (cookie.yyHaveDate | cookie.yyHaveDay | cookie.yyHaveTime |
  948. cookie.yyRelDay | cookie.yyRelMonth | cookie.yyRelYear)
  949. tm.tm_isdst = -1;
  950. tm0 = tm;
  951. Start = mktime (&amp;tm);
  952. if (Start == (time_t) -1)
  953. {
  954. /* Guard against falsely reporting errors near the time_t boundaries
  955. when parsing times in other time zones. For example, if the min
  956. time_t value is 1970-01-01 00:00:00 UTC and we are 8 hours ahead
  957. of UTC, then the min localtime value is 1970-01-01 08:00:00; if
  958. we apply mktime to 1970-01-01 00:00:00 we will get an error, so
  959. we apply mktime to 1970-01-02 08:00:00 instead and adjust the time
  960. zone by 24 hours to compensate. This algorithm assumes that
  961. there is no DST transition within a day of the time_t boundaries. */
  962. if (cookie.yyHaveZone)
  963. {
  964. tm = tm0;
  965. if (tm.tm_year &lt;= EPOCH - TM_YEAR_ORIGIN)
  966. {
  967. tm.tm_mday++;
  968. cookie.yyTimezone -= 24 * 60;
  969. }
  970. else
  971. {
  972. tm.tm_mday--;
  973. cookie.yyTimezone += 24 * 60;
  974. }
  975. Start = mktime (&amp;tm);
  976. }
  977. if (Start == (time_t) -1)
  978. return Start;
  979. }
  980. if (cookie.yyHaveDay &amp;&amp; !cookie.yyHaveDate)
  981. {
  982. tm.tm_mday += ((cookie.yyDayNumber - tm.tm_wday + 7) % 7
  983. + 7 * (cookie.yyDayOrdinal - (0 &lt; cookie.yyDayOrdinal)));
  984. Start = mktime (&amp;tm);
  985. if (Start == (time_t) -1)
  986. return Start;
  987. }
  988. if (cookie.yyHaveZone)
  989. {
  990. long delta;
  991. struct tm *gmt;
  992. #ifdef HAVE_GMTIME_R
  993. /* thread-safe version */
  994. struct tm keeptime;
  995. gmt = (struct tm *)gmtime_r(&amp;Start, &amp;keeptime);
  996. #else
  997. gmt = gmtime(&amp;Start);
  998. #endif
  999. if (!gmt)
  1000. return -1;
  1001. delta = cookie.yyTimezone * 60L + difftm (&amp;tm, gmt);
  1002. if ((Start + delta &lt; Start) != (delta &lt; 0))
  1003. return -1; /* time_t overflow */
  1004. Start += delta;
  1005. }
  1006. return Start;
  1007. }
  1008. #if defined (TEST)
  1009. /* ARGSUSED */
  1010. int
  1011. main (ac, av)
  1012. int ac;
  1013. char *av[];
  1014. {
  1015. char buff[MAX_BUFF_LEN + 1];
  1016. time_t d;
  1017. (void) printf (&quot;Enter date, or blank line to exit.\n\t&gt; &quot;);
  1018. (void) fflush (stdout);
  1019. buff[MAX_BUFF_LEN] = 0;
  1020. while (fgets (buff, MAX_BUFF_LEN, stdin) &amp;&amp; buff[0])
  1021. {
  1022. d = curl_getdate (buff, (time_t *) NULL);
  1023. if (d == -1)
  1024. (void) printf (&quot;Bad format - couldn't convert.\n&quot;);
  1025. else
  1026. (void) printf (&quot;%s&quot;, ctime (&amp;d));
  1027. (void) printf (&quot;\t&gt; &quot;);
  1028. (void) fflush (stdout);
  1029. }
  1030. exit (0);
  1031. /* NOTREACHED */
  1032. }
  1033. #endif /* defined (TEST) */
  1034. </pre>
  1035. <hr />
  1036. </body></html>