1
0
Fork 0
forked from fte/fteqw
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4525 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2013-11-21 23:16:59 +00:00
parent 8640500899
commit 05644d07b4
5 changed files with 88 additions and 72 deletions

View file

@ -676,73 +676,8 @@ FILE IO
*/
wchar_t *widen(wchar_t *out, size_t outlen, const char *utf8)
{
wchar_t *ret = out;
//utf-8 to utf-16, not ucs-2.
unsigned int codepoint;
int error;
if (!outlen)
return L"";
outlen /= sizeof(wchar_t);
outlen--;
while (*utf8)
{
codepoint = utf8_decode(&error, utf8, (void*)&utf8);
if (error)
codepoint = 0xFFFDu;
if (codepoint > 0xffff)
{
if (outlen < 2)
break;
outlen -= 2;
codepoint -= 0x10000u;
*out++ = 0xD800 | (codepoint>>10);
*out++ = 0xDC00 | (codepoint&0x3ff);
}
else
{
if (outlen < 1)
break;
outlen -= 1;
*out++ = codepoint;
}
}
*out = 0;
return ret;
}
char *narrowen(char *out, size_t outlen, wchar_t *wide)
{
char *ret = out;
int bytes;
unsigned int codepoint;
if (!outlen)
return "";
outlen--;
//utf-8 to utf-16, not ucs-2.
while (*wide)
{
codepoint = *wide++;
if (codepoint >= 0xD800u && codepoint <= 0xDBFFu)
{ //handle utf-16 surrogates
if (*wide >= 0xDC00u && *wide <= 0xDFFFu)
{
codepoint = (codepoint&0x3ff)<<10;
codepoint |= *wide++ & 0x3ff;
}
else
codepoint = 0xFFFDu;
}
bytes = utf8_encode(out, codepoint, outlen);
if (bytes <= 0)
break;
out += bytes;
outlen -= bytes;
}
*out = 0;
return ret;
}
wchar_t *widen(wchar_t *out, size_t outlen, const char *utf8);
char *narrowen(char *out, size_t outlen, wchar_t *wide);
void Sys_mkdir (char *path)
{
@ -2733,7 +2668,14 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin
setjmp (restart_jmpbuf);
#endif
GetModuleFileName(NULL, bindir, sizeof(bindir)-1);
if (WinNT)
{
wchar_t widebindir[1024];
GetModuleFileNameW(NULL, widebindir, sizeof(widebindir)/sizeof(widebindir[0])-1);
narrowen(bindir, sizeof(bindir)-1, widebindir);
}
else
GetModuleFileNameA(NULL, bindir, sizeof(bindir)-1);
Q_strncpyz(exename, bindir, sizeof(exename));
*COM_SkipPath(bindir) = 0;
parms.argv = (const char **)argv;

View file

@ -28,8 +28,73 @@ typedef struct {
unsigned int offset;
} vfsw32file_t;
wchar_t *widen(wchar_t *out, size_t outlen, const char *utf8);
char *narrowen(char *out, size_t outlen, const wchar_t *wide);
wchar_t *widen(wchar_t *out, size_t outlen, const char *utf8)
{
wchar_t *ret = out;
//utf-8 to utf-16, not ucs-2.
unsigned int codepoint;
int error;
if (!outlen)
return L"";
outlen /= sizeof(wchar_t);
outlen--;
while (*utf8)
{
codepoint = utf8_decode(&error, utf8, (void*)&utf8);
if (error)
codepoint = 0xFFFDu;
if (codepoint > 0xffff)
{
if (outlen < 2)
break;
outlen -= 2;
codepoint -= 0x10000u;
*out++ = 0xD800 | (codepoint>>10);
*out++ = 0xDC00 | (codepoint&0x3ff);
}
else
{
if (outlen < 1)
break;
outlen -= 1;
*out++ = codepoint;
}
}
*out = 0;
return ret;
}
char *narrowen(char *out, size_t outlen, wchar_t *wide)
{
char *ret = out;
int bytes;
unsigned int codepoint;
if (!outlen)
return "";
outlen--;
//utf-8 to utf-16, not ucs-2.
while (*wide)
{
codepoint = *wide++;
if (codepoint >= 0xD800u && codepoint <= 0xDBFFu)
{ //handle utf-16 surrogates
if (*wide >= 0xDC00u && *wide <= 0xDFFFu)
{
codepoint = (codepoint&0x3ff)<<10;
codepoint |= *wide++ & 0x3ff;
}
else
codepoint = 0xFFFDu;
}
bytes = utf8_encode(out, codepoint, outlen);
if (bytes <= 0)
break;
out += bytes;
outlen -= bytes;
}
*out = 0;
return ret;
}
static int QDECL VFSW32_ReadBytes (struct vfsfile_s *file, void *buffer, int bytestoread)

View file

@ -3974,7 +3974,7 @@ void QCBUILTIN PF_break (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals
//need to alter the client, or rewrite a bit of the server..
if (pr_globals)
Con_TPrintf(STL_BREAKSTATEMENT);
Con_Printf("Break Statement\n");
else if (developer.value!=2)
return; //non developers cann't step.
for(;;)

View file

@ -18942,6 +18942,7 @@
</FileConfiguration>
<FileConfiguration
Name="GLDebug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
@ -29651,6 +29652,14 @@
CompileAs="2"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug Dedicated Server|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\common\net_ssl_winsspi.c"

View file

@ -39,7 +39,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
static HANDLE hconsoleout;
qboolean WinNT; //if true, use utf-16 file paths. if false, hope that paths are in ascii.
#ifdef _DEBUG