diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2012-06-12 22:10:31 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2012-06-12 22:10:31 +0300 |
commit | 820b6a2ccb7859e15ade36af6ac1d0d08c1da4b1 (patch) | |
tree | e820c47953f997e8d267854fd921417d61d8ec3a /extension | |
parent | b4a2d75b7d9fd23069a55dc91a42f7fddd0c7570 (diff) | |
download | egawk-820b6a2ccb7859e15ade36af6ac1d0d08c1da4b1.tar.gz egawk-820b6a2ccb7859e15ade36af6ac1d0d08c1da4b1.tar.bz2 egawk-820b6a2ccb7859e15ade36af6ac1d0d08c1da4b1.zip |
Further cleanups and improvements in API.
Diffstat (limited to 'extension')
-rw-r--r-- | extension/ChangeLog | 12 | ||||
-rw-r--r-- | extension/filefuncs.c | 14 | ||||
-rw-r--r-- | extension/fork.c | 4 | ||||
-rw-r--r-- | extension/ordchr.c | 4 | ||||
-rw-r--r-- | extension/readfile.c | 2 | ||||
-rw-r--r-- | extension/time.c | 5 |
6 files changed, 26 insertions, 15 deletions
diff --git a/extension/ChangeLog b/extension/ChangeLog index 5e513f8e..6c4ea84a 100644 --- a/extension/ChangeLog +++ b/extension/ChangeLog @@ -1,3 +1,15 @@ +2012-06-12 Arnold D. Robbins <arnold@skeeve.com> + + * filefuncs.c (do_chdir): Replace get_curfunc_param with get_argument. + (format_mode): Use unsigned masks. + (do_stat): Replace get_curfunc_param with get_argument. + * fork.c (do_fork): Rearrange arg order in call to sym_lookup + (do_waitpid): Replace get_curfunc_param with get_argument. + * ordchr.c (do_ord, do_chr): Replace get_curfunc_param with get_argument. + * readfile.c (do_readfile): Replace get_curfunc_param with get_argument. + * time.c (do_sleep): Replace get_curfunc_param with get_argument. + Replace set_ERRNO with update_ERRNO_str for no way to sleep case. + 2012-06-10 Andrew J. Schorr <aschorr@telemetry-investments.com> * Makefile.am: Add time extension. diff --git a/extension/filefuncs.c b/extension/filefuncs.c index 4d382005..12f3acb6 100644 --- a/extension/filefuncs.c +++ b/extension/filefuncs.c @@ -57,7 +57,7 @@ do_chdir(int nargs, awk_value_t *result) if (do_lint && nargs != 1) lintwarn(ext_id, "chdir: called with incorrect number of arguments, expecting 1"); - if (get_curfunc_param(0, AWK_STRING, & newdir) != NULL) { + if (get_argument(0, AWK_STRING, & newdir)) { ret = chdir(newdir.str_value.str); if (ret < 0) update_ERRNO_int(errno); @@ -73,7 +73,7 @@ format_mode(unsigned long fmode) { static char outbuf[12]; static struct ftype_map { - int mask; + unsigned int mask; int charval; } ftype_map[] = { { S_IFREG, '-' }, /* redundant */ @@ -94,7 +94,7 @@ format_mode(unsigned long fmode) #endif /* S_IFDOOR */ }; static struct mode_map { - int mask; + unsigned int mask; int rep; } map[] = { { S_IRUSR, 'r' }, { S_IWUSR, 'w' }, { S_IXUSR, 'x' }, @@ -102,7 +102,7 @@ format_mode(unsigned long fmode) { S_IROTH, 'r' }, { S_IWOTH, 'w' }, { S_IXOTH, 'x' }, }; static struct setuid_map { - int mask; + unsigned int mask; int index; int small_rep; int big_rep; @@ -243,7 +243,7 @@ do_stat(int nargs, awk_value_t *result) const char *type = "unknown"; awk_value_t tmp; static struct ftype_map { - int mask; + unsigned int mask; const char *type; } ftype_map[] = { { S_IFREG, "file" }, @@ -270,8 +270,8 @@ do_stat(int nargs, awk_value_t *result) } /* file is first arg, array to hold results is second */ - if ( get_curfunc_param(0, AWK_STRING, & file_param) == NULL - || get_curfunc_param(1, AWK_ARRAY, & array_param) == NULL) { + if ( ! get_argument(0, AWK_STRING, & file_param) + || ! get_argument(1, AWK_ARRAY, & array_param)) { warning(ext_id, "stat: bad parameters"); return make_number(-1, result); } diff --git a/extension/fork.c b/extension/fork.c index 1d4ad82c..0c2e31d0 100644 --- a/extension/fork.c +++ b/extension/fork.c @@ -78,7 +78,7 @@ do_fork(int nargs, awk_value_t *result) /* update PROCINFO in the child, if the array exists */ awk_value_t procinfo; - if (sym_lookup("PROCINFO", & procinfo, AWK_ARRAY) != NULL) { + if (sym_lookup("PROCINFO", AWK_ARRAY, & procinfo)) { if (procinfo.val_type != AWK_ARRAY) { if (do_lint) lintwarn(ext_id, "fork: PROCINFO is not an array!"); @@ -105,7 +105,7 @@ do_waitpid(int nargs, awk_value_t *result) if (do_lint && nargs > 1) lintwarn(ext_id, "waitpid: called with too many arguments"); - if (get_curfunc_param(0, AWK_NUMBER, &pid) != NULL) { + if (get_argument(0, AWK_NUMBER, &pid)) { options = WNOHANG|WUNTRACED; ret = waitpid(pid.num_value, NULL, options); if (ret < 0) diff --git a/extension/ordchr.c b/extension/ordchr.c index c5d2bb45..dc02479a 100644 --- a/extension/ordchr.c +++ b/extension/ordchr.c @@ -56,7 +56,7 @@ do_ord(int nargs, awk_value_t *result) if (do_lint && nargs > 1) lintwarn(ext_id, "ord: called with too many arguments"); - if (get_curfunc_param(0, AWK_STRING, & str) != NULL) { + if (get_argument(0, AWK_STRING, & str)) { ret = str.str_value.str[0]; } else if (do_lint) lintwarn(ext_id, "ord: called with no arguments"); @@ -80,7 +80,7 @@ do_chr(int nargs, awk_value_t *result) if (do_lint && nargs > 1) lintwarn(ext_id, "chr: called with too many arguments"); - if (get_curfunc_param(0, AWK_NUMBER, &num) != NULL) { + if (get_argument(0, AWK_NUMBER, & num)) { val = num.num_value; ret = val; /* convert to int */ ret &= 0xff; diff --git a/extension/readfile.c b/extension/readfile.c index ca513912..166bb8fb 100644 --- a/extension/readfile.c +++ b/extension/readfile.c @@ -66,7 +66,7 @@ do_readfile(int nargs, awk_value_t *result) if (do_lint && nargs > 1) lintwarn(ext_id, "readfile: called with too many arguments"); - if (get_curfunc_param(0, AWK_STRING, &filename) != NULL) { + if (get_argument(0, AWK_STRING, &filename)) { ret = stat(filename.str_value.str, & sbuf); if (ret < 0) { update_ERRNO_int(errno); diff --git a/extension/time.c b/extension/time.c index 4f590c88..09e71d0e 100644 --- a/extension/time.c +++ b/extension/time.c @@ -116,8 +116,7 @@ do_sleep(int nargs, awk_value_t *result) if (do_lint && nargs > 1) lintwarn(ext_id, "sleep: called with too many arguments"); - - if (get_curfunc_param(0, AWK_NUMBER, &num) == NULL) { + if (get_argument(0, AWK_NUMBER, &num) == NULL) { update_ERRNO_string("sleep: missing required numeric argument", 1); return make_number(-1, result); } @@ -151,7 +150,7 @@ do_sleep(int nargs, awk_value_t *result) #else /* no way to sleep on this platform */ rc = -1; - set_ERRNO("sleep: not supported on this platform"); + update_ERRNO_str("sleep: not supported on this platform", 0); #endif return make_number(rc, result); |