diff --git a/Source/build.cpp b/Source/build.cpp index cdfc916c..a415a203 100644 --- a/Source/build.cpp +++ b/Source/build.cpp @@ -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; diff --git a/Source/util.cpp b/Source/util.cpp index 12d78a9d..fa030ea6 100644 --- a/Source/util.cpp +++ b/Source/util.cpp @@ -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); diff --git a/Source/util.h b/Source/util.h index 9c206c66..b1930fd8 100644 --- a/Source/util.h +++ b/Source/util.h @@ -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,