/*
- Copyright 2015 IoT.bzh
+ Copyright 2015, 2016, 2017 IoT.bzh
author: José Bollo <jose.bollo@iot.bzh>
struct wgt {
int refcount;
int rootfd;
- int nrlocales;
+ unsigned int nrlocales;
char **locales;
};
* Adds if needed the locale 'locstr' of 'length'
* to the list of locales.
*/
-static int locadd(struct wgt *wgt, const char *locstr, int length)
+static int locadd(struct wgt *wgt, const char *locstr, size_t length)
{
- int i;
+ unsigned int i;
char *item, **ptr;
item = strndup(locstr, length);
if (item != NULL) {
/* normalize in lower case */
for (i = 0 ; item[i] ; i++)
- item[i] = tolower(item[i]);
+ item[i] = (char)tolower(item[i]);
/* search it (no duplication) */
for (i = 0 ; i < wgt->nrlocales ; i++)
next = stop + !!*stop;
/* iterate variant of languages in reverse order */
while (locstr != stop) {
- if (locadd(wgt, locstr, stop - locstr))
+ if (locadd(wgt, locstr, (size_t)(stop - locstr)))
return -1;
do { stop--; } while(stop > locstr && *stop != '-');
}
* The lower result means the higher priority of the language.
* The returned value of 0 is the top first priority.
*/
-int wgt_locales_score(struct wgt *wgt, const char *lang)
+unsigned int wgt_locales_score(struct wgt *wgt, const char *lang)
{
- int i;
+ unsigned int i;
assert(wgt);
if (lang)
if (!strcasecmp(lang, wgt->locales[i]))
return i;
- return INT_MAX;
+ return UINT_MAX;
}
/*
*/
static const char *localize(struct wgt *wgt, const char *filename, char path[PATH_MAX])
{
- int i;
+ unsigned int i;
/* get the normalized name */
filename = normalsubpath(filename);