Jim Park's Unicode NSIS merging - Step 1 : switch to TCHARs where relevant.
Compiler output is identical before & after this step git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/branches/wizou@6036 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
4e48722b63
commit
752d7d239a
209 changed files with 9698 additions and 7658 deletions
|
@ -12,11 +12,13 @@
|
|||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty.
|
||||
*
|
||||
* Unicode support by Jim Park -- 08/23/2007
|
||||
*/
|
||||
|
||||
#include "Platform.h"
|
||||
#include "dirreader.h"
|
||||
#include <string>
|
||||
#include "tstring.h"
|
||||
#include <set>
|
||||
|
||||
#include <string.h> // for stricmp()
|
||||
|
@ -25,27 +27,27 @@
|
|||
using namespace std;
|
||||
|
||||
dir_reader::dir_reader() {
|
||||
exclude(".");
|
||||
exclude("..");
|
||||
exclude(_T("."));
|
||||
exclude(_T(".."));
|
||||
}
|
||||
|
||||
const set<string>& dir_reader::files() {
|
||||
const set<tstring>& dir_reader::files() {
|
||||
return m_files;
|
||||
}
|
||||
|
||||
const set<string>& dir_reader::dirs() {
|
||||
const set<tstring>& dir_reader::dirs() {
|
||||
return m_dirs;
|
||||
}
|
||||
|
||||
void dir_reader::exclude(const string& spec) {
|
||||
if (spec.find_first_of("?*") != string::npos) {
|
||||
void dir_reader::exclude(const tstring& spec) {
|
||||
if (spec.find_first_of(_T("?*")) != tstring::npos) {
|
||||
m_wildcard_excluded.insert(spec);
|
||||
} else {
|
||||
m_excluded.insert(spec);
|
||||
}
|
||||
}
|
||||
|
||||
void dir_reader::exclude(const set<string>& specs) {
|
||||
void dir_reader::exclude(const set<tstring>& specs) {
|
||||
iterator i = specs.begin();
|
||||
iterator e = specs.end();
|
||||
|
||||
|
@ -54,27 +56,27 @@ void dir_reader::exclude(const set<string>& specs) {
|
|||
}
|
||||
}
|
||||
|
||||
bool dir_reader::matches(const string& name, const string& spec) {
|
||||
string::const_iterator name_itr = name.begin();
|
||||
string::const_iterator name_end = name.end();
|
||||
bool dir_reader::matches(const tstring& name, const tstring& spec) {
|
||||
tstring::const_iterator name_itr = name.begin();
|
||||
tstring::const_iterator name_end = name.end();
|
||||
|
||||
string::const_iterator spec_itr = spec.begin();
|
||||
string::const_iterator spec_end = spec.end();
|
||||
tstring::const_iterator spec_itr = spec.begin();
|
||||
tstring::const_iterator spec_end = spec.end();
|
||||
|
||||
string::const_iterator last_good_spec = spec_end;
|
||||
string::const_iterator last_good_name = name_end;
|
||||
tstring::const_iterator last_good_spec = spec_end;
|
||||
tstring::const_iterator last_good_name = name_end;
|
||||
|
||||
while (name_itr != name_end && spec_itr != spec_end) {
|
||||
switch (*spec_itr) {
|
||||
case '?':
|
||||
case _T('?'):
|
||||
// question mark mathes one char
|
||||
name_itr++;
|
||||
spec_itr++;
|
||||
break;
|
||||
|
||||
case '*':
|
||||
case _T('*'):
|
||||
// double asterisk is the same as a single asterisk
|
||||
while (*spec_itr == '*') {
|
||||
while (*spec_itr == _T('*')) {
|
||||
spec_itr++;
|
||||
// asterisk at the end of the spec matches the end of the name
|
||||
if (spec_itr == spec_end)
|
||||
|
@ -88,6 +90,7 @@ bool dir_reader::matches(const string& name, const string& spec) {
|
|||
break;
|
||||
|
||||
default:
|
||||
// Jim Park: This should work since tolower is templated with Chartype.
|
||||
if (::tolower(*name_itr) != ::tolower(*spec_itr)) {
|
||||
if (last_good_spec != spec_end) {
|
||||
// matched wrong part of the name, try again
|
||||
|
@ -115,7 +118,7 @@ bool dir_reader::matches(const string& name, const string& spec) {
|
|||
|
||||
// skip any redundant asterisks and periods at the end of the name
|
||||
while (spec_itr != spec_end) {
|
||||
if (*spec_itr != '.' && *spec_itr != '*') {
|
||||
if (*spec_itr != _T('.') && *spec_itr != _T('*')) {
|
||||
break;
|
||||
}
|
||||
spec_itr++;
|
||||
|
@ -125,19 +128,19 @@ bool dir_reader::matches(const string& name, const string& spec) {
|
|||
return name_itr == name_end && spec_itr == spec_end;
|
||||
}
|
||||
|
||||
void dir_reader::add_file(const string& file) {
|
||||
void dir_reader::add_file(const tstring& file) {
|
||||
if (!is_excluded(file)) {
|
||||
m_files.insert(file);
|
||||
}
|
||||
}
|
||||
|
||||
void dir_reader::add_dir(const string& dir) {
|
||||
void dir_reader::add_dir(const tstring& dir) {
|
||||
if (!is_excluded(dir)) {
|
||||
m_dirs.insert(dir);
|
||||
}
|
||||
}
|
||||
|
||||
bool dir_reader::is_excluded(const string& name) const {
|
||||
bool dir_reader::is_excluded(const tstring& name) const {
|
||||
iterator i = m_excluded.begin();
|
||||
iterator e = m_excluded.end();
|
||||
|
||||
|
@ -164,10 +167,10 @@ bool dir_reader::is_excluded(const string& name) const {
|
|||
class win32_dir_reader : public dir_reader {
|
||||
public:
|
||||
|
||||
virtual void read(const string& dir) {
|
||||
virtual void read(const tstring& dir) {
|
||||
WIN32_FIND_DATA fd;
|
||||
|
||||
string spec = dir + PLATFORM_PATH_SEPARATOR_STR + "*.*";
|
||||
tstring spec = dir + PLATFORM_PATH_SEPARATOR_STR + _T("*.*");
|
||||
|
||||
HANDLE h = ::FindFirstFile(spec.c_str(), &fd);
|
||||
if (h != INVALID_HANDLE_VALUE) {
|
||||
|
@ -193,7 +196,7 @@ public:
|
|||
class posix_dir_reader : public dir_reader {
|
||||
public:
|
||||
|
||||
virtual void read(const string& dir) {
|
||||
virtual void read(const tstring& dir) {
|
||||
//convert(dir);
|
||||
|
||||
DIR *dip = ::opendir(dir.c_str());
|
||||
|
@ -218,16 +221,16 @@ public:
|
|||
private:
|
||||
|
||||
void convert(string& path) {
|
||||
string::size_type pos = path.find('\\');
|
||||
string::size_type pos = path.find(_T('\\'));
|
||||
while (pos != string::npos) {
|
||||
path[pos] = '/';
|
||||
pos = path.find('\\');
|
||||
path[pos] = _T('/');
|
||||
pos = path.find(_T('\\'));
|
||||
}
|
||||
|
||||
/* Replace drive letter X: by /x */
|
||||
if (path[1] == ':') {
|
||||
path[1] = ::tolower(path[0]);
|
||||
path[0] = '/';
|
||||
if (path[1] == _T(':')) {
|
||||
path[1] = ::_totlower(path[0]);
|
||||
path[0] = _T('/');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue