dlls/usp10/bidi.c
/*------------------------------------------------------------------------
    Function: resolveWeak

    Resolves the directionality of numeric and other weak character types

    Implements rules X10 and W1-W6 of the Unicode Bidirectional Algorithm.

    Input: Array of embedding levels
           Character count

    In/Out: Array of directional classes

    Note: On input only these directional classes are expected
          AL, HL, R, L,  ON, BN, NSM, AN, EN, ES, ET, CS,
------------------------------------------------------------------------*/
resolveWeak
Resolves the directionality of numeric and other weak character types

Implements rules X10 and W1-W6 of the Unicode Bidirectional Algorithm.

Array of embedding levels
Character count

In/Out: Array of directional classes


resolveWeak Resolves the directionality of numeric and other weak character types Implements rules X10 and W1 - W6 of the Unicode Bidirectional Algorithm . Array of embedding levels Character count In / Out : Array of directional classes
static void resolveWeak(int baselevel, WORD *pcls, WORD *plevel, int cch)
{
    int state = odd(baselevel) ? xr : xl;
    int cls;
    int level = baselevel;
    int action, clsRun, clsNew;
    int cchRun = 0;
    int ich = 0;
    for (; ich < cch; ich++)
    {
        if (pcls[ich] == BN)
        {
            plevel[ich] = level;
            if (ich + 1 == cch && level != baselevel)
            {
                pcls[ich] = EmbeddingDirection(level);
            }
            else if (ich + 1 < cch && level != plevel[ich+1] && pcls[ich+1] != BN)
            {
                int newlevel = plevel[ich+1];
                if (level > newlevel) {
                    newlevel = level;
                }
                plevel[ich] = newlevel;
                pcls[ich] = EmbeddingDirection(newlevel);
                level = plevel[ich+1];
            }
            else
            {
                if (cchRun)
                {
                    cchRun++;
                }
                continue;
            }
        }
        ASSERT(pcls[ich] <= BN);
        cls = pcls[ich];
        action = actionWeak[state][cls];
        clsRun = GetDeferredType(action);
        if (clsRun != XX)
        {
            SetDeferredRun(pcls, cchRun, ich, clsRun);
            cchRun = 0;
        }
        clsNew = GetResolvedType(action);
        if (clsNew != XX)
            pcls[ich] = clsNew;
        if (IX & action)
            cchRun++;
        state = stateWeak[state][cls];
    }
    cls = EmbeddingDirection(level);
    clsRun = GetDeferredType(actionWeak[state][cls]);
    if (clsRun != XX)
        SetDeferredRun(pcls, cchRun, ich, clsRun);
}
static void resolveWeak ( int baselevel , WORD * pcls , WORD * plevel , int cch ) { int state = odd ( baselevel ) ? xr : xl ; int cls ; int level = baselevel ; int action , clsRun , clsNew ; int cchRun = 0 ; int ich = 0 ; for ( ; ich < cch ; ich ++ ) { if ( pcls [ ich ] == BN ) { plevel [ ich ] = level ; if ( ich + 1 == cch && level != baselevel ) { pcls [ ich ] = EmbeddingDirection ( level ) ; } else if ( ich + 1 < cch && level != plevel [ ich + 1 ] && pcls [ ich + 1 ] != BN ) { int newlevel = plevel [ ich + 1 ] ; if ( level > newlevel ) { newlevel = level ; } plevel [ ich ] = newlevel ; pcls [ ich ] = EmbeddingDirection ( newlevel ) ; level = plevel [ ich + 1 ] ; } else { if ( cchRun ) { cchRun ++ ; } continue ; } } ASSERT ( pcls [ ich ] <= BN ) ; cls = pcls [ ich ] ; action = actionWeak [ state ] [ cls ] ; clsRun = GetDeferredType ( action ) ; if ( clsRun != XX ) { SetDeferredRun ( pcls , cchRun , ich , clsRun ) ; cchRun = 0 ; } clsNew = GetResolvedType ( action ) ; if ( clsNew != XX ) pcls [ ich ] = clsNew ; if ( IX & action ) cchRun ++ ; state = stateWeak [ state ] [ cls ] ; } cls = EmbeddingDirection ( level ) ; clsRun = GetDeferredType ( actionWeak [ state ] [ cls ] ) ; if ( clsRun != XX ) SetDeferredRun ( pcls , cchRun , ich , clsRun ) ; }
Function: resolveWeak
Resolves the directionality of numeric and other weak character types
Function : resolveWeak Resolves the directionality of numeric and other weak character types
/* ignore boundary neutrals */ /* must flatten levels unless at a level change; */ /* lookahead for level changes */ /* have to fixup last BN before end of the loop, since
                 * its fix-upped value will be needed below the assert */ /* fixup LAST BN in front / after a level run to make
                 * it act like the SOR/EOR in rule X10 */ /* must match assigned level */ /* don't interrupt runs */ /* resolve the directionality for deferred runs */ /* resolve the directionality class at the current location */ /* increment a deferred run */ /* resolve any deferred runs
     * use the direction of the current level to emulate PDF */ /* resolve the directionality for deferred runs */