diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2017-01-31 13:27:28 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2017-01-31 13:27:28 (GMT) |
commit | 4a6021fe4842ba393545d968beed09fa19745a22 (patch) | |
tree | 5ce71463c7228e4d0c14a757255d6ae02d632a60 /generic/tclLink.c | |
parent | 1c6496c269fc6be350eae56e9b2351ce6e7e6dac (diff) | |
parent | a5fff7a94743517ada1b332a259ccfa63bb89570 (diff) | |
download | tcl-4a6021fe4842ba393545d968beed09fa19745a22.zip tcl-4a6021fe4842ba393545d968beed09fa19745a22.tar.gz tcl-4a6021fe4842ba393545d968beed09fa19745a22.tar.bz2 |
Update documentation on recent changes in Tcl_LinkVar.
Minor code clean-up. No functional changes.
Diffstat (limited to 'generic/tclLink.c')
-rw-r--r-- | generic/tclLink.c | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/generic/tclLink.c b/generic/tclLink.c index 46471f5..88c98df 100644 --- a/generic/tclLink.c +++ b/generic/tclLink.c @@ -710,7 +710,7 @@ SetInvalidRealFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr) { /* * This function checks for integer representations, which are valid * when linking with C variables, but which are invalid in other - * contexts in Tcl. Handled are "", "+", "-", "0x", "0b" and "0o" + * contexts in Tcl. Handled are "+", "-", "", "0x", "0b" and "0o" * (upperand lowercase). See bug [39f6304c2e]. */ int @@ -718,13 +718,13 @@ GetInvalidIntFromObj(Tcl_Obj *objPtr, int *intPtr) { const char *str = TclGetString(objPtr); - if ((objPtr->length == 1) && strchr("+-", str[0])) { - *intPtr = (str[0] == '+'); - return TCL_OK; - } else if ((objPtr->length == 0) || + if ((objPtr->length == 0) || ((objPtr->length == 2) && (str[0] == '0') && strchr("xXbBoO", str[1]))) { *intPtr = 0; return TCL_OK; + } else if ((objPtr->length == 1) && strchr("+-", str[0])) { + *intPtr = (str[0] == '+'); + return TCL_OK; } return TCL_ERROR; } @@ -732,25 +732,28 @@ GetInvalidIntFromObj(Tcl_Obj *objPtr, int *intPtr) /* * This function checks for double representations, which are valid * when linking with C variables, but which are invalid in other - * contexts in Tcl. Handled are ".", "+", "-", "0x", "0b" and "0o" + * contexts in Tcl. Handled are "+", "-", "", ".", "0x", "0b" and "0o" * (upper- and lowercase) and sequences like "1e-". See bug [39f6304c2e]. */ int GetInvalidDoubleFromObj(Tcl_Obj *objPtr, double *doublePtr) { - int intValue, result; + int intValue; - if ((objPtr->typePtr == &invalidRealType) || - (SetInvalidRealFromAny(NULL, objPtr) == TCL_OK)) { - *doublePtr = objPtr->internalRep.doubleValue; - return TCL_OK; + if (objPtr->typePtr == &invalidRealType) { + goto gotdouble; } - result = GetInvalidIntFromObj(objPtr, &intValue); - if (result == TCL_OK) { + if (GetInvalidIntFromObj(objPtr, &intValue) == TCL_OK) { *doublePtr = (double) intValue; + return TCL_OK; } - return result; + if (SetInvalidRealFromAny(NULL, objPtr) == TCL_OK) { + gotdouble: + *doublePtr = objPtr->internalRep.doubleValue; + return TCL_OK; + } + return TCL_ERROR; } /* |