Avoid array (string) overlapping.
This commit is contained in:
parent
c2712d8916
commit
7633322d1e
|
@ -32,7 +32,7 @@ void setLanguage(char *applicationName, char *languageCode)
|
||||||
{
|
{
|
||||||
char language[MAX_LINE_LENGTH], c[MAX_LINE_LENGTH];
|
char language[MAX_LINE_LENGTH], c[MAX_LINE_LENGTH];
|
||||||
char *lang, **key, **value;
|
char *lang, **key, **value;
|
||||||
int i, swap;
|
int i, swap, length;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
MOHeader header;
|
MOHeader header;
|
||||||
MOEntry *original, *translation;
|
MOEntry *original, *translation;
|
||||||
|
@ -75,11 +75,15 @@ void setLanguage(char *applicationName, char *languageCode)
|
||||||
STRNCPY(language, languageCode, MAX_LINE_LENGTH);
|
STRNCPY(language, languageCode, MAX_LINE_LENGTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strstr(language, ".") != NULL)
|
length = strlen(language);
|
||||||
{
|
|
||||||
lang = strtok(language, ".");
|
|
||||||
|
|
||||||
STRNCPY(language, lang, MAX_LINE_LENGTH);
|
for (i=0 ; i < length ; i++)
|
||||||
|
{
|
||||||
|
if (language[i] == '.')
|
||||||
|
{
|
||||||
|
language[i] = '\0';
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "Locale is %s", language);
|
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "Locale is %s", language);
|
||||||
|
@ -103,9 +107,17 @@ void setLanguage(char *applicationName, char *languageCode)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
lang = strtok(language, "_");
|
length = strlen(language);
|
||||||
|
|
||||||
STRNCPY(language, lang, MAX_LINE_LENGTH);
|
for (i=0;i<length;i++)
|
||||||
|
{
|
||||||
|
if (language[i] == '_')
|
||||||
|
{
|
||||||
|
language[i] = '\0';
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sprintf(c, "%s/%s/LC_MESSAGES/%s.mo", LOCALE_DIR, language, applicationName);
|
sprintf(c, "%s/%s/LC_MESSAGES/%s.mo", LOCALE_DIR, language, applicationName);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue