Check-in [c237cdd9ec]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:bugs 1090413, 1092789 fixed
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: c237cdd9eca448e03244267b222acb6131c1eacc
User & Date: kennykb 2004-12-29 20:57:25.000
Context
2004-12-29
22:07
bugs 1090413, 1092789 fixed check-in: b110473621 user: kennykb tags: trunk
20:57
bugs 1090413, 1092789 fixed check-in: c237cdd9ec user: kennykb tags: trunk
2004-12-24
18:06
Avoid sharing cmdName literals accross namespaces, and generalise usage of the TclRegisterNewLiteral... check-in: faec68a625 user: msofer tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to generic/tclDate.c.
1
2
3
4
5
6
7
8
9
10
11
/* A Bison parser, made by GNU Bison 1.875.  */

/* Skeleton parser for Yacc-like parsing with Bison,
   Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2, or (at your option)
   any later version.

   This program is distributed in the hope that it will be useful,
|


|







1
2
3
4
5
6
7
8
9
10
11
/* A Bison parser, made by GNU Bison 1.875b.  */

/* Skeleton parser for Yacc-like parsing with Bison,
   Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2, or (at your option)
   any later version.

   This program is distributed in the hope that it will be useful,
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#define tDAY_UNIT 274
#define tNEXT 275




/* Copy the first part of user declarations.  */
#line 17 "../unix/../generic/tclGetDate.y"

/* 
 * tclDate.c --
 *
 *	This file is generated from a yacc grammar defined in
 *	the file tclGetDate.y.  It should not be edited directly.
 *







|







101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#define tDAY_UNIT 274
#define tNEXT 275




/* Copy the first part of user declarations.  */


/* 
 * tclDate.c --
 *
 *	This file is generated from a yacc grammar defined in
 *	the file tclGetDate.y.  It should not be edited directly.
 *
165
166
167
168
169
170
171


172
173
174
175
176
177
178
    time_t   dateDayOrdinal;
    time_t   dateDayNumber;
    int      dateHaveDay;

    char     *dateInput;
    time_t   *dateRelPointer;



} DateInfo;

#define YYPARSE_PARAM info
#define YYLEX_PARAM info

#define yyDSTmode (((DateInfo*)info)->dateDSTmode)
#define yyDayOrdinal (((DateInfo*)info)->dateDayOrdinal)







>
>







165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
    time_t   dateDayOrdinal;
    time_t   dateDayNumber;
    int      dateHaveDay;

    char     *dateInput;
    time_t   *dateRelPointer;

    int	     dateDigitCount;

} DateInfo;

#define YYPARSE_PARAM info
#define YYLEX_PARAM info

#define yyDSTmode (((DateInfo*)info)->dateDSTmode)
#define yyDayOrdinal (((DateInfo*)info)->dateDayOrdinal)
193
194
195
196
197
198
199

200
201
202
203
204
205
206
#define yySeconds (((DateInfo*)info)->dateSeconds)
#define yyMeridian (((DateInfo*)info)->dateMeridian)
#define yyRelMonth (((DateInfo*)info)->dateRelMonth)
#define yyRelDay (((DateInfo*)info)->dateRelDay)
#define yyRelSeconds (((DateInfo*)info)->dateRelSeconds)
#define yyRelPointer (((DateInfo*)info)->dateRelPointer)
#define yyInput (((DateInfo*)info)->dateInput)


#define EPOCH           1970
#define START_OF_TIME   1902
#define END_OF_TIME     2037

/*
 * The offset of tm_year of struct tm returned by localtime, gmtime, etc.







>







195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
#define yySeconds (((DateInfo*)info)->dateSeconds)
#define yyMeridian (((DateInfo*)info)->dateMeridian)
#define yyRelMonth (((DateInfo*)info)->dateRelMonth)
#define yyRelDay (((DateInfo*)info)->dateRelDay)
#define yyRelSeconds (((DateInfo*)info)->dateRelSeconds)
#define yyRelPointer (((DateInfo*)info)->dateRelPointer)
#define yyInput (((DateInfo*)info)->dateInput)
#define yyDigitCount (((DateInfo*)info)->dateDigitCount)

#define EPOCH           1970
#define START_OF_TIME   1902
#define END_OF_TIME     2037

/*
 * The offset of tm_year of struct tm returned by localtime, gmtime, etc.
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
# undef YYERROR_VERBOSE
# define YYERROR_VERBOSE 1
#else
# define YYERROR_VERBOSE 0
#endif

#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
#line 160 "../unix/../generic/tclGetDate.y"
typedef union YYSTYPE {
    time_t              Number;
    enum _MERIDIAN      Meridian;
} YYSTYPE;
/* Line 191 of yacc.c.  */
#line 272 "../unix/../generic/tclDate.c"
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
#endif



/* Copy the second part of user declarations.  */


/* Line 214 of yacc.c.  */
#line 284 "../unix/../generic/tclDate.c"

#if ! defined (yyoverflow) || YYERROR_VERBOSE

/* The parser invokes alloca or malloc; define the necessary symbols.  */

# if YYSTACK_USE_ALLOCA
#  define YYSTACK_ALLOC alloca







|





|











|







262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
# undef YYERROR_VERBOSE
# define YYERROR_VERBOSE 1
#else
# define YYERROR_VERBOSE 0
#endif

#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)

typedef union YYSTYPE {
    time_t              Number;
    enum _MERIDIAN      Meridian;
} YYSTYPE;
/* Line 191 of yacc.c.  */

# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
#endif



/* Copy the second part of user declarations.  */


/* Line 214 of yacc.c.  */


#if ! defined (yyoverflow) || YYERROR_VERBOSE

/* The parser invokes alloca or malloc; define the necessary symbols.  */

# if YYSTACK_USE_ALLOCA
#  define YYSTACK_ALLOC alloca
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
      14,    40,    -1,    40,    -1,    22,    -1,    26,    -1,    12,
      -1,    19,    -1,    10,    -1,    14,    -1,    -1,     7,    -1
};

/* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
static const unsigned short yyrline[] =
{
       0,   176,   176,   177,   180,   183,   186,   189,   192,   195,
     198,   202,   207,   210,   216,   222,   230,   236,   247,   251,
     255,   261,   265,   269,   273,   277,   283,   287,   292,   297,
     302,   307,   311,   316,   320,   325,   332,   336,   342,   351,
     360,   370,   383,   388,   390,   391,   392,   393,   394,   396,
     397,   399,   400,   401,   404,   423,   426
};
#endif

#if YYDEBUG || YYERROR_VERBOSE
/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
   First, the terminals, then, starting at YYNTOKENS, nonterminals. */
static const char *const yytname[] =







|
|
|
|
|
|







469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
      14,    40,    -1,    40,    -1,    22,    -1,    26,    -1,    12,
      -1,    19,    -1,    10,    -1,    14,    -1,    -1,     7,    -1
};

/* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
static const unsigned short yyrline[] =
{
       0,   179,   179,   180,   183,   186,   189,   192,   195,   198,
     201,   205,   210,   213,   219,   225,   233,   239,   250,   254,
     258,   264,   268,   272,   276,   280,   286,   290,   295,   300,
     305,   310,   314,   319,   323,   328,   335,   339,   345,   354,
     363,   373,   386,   391,   393,   394,   395,   396,   397,   399,
     400,   402,   403,   404,   407,   426,   429
};
#endif

#if YYDEBUG || YYERROR_VERBOSE
/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
   First, the terminals, then, starting at YYNTOKENS, nonterminals. */
