Skip to content

Commit d49bf1f

Browse files
committed
merge 8.7
2 parents 8d54b05 + d90942b commit d49bf1f

File tree

4 files changed

+25
-21
lines changed

4 files changed

+25
-21
lines changed

doc/clock.n

+4-4
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,14 @@ slowing its clock by a tiny fraction for some minutes until it is
101101
back in sync with UTC; its data model does not represent minutes that
102102
have 59 or 61 seconds.
103103
.TP
104-
\fI\-now\fR
105-
Instead of \fItimeVal\fR a non-integer option \fI\-now\fR can be used as
104+
\fI\now\fR
105+
Instead of \fItimeVal\fR a non-integer option \fI\now\fR can be used as
106106
replacement for today, which is simply interpolated to the runt-time as value
107107
of \fBclock seconds\fR. For example:
108108
.sp
109-
\fBclock format -now -f %a; # current day of the week\fR
109+
\fBclock format now -f %a; # current day of the week\fR
110110
.sp
111-
\fBclock add -now 1 month; # next month\fR
111+
\fBclock add now 1 month; # next month\fR
112112
.TP
113113
\fIunit\fR
114114
.

generic/tclClock.c

+12-8
Original file line numberDiff line numberDiff line change
@@ -3417,16 +3417,18 @@ ClockParseFmtScnArgs(
34173417
if (opts->baseObj != NULL) {
34183418
Tcl_Obj *baseObj = opts->baseObj;
34193419

3420-
/* bypass integer recognition if looks like option "-now" */
3421-
if ((baseObj->bytes && baseObj->length == 4 && baseObj->bytes[1] == 'n')
3420+
/* bypass integer recognition if looks like "now" or "-now" */
3421+
if ((baseObj->bytes &&
3422+
((baseObj->length == 3 && baseObj->bytes[0] == 'n') ||
3423+
(baseObj->length == 4 && baseObj->bytes[1] == 'n')))
34223424
|| TclGetWideIntFromObj(NULL, baseObj, &baseVal) != TCL_OK) {
3423-
/* we accept "-now" as current date-time */
3425+
/* we accept "now" and "-now" as current date-time */
34243426
static const char *const nowOpts[] = {
3425-
"-now", NULL
3427+
"now", "-now", NULL
34263428
};
34273429
int idx;
34283430

3429-
if (Tcl_GetIndexFromObj(interp, baseObj, nowOpts, "seconds",
3431+
if (Tcl_GetIndexFromObj(NULL, baseObj, nowOpts, "seconds",
34303432
TCL_EXACT, &idx) == TCL_OK) {
34313433
goto baseNow;
34323434
}
@@ -3435,7 +3437,9 @@ ClockParseFmtScnArgs(
34353437
goto baseOverflow;
34363438
}
34373439

3438-
Tcl_AppendResult(interp, " or integer", (char *)NULL);
3440+
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
3441+
"bad seconds \"%s\": must be now or integer",
3442+
TclGetString(baseObj)));
34393443
i = baseIdx;
34403444
goto badOption;
34413445
}
@@ -3527,7 +3531,7 @@ ClockFormatObjCmd(
35273531
Tcl_Obj *const objv[]) /* Parameter values */
35283532
{
35293533
ClockClientData *dataPtr = (ClockClientData *)clientData;
3530-
static const char *syntax = "clock format clockval|-now "
3534+
static const char *syntax = "clock format clockval|now "
35313535
"?-format string? "
35323536
"?-gmt boolean? "
35333537
"?-locale LOCALE? ?-timezone ZONE?";
@@ -4358,7 +4362,7 @@ ClockAddObjCmd(
43584362
int objc, /* Parameter count */
43594363
Tcl_Obj *const objv[]) /* Parameter values */
43604364
{
4361-
static const char *syntax = "clock add clockval|-now ?number units?..."
4365+
static const char *syntax = "clock add clockval|now ?number units?..."
43624366
"?-gmt boolean? "
43634367
"?-locale LOCALE? ?-timezone ZONE?";
43644368
ClockClientData *dataPtr = (ClockClientData *)clientData;

tests/clock.test

+8-8
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ test clock-0.1 "initial: auto-loading of ensemble and stubs on demand" -setup {
283283
clock seconds; # init ensemble (but not yet stubs, loading of clock.tcl retarded)
284284
lappend ret ens:[namespace ensemble exists ::clock]
285285
lappend ret stubs:[expr {[namespace which -command ::tcl::clock::GetSystemTimeZone] ne ""}]
286-
clock format -now; # clock.tcl stubs expected
286+
clock format now; # clock.tcl stubs expected
287287
lappend ret stubs:[expr {[namespace which -command ::tcl::clock::GetSystemTimeZone] ne ""}]
288288
}
289289
} -cleanup {
@@ -298,7 +298,7 @@ test clock-0.1a "initial: safe interpreter shares clock command with parent" -se
298298
$sci eval { clock seconds }; # init ensemble (but not yet stubs, loading of clock.tcl retarded)
299299
lappend ret ens:[namespace ensemble exists ::clock]
300300
lappend ret stubs:[expr {[namespace which -command ::tcl::clock::GetSystemTimeZone] ne ""}]
301-
$sci eval { clock format -now }; # clock.tcl stubs expected
301+
$sci eval { clock format now }; # clock.tcl stubs expected
302302
lappend ret stubs:[expr {[namespace which -command ::tcl::clock::GetSystemTimeZone] ne ""}]
303303
}
304304
} -cleanup {
@@ -314,14 +314,14 @@ test clock-0.2 "initial: loading of format/locale does not overwrite interp stat
314314
if {[catch {
315315
return -level 0 -code error -errorcode {EXPERR TEST-ERROR} -errorinfo "ERROR expected error" test
316316
}]} {
317-
clock format -now -locale de; # should not overwrite error code/info
317+
clock format now -locale de; # should not overwrite error code/info
318318
list $::errorCode $::errorInfo
319319
}
320320
} -result {{EXPERR TEST-ERROR} {ERROR expected error}}
321321

322322
# Test some of the basics of [clock format]
323323

324-
set syntax "clockval|-now ?-format string? ?-gmt boolean? ?-locale LOCALE? ?-timezone ZONE?"
324+
set syntax "clockval|now ?-format string? ?-gmt boolean? ?-locale LOCALE? ?-timezone ZONE?"
325325
test clock-1.0 "clock format - wrong # args" {
326326
list [catch {clock format} msg] $msg $::errorCode
327327
} [subst {1 {wrong # args: should be "clock format $syntax"} {CLOCK wrongNumArgs}}]
@@ -332,7 +332,7 @@ test clock-1.0.1 "clock format - wrong # args (compiled ensemble with invalid sy
332332

333333
test clock-1.1 "clock format - bad time" {
334334
list [catch {clock format foo} msg opt] $msg [dict getd $opt -errorcode {}]
335-
} {1 {bad seconds "foo": must be -now or integer} {CLOCK badOption foo}}
335+
} {1 {bad seconds "foo": must be now or integer} {CLOCK badOption foo}}
336336

337337
test clock-1.2 "clock format - bad gmt val" {
338338
list [catch {clock format 0 -gmt foo} msg] $msg
@@ -367,10 +367,10 @@ test clock-1.7.1 "clock format - command abbreviations (compat regression test)"
367367
clock f 0 -g 1 -f "%Y-%m-%d"
368368
} 1970-01-01
369369

370-
test clock-1.8 "clock format -now" {
370+
test clock-1.8 "clock format now" {
371371
# give one second more for test (if on boundary of the current second):
372372
set n [clock format [clock seconds] -g 1 -f "%s"]
373-
expr {[clock format -now -g 1 -f "%s"] in [list $n [incr n]]}
373+
expr {[clock format now -g 1 -f "%s"] in [list $n [incr n]]}
374374
} 1
375375

376376
test clock-1.9 "clock arguments: option doubly present" {
@@ -18704,7 +18704,7 @@ test clock-6.8 {input of seconds} {
1870418704

1870518705
test clock-6.8b "clock scan - bad base" {
1870618706
list [catch {clock scan "" -base foo -gmt 1} msg opt] $msg [dict getd $opt -errorcode {}]
18707-
} {1 {bad seconds "foo": must be -now or integer} {CLOCK badOption foo}}
18707+
} {1 {bad seconds "foo": must be now or integer} {CLOCK badOption foo}}
1870818708

1870918709
test clock-6.9 {input of seconds - overflow} {
1871018710
list [catch {clock scan -9223372036854775809 -format %s -gmt true} result opt] $result [dict getd $opt -errorcode ""]

tests/cmdAH.test

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ testConstraint filetime64bit [expr {
3232
# check whether disk may have 2038 problem, see [fd91b0ca09cb171f]:
3333
set fn [makeFile "" foo.text]
3434
if {[catch {
35-
exec sh -c "TZ=:UTC LC_TYME=en_US touch -ma -t '207006290000' '$fn' && TZ=:UTC LC_TYME=en_US ls -l '$fn'"
35+
exec sh -c "TZ=:UTC LC_TIME=en_US touch -ma -t '207006290000' '$fn' && TZ=:UTC LC_TIME=en_US ls -l '$fn'"
3636
} res]} {
3737
#puts "Check constraint failed:\t$res"
3838
set res {}

0 commit comments

Comments
 (0)