diff --git a/bin/cut.c b/bin/cut.c index 22d92cfa..cf42036e 100644 --- a/bin/cut.c +++ b/bin/cut.c @@ -99,27 +99,21 @@ static void print_usage (FILE* out, const hawk_bch_t* argv0, const hawk_bch_t* r const hawk_bch_t* b2 = (real_argv0? " ": ""); const hawk_bch_t* b3 = (real_argv0? argv0: ""); - fprintf (out, "USAGE: %s%s%s [options] script [file]\n", b1, b2, b3); - fprintf (out, " %s%s%s [options] -f script-file [file]\n", b1, b2, b3); - fprintf (out, " %s%s%s [options] -e script [file]\n", b1, b2, b3); + fprintf (out, "USAGE: %s%s%s [options] selector [file]\n", b1, b2, b3); + fprintf (out, " %s%s%s [options] -f selector-file [file]\n", b1, b2, b3); + fprintf (out, "Selector as follows:\n"); + fprintf (out, " 'd' followed by a delimiter character\n"); + fprintf (out, " 'D' followed by an input delimiter character and an output delimiter character\n"); + fprintf (out, " 'f' followed by a field number or field number range\n"); + fprintf (out, " 'c' followed by a character position or character position range\n"); + fprintf (out, " for example, 'f3-5 c1-2 f4 D:,'\n"); fprintf (out, "Options as follows:\n"); fprintf (out, " -h/--help show this message\n"); fprintf (out, " -D show extra information\n"); - fprintf (out, " -n disable auto-print\n"); fprintf (out, " -e script specify a script\n"); fprintf (out, " -f file specify a script file\n"); fprintf (out, " -o file specify an output file\n"); - fprintf (out, " -r use the extended regular expression\n"); - fprintf (out, " -R enable non-standard extensions to the regular\n"); - fprintf (out, " expression\n"); - fprintf (out, " -i perform in-place editing. imply -s\n"); - fprintf (out, " -s process input files separately\n"); - fprintf (out, " -a perform strict address and label check\n"); - fprintf (out, " -b allow extended address formats\n"); - fprintf (out, " ,,,<0,/regex/>\n"); - fprintf (out, " -x allow text on the same line as c, a, i\n"); - fprintf (out, " -y ensure a newline at text end\n"); fprintf (out, " -m/--memory-limit number specify the maximum amount of memory to use in bytes\n"); fprintf (out, " -w expand file wildcards\n"); #if defined(HAWK_OOCH_IS_UCH) @@ -192,7 +186,7 @@ static int handle_args (int argc, hawk_bch_t* argv[], const hawk_bch_t* real_arg }; static hawk_bcli_t opt = { - "hDe:f:o:rRisabxym:w", + "hDe:f:om:w", lng }; hawk_bci_t c; @@ -235,32 +229,6 @@ static int handle_args (int argc, hawk_bch_t* argv[], const hawk_bch_t* real_arg arg->output_file = opt.arg; break; - case 'i': - /* 'i' implies 's'. */ - arg->inplace = 1; - - case 's': - arg->separate = 1; - break; - -#if 0 - case 'a': - arg->option |= HAWK_CUT_STRICT; - break; - - case 'b': - arg->option |= HAWK_CUT_EXTENDEDADR; - break; - - case 'x': - arg->option |= HAWK_CUT_SAMELINE; - break; - - case 'y': - arg->option |= HAWK_CUT_ENSURENL; - break; -#endif - case 'm': arg->memlimit = strtoul(opt.arg, HAWK_NULL, 10); break; diff --git a/lib/cut.c b/lib/cut.c index b072848e..e969269e 100644 --- a/lib/cut.c +++ b/lib/cut.c @@ -324,15 +324,7 @@ int hawk_cut_comp (hawk_cut_t* cut, hawk_cut_io_impl_t inf) int mask = 0; while (hawk_is_ooch_space(c)) NXTSC_GOTO(cut, c, oops); - if (EOF(c)) - { - if (cut->sel.count > 0) - { - SETERR0(cut, HAWK_CUT_ESELNV); - return -1; - } - break; - } + if (EOF(c)) break; if (c == HAWK_T('d')) { diff --git a/lib/std-cut.c b/lib/std-cut.c index 9790b8ae..a17e747e 100644 --- a/lib/std-cut.c +++ b/lib/std-cut.c @@ -779,7 +779,7 @@ static hawk_ooi_t read_input_stream (hawk_cut_t* cut, hawk_cut_io_arg_t* arg, ha n = hawk_sio_getoochars(arg->handle, buf, len); if (n <= -1) { - set_eiofil_for_iostd (cut, io); + set_eiofil_for_iostd(cut, io); break; } } @@ -798,6 +798,7 @@ static hawk_ooi_t read_input_stream (hawk_cut_t* cut, hawk_cut_io_arg_t* arg, ha /* == end of file on the current input stream == */ /* ============================================= */ +#if 0 if (base == &xtn->s.in && xtn->s.last != HAWK_T('\n')) { /* TODO: different line termination convension */ @@ -806,6 +807,7 @@ static hawk_ooi_t read_input_stream (hawk_cut_t* cut, hawk_cut_io_arg_t* arg, ha xtn->s.newline_squeezed = 1; break; } +#endif open_next: next = base->cur + 1; @@ -821,7 +823,7 @@ static hawk_ooi_t read_input_stream (hawk_cut_t* cut, hawk_cut_io_arg_t* arg, ha if (open_input_stream(cut, arg, next, base) <= -1) { /* failed to open the next input stream */ - set_eiofil_for_iostd (cut, next); + set_eiofil_for_iostd(cut, next); n = -1; break; } @@ -1082,7 +1084,7 @@ static hawk_ooi_t x_out ( { hawk_ooi_t n; n = hawk_sio_putoochars(arg->handle, dat, len); - if (n <= -1) set_eiofil_for_iostd (cut, io); + if (n <= -1) set_eiofil_for_iostd(cut, io); return n; } } diff --git a/lib/std-sed.c b/lib/std-sed.c index 5e475e12..aa8ac96e 100644 --- a/lib/std-sed.c +++ b/lib/std-sed.c @@ -662,7 +662,7 @@ static hawk_ooi_t read_input_stream (hawk_sed_t* sed, hawk_sed_io_arg_t* arg, ha n = hawk_sio_getoochars(arg->handle, buf, len); if (n <= -1) { - set_eiofil_for_iostd (sed, io); + set_eiofil_for_iostd(sed, io); break; } } @@ -704,7 +704,7 @@ static hawk_ooi_t read_input_stream (hawk_sed_t* sed, hawk_sed_io_arg_t* arg, ha if (open_input_stream(sed, arg, next, base) <= -1) { /* failed to open the next input stream */ - set_eiofil_for_iostd (sed, next); + set_eiofil_for_iostd(sed, next); n = -1; break; } @@ -965,7 +965,7 @@ static hawk_ooi_t x_out ( { hawk_ooi_t n; n = hawk_sio_putoochars(arg->handle, dat, len); - if (n <= -1) set_eiofil_for_iostd (sed, io); + if (n <= -1) set_eiofil_for_iostd(sed, io); return n; } }