static const char *const yytname[] =
637
638
639
640
641
642
643

644
645
646
647
648
649
650
#define yyclearin	(yychar = YYEMPTY)
#define YYEMPTY		(-2)
#define YYEOF		0

#define YYACCEPT	goto yyacceptlab
#define YYABORT		goto yyabortlab
#define YYERROR		goto yyerrlab1


/* Like YYERROR except do call yyerror.  This remains here temporarily
   to ease the transition to the new meaning of YYERROR, for GCC.
   Once GCC version 2 has supplanted version 1, this can go.  */

#define YYFAIL		goto yyerrlab








>







640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
#define yyclearin	(yychar = YYEMPTY)
#define YYEMPTY		(-2)
#define YYEOF		0

#define YYACCEPT	goto yyacceptlab
#define YYABORT		goto yyabortlab
#define YYERROR		goto yyerrlab1


/* Like YYERROR except do call yyerror.  This remains here temporarily
   to ease the transition to the new meaning of YYERROR, for GCC.
   Once GCC version 2 has supplanted version 1, this can go.  */

#define YYFAIL		goto yyerrlab

758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
#else
static void
yy_reduce_print (yyrule)
    int yyrule;
#endif
{
  int yyi;
  unsigned int yylineno = yyrline[yyrule];
  YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
             yyrule - 1, yylineno);
  /* Print the symbols being reduced, and their result.  */
  for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
    YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]);
  YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]);
}

# define YY_REDUCE_PRINT(Rule)		\







|

|







762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
#else
static void
yy_reduce_print (yyrule)
    int yyrule;
#endif
{
  int yyi;
  unsigned int yylno = yyrline[yyrule];
  YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
             yyrule - 1, yylno);
  /* Print the symbols being reduced, and their result.  */
  for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
    YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]);
  YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]);
}

