cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: lib/strcase.c refactoring

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Tue, 1 Nov 2016 11:47:59 +0100

On Tue, Nov 01, 2016 at 12:01:46AM +0100, Daniel Stenberg wrote:
> On Mon, 31 Oct 2016, Dan Fandrich wrote:
>
> >Or, we could avoid this copying by adding these functions to a sort of informal
> >internal API, let's call it "curlx", and call them from there. Hey, wait a
> >minuteā€¦
>
> Long term I'd like to get away from the curlx ones completely (since they're
> so awkward to use and maintain), so maybe it is for the better that we
> slowly reduce our use of them.

There's another fallout from commit 95bd2b3e: tool_metalink.c is using
Curl_raw_toupper for which a public API replacement isn't available, so
no longer compiling strcase.c to fix the Windows link problem is causing
Metalink builds to fail.

Also, tool_cb_hdr.c is using checkprefix() which calls the internal
strncasecompare() function instead of the public curl_strnequal(). This patch
fixes it, but at the cost of a redundant wrapper call to curl_strnequal
everywhere it's used internally. That itself could be worked around with an
#ifdef BUILDING_LIBCURL but we're falling down the rabbit hole now.

diff --git a/lib/strcase.h b/lib/strcase.h
index 932d793..bf057b1 100644
--- a/lib/strcase.h
+++ b/lib/strcase.h
@@ -42,7 +42,7 @@ char Curl_raw_toupper(char in);
 
 /* checkprefix() is a shorter version of the above, used when the first
    argument is zero-byte terminated */
-#define checkprefix(a,b) strncasecompare(a,b,strlen(a))
+#define checkprefix(a,b) curl_strnequal(a,b,strlen(a))
 
 void Curl_strntoupper(char *dest, const char *src, size_t n);
 char Curl_raw_toupper(char in);

I've committed this in the interests of getting the builds working again, but
it would be nice to avoid the extra overhead.

>>> Dan
-------------------------------------------------------------------
List admin: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2016-11-01