diff options
author | Daniel Stenberg <daniel@haxx.se> | 2011-04-20 00:48:20 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2011-04-20 00:50:07 +0200 |
commit | c828646f60b5bffb2bfcf924eba36da767bf08bf (patch) | |
tree | a13db5750b3927a2dea67364fbafba4b91fa7e9f /lib/escape.c | |
parent | eb65a49befa040746b222e693bba19ee56814e85 (diff) | |
download | curl-c828646f60b5bffb2bfcf924eba36da767bf08bf.tar.gz |
CURL_DOES_CONVERSIONS: cleanup
Massively reduce #ifdefs all over (23 #ifdef lines less so far)
Moved conversion-specific code to non-ascii.c
Diffstat (limited to 'lib/escape.c')
-rw-r--r-- | lib/escape.c | 27 |
1 files changed, 5 insertions, 22 deletions
diff --git a/lib/escape.c b/lib/escape.c index 735e1d8a7..4e8dd6e4c 100644 --- a/lib/escape.c +++ b/lib/escape.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -31,10 +31,9 @@ #include <stdlib.h> #include <string.h> #include "curl_memory.h" -/* urldata.h and easyif.h are included for Curl_convert_... prototypes */ #include "urldata.h" -#include "easyif.h" #include "warnless.h" +#include "non-ascii.h" #define _MPRINTF_REPLACE /* use our functions only */ #include <curl/mprintf.h> @@ -91,10 +90,6 @@ char *curl_easy_escape(CURL *handle, const char *string, int inlength) int strindex=0; size_t length; -#ifndef CURL_DOES_CONVERSIONS - /* avoid compiler warnings */ - (void)handle; -#endif ns = malloc(alloc); if(!ns) return NULL; @@ -122,15 +117,11 @@ char *curl_easy_escape(CURL *handle, const char *string, int inlength) } } -#ifdef CURL_DOES_CONVERSIONS -/* escape sequences are always in ASCII so convert them on non-ASCII hosts */ - if(!handle || - (Curl_convert_to_network(handle, &in, 1) != CURLE_OK)) { + if(Curl_convert_to_network(handle, &in, 1)) { /* Curl_convert_to_network calls failf if unsuccessful */ free(ns); return NULL; } -#endif /* CURL_DOES_CONVERSIONS */ snprintf(&ns[strindex], 4, "%%%02X", in); @@ -157,11 +148,7 @@ char *curl_easy_unescape(CURL *handle, const char *string, int length, int strindex=0; unsigned long hex; -#ifndef CURL_DOES_CONVERSIONS - /* avoid compiler warnings */ - (void)handle; -#endif - if( !ns ) + if(!ns) return NULL; while(--alloc > 0) { @@ -178,15 +165,11 @@ char *curl_easy_unescape(CURL *handle, const char *string, int length, in = curlx_ultouc(hex); /* this long is never bigger than 255 anyway */ -#ifdef CURL_DOES_CONVERSIONS -/* escape sequences are always in ASCII so convert them on non-ASCII hosts */ - if(!handle || - (Curl_convert_from_network(handle, &in, 1) != CURLE_OK)) { + if(Curl_convert_from_network(handle, &in, 1)) { /* Curl_convert_from_network calls failf if unsuccessful */ free(ns); return NULL; } -#endif /* CURL_DOES_CONVERSIONS */ string+=2; alloc-=2; |