chore(build): revert to sdl2

This commit is contained in:
phaneron 2024-07-21 17:06:25 -04:00
parent 20f392cd74
commit b5902f5230
2095 changed files with 244085 additions and 192940 deletions

View file

@ -0,0 +1,103 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "../SDL_internal.h"
#include "SDL_syslocale.h"
#include "SDL_hints.h"
static SDL_Locale *build_locales_from_csv_string(char *csv)
{
size_t num_locales = 1; /* at least one */
size_t slen;
size_t alloclen;
char *ptr;
SDL_Locale *loc;
SDL_Locale *retval;
if (!csv || !csv[0]) {
return NULL; /* nothing to report */
}
for (ptr = csv; *ptr; ptr++) {
if (*ptr == ',') {
num_locales++;
}
}
num_locales++; /* one more for terminator */
slen = ((size_t)(ptr - csv)) + 1; /* SDL_strlen(csv) + 1 */
alloclen = slen + (num_locales * sizeof(SDL_Locale));
loc = retval = (SDL_Locale *)SDL_calloc(1, alloclen);
if (!retval) {
SDL_OutOfMemory();
return NULL; /* oh well */
}
ptr = (char *)(retval + num_locales);
SDL_strlcpy(ptr, csv, slen);
while (SDL_TRUE) { /* parse out the string */
while (*ptr == ' ') {
ptr++; /* skip whitespace. */
}
if (*ptr == '\0') {
break;
}
loc->language = ptr++;
while (SDL_TRUE) {
const char ch = *ptr;
if (ch == '_') {
*(ptr++) = '\0';
loc->country = ptr;
} else if (ch == ' ') {
*(ptr++) = '\0'; /* trim ending whitespace and keep going. */
} else if (ch == ',') {
*(ptr++) = '\0';
loc++;
break;
} else if (ch == '\0') {
loc++;
break;
} else {
ptr++; /* just keep going, still a valid string */
}
}
}
return retval;
}
SDL_Locale *SDL_GetPreferredLocales(void)
{
char locbuf[128]; /* enough for 21 "xx_YY," language strings. */
const char *hint = SDL_GetHint(SDL_HINT_PREFERRED_LOCALES);
if (hint) {
SDL_strlcpy(locbuf, hint, sizeof(locbuf));
} else {
SDL_zeroa(locbuf);
SDL_SYS_GetPreferredLocales(locbuf, sizeof(locbuf));
}
return build_locales_from_csv_string(locbuf);
}
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -0,0 +1,37 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_config.h"
/* This is the system specific header for the SDL locale API */
#include "SDL_locale.h"
#ifdef __cplusplus
extern "C" {
#endif
extern void SDL_SYS_GetPreferredLocales(char *buf, size_t buflen);
#ifdef __cplusplus
}
#endif
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -0,0 +1,31 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
#include "../SDL_syslocale.h"
#include "../../core/android/SDL_android.h"
void SDL_SYS_GetPreferredLocales(char *buf, size_t buflen)
{
Android_JNI_GetLocale(buf, buflen);
}
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -0,0 +1,31 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
#include "../SDL_syslocale.h"
void SDL_SYS_GetPreferredLocales(char *buf, size_t buflen)
{
/* dummy implementation. Caller already zero'd out buffer. */
SDL_Unsupported();
}
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -0,0 +1,72 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include <emscripten.h>
#include "../../SDL_internal.h"
#include "../SDL_syslocale.h"
void SDL_SYS_GetPreferredLocales(char *buf, size_t buflen)
{
/* *INDENT-OFF* */ /* clang-format off */
EM_ASM({
var buf = $0;
var buflen = $1;
var list = undefined;
if (navigator.languages && navigator.languages.length) {
list = navigator.languages;
} else {
var oneOfThese = navigator.userLanguage || navigator.language || navigator.browserLanguage || navigator.systemLanguage;
if (oneOfThese !== undefined) {
list = [ oneOfThese ];
}
}
if (list === undefined) {
return; /* we've got nothing. */
}
var str = ""; /* Can't do list.join() because we need to fit in buflen. */
for (var i = 0; i < list.length; i++) {
var item = list[i];
if ((str.length + item.length + 1) > buflen) {
break; /* don't add, we're out of space. */
}
if (str.length > 0) {
str += ",";
}
str += item;
}
str = str.replace(/-/g, "_");
if (buflen > str.length) {
buflen = str.length; /* clamp to size of string. */
}
for (var i = 0; i < buflen; i++) {
setValue(buf + i, str.charCodeAt(i), "i8"); /* fill in C array. */
}
}, buf, buflen);
/* *INDENT-ON* */ /* clang-format on */
}
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -0,0 +1,76 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include <AppKit.h>
#include <LocaleRoster.h>
#include <TypeConstants.h>
#include "../../SDL_internal.h"
#include "../SDL_syslocale.h"
void SDL_SYS_GetPreferredLocales(char *buf, size_t buflen)
{
BLocaleRoster *roster = BLocaleRoster::Default();
roster->Refresh();
BMessage msg;
if (roster->GetPreferredLanguages(&msg) != B_OK) {
SDL_SetError("BLocaleRoster couldn't get preferred languages");
return;
}
const char *key = "language";
type_code typ = B_ANY_TYPE;
int32 numlangs = 0;
if ((msg.GetInfo(key, &typ, &numlangs) != B_OK) || (typ != B_STRING_TYPE)) {
SDL_SetError("BLocaleRoster message was wrong");
return;
}
for (int32 i = 0; i < numlangs; i++) {
const char *str = NULL;
if (msg.FindString(key, i, &str) != B_OK) {
continue;
}
const size_t len = SDL_strlen(str);
if (buflen <= len) {
break; // can't fit it, we're done.
}
SDL_strlcpy(buf, str, buflen);
buf += len;
buflen -= len;
if (i < (numlangs - 1)) {
if (buflen <= 1) {
break; // out of room, stop looking.
}
buf[0] = ','; // add a comma between entries.
buf[1] = '\0';
buf++;
buflen--;
}
}
}
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -0,0 +1,77 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
#include "../SDL_syslocale.h"
#import <Foundation/Foundation.h>
void SDL_SYS_GetPreferredLocales(char *buf, size_t buflen)
{
@autoreleasepool {
NSArray *languages = NSLocale.preferredLanguages;
size_t numlangs = 0;
size_t i;
numlangs = (size_t)[languages count];
for (i = 0; i < numlangs; i++) {
NSString *nsstr = [languages objectAtIndex:i];
size_t len;
char *ptr;
if (nsstr == nil) {
break;
}
[nsstr getCString:buf maxLength:buflen encoding:NSASCIIStringEncoding];
len = SDL_strlen(buf);
// convert '-' to '_'...
// These are always full lang-COUNTRY, so we search from the back,
// so things like zh-Hant-CN find the right '-' to convert.
ptr = SDL_strrchr(buf, '-');
if (ptr != NULL) {
*ptr = '_';
}
if (buflen <= len) {
*buf = '\0'; // drop this one and stop, we can't fit anymore.
break;
}
buf += len;
buflen -= len;
if (i < (numlangs - 1)) {
if (buflen <= 1) {
break; // out of room, stop looking.
}
buf[0] = ','; // add a comma between entries.
buf[1] = '\0';
buf++;
buflen--;
}
}
}
}
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -0,0 +1,57 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "../SDL_syslocale.h"
#include "../../SDL_internal.h"
#include <3ds.h>
/* Used when the CFGU fails to work. */
#define BAD_LOCALE 255
SDL_FORCE_INLINE u8 GetLocaleIndex(void);
void SDL_SYS_GetPreferredLocales(char *buf, size_t buflen)
{
/* The 3DS only supports these 12 languages, only one can be active at a time */
static const char AVAILABLE_LOCALES[][6] = { "ja_JP", "en_US", "fr_FR", "de_DE",
"it_IT", "es_ES", "zh_CN", "ko_KR",
"nl_NL", "pt_PT", "ru_RU", "zh_TW" };
u8 current_locale = GetLocaleIndex();
if (current_locale != BAD_LOCALE) {
SDL_strlcpy(buf, AVAILABLE_LOCALES[current_locale], buflen);
}
}
SDL_FORCE_INLINE u8
GetLocaleIndex(void)
{
u8 current_locale;
Result result;
if (R_FAILED(cfguInit())) {
return BAD_LOCALE;
}
result = CFGU_GetSystemLanguage(&current_locale);
cfguExit();
return R_SUCCEEDED(result) ? current_locale : BAD_LOCALE;
}
/* vi: set sts=4 ts=4 sw=4 expandtab: */

