Mend compile-time warnings in locale_to_closest_locale

Also, not currently used except for macOS, so wrapping in #ifdef
to avoid "defined but not used" warning.
This commit is contained in:
Bill Kendrick 2022-02-09 22:06:14 -08:00
parent 110cdeaa6a
commit b60a4ec4d1

View file

@ -4,7 +4,7 @@
For Tux Paint
Language-related functions
Copyright (c) 2002-2020 by Bill Kendrick and others
Copyright (c) 2002-2022 by Bill Kendrick and others
bill@newbreedsoftware.com
http://www.tuxpaint.org/
@ -25,7 +25,7 @@
$Id$
June 14, 2002 - October 25, 2021
June 14, 2002 - February 9, 2022
*/
#include <stdio.h>
@ -818,6 +818,9 @@ static const char *language_to_locale(const char *langstr)
return NULL;
}
#if defined(__APPLE__)
/**
* For a given locale, return the known locale that matches it closest, or exit
* with a usage error.
@ -834,11 +837,11 @@ static const char *locale_to_closest_locale(const char *inlocale)
int j = 0;
/* find the locale with the longest string match */
for (i=0; i<numlocale; i++)
for (i = 0; i < numlocale; i++)
{
const char* candidate = language_to_locale_array[i].locale;
for (j=0; j<strlen(inlocale) && j<strlen(candidate); j++)
for (j = 0; j < (int) strlen(inlocale) && j < (int) strlen(candidate); j++)
{
if(inlocale[j] != candidate[j]) break;
}
@ -859,6 +862,9 @@ static const char *locale_to_closest_locale(const char *inlocale)
return outlocale;
}
#endif
/**
* Set language ("langint" global) based on a given locale;
* will try a few ways of checking, is case-insensitive, etc.