diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2016-12-22 17:35:08 +0200 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2016-12-22 17:35:08 +0200 |
commit | cd820dc4359b8dc1a40fedc0c5d3924ed8f88df0 (patch) | |
tree | 17ce84a9a1907783c7839b2dd6fd9afefe303815 /extension/ordchr.c | |
parent | 0eb15bcef4ca13a329c9bf3d5e608e29bbce42ad (diff) | |
parent | 0f15f82e19b32823fe3fdf51052389ca3b60e92e (diff) | |
download | egawk-cd820dc4359b8dc1a40fedc0c5d3924ed8f88df0.tar.gz egawk-cd820dc4359b8dc1a40fedc0c5d3924ed8f88df0.tar.bz2 egawk-cd820dc4359b8dc1a40fedc0c5d3924ed8f88df0.zip |
Merge branch 'master' into feature/regex-to-api
Diffstat (limited to 'extension/ordchr.c')
-rw-r--r-- | extension/ordchr.c | 30 |
1 files changed, 8 insertions, 22 deletions
diff --git a/extension/ordchr.c b/extension/ordchr.c index 4f9cd616..c7451f6d 100644 --- a/extension/ordchr.c +++ b/extension/ordchr.c @@ -58,24 +58,17 @@ int plugin_is_GPL_compatible; /* do_ord --- return numeric value of first char of string */ static awk_value_t * -do_ord(int nargs, awk_value_t *result) +do_ord(int nargs, awk_value_t *result, struct awk_ext_func *unused) { awk_value_t str; double ret = -1; 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); @@ -84,7 +77,7 @@ do_ord(int nargs, awk_value_t *result) /* do_chr --- turn numeric value into a string */ static awk_value_t * -do_chr(int nargs, awk_value_t *result) +do_chr(int nargs, awk_value_t *result, struct awk_ext_func *unused) { awk_value_t num; unsigned int ret = 0; @@ -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, awk_false, NULL }, + { "chr", do_chr, 1, 1, awk_false, NULL }, }; /* define the dl_load function using the boilerplate macro */ |