Exemplo n.º 1
0
int
wcsncasecmp_l(const wchar_t *s1, const wchar_t *s2, size_t n, locale_t loc)
{
	int lc1  = 0;
	int lc2  = 0;
	int diff = 0;

	_DIAGASSERT(s1);
	_DIAGASSERT(s2);

	while (n--) {
		lc1 = towlower_l(*s1, loc);
		lc2 = towlower_l(*s2, loc);

		diff = lc1 - lc2;
		if (diff)
			return diff;

		if (!lc1)
			return 0;

		++s1;
		++s2;
	}

	return 0;
}
Exemplo n.º 2
0
int wcscasecmp_l(__CONST wchar_t *s1, 
	__CONST wchar_t *s2, locale_t locale)
{
  int d = 0;
  for ( ; ; )
    {
      __CONST int c1 = towlower_l (*s1++, locale);
      __CONST int c2 = towlower_l (*s2++, locale);
      if (((d = c1 - c2) != 0) || (c2 == '\0'))
        break;
    }
  return d;
}
Exemplo n.º 3
0
int
wcscasecmp_l(const wchar_t *s1, const wchar_t *s2, locale_t loc)
{
	wchar_t c1, c2;

	for (; *s1; s1++, s2++) {
		c1 = towlower_l(*s1, loc);
		c2 = towlower_l(*s2, loc);
		if (c1 != c2)
			return ((int)c1 - c2);
	}
	return (-*s2);
}
Exemplo n.º 4
0
 virtual std::string convert(converter_base::conversion_type how,char const *begin,char const *end,int flags = 0) const 
 {
     switch(how) {
     case upper_case:
         {
             std::wstring tmp = conv::to_utf<wchar_t>(begin,end,"UTF-8");
             std::wstring wres;
             wres.reserve(tmp.size());
             for(unsigned i=0;i<tmp.size();i++)
                 wres+=towupper_l(tmp[i],*lc_);
             return conv::from_utf<wchar_t>(wres,"UTF-8");
         }
         
     case lower_case:
     case case_folding:
         {
             std::wstring tmp = conv::to_utf<wchar_t>(begin,end,"UTF-8");
             std::wstring wres;
             wres.reserve(tmp.size());
             for(unsigned i=0;i<tmp.size();i++)
                 wres+=towlower_l(tmp[i],*lc_);
             return conv::from_utf<wchar_t>(wres,"UTF-8");
         }
     default:
         return std::string(begin,end-begin);
     }
 }
