void xlocale2_check_functions(nl_item ni, locale_t l)
{
    /* ctype.h */
    (void)isalnum_l(0, l);
    (void)isdigit_l(0, l);
    (void)isxdigit_l(0, l);
    /* inttypes.h */
    (void)strtoimax_l("", (char**)1234, 10, l);
    /* langinfo.h */
    (void)nl_langinfo_l(ni, l);
    /* monetary.h */
    (void)strfmon_l((char*)1234, (size_t)0, l, "%n", 0.0);
    /* stdio.h */
    (void)printf_l(l, "%d", 0);
    /* stdlib.h */
    (void)strtol_l("", (char**)1234, 10, l);
    /* string.h */
    (void)strcoll_l("", "", l);
    /* time.h */
    (void)strftime_l((char*)1234, (size_t)0, "%s", (const struct tm *)1234, l);
    /* wchar.h */
    (void)wcstol_l(L"", (wchar_t**)1234, 10, l);
    /* wctype.h */
    (void)iswalnum_l((wint_t)0, l);
    (void)iswdigit_l((wint_t)0, l);
    (void)iswxdigit_l((wint_t)0, l);
}
Exemple #2
0
int __collate_range_cmp(struct xlocale_collate *table, int c1, int c2)
{
	static char s1[2], s2[2];

	s1[0] = c1;
	s2[0] = c2;
	struct _xlocale l = {{0}};
	l.components[XLC_COLLATE] = (struct xlocale_component *)table;
	return (strcoll_l(s1, s2, &l));
}
Exemple #3
0
/* Collate */
int _Locale_strcmp(struct _Locale_collate * __loc,
                   const char *s1, size_t n1,
		   const char *s2, size_t n2) {
  int ret;
  char buf1[64], buf2[64];
  while (n1 > 0 && n2 > 0) {
    size_t bufsize1 = n1 < 63 ? n1 : 63;
    size_t bufsize2 = n2 < 63 ? n2 : 63;
    strncpy(buf1, s1, bufsize1); buf1[bufsize1] = 0;
    strncpy(buf2, s2, bufsize2); buf2[bufsize2] = 0;

    ret = strcoll_l(buf1, buf2, (__c_locale)__loc);
    if (ret != 0) return ret;
    s1 += bufsize1; n1 -= bufsize1;
    s2 += bufsize2; n2 -= bufsize2;
  }
  return ret;
}
Exemple #4
0
/*
 * Placeholder implementation of wcscoll(). Attempts to use the single-byte
 * collation ordering where possible, and falls back on wcscmp() in locales
 * with extended character sets.
 */
int
wcscoll_l(const wchar_t *ws1, const wchar_t *ws2, locale_t locale)
{
	char *mbs1, *mbs2;
	int diff, sverrno;
	FIX_LOCALE(locale);
	struct xlocale_collate *table =
		(struct xlocale_collate*)locale->components[XLC_COLLATE];

	if (table->__collate_load_error || MB_CUR_MAX > 1)
		/*
		 * Locale has no special collating order, could not be
		 * loaded, or has an extended character set; do a fast binary
		 * comparison.
		 */
		return (wcscmp(ws1, ws2));

	if ((mbs1 = __mbsdup(ws1)) == NULL || (mbs2 = __mbsdup(ws2)) == NULL) {
		/*
		 * Out of memory or illegal wide chars; fall back to wcscmp()
		 * but leave errno indicating the error. Callers that don't
		 * check for error will get a reasonable but often slightly
		 * incorrect result.
		 */
		sverrno = errno;
		free(mbs1);
		errno = sverrno;
		return (wcscmp(ws1, ws2));
	}

	diff = strcoll_l(mbs1, mbs2, locale);
	sverrno = errno;
	free(mbs1);
	free(mbs2);
	errno = sverrno;

	return (diff);
}
Exemple #5
0
int
strcoll(const char *s, const char *s2)
{
	return strcoll_l(s, s2, __current_locale());
}
Exemple #6
0
 static size_t coll(char const *left,char const *right,locale_t l)
 {
     return strcoll_l(left,right,l);
 }
Exemple #7
0
int
strcoll(const char *s1, const char *s2)
{
	return (strcoll_l(s1, s2, uselocale(NULL)));
}