gawk-diffs
[Top][All Lists]
Advanced

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

[gawk-diffs] [SCM] gawk branch, master, updated. 150130bb66391dea89da18d


From: Arnold Robbins
Subject: [gawk-diffs] [SCM] gawk branch, master, updated. 150130bb66391dea89da18d470547bf1b9129ff9
Date: Sun, 21 Oct 2012 19:42:55 +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, master has been updated
       via  150130bb66391dea89da18d470547bf1b9129ff9 (commit)
       via  d61172dcf8117f4d3092a186122e3c66c17c58ba (commit)
      from  104a4dbd6430d1b96dbf44601738c3652bcc85c9 (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=150130bb66391dea89da18d470547bf1b9129ff9

commit 150130bb66391dea89da18d470547bf1b9129ff9
Author: Arnold D. Robbins <address@hidden>
Date:   Sun Oct 21 21:42:35 2012 +0200

    More API doc.

diff --git a/doc/api.texi b/doc/api.texi
index 144c6b9..7fdfcdc 100644
--- a/doc/api.texi
+++ b/doc/api.texi
@@ -244,22 +244,6 @@ When @option{--sandbox} is specified, extensions are 
disabled
 * Plugin License::              A note about licensing.
 @end menu
 
address@hidden Plugin License
address@hidden Extension Licensing
-
-Every dynamic extension should define the global symbol
address@hidden to assert that it has been licensed under
-a GPL-compatible license.  If this symbol does not exist, @command{gawk}
-will emit a fatal error and exit.
-
-The declared type of the symbol should be @code{int}.  It does not need
-to be in any allocated section, though.  The code merely asserts that
-the symbol exists in the global scope.  Something like this is enough:
-
address@hidden
-int plugin_is_GPL_compatible;
address@hidden example
-
 @node Extension Intro
 @section Introduction
 
@@ -282,6 +266,22 @@ decisions behind the API, the facilities it provides and 
how to use
 them, and presents a small sample extension.  In addition, it documents
 the sample extensions included in the @command{gawk} distribution.
 
address@hidden Plugin License
address@hidden Extension Licensing
+
+Every dynamic extension should define the global symbol
address@hidden to assert that it has been licensed under
+a GPL-compatible license.  If this symbol does not exist, @command{gawk}
+will emit a fatal error and exit.
+
+The declared type of the symbol should be @code{int}.  It does not need
+to be in any allocated section, though.  The code merely asserts that
+the symbol exists in the global scope.  Something like this is enough:
+
address@hidden
+int plugin_is_GPL_compatible;
address@hidden example
+
 @node Extension Design
 @section Extension API Design
 
@@ -2290,6 +2290,9 @@ If there's an error, it sets @code{ERRNO} and returns:
     name = file_param.str_value.str;
     array = array_param.array_cookie;
 
+    /* always empty out the array */
+    clear_array(array);
+
     /* lstat the file, if error, set ERRNO and return */
     ret = lstat(name, & sbuf);
     if (ret < 0) @{
@@ -2359,32 +2362,28 @@ Now that the code is written, it must be possible to 
add it at
 runtime to the running @command{gawk} interpreter.  First, the
 code must be compiled.  Assuming that the functions are in
 a file named @file{filefuncs.c}, and @var{idir} is the location
-of the @command{gawk} include files,
-the following steps create
-a GNU/Linux shared library:
+of the @file{gawkapi.h} header file,
+the following steps create a GNU/Linux shared library:
 
 @example
 $ @kbd{gcc -fPIC -shared -DHAVE_CONFIG_H -c -O -g address@hidden filefuncs.c}
-$ @kbd{ld -o filefuncs.so -shared filefuncs.o}
+$ @kbd{ld -o filefuncs.so -shared filefuncs.o -lc}
 @end example
 
address@hidden @code{extension()} function (@command{gawk})
-Once the library exists, it is loaded by calling the @code{extension()}
-built-in function.
-This function takes two arguments: the name of the
-library to load and the name of a function to call when the library
-is first loaded. This function adds the new functions to @command{gawk}.
-It returns the value returned by the initialization function
-within the shared library:
+Once the library exists, it is loaded by using the @code{@@load} keyword.
 
 @example
 # file testff.awk
+@@load "filefuncs"
+
 BEGIN @{
-    extension("./filefuncs.so", "dl_load")
+    "pwd" | getline curdir  # save current directory
+    close("pwd")
 
-    chdir(".")  # no-op
+    chdir("/tmp")
+    system("pwd")   # test it
+    chdir(curdir)   # go back
 
-    data[1] = 1 # force `data' to be an array
     print "Info for testff.awk"
     ret = stat("testff.awk", data)
     print "ret =", ret
@@ -2402,28 +2401,31 @@ BEGIN @{
 @}
 @end example
 
-Here are the results of running the program:
+The @env{AWKLIBPATH} environment variable tells
address@hidden where to find shared libraries (FIXME: PXREF).
+We set it to the current directory and run the program:
 
 @example
-$ @kbd{gawk -f testff.awk}
+$ @kbd{AWKLIBPATH=$PWD gawk -f testff.awk}
address@hidden /tmp
 @print{} Info for testff.awk
 @print{} ret = 0
address@hidden data["size"] = 607
address@hidden data["ino"] = 14945891
address@hidden data["name"] = testff.awk
address@hidden data["pmode"] = -rw-rw-r--
address@hidden data["nlink"] = 1
address@hidden data["atime"] = 1293993369
address@hidden data["mtime"] = 1288520752
address@hidden data["mode"] = 33204
 @print{} data["blksize"] = 4096
address@hidden data["dev"] = 2054
address@hidden data["mtime"] = 1350838628
address@hidden data["mode"] = 33204
 @print{} data["type"] = file
address@hidden data["gid"] = 500
address@hidden data["uid"] = 500
address@hidden data["dev"] = 2053
address@hidden data["gid"] = 1000
address@hidden data["ino"] = 1719496
address@hidden data["ctime"] = 1350838628
 @print{} data["blocks"] = 8
address@hidden data["ctime"] = 1290113572
address@hidden testff.awk modified: 10 31 10 12:25:52
address@hidden data["nlink"] = 1
address@hidden data["name"] = testff.awk
address@hidden data["atime"] = 1350838632
address@hidden data["pmode"] = -rw-rw-r--
address@hidden data["size"] = 662
address@hidden data["uid"] = 1000
address@hidden testff.awk modified: 10 21 12 18:57:08
 @print{} 
 @print{} Info for JUNK
 @print{} ret = -1
@@ -2436,11 +2438,11 @@ $ @kbd{gawk -f testff.awk}
 @menu
 @end menu
 
address@hidden can pull doc from man pages in extension directory
+
 @node Extension Sample File Functions
 @subsection File Related Functions
 
address@hidden can pull doc from man pages in extension directory
-
 @node Extension Sample Fnmatch
 @subsection Interface To @code{fnmatch()}
 

http://git.sv.gnu.org/cgit/gawk.git/commit/?id=d61172dcf8117f4d3092a186122e3c66c17c58ba

commit d61172dcf8117f4d3092a186122e3c66c17c58ba
Author: Arnold D. Robbins <address@hidden>
Date:   Sun Oct 21 21:42:19 2012 +0200

    Bug fix in do_stat().

diff --git a/extension/ChangeLog b/extension/ChangeLog
index 8889420..d83b194 100644
--- a/extension/ChangeLog
+++ b/extension/ChangeLog
@@ -1,3 +1,7 @@
+2012-10-21         Arnold D. Robbins     <address@hidden>
+
+       * filefuncs.c (do_stat): Always clear the array.
+
 2012-10-14         Arnold D. Robbins     <address@hidden>
 
        * readdir.c, revoutput.c, revtwoway.c: Adjust for name change
diff --git a/extension/filefuncs.c b/extension/filefuncs.c
index bc2f2af..f2479c5 100644
--- a/extension/filefuncs.c
+++ b/extension/filefuncs.c
@@ -359,6 +359,9 @@ do_stat(int nargs, awk_value_t *result)
        name = file_param.str_value.str;
        array = array_param.array_cookie;
 
+       /* always empty out the array */
+       clear_array(array);
+
        /* lstat the file, if error, set ERRNO and return */
        ret = lstat(name, & sbuf);
        if (ret < 0) {

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

Summary of changes:
 doc/api.texi          |   98 +++++++++++++++++++++++++------------------------
 extension/ChangeLog   |    4 ++
 extension/filefuncs.c |    3 +
 3 files changed, 57 insertions(+), 48 deletions(-)


hooks/post-receive
-- 
gawk



reply via email to

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