/src/mozilla-central/xpcom/string/nsStringComparator.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
3 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #include <ctype.h> |
8 | | #include "nsAString.h" |
9 | | #include "plstr.h" |
10 | | |
11 | | #include "nsTStringComparator.cpp" |
12 | | |
13 | | |
14 | | int |
15 | | nsCaseInsensitiveCStringComparator::operator()(const char_type* aLhs, |
16 | | const char_type* aRhs, |
17 | | uint32_t aLhsLength, |
18 | | uint32_t aRhsLength) const |
19 | 102k | { |
20 | 102k | if (aLhsLength != aRhsLength) { |
21 | 0 | return (aLhsLength > aRhsLength) ? 1 : -1; |
22 | 0 | } |
23 | 102k | int32_t result = int32_t(PL_strncasecmp(aLhs, aRhs, aLhsLength)); |
24 | 102k | //Egads. PL_strncasecmp is returning *very* negative numbers. |
25 | 102k | //Some folks expect -1,0,1, so let's temper its enthusiasm. |
26 | 102k | if (result < 0) { |
27 | 43.9k | result = -1; |
28 | 43.9k | } |
29 | 102k | return result; |
30 | 102k | } |