View file

@ -0,0 +1,105 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
#include "../SDL_syslocale.h"
static void normalize_locale_str(char *dst, char *str, size_t buflen)
{
char *ptr;
ptr = SDL_strchr(str, '.'); /* chop off encoding if specified. */
if (ptr) {
*ptr = '\0';
}
ptr = SDL_strchr(str, '@'); /* chop off extra bits if specified. */
if (ptr) {
*ptr = '\0';
}
/* The "C" locale isn't useful for our needs, ignore it if you see it. */
if ((str[0] == 'C') && (str[1] == '\0')) {
return;
}
if (*str) {
if (*dst) {
SDL_strlcat(dst, ",", buflen); /* SDL has these split by commas */
}
SDL_strlcat(dst, str, buflen);
}
}
static void normalize_locales(char *dst, char *src, size_t buflen)
{
char *ptr;
/* entries are separated by colons */
while ((ptr = SDL_strchr(src, ':')) != NULL) {
*ptr = '\0';
normalize_locale_str(dst, src, buflen);
src = ptr + 1;
}
normalize_locale_str(dst, src, buflen);
}
void SDL_SYS_GetPreferredLocales(char *buf, size_t buflen)
{
/* !!! FIXME: should we be using setlocale()? Or some D-Bus thing? */
SDL_bool isstack;
const char *envr;
char *tmp;
SDL_assert(buflen > 0);
tmp = SDL_small_alloc(char, buflen, &isstack);
if (!tmp) {
SDL_OutOfMemory();
return;
}
*tmp = '\0';
/* LANG is the primary locale (maybe) */
envr = SDL_getenv("LANG");
if (envr) {
SDL_strlcpy(tmp, envr, buflen);
}
/* fallback languages */
envr = SDL_getenv("LANGUAGE");
if (envr) {
if (*tmp) {
SDL_strlcat(tmp, ":", buflen);
}
SDL_strlcat(tmp, envr, buflen);
}
if (*tmp == '\0') {
SDL_SetError("LANG environment variable isn't set");
} else {
normalize_locales(buf, tmp, buflen);
}
SDL_small_free(tmp, isstack);
}
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -0,0 +1,70 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
#include "../SDL_syslocale.h"
#include <psp2/apputil.h>
#include <psp2/system_param.h>
void SDL_SYS_GetPreferredLocales(char *buf, size_t buflen)
{
const char *vita_locales[] = {
"ja_JP",
"en_US",
"fr_FR",
"es_ES",
"de_DE",
"it_IT",
"nl_NL",
"pt_PT",
"ru_RU",
"ko_KR",
"zh_TW",
"zh_CN",
"fi_FI",
"sv_SE",
"da_DK",
"no_NO",
"pl_PL",
"pt_BR",
"en_GB",
"tr_TR",
};
Sint32 language = SCE_SYSTEM_PARAM_LANG_ENGLISH_US;
SceAppUtilInitParam initParam;
SceAppUtilBootParam bootParam;
SDL_zero(initParam);
SDL_zero(bootParam);
sceAppUtilInit(&initParam, &bootParam);
sceAppUtilSystemParamGetInt(SCE_SYSTEM_PARAM_ID_LANG, &language);
if (language < 0 || language > SCE_SYSTEM_PARAM_LANG_TURKISH) {
language = SCE_SYSTEM_PARAM_LANG_ENGLISH_US; // default to english
}
SDL_strlcpy(buf, vita_locales[language], buflen);
sceAppUtilShutdown();
}
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -0,0 +1,112 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
#include "../../core/windows/SDL_windows.h"
#include "../SDL_syslocale.h"
typedef BOOL(WINAPI *pfnGetUserPreferredUILanguages)(DWORD, PULONG, WCHAR *, PULONG);
#ifndef MUI_LANGUAGE_NAME
#define MUI_LANGUAGE_NAME 0x8
#endif
static pfnGetUserPreferredUILanguages pGetUserPreferredUILanguages = NULL;
static HMODULE kernel32 = 0;
/* this is the fallback for WinXP...one language, not a list. */
static void SDL_SYS_GetPreferredLocales_winxp(char *buf, size_t buflen)
{
char lang[16];
char country[16];
const int langrc = GetLocaleInfoA(LOCALE_USER_DEFAULT,
LOCALE_SISO639LANGNAME,
lang, sizeof(lang));
const int ctryrc = GetLocaleInfoA(LOCALE_USER_DEFAULT,
LOCALE_SISO3166CTRYNAME,
country, sizeof(country));
/* Win95 systems will fail, because they don't have LOCALE_SISO*NAME ... */
if (langrc == 0) {
SDL_SetError("Couldn't obtain language info");
} else {
(void)SDL_snprintf(buf, buflen, "%s%s%s", lang, ctryrc ? "_" : "", ctryrc ? country : "");
}
}
/* this works on Windows Vista and later. */
static void SDL_SYS_GetPreferredLocales_vista(char *buf, size_t buflen)
{
ULONG numlangs = 0;
WCHAR *wbuf = NULL;
ULONG wbuflen = 0;
SDL_bool isstack;
SDL_assert(pGetUserPreferredUILanguages != NULL);
pGetUserPreferredUILanguages(MUI_LANGUAGE_NAME, &numlangs, NULL, &wbuflen);
wbuf = SDL_small_alloc(WCHAR, wbuflen, &isstack);
if (!wbuf) {
SDL_OutOfMemory();
return;
}
if (!pGetUserPreferredUILanguages(MUI_LANGUAGE_NAME, &numlangs, wbuf, &wbuflen)) {
SDL_SYS_GetPreferredLocales_winxp(buf, buflen); /* oh well, try the fallback. */
} else {
const ULONG endidx = (ULONG)SDL_min(buflen, wbuflen - 1);
ULONG str_start = 0;
ULONG i;
for (i = 0; i < endidx; i++) {
const char ch = (char)wbuf[i]; /* these should all be low-ASCII, safe to cast */
if (ch == '\0') {
buf[i] = ','; /* change null separators to commas */
str_start = i;
} else if (ch == '-') {
buf[i] = '_'; /* change '-' to '_' */
} else {
buf[i] = ch; /* copy through as-is. */
}
}
buf[str_start] = '\0'; /* terminate string, chop off final ',' */
}
SDL_small_free(wbuf, isstack);
}
void SDL_SYS_GetPreferredLocales(char *buf, size_t buflen)
{
if (!kernel32) {
kernel32 = GetModuleHandle(TEXT("kernel32.dll"));
if (kernel32) {
pGetUserPreferredUILanguages = (pfnGetUserPreferredUILanguages)GetProcAddress(kernel32, "GetUserPreferredUILanguages");
}
}
if (!pGetUserPreferredUILanguages) {
SDL_SYS_GetPreferredLocales_winxp(buf, buflen); /* this is always available */
} else {
SDL_SYS_GetPreferredLocales_vista(buf, buflen); /* available on Vista and later. */
}
}
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -0,0 +1,55 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include <Windows.h>
#include "../../SDL_internal.h"
#include "../SDL_syslocale.h"
/*using namespace Windows::Graphics::Display;*/
#include <wchar.h>
void SDL_SYS_GetPreferredLocales(char *buf, size_t buflen)
{
WCHAR wbuffer[128] = L"";
int ret = 0;
/* !!! FIXME: do we not have GetUserPreferredUILanguages on WinPhone or UWP? */
#if SDL_WINAPI_FAMILY_PHONE
ret = GetLocaleInfoEx(LOCALE_NAME_SYSTEM_DEFAULT, LOCALE_SNAME, wbuffer, SDL_arraysize(wbuffer));
#else
ret = GetSystemDefaultLocaleName(wbuffer, SDL_arraysize(wbuffer));
#endif
if (ret > 0) {
/* Need to convert LPWSTR to LPSTR, that is wide char to char. */
int i;
if (((size_t)ret) >= (buflen - 1)) {
ret = (int)(buflen - 1);
}
for (i = 0; i < ret; i++) {
buf[i] = (char)wbuffer[i]; /* assume this was ASCII anyhow. */
}
}
}
/* vi: set ts=4 sw=4 expandtab: */