# define YY_REDUCE_PRINT(Rule)		\
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
  yyval = yyvsp[1-yylen];


  YY_REDUCE_PRINT (yyn);
  switch (yyn)
    {
        case 4:
#line 180 "../unix/../generic/tclGetDate.y"
    {
            yyHaveTime++;
        ;}
    break;

  case 5:
#line 183 "../unix/../generic/tclGetDate.y"
    {
            yyHaveZone++;
        ;}
    break;

  case 6:
#line 186 "../unix/../generic/tclGetDate.y"
    {
            yyHaveDate++;
        ;}
    break;

  case 7:
#line 189 "../unix/../generic/tclGetDate.y"
    {
            yyHaveOrdinalMonth++;
        ;}
    break;

  case 8:
#line 192 "../unix/../generic/tclGetDate.y"
    {
            yyHaveDay++;
        ;}
    break;

  case 9:
#line 195 "../unix/../generic/tclGetDate.y"
    {
            yyHaveRel++;
        ;}
    break;

  case 10:
#line 198 "../unix/../generic/tclGetDate.y"
    {
	    yyHaveTime++;
	    yyHaveDate++;
	;}
    break;

  case 11:
#line 202 "../unix/../generic/tclGetDate.y"
    {
	    yyHaveTime++;
	    yyHaveDate++;
	    yyHaveRel++;
        ;}
    break;

  case 13:
#line 210 "../unix/../generic/tclGetDate.y"
    {
            yyHour = yyvsp[-1].Number;
            yyMinutes = 0;
            yySeconds = 0;
            yyMeridian = yyvsp[0].Meridian;
        ;}
    break;

  case 14:
#line 216 "../unix/../generic/tclGetDate.y"
    {
            yyHour = yyvsp[-3].Number;
            yyMinutes = yyvsp[-1].Number;
            yySeconds = 0;
            yyMeridian = yyvsp[0].Meridian;
        ;}
    break;

  case 15:
#line 222 "../unix/../generic/tclGetDate.y"
    {
            yyHour = yyvsp[-4].Number;
            yyMinutes = yyvsp[-2].Number;
            yyMeridian = MER24;
            yyDSTmode = DSToff;
            yyTimezone = (yyvsp[0].Number % 100 + (yyvsp[0].Number / 100) * 60);
	    ++yyHaveZone;
        ;}
    break;

  case 16:
#line 230 "../unix/../generic/tclGetDate.y"
    {
            yyHour = yyvsp[-5].Number;
            yyMinutes = yyvsp[-3].Number;
            yySeconds = yyvsp[-1].Number;
            yyMeridian = yyvsp[0].Meridian;
        ;}
    break;

  case 17:
#line 236 "../unix/../generic/tclGetDate.y"
    {
            yyHour = yyvsp[-6].Number;
            yyMinutes = yyvsp[-4].Number;
            yySeconds = yyvsp[-2].Number;
            yyMeridian = MER24;
            yyDSTmode = DSToff;
            yyTimezone = (yyvsp[0].Number % 100 + (yyvsp[0].Number / 100) * 60);
	    ++yyHaveZone;
        ;}
    break;

  case 18:
#line 247 "../unix/../generic/tclGetDate.y"
    {
            yyTimezone = yyvsp[-1].Number;
            yyDSTmode = DSTon;
        ;}
    break;

  case 19:
#line 251 "../unix/../generic/tclGetDate.y"
    {
            yyTimezone = yyvsp[0].Number;
            yyDSTmode = DSToff;
        ;}
    break;

  case 20:
#line 255 "../unix/../generic/tclGetDate.y"
    {
            yyTimezone = yyvsp[0].Number;
            yyDSTmode = DSTon;
        ;}
    break;

  case 21:
#line 261 "../unix/../generic/tclGetDate.y"
    {
            yyDayOrdinal = 1;
            yyDayNumber = yyvsp[0].Number;
        ;}
    break;

  case 22:
#line 265 "../unix/../generic/tclGetDate.y"
    {
            yyDayOrdinal = 1;
            yyDayNumber = yyvsp[-1].Number;
        ;}
    break;

  case 23:
#line 269 "../unix/../generic/tclGetDate.y"
    {
            yyDayOrdinal = yyvsp[-1].Number;
            yyDayNumber = yyvsp[0].Number;
        ;}
    break;

  case 24:
#line 273 "../unix/../generic/tclGetDate.y"
    {
            yyDayOrdinal = yyvsp[-2].Number * yyvsp[-1].Number;
            yyDayNumber = yyvsp[0].Number;
        ;}
    break;

  case 25:
#line 277 "../unix/../generic/tclGetDate.y"
    {
            yyDayOrdinal = 2;
            yyDayNumber = yyvsp[0].Number;
        ;}
    break;

  case 26:
#line 283 "../unix/../generic/tclGetDate.y"
    {
            yyMonth = yyvsp[-2].Number;
            yyDay = yyvsp[0].Number;
        ;}
    break;

  case 27:
#line 287 "../unix/../generic/tclGetDate.y"
    {
            yyMonth = yyvsp[-4].Number;
            yyDay = yyvsp[-2].Number;
            yyYear = yyvsp[0].Number;
        ;}
    break;

  case 28:
#line 292 "../unix/../generic/tclGetDate.y"
    {
	    yyYear = yyvsp[0].Number / 10000;
	    yyMonth = (yyvsp[0].Number % 10000)/100;
	    yyDay = yyvsp[0].Number % 100;
	;}
    break;

  case 29:
#line 297 "../unix/../generic/tclGetDate.y"
    {
	    yyDay = yyvsp[-4].Number;
	    yyMonth = yyvsp[-2].Number;
	    yyYear = yyvsp[0].Number;
	;}
    break;

  case 30:
#line 302 "../unix/../generic/tclGetDate.y"
    {
            yyMonth = yyvsp[-2].Number;
            yyDay = yyvsp[0].Number;
            yyYear = yyvsp[-4].Number;
        ;}
    break;

  case 31:
#line 307 "../unix/../generic/tclGetDate.y"
    {
            yyMonth = yyvsp[-1].Number;
            yyDay = yyvsp[0].Number;
        ;}
    break;

  case 32:
#line 311 "../unix/../generic/tclGetDate.y"
    {
            yyMonth = yyvsp[-3].Number;
            yyDay = yyvsp[-2].Number;
            yyYear = yyvsp[0].Number;
        ;}
    break;

  case 33:
#line 316 "../unix/../generic/tclGetDate.y"
    {
            yyMonth = yyvsp[0].Number;
            yyDay = yyvsp[-1].Number;
        ;}
    break;

  case 34:
#line 320 "../unix/../generic/tclGetDate.y"
    {
	    yyMonth = 1;
	    yyDay = 1;
	    yyYear = EPOCH;
	;}
    break;

  case 35:
#line 325 "../unix/../generic/tclGetDate.y"
    {
            yyMonth = yyvsp[-1].Number;
            yyDay = yyvsp[-2].Number;
            yyYear = yyvsp[0].Number;
        ;}
    break;

  case 36:
#line 332 "../unix/../generic/tclGetDate.y"
    {
	    yyMonthOrdinal = 1;
	    yyMonth = yyvsp[0].Number;
	;}
    break;

  case 37:
#line 336 "../unix/../generic/tclGetDate.y"
    {
	    yyMonthOrdinal = yyvsp[-1].Number;
	    yyMonth = yyvsp[0].Number;
	;}
    break;

  case 38:
#line 342 "../unix/../generic/tclGetDate.y"
    {
            if (yyvsp[-1].Number != HOUR(- 7)) YYABORT;
	    yyYear = yyvsp[-2].Number / 10000;
	    yyMonth = (yyvsp[-2].Number % 10000)/100;
	    yyDay = yyvsp[-2].Number % 100;
	    yyHour = yyvsp[0].Number / 10000;
	    yyMinutes = (yyvsp[0].Number % 10000)/100;
	    yySeconds = yyvsp[0].Number % 100;
        ;}
    break;

  case 39:
#line 351 "../unix/../generic/tclGetDate.y"
    {
            if (yyvsp[-5].Number != HOUR(- 7)) YYABORT;
	    yyYear = yyvsp[-6].Number / 10000;
	    yyMonth = (yyvsp[-6].Number % 10000)/100;
	    yyDay = yyvsp[-6].Number % 100;
	    yyHour = yyvsp[-4].Number;
	    yyMinutes = yyvsp[-2].Number;
	    yySeconds = yyvsp[0].Number;
        ;}
    break;

  case 40:
#line 360 "../unix/../generic/tclGetDate.y"
    {
	    yyYear = yyvsp[-1].Number / 10000;
	    yyMonth = (yyvsp[-1].Number % 10000)/100;
	    yyDay = yyvsp[-1].Number % 100;
	    yyHour = yyvsp[0].Number / 10000;
	    yyMinutes = (yyvsp[0].Number % 10000)/100;
	    yySeconds = yyvsp[0].Number % 100;
        ;}
    break;

  case 41:
#line 370 "../unix/../generic/tclGetDate.y"
    {
            /*
	     * Offset computed year by -377 so that the returned years will
	     * be in a range accessible with a 32 bit clock seconds value
	     */
            yyYear = yyvsp[-2].Number/1000 + 2323 - 377;
            yyDay  = 1;
	    yyMonth = 1;
	    yyRelDay += ((yyvsp[-2].Number%1000)*(365 + IsLeapYear(yyYear)))/1000;
	    yyRelSeconds += yyvsp[0].Number * 144 * 60;
        ;}
    break;

  case 42:
#line 383 "../unix/../generic/tclGetDate.y"
    {
	    yyRelSeconds *= -1;
	    yyRelMonth *= -1;
	    yyRelDay *= -1;
	;}
    break;

  case 44:
#line 390 "../unix/../generic/tclGetDate.y"
    { *yyRelPointer += yyvsp[-2].Number * yyvsp[-1].Number * yyvsp[0].Number; ;}
    break;

  case 45:
#line 391 "../unix/../generic/tclGetDate.y"
    { *yyRelPointer += yyvsp[-1].Number * yyvsp[0].Number; ;}
    break;

  case 46:
#line 392 "../unix/../generic/tclGetDate.y"
    { *yyRelPointer += yyvsp[0].Number; ;}
    break;

  case 47:
#line 393 "../unix/../generic/tclGetDate.y"
    { *yyRelPointer += yyvsp[-1].Number * yyvsp[0].Number; ;}
    break;

  case 48:
#line 394 "../unix/../generic/tclGetDate.y"
    { *yyRelPointer += yyvsp[0].Number; ;}
    break;

  case 49:
#line 396 "../unix/../generic/tclGetDate.y"
    { yyval.Number = -1; ;}
    break;

  case 50:
#line 397 "../unix/../generic/tclGetDate.y"
    { yyval.Number =  1; ;}
    break;

  case 51:
#line 399 "../unix/../generic/tclGetDate.y"
    { yyval.Number = yyvsp[0].Number; yyRelPointer = &yyRelSeconds; ;}
    break;

  case 52:
#line 400 "../unix/../generic/tclGetDate.y"
    { yyval.Number = yyvsp[0].Number; yyRelPointer = &yyRelDay; ;}
    break;

  case 53:
#line 401 "../unix/../generic/tclGetDate.y"
    { yyval.Number = yyvsp[0].Number; yyRelPointer = &yyRelMonth; ;}
    break;

  case 54:
#line 405 "../unix/../generic/tclGetDate.y"
    {
	if (yyHaveTime && yyHaveDate && !yyHaveRel) {
	    yyYear = yyvsp[0].Number;
	} else {
	    yyHaveTime++;
	    if (yyvsp[0].Number < 100) {
		yyHour = yyvsp[0].Number;
		yyMinutes = 0;
	    } else {
		yyHour = yyvsp[0].Number / 100;
		yyMinutes = yyvsp[0].Number % 100;
	    }
	    yySeconds = 0;
	    yyMeridian = MER24;
	}
    ;}
    break;

  case 55:
#line 423 "../unix/../generic/tclGetDate.y"
    {
            yyval.Meridian = MER24;
        ;}
    break;

  case 56:
#line 426 "../unix/../generic/tclGetDate.y"
    {
            yyval.Meridian = yyvsp[0].Meridian;
        ;}
    break;


    }

/* Line 991 of yacc.c.  */
#line 1657 "../unix/../generic/tclDate.c"

  yyvsp -= yylen;
  yyssp -= yylen;


  YY_STACK_PRINT (yyss, yyssp);








