| 553 | |
| 554 | |
| 555 | int64 atoilw(const wchar *s) |
| 556 | { |
| 557 | bool sign=false; |
| 558 | if (*s=='-') // We do use signed integers here, for example, in GUI SFX. |
| 559 | { |
| 560 | s++; |
| 561 | sign=true; |
| 562 | } |
| 563 | // Use unsigned type here, since long string can overflow the variable |
| 564 | // and signed integer overflow is undefined behavior in C++. |
| 565 | uint64 n=0; |
| 566 | while (*s>='0' && *s<='9') |
| 567 | { |
| 568 | n=n*10+(*s-'0'); |
| 569 | s++; |
| 570 | } |
| 571 | // Check int64(n)>=0 to avoid the signed overflow with undefined behavior |
| 572 | // when negating 0x8000000000000000. |
| 573 | return sign && int64(n)>=0 ? -int64(n) : int64(n); |
| 574 | } |
| 575 | |
| 576 | |
| 577 | #ifdef DBCS_SUPPORTED |
no outgoing calls
no test coverage detected