Exemplo n.º 5
0
void testValues() {
    f = 2;
    wint_t result;
    
    result = towlower_l(anychar(), locale());

    //@ assert f == 2;
    //@ assert vacuous: \false;
}
Exemplo n.º 6
0
wint_t
towctrans_l(wint_t wc, wctrans_t desc, locale_t locale)
{
	switch (desc) {
	case _WCT_TOLOWER:
		wc = towlower_l(wc, locale);
		break;
	case _WCT_TOUPPER:
		wc = towupper_l(wc, locale);
		break;
	case _WCT_ERROR:
	default:
		errno = EINVAL;
		break;
	}

	return (wc);
}
Exemplo n.º 7
0
static pg_wchar
pg_wc_tolower(pg_wchar c)
{
	switch (pg_regex_strategy)
	{
		case PG_REGEX_LOCALE_C:
			if (c <= (pg_wchar) 127)
				return pg_ascii_tolower((unsigned char) c);
			return c;
		case PG_REGEX_LOCALE_WIDE:
			/* force C behavior for ASCII characters, per comments above */
			if (c <= (pg_wchar) 127)
				return pg_ascii_tolower((unsigned char) c);
#ifdef USE_WIDE_UPPER_LOWER
			if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
				return towlower((wint_t) c);
#endif
			/* FALL THRU */
		case PG_REGEX_LOCALE_1BYTE:
			/* force C behavior for ASCII characters, per comments above */
			if (c <= (pg_wchar) 127)
				return pg_ascii_tolower((unsigned char) c);
			if (c <= (pg_wchar) UCHAR_MAX)
				return tolower((unsigned char) c);
			return c;
		case PG_REGEX_LOCALE_WIDE_L:
#if defined(HAVE_LOCALE_T) && defined(USE_WIDE_UPPER_LOWER)
			if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
				return towlower_l((wint_t) c, pg_regex_locale);
#endif
			/* FALL THRU */
		case PG_REGEX_LOCALE_1BYTE_L:
#ifdef HAVE_LOCALE_T
			if (c <= (pg_wchar) UCHAR_MAX)
				return tolower_l((unsigned char) c, pg_regex_locale);
#endif
			return c;
	}
	return 0;					/* can't get here, but keep compiler quiet */
}
Exemplo n.º 8
0
void wctype_check_functions(wint_t i, wctype_t t, wctrans_t tr, locale_t l)
{
    (void)iswalnum(i);
    (void)iswalnum_l(i, l);
    (void)iswalpha(i);
    (void)iswalpha_l(i, l);
    (void)iswblank(i);
    (void)iswblank_l(i, l);
    (void)iswcntrl(i);
    (void)iswcntrl_l(i, l);
    (void)iswctype(i, t);
    (void)iswctype_l(i, t, l);
    (void)iswdigit(i);
    (void)iswdigit_l(i, l);
    (void)iswgraph(i);
    (void)iswgraph_l(i, l);
    (void)iswlower(i);
    (void)iswlower_l(i, l);
    (void)iswprint(i);
    (void)iswprint_l(i, l);
    (void)iswpunct(i);
    (void)iswpunct_l(i, l);
    (void)iswspace(i);
    (void)iswspace_l(i, l);
    (void)iswupper(i);
    (void)iswupper_l(i, l);
    (void)iswxdigit(i);
    (void)iswxdigit_l(i, l);
    (void)towctrans(i, tr);
    (void)towctrans_l(i, tr, l);
    (void)towlower(i);
    (void)towlower_l(i, l);
    (void)towupper(i);
    (void)towupper_l(i, l);
    (void)wctrans((const char *)1234);
    (void)wctrans_l((const char *)1234, l);
    (void)wctype((const char *)1234);
    (void)wctype_l((const char *)1234, l);
}
Exemplo n.º 9
0
/**
 * Downcase the first letter of the word.
 * XXX FIXME This works 'most of the time', but is not technically correct.
 * This is because towlower() and towupper() are locale dependent, and also
 * because the byte-counts might not match up, e.g. German ß and SS.
 * The correct long-term fix is to use ICU or glib g_utf8_strup(), etc.
 */
void downcase_utf8_str(char *to, const char * from, size_t usize, locale_t locale)
{
	wchar_t c;
	int i, nbl, nbh;
	char low[MB_LEN_MAX];
	mbstate_t mbs;

	/* Make sure it doesn't contain garbage in case of an error */
	if (to != from) strcpy(to, from);

	memset(&mbs, 0, sizeof(mbs));
	nbh = mbrtowc (&c, from, MB_CUR_MAX, &mbs);
	if (nbh < 0)
	{
		prt_error("Error: Invalid UTF-8 string!\n");
		return;
	}
	c = towlower_l(c, locale);
	nbl = wctomb_check(low, c);

	/* Check for error on an in-place copy */
	if ((nbh < nbl) && (to == from))
	{
		/* I'm to lazy to fix this */
		prt_error("Error: can't downcase UTF-8 string!\n");
		return;
	}

	/* Downcase */
	for (i=0; i<nbl; i++) { to[i] = low[i]; }

	if ((nbh == nbl) && (to == from)) return;

	from += nbh;
	to += nbl;
	safe_strcpy(to, from, usize-nbl);
}
Exemplo n.º 10
0
wint_t towlower(wint_t wc)
{
	return towlower_l(wc, __UCLIBC_CURLOCALE);
}
Exemplo n.º 11
0
 static wchar_t lower(wchar_t c,locale_t lc)
 {
     return towlower_l(c,lc);
 }
Exemplo n.º 12
0
void runFailure() {
    towlower_l(invalid(), locale());
}
Exemplo n.º 13
0
void runSuccess() {
    towlower_l(WEOF, locale());
    towlower_l(anychar(), locale());
}