|






|






|






|






|






|






|







|








|









|









|











|









|












|







|







|







|







|







|







|







|







|







|








|








|








|








|







|








|







|








|








|







|







|












|












|











|














|








|




|




|




|




|




|




|




|




|




|




|





|













|






|








|
|







1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
  yyval = yyvsp[1-yylen];


  YY_REDUCE_PRINT (yyn);
  switch (yyn)
    {
        case 4:

    {
            yyHaveTime++;
        ;}
    break;

  case 5:

    {
            yyHaveZone++;
        ;}
    break;

  case 6:

    {
            yyHaveDate++;
        ;}
    break;

  case 7:

    {
            yyHaveOrdinalMonth++;
        ;}
    break;

  case 8:

    {
            yyHaveDay++;
        ;}
    break;

  case 9:

    {
            yyHaveRel++;
        ;}
    break;

  case 10:

    {
	    yyHaveTime++;
	    yyHaveDate++;
	;}
    break;

  case 11:

    {
	    yyHaveTime++;
	    yyHaveDate++;
	    yyHaveRel++;
        ;}
    break;

  case 13:

    {
            yyHour = yyvsp[-1].Number;
            yyMinutes = 0;
            yySeconds = 0;
            yyMeridian = yyvsp[0].Meridian;
        ;}
    break;

  case 14:

    {
            yyHour = yyvsp[-3].Number;
            yyMinutes = yyvsp[-1].Number;
            yySeconds = 0;
            yyMeridian = yyvsp[0].Meridian;
        ;}
    break;

  case 15:

    {
            yyHour = yyvsp[-4].Number;
            yyMinutes = yyvsp[-2].Number;
            yyMeridian = MER24;
            yyDSTmode = DSToff;
            yyTimezone = (yyvsp[0].Number % 100 + (yyvsp[0].Number / 100) * 60);
	    ++yyHaveZone;
        ;}
    break;

  case 16:

    {
            yyHour = yyvsp[-5].Number;
            yyMinutes = yyvsp[-3].Number;
            yySeconds = yyvsp[-1].Number;
            yyMeridian = yyvsp[0].Meridian;
        ;}
    break;

  case 17:

    {
            yyHour = yyvsp[-6].Number;
            yyMinutes = yyvsp[-4].Number;
            yySeconds = yyvsp[-2].Number;
            yyMeridian = MER24;
            yyDSTmode = DSToff;
            yyTimezone = (yyvsp[0].Number % 100 + (yyvsp[0].Number / 100) * 60);
	    ++yyHaveZone;
        ;}
    break;

  case 18:

    {
            yyTimezone = yyvsp[-1].Number;
            yyDSTmode = DSTon;
        ;}
    break;

  case 19:

    {
            yyTimezone = yyvsp[0].Number;
            yyDSTmode = DSToff;
        ;}
    break;

  case 20:

    {
            yyTimezone = yyvsp[0].Number;
            yyDSTmode = DSTon;
        ;}
    break;

  case 21:

    {
            yyDayOrdinal = 1;
            yyDayNumber = yyvsp[0].Number;
        ;}
    break;

  case 22:

    {
            yyDayOrdinal = 1;
            yyDayNumber = yyvsp[-1].Number;
        ;}
    break;

  case 23:

    {
            yyDayOrdinal = yyvsp[-1].Number;
            yyDayNumber = yyvsp[0].Number;
        ;}
    break;

  case 24:

    {
            yyDayOrdinal = yyvsp[-2].Number * yyvsp[-1].Number;
            yyDayNumber = yyvsp[0].Number;
        ;}
    break;

  case 25:

    {
            yyDayOrdinal = 2;
            yyDayNumber = yyvsp[0].Number;
        ;}
    break;

  case 26:

    {
            yyMonth = yyvsp[-2].Number;
            yyDay = yyvsp[0].Number;
        ;}
    break;

  case 27:

    {
            yyMonth = yyvsp[-4].Number;
            yyDay = yyvsp[-2].Number;
            yyYear = yyvsp[0].Number;
        ;}
    break;

  case 28:

    {
	    yyYear = yyvsp[0].Number / 10000;
	    yyMonth = (yyvsp[0].Number % 10000)/100;
	    yyDay = yyvsp[0].Number % 100;
	;}
    break;

  case 29:

    {
	    yyDay = yyvsp[-4].Number;
	    yyMonth = yyvsp[-2].Number;
	    yyYear = yyvsp[0].Number;
	;}
    break;

  case 30:

    {
            yyMonth = yyvsp[-2].Number;
            yyDay = yyvsp[0].Number;
            yyYear = yyvsp[-4].Number;
        ;}
    break;

  case 31:

    {
            yyMonth = yyvsp[-1].Number;
            yyDay = yyvsp[0].Number;
        ;}
    break;

  case 32:

    {
            yyMonth = yyvsp[-3].Number;
            yyDay = yyvsp[-2].Number;
            yyYear = yyvsp[0].Number;
        ;}
    break;

  case 33:

    {
            yyMonth = yyvsp[0].Number;
            yyDay = yyvsp[-1].Number;
        ;}
    break;

  case 34:

    {
	    yyMonth = 1;
	    yyDay = 1;
	    yyYear = EPOCH;
	;}
    break;

  case 35:

    {
            yyMonth = yyvsp[-1].Number;
            yyDay = yyvsp[-2].Number;
            yyYear = yyvsp[0].Number;
        ;}
    break;

  case 36:

    {
	    yyMonthOrdinal = 1;
	    yyMonth = yyvsp[0].Number;
	;}
    break;

  case 37:

    {
	    yyMonthOrdinal = yyvsp[-1].Number;
	    yyMonth = yyvsp[0].Number;
	;}
    break;

  case 38:

    {
            if (yyvsp[-1].Number != HOUR(- 7)) YYABORT;
	    yyYear = yyvsp[-2].Number / 10000;
	    yyMonth = (yyvsp[-2].Number % 10000)/100;
	    yyDay = yyvsp[-2].Number % 100;
	    yyHour = yyvsp[0].Number / 10000;
	    yyMinutes = (yyvsp[0].Number % 10000)/100;
	    yySeconds = yyvsp[0].Number % 100;
        ;}
    break;

  case 39:

    {
            if (yyvsp[-5].Number != HOUR(- 7)) YYABORT;
	    yyYear = yyvsp[-6].Number / 10000;
	    yyMonth = (yyvsp[-6].Number % 10000)/100;
	    yyDay = yyvsp[-6].Number % 100;
	    yyHour = yyvsp[-4].Number;
	    yyMinutes = yyvsp[-2].Number;
	    yySeconds = yyvsp[0].Number;
        ;}
    break;

  case 40:

    {
	    yyYear = yyvsp[-1].Number / 10000;
	    yyMonth = (yyvsp[-1].Number % 10000)/100;
	    yyDay = yyvsp[-1].Number % 100;
	    yyHour = yyvsp[0].Number / 10000;
	    yyMinutes = (yyvsp[0].Number % 10000)/100;
	    yySeconds = yyvsp[0].Number % 100;
        ;}
    break;

  case 41:

    {
            /*
	     * Offset computed year by -377 so that the returned years will
	     * be in a range accessible with a 32 bit clock seconds value
	     */
            yyYear = yyvsp[-2].Number/1000 + 2323 - 377;
            yyDay  = 1;
	    yyMonth = 1;
	    yyRelDay += ((yyvsp[-2].Number%1000)*(365 + IsLeapYear(yyYear)))/1000;
	    yyRelSeconds += yyvsp[0].Number * 144 * 60;
        ;}
    break;

  case 42:

    {
	    yyRelSeconds *= -1;
	    yyRelMonth *= -1;
	    yyRelDay *= -1;
	;}
    break;

  case 44:

    { *yyRelPointer += yyvsp[-2].Number * yyvsp[-1].Number * yyvsp[0].Number; ;}
    break;

  case 45:

    { *yyRelPointer += yyvsp[-1].Number * yyvsp[0].Number; ;}
    break;

  case 46:

    { *yyRelPointer += yyvsp[0].Number; ;}
    break;

  case 47:

    { *yyRelPointer += yyvsp[-1].Number * yyvsp[0].Number; ;}
    break;

  case 48:

    { *yyRelPointer += yyvsp[0].Number; ;}
    break;

  case 49:

    { yyval.Number = -1; ;}
    break;

  case 50:

    { yyval.Number =  1; ;}
    break;

  case 51:

    { yyval.Number = yyvsp[0].Number; yyRelPointer = &yyRelSeconds; ;}
    break;

  case 52:

    { yyval.Number = yyvsp[0].Number; yyRelPointer = &yyRelDay; ;}
    break;

  case 53:

    { yyval.Number = yyvsp[0].Number; yyRelPointer = &yyRelMonth; ;}
    break;

  case 54:

    {
	if (yyHaveTime && yyHaveDate && !yyHaveRel) {
	    yyYear = yyvsp[0].Number;
	} else {
	    yyHaveTime++;
	    if (yyDigitCount <= 2) {
		yyHour = yyvsp[0].Number;
		yyMinutes = 0;
	    } else {
		yyHour = yyvsp[0].Number / 100;
		yyMinutes = yyvsp[0].Number % 100;
	    }
	    yySeconds = 0;
	    yyMeridian = MER24;
	}
    ;}
    break;

  case 55:

    {
            yyval.Meridian = MER24;
        ;}
    break;

  case 56:

    {
            yyval.Meridian = yyvsp[0].Meridian;
        ;}
    break;


    }

