summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorKevin B Kenny <kennykb@acm.org>2007-03-20 19:47:47 (GMT)
committerKevin B Kenny <kennykb@acm.org>2007-03-20 19:47:47 (GMT)
commit1e14587ab8671097dbf480b432c3088434d59bef (patch)
treece9d5cd779d10bbf2badad2b903cd4a511df71ce /generic
parentabd93fef6a71368ac43d2e09eb707057229bf8e4 (diff)
downloadtcl-1e14587ab8671097dbf480b432c3088434d59bef.zip
tcl-1e14587ab8671097dbf480b432c3088434d59bef.tar.gz
tcl-1e14587ab8671097dbf480b432c3088434d59bef.tar.bz2
2007-03-20 Kevin B. Kenny <kennykb@acm.org>
* generic/tclDate.c: Rebuilt, despite Donal Fellows's comment when committing it that no rebuild was required. * generic/tclGetDate.y: According to Donal Fellows, "Introduce modern formatting standards; no need for rebuild of tclDate.c." * library/tzdata/America/Cambridge_Bay: * library/tzdata/America/Havana: * library/tzdata/America/Inuvik: * library/tzdata/America/Iqaluit: * library/tzdata/America/Pangnirtung: * library/tzdata/America/Rankin_Inlet: * library/tzdata/America/Resolute: * library/tzdata/America/Yellowknife: * library/tzdata/Asia/Choibalsan: * library/tzdata/Asia/Dili: * library/tzdata/Asia/Hovd: * library/tzdata/Asia/Jakarta: * library/tzdata/Asia/Jayapura: * library/tzdata/Asia/Makassar: * library/tzdata/Asia/Pontianak: * library/tzdata/Asia/Ulaanbaatar: * library/tzdata/Europe/Istanbul: Upgraded to Olson's tzdata2007d. * generic/tclListObj.c (TclLsetList, TclLsetFlat): * tests/lset.test: Changes to deal with shared internal representation for lists passed to the [lset] command. Thanks to Don Porter for fixing this issue. [Bug 1677512]
Diffstat (limited to 'generic')
-rw-r--r--generic/tclDate.c1252
-rw-r--r--generic/tclListObj.c219
2 files changed, 737 insertions, 734 deletions
diff --git a/generic/tclDate.c b/generic/tclDate.c
index b38026f..cc1a30b 100644
--- a/generic/tclDate.c
+++ b/generic/tclDate.c
@@ -1,7 +1,7 @@
-/* A Bison parser, made by GNU Bison 1.875. */
+/* 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 Free Software Foundation, Inc.
+ 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
@@ -107,25 +107,25 @@
/* 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.
+ * This file is generated from a yacc grammar defined in the file
+ * tclGetDate.y. It should not be edited directly.
*
* 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.
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
*/
#include "tclInt.h"
/*
- * Bison generates several labels that happen to be unused. MS Visual
- * C++ doesn't like that, and complains. Tell it to shut up.
+ * Bison generates several labels that happen to be unused. MS Visual C++
+ * doesn't like that, and complains. Tell it to shut up.
*/
#ifdef _MSC_VER
@@ -133,124 +133,123 @@
#endif /* _MSC_VER */
/*
- * yyparse will accept a 'struct DateInfo' as its parameter;
- * that's where the parsed fields will be returned.
+ * yyparse will accept a 'struct DateInfo' as its parameter; that's where the
+ * parsed fields will be returned.
*/
typedef struct DateInfo {
+ time_t dateYear;
+ time_t dateMonth;
+ time_t dateDay;
+ int dateHaveDate;
- time_t dateYear;
- time_t dateMonth;
- time_t dateDay;
- int dateHaveDate;
-
- time_t dateHour;
- time_t dateMinutes;
- time_t dateSeconds;
- int dateMeridian;
- int dateHaveTime;
-
- time_t dateTimezone;
- int dateDSTmode;
- int dateHaveZone;
+ time_t dateHour;
+ time_t dateMinutes;
+ time_t dateSeconds;
+ int dateMeridian;
+ int dateHaveTime;
- time_t dateRelMonth;
- time_t dateRelDay;
- time_t dateRelSeconds;
- int dateHaveRel;
+ time_t dateTimezone;
+ int dateDSTmode;
+ int dateHaveZone;
- time_t dateMonthOrdinal;
- int dateHaveOrdinalMonth;
+ time_t dateRelMonth;
+ time_t dateRelDay;
+ time_t dateRelSeconds;
+ int dateHaveRel;
- time_t dateDayOrdinal;
- time_t dateDayNumber;
- int dateHaveDay;
+ time_t dateMonthOrdinal;
+ int dateHaveOrdinalMonth;
- char *dateInput;
- time_t *dateRelPointer;
+ time_t dateDayOrdinal;
+ time_t dateDayNumber;
+ int dateHaveDay;
- int dateDigitCount;
+ 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)
-#define yyDayNumber (((DateInfo*)info)->dateDayNumber)
-#define yyMonthOrdinal (((DateInfo*)info)->dateMonthOrdinal)
-#define yyHaveDate (((DateInfo*)info)->dateHaveDate)
-#define yyHaveDay (((DateInfo*)info)->dateHaveDay)
-#define yyHaveOrdinalMonth (((DateInfo*)info)->dateHaveOrdinalMonth)
-#define yyHaveRel (((DateInfo*)info)->dateHaveRel)
-#define yyHaveTime (((DateInfo*)info)->dateHaveTime)
-#define yyHaveZone (((DateInfo*)info)->dateHaveZone)
-#define yyTimezone (((DateInfo*)info)->dateTimezone)
-#define yyDay (((DateInfo*)info)->dateDay)
-#define yyMonth (((DateInfo*)info)->dateMonth)
-#define yyYear (((DateInfo*)info)->dateYear)
-#define yyHour (((DateInfo*)info)->dateHour)
-#define yyMinutes (((DateInfo*)info)->dateMinutes)
-#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
+#define YYPARSE_PARAM info
+#define YYLEX_PARAM info
+
+#define yyDSTmode (((DateInfo *) info)->dateDSTmode)
+#define yyDayOrdinal (((DateInfo *) info)->dateDayOrdinal)
+#define yyDayNumber (((DateInfo *) info)->dateDayNumber)
+#define yyMonthOrdinal (((DateInfo *) info)->dateMonthOrdinal)
+#define yyHaveDate (((DateInfo *) info)->dateHaveDate)
+#define yyHaveDay (((DateInfo *) info)->dateHaveDay)
+#define yyHaveOrdinalMonth (((DateInfo *) info)->dateHaveOrdinalMonth)
+#define yyHaveRel (((DateInfo *) info)->dateHaveRel)
+#define yyHaveTime (((DateInfo *) info)->dateHaveTime)
+#define yyHaveZone (((DateInfo *) info)->dateHaveZone)
+#define yyTimezone (((DateInfo *) info)->dateTimezone)
+#define yyDay (((DateInfo *) info)->dateDay)
+#define yyMonth (((DateInfo *) info)->dateMonth)
+#define yyYear (((DateInfo *) info)->dateYear)
+#define yyHour (((DateInfo *) info)->dateHour)
+#define yyMinutes (((DateInfo *) info)->dateMinutes)
+#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.
* Posix requires 1900.
*/
-#define TM_YEAR_BASE 1900
-#define HOUR(x) ((int) (60 * x))
-#define SECSPERDAY (24L * 60L * 60L)
-#define IsLeapYear(x) ((x % 4 == 0) && (x % 100 != 0 || x % 400 == 0))
+#define TM_YEAR_BASE 1900
+
+#define HOUR(x) ((int) (60 * x))
+#define SECSPERDAY (24L * 60L * 60L)
+#define IsLeapYear(x) ((x % 4 == 0) && (x % 100 != 0 || x % 400 == 0))
/*
- * An entry in the lexical lookup table.
+ * An entry in the lexical lookup table.
*/
+
typedef struct _TABLE {
- const char *name;
- int type;
- time_t value;
+ char *name;
+ int type;
+ time_t value;
} TABLE;
-
/*
- * Daylight-savings mode: on, off, or not yet known.
+ * Daylight-savings mode: on, off, or not yet known.
*/
+
typedef enum _DSTMODE {
DSTon, DSToff, DSTmaybe
} DSTMODE;
/*
- * Meridian: am, pm, or 24-hour style.
+ * Meridian: am, pm, or 24-hour style.
*/
+
typedef enum _MERIDIAN {
MERam, MERpm, MER24
} MERIDIAN;
-
/*
* Prototypes of internal functions.
*/
-static void TclDateerror(const char *s);
-static time_t ToSeconds(time_t Hours, time_t Minutes,
- time_t Seconds, MERIDIAN Meridian);
-static int LookupWord(char *buff);
-static int TclDatelex(void* info);
-
-MODULE_SCOPE int yyparse (void *);
+static int LookupWord(char *buff);
+static void TclDateerror(char *s);
+static int TclDatelex(void *info);
+static time_t ToSeconds(time_t Hours, time_t Minutes,
+ time_t Seconds, MERIDIAN Meridian);
+MODULE_SCOPE int yyparse(void *);
@@ -270,8 +269,8 @@ MODULE_SCOPE int yyparse (void *);
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
typedef union YYSTYPE {
- time_t Number;
- enum _MERIDIAN Meridian;
+ time_t Number;
+ enum _MERIDIAN Meridian;
} YYSTYPE;
/* Line 191 of yacc.c. */
@@ -475,12 +474,12 @@ static const yysigned_char yyrhs[] =
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static const unsigned short yyrline[] =
{
- 0, 181, 181, 182, 185, 188, 191, 194, 197, 200,
- 203, 207, 212, 215, 221, 227, 235, 241, 252, 256,
- 260, 266, 270, 274, 278, 282, 288, 292, 297, 302,
- 307, 312, 316, 321, 325, 330, 337, 341, 347, 356,
- 365, 375, 388, 393, 395, 396, 397, 398, 399, 401,
- 402, 404, 405, 406, 409, 428, 431
+ 0, 182, 182, 183, 186, 189, 192, 195, 198, 201,
+ 204, 208, 213, 216, 222, 228, 236, 242, 253, 257,
+ 261, 267, 271, 275, 279, 283, 289, 293, 298, 303,
+ 308, 313, 317, 322, 326, 331, 338, 342, 348, 357,
+ 366, 376, 390, 395, 398, 401, 404, 407, 410, 415,
+ 418, 423, 427, 431, 437, 455, 458
};
#endif
@@ -647,6 +646,7 @@ static const unsigned char yystos[] =
#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. */
@@ -767,9 +767,9 @@ yy_reduce_print (yyrule)
#endif
{
int yyi;
- unsigned int yylineno = yyrline[yyrule];
+ unsigned int yylno = yyrline[yyrule];
YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
- yyrule - 1, yylineno);
+ 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]]);
@@ -1231,43 +1231,43 @@ yyreduce:
case 4:
{
- yyHaveTime++;
- ;}
+ yyHaveTime++;
+ ;}
break;
case 5:
{
- yyHaveZone++;
- ;}
+ yyHaveZone++;
+ ;}
break;
case 6:
{
- yyHaveDate++;
- ;}
+ yyHaveDate++;
+ ;}
break;
case 7:
{
- yyHaveOrdinalMonth++;
- ;}
+ yyHaveOrdinalMonth++;
+ ;}
break;
case 8:
{
- yyHaveDay++;
- ;}
+ yyHaveDay++;
+ ;}
break;
case 9:
{
- yyHaveRel++;
- ;}
+ yyHaveRel++;
+ ;}
break;
case 10:
@@ -1284,143 +1284,143 @@ yyreduce:
yyHaveTime++;
yyHaveDate++;
yyHaveRel++;
- ;}
+ ;}
break;
case 13:
{
- yyHour = yyvsp[-1].Number;
- yyMinutes = 0;
- yySeconds = 0;
- yyMeridian = yyvsp[0].Meridian;
- ;}
+ 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;
- ;}
+ 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);
+ 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;
- ;}
+ 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);
+ 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;
- ;}
+ yyTimezone = yyvsp[-1].Number;
+ yyDSTmode = DSTon;
+ ;}
break;
case 19:
{
- yyTimezone = yyvsp[0].Number;
- yyDSTmode = DSToff;
- ;}
+ yyTimezone = yyvsp[0].Number;
+ yyDSTmode = DSToff;
+ ;}
break;
case 20:
{
- yyTimezone = yyvsp[0].Number;
- yyDSTmode = DSTon;
- ;}
+ yyTimezone = yyvsp[0].Number;
+ yyDSTmode = DSTon;
+ ;}
break;
case 21:
{
- yyDayOrdinal = 1;
- yyDayNumber = yyvsp[0].Number;
- ;}
+ yyDayOrdinal = 1;
+ yyDayNumber = yyvsp[0].Number;
+ ;}
break;
case 22:
{
- yyDayOrdinal = 1;
- yyDayNumber = yyvsp[-1].Number;
- ;}
+ yyDayOrdinal = 1;
+ yyDayNumber = yyvsp[-1].Number;
+ ;}
break;
case 23:
{
- yyDayOrdinal = yyvsp[-1].Number;
- yyDayNumber = yyvsp[0].Number;
- ;}
+ yyDayOrdinal = yyvsp[-1].Number;
+ yyDayNumber = yyvsp[0].Number;
+ ;}
break;
case 24:
{
- yyDayOrdinal = yyvsp[-2].Number * yyvsp[-1].Number;
- yyDayNumber = yyvsp[0].Number;
- ;}
+ yyDayOrdinal = yyvsp[-2].Number * yyvsp[-1].Number;
+ yyDayNumber = yyvsp[0].Number;
+ ;}
break;
case 25:
{
- yyDayOrdinal = 2;
- yyDayNumber = yyvsp[0].Number;
- ;}
+ yyDayOrdinal = 2;
+ yyDayNumber = yyvsp[0].Number;
+ ;}
break;
case 26:
{
- yyMonth = yyvsp[-2].Number;
- yyDay = yyvsp[0].Number;
- ;}
+ yyMonth = yyvsp[-2].Number;
+ yyDay = yyvsp[0].Number;
+ ;}
break;
case 27:
{
- yyMonth = yyvsp[-4].Number;
- yyDay = yyvsp[-2].Number;
- yyYear = yyvsp[0].Number;
- ;}
+ yyMonth = yyvsp[-4].Number;
+ yyDay = yyvsp[-2].Number;
+ yyYear = yyvsp[0].Number;
+ ;}
break;
case 28:
@@ -1444,35 +1444,35 @@ yyreduce:
case 30:
{
- yyMonth = yyvsp[-2].Number;
- yyDay = yyvsp[0].Number;
- yyYear = yyvsp[-4].Number;
- ;}
+ yyMonth = yyvsp[-2].Number;
+ yyDay = yyvsp[0].Number;
+ yyYear = yyvsp[-4].Number;
+ ;}
break;
case 31:
{
- yyMonth = yyvsp[-1].Number;
- yyDay = yyvsp[0].Number;
- ;}
+ yyMonth = yyvsp[-1].Number;
+ yyDay = yyvsp[0].Number;
+ ;}
break;
case 32:
{
- yyMonth = yyvsp[-3].Number;
- yyDay = yyvsp[-2].Number;
- yyYear = yyvsp[0].Number;
- ;}
+ yyMonth = yyvsp[-3].Number;
+ yyDay = yyvsp[-2].Number;
+ yyYear = yyvsp[0].Number;
+ ;}
break;
case 33:
{
- yyMonth = yyvsp[0].Number;
- yyDay = yyvsp[-1].Number;
- ;}
+ yyMonth = yyvsp[0].Number;
+ yyDay = yyvsp[-1].Number;
+ ;}
break;
case 34:
@@ -1487,10 +1487,10 @@ yyreduce:
case 35:
{
- yyMonth = yyvsp[-1].Number;
- yyDay = yyvsp[-2].Number;
- yyYear = yyvsp[0].Number;
- ;}
+ yyMonth = yyvsp[-1].Number;
+ yyDay = yyvsp[-2].Number;
+ yyYear = yyvsp[0].Number;
+ ;}
break;
case 36:
@@ -1512,27 +1512,27 @@ yyreduce:
case 38:
{
- if (yyvsp[-1].Number != HOUR(- 7)) YYABORT;
+ 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;
+ 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:
@@ -1544,22 +1544,23 @@ yyreduce:
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
+ /*
+ * 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;
+
+ 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:
@@ -1573,92 +1574,115 @@ yyreduce:
case 44:
- { *yyRelPointer += yyvsp[-2].Number * yyvsp[-1].Number * yyvsp[0].Number; ;}
+ {
+ *yyRelPointer += yyvsp[-2].Number * yyvsp[-1].Number * yyvsp[0].Number;
+ ;}
break;
case 45:
- { *yyRelPointer += yyvsp[-1].Number * yyvsp[0].Number; ;}
+ {
+ *yyRelPointer += yyvsp[-1].Number * yyvsp[0].Number;
+ ;}
break;
case 46:
- { *yyRelPointer += yyvsp[0].Number; ;}
+ {
+ *yyRelPointer += yyvsp[0].Number;
+ ;}
break;
case 47:
- { *yyRelPointer += yyvsp[-1].Number * yyvsp[0].Number; ;}
+ {
+ *yyRelPointer += yyvsp[-1].Number * yyvsp[0].Number;
+ ;}
break;
case 48:
- { *yyRelPointer += yyvsp[0].Number; ;}
+ {
+ *yyRelPointer += yyvsp[0].Number;
+ ;}
break;
case 49:
- { yyval.Number = -1; ;}
+ {
+ yyval.Number = -1;
+ ;}
break;
case 50:
- { yyval.Number = 1; ;}
+ {
+ yyval.Number = 1;
+ ;}
break;
case 51:
- { yyval.Number = yyvsp[0].Number; yyRelPointer = &yyRelSeconds; ;}
+ {
+ yyval.Number = yyvsp[0].Number;
+ yyRelPointer = &yyRelSeconds;
+ ;}
break;
case 52:
- { yyval.Number = yyvsp[0].Number; yyRelPointer = &yyRelDay; ;}
+ {
+ yyval.Number = yyvsp[0].Number;
+ yyRelPointer = &yyRelDay;
+ ;}
break;
case 53:
- { yyval.Number = yyvsp[0].Number; yyRelPointer = &yyRelMonth; ;}
+ {
+ 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;
+ if (yyHaveTime && yyHaveDate && !yyHaveRel) {
+ yyYear = yyvsp[0].Number;
} else {
- yyHour = yyvsp[0].Number / 100;
- yyMinutes = yyvsp[0].Number % 100;
+ 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;
}
- yySeconds = 0;
- yyMeridian = MER24;
- }
- ;}
+ ;}
break;
case 55:
{
- yyval.Meridian = MER24;
- ;}
+ yyval.Meridian = MER24;
+ ;}
break;
case 56:
{
- yyval.Meridian = yyvsp[0].Meridian;
- ;}
+ yyval.Meridian = yyvsp[0].Meridian;
+ ;}
break;
}
-/* Line 991 of yacc.c. */
+/* Line 999 of yacc.c. */
yyvsp -= yylen;
@@ -1700,18 +1724,33 @@ yyerrlab:
{
YYSIZE_T yysize = 0;
int yytype = YYTRANSLATE (yychar);
+ const char* yyprefix;
char *yymsg;
- int yyx, yycount;
+ int yyx;
- 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++)
+ 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 (yytname[yyx]) + 15, yycount++;
- yysize += yystrlen ("syntax error, unexpected ") + 1;
- yysize += yystrlen (yytname[yytype]);
+ {
+ 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)
{
@@ -1720,16 +1759,13 @@ yyerrlab:
if (yycount < 5)
{
- yycount = 0;
- for (yyx = yyn < 0 ? -yyn : 0;
- yyx < (int) (sizeof (yytname) / sizeof (char *));
- yyx++)
+ yyprefix = ", expecting ";
+ for (yyx = yyxbegin; yyx < yyxend; ++yyx)
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
{
- const char *yyq = ! yycount ? ", expecting " : " or ";
- yyp = yystpcpy (yyp, yyq);
+ yyp = yystpcpy (yyp, yyprefix);
yyp = yystpcpy (yyp, yytname[yyx]);
- yycount++;
+ yyprefix = " or ";
}
}
yyerror (yymsg);
@@ -1773,30 +1809,13 @@ yyerrlab:
/* Else will try to reuse lookahead token after shifting the error
token. */
- goto yyerrlab2;
+ goto yyerrlab1;
/*----------------------------------------------------.
| 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 (;;)
@@ -1872,7 +1891,6 @@ yyreturn:
-
MODULE_SCOPE int yychar;
MODULE_SCOPE YYSTYPE yylval;
MODULE_SCOPE int yynerrs;
@@ -1880,163 +1898,167 @@ MODULE_SCOPE int yynerrs;
/*
* Month and day table.
*/
-static TABLE MonthDayTable[] = {
- { "january", tMONTH, 1 },
- { "february", tMONTH, 2 },
- { "march", tMONTH, 3 },
- { "april", tMONTH, 4 },
- { "may", tMONTH, 5 },
- { "june", tMONTH, 6 },
- { "july", tMONTH, 7 },
- { "august", tMONTH, 8 },
- { "september", tMONTH, 9 },
- { "sept", tMONTH, 9 },
- { "october", tMONTH, 10 },
- { "november", tMONTH, 11 },
- { "december", tMONTH, 12 },
- { "sunday", tDAY, 0 },
- { "monday", tDAY, 1 },
- { "tuesday", tDAY, 2 },
- { "tues", tDAY, 2 },
- { "wednesday", tDAY, 3 },
- { "wednes", tDAY, 3 },
- { "thursday", tDAY, 4 },
- { "thur", tDAY, 4 },
- { "thurs", tDAY, 4 },
- { "friday", tDAY, 5 },
- { "saturday", tDAY, 6 },
+
+static TABLE MonthDayTable[] = {
+ { "january", tMONTH, 1 },
+ { "february", tMONTH, 2 },
+ { "march", tMONTH, 3 },
+ { "april", tMONTH, 4 },
+ { "may", tMONTH, 5 },
+ { "june", tMONTH, 6 },
+ { "july", tMONTH, 7 },
+ { "august", tMONTH, 8 },
+ { "september", tMONTH, 9 },
+ { "sept", tMONTH, 9 },
+ { "october", tMONTH, 10 },
+ { "november", tMONTH, 11 },
+ { "december", tMONTH, 12 },
+ { "sunday", tDAY, 0 },
+ { "monday", tDAY, 1 },
+ { "tuesday", tDAY, 2 },
+ { "tues", tDAY, 2 },
+ { "wednesday", tDAY, 3 },
+ { "wednes", tDAY, 3 },
+ { "thursday", tDAY, 4 },
+ { "thur", tDAY, 4 },
+ { "thurs", tDAY, 4 },
+ { "friday", tDAY, 5 },
+ { "saturday", tDAY, 6 },
{ NULL }
};
/*
* Time units table.
*/
-static TABLE UnitsTable[] = {
- { "year", tMONTH_UNIT, 12 },
- { "month", tMONTH_UNIT, 1 },
- { "fortnight", tDAY_UNIT, 14 },
- { "week", tDAY_UNIT, 7 },
- { "day", tDAY_UNIT, 1 },
- { "hour", tSEC_UNIT, 60 * 60 },
- { "minute", tSEC_UNIT, 60 },
- { "min", tSEC_UNIT, 60 },
- { "second", tSEC_UNIT, 1 },
- { "sec", tSEC_UNIT, 1 },
+
+static TABLE UnitsTable[] = {
+ { "year", tMONTH_UNIT, 12 },
+ { "month", tMONTH_UNIT, 1 },
+ { "fortnight", tDAY_UNIT, 14 },
+ { "week", tDAY_UNIT, 7 },
+ { "day", tDAY_UNIT, 1 },
+ { "hour", tSEC_UNIT, 60 * 60 },
+ { "minute", tSEC_UNIT, 60 },
+ { "min", tSEC_UNIT, 60 },
+ { "second", tSEC_UNIT, 1 },
+ { "sec", tSEC_UNIT, 1 },
{ NULL }
};
/*
* Assorted relative-time words.
*/
-static TABLE OtherTable[] = {
- { "tomorrow", tDAY_UNIT, 1 },
- { "yesterday", tDAY_UNIT, -1 },
- { "today", tDAY_UNIT, 0 },
- { "now", tSEC_UNIT, 0 },
- { "last", tUNUMBER, -1 },
- { "this", tSEC_UNIT, 0 },
- { "next", tNEXT, 1 },
+
+static TABLE OtherTable[] = {
+ { "tomorrow", tDAY_UNIT, 1 },
+ { "yesterday", tDAY_UNIT, -1 },
+ { "today", tDAY_UNIT, 0 },
+ { "now", tSEC_UNIT, 0 },
+ { "last", tUNUMBER, -1 },
+ { "this", tSEC_UNIT, 0 },
+ { "next", tNEXT, 1 },
#if 0
- { "first", tUNUMBER, 1 },
- { "second", tUNUMBER, 2 },
- { "third", tUNUMBER, 3 },
- { "fourth", tUNUMBER, 4 },
- { "fifth", tUNUMBER, 5 },
- { "sixth", tUNUMBER, 6 },
- { "seventh", tUNUMBER, 7 },
- { "eighth", tUNUMBER, 8 },
- { "ninth", tUNUMBER, 9 },
- { "tenth", tUNUMBER, 10 },
- { "eleventh", tUNUMBER, 11 },
- { "twelfth", tUNUMBER, 12 },
+ { "first", tUNUMBER, 1 },
+ { "second", tUNUMBER, 2 },
+ { "third", tUNUMBER, 3 },
+ { "fourth", tUNUMBER, 4 },
+ { "fifth", tUNUMBER, 5 },
+ { "sixth", tUNUMBER, 6 },
+ { "seventh", tUNUMBER, 7 },
+ { "eighth", tUNUMBER, 8 },
+ { "ninth", tUNUMBER, 9 },
+ { "tenth", tUNUMBER, 10 },
+ { "eleventh", tUNUMBER, 11 },
+ { "twelfth", tUNUMBER, 12 },
#endif
- { "ago", tAGO, 1 },
- { "epoch", tEPOCH, 0 },
- { "stardate", tSTARDATE, 0},
+ { "ago", tAGO, 1 },
+ { "epoch", tEPOCH, 0 },
+ { "stardate", tSTARDATE, 0 },
{ NULL }
};
/*
- * The timezone table. (Note: This table was modified to not use any floating
+ * The timezone table. (Note: This table was modified to not use any floating
* point constants to work around an SGI compiler bug).
*/
-static TABLE TimezoneTable[] = {
- { "gmt", tZONE, HOUR( 0) }, /* Greenwich Mean */
- { "ut", tZONE, HOUR( 0) }, /* Universal (Coordinated) */
- { "utc", tZONE, HOUR( 0) },
- { "uct", tZONE, HOUR( 0) }, /* Universal Coordinated Time */
- { "wet", tZONE, HOUR( 0) }, /* Western European */
- { "bst", tDAYZONE, HOUR( 0) }, /* British Summer */
- { "wat", tZONE, HOUR( 1) }, /* West Africa */
- { "at", tZONE, HOUR( 2) }, /* Azores */
-#if 0
+
+static TABLE TimezoneTable[] = {
+ { "gmt", tZONE, HOUR( 0) }, /* Greenwich Mean */
+ { "ut", tZONE, HOUR( 0) }, /* Universal (Coordinated) */
+ { "utc", tZONE, HOUR( 0) },
+ { "uct", tZONE, HOUR( 0) }, /* Universal Coordinated Time */
+ { "wet", tZONE, HOUR( 0) }, /* Western European */
+ { "bst", tDAYZONE, HOUR( 0) }, /* British Summer */
+ { "wat", tZONE, HOUR( 1) }, /* West Africa */
+ { "at", tZONE, HOUR( 2) }, /* Azores */
+#if 0
/* For completeness. BST is also British Summer, and GST is
* also Guam Standard. */
- { "bst", tZONE, HOUR( 3) }, /* Brazil Standard */
- { "gst", tZONE, HOUR( 3) }, /* Greenland Standard */
+ { "bst", tZONE, HOUR( 3) }, /* Brazil Standard */
+ { "gst", tZONE, HOUR( 3) }, /* Greenland Standard */
#endif
- { "nft", tZONE, HOUR( 7/2) }, /* Newfoundland */
- { "nst", tZONE, HOUR( 7/2) }, /* Newfoundland Standard */
- { "ndt", tDAYZONE, HOUR( 7/2) }, /* Newfoundland Daylight */
- { "ast", tZONE, HOUR( 4) }, /* Atlantic Standard */
- { "adt", tDAYZONE, HOUR( 4) }, /* Atlantic Daylight */
- { "est", tZONE, HOUR( 5) }, /* Eastern Standard */
- { "edt", tDAYZONE, HOUR( 5) }, /* Eastern Daylight */
- { "cst", tZONE, HOUR( 6) }, /* Central Standard */
- { "cdt", tDAYZONE, HOUR( 6) }, /* Central Daylight */
- { "mst", tZONE, HOUR( 7) }, /* Mountain Standard */
- { "mdt", tDAYZONE, HOUR( 7) }, /* Mountain Daylight */
- { "pst", tZONE, HOUR( 8) }, /* Pacific Standard */
- { "pdt", tDAYZONE, HOUR( 8) }, /* Pacific Daylight */
- { "yst", tZONE, HOUR( 9) }, /* Yukon Standard */
- { "ydt", tDAYZONE, HOUR( 9) }, /* Yukon Daylight */
- { "hst", tZONE, HOUR(10) }, /* Hawaii Standard */
- { "hdt", tDAYZONE, HOUR(10) }, /* Hawaii Daylight */
- { "cat", tZONE, HOUR(10) }, /* Central Alaska */
- { "ahst", tZONE, HOUR(10) }, /* Alaska-Hawaii Standard */
- { "nt", tZONE, HOUR(11) }, /* Nome */
- { "idlw", tZONE, HOUR(12) }, /* International Date Line West */
- { "cet", tZONE, -HOUR( 1) }, /* Central European */
- { "cest", tDAYZONE, -HOUR( 1) }, /* Central European Summer */
- { "met", tZONE, -HOUR( 1) }, /* Middle European */
- { "mewt", tZONE, -HOUR( 1) }, /* Middle European Winter */
- { "mest", tDAYZONE, -HOUR( 1) }, /* Middle European Summer */
- { "swt", tZONE, -HOUR( 1) }, /* Swedish Winter */
- { "sst", tDAYZONE, -HOUR( 1) }, /* Swedish Summer */
- { "fwt", tZONE, -HOUR( 1) }, /* French Winter */
- { "fst", tDAYZONE, -HOUR( 1) }, /* French Summer */
- { "eet", tZONE, -HOUR( 2) }, /* Eastern Europe, USSR Zone 1 */
- { "bt", tZONE, -HOUR( 3) }, /* Baghdad, USSR Zone 2 */
- { "it", tZONE, -HOUR( 7/2) }, /* Iran */
- { "zp4", tZONE, -HOUR( 4) }, /* USSR Zone 3 */
- { "zp5", tZONE, -HOUR( 5) }, /* USSR Zone 4 */
- { "ist", tZONE, -HOUR(11/2) }, /* Indian Standard */
- { "zp6", tZONE, -HOUR( 6) }, /* USSR Zone 5 */
-#if 0
+ { "nft", tZONE, HOUR( 7/2) }, /* Newfoundland */
+ { "nst", tZONE, HOUR( 7/2) }, /* Newfoundland Standard */
+ { "ndt", tDAYZONE, HOUR( 7/2) }, /* Newfoundland Daylight */
+ { "ast", tZONE, HOUR( 4) }, /* Atlantic Standard */
+ { "adt", tDAYZONE, HOUR( 4) }, /* Atlantic Daylight */
+ { "est", tZONE, HOUR( 5) }, /* Eastern Standard */
+ { "edt", tDAYZONE, HOUR( 5) }, /* Eastern Daylight */
+ { "cst", tZONE, HOUR( 6) }, /* Central Standard */
+ { "cdt", tDAYZONE, HOUR( 6) }, /* Central Daylight */
+ { "mst", tZONE, HOUR( 7) }, /* Mountain Standard */
+ { "mdt", tDAYZONE, HOUR( 7) }, /* Mountain Daylight */
+ { "pst", tZONE, HOUR( 8) }, /* Pacific Standard */
+ { "pdt", tDAYZONE, HOUR( 8) }, /* Pacific Daylight */
+ { "yst", tZONE, HOUR( 9) }, /* Yukon Standard */
+ { "ydt", tDAYZONE, HOUR( 9) }, /* Yukon Daylight */
+ { "hst", tZONE, HOUR(10) }, /* Hawaii Standard */
+ { "hdt", tDAYZONE, HOUR(10) }, /* Hawaii Daylight */
+ { "cat", tZONE, HOUR(10) }, /* Central Alaska */
+ { "ahst", tZONE, HOUR(10) }, /* Alaska-Hawaii Standard */
+ { "nt", tZONE, HOUR(11) }, /* Nome */
+ { "idlw", tZONE, HOUR(12) }, /* International Date Line West */
+ { "cet", tZONE, -HOUR( 1) }, /* Central European */
+ { "cest", tDAYZONE, -HOUR( 1) }, /* Central European Summer */
+ { "met", tZONE, -HOUR( 1) }, /* Middle European */
+ { "mewt", tZONE, -HOUR( 1) }, /* Middle European Winter */
+ { "mest", tDAYZONE, -HOUR( 1) }, /* Middle European Summer */
+ { "swt", tZONE, -HOUR( 1) }, /* Swedish Winter */
+ { "sst", tDAYZONE, -HOUR( 1) }, /* Swedish Summer */
+ { "fwt", tZONE, -HOUR( 1) }, /* French Winter */
+ { "fst", tDAYZONE, -HOUR( 1) }, /* French Summer */
+ { "eet", tZONE, -HOUR( 2) }, /* Eastern Europe, USSR Zone 1 */
+ { "bt", tZONE, -HOUR( 3) }, /* Baghdad, USSR Zone 2 */
+ { "it", tZONE, -HOUR( 7/2) }, /* Iran */
+ { "zp4", tZONE, -HOUR( 4) }, /* USSR Zone 3 */
+ { "zp5", tZONE, -HOUR( 5) }, /* USSR Zone 4 */
+ { "ist", tZONE, -HOUR(11/2) }, /* Indian Standard */
+ { "zp6", tZONE, -HOUR( 6) }, /* USSR Zone 5 */
+#if 0
/* For completeness. NST is also Newfoundland Stanard, nad SST is
* also Swedish Summer. */
- { "nst", tZONE, -HOUR(13/2) }, /* North Sumatra */
- { "sst", tZONE, -HOUR( 7) }, /* South Sumatra, USSR Zone 6 */
-#endif /* 0 */
- { "wast", tZONE, -HOUR( 7) }, /* West Australian Standard */
- { "wadt", tDAYZONE, -HOUR( 7) }, /* West Australian Daylight */
- { "jt", tZONE, -HOUR(15/2) }, /* Java (3pm in Cronusland!) */
- { "cct", tZONE, -HOUR( 8) }, /* China Coast, USSR Zone 7 */
- { "jst", tZONE, -HOUR( 9) }, /* Japan Standard, USSR Zone 8 */
- { "jdt", tDAYZONE, -HOUR( 9) }, /* Japan Daylight */
- { "kst", tZONE, -HOUR( 9) }, /* Korea Standard */
- { "kdt", tDAYZONE, -HOUR( 9) }, /* Korea Daylight */
- { "cast", tZONE, -HOUR(19/2) }, /* Central Australian Standard */
- { "cadt", tDAYZONE, -HOUR(19/2) }, /* Central Australian Daylight */
- { "east", tZONE, -HOUR(10) }, /* Eastern Australian Standard */
- { "eadt", tDAYZONE, -HOUR(10) }, /* Eastern Australian Daylight */
- { "gst", tZONE, -HOUR(10) }, /* Guam Standard, USSR Zone 9 */
- { "nzt", tZONE, -HOUR(12) }, /* New Zealand */
- { "nzst", tZONE, -HOUR(12) }, /* New Zealand Standard */
- { "nzdt", tDAYZONE, -HOUR(12) }, /* New Zealand Daylight */
- { "idle", tZONE, -HOUR(12) }, /* International Date Line East */
+ { "nst", tZONE, -HOUR(13/2) }, /* North Sumatra */
+ { "sst", tZONE, -HOUR( 7) }, /* South Sumatra, USSR Zone 6 */
+#endif /* 0 */
+ { "wast", tZONE, -HOUR( 7) }, /* West Australian Standard */
+ { "wadt", tDAYZONE, -HOUR( 7) }, /* West Australian Daylight */
+ { "jt", tZONE, -HOUR(15/2) }, /* Java (3pm in Cronusland!) */
+ { "cct", tZONE, -HOUR( 8) }, /* China Coast, USSR Zone 7 */
+ { "jst", tZONE, -HOUR( 9) }, /* Japan Standard, USSR Zone 8 */
+ { "jdt", tDAYZONE, -HOUR( 9) }, /* Japan Daylight */
+ { "kst", tZONE, -HOUR( 9) }, /* Korea Standard */
+ { "kdt", tDAYZONE, -HOUR( 9) }, /* Korea Daylight */
+ { "cast", tZONE, -HOUR(19/2) }, /* Central Australian Standard */
+ { "cadt", tDAYZONE, -HOUR(19/2) }, /* Central Australian Daylight */
+ { "east", tZONE, -HOUR(10) }, /* Eastern Australian Standard */
+ { "eadt", tDAYZONE, -HOUR(10) }, /* Eastern Australian Daylight */
+ { "gst", tZONE, -HOUR(10) }, /* Guam Standard, USSR Zone 9 */
+ { "nzt", tZONE, -HOUR(12) }, /* New Zealand */
+ { "nzst", tZONE, -HOUR(12) }, /* New Zealand Standard */
+ { "nzdt", tDAYZONE, -HOUR(12) }, /* New Zealand Daylight */
+ { "idle", tZONE, -HOUR(12) }, /* International Date Line East */
/* ADDED BY Marco Nijdam */
- { "dst", tDST, HOUR( 0) }, /* DST on (hour is ignored) */
+ { "dst", tDST, HOUR( 0) }, /* DST on (hour is ignored) */
/* End ADDED */
{ NULL }
};
@@ -2044,81 +2066,84 @@ static TABLE TimezoneTable[] = {
/*
* Military timezone table.
*/
-static TABLE MilitaryTable[] = {
- { "a", tZONE, HOUR( 1) },
- { "b", tZONE, HOUR( 2) },
- { "c", tZONE, HOUR( 3) },
- { "d", tZONE, HOUR( 4) },
- { "e", tZONE, HOUR( 5) },
- { "f", tZONE, HOUR( 6) },
- { "g", tZONE, HOUR( 7) },
- { "h", tZONE, HOUR( 8) },
- { "i", tZONE, HOUR( 9) },
- { "k", tZONE, HOUR( 10) },
- { "l", tZONE, HOUR( 11) },
- { "m", tZONE, HOUR( 12) },
- { "n", tZONE, HOUR(- 1) },
- { "o", tZONE, HOUR(- 2) },
- { "p", tZONE, HOUR(- 3) },
- { "q", tZONE, HOUR(- 4) },
- { "r", tZONE, HOUR(- 5) },
- { "s", tZONE, HOUR(- 6) },
- { "t", tZONE, HOUR(- 7) },
- { "u", tZONE, HOUR(- 8) },
- { "v", tZONE, HOUR(- 9) },
- { "w", tZONE, HOUR(-10) },
- { "x", tZONE, HOUR(-11) },
- { "y", tZONE, HOUR(-12) },
- { "z", tZONE, HOUR( 0) },
+
+static TABLE MilitaryTable[] = {
+ { "a", tZONE, HOUR( 1) },
+ { "b", tZONE, HOUR( 2) },
+ { "c", tZONE, HOUR( 3) },
+ { "d", tZONE, HOUR( 4) },
+ { "e", tZONE, HOUR( 5) },
+ { "f", tZONE, HOUR( 6) },
+ { "g", tZONE, HOUR( 7) },
+ { "h", tZONE, HOUR( 8) },
+ { "i", tZONE, HOUR( 9) },
+ { "k", tZONE, HOUR( 10) },
+ { "l", tZONE, HOUR( 11) },
+ { "m", tZONE, HOUR( 12) },
+ { "n", tZONE, HOUR(- 1) },
+ { "o", tZONE, HOUR(- 2) },
+ { "p", tZONE, HOUR(- 3) },
+ { "q", tZONE, HOUR(- 4) },
+ { "r", tZONE, HOUR(- 5) },
+ { "s", tZONE, HOUR(- 6) },
+ { "t", tZONE, HOUR(- 7) },
+ { "u", tZONE, HOUR(- 8) },
+ { "v", tZONE, HOUR(- 9) },
+ { "w", tZONE, HOUR(-10) },
+ { "x", tZONE, HOUR(-11) },
+ { "y", tZONE, HOUR(-12) },
+ { "z", tZONE, HOUR( 0) },
{ NULL }
};
-
/*
* Dump error messages in the bit bucket.
*/
+
static void
-TclDateerror(s)
- const char *s;
+TclDateerror(
+ char *s)
{
}
static time_t
-ToSeconds(Hours, Minutes, Seconds, Meridian)
- time_t Hours;
- time_t Minutes;
- time_t Seconds;
- MERIDIAN Meridian;
+ToSeconds(
+ time_t Hours,
+ time_t Minutes,
+ time_t Seconds,
+ MERIDIAN Meridian)
{
- if (Minutes < 0 || Minutes > 59 || Seconds < 0 || Seconds > 59)
- return -1;
+ if (Minutes < 0 || Minutes > 59 || Seconds < 0 || Seconds > 59) {
+ return -1;
+ }
switch (Meridian) {
case MER24:
- if (Hours < 0 || Hours > 23)
- return -1;
- return (Hours * 60L + Minutes) * 60L + Seconds;
+ if (Hours < 0 || Hours > 23) {
+ return -1;
+ }
+ return (Hours * 60L + Minutes) * 60L + Seconds;
case MERam:
- if (Hours < 1 || Hours > 12)
- return -1;
- return ((Hours % 12) * 60L + Minutes) * 60L + Seconds;
+ if (Hours < 1 || Hours > 12) {
+ return -1;
+ }
+ return ((Hours % 12) * 60L + Minutes) * 60L + Seconds;
case MERpm:
- if (Hours < 1 || Hours > 12)
- return -1;
- return (((Hours % 12) + 12) * 60L + Minutes) * 60L + Seconds;
+ if (Hours < 1 || Hours > 12) {
+ return -1;
+ }
+ return (((Hours % 12) + 12) * 60L + Minutes) * 60L + Seconds;
}
- return -1; /* Should never be reached */
+ return -1; /* Should never be reached */
}
-
static int
-LookupWord(buff)
- char *buff;
+LookupWord(
+ char *buff)
{
register char *p;
register char *q;
register TABLE *tp;
- int i;
- int abbrev;
+ int i, abbrev;
/*
* Make it lowercase.
@@ -2127,192 +2152,203 @@ LookupWord(buff)
Tcl_UtfToLower(buff);
if (strcmp(buff, "am") == 0 || strcmp(buff, "a.m.") == 0) {
- yylval.Meridian = MERam;
- return tMERIDIAN;
+ yylval.Meridian = MERam;
+ return tMERIDIAN;
}
if (strcmp(buff, "pm") == 0 || strcmp(buff, "p.m.") == 0) {
- yylval.Meridian = MERpm;
- return tMERIDIAN;
+ yylval.Meridian = MERpm;
+ return tMERIDIAN;
}
/*
* See if we have an abbreviation for a month.
*/
+
if (strlen(buff) == 3) {
- abbrev = 1;
+ abbrev = 1;
} else if (strlen(buff) == 4 && buff[3] == '.') {
- abbrev = 1;
- buff[3] = '\0';
+ abbrev = 1;
+ buff[3] = '\0';
} else {
- abbrev = 0;
+ abbrev = 0;
}
for (tp = MonthDayTable; tp->name; tp++) {
- if (abbrev) {
- if (strncmp(buff, tp->name, 3) == 0) {
- yylval.Number = tp->value;
- return tp->type;
- }
- } else if (strcmp(buff, tp->name) == 0) {
- yylval.Number = tp->value;
- return tp->type;
- }
+ if (abbrev) {
+ if (strncmp(buff, tp->name, 3) == 0) {
+ yylval.Number = tp->value;
+ return tp->type;
+ }
+ } else if (strcmp(buff, tp->name) == 0) {
+ yylval.Number = tp->value;
+ return tp->type;
+ }
}
for (tp = TimezoneTable; tp->name; tp++) {
- if (strcmp(buff, tp->name) == 0) {
- yylval.Number = tp->value;
- return tp->type;
- }
+ if (strcmp(buff, tp->name) == 0) {
+ yylval.Number = tp->value;
+ return tp->type;
+ }
}
for (tp = UnitsTable; tp->name; tp++) {
- if (strcmp(buff, tp->name) == 0) {
- yylval.Number = tp->value;
- return tp->type;
- }
+ if (strcmp(buff, tp->name) == 0) {
+ yylval.Number = tp->value;
+ return tp->type;
+ }
}
/*
* Strip off any plural and try the units table again.
*/
+
i = strlen(buff) - 1;
if (buff[i] == 's') {
- buff[i] = '\0';
- for (tp = UnitsTable; tp->name; tp++) {
- if (strcmp(buff, tp->name) == 0) {
- yylval.Number = tp->value;
- return tp->type;
- }
+ buff[i] = '\0';
+ for (tp = UnitsTable; tp->name; tp++) {
+ if (strcmp(buff, tp->name) == 0) {
+ yylval.Number = tp->value;
+ return tp->type;
+ }
}
}
for (tp = OtherTable; tp->name; tp++) {
- if (strcmp(buff, tp->name) == 0) {
- yylval.Number = tp->value;
- return tp->type;
- }
+ if (strcmp(buff, tp->name) == 0) {
+ yylval.Number = tp->value;
+ return tp->type;
+ }
}
/*
* Military timezones.
*/
+
if (buff[1] == '\0' && !(*buff & 0x80)
- && isalpha(UCHAR(*buff))) { /* INTL: ISO only */
- for (tp = MilitaryTable; tp->name; tp++) {
- if (strcmp(buff, tp->name) == 0) {
- yylval.Number = tp->value;
- return tp->type;
- }
+ && isalpha(UCHAR(*buff))) { /* INTL: ISO only */
+ for (tp = MilitaryTable; tp->name; tp++) {
+ if (strcmp(buff, tp->name) == 0) {
+ yylval.Number = tp->value;
+ return tp->type;
+ }
}
}
/*
* Drop out any periods and try the timezone table again.
*/
- for (i = 0, p = q = buff; *q; q++)
- if (*q != '.') {
- *p++ = *q;
- } else {
- i++;
+
+ for (i = 0, p = q = buff; *q; q++) {
+ if (*q != '.') {
+ *p++ = *q;
+ } else {
+ i++;
}
+ }
*p = '\0';
if (i) {
- for (tp = TimezoneTable; tp->name; tp++) {
- if (strcmp(buff, tp->name) == 0) {
- yylval.Number = tp->value;
- return tp->type;
- }
+ for (tp = TimezoneTable; tp->name; tp++) {
+ if (strcmp(buff, tp->name) == 0) {
+ yylval.Number = tp->value;
+ return tp->type;
+ }
}
}
-
+
return tID;
}
static int
-TclDatelex( void* info )
+TclDatelex(
+ void *info)
{
- register char c;
- register char *p;
- char buff[20];
- int Count;
+ register char c;
+ register char *p;
+ char buff[20];
+ int Count;
for ( ; ; ) {
- while (isspace(UCHAR(*yyInput))) {
- yyInput++;
+ while (isspace(UCHAR(*yyInput))) {
+ yyInput++;
}
- if (isdigit(UCHAR(c = *yyInput))) { /* INTL: digit */
- /* convert the string into a number; count the number of digits */
+ if (isdigit(UCHAR(c = *yyInput))) { /* INTL: digit */
+ /*
+ * Convert the string into a number; count the number of digits.
+ */
+
Count = 0;
- for (yylval.Number = 0;
- isdigit(UCHAR(c = *yyInput++)); ) { /* INTL: digit */
- yylval.Number = 10 * yylval.Number + c - '0';
+ for (yylval.Number = 0;
+ isdigit(UCHAR(c = *yyInput++)); ) { /* INTL: digit */
+ yylval.Number = 10 * yylval.Number + c - '0';
Count++;
}
- yyInput--;
+ yyInput--;
yyDigitCount = Count;
- /* A number with 6 or more digits is considered an ISO 8601 base */
+
+ /*
+ * A number with 6 or more digits is considered an ISO 8601 base.
+ */
+
if (Count >= 6) {
return tISOBASE;
} else {
return tUNUMBER;
}
- }
- if (!(c & 0x80) && isalpha(UCHAR(c))) { /* INTL: ISO only. */
- for (p = buff; isalpha(UCHAR(c = *yyInput++)) /* INTL: ISO only. */
+ }
+ if (!(c & 0x80) && isalpha(UCHAR(c))) { /* INTL: ISO only. */
+ for (p = buff; isalpha(UCHAR(c = *yyInput++)) /* INTL: ISO only. */
|| c == '.'; ) {
- if (p < &buff[sizeof buff - 1]) {
- *p++ = c;
+ if (p < &buff[sizeof buff - 1]) {
+ *p++ = c;
}
}
- *p = '\0';
- yyInput--;
- return LookupWord(buff);
- }
- if (c != '(') {
- return *yyInput++;
+ *p = '\0';
+ yyInput--;
+ return LookupWord(buff);
}
- Count = 0;
- do {
- c = *yyInput++;
- if (c == '\0') {
- return c;
+ if (c != '(') {
+ return *yyInput++;
+ }
+ Count = 0;
+ do {
+ c = *yyInput++;
+ if (c == '\0') {
+ return c;
} else if (c == '(') {
- Count++;
+ Count++;
} else if (c == ')') {
- Count--;
+ Count--;
}
- } while (Count > 0);
+ } while (Count > 0);
}
}
int
-TclClockOldscanObjCmd( clientData, interp, objc, objv )
- ClientData clientData; /* Unused */
- Tcl_Interp* interp; /* Tcl interpreter */
- int objc; /* Count of paraneters */
- Tcl_Obj *const *objv; /* Parameters */
+TclClockOldscanObjCmd(
+ ClientData clientData, /* Unused */
+ Tcl_Interp *interp, /* Tcl interpreter */
+ int objc, /* Count of paraneters */
+ Tcl_Obj *CONST *objv) /* Parameters */
{
-
- Tcl_Obj* result;
- Tcl_Obj* resultElement;
+ Tcl_Obj *result, *resultElement;
int yr, mo, da;
DateInfo dateInfo;
- void* info = (void*) &dateInfo;
+ void *info = (void *) &dateInfo;
- if ( objc != 5 ) {
- Tcl_WrongNumArgs( interp, 1, objv,
- "stringToParse baseYear baseMonth baseDay" );
+ if (objc != 5) {
+ Tcl_WrongNumArgs(interp, 1, objv,
+ "stringToParse baseYear baseMonth baseDay" );
return TCL_ERROR;
}
yyInput = Tcl_GetString( objv[1] );
yyHaveDate = 0;
- if ( Tcl_GetIntFromObj( interp, objv[2], &yr ) != TCL_OK
- || Tcl_GetIntFromObj( interp, objv[3], &mo ) != TCL_OK
- || Tcl_GetIntFromObj( interp, objv[4], &da ) != TCL_OK ) {
+ if (Tcl_GetIntFromObj(interp, objv[2], &yr) != TCL_OK
+ || Tcl_GetIntFromObj(interp, objv[3], &mo) != TCL_OK
+ || Tcl_GetIntFromObj(interp, objv[4], &da) != TCL_OK) {
return TCL_ERROR;
}
yyYear = yr; yyMonth = mo; yyDay = da;
@@ -2332,104 +2368,104 @@ TclClockOldscanObjCmd( clientData, interp, objc, objv )
yyHaveRel = 0;
yyRelMonth = 0; yyRelDay = 0; yyRelSeconds = 0; yyRelPointer = NULL;
- if ( yyparse( info ) ) {
- Tcl_SetObjResult( interp, Tcl_NewStringObj( "syntax error", -1 ) );
+ if (yyparse(info)) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("syntax error", -1));
return TCL_ERROR;
}
- if ( yyHaveDate > 1 ) {
- Tcl_SetObjResult
- ( interp,
- Tcl_NewStringObj( "more than one date in string", -1 ) );
+ if (yyHaveDate > 1) {
+ Tcl_SetObjResult(interp,
+ Tcl_NewStringObj("more than one date in string", -1));
return TCL_ERROR;
}
- if ( yyHaveTime > 1 ) {
- Tcl_SetObjResult
- ( interp,
- Tcl_NewStringObj( "more than one time of day in string", -1 ) );
+ if (yyHaveTime > 1) {
+ Tcl_SetObjResult(interp,
+ Tcl_NewStringObj("more than one time of day in string", -1));
return TCL_ERROR;
}
- if ( yyHaveZone > 1 ) {
- Tcl_SetObjResult
- ( interp,
- Tcl_NewStringObj( "more than one time zone in string", -1 ) );
+ if (yyHaveZone > 1) {
+ Tcl_SetObjResult(interp,
+ Tcl_NewStringObj("more than one time zone in string", -1));
return TCL_ERROR;
}
- if ( yyHaveDay > 1 ) {
- Tcl_SetObjResult
- ( interp,
- Tcl_NewStringObj( "more than one weekday in string", -1 ) );
+ if (yyHaveDay > 1) {
+ Tcl_SetObjResult(interp,
+ Tcl_NewStringObj("more than one weekday in string", -1));
return TCL_ERROR;
}
- if ( yyHaveOrdinalMonth > 1 ) {
- Tcl_SetObjResult
- ( interp,
- Tcl_NewStringObj( "more than one ordinal month in string", -1 ) );
+ if (yyHaveOrdinalMonth > 1) {
+ Tcl_SetObjResult(interp,
+ Tcl_NewStringObj("more than one ordinal month in string", -1));
return TCL_ERROR;
}
-
+
result = Tcl_NewObj();
resultElement = Tcl_NewObj();
- if ( yyHaveDate ) {
- Tcl_ListObjAppendElement( interp, resultElement,
- Tcl_NewIntObj( (int) yyYear ) );
- Tcl_ListObjAppendElement( interp, resultElement,
- Tcl_NewIntObj( (int) yyMonth ) );
- Tcl_ListObjAppendElement( interp, resultElement,
- Tcl_NewIntObj( (int) yyDay ) );
+ if (yyHaveDate) {
+ Tcl_ListObjAppendElement(interp, resultElement,
+ Tcl_NewIntObj((int) yyYear));
+ Tcl_ListObjAppendElement(interp, resultElement,
+ Tcl_NewIntObj((int) yyMonth));
+ Tcl_ListObjAppendElement(interp, resultElement,
+ Tcl_NewIntObj((int) yyDay));
}
- Tcl_ListObjAppendElement( interp, result, resultElement );
-
- if ( yyHaveTime ) {
- Tcl_ListObjAppendElement( interp, result,
- Tcl_NewIntObj( (int) ToSeconds( yyHour,
- yyMinutes,
- yySeconds,
- yyMeridian ) ) );
+ Tcl_ListObjAppendElement(interp, result, resultElement);
+
+ if (yyHaveTime) {
+ Tcl_ListObjAppendElement(interp, result, Tcl_NewIntObj((int)
+ ToSeconds(yyHour, yyMinutes, yySeconds, yyMeridian)));
} else {
- Tcl_ListObjAppendElement( interp, result, Tcl_NewObj() );
+ Tcl_ListObjAppendElement(interp, result, Tcl_NewObj());
}
resultElement = Tcl_NewObj();
- if ( yyHaveZone ) {
- Tcl_ListObjAppendElement( interp, resultElement,
- Tcl_NewIntObj( (int) -yyTimezone ) );
- Tcl_ListObjAppendElement( interp, resultElement,
- Tcl_NewIntObj( 1-yyDSTmode ) );
+ if (yyHaveZone) {
+ Tcl_ListObjAppendElement(interp, resultElement,
+ Tcl_NewIntObj((int) -yyTimezone));
+ Tcl_ListObjAppendElement(interp, resultElement,
+ Tcl_NewIntObj(1 - yyDSTmode));
}
- Tcl_ListObjAppendElement( interp, result, resultElement );
+ Tcl_ListObjAppendElement(interp, result, resultElement);
resultElement = Tcl_NewObj();
- if ( yyHaveRel ) {
- Tcl_ListObjAppendElement( interp, resultElement,
- Tcl_NewIntObj( (int) yyRelMonth ) );
- Tcl_ListObjAppendElement( interp, resultElement,
- Tcl_NewIntObj( (int) yyRelDay ) );
- Tcl_ListObjAppendElement( interp, resultElement,
- Tcl_NewIntObj( (int) yyRelSeconds ) );
+ if (yyHaveRel) {
+ Tcl_ListObjAppendElement(interp, resultElement,
+ Tcl_NewIntObj((int) yyRelMonth));
+ Tcl_ListObjAppendElement(interp, resultElement,
+ Tcl_NewIntObj((int) yyRelDay));
+ Tcl_ListObjAppendElement(interp, resultElement,
+ Tcl_NewIntObj((int) yyRelSeconds));
}
- Tcl_ListObjAppendElement( interp, result, resultElement );
+ Tcl_ListObjAppendElement(interp, result, resultElement);
resultElement = Tcl_NewObj();
- if ( yyHaveDay && !yyHaveDate ) {
- Tcl_ListObjAppendElement( interp, resultElement,
- Tcl_NewIntObj( (int) yyDayOrdinal ) );
- Tcl_ListObjAppendElement( interp, resultElement,
- Tcl_NewIntObj( (int) yyDayNumber ) );
+ if (yyHaveDay && !yyHaveDate) {
+ Tcl_ListObjAppendElement(interp, resultElement,
+ Tcl_NewIntObj((int) yyDayOrdinal));
+ Tcl_ListObjAppendElement(interp, resultElement,
+ Tcl_NewIntObj((int) yyDayNumber));
}
- Tcl_ListObjAppendElement( interp, result, resultElement );
+ Tcl_ListObjAppendElement(interp, result, resultElement);
resultElement = Tcl_NewObj();
- if ( yyHaveOrdinalMonth ) {
- Tcl_ListObjAppendElement( interp, resultElement,
- Tcl_NewIntObj( (int) yyMonthOrdinal ) );
- Tcl_ListObjAppendElement( interp, resultElement,
- Tcl_NewIntObj( (int) yyMonth ) );
+ if (yyHaveOrdinalMonth) {
+ Tcl_ListObjAppendElement(interp, resultElement,
+ Tcl_NewIntObj((int) yyMonthOrdinal));
+ Tcl_ListObjAppendElement(interp, resultElement,
+ Tcl_NewIntObj((int) yyMonth));
}
- Tcl_ListObjAppendElement( interp, result, resultElement );
-
- Tcl_SetObjResult( interp, result );
+ Tcl_ListObjAppendElement(interp, result, resultElement);
+
+ Tcl_SetObjResult(interp, result);
return TCL_OK;
}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */
diff --git a/generic/tclListObj.c b/generic/tclListObj.c
index f619f8b..7278384 100644
--- a/generic/tclListObj.c
+++ b/generic/tclListObj.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclListObj.c,v 1.42 2007/03/17 05:04:16 dgp Exp $
+ * RCS: @(#) $Id: tclListObj.c,v 1.43 2007/03/20 19:47:48 kennykb Exp $
*/
#include "tclInt.h"
@@ -1255,22 +1255,12 @@ TclLsetFlat(
/* Index args. */
Tcl_Obj *valuePtr) /* Value arg to 'lset'. */
{
- int duplicated; /* Flag == 1 if the obj has been duplicated, 0
- * otherwise. */
- Tcl_Obj *retValuePtr; /* Pointer to the list to be returned. */
- int elemCount; /* Length of one sublist being changed. */
- Tcl_Obj **elemPtrs; /* Pointers to the elements of a sublist. */
- Tcl_Obj *subListPtr; /* Pointer to the current sublist. */
- int index; /* Index of the element to replace in the
- * current sublist. */
- Tcl_Obj *chainPtr; /* Pointer to the enclosing list of the
- * current sublist. */
- int result; /* Status return from library calls. */
- int i;
+ int index, result;
+ Tcl_Obj *subListPtr, *retValuePtr, *chainPtr;
/*
- * If there are no indices, then simply return the new value, counting the
- * returned pointer as a reference.
+ * If there are no indices, simply return the new value.
+ * (Without indices, [lset] is a synonym for [set].
*/
if (indexCount == 0) {
@@ -1279,163 +1269,140 @@ TclLsetFlat(
}
/*
- * If the list is shared, make a private copy. Duplicate the intrep to
- * insure that it is modifyable [Bug 1333036]. A plain Tcl_DuplicateObj
- * will just increase the intrep's refCount without upping the sublists'
- * refCount, so that their true shared status cannot be determined from
- * their refCount.
+ * If the list is shared, make a copy we can modify (copy-on-write).
+ * We use Tcl_DuplicateObj() instead of TclListObjCopy() for a few
+ * reasons: 1) we have not yet confirmed listPtr is actually a list;
+ * 2) We make a verbatim copy of any existing string rep, and when
+ * we combine that with the delayed invalidation of string reps of
+ * modified Tcl_Obj's implemented below, the outcome is that any
+ * error condition that causes this routine to return NULL, will
+ * leave the string rep of listPtr and all elements to be unchanged.
*/
- if (Tcl_IsShared(listPtr)) {
- duplicated = 1;
- if (listPtr->typePtr == &tclListType) {
- result = Tcl_ListObjGetElements(interp, listPtr, &elemCount,
- &elemPtrs);
- listPtr = Tcl_NewListObj(elemCount, elemPtrs);
- } else {
- listPtr = Tcl_DuplicateObj(listPtr);
- }
- Tcl_IncrRefCount(listPtr);
- } else {
- duplicated = 0;
- }
+ subListPtr = Tcl_IsShared(listPtr) ? Tcl_DuplicateObj(listPtr) : listPtr;
/*
* Anchor the linked list of Tcl_Obj's whose string reps must be
* invalidated if the operation succeeds.
*/
- retValuePtr = listPtr;
+ retValuePtr = subListPtr;
chainPtr = NULL;
/*
- * Handle each index arg by diving into the appropriate sublist.
+ * Loop through all the index arguments, and for each one dive
+ * into the appropriate sublist.
*/
- for (i=0 ; ; i++) {
- /*
- * Take the sublist apart.
- */
+ do {
+ int elemCount;
+ Tcl_Obj *parentList, **elemPtrs;
- result = Tcl_ListObjGetElements(interp, listPtr, &elemCount,
- &elemPtrs);
- if (result != TCL_OK) {
+ /* Check for the possible error conditions... */
+ result = TCL_ERROR;
+ if (Tcl_ListObjGetElements(interp, subListPtr, &elemCount, &elemPtrs)
+ != TCL_OK) {
+ /* ...the sublist we're indexing into isn't a list at all. */
break;
}
- if (elemCount == 0) {
- Tcl_SetObjResult(interp,
- Tcl_NewStringObj("list index out of range", -1));
- result = TCL_ERROR;
- break;
- }
- listPtr->internalRep.twoPtrValue.ptr2 = (void *) chainPtr;
-
- /*
- * Determine the index of the requested element.
- */
- result = TclGetIntForIndex(interp, indexArray[i], elemCount-1, &index);
- if (result != TCL_OK) {
+ if (TclGetIntForIndex(interp, *indexArray++, elemCount - 1, &index)
+ != TCL_OK) {
+ /* ...the index we're trying to use isn't an index at all. */
break;
}
- /*
- * Check that the index is in range.
- */
-
- if (index<0 || index>=elemCount) {
+ if (index < 0 || index >= elemCount) {
+ /* ...the index points outside the sublist. */
Tcl_SetObjResult(interp,
Tcl_NewStringObj("list index out of range", -1));
- result = TCL_ERROR;
break;
}
/*
- * Break the loop after extracting the innermost sublist.
+ * No error conditions. As long as we're not yet on the last
+ * index, determine the next sublist for the next pass through
+ * the loop, and take steps to make sure it is an unshared copy,
+ * as we intend to modify it.
*/
- if (i >= indexCount-1) {
- result = TCL_OK;
- break;
- }
-
- /*
- * Extract the appropriate sublist, and make sure that it is unshared.
- * If it is a list, duplicate the intrep to avoid [Bug 1333036], as
- * per the previous comment.
- */
-
- subListPtr = elemPtrs[index];
- if (Tcl_IsShared(subListPtr)) {
- if (subListPtr->typePtr == &tclListType) {
- result = Tcl_ListObjGetElements(interp, subListPtr, &elemCount,
- &elemPtrs);
- subListPtr = Tcl_NewListObj(elemCount, elemPtrs);
- } else {
+ result = TCL_OK;
+ if (--indexCount) {
+ parentList = subListPtr;
+ subListPtr = elemPtrs[index];
+ if (Tcl_IsShared(subListPtr)) {
subListPtr = Tcl_DuplicateObj(subListPtr);
}
- result = TclListObjSetElement(interp, listPtr, index, subListPtr);
- if (result != TCL_OK) {
- /*
- * We actually shouldn't be able to get here. If we do, it
- * would result in leaking subListPtr, but everything's been
- * validated already; the error exit from TclListObjSetElement
- * should never happen.
- */
- break;
+ /*
+ * Replace the original elemPtr[index] in parentList with a copy
+ * we know to be unshared. This call will also deal with the
+ * situation where parentList shares its intrep with other
+ * Tcl_Obj's. Dealing with the shared intrep case can cause
+ * subListPtr to become shared again, so detect that case and
+ * make and store another copy.
+ */
+
+ TclListObjSetElement(NULL, parentList, index, subListPtr);
+ if (Tcl_IsShared(subListPtr)) {
+ subListPtr = Tcl_DuplicateObj(subListPtr);
+ TclListObjSetElement(NULL, parentList, index, subListPtr);
}
- }
- /*
- * Chain the current sublist onto the linked list of Tcl_Obj's whose
- * string reps must be spoilt.
- */
+ /*
+ * The TclListObjSetElement() calls do not spoil the string
+ * rep of parentList, and that's fine for now, since all we've
+ * done so far is replace a list element with an unshared copy.
+ * The list value remains the same, so the string rep. is still
+ * valid, and unchanged, which is good because if this whole
+ * routine returns NULL, we'd like to leave no change to the
+ * value of the lset variable. Later on, when we set valuePtr
+ * in its proper place, then all containing lists will have
+ * their values changed, and will need their string reps spoiled.
+ * We maintain a list of all those Tcl_Obj's (via a little intrep
+ * surgery) so we can spoil them at that time.
+ */
- chainPtr = listPtr;
- listPtr = subListPtr;
- }
+ parentList->internalRep.twoPtrValue.ptr2 = (void *) chainPtr;
+ chainPtr = parentList;
+ }
+ } while (indexCount > 0);
/*
- * Store the result in the list element.
+ * Either we've detected and error condition, and exited the loop
+ * with result == TCL_ERROR, or we've successfully reached the last
+ * index, and we're ready to store valuePtr. In either case, we
+ * need to clean up our string spoiling list of Tcl_Obj's.
*/
- if (result == TCL_OK) {
- result = TclListObjSetElement(interp, listPtr, index, valuePtr);
- }
+ while (chainPtr) {
+ Tcl_Obj *objPtr = chainPtr;
- if (result == TCL_OK) {
- listPtr->internalRep.twoPtrValue.ptr2 = (void *) chainPtr;
+ if (result == TCL_OK) {
- /*
- * Spoil all the string reps.
- */
+ /*
+ * We're going to store valuePtr, so spoil string reps
+ * of all containing lists.
+ */
- while (listPtr != NULL) {
- subListPtr = (Tcl_Obj *) listPtr->internalRep.twoPtrValue.ptr2;
- Tcl_InvalidateStringRep(listPtr);
- listPtr->internalRep.twoPtrValue.ptr2 = NULL;
- listPtr = subListPtr;
+ Tcl_InvalidateStringRep(objPtr);
}
- /*
- * Return the new list if everything worked.
- */
-
- if (!duplicated) {
- Tcl_IncrRefCount(retValuePtr);
- }
- return retValuePtr;
+ /* Clear away our intrep surgery mess */
+ chainPtr = (Tcl_Obj *) objPtr->internalRep.twoPtrValue.ptr2;
+ objPtr->internalRep.twoPtrValue.ptr2 = NULL;
}
- /*
- * Clean up the one dangling reference otherwise.
- */
-
- if (duplicated) {
- Tcl_DecrRefCount(retValuePtr);
+ if (result != TCL_OK) {
+ /* Error return; message is already in interp */
+ return NULL;
}
- return NULL;
+
+ /* Store valuePtr in proper sublist and return */
+ TclListObjSetElement(NULL, subListPtr, index, valuePtr);
+ Tcl_InvalidateStringRep(subListPtr);
+ Tcl_IncrRefCount(retValuePtr);
+ return retValuePtr;
}
/*