diff options
Diffstat (limited to 'xdelta3/xdelta3-main.h')
-rw-r--r-- | xdelta3/xdelta3-main.h | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/xdelta3/xdelta3-main.h b/xdelta3/xdelta3-main.h index 63ca51f..157a4fb 100644 --- a/xdelta3/xdelta3-main.h +++ b/xdelta3/xdelta3-main.h | |||
@@ -49,6 +49,8 @@ | |||
49 | 49 | ||
50 | /*********************************************************************/ | 50 | /*********************************************************************/ |
51 | 51 | ||
52 | #include <limits.h> | ||
53 | |||
52 | #ifndef XD3_POSIX | 54 | #ifndef XD3_POSIX |
53 | #define XD3_POSIX 0 | 55 | #define XD3_POSIX 0 |
54 | #endif | 56 | #endif |
@@ -669,14 +671,17 @@ main_strtoxoff (const char* s, xoff_t *xo, char which) | |||
669 | XD3_ASSERT(s && *s != 0); | 671 | XD3_ASSERT(s && *s != 0); |
670 | 672 | ||
671 | { | 673 | { |
672 | /* Should check LONG_MIN, LONG_MAX, LLONG_MIN, LLONG_MAX? */ | 674 | #if SIZEOF_XOFF_T == SIZEOF_LONG_LONG |
673 | #if SIZEOF_XOFF_T == 4 | 675 | unsigned long long xx = strtoull (s, &e, 0); |
674 | long xx = strtol (s, &e, 0); | 676 | unsigned long long bad = ULLONG_MAX; |
677 | #elif SIZEOF_XOFF_T <= SIZEOF_LONG | ||
678 | unsigned long xx = strtoul (s, &e, 0); | ||
679 | unsigned long long bad = ULONG_MAX; | ||
675 | #else | 680 | #else |
676 | long long xx = strtoll (s, &e, 0); | 681 | /* Something wrong with SIZEOF_XOFF_T, SIZEOF_LONG, etc. */ |
677 | #endif | 682 | #endif |
678 | 683 | ||
679 | if (xx < 0) | 684 | if (xx == bad) |
680 | { | 685 | { |
681 | XPR(NT "-%c: negative integer: %s\n", which, s); | 686 | XPR(NT "-%c: negative integer: %s\n", which, s); |
682 | return EXIT_FAILURE; | 687 | return EXIT_FAILURE; |
@@ -703,7 +708,7 @@ main_atoux (const char* arg, xoff_t *xo, xoff_t low, | |||
703 | int ret; | 708 | int ret; |
704 | 709 | ||
705 | if ((ret = main_strtoxoff (arg, & x, which))) { return ret; } | 710 | if ((ret = main_strtoxoff (arg, & x, which))) { return ret; } |
706 | 711 | XPR(NT "SEE -%c: value %"Q" low %"Q" high %"Q"\n", which, x, low, high); | |
707 | if (x < low) | 712 | if (x < low) |
708 | { | 713 | { |
709 | XPR(NT "-%c: minimum value: %"Q"\n", which, low); | 714 | XPR(NT "-%c: minimum value: %"Q"\n", which, low); |