From 436a198c367c22b34f711d3d81d49cc7cbf6ef57 Mon Sep 17 00:00:00 2001 From: Tomasz Sowa Date: Fri, 25 May 2018 17:22:12 +0000 Subject: [PATCH] changed: using PT::ToLower instead of ToSmall using PT::ToUpper instead of ToCapital using PT::EqualNoCase instead of EqualNoCase git-svn-id: svn://ttmath.org/publicrep/winix/trunk@1112 e52654a7-88a9-db11-a3e9-0013d4bc506e --- winixd/core/app.cpp | 15 ++++---- winixd/core/misc.cpp | 82 +++++++++++++------------------------------- winixd/core/misc.h | 34 +----------------- 3 files changed, 32 insertions(+), 99 deletions(-) diff --git a/winixd/core/app.cpp b/winixd/core/app.cpp index 6143740..a333cf4 100644 --- a/winixd/core/app.cpp +++ b/winixd/core/app.cpp @@ -49,6 +49,7 @@ #include "misc.h" #include "functions/functions.h" #include "utf8/utf8.h" +#include "convert/convert.h" namespace Winix @@ -836,7 +837,7 @@ bool App::SaveEnvHTTPVariable(const char * env) for( ; env[i] != 0 && env[i] != '=' && i < Request::INPUT_HEADER_NAME_MAX_LENGTH ; ++i) { - header_name[i] = ToSmall(env[i]); + header_name[i] = PT::ToLower(env[i]); } header_name[i] = 0; @@ -883,7 +884,7 @@ void App::ReadEnvRemoteIP() { http_header = L"HTTP_"; http_header += config.proxy_ip_header; - ToCapital(http_header); + PT::ToUpper(http_header); PT::WideToUTF8(http_header, http_header_8bit); v = FCGX_GetParam(http_header_8bit.c_str(), fcgi_request.envp); @@ -909,16 +910,16 @@ void App::CheckRequestMethod() if( !cur.request->env_request_method.empty() ) { - if( ToSmall(cur.request->env_request_method[0]) == 'g' ) + if( PT::ToLower(cur.request->env_request_method[0]) == 'g' ) cur.request->method = Request::get; else - if( ToSmall(cur.request->env_request_method[0]) == 'p' ) + if( PT::ToLower(cur.request->env_request_method[0]) == 'p' ) cur.request->method = Request::post; else - if( ToSmall(cur.request->env_request_method[0]) == 'h' ) + if( PT::ToLower(cur.request->env_request_method[0]) == 'h' ) cur.request->method = Request::head; else - if( ToSmall(cur.request->env_request_method[0]) == 'd' ) + if( PT::ToLower(cur.request->env_request_method[0]) == 'd' ) cur.request->method = Request::delete_; } } @@ -934,7 +935,7 @@ void App::CheckSSL() if( config.assume_connection_is_through_ssl ) cur.request->using_ssl = true; else - if( EqualNoCase(cur.request->env_https.c_str(), L"on") ) + if( PT::EqualNoCase(cur.request->env_https.c_str(), L"on") ) cur.request->using_ssl = true; } diff --git a/winixd/core/misc.cpp b/winixd/core/misc.cpp index e9960cf..0de518a 100644 --- a/winixd/core/misc.cpp +++ b/winixd/core/misc.cpp @@ -40,6 +40,7 @@ #include "misc.h" #include "log.h" #include "templates/templates.h" +#include "convert/convert.h" namespace Winix @@ -331,7 +332,7 @@ void CorrectUrlOnlyAllowedChar(std::wstring & url) { CorrectUrlDots(url); CorrectUrlChars(url); - ToSmall(url); + PT::ToLower(url); Trim(url, '_'); if( url.empty() || url == L"." ) @@ -788,43 +789,6 @@ void Overwrite(std::wstring & str) -wchar_t ToSmall(wchar_t c) -{ - if( c>='A' && c<='Z' ) - c = c - 'A' + 'a'; - -return c; -} - - -void ToSmall(std::wstring & s) -{ -std::wstring::size_type i; - - for(i=0 ; i='a' && c<='z' ) - c = c - 'a' + 'A'; - -return c; -} - - -void ToCapital(std::wstring & s) -{ -std::wstring::size_type i; - - for(i=0 ; i bool IsSubStringp(const StringType1 * short_str, const StringType2 * long_str) @@ -420,7 +412,7 @@ bool IsSubString(const StringType1 & short_str, const StringType2 & long_str) template bool IsSubStringNoCasep(const StringType1 * short_str, const StringType2 * long_str) { - while( *short_str && *long_str && ToSmall(*short_str) == ToSmall(*long_str) ) + while( *short_str && *long_str && PT::ToLower(*short_str) == PT::ToLower(*long_str) ) { ++short_str; ++long_str; @@ -471,30 +463,6 @@ bool Equal(const StringType1 & str1, const StringType2 & str2) -template -bool EqualNoCase(const StringType1 * str1, const StringType2 * str2) -{ - while( *str1 && *str2 && ToSmall(*str1) == ToSmall(*str2) ) - { - ++str1; - ++str2; - } - - if( *str1 == 0 && *str2 == 0 ) - return true; - -return false; -} - - -template -bool EqualNoCase(const StringType1 & str1, const StringType2 & str2) -{ - return EqualNoCase(str1.c_str(), str2.c_str()); -} - - - /* looking for 'look_for' string in 'buf' and replacing it with 'replace' 'replace' can be empty (so only 'look_for' will be deleted)