Skip to content

Commit 2729717

Browse files
committed
code review, partially cherry picked from tcl-core trunk
1 parent 5cc3a1e commit 2729717

File tree

4 files changed

+38
-29
lines changed

4 files changed

+38
-29
lines changed

generic/tclClock.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,7 +1392,7 @@ ClockSetupTimeZone(
13921392
*----------------------------------------------------------------------
13931393
*/
13941394

1395-
Tcl_Obj *
1395+
static Tcl_Obj *
13961396
ClockFormatNumericTimeZone(int z) {
13971397
char buf[12+1], *p;
13981398

@@ -2580,7 +2580,7 @@ GetYearWeekDay(
25802580
}
25812581

25822582
fields->iso8601Year = temp.iso8601Year;
2583-
dayOfFiscalYear = fields->julianDay - temp.julianDay;
2583+
dayOfFiscalYear = (int)(fields->julianDay - temp.julianDay);
25842584
fields->iso8601Week = (dayOfFiscalYear / 7) + 1;
25852585
fields->dayOfWeek = (dayOfFiscalYear + 1) % 7;
25862586
if (fields->dayOfWeek < 1) {
@@ -2612,9 +2612,9 @@ GetGregorianEraYearDay(
26122612
int changeover) /* Gregorian transition date */
26132613
{
26142614
Tcl_WideInt jday = fields->julianDay;
2615-
Tcl_WideInt year;
26162615
Tcl_WideInt day;
2617-
Tcl_WideInt n;
2616+
int year;
2617+
int n;
26182618

26192619
if (jday >= changeover) {
26202620
/*
@@ -2630,7 +2630,7 @@ GetGregorianEraYearDay(
26302630
*/
26312631

26322632
day = jday - JDAY_1_JAN_1_CE_GREGORIAN;
2633-
n = day / FOUR_CENTURIES;
2633+
n = (int)(day / FOUR_CENTURIES);
26342634
day %= FOUR_CENTURIES;
26352635
if (day < 0) {
26362636
day += FOUR_CENTURIES;
@@ -2643,7 +2643,7 @@ GetGregorianEraYearDay(
26432643
* day = remaining days
26442644
*/
26452645

2646-
n = day / ONE_CENTURY_GREGORIAN;
2646+
n = (int)(day / ONE_CENTURY_GREGORIAN);
26472647
day %= ONE_CENTURY_GREGORIAN;
26482648
if (n > 3) {
26492649
/*
@@ -2668,7 +2668,7 @@ GetGregorianEraYearDay(
26682668
* n = number of 4-year cycles; days = remaining days.
26692669
*/
26702670

2671-
n = day / FOUR_YEARS;
2671+
n = (int)(day / FOUR_YEARS);
26722672
day %= FOUR_YEARS;
26732673
if (day < 0) {
26742674
day += FOUR_YEARS;
@@ -2680,7 +2680,7 @@ GetGregorianEraYearDay(
26802680
* n = number of years; days = remaining days.
26812681
*/
26822682

2683-
n = day / ONE_YEAR;
2683+
n = (int)(day / ONE_YEAR);
26842684
day %= ONE_YEAR;
26852685
if (n > 3) {
26862686
/*
@@ -2703,7 +2703,7 @@ GetGregorianEraYearDay(
27032703
fields->era = CE;
27042704
fields->year = (int)year;
27052705
}
2706-
fields->dayOfYear = (int)(day + 1);
2706+
fields->dayOfYear = (int)day + 1;
27072707
}
27082708

27092709
/*
@@ -2828,8 +2828,8 @@ GetJulianDayFromEraYearMonthDay(
28282828
TclDateFields *fields, /* Date to convert */
28292829
int changeover) /* Gregorian transition date as a Julian Day */
28302830
{
2831-
Tcl_WideInt year, ym1, ym1o4, ym1o100, ym1o400;
2832-
int month, mm1, q, r;
2831+
Tcl_WideInt ym1, ym1o4, ym1o100, ym1o400;
2832+
int year, month, mm1, q, r;
28332833

28342834
if (fields->era == BCE) {
28352835
year = 1 - fields->year;
@@ -3659,7 +3659,8 @@ ClockScanObjCmd(
36593659
}
36603660

36613661
/* seconds are in localSeconds (relative base date), so reset time here */
3662-
yyHour = yyMinutes = yySeconds = yySecondOfDay = 0; yyMeridian = MER24;
3662+
yySecondOfDay = yySeconds = yyMinutes = yyHour = 0;
3663+
yyMeridian = MER24;
36633664

36643665
/* If free scan */
36653666
if (opts.formatObj == NULL) {
@@ -4542,7 +4543,7 @@ ClockAddObjCmd(
45424543
case CLC_ADD_WEEKDAYS:
45434544
/* add number of week days (skipping Saturdays and Sundays)
45444545
* to a relative days value. */
4545-
offs = ClockWeekdaysOffs(yy.date.dayOfWeek, offs);
4546+
offs = ClockWeekdaysOffs(yy.date.dayOfWeek, (int)offs);
45464547
yyRelDay += offs;
45474548
break;
45484549
case CLC_ADD_HOURS:

generic/tclClockFmt.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2087,7 +2087,7 @@ EstimateTokenCount(
20872087
/*
20882088
*----------------------------------------------------------------------
20892089
*/
2090-
ClockFmtScnStorage *
2090+
static ClockFmtScnStorage *
20912091
ClockGetOrParseScanFormat(
20922092
Tcl_Interp *interp, /* Tcl interpreter */
20932093
Tcl_Obj *formatObj) /* Format container */
@@ -3152,7 +3152,7 @@ static ClockFormatTokenMap FmtWordTokenMap = {
31523152
/*
31533153
*----------------------------------------------------------------------
31543154
*/
3155-
ClockFmtScnStorage *
3155+
static ClockFmtScnStorage *
31563156
ClockGetOrParseFmtFormat(
31573157
Tcl_Interp *interp, /* Tcl interpreter */
31583158
Tcl_Obj *formatObj) /* Format container */

generic/tclDate.c

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,17 @@
9090
#include "tclInt.h"
9191

9292
/*
93-
* Bison generates several labels that happen to be unused. MS Visual C++
94-
* doesn't like that, and complains. Tell it to shut up.
93+
* Bison generates several labels that happen to be unused. Several compilers
94+
* don't like that, and complain. Simply disable the warning to silence them.
9595
*/
9696

9797
#ifdef _MSC_VER
9898
#pragma warning( disable : 4102 )
99-
#endif /* _MSC_VER */
99+
#elif defined (__clang__) && (__clang_major__ > 14)
100+
#pragma clang diagnostic ignored "-Wunused-but-set-variable"
101+
#elif (__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 5)))
102+
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
103+
#endif
100104

101105
#if 0
102106
#define YYDEBUG 1
@@ -716,14 +720,14 @@ static const yytype_int8 yytranslate[] =
716720
/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
717721
static const yytype_int16 yyrline[] =
718722
{
719-
0, 171, 171, 172, 176, 179, 182, 185, 189, 193,
720-
196, 199, 203, 206, 211, 217, 223, 228, 232, 236,
721-
240, 244, 248, 254, 255, 258, 262, 266, 270, 274,
722-
278, 284, 290, 294, 299, 300, 305, 309, 314, 318,
723-
323, 330, 334, 340, 340, 342, 347, 352, 354, 359,
724-
361, 362, 370, 381, 396, 401, 404, 407, 410, 413,
725-
416, 419, 424, 427, 432, 437, 442, 449, 452, 455,
726-
460, 478, 481
723+
0, 175, 175, 176, 180, 183, 186, 189, 193, 197,
724+
200, 203, 207, 210, 215, 221, 227, 232, 236, 240,
725+
244, 248, 252, 258, 259, 262, 266, 270, 274, 278,
726+
282, 288, 294, 298, 303, 304, 309, 313, 318, 322,
727+
327, 334, 338, 344, 344, 346, 351, 356, 358, 363,
728+
365, 366, 374, 385, 400, 405, 408, 411, 414, 417,
729+
420, 423, 428, 431, 436, 441, 446, 453, 456, 459,
730+
464, 482, 485
727731
};
728732
#endif
729733

generic/tclGetDate.y

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,17 @@
3939
#include "tclInt.h"
4040

4141
/*
42-
* Bison generates several labels that happen to be unused. MS Visual C++
43-
* doesn't like that, and complains. Tell it to shut up.
42+
* Bison generates several labels that happen to be unused. Several compilers
43+
* don't like that, and complain. Simply disable the warning to silence them.
4444
*/
4545

4646
#ifdef _MSC_VER
4747
#pragma warning( disable : 4102 )
48-
#endif /* _MSC_VER */
48+
#elif defined (__clang__) && (__clang_major__ > 14)
49+
#pragma clang diagnostic ignored "-Wunused-but-set-variable"
50+
#elif (__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 5)))
51+
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
52+
#endif
4953

5054
#if 0
5155
#define YYDEBUG 1

0 commit comments

Comments
 (0)