/* Line 999 of yacc.c.  */


  yyvsp -= yylen;
  yyssp -= yylen;


  YY_STACK_PRINT (yyss, yyssp);

1691
1692
1693
1694
1695
1696
1697

1698
1699
1700
1701
1702
1703
1704
1705







1706

1707







1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
#if YYERROR_VERBOSE
      yyn = yypact[yystate];

      if (YYPACT_NINF < yyn && yyn < YYLAST)
	{
	  YYSIZE_T yysize = 0;
	  int yytype = YYTRANSLATE (yychar);

	  char *yymsg;
	  int yyx, yycount;

	  yycount = 0;
	  /* Start YYX at -YYN if negative to avoid negative indexes in
	     YYCHECK.  */
	  for (yyx = yyn < 0 ? -yyn : 0;
	       yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)







	    if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)

	      yysize += yystrlen (yytname[yyx]) + 15, yycount++;







	  yysize += yystrlen ("syntax error, unexpected ") + 1;
	  yysize += yystrlen (yytname[yytype]);
	  yymsg = (char *) YYSTACK_ALLOC (yysize);
	  if (yymsg != 0)
	    {
	      char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
	      yyp = yystpcpy (yyp, yytname[yytype]);

	      if (yycount < 5)
		{
		  yycount = 0;
		  for (yyx = yyn < 0 ? -yyn : 0;
		       yyx < (int) (sizeof (yytname) / sizeof (char *));
		       yyx++)
		    if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
		      {
			const char *yyq = ! yycount ? ", expecting " : " or ";
			yyp = yystpcpy (yyp, yyq);
			yyp = yystpcpy (yyp, yytname[yyx]);
			yycount++;
		      }
		}
	      yyerror (yymsg);
	      YYSTACK_FREE (yymsg);
	    }
	  else
	    yyerror ("syntax error; also virtual memory exhausted");







>

|

<


|
|
>
>
>
>
>
>
>

>
|
>
>
>
>
>
>
>
|
|








|
|
<
<


<
|

|







1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705

1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738


1739
1740

1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
#if YYERROR_VERBOSE
      yyn = yypact[yystate];

      if (YYPACT_NINF < yyn && yyn < YYLAST)
	{
	  YYSIZE_T yysize = 0;
	  int yytype = YYTRANSLATE (yychar);
	  const char* yyprefix;
	  char *yymsg;
	  int yyx;


	  /* Start YYX at -YYN if negative to avoid negative indexes in
	     YYCHECK.  */
	  int yyxbegin = yyn < 0 ? -yyn : 0;

	  /* Stay within bounds of both yycheck and yytname.  */
	  int yychecklim = YYLAST - yyn;
	  int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
	  int yycount = 0;

	  yyprefix = ", expecting ";
	  for (yyx = yyxbegin; yyx < yyxend; ++yyx)
	    if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
	      {
		yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]);
		yycount += 1;
		if (yycount == 5)
		  {
		    yysize = 0;
		    break;
		  }
	      }
	  yysize += (sizeof ("syntax error, unexpected ")
		     + yystrlen (yytname[yytype]));
	  yymsg = (char *) YYSTACK_ALLOC (yysize);
	  if (yymsg != 0)
	    {
	      char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
	      yyp = yystpcpy (yyp, yytname[yytype]);

	      if (yycount < 5)
		{
		  yyprefix = ", expecting ";
		  for (yyx = yyxbegin; yyx < yyxend; ++yyx)


		    if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
		      {

			yyp = yystpcpy (yyp, yyprefix);
			yyp = yystpcpy (yyp, yytname[yyx]);
			yyprefix = " or ";
		      }
		}
	      yyerror (yymsg);
	      YYSTACK_FREE (yymsg);
	    }
	  else
	    yyerror ("syntax error; also virtual memory exhausted");
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
      yydestruct (yytoken, &yylval);
      yychar = YYEMPTY;

    }

  /* Else will try to reuse lookahead token after shifting the error
     token.  */
  goto yyerrlab2;


/*----------------------------------------------------.
| yyerrlab1 -- error raised explicitly by an action.  |
`----------------------------------------------------*/
yyerrlab1:

  /* Suppress GCC warning that yyerrlab1 is unused when no action
     invokes YYERROR.  Doesn't work in C++ */
#ifndef __cplusplus
#if defined (__GNUC_MINOR__) && 2093 <= (__GNUC__ * 1000 + __GNUC_MINOR__)
  __attribute__ ((__unused__))
#endif
#endif


  goto yyerrlab2;


