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 *lang, **key, **value;
|
||||
int i, swap;
|
||||
int i, swap, length;
|
||||
FILE *fp;
|
||||
MOHeader header;
|
||||
MOEntry *original, *translation;
|
||||
|
@ -75,11 +75,15 @@ void setLanguage(char *applicationName, char *languageCode)
|
|||
STRNCPY(language, languageCode, MAX_LINE_LENGTH);
|
||||
}
|
||||
|
||||
if (strstr(language, ".") != NULL)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
lang = strtok(language, "_");
|
||||
|
||||
STRNCPY(language, lang, MAX_LINE_LENGTH);
|
||||
length = strlen(language);
|
||||
|
||||
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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue