diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2022-02-02 13:24:44 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2022-02-02 13:24:44 (GMT) |
commit | 560a6d1d1e9ba0bb6a7232c74703ea1b0e089fdc (patch) | |
tree | 33027d2c711f70073dbf6b5b0d6bdf083375a84b /generic/tkConfig.c | |
parent | b2dadc9cca46b6371ef584274bce66af634a89fb (diff) | |
download | tk-560a6d1d1e9ba0bb6a7232c74703ea1b0e089fdc.zip tk-560a6d1d1e9ba0bb6a7232c74703ea1b0e089fdc.tar.gz tk-560a6d1d1e9ba0bb6a7232c74703ea1b0e089fdc.tar.bz2 |
More adaptations (use NaN/INT_MIN as internal representation)
Diffstat (limited to 'generic/tkConfig.c')
-rw-r--r-- | generic/tkConfig.c | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/generic/tkConfig.c b/generic/tkConfig.c index 6c3575f..ed81eaf 100644 --- a/generic/tkConfig.c +++ b/generic/tkConfig.c @@ -635,7 +635,7 @@ DoObjConfig( if (nullOK && ObjectIsEmpty(valuePtr)) { valuePtr = NULL; - newInt = 0; + newInt = INT_MIN; } else if (Tcl_GetIntFromObj(nullOK ? NULL : interp, valuePtr, &newInt) != TCL_OK) { if (nullOK && interp) { Tcl_Obj *msg = Tcl_NewStringObj("expected integer or \"\" but got \"", -1); @@ -679,7 +679,13 @@ DoObjConfig( if (nullOK && ObjectIsEmpty(valuePtr)) { valuePtr = NULL; - newDbl = 0; +#if (TCL_MAJOR_VERSION > 8 || defined(TK_NO_DEPRECATED)) && defined(NAN) + if (optionPtr->specPtr->flags & TK_OPTION_NULL_OK) { + newDbl = NAN; + } else +#else + newDbl = 0.0; +#endif } else { if (Tcl_GetDoubleFromObj(nullOK ? NULL : interp, valuePtr, &newDbl) != TCL_OK) { if (nullOK && interp) { @@ -902,7 +908,7 @@ DoObjConfig( if (nullOK && ObjectIsEmpty(valuePtr)) { valuePtr = NULL; - newPixels = 0; + newPixels = INT_MIN; } else if (Tk_GetPixelsFromObj(interp, tkwin, valuePtr, &newPixels) != TCL_OK) { return TCL_ERROR; @@ -1927,12 +1933,14 @@ GetObjectForOption( internalPtr = (char *)recordPtr + optionPtr->specPtr->internalOffset; switch (optionPtr->specPtr->type) { case TK_OPTION_BOOLEAN: - if (*((int *) internalPtr) < 0) { - break; + if (*((int *) internalPtr) != -1) { + objPtr = Tcl_NewBooleanObj(*((int *)internalPtr)); } - /* FALLTHRU */ + break; case TK_OPTION_INT: - objPtr = Tcl_NewWideIntObj(*((int *)internalPtr)); + if (!(optionPtr->specPtr->flags & TK_OPTION_NULL_OK) && *((int *) internalPtr) != INT_MIN) { + objPtr = Tcl_NewWideIntObj(*((int *)internalPtr)); + } break; case TK_OPTION_INDEX: if (*((int *) internalPtr) == INT_MIN) { @@ -1950,7 +1958,9 @@ GetObjectForOption( } break; case TK_OPTION_DOUBLE: - objPtr = Tcl_NewDoubleObj(*((double *) internalPtr)); + if (!(optionPtr->specPtr->flags & TK_OPTION_NULL_OK) && !TkIsNaN(*((double *) internalPtr))) { + objPtr = Tcl_NewDoubleObj(*((double *) internalPtr)); + } break; case TK_OPTION_STRING: objPtr = Tcl_NewStringObj(*((char **)internalPtr), -1); @@ -2023,7 +2033,9 @@ GetObjectForOption( *((Tk_Anchor *)internalPtr)), -1); break; case TK_OPTION_PIXELS: - objPtr = Tcl_NewWideIntObj(*((int *)internalPtr)); + if (!(optionPtr->specPtr->flags & TK_OPTION_NULL_OK) && *((int *) internalPtr) != INT_MIN) { + objPtr = Tcl_NewWideIntObj(*((int *)internalPtr)); + } break; case TK_OPTION_WINDOW: { tkwin = *((Tk_Window *) internalPtr); |