gawk-diffs
[Top][All Lists]
Advanced

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

[gawk-diffs] [SCM] gawk branch, select, updated. gawk-4.1.0-57-g27e1e91


From: Andrew J. Schorr
Subject: [gawk-diffs] [SCM] gawk branch, select, updated. gawk-4.1.0-57-g27e1e91
Date: Tue, 02 Jul 2013 02:04:30 +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, select has been updated
       via  27e1e910147465ad240a3e4393bbd4312937fed5 (commit)
      from  24a57029937207c4fa2ff4acb5a4e1ae1dc9e54b (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=27e1e910147465ad240a3e4393bbd4312937fed5

commit 27e1e910147465ad240a3e4393bbd4312937fed5
Author: Andrew J. Schorr <address@hidden>
Date:   Mon Jul 1 22:04:03 2013 -0400

    Add set_non_blocking function to the select extension.

diff --git a/extension/ChangeLog b/extension/ChangeLog
index 8b3e4bc..9218c74 100644
--- a/extension/ChangeLog
+++ b/extension/ChangeLog
@@ -1,5 +1,11 @@
 2013-07-01         Andrew J. Schorr     <address@hidden>
 
+       * select.c (do_set_non_blocking): Implement new set_non_blocking
+       function.
+       (func_table): Add set_non_blocking.
+
+2013-07-01         Andrew J. Schorr     <address@hidden>
+
        * errlist.h: New file containing a list of all the errno values I could
        find.
        * errno.c: Implement a new errno extension providing strerror,
diff --git a/extension/select.c b/extension/select.c
index 6211635..91898a2 100644
--- a/extension/select.c
+++ b/extension/select.c
@@ -33,6 +33,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <fcntl.h>
 
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -288,7 +289,7 @@ do_select(int nargs, awk_value_t *result)
                maxwait.tv_sec = maxwait.tv_usec = 0;
                timeout = &maxwait;
        }
-        else if (get_argument(3, AWK_NUMBER, &timeout_arg)) {
+       else if (get_argument(3, AWK_NUMBER, &timeout_arg)) {
                double secs = timeout_arg.num_value;
                if (secs < 0) {
                        warning(ext_id, _("select: treating negative timeout as 
zero"));
@@ -363,9 +364,39 @@ do_select(int nargs, awk_value_t *result)
        return make_number(rc, result);
 }
 
+/*  do_set_non_blocking --- Set a file to be non-blocking */
+
+static awk_value_t *
+do_set_non_blocking(int nargs, awk_value_t *result)
+{
+       awk_value_t cmd, cmdtype;
+
+       if (do_lint && nargs > 2)
+               lintwarn(ext_id, _("set_non_blocking: called with too many 
arguments"));
+       if (get_argument(0, AWK_STRING, & cmd) &&
+               get_argument(1, AWK_STRING, & cmdtype)) {
+               const awk_input_buf_t *buf;
+               if ((buf = get_file(cmd.str_value.str, cmd.str_value.len, 
cmdtype.str_value.str, cmdtype.str_value.len)) != NULL) {
+                       int flags = fcntl(buf->fd, F_GETFL);
+                       int rc = fcntl(buf->fd, F_SETFL, (flags|O_NONBLOCK));
+                       if (rc < 0)
+                               update_ERRNO_int(errno);
+                       return make_number(rc, result);
+               } else
+                       warning(ext_id, _("set_non_blocking: get_file(`%s', 
`%s') failed"), cmd.str_value.str, cmdtype.str_value.str);
+       } else if (do_lint) {
+               if (nargs < 2)
+                       lintwarn(ext_id, _("set_non_blocking: called with too 
few arguments"));
+               else
+                       lintwarn(ext_id, _("set_non_blocking: called with 
inappropriate argument(s)"));
+       }
+       return make_number(-1, result);
+}
+
 static awk_ext_func_t func_table[] = {
        { "select", do_select, 5 },
        { "select_signal", do_signal, 2 },
+       { "set_non_blocking", do_set_non_blocking, 2 },
 };
 
 /* define the dl_load function using the boilerplate macro */

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

Summary of changes:
 extension/ChangeLog |    6 ++++++
 extension/select.c  |   33 ++++++++++++++++++++++++++++++++-
 2 files changed, 38 insertions(+), 1 deletions(-)


hooks/post-receive
-- 
gawk



reply via email to

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