mirror of
https://github.com/Stichting-MINIX-Research-Foundation/pkgsrc-ng.git
synced 2025-09-08 03:44:13 -04:00
135 lines
3.7 KiB
Plaintext
135 lines
3.7 KiB
Plaintext
$NetBSD: patch-ad,v 1.7 2014/01/20 19:29:34 joerg Exp $
|
|
|
|
On Solaris 10 with SunPro, vector<> does not have a method assign().
|
|
|
|
--- src/libdar/mask_list.cpp.orig 2011-02-11 20:23:42.000000000 +0000
|
|
+++ src/libdar/mask_list.cpp
|
|
@@ -55,6 +55,21 @@ using namespace std;
|
|
namespace libdar
|
|
{
|
|
|
|
+static bool cmp_strings(const std::string &x, const std::string &y)
|
|
+{
|
|
+ size_t i;
|
|
+ for (i = 0; i < x.size(); ++i) {
|
|
+ if (x[i] == y[i])
|
|
+ continue;
|
|
+ if(x[i] == '/')
|
|
+ return true;
|
|
+ if(y[i] == '/')
|
|
+ return false;
|
|
+ return x[i] < y[i];
|
|
+ }
|
|
+ return false;
|
|
+}
|
|
+
|
|
mask_list::mask_list(const string & filename_list_st, bool case_sensit, const path & prefix_t, bool include)
|
|
{
|
|
NLS_SWAP_IN;
|
|
@@ -194,12 +209,14 @@ namespace libdar
|
|
|
|
// we use a temporary list of string of my_chart to use
|
|
// the lexicographic sorting with having the / as the lowest character
|
|
- list<basic_string<my_char> > my_tmp = convert_list_string_char(tmp);
|
|
- my_tmp.sort(); // sort the list ( using the string's < operator over "my_char" )
|
|
- my_tmp.unique(); // remove duplicates
|
|
+ tmp.sort(cmp_strings);
|
|
+ tmp.unique();
|
|
|
|
// converting the sorted list to vector, to get the indexing feature of this type
|
|
- contenu.assign(my_tmp.begin(), my_tmp.end());
|
|
+ contenu.clear();
|
|
+ for (list< string >::const_iterator it = tmp.begin(); it != tmp.end(); it++)
|
|
+ contenu.push_back(*it);
|
|
+
|
|
taille = contenu.size();
|
|
if(taille < contenu.size())
|
|
throw Erange("mask_list::mask_list", tools_printf(gettext("Too much line in file %S (integer overflow)"), &filename_list_st));
|
|
@@ -218,23 +235,23 @@ namespace libdar
|
|
return false;
|
|
|
|
U_I min = 0, max = taille-1, tmp;
|
|
- basic_string<my_char> target;
|
|
+ string target;
|
|
bool ret;
|
|
|
|
if(case_s)
|
|
- target = convert_string_char(expression);
|
|
+ target = expression;
|
|
else
|
|
{
|
|
string hidden = expression;
|
|
tools_to_upper(hidden);
|
|
- target = convert_string_char(hidden);
|
|
+ target = hidden;
|
|
}
|
|
|
|
// divide & conquer algorithm on a sorted list (aka binary search)
|
|
while(max - min > 1)
|
|
{
|
|
tmp = (min + max)/2;
|
|
- if(contenu[tmp] < target)
|
|
+ if(cmp_strings(contenu[tmp], target))
|
|
min = tmp;
|
|
else
|
|
if(contenu[tmp] == target)
|
|
@@ -246,57 +263,11 @@ namespace libdar
|
|
ret = contenu[max] == target || contenu[min] == target;
|
|
if(including && !ret) // if including files, we must also include directories leading to a listed file
|
|
{
|
|
- string c_max = convert_string_my_char(contenu[max]);
|
|
+ string c_max = contenu[max];
|
|
ret = path(c_max).is_subdir_of(expression, case_s);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
-
|
|
- //////// private routines implementation
|
|
-
|
|
-
|
|
- list<basic_string<mask_list::my_char> > mask_list::convert_list_string_char(const list<string> & src)
|
|
- {
|
|
- list<basic_string<my_char> > ret;
|
|
- list<string>::const_iterator it = src.begin();
|
|
-
|
|
- while(it != src.end())
|
|
- {
|
|
- ret.push_back(convert_string_char(*it));
|
|
- ++it;
|
|
- }
|
|
- return ret;
|
|
- }
|
|
-
|
|
- basic_string<mask_list::my_char> mask_list::convert_string_char(const string & src)
|
|
- {
|
|
- basic_string<my_char> ret;
|
|
-
|
|
- string::const_iterator ut = src.begin();
|
|
- while(ut != src.end())
|
|
- {
|
|
- ret += my_char(*ut);
|
|
- ++ut;
|
|
- }
|
|
-
|
|
- return ret;
|
|
- }
|
|
-
|
|
- string mask_list::convert_string_my_char(const basic_string<mask_list::my_char> & src)
|
|
- {
|
|
- string ret;
|
|
-
|
|
- basic_string<my_char>::const_iterator ut = src.begin();
|
|
- while(ut != src.end())
|
|
- {
|
|
- ret += char(*ut);
|
|
- ++ut;
|
|
- }
|
|
-
|
|
- return ret;
|
|
- }
|
|
-
|
|
-
|
|
} // end of namespace
|