aboutsummaryrefslogtreecommitdiffstats
path: root/extension/ordchr.c
diff options
context:
space:
mode:
Diffstat (limited to 'extension/ordchr.c')
-rw-r--r--extension/ordchr.c30
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 */