| 17012 | |
| 17013 | |
| 17014 | ResultType TokenToDoubleOrInt64(const ExprTokenType &aInput, ExprTokenType &aOutput) |
| 17015 | // Converts aToken's contents to a numeric value, either int64 or double (whichever is more appropriate). |
| 17016 | // Returns FAIL when aToken isn't an operand or is but contains a string that isn't purely numeric. |
| 17017 | { |
| 17018 | LPTSTR str; |
| 17019 | switch (aInput.symbol) |
| 17020 | { |
| 17021 | case SYM_INTEGER: |
| 17022 | case SYM_FLOAT: |
| 17023 | aOutput.symbol = aInput.symbol; |
| 17024 | aOutput.value_int64 = aInput.value_int64; |
| 17025 | return OK; |
| 17026 | case SYM_VAR: |
| 17027 | return aInput.var->ToDoubleOrInt64(aOutput); |
| 17028 | case SYM_STRING: // v1.0.40.06: Fixed to be listed explicitly so that "default" case can return failure. |
| 17029 | str = aInput.marker; |
| 17030 | break; |
| 17031 | //case SYM_OBJECT: // L31: Treat objects as empty strings (or TRUE where appropriate). |
| 17032 | //case SYM_MISSING: |
| 17033 | default: |
| 17034 | return FAIL; |
| 17035 | } |
| 17036 | // Since above didn't return, interpret "str" as a number. |
| 17037 | switch (aOutput.symbol = IsNumeric(str, true, false, true)) |
| 17038 | { |
| 17039 | case PURE_INTEGER: |
| 17040 | aOutput.value_int64 = ATOI64(str); |
| 17041 | break; |
| 17042 | case PURE_FLOAT: |
| 17043 | aOutput.value_double = ATOF(str); |
| 17044 | break; |
| 17045 | default: // Not a pure number. |
| 17046 | return FAIL; |
| 17047 | } |
| 17048 | return OK; // Since above didn't return, indicate success. |
| 17049 | } |
| 17050 | |
| 17051 | |
| 17052 |
no test coverage detected