diff options
author | Adrián Medraño Calvo <adrian@medranocalvo.com> | 2017-08-01 07:28:24 (GMT) |
---|---|---|
committer | Adrián Medraño Calvo <adrian@medranocalvo.com> | 2017-08-01 07:28:24 (GMT) |
commit | 95101fc9f957cb4c3eee8b56b455e8b1f883e014 (patch) | |
tree | 4f86c7382696f23c312c49024813e2fd54d10ca7 /generic/tkbltVecCmd.C | |
parent | e4521220d9623f9e00ff1a5f1497665c956b1387 (diff) | |
download | blt-95101fc9f957cb4c3eee8b56b455e8b1f883e014.zip blt-95101fc9f957cb4c3eee8b56b455e8b1f883e014.tar.gz blt-95101fc9f957cb4c3eee8b56b455e8b1f883e014.tar.bz2 |
Interpret empty strings as NaN
Diffstat (limited to 'generic/tkbltVecCmd.C')
-rw-r--r-- | generic/tkbltVecCmd.C | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/generic/tkbltVecCmd.C b/generic/tkbltVecCmd.C index d42dcda..feaddab 100644 --- a/generic/tkbltVecCmd.C +++ b/generic/tkbltVecCmd.C @@ -161,8 +161,17 @@ static int Blt_ExprDoubleFromObj(Tcl_Interp* interp, Tcl_Obj *objPtr, if (Tcl_GetDoubleFromObj((Tcl_Interp *)NULL, objPtr, valuePtr) == TCL_OK) return TCL_OK; + // Interpret the empty string as NaN + int length; + char *string; + string = Tcl_GetStringFromObj(objPtr, &length); + if (length == 0) { + *valuePtr = NAN; + return TCL_OK; + } + // Then try to parse it as an expression. - if (Tcl_ExprDouble(interp, Tcl_GetString(objPtr), valuePtr) == TCL_OK) + if (Tcl_ExprDouble(interp, string, valuePtr) == TCL_OK) return TCL_OK; return TCL_ERROR; |