summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog16
-rw-r--r--awk.h6
-rw-r--r--ext.c16
-rw-r--r--gawkapi.c6
4 files changed, 23 insertions, 21 deletions
diff --git a/ChangeLog b/ChangeLog
index f92bf52b..0f0e8949 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2016-05-26 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ * awk.h (get_actual_argument): Add an initial argument containing the
+ (NODE *) previously returned by get_argument. This allows us to
+ eliminate a call to get_argument from inside get_actual_argument.
+ (get_scalar_argument, get_array_argument): Change macro definition to
+ add an initial node argument to pass through to get_actual_argument.
+ * ext.c (get_actual_argument): Add initial (NODE *) argument to contain
+ the value previously returned by get_argument. This allows us to
+ avoid repeating the call to get_argument. We can also eliminate the
+ check for a NULL value, since the caller did that already.
+ * gawkapi.c (api_get_argument): Pass (NODE *) returned by get_argument
+ to get_array_argument and get_scalar_argument.
+ (api_set_argument): Pass (NODE *) returned by get_argument to
+ get_array_argument.
+
2016-05-25 Manuel Collado <mcollado2011@gmail.com>.
* gawkapi.c (api_nonfatal): New function.
diff --git a/awk.h b/awk.h
index c643581a..8a25dcc7 100644
--- a/awk.h
+++ b/awk.h
@@ -1449,9 +1449,9 @@ extern void close_extensions(void);
#ifdef DYNAMIC
extern awk_bool_t make_builtin(const awk_ext_func_t *);
extern NODE *get_argument(int);
-extern NODE *get_actual_argument(int, bool, bool);
-#define get_scalar_argument(i, opt) get_actual_argument((i), (opt), false)
-#define get_array_argument(i, opt) get_actual_argument((i), (opt), true)
+extern NODE *get_actual_argument(NODE *, int, bool, bool);
+#define get_scalar_argument(n, i, opt) get_actual_argument((n), (i), (opt), false)
+#define get_array_argument(n, i, opt) get_actual_argument((n), (i), (opt), true)
#endif
/* field.c */
extern void init_fields(void);
diff --git a/ext.c b/ext.c
index 522b18aa..c622599d 100644
--- a/ext.c
+++ b/ext.c
@@ -187,28 +187,14 @@ get_argument(int i)
*/
NODE *
-get_actual_argument(int i, bool optional, bool want_array)
+get_actual_argument(NODE *t, int i, bool optional, bool want_array)
{
- NODE *t;
char *fname;
- int pcount;
INSTRUCTION *pc;
pc = TOP()->code_ptr; /* Op_ext_builtin instruction */
fname = (pc + 1)->func_name;
- pcount = (pc + 1)->expr_count;
- t = get_argument(i);
- if (t == NULL) {
- if (i >= pcount) /* must be fatal */
- fatal(_("function `%s' defined to take no more than %d argument(s)"),
- fname, pcount);
- if (! optional)
- fatal(_("function `%s': missing argument #%d"),
- fname, i + 1);
- return NULL;
- }
-
if (t->type == Node_var_new) {
if (want_array)
return force_array(t, false);
diff --git a/gawkapi.c b/gawkapi.c
index 9d5f4491..e86172ac 100644
--- a/gawkapi.c
+++ b/gawkapi.c
@@ -87,7 +87,7 @@ api_get_argument(awk_ext_id_t id, size_t count,
array:
/* get the array here */
- arg = get_array_argument(count, false);
+ arg = get_array_argument(arg, count, false);
if (arg == NULL)
return awk_false;
@@ -95,7 +95,7 @@ array:
scalar:
/* at this point we have a real type that is not an array */
- arg = get_scalar_argument(count, false);
+ arg = get_scalar_argument(arg, count, false);
if (arg == NULL)
return awk_false;
@@ -125,7 +125,7 @@ api_set_argument(awk_ext_id_t id,
|| arg->type != Node_var_new)
return awk_false;
- arg = get_array_argument(count, false);
+ arg = get_array_argument(arg, count, false);
if (arg == NULL)
return awk_false;