added 'abort' & QSE_AWK_ABORT to awk.

added a new sed command 'C' that resembles the cut utility
dropped the cut utility.
added qse_str_nrcat()/qse_mbs_nrcat()/qse_wcs_nrcat()
This commit is contained in:
2012-08-19 14:20:19 +00:00
parent 006dd8975f
commit 6421da99f4
31 changed files with 159 additions and 2822 deletions

View File

@ -10,6 +10,8 @@
- @ref awk_ext_exprgroup "GROUPED EXPRESSION"
- @ref awk_ext_rwpipe "TWO-WAY PIPE"
- @ref awk_ext_return "RETURN"
- @ref awk_ext_reset "RESET"
- @ref awk_ext_abort "ABORT"
- @ref awk_ext_comment "COMMENT"
- @ref awk_ext_fnc "EXTENDED FUNCTIONS"
- @ref awk_ext_fs "EXTENDED FS"
@ -187,7 +189,9 @@ Where options are:
--rexbound on/off enable {n,m} in a regular expression
--ncmponstr on/off perform numeric comparsion on numeric strings
--strictnaming on/off enable the strict naming rule
--include on/off enable 'include'
--include on/off enable '@include'
--tolerant on/off make more I/O fault-tolerant
--abort on/off enable 'abort'
@endcode
@section awk_lang AWK LANGUAGE
@ -222,6 +226,7 @@ A pattern-action block, and a user-defined function can have the following eleme
<tr><td>print </td><td>#QSE_AWK_RIO </td></tr>
<tr><td>nextofile </td><td>#QSE_AWK_NEXTOFILE </td></tr>
<tr><td>reset </td><td>#QSE_AWK_RESET </td></tr>
<tr><td>abort </td><td>#QSE_AWK_ABORT </td></tr>
</table>
@ -234,6 +239,7 @@ AWK has the following statement constructs.
- continue
- return
- exit
- abort
- next
- nextfile
- nextofile
@ -471,7 +477,13 @@ function RunApp(app) {
@endcode
@subsection awk_ext_return RETURN
The return statement is valid in pattern-action blocks as well as in functions. The execution of a calling block is aborted once the return statement is executed.
The return statement is valid in pattern-action blocks as well as in functions.
The execution of a calling block is aborted once the return statement is executed.
@code
$ qseawk 'BEGIN { return 20; }' ; echo $?
20
@endcode
If #QSE_AWK_MAPTOVAR is on, you can return an arrayed value from a function.
@code
@ -491,6 +503,36 @@ BEGIN {
}
@endcode
@subsection awk_ext_reset RESET
The reset statement resets an array variable back to the initial state.
After that, the array variable can also be used as a scalar variable again.
You must have #QSE_AWK_RESET on to be able to be able to use this
statement.
@code
BEGIN {
a[1] = 20;
reset a;
a = 20; # this is legal
print a;
}
@endcode
@subsection awk_ext_abort ABORT
The abort statment is similar to the exit statement except that
it skips executing the END block. You must have #QSE_AWK_ABORT on to be
able to use this statement.
@code
BEGIN {
print "--- BEGIN ---";
abort 10;
}
END {
print "--- END ---"; # this must not be printed
}
@endcode
@subsection awk_ext_comment COMMENT
You can use the C-style comment as well as the pound comment.

View File

@ -258,6 +258,28 @@ be empty; You can combine the following options into @b opts:
Replaces all occurrences of characters in @b src with characters in @b dst.
@b src and @b dst must contain equal number of characters.
- <b>c/selector/opts</b>
Selects characters or fields from the pattern space as specified by the
@b selector and update the pattern space with the selected text. A selector
is a comma-separated list of selector atoms. A selector atom is one of
the followings:
<ul>
<li>@b d specifies the input field delimiter with the next character. e.g) d:
<li>@b D sepcifies the output field delimiter with the next character. e.g) D;
<li>@b c specifies a position or a range of characters to select. e.g) c23-25
<li>@b f specifies a position or a range of fields to select. e.g) f1,f4-3
</ul>
@b opts may be empty; You can combine the following options into @b opts:
<ul>
<li>@b f folds consecutive delimiters into one.
<li>@b w uses white spaces for a field delimiter regardless of the input
delimiter specified in the selector.
<li>@b d deletes the pattern space if the line is not delimited by
the input field delimiter
</ul>
In principle, this can replace the @b cut utility.
Let's see actual examples:
- <b>G;G;G</b>
Triple spaces input lines. If #QSE_SED_QUIET is on, <b>G;G;G;p</b>.