<<< Date Index >>>     <<< Thread Index >>>

Re: mutt/2673: search is case-sensitive when the pattern contains



The following reply was made to PR mutt/2673; it has been noted by GNATS.

From: Thomas Roessler <roessler@xxxxxxxxxxxxxxxxxx>
To: bug-any@xxxxxxxxxxxxx
Cc: 
Subject: Re: mutt/2673: search is case-sensitive when the pattern contains
        an accented character
Date: Tue, 9 Jan 2007 11:32:11 +0100

 mutt_which_case() in pattern.c wasn't multibyte-aware.  Please try
 this patch (untested):
 
 Index: pattern.c
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
 RCS file: /cvs/mutt/mutt/pattern.c,v
 retrieving revision 3.33
 diff -u -r3.33 pattern.c
 --- pattern.c  28 Nov 2006 00:22:16 -0000      3.33
 +++ pattern.c  9 Jan 2007 10:28:01 -0000
 @@ -134,12 +134,22 @@
  /* if no uppercase letters are given, do a case-insensitive search */
  int mutt_which_case (const char *s)
  {
 -  while (*s)
 +  wchar_t w;
 +  mbstate_t mb;
 +  size_t l;
 + =20
 +  memset (&mb, 0, sizeof (mb));
 + =20
 +  for (; (l =3D mbrtowc (&w, s, MB_CUR_MAX, &mb)) !=3D 0; s +=3D l)
    {
 -    if (isalpha ((unsigned char) *s) && isupper ((unsigned char) *s))
 +    if (l =3D=3D (size_t) -2)
 +      continue; /* shift sequences */
 +    if (l =3D=3D (size_t) -1)
 +      return 0; /* error; assume case-sensitive */
 +    if (iswalpha ((wint_t) w) && iswupper ((wint_t) w))
        return 0; /* case-sensitive */
 -    s++;
    }
 +
    return REG_ICASE; /* case-insensitive */
  }
 =20
 
 --=20
 Thomas Roessler   <roessler@xxxxxxxxxxxxxxxxxx>
 
 
 
 
 
 On 2007-01-09 10:27:50 +0100, vincent@xxxxxxxxxx wrote:
 > From: vincent@xxxxxxxxxx
 > To: Mutt Developers <mutt-dev@xxxxxxxx>
 > Date: Tue, 09 Jan 2007 10:27:50 +0100
 > Subject: mutt/2673: search is case-sensitive when the pattern contains an=
  accented character
 > Reply-To: bug-any@xxxxxxxxxxxxx
 > X-Spam-Level:=20
 >=20
 > >Number:         2673
 > >Notify-List:   =20
 > >Category:       mutt
 > >Synopsis:       search is case-sensitive when the pattern contains an ac=
 cented character
 > >Confidential:   no
 > >Severity:       normal
 > >Priority:       medium
 > >Responsible:    mutt-dev
 > >State:          open
 > >Keywords:      =20
 > >Class:          sw-bug
 > >Submitter-Id:   net
 > >Arrival-Date:   Tue Jan 09 10:27:49 +0100 2007
 > >Originator:     Vincent Lefevre
 > >Release:        cvs
 > >Organization:
 > >Environment:
 > Mac OS X 10.4.8
 > >Description:
 > When I search for ~sr=EF=BF=BDunion, messages with R=EF=BF=BDunion in the=
  subject are not found. Such a problem doesn't occur when the characters ar=
 e all ASCII ones.
 > >How-To-Repeat:
 > >Fix:
 > Unknown
 > >Add-To-Audit-Trail:
 >=20
 > >Unformatted:
 >=20
 >=20