gawk-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gawk-diffs] [SCM] gawk branch, extgawk, updated. 77036f5ae0d0c4e2e15518


From: Arnold Robbins
Subject: [gawk-diffs] [SCM] gawk branch, extgawk, updated. 77036f5ae0d0c4e2e1551838c193dd2ca877a54e
Date: Fri, 13 Jul 2012 11:04:21 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gawk".

The branch, extgawk has been updated
       via  77036f5ae0d0c4e2e1551838c193dd2ca877a54e (commit)
      from  7c209cbe1b2fd054769512e325ede72d865f0c84 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=77036f5ae0d0c4e2e1551838c193dd2ca877a54e

commit 77036f5ae0d0c4e2e1551838c193dd2ca877a54e
Author: Arnold D. Robbins <address@hidden>
Date:   Fri Jul 13 14:02:02 2012 +0300

    Refactoring filefuncs.c before fts changes.

diff --git a/extension/ChangeLog b/extension/ChangeLog
index e71d071..6982758 100644
--- a/extension/ChangeLog
+++ b/extension/ChangeLog
@@ -1,3 +1,9 @@
+2012-07-13         Arnold D. Robbins     <address@hidden>
+
+       * filefuncs.c (fill_stat_array): New function to do the work
+       for stat.
+       (do_stat): Call it.
+
 2012-07-12         Arnold D. Robbins     <address@hidden>
 
        * fnmatch.c: New file.
diff --git a/extension/filefuncs.c b/extension/filefuncs.c
index 71387cb..41783c8 100644
--- a/extension/filefuncs.c
+++ b/extension/filefuncs.c
@@ -230,18 +230,14 @@ array_set_numeric(awk_array_t array, const char *sub, 
double num)
        array_set(array, sub, make_number(num, & tmp));
 }
 
-/* do_stat --- provide a stat() function for gawk */
+/* fill_stat_array --- do the work to fill an array with stat info */
 
-static awk_value_t *
-do_stat(int nargs, awk_value_t *result)
+static int
+fill_stat_array(const char *name, awk_array_t array)
 {
-       awk_value_t file_param, array_param;
-       char *name;
-       awk_array_t array;
-       struct stat sbuf;
-       int ret, j, k;
        char *pmode;    /* printable mode */
        const char *type = "unknown";
+       struct stat sbuf;
        awk_value_t tmp;
        static struct ftype_map {
                unsigned int mask;
@@ -264,23 +260,7 @@ do_stat(int nargs, awk_value_t *result)
                { S_IFDOOR, "door" },
 #endif /* S_IFDOOR */
        };
-
-       assert(result != NULL);
-
-       if (do_lint && nargs != 2) {
-               lintwarn(ext_id, "stat: called with wrong number of arguments");
-               return make_number(-1, result);
-       }
-
-       /* file is first arg, array to hold results is second */
-       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);
-       }
-
-       name = file_param.str_value.str;
-       array = array_param.array_cookie;
+       int ret, j, k;
 
        /* empty out the array */
        clear_array(array);
@@ -289,11 +269,11 @@ do_stat(int nargs, awk_value_t *result)
        ret = lstat(name, & sbuf);
        if (ret < 0) {
                update_ERRNO_int(errno);
-               return make_number(-1, result);
+               return -1;
        }
 
        /* fill in the array */
-       array_set(array, "name", make_const_string(name, 
file_param.str_value.len, &tmp));
+       array_set(array, "name", make_const_string(name, strlen(name), & tmp));
        array_set_numeric(array, "dev", sbuf.st_dev);
        array_set_numeric(array, "ino", sbuf.st_ino);
        array_set_numeric(array, "mode", sbuf.st_mode);
@@ -343,7 +323,37 @@ do_stat(int nargs, awk_value_t *result)
 
        array_set(array, "type", make_const_string(type, strlen(type), &tmp));
 
-       ret = 1;        /* success */
+       return 0;
+}
+
+/* do_stat --- provide a stat() function for gawk */
+
+static awk_value_t *
+do_stat(int nargs, awk_value_t *result)
+{
+       awk_value_t file_param, array_param;
+       char *name;
+       awk_array_t array;
+       int ret;
+
+       assert(result != NULL);
+
+       if (do_lint && nargs != 2) {
+               lintwarn(ext_id, "stat: called with wrong number of arguments");
+               return make_number(-1, result);
+       }
+
+       /* file is first arg, array to hold results is second */
+       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);
+       }
+
+       name = file_param.str_value.str;
+       array = array_param.array_cookie;
+
+       ret = fill_stat_array(name, array);
 
        return make_number(ret, result);
 }

-----------------------------------------------------------------------

Summary of changes:
 extension/ChangeLog   |    6 ++++
 extension/filefuncs.c |   66 ++++++++++++++++++++++++++++--------------------
 2 files changed, 44 insertions(+), 28 deletions(-)


hooks/post-receive
-- 
gawk



reply via email to

[Prev in Thread] Current Thread [Next in Thread]