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

    Recursively resolves explicit embedding levels and overrides.
    Implements rules X1-X9, of the Unicode Bidirectional Algorithm.

    Input: Base embedding level and direction
           Character count

    Output: Array of embedding levels

    In/Out: Array of direction classes


    Note: The function uses two simple counters to keep track of
          matching explicit codes and PDF. Use the default argument for
          the outermost call. The nesting counter counts the recursion
          depth and not the embedding level.
------------------------------------------------------------------------*/
resolveExplicit
Recursively resolves explicit embedding levels and overrides.
Implements rules X1-X9, of the Unicode Bidirectional Algorithm.

Base embedding level and direction
Character count

Array of embedding levels

In/Out: Array of direction classes

The function uses two simple counters to keep track of
matching explicit codes and PDF. Use the default argument for
the outermost call. The nesting counter counts the recursion
depth and not the embedding level.
resolveExplicit Recursively resolves explicit embedding levels and overrides . Implements rules X1 - X9 of the Unicode Bidirectional Algorithm . Base embedding level and direction Character count Array of embedding levels In / Out : Array of direction classes The function uses two simple counters to keep track of matching explicit codes and PDF . Use the default argument for the outermost call . The nesting counter counts the recursion depth and not the embedding level .
static int resolveExplicit(int level, int dir, WORD *pcls, WORD *plevel, int cch, int nNest)
{
    int nLastValid = nNest;
    int ich = 0;
    ASSERT(nNest >= 0 && level >= 0 && level <= MAX_LEVEL);
    for (; ich < cch; ich++)
    {
        WORD cls = pcls[ich];
        switch (cls)
        {
        case LRO:
        case LRE:
            nNest++;
            if (GreaterEven(level) <= MAX_LEVEL - (cls == LRO ? 2 : 0))
            {
                plevel[ich] = GreaterEven(level);
                pcls[ich] = BN;
                ich += resolveExplicit(plevel[ich], (cls == LRE ? N : L),
                            &pcls[ich+1], &plevel[ich+1],
                             cch - (ich+1), nNest);
                nNest--;
                continue;
            }
            cls = pcls[ich] = BN;
            break;
        case RLO:
        case RLE:
            nNest++;
            if (GreaterOdd(level) <= MAX_LEVEL - (cls == RLO ? 2 : 0))
            {
                plevel[ich] = GreaterOdd(level);
                pcls[ich] = BN;
                ich += resolveExplicit(plevel[ich], (cls == RLE ? N : R),
                                &pcls[ich+1], &plevel[ich+1],
                                 cch - (ich+1), nNest);
                nNest--;
                continue;
            }
            cls = pcls[ich] = BN;
            break;
        case PDF:
            cls = pcls[ich] = BN;
            if (nNest)
            {
                if (nLastValid < nNest)
                {
                    nNest--;
                }
                else
                {
                    cch = ich; 
                }
            }
        }
        if (dir != N)
        {
            cls = dir;
        }
        plevel[ich] = level;
        if (pcls[ich] != BN)
            pcls[ich] = cls;
    }
    return ich;
}
static int resolveExplicit ( int level , int dir , WORD * pcls , WORD * plevel , int cch , int nNest ) { int nLastValid = nNest ; int ich = 0 ; ASSERT ( nNest >= 0 && level >= 0 && level <= MAX_LEVEL ) ; for ( ; ich < cch ; ich ++ ) { WORD cls = pcls [ ich ] ; switch ( cls ) { case LRO : case LRE : nNest ++ ; if ( GreaterEven ( level ) <= MAX_LEVEL - ( cls == LRO ? 2 : 0 ) ) { plevel [ ich ] = GreaterEven ( level ) ; pcls [ ich ] = BN ; ich += resolveExplicit ( plevel [ ich ] , ( cls == LRE ? N : L ) , & pcls [ ich + 1 ] , & plevel [ ich + 1 ] , cch - ( ich + 1 ) , nNest ) ; nNest -- ; continue ; } cls = pcls [ ich ] = BN ; break ; case RLO : case RLE : nNest ++ ; if ( GreaterOdd ( level ) <= MAX_LEVEL - ( cls == RLO ? 2 : 0 ) ) { plevel [ ich ] = GreaterOdd ( level ) ; pcls [ ich ] = BN ; ich += resolveExplicit ( plevel [ ich ] , ( cls == RLE ? N : R ) , & pcls [ ich + 1 ] , & plevel [ ich + 1 ] , cch - ( ich + 1 ) , nNest ) ; nNest -- ; continue ; } cls = pcls [ ich ] = BN ; break ; case PDF : cls = pcls [ ich ] = BN ; if ( nNest ) { if ( nLastValid < nNest ) { nNest -- ; } else { cch = ich ; } } } if ( dir != N ) { cls = dir ; } plevel [ ich ] = level ; if ( pcls [ ich ] != BN ) pcls [ ich ] = cls ; } return ich ; }
Function: resolveExplicit
Recursively resolves explicit embedding levels and overrides.
Function : resolveExplicit Recursively resolves explicit embedding levels and overrides .
/* always called with a valid nesting level
       nesting levels are != embedding levels */ /* check input values */ /* process the text */ /* break the loop, but complete body */ /* Apply the override */