/[grep]/grep/src/grep.c
ViewVC logotype

Diff of /grep/src/grep.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.89 by kasal, Wed Dec 15 14:33:38 2004 UTC revision 1.90 by kasal, Thu Dec 16 07:18:15 2004 UTC
# Line 30  Line 30 
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"
# Line 1729  warranty; not even for MERCHANTABILITY o Line 1735  warranty; not even for MERCHANTABILITY o
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)

Legend:
Removed from v.1.89  
changed lines
  Added in v.1.90

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26