Date:2013-07-05 20:00:46 (10 years 8 months ago)
Author:Paul Cercueil
Commit:eb6329423193292c3c13e50c0b1f8cf56354b89a
Message:Don't call tolower() on the whole filenames, only on extensions

tolower() will trigger an assertion failure in the case where the
string contains UTF-8 codes. This is not a problem as only the
file extension needs to be processed, and that one should contain
only ASCII.
Files: src/filelister.cpp (2 diffs)

Change Details

src/filelister.cpp
8383        vector<string> vfilter;
8484        split(vfilter, getFilter(), ",");
8585
86        string filepath, file, file_lowercase;
86        string filepath, file;
8787        struct stat st;
8888        struct dirent *dptr;
8989
9090        while ((dptr = readdir(dirp))) {
9191            file = dptr->d_name;
92            file_lowercase = file;
93            std::transform(file_lowercase.begin(), file_lowercase.end(), file_lowercase.begin(), ::tolower);
9492
9593            if (file[0] == '.' && file != "..")
9694                continue;
...... 
120118                  continue;
121119
122120                for (vector<string>::iterator it = vfilter.begin(); it != vfilter.end(); ++it) {
123                    if (it->length() <= file.length()) {
124                        if (file_lowercase.compare(file.length() - it->length(), it->length(), *it) == 0) {
121                    if (it->length() < file.length()) {
122                        string file_lowercase =
123                                    file.substr(file.length() - it->length());
124                        if (file_lowercase[0] != '.')
125                            continue;
126
127                        /* XXX: This won't accept UTF-8 codes.
128                         * Thanksfully file extensions shouldn't contain any. */
129                        transform(file_lowercase.begin(), file_lowercase.end(),
130                                    file_lowercase.begin(), ::tolower);
131
132                        if (file_lowercase.compare(0, it->length(), *it) == 0) {
125133                            files.push_back(file);
126134                            break;
127135                        }

Archive Download the corresponding diff file



interactive