Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 90681 Details for
Bug 137784
eix does not respect /etc/portage/package.* directories
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Cleaner version of previous patches and a bugfix for an unreported bug
read_recursive.patch (text/plain), 6.12 KB, created by
Martin Väth
on 2006-07-02 04:54:30 UTC
(
hide
)
Description:
Cleaner version of previous patches and a bugfix for an unreported bug
Filename:
MIME Type:
Creator:
Martin Väth
Created:
2006-07-02 04:54:30 UTC
Size:
6.12 KB
patch
obsolete
>--- src/eixTk/utils.cc >+++ src/eixTk/utils.cc >@@ -43,7 +43,7 @@ > using namespace std; > > /** push_back every line of file into v. */ >-bool pushback_lines(const char *file, vector<string> *v, bool removed_empty) >+bool pushback_lines_file(const char *file, vector<string> *v, bool removed_empty) > { > string line; > ifstream ifstr(file); >@@ -71,14 +71,37 @@ > return false; > } > >+/** push_back every line of file or dir into v. */ >+bool pushback_lines(const char *file, vector<string> *v, bool removed_empty, bool recursive) >+{ >+ static const char *files_exclude[] = { "..", "." , NULL }; >+ vector<string> files; >+ string dir(file); >+ dir += "/"; >+ if(recursive && pushback_files(dir, files, files_exclude, false)) >+ { >+ bool rvalue=true; >+ for(vector<string>::iterator it=files.begin(); >+ it<files.end(); ++it) >+ { >+ if(! pushback_lines(it->c_str(), v, removed_empty)) >+ rvalue=false; >+ } >+ return rvalue; >+ } >+ else >+ return pushback_lines_file(file, v, removed_empty); >+} >+ > /** List of files in directory. > * Pushed names of file in directory into string-vector if the don't match any > * char * in given exlude list. > * @param dir_path Path to directory > * @param into pointer to vector of strings .. files get append here (with full path) > * @param exclude list of char * that don't need to be put into vector >+ * @param onlyfiles consider only ordinary files > * @return false if everything is ok */ >-bool pushback_files(string &dir_path, vector<string> &into, const char *exclude[]) >+bool pushback_files(string &dir_path, vector<string> &into, const char *exclude[], bool onlyfiles) > { > struct stat static_stat; > DIR *dir = opendir(dir_path.c_str()); >@@ -91,13 +114,19 @@ > if(exclude) > { > char **_p = (char **)exclude; >- while(*_p) /* Look if it's in exclude */ >- if(strcmp(*(_p++), dir_entry->d_name) == 0) >- continue; >+ for(;*_p;_p++) /* Look if it's in exclude */ >+ if(strcmp(*_p, dir_entry->d_name) == 0) >+ break; >+ if(*_p) >+ continue; >+ >+ } >+ if(onlyfiles) >+ { >+ if(stat((dir_path + dir_entry->d_name).c_str(), &static_stat) >+ || !S_ISREG(static_stat.st_mode)) >+ continue; > } >- if(stat((dir_path + dir_entry->d_name).c_str(), &static_stat) >- || !S_ISREG(static_stat.st_mode)) >- continue; > into.push_back(dir_path + dir_entry->d_name); > } > closedir(dir); >--- src/eixTk/utils.h >+++ src/eixTk/utils.h >@@ -32,8 +32,8 @@ > #include <vector> > #include <string> > >-/** push_back every line of file into v. */ >-bool pushback_lines(const char *file, std::vector<std::string> *v, bool removed_empty = true); >+/** push_back every line of file or dir into v. */ >+bool pushback_lines(const char *file, std::vector<std::string> *v, bool removed_empty = true, bool recursive = true); > > /** List of files in directory. > * Pushed names of file in directory into string-vector if the don't match any >@@ -41,8 +41,9 @@ > * @param dir_path Path to directory > * @param into pointer to vector of strings .. files get append here (with full path) > * @param exlude list of char * that don't need to be put into vector >+ * @param onlyfiles consider only ordinary files > * @return false if everything is ok */ >-bool pushback_files(std::string &dir_path, std::vector<std::string> &into, const char *exclude[]); >+bool pushback_files(std::string &dir_path, std::vector<std::string> &into, const char *exclude[], bool onlyfiles = true); > > > /** Cycle through map using it, until it is it_end, append all values from it >--- src/portage/conf/portagesettings.cc >+++ src/portage/conf/portagesettings.cc >@@ -42,36 +42,35 @@ > > using namespace std; > >-bool grab_masks(const char *file, Mask::Type type, MaskList<Mask> *cat_map, vector<Mask*> *mask_vec) >+bool grab_masks(const char *file, Mask::Type type, MaskList<Mask> *cat_map, vector<Mask*> *mask_vec, bool recursive) > { >- ifstream mask_file(file); >- if(mask_file.is_open()) { >- string line; >- while(getline(mask_file, line)) { >- trim(&line); >- if(line.size() == 0 || line[0] == '#') >- continue; >- try { >- Mask *m = new Mask(line.c_str(), type); >- OOM_ASSERT(m); >- if(cat_map) { >- cat_map->add(m); >- } >- else { >- mask_vec->push_back(m); >- } >+ vector<string> lines; >+ if( ! pushback_lines(file, &lines, true, recursive)) >+ return false; >+ for(vector<string>::iterator it=lines.begin(); it<lines.end(); ++it) >+ { >+ string line=*it; >+ try { >+ Mask *m = new Mask(line.c_str(), type); >+ OOM_ASSERT(m); >+ if(cat_map) { >+ cat_map->add(m); > } >- catch(ExBasic e) { >- cerr << "-- Invalid line in " << file << ": \"" << line << "\"" << endl >- << " " << e.getMessage() << endl; >+ else { >+ mask_vec->push_back(m); > } > } >- mask_file.close(); >- return true; >+ catch(ExBasic e) { >+ cerr << "-- Invalid line in " << file << ": \"" << line << "\"" << endl >+ << " " << e.getMessage() << endl; >+ } > } >- return false; >+ return true; > } > >+ >+ >+ > /** Key that should accumelate their content rathern then replace. */ > static const char *default_accumulating_keys[] = { > "USE", >--- src/portage/conf/portagesettings.h >+++ src/portage/conf/portagesettings.h >@@ -45,16 +45,16 @@ > class Package; > > /** Grab Masks from file and add to a category->vector<Mask*> mapping or to a vector<Mask*>. */ >-bool grab_masks(const char *file, Mask::Type type, MaskList<Mask> *cat_map, std::vector<Mask*> *mask_vec); >+bool grab_masks(const char *file, Mask::Type type, MaskList<Mask> *cat_map, std::vector<Mask*> *mask_vec, bool recursive=true); > > /** Grab Mask from file and add to category->vector<Mask*>. */ >-inline bool grab_masks(const char *file, Mask::Type type, std::vector<Mask*> *mask_vec) { >- return grab_masks(file, type, NULL , mask_vec); >+inline bool grab_masks(const char *file, Mask::Type type, std::vector<Mask*> *mask_vec, bool recursive=true) { >+ return grab_masks(file, type, NULL , mask_vec, recursive); > } > > /** Grab Mask from file and add to vector<Mask*>. */ >-inline bool grab_masks(const char *file, Mask::Type type, MaskList<Mask> *cat_map) { >- return grab_masks(file, type, cat_map, NULL); >+inline bool grab_masks(const char *file, Mask::Type type, MaskList<Mask> *cat_map, bool recursive=true) { >+ return grab_masks(file, type, cat_map, NULL, recursive); > } > > class PortageSettings;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 137784
:
89960
|
89981
|
89982
| 90681