moved non-win32 CharNextExA implementation to util.cpp

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@5208 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2007-07-18 19:18:00 +00:00
parent 9d1ab6f1ae
commit 3e9377d5b2
3 changed files with 19 additions and 16 deletions

View file

@ -466,22 +466,7 @@ int CEXEBuild::preprocess_string(char *out, const char *in, WORD codepage/*=CP_A
const char *p=in;
while (*p)
{
const char *np;
#ifdef _WIN32
np = CharNextExA(codepage, p, 0);
#else
{
char buf[1024];
snprintf(buf, 1024, "CP%d", codepage);
setlocale(LC_CTYPE, buf);
int len = mblen(p, strlen(p));
if (len > 0)
np = p + len;
else
np = p + 1;
setlocale(LC_CTYPE, "");
}
#endif
const char *np = CharNextExA(codepage, p, 0);
if (np - p > 1) // multibyte char
{
int l = np - p;

View file

@ -413,6 +413,23 @@ char *CharNext(const char *s) {
return (char *) s + l;
}
char *CharNextExA(WORD codepage, const char *s, int flags) {
char buf[1024];
snprintf(buf, 1024, "CP%d", codepage);
setlocale(LC_CTYPE, buf);
const char* np;
int len = mblen(s, strlen(s));
if (len > 0)
np = s + len;
else
np = s + 1;
setlocale(LC_CTYPE, "");
return (char *) np;
}
int wsprintf(char *s, const char *format, ...) {
va_list val;
va_start(val, format);

View file

@ -65,6 +65,7 @@ int sane_system(const char *command);
#ifndef _WIN32
char *CharPrev(const char *s, const char *p);
char *CharNext(const char *s);
char *CharNextExA(WORD codepage, const char *s, int flags);
int wsprintf(char *s, const char *format, ...);
int WideCharToMultiByte(UINT CodePage, DWORD dwFlags, LPCWSTR lpWideCharStr,
int cchWideChar, LPSTR lpMultiByteStr, int cbMultiByte, LPCSTR lpDefaultChar,