Ignore:
Timestamp:
May 25, 2018, 4:38:54 AM (7 years ago)
Author:
rlwalsh
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/helpers/nls.c

    r390 r439  
    281281    // we're on DBCS:
    282282
    283     // we can't find c if it is a leading byte
    284     if (G_afLeadByte[c] != TYPE_SBCS)
     283    // we can't find c if it is a DBCS lead byte
     284    if (G_afLeadByte[c])
    285285        return NULL;
    286286
     
    289289         ++p2)
    290290    {
    291         // check _previous_ DBCS type and refresh
    292         // DBCS type accordingly
     291        // Set current DBCS scan state based of _previous_ DBCS scan state
    293292        switch (ulDBCSType)
    294293        {
    295             case TYPE_SBCS:
    296             case TYPE_DBCS_2ND:
    297                 ulDBCSType = G_afLeadByte[*p2];
    298                 // we can safely do the test here (and skip rechecking
    299                 // the type) because c can't possibly be a leading byte
    300                 // V0.9.20 (2002-07-22) [lafaix]
    301                 if (*p2 == c)
    302                     return (PSZ)p2;
    303             break;
    304 
    305294            case TYPE_DBCS_1ST :
    306295                ulDBCSType = TYPE_DBCS_2ND;
    307296            break;
     297            case TYPE_SBCS:
     298                if (G_afLeadByte[*p2])
     299                    ulDBCSType = TYPE_DBCS_1ST;
     300                break;
    308301        }
    309     }
    310 
    311     /*  old code V0.9.20 (2002-07-22) [umoeller]
    312     // we're on DBCS:
    313     for (p2 = p;
    314          *p2;
    315          ++p2)
    316     {
     302
     303        if (ulDBCSType != TYPE_DBCS_1ST) {
    317304        if (*p2 == c)
    318         {
    319             // match: return this only if it's SBCS;
    320             // if it's a DBCS lead char, skip it
    321             switch (ulDBCS = nlsQueryDBCSChar(p, p2 - p))
    322             {
    323                 case TYPE_SBCS:
    324305                    return (PSZ)p2;
    325 
    326                 case TYPE_DBCS_1ST:
    327                     ++p2;
     306            ulDBCSType = TYPE_SBCS;     // Ensure next char checked for DBCS lead
    328307            }
    329         }
    330     }
    331     */
     308
     309    } // for
    332310
    333311    return NULL;
Note: See TracChangeset for help on using the changeset viewer.