30 |
# include <sys/time.h> |
# include <sys/time.h> |
31 |
# include <sys/resource.h> |
# include <sys/resource.h> |
32 |
#endif |
#endif |
33 |
|
#if defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H && defined HAVE_MBRTOWC |
34 |
|
/* We can handle multibyte string. */ |
35 |
|
# define MBS_SUPPORT |
36 |
|
# include <wchar.h> |
37 |
|
# include <wctype.h> |
38 |
|
#endif |
39 |
#include <stdio.h> |
#include <stdio.h> |
40 |
#include "system.h" |
#include "system.h" |
41 |
#include "getopt.h" |
#include "getopt.h" |
1735 |
if (!install_matcher (matcher) && !install_matcher ("default")) |
if (!install_matcher (matcher) && !install_matcher ("default")) |
1736 |
abort (); |
abort (); |
1737 |
|
|
1738 |
|
#ifdef MBS_SUPPORT |
1739 |
|
if (MB_CUR_MAX != 1 && match_icase) |
1740 |
|
{ |
1741 |
|
wchar_t wc; |
1742 |
|
mbstate_t cur_state, prev_state; |
1743 |
|
int i, len = strlen(keys); |
1744 |
|
|
1745 |
|
memset(&cur_state, 0, sizeof(mbstate_t)); |
1746 |
|
for (i = 0; i <= len ;) |
1747 |
|
{ |
1748 |
|
size_t mbclen; |
1749 |
|
mbclen = mbrtowc(&wc, keys + i, len - i, &cur_state); |
1750 |
|
if (mbclen == (size_t) -1 || mbclen == (size_t) -2 || mbclen == 0) |
1751 |
|
{ |
1752 |
|
/* An invalid sequence, or a truncated multibyte character. |
1753 |
|
We treat it as a singlebyte character. */ |
1754 |
|
mbclen = 1; |
1755 |
|
} |
1756 |
|
else |
1757 |
|
{ |
1758 |
|
if (iswupper((wint_t)wc)) |
1759 |
|
{ |
1760 |
|
wc = towlower((wint_t)wc); |
1761 |
|
wcrtomb(keys + i, wc, &cur_state); |
1762 |
|
} |
1763 |
|
} |
1764 |
|
i += mbclen; |
1765 |
|
} |
1766 |
|
} |
1767 |
|
#endif /* MBS_SUPPORT */ |
1768 |
|
|
1769 |
(*compile)(keys, keycc); |
(*compile)(keys, keycc); |
1770 |
|
|
1771 |
if ((argc - optind > 1 && !no_filenames) || with_filenames) |
if ((argc - optind > 1 && !no_filenames) || with_filenames) |