openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/util-linux/2.33.2-r0/util-linux-2.33.2/text-utils/more.c
static void screen(struct more_control* ctl, FILE* f, int num_lines)
{
    int c;
    int nchars;
    int length;              /* length of current line */
    static int prev_len = 1; /* length of previous line */

    for (;;)
    {
        while (num_lines > 0 && !ctl->is_paused)
        {
            if ((nchars = get_line(ctl, f, &length)) == EOF)
            {
                if (ctl->clear_line_ends)
                    putp(ctl->clear_rest);
                return;
            }
            if (ctl->squeeze_spaces && length == 0 && prev_len == 0)
                continue;
            prev_len = length;
            if (ctl->bad_stdout ||
                ((ctl->enter_std && *ctl->enter_std == ' ') &&
                 (ctl->prompt_len > 0)))
                erase_prompt(ctl, 0);
            /* must clear before drawing line since tabs on
             * some terminals do not erase what they tab
             * over. */
            if (ctl->clear_line_ends)
                putp(ctl->erase_line);
            print_buf(ctl, ctl->line_buf, length);
            if (nchars < ctl->prompt_len)
                erase_prompt(ctl,
                             nchars); /* erase_prompt () sets prompt_len to 0 */
            else
                ctl->prompt_len = 0;
            if (nchars < ctl->num_columns || !ctl->fold_long_lines)
                print_buf(ctl, "\n", 1); /* will turn off UL if necessary */
            num_lines--;
        }
        if (ctl->underline_state)
        {
            putp(ctl->exit_underline);
            ctl->underline_state = 0;
        }
        fflush(stdout);
        if ((c = more_getc(ctl, f)) == EOF)
        {
            if (ctl->clear_line_ends)
                putp(ctl->clear_rest);
            return;
        }

        if (ctl->is_paused && ctl->clear_line_ends)
            putp(ctl->clear_rest);
        more_ungetc(ctl, c, f);
        sigsetjmp(ctl->destination, 1);
        ctl->is_paused = 0;
        ctl->starting_up = 0;
        if ((num_lines = more_key_command(ctl, NULL, f)) == 0)
            return;
        if (ctl->hard_tty && ctl->prompt_len > 0)
            erase_prompt(ctl, 0);
        if (ctl->no_scroll && num_lines >= ctl->lines_per_screen)
        {
            if (ctl->clear_line_ends)
                putp(ctl->go_home);
            else
                more_clear_screen(ctl);
        }
        ctl->screen_start.line_num = ctl->current_line;
        ctl->screen_start.row_num = ctl->file_position;
    }
}
/* Print out the contents of the file f, one screenful at a time. */
Print out the contents of the file f, one screenful at a time.
Print out the contents of the file f one screenful at a time .
static void screen(struct more_control* ctl, FILE* f, int num_lines)
{
    int c;
    int nchars;
    int length;              
    static int prev_len = 1; 
    for (;;)
    {
        while (num_lines > 0 && !ctl->is_paused)
        {
            if ((nchars = get_line(ctl, f, &length)) == EOF)
            {
                if (ctl->clear_line_ends)
                    putp(ctl->clear_rest);
                return;
            }
            if (ctl->squeeze_spaces && length == 0 && prev_len == 0)
                continue;
            prev_len = length;
            if (ctl->bad_stdout ||
                ((ctl->enter_std && *ctl->enter_std == ' ') &&
                 (ctl->prompt_len > 0)))
                erase_prompt(ctl, 0);
            if (ctl->clear_line_ends)
                putp(ctl->erase_line);
            print_buf(ctl, ctl->line_buf, length);
            if (nchars < ctl->prompt_len)
                erase_prompt(ctl,
                             nchars); 
            else
                ctl->prompt_len = 0;
            if (nchars < ctl->num_columns || !ctl->fold_long_lines)
                print_buf(ctl, "\n", 1); 
            num_lines--;
        }
        if (ctl->underline_state)
        {
            putp(ctl->exit_underline);
            ctl->underline_state = 0;
        }
        fflush(stdout);
        if ((c = more_getc(ctl, f)) == EOF)
        {
            if (ctl->clear_line_ends)
                putp(ctl->clear_rest);
            return;
        }
        if (ctl->is_paused && ctl->clear_line_ends)
            putp(ctl->clear_rest);
        more_ungetc(ctl, c, f);
        sigsetjmp(ctl->destination, 1);
        ctl->is_paused = 0;
        ctl->starting_up = 0;
        if ((num_lines = more_key_command(ctl, NULL, f)) == 0)
            return;
        if (ctl->hard_tty && ctl->prompt_len > 0)
            erase_prompt(ctl, 0);
        if (ctl->no_scroll && num_lines >= ctl->lines_per_screen)
        {
            if (ctl->clear_line_ends)
                putp(ctl->go_home);
            else
                more_clear_screen(ctl);
        }
        ctl->screen_start.line_num = ctl->current_line;
        ctl->screen_start.row_num = ctl->file_position;
    }
}
static void screen ( struct more_control * ctl , FILE * f , int num_lines ) { int c ; int nchars ; int length ; static int prev_len = 1 ; for ( ; ; ) { while ( num_lines > 0 && ! ctl -> is_paused ) { if ( ( nchars = get_line ( ctl , f , & length ) ) == EOF ) { if ( ctl -> clear_line_ends ) putp ( ctl -> clear_rest ) ; return ; } if ( ctl -> squeeze_spaces && length == 0 && prev_len == 0 ) continue ; prev_len = length ; if ( ctl -> bad_stdout || ( ( ctl -> enter_std && * ctl -> enter_std == ' ' ) && ( ctl -> prompt_len > 0 ) ) ) erase_prompt ( ctl , 0 ) ; if ( ctl -> clear_line_ends ) putp ( ctl -> erase_line ) ; print_buf ( ctl , ctl -> line_buf , length ) ; if ( nchars < ctl -> prompt_len ) erase_prompt ( ctl , nchars ) ; else ctl -> prompt_len = 0 ; if ( nchars < ctl -> num_columns || ! ctl -> fold_long_lines ) print_buf ( ctl , " \n " , 1 ) ; num_lines -- ; } if ( ctl -> underline_state ) { putp ( ctl -> exit_underline ) ; ctl -> underline_state = 0 ; } fflush ( stdout ) ; if ( ( c = more_getc ( ctl , f ) ) == EOF ) { if ( ctl -> clear_line_ends ) putp ( ctl -> clear_rest ) ; return ; } if ( ctl -> is_paused && ctl -> clear_line_ends ) putp ( ctl -> clear_rest ) ; more_ungetc ( ctl , c , f ) ; sigsetjmp ( ctl -> destination , 1 ) ; ctl -> is_paused = 0 ; ctl -> starting_up = 0 ; if ( ( num_lines = more_key_command ( ctl , NULL , f ) ) == 0 ) return ; if ( ctl -> hard_tty && ctl -> prompt_len > 0 ) erase_prompt ( ctl , 0 ) ; if ( ctl -> no_scroll && num_lines >= ctl -> lines_per_screen ) { if ( ctl -> clear_line_ends ) putp ( ctl -> go_home ) ; else more_clear_screen ( ctl ) ; } ctl -> screen_start . line_num = ctl -> current_line ; ctl -> screen_start . row_num = ctl -> file_position ; } }
Print out the contents of the file f, one screenful at a time.
Print out the contents of the file f one screenful at a time .
/* length of current line */ /* length of previous line */ /* must clear before drawing line since tabs on
             * some terminals do not erase what they tab
             * over. */ /* erase_prompt () sets prompt_len to 0 */ /* will turn off UL if necessary */