aboutsummaryrefslogtreecommitdiffstats
path: root/extension/ordchr.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2016-12-06 22:06:26 +0200
committerArnold D. Robbins <arnold@skeeve.com>2016-12-06 22:06:26 +0200
commitf2b6d100d8958a9c811c950f113a0ce38a25d484 (patch)
tree53c03280dab7f88134bbcdad1279f13cf12b0cf6 /extension/ordchr.c
parent0dd8054d05d8286f2f7cbcf85456c6953a9b6146 (diff)
downloadegawk-f2b6d100d8958a9c811c950f113a0ce38a25d484.tar.gz
egawk-f2b6d100d8958a9c811c950f113a0ce38a25d484.tar.bz2
egawk-f2b6d100d8958a9c811c950f113a0ce38a25d484.zip
Add min_required and max_expected arg counts to API.
Diffstat (limited to 'extension/ordchr.c')
-rw-r--r--extension/ordchr.c26
1 files changed, 6 insertions, 20 deletions
diff --git a/extension/ordchr.c b/extension/ordchr.c
index 4f9cd616..3722ced8 100644
--- a/extension/ordchr.c
+++ b/extension/ordchr.c
@@ -65,17 +65,10 @@ do_ord(int nargs, awk_value_t *result)
assert(result != NULL);
- if (do_lint && nargs > 1)
- lintwarn(ext_id, _("ord: called with too many arguments"));
-
if (get_argument(0, AWK_STRING, & str)) {
ret = str.str_value.str[0];
- } else if (do_lint) {
- if (nargs == 0)
- lintwarn(ext_id, _("ord: called with no arguments"));
- else
- lintwarn(ext_id, _("ord: called with inappropriate argument(s)"));
- }
+ } else if (do_lint)
+ lintwarn(ext_id, _("ord: called with inappropriate argument(s)"));
/* Set the return value */
return make_number(ret, result);
@@ -95,29 +88,22 @@ do_chr(int nargs, awk_value_t *result)
assert(result != NULL);
- if (do_lint && nargs > 1)
- lintwarn(ext_id, _("chr: called with too many arguments"));
-
if (get_argument(0, AWK_NUMBER, & num)) {
val = num.num_value;
ret = val; /* convert to int */
ret &= 0xff;
str[0] = ret;
str[1] = '\0';
- } else if (do_lint) {
- if (nargs == 0)
- lintwarn(ext_id, _("chr: called with no arguments"));
- else
- lintwarn(ext_id, _("chr: called with inappropriate argument(s)"));
- }
+ } else if (do_lint)
+ lintwarn(ext_id, _("chr: called with inappropriate argument(s)"));
/* Set the return value */
return make_const_string(str, 1, result);
}
static awk_ext_func_t func_table[] = {
- { "ord", do_ord, 1 },
- { "chr", do_chr, 1 },
+ { "ord", do_ord, 1, 1 },
+ { "chr", do_chr, 1, 1 },
};
/* define the dl_load function using the boilerplate macro */