a little bit more TCHARs and minor fixes

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6042 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
wizou 2010-03-29 15:32:24 +00:00
parent acf9a8c21f
commit f4f18f9469
7 changed files with 29 additions and 16 deletions

View file

@ -223,6 +223,7 @@ defines_h.close()
# write version into version.h
f = open(defenv.File('#$BUILD_CONFIG/nsis-version.h').abspath, 'w')
f.write('// This file is automatically generated by SCons\n// DO NOT EDIT THIS FILE\n')
f.write('#include "tchar.h"\n')
if defenv.has_key('VER_MAJOR'):
defenv['VERSION'] = defenv['VER_MAJOR']

View file

@ -19,6 +19,7 @@
#include "Platform.h"
#include <stdio.h>
#include <stdlib.h>
#include "tchar.h"
#include "build.h"
#include "util.h"
#include "DialogTemplate.h"
@ -727,7 +728,7 @@ int CEXEBuild::GenerateLangTables() {
#undef ADD_FONT
}
catch (exception& err) {
ERROR_MSG(_T("\nError while applying font: %s\n"), err.what());
ERROR_MSG(_T("\nError while applying font: %s\n"), CtoTString(err.what()));
return PS_ERROR;
}
}
@ -790,7 +791,7 @@ int CEXEBuild::GenerateLangTables() {
#undef ADD_FONT
}
catch (exception& err) {
ERROR_MSG(_T("\nError while applying NLF font/RTL: %s\n"), err.what());
ERROR_MSG(_T("\nError while applying NLF font/RTL: %s\n"), CtoTString(err.what()));
return PS_ERROR;
}
@ -906,7 +907,7 @@ TCHAR SkipComments(FILE *f) {
// NSIS Language File parser
LanguageTable * CEXEBuild::LoadLangFile(TCHAR *filename) {
FILE *f = FOPEN(filename, _T("r"));
FILE *f = FOPENTEXT(filename, _T("r"));
if (!f) {
ERROR_MSG(_T("Error: Can't open language file - \"%s\"!\n"),filename);
return 0;
@ -971,7 +972,7 @@ LanguageTable * CEXEBuild::LoadLangFile(TCHAR *filename) {
}
// set ^Language
nlf->m_szStrings[NLF_LANGUAGE] = strdup(nlf->m_szName);
nlf->m_szStrings[NLF_LANGUAGE] = _tcsdup(nlf->m_szName);
int temp;

View file

@ -2825,7 +2825,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
if (s == 0)
datebuf[0]=0;
else
datebuf[max(s,sizeof(datebuf)-1)]=0;
datebuf[max(s,_countof(datebuf)-1)]=0;
value=datebuf;
} else if (!_tcsicmp(define,_T("/file")) || !_tcsicmp(define,_T("/file_noerr"))) {
@ -3139,7 +3139,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
for (;;)
{
str[0]=0;
fgets(str,sizeof(str),fp);
_fgetts(str,_countof(str),fp);
if (!str[0]) break; // eof
TCHAR *p=str;

View file

@ -300,7 +300,8 @@ class SortedStringListND // no delete - can be placed in GrowBuf
int pos=find(name,-1,case_sensitive,1,&where);
if (pos==-1) return alwaysreturnpos ? where : -1;
newstruct.name=strings.add(name,strlen(name)+1);
// Note that .name is set with the TCHAR* offset into m_strings. newstruct.name=strings.add(name,strlen(name)+1);
gr.add(&newstruct,sizeof(T));
T *s=(T*)gr.get();
@ -357,6 +358,7 @@ class SortedStringListND // no delete - can be placed in GrowBuf
int ll=0;
int nextpos=(ul+ll)/2;
// Do binary search on m_gr which is sorted. m_strings is NOT sorted.
while (ul > ll)
{
int res;
@ -366,21 +368,32 @@ class SortedStringListND // no delete - can be placed in GrowBuf
if (case_sensitive)
res = _tcscmp(str, pCurr);
else
res = stricmp(str, pCurr);
res = _tcsicmp(str, pCurr);
}
else
{
unsigned int pCurr_len = _tcslen(pCurr);
if (case_sensitive)
res=strncmp(str, pCurr, mymin((unsigned int) n_chars, strlen(pCurr)));
res = _tcsncmp(str, pCurr, mymin((unsigned int) n_chars, pCurr_len));
else
res=strnicmp(str, pCurr, mymin((unsigned int) n_chars, strlen(pCurr)));
if (res == 0 && n_chars != -1 && (unsigned int) n_chars != strlen(pCurr))
res = n_chars - strlen(pCurr);
res = _tcsncicmp(str, pCurr, mymin((unsigned int) n_chars, pCurr_len));
// If there is a match and we are looking for a partial match and
// n_chars is NOT the length of the current string, then the
// comparison result is determined by the length comparison.
if (res == 0 && n_chars != -1 && (unsigned int) n_chars != pCurr_len)
res = n_chars - pCurr_len;
}
// Found!
if (res==0)
{
// Return where we found it in *where.
if (where) *where = nextpos;
// If returnbestpos, then we should return -1, otherwise where
// we found it. But if (returnbestpos && case_sensitive == -1)
// returns nextpos.
return returnbestpos ? (case_sensitive!=-1 ? -1 : nextpos) : nextpos;
}
if (res<0) ul=nextpos;

View file

@ -21,8 +21,6 @@
#include "tchar.h"
#include <string>
//#include <windows.h>
//#include <fstream>
/* Abstract string type as well. */
#ifdef _UNICODE