This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Q about ctype.narrow


Martin Sebor wrote:

...
/* out-of-line */ char*
ctype<char>::__narrow(char* lo, char* hi, char dfault, char* dest)
{
  if (cache_empty) {
       const char s[] = { 0, ..., UCHAR_MAX };
       do_narrow (s, s + sizeof s, 0, cache);
       cache_consecutive = !memchr (cache + 1, 0, sizeof cache - 1);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Oops, it's not that simple. Make that

         cache_consecutive = true;
         for (char *pc = cache + 1; pc != cache + UCHAR_MAX; ++pc)
             if (pc [0] != pc [-1] + 1) {
                  cache_consecutive = false;
                  break;
             }

Martin



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]