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 int colon_command(struct more_control* ctl, char* filename, int cmd,
                         int nlines)
{
    char ch;

    if (cmd == 0)
        ch = read_user_input(ctl);
    else
        ch = cmd;
    ctl->last_colon_command = ch;
    switch (ch)
    {
        case 'f':
            kill_line(ctl);
            if (!ctl->no_tty_in)
                ctl->prompt_len = printf(_("\"%s\" line %d"),
                                         ctl->file_names[ctl->argv_position],
                                         ctl->current_line);
            else
                ctl->prompt_len =
                    printf(_("[Not a file] line %d"), ctl->current_line);
            fflush(stdout);
            return -1;
        case 'n':
            if (nlines == 0)
            {
                if (ctl->argv_position >= ctl->num_files - 1)
                    more_exit(0);
                nlines++;
            }
            putchar('\r');
            erase_prompt(ctl, 0);
            change_file(ctl, nlines);
            return 0;
        case 'p':
            if (ctl->no_tty_in)
            {
                fputc(RINGBELL, stderr);
                return -1;
            }
            putchar('\r');
            erase_prompt(ctl, 0);
            if (nlines == 0)
                nlines++;
            change_file(ctl, -nlines);
            return 0;
        case '!':
            run_shell(ctl, filename);
            return -1;
        case 'q':
        case 'Q':
            more_exit(0);
        default:
            fputc(RINGBELL, stderr);
            return -1;
    }
}
/* Execute a colon-prefixed command.  Returns <0 if not a command that
 * should cause more of the file to be printed. */
Execute a colon-prefixed command.  Returns <0 if not a command that
should cause more of the file to be printed.
Execute a colon - prefixed command . Returns <0 if not a command that should cause more of the file to be printed .
static int colon_command(struct more_control* ctl, char* filename, int cmd,
                         int nlines)
{
    char ch;
    if (cmd == 0)
        ch = read_user_input(ctl);
    else
        ch = cmd;
    ctl->last_colon_command = ch;
    switch (ch)
    {
        case 'f':
            kill_line(ctl);
            if (!ctl->no_tty_in)
                ctl->prompt_len = printf(_("\"%s\" line %d"),
                                         ctl->file_names[ctl->argv_position],
                                         ctl->current_line);
            else
                ctl->prompt_len =
                    printf(_("[Not a file] line %d"), ctl->current_line);
            fflush(stdout);
            return -1;
        case 'n':
            if (nlines == 0)
            {
                if (ctl->argv_position >= ctl->num_files - 1)
                    more_exit(0);
                nlines++;
            }
            putchar('\r');
            erase_prompt(ctl, 0);
            change_file(ctl, nlines);
            return 0;
        case 'p':
            if (ctl->no_tty_in)
            {
                fputc(RINGBELL, stderr);
                return -1;
            }
            putchar('\r');
            erase_prompt(ctl, 0);
            if (nlines == 0)
                nlines++;
            change_file(ctl, -nlines);
            return 0;
        case '!':
            run_shell(ctl, filename);
            return -1;
        case 'q':
        case 'Q':
            more_exit(0);
        default:
            fputc(RINGBELL, stderr);
            return -1;
    }
}
static int colon_command ( struct more_control * ctl , char * filename , int cmd , int nlines ) { char ch ; if ( cmd == 0 ) ch = read_user_input ( ctl ) ; else ch = cmd ; ctl -> last_colon_command = ch ; switch ( ch ) { case ' ' : kill_line ( ctl ) ; if ( ! ctl -> no_tty_in ) ctl -> prompt_len = printf ( _ ( " \" \" " ) , ctl -> file_names [ ctl -> argv_position ] , ctl -> current_line ) ; else ctl -> prompt_len = printf ( _ ( " " ) , ctl -> current_line ) ; fflush ( stdout ) ; return -1 ; case ' ' : if ( nlines == 0 ) { if ( ctl -> argv_position >= ctl -> num_files - 1 ) more_exit ( 0 ) ; nlines ++ ; } putchar ( ' \r ' ) ; erase_prompt ( ctl , 0 ) ; change_file ( ctl , nlines ) ; return 0 ; case ' ' : if ( ctl -> no_tty_in ) { fputc ( RINGBELL , stderr ) ; return -1 ; } putchar ( ' \r ' ) ; erase_prompt ( ctl , 0 ) ; if ( nlines == 0 ) nlines ++ ; change_file ( ctl , - nlines ) ; return 0 ; case ' ' : run_shell ( ctl , filename ) ; return -1 ; case ' ' : case ' ' : more_exit ( 0 ) ; default : fputc ( RINGBELL , stderr ) ; return -1 ; } }
Execute a colon-prefixed command.
Execute a colon - prefixed command .