From 9363d94f9b07eb4ffb9addfe80114dfd4247c1d9 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 5 Jan 2004 22:39:46 +0000 Subject: new files for the large file support number parsing --- lib/strtoofft.c | 153 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 153 insertions(+) create mode 100644 lib/strtoofft.c (limited to 'lib/strtoofft.c') diff --git a/lib/strtoofft.c b/lib/strtoofft.c new file mode 100644 index 000000000..a8e6fa160 --- /dev/null +++ b/lib/strtoofft.c @@ -0,0 +1,153 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2003, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id$ + ***************************************************************************/ + +#include "setup.h" +#include "strtoofft.h" + +#ifdef NEED_CURL_STRTOLL +#include +#include +#include + +static int get_char(char c, int base); + +/** + * Emulated version of the strtoll function. This extracts a long long + * value from the given input string and returns it. + */ +long long +Curl_strtoll(const char *nptr, char **endptr, int base) +{ + char *end; + int is_negative = 0; + int overflow; + int i; + long long value = 0; + long long newval; + + /* Skip leading whitespace. */ + end = (char *)nptr; + while (isspace((int)end[0])) { + end++; + } + + /* Handle the sign, if any. */ + if (end[0] == '-') { + is_negative = 1; + end++; + } else if (end[0] == '+') { + end++; + } else if (end[0] == '\0') { + /* We had nothing but perhaps some whitespace -- there was no number. */ + if (endptr) { + *endptr = end; + } + return 0; + } + + /* Handle special beginnings, if present and allowed. */ + if (end[0] == '0' && end[1] == 'x') { + if (base == 16 || base == 0) { + end += 2; + base = 16; + } + } else if (end[0] == '0') { + if (base == 8 || base == 0) { + end++; + base = 8; + } + } + + /* Matching strtol, if the base is 0 and it doesn't look like + * the number is octal or hex, we assume it's base 10. + */ + if (base == 0) { + base = 10; + } + + /* Loop handling digits. */ + value = 0; + overflow = 0; + for (i = get_char(end[0], base); + i != -1; + end++, i = get_char(end[0], base)) + { + newval = base * value + i; + if (newval < value) { + /* We've overflowed. */ + overflow = 1; + break; + } else { + value = newval; + } + } + + if (!overflow) { + if (is_negative) { + /* Fix the sign. */ + value *= -1; + } + } else { + if (is_negative) { + value = 0x8000000000000000L; + } else { + value = 0x7FFFFFFFFFFFFFFFL; + } + + errno = ERANGE; + } + + if (endptr) { + *endptr = end; + } + + return value; +} + +/** + * Returns the value of c in the given base, or -1 if c cannot + * be interpreted properly in that base (i.e., is out of range, + * is a null, etc.). + * + * @param c the character to interpret according to base + * @param base the base in which to interpret c + * + * @return the value of c in base, or -1 if c isn't in range + */ +static int get_char(char c, int base) { + int value = -1; + if (c <= '9' && c >= '0') { + value = c - '0'; + } else if (c <= 'Z' && c >= 'A') { + value = c - 'A' + 10; + } else if (c <= 'z' && c >= 'a') { + value = c - 'a' + 10; + } + + if (value >= base) { + value = -1; + } + + return value; +} +#endif /* Only present if we need strtoll, but don't have it. */ -- cgit v1.2.1 From 053f6c85efd0bf698f73343989474d672d0563a8 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 7 Jan 2004 09:19:33 +0000 Subject: updated year in the copyright string --- lib/strtoofft.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/strtoofft.c') diff --git a/lib/strtoofft.c b/lib/strtoofft.c index a8e6fa160..7b1a55e30 100644 --- a/lib/strtoofft.c +++ b/lib/strtoofft.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2003, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms -- cgit v1.2.1 From ad7e26b1401238d50b8bc7e98b6cf7660f03d4e6 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 22 Jan 2004 14:31:46 +0000 Subject: return curl_off_t instead of long long, to work on more platforms --- lib/strtoofft.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/strtoofft.c') diff --git a/lib/strtoofft.c b/lib/strtoofft.c index 7b1a55e30..322a753e3 100644 --- a/lib/strtoofft.c +++ b/lib/strtoofft.c @@ -35,15 +35,15 @@ static int get_char(char c, int base); * Emulated version of the strtoll function. This extracts a long long * value from the given input string and returns it. */ -long long +curl_off_t Curl_strtoll(const char *nptr, char **endptr, int base) { char *end; int is_negative = 0; int overflow; int i; - long long value = 0; - long long newval; + curl_off_t value = 0; + curl_off_t newval; /* Skip leading whitespace. */ end = (char *)nptr; -- cgit v1.2.1 From 3efb90dd755af19eda4b4004e3fadbd3a9c6b1e7 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 22 Jan 2004 14:37:06 +0000 Subject: re-intended the code curl-style --- lib/strtoofft.c | 56 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 26 deletions(-) (limited to 'lib/strtoofft.c') diff --git a/lib/strtoofft.c b/lib/strtoofft.c index 322a753e3..a6f1f01f3 100644 --- a/lib/strtoofft.c +++ b/lib/strtoofft.c @@ -55,9 +55,11 @@ Curl_strtoll(const char *nptr, char **endptr, int base) if (end[0] == '-') { is_negative = 1; end++; - } else if (end[0] == '+') { + } + else if (end[0] == '+') { end++; - } else if (end[0] == '\0') { + } + else if (end[0] == '\0') { /* We had nothing but perhaps some whitespace -- there was no number. */ if (endptr) { *endptr = end; @@ -71,7 +73,8 @@ Curl_strtoll(const char *nptr, char **endptr, int base) end += 2; base = 16; } - } else if (end[0] == '0') { + } + else if (end[0] == '0') { if (base == 8 || base == 0) { end++; base = 8; @@ -90,16 +93,15 @@ Curl_strtoll(const char *nptr, char **endptr, int base) overflow = 0; for (i = get_char(end[0], base); i != -1; - end++, i = get_char(end[0], base)) - { + end++, i = get_char(end[0], base)) { newval = base * value + i; if (newval < value) { /* We've overflowed. */ overflow = 1; break; - } else { - value = newval; } + else + value = newval; } if (!overflow) { @@ -107,19 +109,18 @@ Curl_strtoll(const char *nptr, char **endptr, int base) /* Fix the sign. */ value *= -1; } - } else { - if (is_negative) { + } + else { + if (is_negative) value = 0x8000000000000000L; - } else { + else value = 0x7FFFFFFFFFFFFFFFL; - } errno = ERANGE; } - if (endptr) { + if (endptr) *endptr = end; - } return value; } @@ -134,20 +135,23 @@ Curl_strtoll(const char *nptr, char **endptr, int base) * * @return the value of c in base, or -1 if c isn't in range */ -static int get_char(char c, int base) { - int value = -1; - if (c <= '9' && c >= '0') { - value = c - '0'; - } else if (c <= 'Z' && c >= 'A') { - value = c - 'A' + 10; - } else if (c <= 'z' && c >= 'a') { - value = c - 'a' + 10; - } +static int get_char(char c, int base) +{ + int value = -1; + if (c <= '9' && c >= '0') { + value = c - '0'; + } + else if (c <= 'Z' && c >= 'A') { + value = c - 'A' + 10; + } + else if (c <= 'z' && c >= 'a') { + value = c - 'a' + 10; + } - if (value >= base) { - value = -1; - } + if (value >= base) { + value = -1; + } - return value; + return value; } #endif /* Only present if we need strtoll, but don't have it. */ -- cgit v1.2.1 From 0bf1bd51c489e8316fe201bcbdaaab38c0d570c2 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 19 Feb 2004 08:12:13 +0000 Subject: Remade to use curlx_-prefix. This means this function can be compiled and linked separately by the application. This function is not provided by the libcurl API. It can only be accessed by apps if they compile and use this particular source code. --- lib/strtoofft.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/strtoofft.c') diff --git a/lib/strtoofft.c b/lib/strtoofft.c index a6f1f01f3..1bcfb1af4 100644 --- a/lib/strtoofft.c +++ b/lib/strtoofft.c @@ -36,7 +36,7 @@ static int get_char(char c, int base); * value from the given input string and returns it. */ curl_off_t -Curl_strtoll(const char *nptr, char **endptr, int base) +curlx_strtoll(const char *nptr, char **endptr, int base) { char *end; int is_negative = 0; -- cgit v1.2.1 From eb5d3b5a7c21501941cefe3a1d83deccdee7cd9c Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 8 Oct 2004 09:39:37 +0000 Subject: killed trailing whitespace --- lib/strtoofft.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lib/strtoofft.c') diff --git a/lib/strtoofft.c b/lib/strtoofft.c index 1bcfb1af4..f6abc20a0 100644 --- a/lib/strtoofft.c +++ b/lib/strtoofft.c @@ -1,8 +1,8 @@ /*************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. @@ -10,7 +10,7 @@ * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms * are also available at http://curl.haxx.se/docs/copyright.html. - * + * * You may opt to use, copy, modify, merge, publish, distribute and/or sell * copies of the Software, and permit persons to whom the Software is * furnished to do so, under the terms of the COPYING file. -- cgit v1.2.1 From 34750cc738214008a6098e554584c2d88677ed92 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sun, 10 Oct 2004 03:28:51 +0000 Subject: Use LL suffix for long long constants if the compiler supports it, to prevent warnings. --- lib/strtoofft.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/strtoofft.c') diff --git a/lib/strtoofft.c b/lib/strtoofft.c index f6abc20a0..391f80d24 100644 --- a/lib/strtoofft.c +++ b/lib/strtoofft.c @@ -112,9 +112,9 @@ curlx_strtoll(const char *nptr, char **endptr, int base) } else { if (is_negative) - value = 0x8000000000000000L; + value = CURL_LLONG_MIN; else - value = 0x7FFFFFFFFFFFFFFFL; + value = CURL_LLONG_MAX; errno = ERANGE; } -- cgit v1.2.1 From 6d14a8060887d2a54c0cee26b0c444a58ac1387c Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 11 Aug 2005 20:42:02 +0000 Subject: Added comment about strtoimax() --- lib/strtoofft.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib/strtoofft.c') diff --git a/lib/strtoofft.c b/lib/strtoofft.c index 391f80d24..a0aab9037 100644 --- a/lib/strtoofft.c +++ b/lib/strtoofft.c @@ -24,6 +24,14 @@ #include "setup.h" #include "strtoofft.h" +/* + * NOTE: + * + * In the ISO C standard (IEEE Std 1003.1), there is a strtoimax() function we + * could use in case strtoll() doesn't exist... See + * http://www.opengroup.org/onlinepubs/009695399/functions/strtoimax.html + */ + #ifdef NEED_CURL_STRTOLL #include #include -- cgit v1.2.1 From bda1e9aeab019d003036a3ec24193605bc191b3a Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 9 Jan 2006 13:17:14 +0000 Subject: Made the copyright year match the latest modification's year. --- lib/strtoofft.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/strtoofft.c') diff --git a/lib/strtoofft.c b/lib/strtoofft.c index a0aab9037..b11755b1b 100644 --- a/lib/strtoofft.c +++ b/lib/strtoofft.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2005, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms -- cgit v1.2.1 From 44d84ac1646cf04ccc2c1a736f3c9d1644ccacec Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 17 Oct 2006 21:32:56 +0000 Subject: Avoid typecasting a signed char to an int when using is*() functions, as that could very well cause a negate number get passed in and thus cause reading outside of the array usually used for this purpose. We avoid this by using the uppercase macro versions introduced just now that does some extra crazy typecasts to avoid byte codes > 127 to cause negative int values. --- lib/strtoofft.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/strtoofft.c') diff --git a/lib/strtoofft.c b/lib/strtoofft.c index b11755b1b..3ab1bfdff 100644 --- a/lib/strtoofft.c +++ b/lib/strtoofft.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2005, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2006, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -55,7 +55,7 @@ curlx_strtoll(const char *nptr, char **endptr, int base) /* Skip leading whitespace. */ end = (char *)nptr; - while (isspace((int)end[0])) { + while (ISSPACE(end[0])) { end++; } -- cgit v1.2.1 From a1d598399146984c99baa46db148e87c75261033 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 16 Feb 2007 18:19:35 +0000 Subject: use macros ERRNO, SET_ERRNO(), SOCKERRNO and SET_SOCKERRNO() for errno handling --- lib/strtoofft.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/strtoofft.c') diff --git a/lib/strtoofft.c b/lib/strtoofft.c index 3ab1bfdff..5314fa403 100644 --- a/lib/strtoofft.c +++ b/lib/strtoofft.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2006, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2007, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -124,7 +124,7 @@ curlx_strtoll(const char *nptr, char **endptr, int base) else value = CURL_LLONG_MAX; - errno = ERANGE; + SET_ERRNO(ERANGE); } if (endptr) -- cgit v1.2.1 From 1926f4573d43f35f33b524d120e847ea819cc7c7 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sat, 4 Aug 2007 20:47:59 +0000 Subject: Patrick Monnerat fixed curl_easy_escape() and curlx_strtoll() to work on non-ASCII systems. --- lib/strtoofft.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'lib/strtoofft.c') diff --git a/lib/strtoofft.c b/lib/strtoofft.c index 5314fa403..043ff4d9b 100644 --- a/lib/strtoofft.c +++ b/lib/strtoofft.c @@ -37,6 +37,18 @@ #include #include +/* Range tests can be used for alphanum decoding if characters are consecutive, + like in ASCII. Else an array is scanned. Determine this condition now. */ + +#if ('9' - '0') != 9 || ('Z' - 'A') != 25 || ('z' - 'a') != 25 +#include + +#define NO_RANGE_TEST + +static const char valchars[] = + "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; +#endif + static int get_char(char c, int base); /** @@ -145,6 +157,7 @@ curlx_strtoll(const char *nptr, char **endptr, int base) */ static int get_char(char c, int base) { +#ifndef NO_RANGE_TEST int value = -1; if (c <= '9' && c >= '0') { value = c - '0'; @@ -155,6 +168,20 @@ static int get_char(char c, int base) else if (c <= 'z' && c >= 'a') { value = c - 'a' + 10; } +#else + const char * cp; + int value; + + cp = memchr(valchars, c, 10 + 26 + 26); + + if (!cp) + return -1; + + value = cp - valchars; + + if (value >= 10 + 26) + value -= 26; /* Lowercase. */ +#endif if (value >= base) { value = -1; -- cgit v1.2.1 From ad6e28073c985a42e8b15d2234baa7ef67ffcb35 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 5 Nov 2007 09:45:09 +0000 Subject: removed space after if and while before the parenthesis for better source code consistency --- lib/strtoofft.c | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'lib/strtoofft.c') diff --git a/lib/strtoofft.c b/lib/strtoofft.c index 043ff4d9b..6cd9a3e26 100644 --- a/lib/strtoofft.c +++ b/lib/strtoofft.c @@ -40,7 +40,7 @@ /* Range tests can be used for alphanum decoding if characters are consecutive, like in ASCII. Else an array is scanned. Determine this condition now. */ -#if ('9' - '0') != 9 || ('Z' - 'A') != 25 || ('z' - 'a') != 25 +#if('9' - '0') != 9 || ('Z' - 'A') != 25 || ('z' - 'a') != 25 #include #define NO_RANGE_TEST @@ -67,35 +67,35 @@ curlx_strtoll(const char *nptr, char **endptr, int base) /* Skip leading whitespace. */ end = (char *)nptr; - while (ISSPACE(end[0])) { + while(ISSPACE(end[0])) { end++; } /* Handle the sign, if any. */ - if (end[0] == '-') { + if(end[0] == '-') { is_negative = 1; end++; } - else if (end[0] == '+') { + else if(end[0] == '+') { end++; } - else if (end[0] == '\0') { + else if(end[0] == '\0') { /* We had nothing but perhaps some whitespace -- there was no number. */ - if (endptr) { + if(endptr) { *endptr = end; } return 0; } /* Handle special beginnings, if present and allowed. */ - if (end[0] == '0' && end[1] == 'x') { - if (base == 16 || base == 0) { + if(end[0] == '0' && end[1] == 'x') { + if(base == 16 || base == 0) { end += 2; base = 16; } } - else if (end[0] == '0') { - if (base == 8 || base == 0) { + else if(end[0] == '0') { + if(base == 8 || base == 0) { end++; base = 8; } @@ -104,7 +104,7 @@ curlx_strtoll(const char *nptr, char **endptr, int base) /* Matching strtol, if the base is 0 and it doesn't look like * the number is octal or hex, we assume it's base 10. */ - if (base == 0) { + if(base == 0) { base = 10; } @@ -115,7 +115,7 @@ curlx_strtoll(const char *nptr, char **endptr, int base) i != -1; end++, i = get_char(end[0], base)) { newval = base * value + i; - if (newval < value) { + if(newval < value) { /* We've overflowed. */ overflow = 1; break; @@ -124,14 +124,14 @@ curlx_strtoll(const char *nptr, char **endptr, int base) value = newval; } - if (!overflow) { - if (is_negative) { + if(!overflow) { + if(is_negative) { /* Fix the sign. */ value *= -1; } } else { - if (is_negative) + if(is_negative) value = CURL_LLONG_MIN; else value = CURL_LLONG_MAX; @@ -139,7 +139,7 @@ curlx_strtoll(const char *nptr, char **endptr, int base) SET_ERRNO(ERANGE); } - if (endptr) + if(endptr) *endptr = end; return value; @@ -159,13 +159,13 @@ static int get_char(char c, int base) { #ifndef NO_RANGE_TEST int value = -1; - if (c <= '9' && c >= '0') { + if(c <= '9' && c >= '0') { value = c - '0'; } - else if (c <= 'Z' && c >= 'A') { + else if(c <= 'Z' && c >= 'A') { value = c - 'A' + 10; } - else if (c <= 'z' && c >= 'a') { + else if(c <= 'z' && c >= 'a') { value = c - 'a' + 10; } #else @@ -174,16 +174,16 @@ static int get_char(char c, int base) cp = memchr(valchars, c, 10 + 26 + 26); - if (!cp) + if(!cp) return -1; value = cp - valchars; - if (value >= 10 + 26) + if(value >= 10 + 26) value -= 26; /* Lowercase. */ #endif - if (value >= base) { + if(value >= base) { value = -1; } -- cgit v1.2.1 From 2309b4e330b96bc2e1f8e36b6184015e59544037 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 24 Mar 2010 11:02:54 +0100 Subject: remove the CVSish $Id$ lines --- lib/strtoofft.c | 1 - 1 file changed, 1 deletion(-) (limited to 'lib/strtoofft.c') diff --git a/lib/strtoofft.c b/lib/strtoofft.c index 6cd9a3e26..f75eb8a44 100644 --- a/lib/strtoofft.c +++ b/lib/strtoofft.c @@ -18,7 +18,6 @@ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY * KIND, either express or implied. * - * $Id$ ***************************************************************************/ #include "setup.h" -- cgit v1.2.1 From 20ae9d4f716cd898ca1aa47b7ea0664ebc57b2ba Mon Sep 17 00:00:00 2001 From: Kamil Dudka Date: Sat, 29 May 2010 21:28:16 +0200 Subject: strtoofft: rename CURL_LLONG_MIN -> CURL_OFF_T_MIN ... and CURL_LLONG_MAX -> CURL_OFF_T_MAX --- lib/strtoofft.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/strtoofft.c') diff --git a/lib/strtoofft.c b/lib/strtoofft.c index f75eb8a44..61ff05bed 100644 --- a/lib/strtoofft.c +++ b/lib/strtoofft.c @@ -131,9 +131,9 @@ curlx_strtoll(const char *nptr, char **endptr, int base) } else { if(is_negative) - value = CURL_LLONG_MIN; + value = CURL_OFF_T_MIN; else - value = CURL_LLONG_MAX; + value = CURL_OFF_T_MAX; SET_ERRNO(ERANGE); } -- cgit v1.2.1 From b903186fa0189ff241d756d25d07fdfe9885ae49 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 20 Apr 2011 15:17:42 +0200 Subject: source cleanup: unify look, style and indent levels By the use of a the new lib/checksrc.pl script that checks that our basic source style rules are followed. --- lib/strtoofft.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib/strtoofft.c') diff --git a/lib/strtoofft.c b/lib/strtoofft.c index 61ff05bed..55a6ffd0d 100644 --- a/lib/strtoofft.c +++ b/lib/strtoofft.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2007, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -110,9 +110,9 @@ curlx_strtoll(const char *nptr, char **endptr, int base) /* Loop handling digits. */ value = 0; overflow = 0; - for (i = get_char(end[0], base); - i != -1; - end++, i = get_char(end[0], base)) { + for(i = get_char(end[0], base); + i != -1; + end++, i = get_char(end[0], base)) { newval = base * value + i; if(newval < value) { /* We've overflowed. */ -- cgit v1.2.1 From ef2176109fca302ed89193716b62c3a7113552a3 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sun, 24 Jul 2011 04:39:43 +0200 Subject: errno.h inclusion conditionally done in setup_once.h --- lib/strtoofft.c | 1 - 1 file changed, 1 deletion(-) (limited to 'lib/strtoofft.c') diff --git a/lib/strtoofft.c b/lib/strtoofft.c index 55a6ffd0d..dd897cf16 100644 --- a/lib/strtoofft.c +++ b/lib/strtoofft.c @@ -34,7 +34,6 @@ #ifdef NEED_CURL_STRTOLL #include #include -#include /* Range tests can be used for alphanum decoding if characters are consecutive, like in ASCII. Else an array is scanned. Determine this condition now. */ -- cgit v1.2.1 From f1586cb4775681810afd8e6626e7842d459f3b85 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 26 Jul 2011 17:23:27 +0200 Subject: stdio.h, stdlib.h, string.h, stdarg.h and ctype.h inclusion done in setup_once.h --- lib/strtoofft.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'lib/strtoofft.c') diff --git a/lib/strtoofft.c b/lib/strtoofft.c index dd897cf16..c61459de8 100644 --- a/lib/strtoofft.c +++ b/lib/strtoofft.c @@ -21,6 +21,7 @@ ***************************************************************************/ #include "setup.h" + #include "strtoofft.h" /* @@ -32,14 +33,11 @@ */ #ifdef NEED_CURL_STRTOLL -#include -#include /* Range tests can be used for alphanum decoding if characters are consecutive, like in ASCII. Else an array is scanned. Determine this condition now. */ #if('9' - '0') != 9 || ('Z' - 'A') != 25 || ('z' - 'a') != 25 -#include #define NO_RANGE_TEST -- cgit v1.2.1