diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2014-09-18 20:03:23 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2014-09-18 20:03:23 +0000 |
commit | f316a2ed52195135a35e32d7096e876357c48c69 (patch) | |
tree | 5f4486b9a5a213a69e66ef574d6bc643a207981c /src/libexecline/el_semicolon.c | |
download | execline-f316a2ed52195135a35e32d7096e876357c48c69.tar.xz |
initial commit: rc for execline-2.0.0.0
Diffstat (limited to 'src/libexecline/el_semicolon.c')
-rw-r--r-- | src/libexecline/el_semicolon.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/libexecline/el_semicolon.c b/src/libexecline/el_semicolon.c new file mode 100644 index 0000000..dc99daf --- /dev/null +++ b/src/libexecline/el_semicolon.c @@ -0,0 +1,35 @@ +/* ISC license. */ + +#include <skalibs/env.h> +#include <skalibs/strerr2.h> +#include <skalibs/uint.h> +#include <execline/execline.h> + +int el_semicolon (char const **argv) +{ + static unsigned int nblock = 0 ; + register int argc1 = 0 ; + nblock++ ; + for (;; argc1++, argv++) + { + register char const *arg = *argv ; + if (!arg) return argc1 + 1 ; + if ((arg[0] == EXECLINE_BLOCK_END_CHAR) && (!EXECLINE_BLOCK_END_CHAR || !arg[1])) return argc1 ; + else if (arg[0] == EXECLINE_BLOCK_QUOTE_CHAR) ++*argv ; + else + { + unsigned int strict = el_getstrict() ; + if (strict) + { + char fmt1[UINT_FMT] ; + char fmt2[UINT_FMT] ; + fmt1[uint_fmt(fmt1, nblock)] = 0 ; + fmt2[uint_fmt(fmt2, (unsigned int)argc1)] = 0 ; + if (strict >= 2) + strerr_dief6x(100, "unquoted argument ", arg, " at block ", fmt1, " position ", fmt2) ; + else + strerr_warnw6x("unquoted argument ", arg, " at block ", fmt1, " position ", fmt2) ; + } + } + } +} |