1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/xpcom/string/src/nsStringComparator.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,37 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim:set ts=2 sw=2 sts=2 et cindent: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#include <ctype.h> 1.11 +#include "nsAString.h" 1.12 +#include "plstr.h" 1.13 + 1.14 + 1.15 + // define nsStringComparator 1.16 +#include "string-template-def-unichar.h" 1.17 +#include "nsTStringComparator.cpp" 1.18 +#include "string-template-undef.h" 1.19 + 1.20 + // define nsCStringComparator 1.21 +#include "string-template-def-char.h" 1.22 +#include "nsTStringComparator.cpp" 1.23 +#include "string-template-undef.h" 1.24 + 1.25 + 1.26 +int 1.27 +nsCaseInsensitiveCStringComparator::operator()( const char_type* lhs, 1.28 + const char_type* rhs, 1.29 + uint32_t lLength, 1.30 + uint32_t rLength ) const 1.31 + { 1.32 + if (lLength != rLength) 1.33 + return (lLength > rLength) ? 1 : -1; 1.34 + int32_t result=int32_t(PL_strncasecmp(lhs, rhs, lLength)); 1.35 + //Egads. PL_strncasecmp is returning *very* negative numbers. 1.36 + //Some folks expect -1,0,1, so let's temper its enthusiasm. 1.37 + if (result<0) 1.38 + result=-1; 1.39 + return result; 1.40 + }