]>
git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_string.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 #include "rgw_string.h"
6 static bool char_eq(char c1
, char c2
)
11 static bool ci_char_eq(char c1
, char c2
)
13 return tolower(c1
) == tolower(c2
);
16 bool match_wildcards(boost::string_view pattern
, boost::string_view input
,
19 const auto eq
= (flags
& MATCH_CASE_INSENSITIVE
) ? &ci_char_eq
: &char_eq
;
21 auto it1
= pattern
.begin();
22 auto it2
= input
.begin();
24 if (it1
== pattern
.end())
25 return it2
== input
.end();
27 if (it1
+ 1 == pattern
.end())
29 if (it2
== input
.end() || eq(*(it1
+ 1), *it2
))
35 if (it2
== input
.end())
37 if (*it1
== '?' || eq(*it1
, *it2
)) {