| 16777 | //////////////////////////////////////////////////////// |
| 16778 | |
| 16779 | BOOL ResultToBOOL(LPTSTR aResult) |
| 16780 | { |
| 16781 | UINT c1 = (UINT)*aResult; // UINT vs. UCHAR might squeeze a little more performance out of it. |
| 16782 | if (c1 > 48) // Any UCHAR greater than '0' can't be a space(32), tab(9), '+'(43), or '-'(45), or '.'(46)... |
| 16783 | return TRUE; // ...so any string starting with c1>48 can't be anything that's false (e.g. " 0", "+0", "-0", ".0", "0"). |
| 16784 | if (!c1 // Besides performance, must be checked anyway because otherwise IsNumeric() would consider "" to be non-numeric and thus TRUE. |
| 16785 | || c1 == 48 && !aResult[1]) // The string "0" seems common enough to detect explicitly, for performance. |
| 16786 | return FALSE; |
| 16787 | // IsNumeric() is called below because there are many variants of a false string: |
| 16788 | // e.g. "0", "0.0", "0x0", ".0", "+0", "-0", and " 0" (leading spaces/tabs). |
| 16789 | switch (IsNumeric(aResult, true, false, true)) // It's purely numeric and not all whitespace (and due to earlier check, it's not blank). |
| 16790 | { |
| 16791 | case PURE_INTEGER: return ATOI64(aResult) != 0; // Could call ATOF() for both integers and floats; but ATOI64() probably performs better, and a float comparison to 0.0 might be a slower than an integer comparison to 0. |
| 16792 | case PURE_FLOAT: return _tstof(aResult) != 0.0; // atof() vs. ATOF() because PURE_FLOAT is never hexadecimal. |
| 16793 | default: // PURE_NOT_NUMERIC. |
| 16794 | // Even a string containing all whitespace would be considered non-numeric since it's a non-blank string |
| 16795 | // that isn't equal to 0. |
| 16796 | return TRUE; |
| 16797 | } |
| 16798 | } |
| 16799 | |
| 16800 | |
| 16801 |
no test coverage detected