Ignore:
Timestamp:
2013-08-04T12:01:10Z (11 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ea50906
Parents:
b08879c2 (diff), d856110 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bdsh/cmds/modules/cat/cat.c

    rb08879c2 rbdae198  
    6363static bool should_quit = false;
    6464static bool dash_represents_stdin = false;
     65static unsigned int lineno = 0;
     66static bool number = false;
     67static bool last_char_was_newline = false;
    6568
    6669static console_ctrl_t *console = NULL;
     
    7578        { "hex", no_argument, 0, 'x' },
    7679        { "stdin", no_argument, 0, 's' },
     80        { "number", no_argument, 0, 'n' },
    7781        { 0, 0, 0, 0 }
    7882};
     
    9599                "  -m, --more       Pause after each screen full\n"
    96100                "  -x, --hex        Print bytes as hex values\n"
    97                 "  -s  --stdin      Treat `-' in file list as standard input\n"
     101                "  -s, --stdin      Treat `-' in file list as standard input\n"
     102                "  -n, --number     Number all output lines\n"
    98103                "Currently, %s is under development, some options don't work.\n",
    99104                cmdname, cmdname);
     
    153158static void paged_char(wchar_t c)
    154159{
     160        if (last_char_was_newline && number) {
     161                lineno++;
     162                printf("%6u  ", lineno);
     163        }
    155164        putchar(c);
     165        last_char_was_newline = c == '\n';
    156166        if (paging_enabled) {
    157167                chars_remaining--;
     
    306316        should_quit = false;
    307317        console = console_init(stdin, stdout);
     318        number = false;
     319        lineno = 0;
     320        /* This enables printing of the first number. */
     321        last_char_was_newline = true;
     322
    308323
    309324        argc = cli_count_args(argv);
    310325
    311326        for (c = 0, optind = 0, opt_ind = 0; c != -1;) {
    312                 c = getopt_long(argc, argv, "xhvmH:t:b:s", long_options, &opt_ind);
     327                c = getopt_long(argc, argv, "xhvmH:t:b:s:n", long_options, &opt_ind);
    313328                switch (c) {
    314329                case 'h':
     
    347362                        dash_represents_stdin = true;
    348363                        break;
     364                case 'n':
     365                        number = true;
     366                        break;
    349367                }
    350368        }
Note: See TracChangeset for help on using the changeset viewer.