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

    Resolves the directionality of neutral character types.

    Implements rules W7, N1 and N2 of the Unicode Bidi Algorithm.

    Input: Array of embedding levels
           Character count
           Baselevel

    In/Out: Array of directional classes

    Note: On input only these directional classes are expected
          R,  L,  N, AN, EN and BN

          W8 resolves a number of ENs to L
------------------------------------------------------------------------*/
resolveNeutrals
Resolves the directionality of neutral character types.

Implements rules W7, N1 and N2 of the Unicode Bidi Algorithm.

Array of embedding levels
Character count
Baselevel

In/Out: Array of directional classes

On input only these directional classes are expected
R,  L,  N, AN, EN and BN

W8 resolves a number of ENs to L
resolveNeutrals Resolves the directionality of neutral character types . Implements rules W7 N1 and N2 of the Unicode Bidi Algorithm . Array of embedding levels Character count Baselevel In / Out : Array of directional classes On input only these directional classes are expected R L N AN EN and BN W8 resolves a number of ENs to L
static void resolveNeutrals(int baselevel, WORD *pcls, const WORD *plevel, int cch)
{
    int state = odd(baselevel) ? r : l;
    int cls;
    int cchRun = 0;
    int level = baselevel;
    int action, clsRun, clsNew;
    int ich = 0;
    for (; ich < cch; ich++)
    {
        if (pcls[ich] == BN)
        {
            if (cchRun)
                cchRun++;
            continue;
        }
        ASSERT(pcls[ich] < 5); 
        cls = pcls[ich];
        action = actionNeutrals[state][cls];
        clsRun = GetDeferredNeutrals(action, level);
        if (clsRun != N)
        {
            SetDeferredRun(pcls, cchRun, ich, clsRun);
            cchRun = 0;
        }
        clsNew = GetResolvedNeutrals(action);
        if (clsNew != N)
            pcls[ich] = clsNew;
        if (In & action)
            cchRun++;
        state = stateNeutrals[state][cls];
        level = plevel[ich];
    }
    cls = EmbeddingDirection(level);    
    clsRun = GetDeferredNeutrals(actionNeutrals[state][cls], level);
    if (clsRun != N)
        SetDeferredRun(pcls, cchRun, ich, clsRun);
}
static void resolveNeutrals ( int baselevel , WORD * pcls , const WORD * plevel , int cch ) { int state = odd ( baselevel ) ? r : l ; int cls ; int cchRun = 0 ; int level = baselevel ; int action , clsRun , clsNew ; int ich = 0 ; for ( ; ich < cch ; ich ++ ) { if ( pcls [ ich ] == BN ) { if ( cchRun ) cchRun ++ ; continue ; } ASSERT ( pcls [ ich ] < 5 ) ; cls = pcls [ ich ] ; action = actionNeutrals [ state ] [ cls ] ; clsRun = GetDeferredNeutrals ( action , level ) ; if ( clsRun != N ) { SetDeferredRun ( pcls , cchRun , ich , clsRun ) ; cchRun = 0 ; } clsNew = GetResolvedNeutrals ( action ) ; if ( clsNew != N ) pcls [ ich ] = clsNew ; if ( In & action ) cchRun ++ ; state = stateNeutrals [ state ] [ cls ] ; level = plevel [ ich ] ; } cls = EmbeddingDirection ( level ) ; clsRun = GetDeferredNeutrals ( actionNeutrals [ state ] [ cls ] , level ) ; if ( clsRun != N ) SetDeferredRun ( pcls , cchRun , ich , clsRun ) ; }
Function: resolveNeutrals
Resolves the directionality of neutral character types.
Function : resolveNeutrals Resolves the directionality of neutral character types .
/* the state at the start of text depends on the base level */ /* ignore boundary neutrals */ /* include in the count for a deferred run */ /* skip any further processing */ /* "Only N, L, R,  AN, EN are allowed" */ /* resolve the directionality for deferred runs */ /* resolve the directionality class at the current location */ /* resolve any deferred runs */ /* eor has type of current level */ /* resolve the directionality for deferred runs */