Changeset 423 for trunk/Lucide


Ignore:
Timestamp:
Apr 21, 2010, 11:39:25 AM (11 years ago)
Author:
dmik
Message:

Do case-insensitive locale-aware file name comparison when building the file navigation list.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Lucide/gui/lucide.cpp

    r421 r423  
    3838
    3939#include <string>
    40 #include <set>
     40#include <vector>
     41#include <algorithm>
    4142#include <stdio.h>
    4243#include <stdlib.h>
     
    137138
    138139// List of files in current directory
    139 static std::set<std::string> fileList;
    140 static std::set<std::string>::const_iterator fileListIterator;
     140static std::vector<std::string> fileList;
     141static std::vector<std::string>::const_iterator fileListIterator;
    141142
    142143HMODULE _hmod = NULLHANDLE;
     
    631632        while ( done == 0 )
    632633        {
    633             fileList.insert( find_t_name( ffblk ) );
     634            fileList.push_back( find_t_name( ffblk ) );
    634635            done = _dos_findnext( &ffblk );
    635636        }
     
    638639    }
    639640    delete buf;
     641}
     642
     643// comparison, not case sensitive.
     644bool compare_nocase( const std::string &first, const std::string &second)
     645{
     646    // note: stricmp is locale aware in kLIBC
     647    return stricmp( first.c_str(), second.c_str() ) < 0;
    640648}
    641649
     
    654662    delete exts;
    655663
    656     fileListIterator = fileList.find( docFileName );
     664    std::sort( fileList.begin(), fileList.end(), compare_nocase );
     665    fileListIterator = std::find( fileList.begin(), fileList.end(), docFileName );
    657666}
    658667
Note: See TracChangeset for help on using the changeset viewer.