Ejemplo n.º 1
0
static void GetInputChar (void)
/* Read the next character from the input stream and make CurC and NextC
 * valid. If end of line is reached, both are set to NUL, no more lines
 * are read by this function.
 */
{
    /* Drop all pushed fragments that don't have data left */
    while (SB_GetIndex (Line) >= SB_GetLen (Line)) {
        /* Cannot read more from this line, check next line on stack if any */
        if (CollCount (&InputStack) == 0) {
            /* This is THE line */
            break;
        }
        FreeStrBuf (Line);
        Line = CollPop (&InputStack);
    }

    /* Now get the next characters from the line */
    if (SB_GetIndex (Line) >= SB_GetLen (Line)) {
        CurC = NextC = '\0';
    } else {
        CurC = SB_AtUnchecked (Line, SB_GetIndex (Line));
        if (SB_GetIndex (Line) + 1 < SB_GetLen (Line)) {
            /* NextC comes from this fragment */
            NextC = SB_AtUnchecked (Line, SB_GetIndex (Line) + 1);
        } else {
            /* NextC comes from next fragment */
            if (CollCount (&InputStack) > 0) {
                NextC = ' ';
            } else {
                NextC = '\0';
            }
        }
    }
}
Ejemplo n.º 2
0
void PopSegments (void)
/* Pop the old segment list (make it current) */
{
    /* Must have something on the stack */
    PRECONDITION (CollCount (&SegmentStack) > 0);

    /* Pop the last segment and set it as current */
    CS = CollPop (&SegmentStack);
}