diff options
Diffstat (limited to 'generic/tclClock.c')
| -rw-r--r-- | generic/tclClock.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/generic/tclClock.c b/generic/tclClock.c index 20da59f..0b72bf4 100644 --- a/generic/tclClock.c +++ b/generic/tclClock.c @@ -3419,16 +3419,18 @@ ClockParseFmtScnArgs( if (opts->baseObj != NULL) { Tcl_Obj *baseObj = opts->baseObj; - /* bypass integer recognition if looks like option "-now" */ - if ((baseObj->bytes && baseObj->length == 4 && baseObj->bytes[1] == 'n') + /* bypass integer recognition if looks like "now" or "-now" */ + if ((baseObj->bytes && + ((baseObj->length == 3 && baseObj->bytes[0] == 'n') || + (baseObj->length == 4 && baseObj->bytes[1] == 'n'))) || TclGetWideIntFromObj(NULL, baseObj, &baseVal) != TCL_OK) { - /* we accept "-now" as current date-time */ + /* we accept "now" and "-now" as current date-time */ static const char *const nowOpts[] = { - "-now", NULL + "now", "-now", NULL }; int idx; - if (Tcl_GetIndexFromObj(interp, baseObj, nowOpts, "seconds", + if (Tcl_GetIndexFromObj(NULL, baseObj, nowOpts, "seconds", TCL_EXACT, &idx) == TCL_OK) { goto baseNow; } @@ -3437,7 +3439,9 @@ ClockParseFmtScnArgs( goto baseOverflow; } - Tcl_AppendResult(interp, " or integer", (char *)NULL); + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "bad seconds \"%s\": must be now or integer", + TclGetString(baseObj))); i = baseIdx; goto badOption; } @@ -3529,7 +3533,7 @@ ClockFormatObjCmd( Tcl_Obj *const objv[]) /* Parameter values */ { ClockClientData *dataPtr = (ClockClientData *)clientData; - static const char *syntax = "clock format clockval|-now " + static const char *syntax = "clock format clockval|now " "?-format string? " "?-gmt boolean? " "?-locale LOCALE? ?-timezone ZONE?"; @@ -4363,7 +4367,7 @@ ClockAddObjCmd( int objc, /* Parameter count */ Tcl_Obj *const objv[]) /* Parameter values */ { - static const char *syntax = "clock add clockval|-now ?number units?..." + static const char *syntax = "clock add clockval|now ?number units?..." "?-gmt boolean? " "?-locale LOCALE? ?-timezone ZONE?"; ClockClientData *dataPtr = (ClockClientData *)clientData; |