/*---------------------------------------------------------------.
| yyerrlab2 -- pop states until the error token can be shifted.  |
`---------------------------------------------------------------*/
yyerrlab2:
  yyerrstatus = 3;	/* Each real token shifted decrements this.  */

  for (;;)
    {
      yyn = yypact[yystate];
      if (yyn != YYPACT_NINF)
	{







|






<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793

















1794
1795
1796
1797
1798
1799
1800
      yydestruct (yytoken, &yylval);
      yychar = YYEMPTY;

    }

  /* Else will try to reuse lookahead token after shifting the error
     token.  */
  goto yyerrlab1;


/*----------------------------------------------------.
| yyerrlab1 -- error raised explicitly by an action.  |
`----------------------------------------------------*/
yyerrlab1:

















  yyerrstatus = 3;	/* Each real token shifted decrements this.  */

  for (;;)
    {
      yyn = yypact[yystate];
      if (yyn != YYPACT_NINF)
	{
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
  if (yyss != yyssa)
    YYSTACK_FREE (yyss);
#endif
  return yyresult;
}


#line 431 "../unix/../generic/tclGetDate.y"


/*
 * Month and day table.
 */
static TABLE    MonthDayTable[] = {
    { "january",        tMONTH,  1 },







|







1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
  if (yyss != yyssa)
    YYSTACK_FREE (yyss);
#endif
  return yyresult;
}





/*
 * Month and day table.
 */
static TABLE    MonthDayTable[] = {
    { "january",        tMONTH,  1 },
2235
2236
2237
2238
2239
2240
2241

2242
2243
2244
2245
2246
2247
2248
	    Count = 0;
            for (yylval.Number = 0;
		    isdigit(UCHAR(c = *yyInput++)); ) { /* INTL: digit */
                yylval.Number = 10 * yylval.Number + c - '0';
		Count++;
	    }
            yyInput--;

	    /* A number with 6 or more digits is considered an ISO 8601 base */
	    if (Count >= 6) {
		return tISOBASE;
	    } else {
		return tUNUMBER;
	    }
        }







>







2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
	    Count = 0;
            for (yylval.Number = 0;
		    isdigit(UCHAR(c = *yyInput++)); ) { /* INTL: digit */
                yylval.Number = 10 * yylval.Number + c - '0';
		Count++;
	    }
            yyInput--;
	    yyDigitCount = Count;
	    /* A number with 6 or more digits is considered an ISO 8601 base */
	    if (Count >= 6) {
		return tISOBASE;
	    } else {
		return tUNUMBER;
	    }
        }
Changes to generic/tclGetDate.y.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/* 
 * tclGetDate.y --
 *
 *	Contains yacc grammar for parsing date and time strings.
 *	The output of this file should be the file tclDate.c which
 *	is used directly in the Tcl sources.
 *
 * Copyright (c) 1992-1995 Karl Lehenbauer and Mark Diekhans.
 * Copyright (c) 1995-1997 Sun Microsystems, Inc.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tclGetDate.y,v 1.25 2004/09/27 14:31:17 kennykb Exp $
 */

%{
/* 
 * tclDate.c --
 *
 *	This file is generated from a yacc grammar defined in













|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/* 
 * tclGetDate.y --
 *
 *	Contains yacc grammar for parsing date and time strings.
 *	The output of this file should be the file tclDate.c which
 *	is used directly in the Tcl sources.
 *
 * Copyright (c) 1992-1995 Karl Lehenbauer and Mark Diekhans.
 * Copyright (c) 1995-1997 Sun Microsystems, Inc.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tclGetDate.y,v 1.26 2004/12/29 20:57:27 kennykb Exp $
 */

%{
/* 
 * tclDate.c --
 *
 *	This file is generated from a yacc grammar defined in
73
74
75
76
77
78
79


80
81
82
83
84
85
86
    time_t   dateDayOrdinal;
    time_t   dateDayNumber;
    int      dateHaveDay;

    char     *dateInput;
    time_t   *dateRelPointer;



} DateInfo;

#define YYPARSE_PARAM info
#define YYLEX_PARAM info

#define yyDSTmode (((DateInfo*)info)->dateDSTmode)
#define yyDayOrdinal (((DateInfo*)info)->dateDayOrdinal)







>
>







73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
    time_t   dateDayOrdinal;
    time_t   dateDayNumber;
    int      dateHaveDay;

    char     *dateInput;
    time_t   *dateRelPointer;

    int	     dateDigitCount;

} DateInfo;

#define YYPARSE_PARAM info
#define YYLEX_PARAM info

#define yyDSTmode (((DateInfo*)info)->dateDSTmode)
#define yyDayOrdinal (((DateInfo*)info)->dateDayOrdinal)
101
102
103
104
105
106
107

108
109
110
111
112
113
114
#define yySeconds (((DateInfo*)info)->dateSeconds)
#define yyMeridian (((DateInfo*)info)->dateMeridian)
#define yyRelMonth (((DateInfo*)info)->dateRelMonth)
#define yyRelDay (((DateInfo*)info)->dateRelDay)
#define yyRelSeconds (((DateInfo*)info)->dateRelSeconds)
#define yyRelPointer (((DateInfo*)info)->dateRelPointer)
#define yyInput (((DateInfo*)info)->dateInput)


#define EPOCH           1970
#define START_OF_TIME   1902
#define END_OF_TIME     2037

/*
 * The offset of tm_year of struct tm returned by localtime, gmtime, etc.







>







103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#define yySeconds (((DateInfo*)info)->dateSeconds)
#define yyMeridian (((DateInfo*)info)->dateMeridian)
#define yyRelMonth (((DateInfo*)info)->dateRelMonth)
#define yyRelDay (((DateInfo*)info)->dateRelDay)
#define yyRelSeconds (((DateInfo*)info)->dateRelSeconds)
#define yyRelPointer (((DateInfo*)info)->dateRelPointer)
#define yyInput (((DateInfo*)info)->dateInput)
#define yyDigitCount (((DateInfo*)info)->dateDigitCount)

#define EPOCH           1970
#define START_OF_TIME   1902
#define END_OF_TIME     2037

/*
 * The offset of tm_year of struct tm returned by localtime, gmtime, etc.
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417

number  : tUNUMBER
    {
	if (yyHaveTime && yyHaveDate && !yyHaveRel) {
	    yyYear = $1;
	} else {
	    yyHaveTime++;
	    if ($1 < 100) {
		yyHour = $1;
		yyMinutes = 0;
	    } else {
		yyHour = $1 / 100;
		yyMinutes = $1 % 100;
	    }
	    yySeconds = 0;







|







406
407
408
409
410
411
412
413
414
415
416
417
418
419
420

number  : tUNUMBER
    {
	if (yyHaveTime && yyHaveDate && !yyHaveRel) {
	    yyYear = $1;
	} else {
	    yyHaveTime++;
	    if (yyDigitCount <= 2) {
		yyHour = $1;
		yyMinutes = 0;
	    } else {
		yyHour = $1 / 100;
		yyMinutes = $1 % 100;
	    }
	    yySeconds = 0;
797
798
799
800
801
802
803

804
805
806
807
808
809
810
	    Count = 0;
            for (yylval.Number = 0;
		    isdigit(UCHAR(c = *yyInput++)); ) { /* INTL: digit */
                yylval.Number = 10 * yylval.Number + c - '0';
		Count++;
	    }
            yyInput--;

	    /* A number with 6 or more digits is considered an ISO 8601 base */
	    if (Count >= 6) {
		return tISOBASE;
	    } else {
		return tUNUMBER;
	    }
        }







>







800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
	    Count = 0;
            for (yylval.Number = 0;
		    isdigit(UCHAR(c = *yyInput++)); ) { /* INTL: digit */
                yylval.Number = 10 * yylval.Number + c - '0';
		Count++;
	    }
            yyInput--;
	    yyDigitCount = Count;
	    /* A number with 6 or more digits is considered an ISO 8601 base */
	    if (Count >= 6) {
		return tISOBASE;
	    } else {
		return tUNUMBER;
	    }
        }
