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. gawk-4.1.0-1390-g681a5d


From: Andrew J. Schorr
Subject: [gawk-diffs] [SCM] gawk branch, master, updated. gawk-4.1.0-1390-g681a5d8
Date: Fri, 15 May 2015 13:20:36 +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  681a5d8b52b7c5725c54bdab507c3c63effad142 (commit)
      from  3cb8fca4531cb348984bfc5ff499fbd1e1036f69 (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=681a5d8b52b7c5725c54bdab507c3c63effad142

commit 681a5d8b52b7c5725c54bdab507c3c63effad142
Author: Andrew J. Schorr <address@hidden>
Date:   Fri May 15 09:20:13 2015 -0400

    Add PROCINFO["argv"] array to contain the command-line arguments.

diff --git a/ChangeLog b/ChangeLog
index 1837262..8e2e51a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2015-05-15         Andrew J. Schorr     <address@hidden>
+
+       * main.c (load_procinfo_argv): New function to save argv array values
+       in PROCINFO["argv"][0..argc-1].
+       (load_procinfo): Call load_procinfo_argv.
+
 2015-05-05         Arnold D. Robbins     <address@hidden>
 
        * awkgram.y (yylex): Yet Another Fix for parsing bracket
diff --git a/doc/ChangeLog b/doc/ChangeLog
index 6a19e9d..edb19d4 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,7 @@
+2015-05-15         Andrew J. Schorr     <address@hidden>
+
+       * gawktexi.in (Undocumented): Describe the new PROCINFO["argv"] array.
+
 2015-05-14         Arnold D. Robbins     <address@hidden>
 
        * gawktexi.in (Bugs): Add that email should be in plain
diff --git a/doc/gawk.texi b/doc/gawk.texi
index b684341..b1ff494 100644
--- a/doc/gawk.texi
+++ b/doc/gawk.texi
@@ -4907,6 +4907,25 @@ function names added by @command{gawk} after the code 
was written.
 Standard @command{awk} built-in functions, such as @code{sin()} or
 @code{substr()} are @emph{not} shadowed in this way.
 
+The @code{PROCINFO["argv"]} array contains all of the command-line arguments
+(after glob expansion and redirection processing on platforms where that must
+be done manually by the program) with subscripts ranging from 0 through
address@hidden @minus{} 1.  For example, @code{PROCINFO["argv"][0]} will contain
+the name by which @command{gawk} was invoked.  Here is an example of how this
+feature may be used:
+
address@hidden
+awk '
+BEGIN @{
+        for (i = 0; i < length(PROCINFO["argv"]); i++)
+                print i, PROCINFO["argv"][i]
address@hidden'
address@hidden example
+
+Please note that this differs from the standard @code{ARGV} array which does
+not include command-line arguments that have already been processed by
address@hidden (@pxref{ARGC and ARGV}).
+
 @end ignore
 
 @node Invoking Summary
diff --git a/doc/gawktexi.in b/doc/gawktexi.in
index da7eeef..2610a74 100644
--- a/doc/gawktexi.in
+++ b/doc/gawktexi.in
@@ -4818,6 +4818,25 @@ function names added by @command{gawk} after the code 
was written.
 Standard @command{awk} built-in functions, such as @code{sin()} or
 @code{substr()} are @emph{not} shadowed in this way.
 
+The @code{PROCINFO["argv"]} array contains all of the command-line arguments
+(after glob expansion and redirection processing on platforms where that must
+be done manually by the program) with subscripts ranging from 0 through
address@hidden @minus{} 1.  For example, @code{PROCINFO["argv"][0]} will contain
+the name by which @command{gawk} was invoked.  Here is an example of how this
+feature may be used:
+
address@hidden
+awk '
+BEGIN @{
+        for (i = 0; i < length(PROCINFO["argv"]); i++)
+                print i, PROCINFO["argv"][i]
address@hidden'
address@hidden example
+
+Please note that this differs from the standard @code{ARGV} array which does
+not include command-line arguments that have already been processed by
address@hidden (@pxref{ARGC and ARGV}).
+
 @end ignore
 
 @node Invoking Summary
diff --git a/main.c b/main.c
index ef4f855..b17ab30 100644
--- a/main.c
+++ b/main.c
@@ -892,6 +892,33 @@ load_environ()
        return ENVIRON_node;
 }
 
+static void
+load_procinfo_argv()
+{
+       NODE *tmp;
+       NODE **aptr;
+       NODE *argv_array;
+       int i;
+
+       tmp = make_string("argv", 4);
+       aptr = assoc_lookup(PROCINFO_node, tmp);
+       unref(tmp);
+       unref(*aptr);
+       getnode(argv_array);
+       memset(argv_array, '\0', sizeof(NODE));  /* valgrind wants this */
+       null_array(argv_array);
+       *aptr = argv_array;
+       argv_array->parent_array = PROCINFO_node;
+       argv_array->vname = estrdup("argv", 4);
+       for (i = 0; d_argv[i] != NULL; i++) {
+               tmp = make_number(i);
+               aptr = assoc_lookup(argv_array, tmp);
+               unref(tmp);
+               unref(*aptr);
+               *aptr = make_string(d_argv[i], strlen(d_argv[i]));
+       }
+}
+
 /* load_procinfo --- populate the PROCINFO array */
 
 static NODE *
@@ -991,6 +1018,7 @@ load_procinfo()
                groupset = NULL;
        }
 #endif
+       load_procinfo_argv();
        return PROCINFO_node;
 }
 

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

Summary of changes:
 ChangeLog       |    6 ++++++
 doc/ChangeLog   |    4 ++++
 doc/gawk.texi   |   19 +++++++++++++++++++
 doc/gawktexi.in |   19 +++++++++++++++++++
 main.c          |   28 ++++++++++++++++++++++++++++
 5 files changed, 76 insertions(+), 0 deletions(-)


hooks/post-receive
-- 
gawk



reply via email to

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