From dec805ebf7d0ce3fb32780ef83a06d1bb2881407 Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Thu, 15 Apr 2010 13:31:08 +0000 Subject: [PATCH] avoid usage of non C99 function [r27406] --- lexer.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lexer.c b/lexer.c index 111bc6d..15c12a0 100644 --- a/lexer.c +++ b/lexer.c @@ -333,10 +333,20 @@ static named_decoder_t const decoders[] = { { NULL, NULL } }; +/** strcasecmp is not part of C99 so we need our own implementation here */ +static int my_strcasecmp(const char *s1, const char *s2) +{ + for ( ; *s1 != 0; ++s1, ++s2) { + if (tolower(*s1) != tolower(*s2)) + break; + } + return (unsigned char)*s1 - (unsigned char)*s2; +} + void select_input_encoding(char const* const encoding) { for (named_decoder_t const *i = decoders; i->name != NULL; ++i) { - if (strcasecmp(encoding, i->name) != 0) + if (my_strcasecmp(encoding, i->name) != 0) continue; decoder = i->decoder; return; -- 2.20.1