Changes to library/clock.tcl.
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#
#----------------------------------------------------------------------
#
# Copyright (c) 2004 by Kevin B. Kenny.  All rights reserved.
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# RCS: @(#) $Id: clock.tcl,v 1.12 2004/11/30 15:45:04 kennykb Exp $
#
#----------------------------------------------------------------------

# We must have message catalogs that support the root locale, and
# we need access to the Registry on Windows systems.  We also need
# Tcl 8.5 dictionaries.








|







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#
#----------------------------------------------------------------------
#
# Copyright (c) 2004 by Kevin B. Kenny.  All rights reserved.
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# RCS: @(#) $Id: clock.tcl,v 1.13 2004/12/29 20:57:28 kennykb Exp $
#
#----------------------------------------------------------------------

# We must have message catalogs that support the root locale, and
# we need access to the Registry on Windows systems.  We also need
# Tcl 8.5 dictionaries.

4415
4416
4417
4418
4419
4420
4421








4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
	BCE {
	    set year [expr { 1 - [dict get $date year] }]
	}
	CE {
	    set year [dict get $date year]
	}
    }








    set ym1 [expr { $year - 1 }]

    # Try the Gregorian calendar first.

    dict set date gregorian 1
    set jd [expr { 1721425
		   + [dict get $date dayOfMonth]
		   + ( [IsGregorianLeapYear $date] ?
		       [lindex $DaysInPriorMonthsInLeapYear \
			    [expr { [dict get $date month] - 1}]]
		       : [lindex $DaysInPriorMonthsInCommonYear \
			      [expr { [dict get $date month] - 1}]] )
		   + ( 365 * $ym1 )
		   + ( $ym1 / 4 )
		   - ( $ym1 / 100 )
		   + ( $ym1 / 400 ) }]
    
    # If the date is before the Gregorian change, use the Julian calendar.

    if { $jd < [mc GREGORIAN_CHANGE_DATE] } {

	dict set date gregorian 0
	set jd [expr { 1721423
		       + [dict get $date dayOfMonth]
		       + ( ( $year % 4 == 0 ) ?
		       [lindex $DaysInPriorMonthsInLeapYear \
			    [expr { [dict get $date month] - 1}]]
		       : [lindex $DaysInPriorMonthsInCommonYear \
			      [expr { [dict get $date month] - 1}]] )
		       + ( 365 * $ym1 )
		       + ( $ym1 / 4 ) }]
    }

    dict set date julianDay $jd
    return $date








>
>
>
>
>
>
>
>









|

|














|

|







4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
	BCE {
	    set year [expr { 1 - [dict get $date year] }]
	}
	CE {
	    set year [dict get $date year]
	}
    }

    # If month is out of range, reduce modulo 12 and adjust year accordingly.

    set month [expr { [dict get $date month] - 1 }]
    incr year [expr { $month / 12 }]
    set month [expr { ( $month % 12 ) + 1 }]
    dict set date era CE; dict set date year $year; dict set date month $month

    set ym1 [expr { $year - 1 }]

    # Try the Gregorian calendar first.

    dict set date gregorian 1
    set jd [expr { 1721425
		   + [dict get $date dayOfMonth]
		   + ( [IsGregorianLeapYear $date] ?
		       [lindex $DaysInPriorMonthsInLeapYear \
			    [expr { $month - 1}]]
		       : [lindex $DaysInPriorMonthsInCommonYear \
			      [expr { $month - 1}]] )
		   + ( 365 * $ym1 )
		   + ( $ym1 / 4 )
		   - ( $ym1 / 100 )
		   + ( $ym1 / 400 ) }]
    
    # If the date is before the Gregorian change, use the Julian calendar.

    if { $jd < [mc GREGORIAN_CHANGE_DATE] } {

	dict set date gregorian 0
	set jd [expr { 1721423
		       + [dict get $date dayOfMonth]
		       + ( ( $year % 4 == 0 ) ?
		       [lindex $DaysInPriorMonthsInLeapYear \
			    [expr { $month - 1}]]
		       : [lindex $DaysInPriorMonthsInCommonYear \
			      [expr { $month - 1}]] )
		       + ( 365 * $ym1 )
		       + ( $ym1 / 4 ) }]
    }

    dict set date julianDay $jd
    return $date

4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
# Side effects:
#	None.
#
#----------------------------------------------------------------------

