Ignore:
Timestamp:
May 25, 2018, 3:57:47 AM (7 years ago)
Author:
rlwalsh
Message:

nls: fix DBCS handling in nlschr()
patch from Steve Levine

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/branch-1-0/src/helpers/nls.c

    r386 r437  
    262262    // we're on DBCS:
    263263
    264     // we can't find c if it is a leading byte
    265     if (G_afLeadByte[c] != TYPE_SBCS)
     264    // we can't find c if it is a DBCS lead byte
     265    if (G_afLeadByte[c])
    266266        return NULL;
    267267
     
    270270         ++p2)
    271271    {
    272         // check _previous_ DBCS type and refresh
    273         // DBCS type accordingly
     272        // Set current DBCS scan state based of _previous_ DBCS scan state
    274273        switch (ulDBCSType)
    275274        {
    276             case TYPE_SBCS:
    277             case TYPE_DBCS_2ND:
    278                 ulDBCSType = G_afLeadByte[*p2];
    279                 // we can safely do the test here (and skip rechecking
    280                 // the type) because c can't possibly be a leading byte
    281                 // V0.9.20 (2002-07-22) [lafaix]
    282                 if (*p2 == c)
    283                     return (PSZ)p2;
    284             break;
    285 
    286275            case TYPE_DBCS_1ST :
    287276                ulDBCSType = TYPE_DBCS_2ND;
    288277            break;
    289         }
    290     }
    291 
    292     /*  old code V0.9.20 (2002-07-22) [umoeller]
    293     // we're on DBCS:
    294     for (p2 = p;
    295          *p2;
    296          ++p2)
    297     {
     278            case TYPE_SBCS:
     279                if (G_afLeadByte[*p2])
     280                    ulDBCSType = TYPE_DBCS_1ST;
     281                break;
     282        }
     283
     284        if (ulDBCSType != TYPE_DBCS_1ST) {
    298285        if (*p2 == c)
    299         {
    300             // match: return this only if it's SBCS;
    301             // if it's a DBCS lead char, skip it
    302             switch (ulDBCS = nlsQueryDBCSChar(p, p2 - p))
    303             {
    304                 case TYPE_SBCS:
    305286                    return (PSZ)p2;
    306 
    307                 case TYPE_DBCS_1ST:
    308                     ++p2;
     287            ulDBCSType = TYPE_SBCS;     // Ensure next char checked for DBCS lead
    309288            }
    310         }
    311     }
    312     */
     289
     290    } // for
    313291
    314292    return NULL;
Note: See TracChangeset for help on using the changeset viewer.