MiKTeX 26.5-next
A scalable TeX distribution
Loading...
Searching...
No Matches
less_icase_dos.h
1/* miktex/Core/equal_icase_dos: -*- C++ -*-
2
3 Copyright (C) 1996-2018 Christian Schenk
4
5 This file is part of the MiKTeX Core Library.
6
7 The MiKTeX Core Library is free software; you can redistribute it
8 and/or modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either version 2, or
10 (at your option) any later version.
11
12 The MiKTeX Core Library is distributed in the hope that it will be
13 useful, but WITHOUT ANY WARRANTY; without even the implied warranty
14 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with the MiKTeX Core Library; if not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
20 02111-1307, USA. */
21
22#pragma once
23
24#if !defined(B9BC6F86436E4103A4836E2C16CA8343)
25#define B9BC6F86436E4103A4836E2C16CA8343
26
27#include <miktex/Core/config.h>
28
29#include <string>
30
31MIKTEX_CORE_BEGIN_NAMESPACE;
32
34{
35public:
36 bool operator() (const std::string& str1, const std::string& str2) const
37 {
38 std::size_t l1 = str1.length();
39 std::size_t l2 = str2.length();
40 std::size_t count = l1 < l2 ? l1 : l2;
41 for (std::size_t idx = 0; idx < count; ++idx)
42 {
43 char ch1 = normalize(str1[idx]);
44 char ch2 = normalize(str2[idx]);
45 if (ch1 != ch2)
46 {
47 return ch1 < ch2;
48 }
49 }
50 return l1 < l2;
51 }
52private:
53 char normalize(char ch) const
54 {
55 if (ch == '/')
56 {
57 return '\\';
58 }
59 else if (ch >= 'A' && ch <= 'Z')
60 {
61 return ch - 'A' + 'a';
62 }
63 else
64 {
65 return ch;
66 }
67 }
68};
69
70MIKTEX_CORE_END_NAMESPACE;
71
72#endif
Definition less_icase_dos.h:34