proc ::tcl::clock::GetJulianDayFromEraYearDay { date } {

    variable DaysInPriorMonthsInCommonYear
    variable DaysInPriorMonthsInLeapYear

    # Get absolute year number from the civil year

    switch -exact [dict get $date era] {
	BCE {
	    set year [expr { 1 - [dict get $date year] }]
	}
	CE {







<
<
<







4487
4488
4489
4490
4491
4492
4493



4494
4495
4496
4497
4498
4499
4500
# Side effects:
#	None.
#
#----------------------------------------------------------------------

proc ::tcl::clock::GetJulianDayFromEraYearDay { date } {




    # Get absolute year number from the civil year

    switch -exact [dict get $date era] {
	BCE {
	    set year [expr { 1 - [dict get $date year] }]
	}
	CE {
Changes to tests/clock.test.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# clock.test --
#
#	This test file covers the 'clock' command that manipulates time.
#
# This file contains a collection of tests for one or more of the Tcl
# built-in commands. Sourcing this file into Tcl runs the tests and
# generates output for errors.  No output means no errors were found.
#
# Copyright (c) 2004 by Kevin B. Kenny.  All rights reserved.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# RCS: @(#) $Id: clock.test,v 1.52 2004/11/30 15:45:04 kennykb Exp $

if {[lsearch [namespace children] ::tcltest] == -1} {
    package require tcltest 2
    namespace import -force ::tcltest::*
}

if { $::tcl_platform(platform) eq {windows} } {













|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# clock.test --
#
#	This test file covers the 'clock' command that manipulates time.
#
# This file contains a collection of tests for one or more of the Tcl
# built-in commands. Sourcing this file into Tcl runs the tests and
# generates output for errors.  No output means no errors were found.
#
# Copyright (c) 2004 by Kevin B. Kenny.  All rights reserved.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# RCS: @(#) $Id: clock.test,v 1.53 2004/12/29 20:57:28 kennykb Exp $

if {[lsearch [namespace children] ::tcltest] == -1} {
    package require tcltest 2
    namespace import -force ::tcltest::*
}

if { $::tcl_platform(platform) eq {windows} } {
35370
35371
35372
35373
35374
35375
35376
























35377
35378
35379
35380
35381
35382
35383
35384
35385
35386
35387
    -result {12:34:56-0500}
    
test clock-45.1 {regression test - time zone containing only two digits} \
    -body {
	clock scan 1985-04-12T10:15:30+04 -format %Y-%m-%dT%H:%M:%S%Z
    } \
    -result 482134530

























# cleanup

namespace delete ::testClock
::tcl::clock::ClearCaches
::tcltest::cleanupTests
return

# Local Variables:
# mode: tcl
# End:







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>











35370
35371
35372
35373
35374
35375
35376
35377
35378
35379
35380
35381
35382
35383
35384
35385
35386
35387
35388
35389
35390
35391
35392
35393
35394
35395
35396
35397
35398
35399
35400
35401
35402
35403
35404
35405
35406
35407
35408
35409
35410
35411
    -result {12:34:56-0500}
    
test clock-45.1 {regression test - time zone containing only two digits} \
    -body {
	clock scan 1985-04-12T10:15:30+04 -format %Y-%m-%dT%H:%M:%S%Z
    } \
    -result 482134530

test clock-46.1 {regression test - month zero} \
    -body {
	clock scan 2004-00-00 -format %Y-%m-%d
    } -result [clock scan 2003-11-30 -format %Y-%m-%d]
test clock-46.2 {regression test - month zero} \
    -body {
	clock scan 20040000
    } -result [clock scan 2003-11-30 -format %Y-%m-%d]
test clock-46.3 {regression test - month thirteen} \
    -body {
	clock scan 2004-13-01 -format %Y-%m-%d
    } -result [clock scan 2005-01-01 -format %Y-%m-%d]
test clock-46.4 {regression test - month thirteen} \
    -body {
	clock scan 20041301
    } -result [clock scan 2005-01-01 -format %Y-%m-%d]

test clock-47.1 {regression test - four-digit time} {
    clock scan 0012
} [clock scan 0012 -format %H%M]
test clock-47.2 {regression test - four digit time} {
    clock scan 0039
} [clock scan 0039 -format %H%M]

# cleanup

namespace delete ::testClock
::tcl::clock::ClearCaches
::tcltest::cleanupTests
return

# Local Variables:
# mode: tcl
# End:
Changes to unix/Makefile.in.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#
# This file is a Makefile for Tcl.  If it has the name "Makefile.in"
# then it is a template for a Makefile;  to generate the actual Makefile,
# run "./configure", which is a configuration script generated by the
# "autoconf" program (constructs like "@foo@" will get replaced in the
# actual Makefile.
#
# RCS: @(#) $Id: Makefile.in,v 1.158 2004/12/07 23:15:19 hobbs Exp $

VERSION 		= @TCL_VERSION@
MAJOR_VERSION		= @TCL_MAJOR_VERSION@
MINOR_VERSION		= @TCL_MINOR_VERSION@
PATCH_LEVEL		= @TCL_PATCH_LEVEL@

#----------------------------------------------------------------







|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#
# This file is a Makefile for Tcl.  If it has the name "Makefile.in"
# then it is a template for a Makefile;  to generate the actual Makefile,
# run "./configure", which is a configuration script generated by the
# "autoconf" program (constructs like "@foo@" will get replaced in the
# actual Makefile.
#
# RCS: @(#) $Id: Makefile.in,v 1.159 2004/12/29 20:57:30 kennykb Exp $

VERSION 		= @TCL_VERSION@
MAJOR_VERSION		= @TCL_MAJOR_VERSION@
MINOR_VERSION		= @TCL_MINOR_VERSION@
PATCH_LEVEL		= @TCL_PATCH_LEVEL@

#----------------------------------------------------------------
558
559
560
561
562
563
564

565
566
567
568
569
570
571
# from the yacc grammar found in generic/tclGetDate.y.  This is
# only run by hand as yacc is not available in all environments.
# The name of the .c file is different than the name of the .y file
# so that make doesn't try to automatically regenerate the .c file.

gendate:
	bison --output-file=$(GENERIC_DIR)/tclDate.c \

	--name-prefix=TclDate \
	$(GENERIC_DIR)/tclGetDate.y

#	yacc -l $(GENERIC_DIR)/tclGetDate.y
#	sed -e 's/yy/TclDate/g' -e '/^#include <values.h>/d' \
#	    -e 's?SCCSID?RCS: @(#) ?' \
#	    -e '/#ifdef __STDC__/,/#endif/d' -e '/TclDateerrlab:/d' \







>







558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
# from the yacc grammar found in generic/tclGetDate.y.  This is
# only run by hand as yacc is not available in all environments.
# The name of the .c file is different than the name of the .y file
# so that make doesn't try to automatically regenerate the .c file.

gendate:
	bison --output-file=$(GENERIC_DIR)/tclDate.c \
	--no-lines \
	--name-prefix=TclDate \
	$(GENERIC_DIR)/tclGetDate.y

#	yacc -l $(GENERIC_DIR)/tclGetDate.y
#	sed -e 's/yy/TclDate/g' -e '/^#include <values.h>/d' \
#	    -e 's?SCCSID?RCS: @(#) ?' \
#	    -e '/#ifdef __STDC__/,/#endif/d' -e '/TclDateerrlab:/d' \
Changes to win/Makefile.in.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#
# This file is a Makefile for Tcl.  If it has the name "Makefile.in"
# then it is a template for a Makefile;  to generate the actual Makefile,
# run "./configure", which is a configuration script generated by the
# "autoconf" program (constructs like "@foo@" will get replaced in the
# actual Makefile.
#
# RCS: @(#) $Id: Makefile.in,v 1.85 2004/12/02 18:40:17 kennykb Exp $

VERSION = @TCL_VERSION@

#----------------------------------------------------------------
# Things you can change to personalize the Makefile for your own
# site (you can make these changes in either Makefile.in or
# Makefile, but changes to Makefile will get lost if you re-run







|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#
# This file is a Makefile for Tcl.  If it has the name "Makefile.in"
# then it is a template for a Makefile;  to generate the actual Makefile,
# run "./configure", which is a configuration script generated by the
# "autoconf" program (constructs like "@foo@" will get replaced in the
# actual Makefile.
#
# RCS: @(#) $Id: Makefile.in,v 1.86 2004/12/29 20:57:30 kennykb Exp $

VERSION = @TCL_VERSION@

#----------------------------------------------------------------
# Things you can change to personalize the Makefile for your own
# site (you can make these changes in either Makefile.in or
# Makefile, but changes to Makefile will get lost if you re-run
464
465
466
467
468
469
470

471
472
473
474
475
476
477
# only run by hand as yacc is not available in all environments.
# The name of the .c file is different than the name of the .y file
# so that make doesn't try to automatically regenerate the .c file.

gendate:
	bison --output-file=$(GENERIC_DIR)/tclDate.c \
	--name-prefix=TclDate \

	$(GENERIC_DIR)/tclGetDate.y

install: all install-binaries install-libraries install-doc

install-binaries: binaries
	@for i in "$(LIB_INSTALL_DIR)" "$(BIN_INSTALL_DIR)" ; \
	    do \







>







464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
# only run by hand as yacc is not available in all environments.
# The name of the .c file is different than the name of the .y file
# so that make doesn't try to automatically regenerate the .c file.

gendate:
	bison --output-file=$(GENERIC_DIR)/tclDate.c \
	--name-prefix=TclDate \
	--no-lines \
	$(GENERIC_DIR)/tclGetDate.y

install: all install-binaries install-libraries install-doc

install-binaries: binaries
	@for i in "$(LIB_INSTALL_DIR)" "$(BIN_INSTALL_DIR)" ; \
	    do \