gawk-diffs
[Top][All Lists]
Advanced

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

[gawk-diffs] [SCM] gawk branch, constants, updated. 24f5ceced8702af452f0


From: Arnold Robbins
Subject: [gawk-diffs] [SCM] gawk branch, constants, updated. 24f5ceced8702af452f0a79c40a8336ee0d47d1b
Date: Thu, 14 Mar 2013 10:25:09 +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, constants has been updated
       via  24f5ceced8702af452f0a79c40a8336ee0d47d1b (commit)
      from  ee30213e1b93fc708951afd105d367c75ae067b8 (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=24f5ceced8702af452f0a79c40a8336ee0d47d1b

commit 24f5ceced8702af452f0a79c40a8336ee0d47d1b
Author: Arnold D. Robbins <address@hidden>
Date:   Thu Mar 14 12:24:32 2013 +0200

    Allow := in -v and command line assignments.

diff --git a/ChangeLog b/ChangeLog
index 423659e..a513d4e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-03-14         Arnold D. Robbins     <address@hidden>
+
+       * main.c (arg_assign): Recognize ":=" in a variable assignment to
+       do a constant assignment.
+
 2013-03-11         Arnold D. Robbins     <address@hidden>
 
        * re.c (check_bracket_exp): Make handling of embedded ] in
diff --git a/main.c b/main.c
index 785935e..357f8e4 100644
--- a/main.c
+++ b/main.c
@@ -1249,6 +1249,7 @@ arg_assign(char *arg, bool initing)
        NODE *it;
        NODE **lhs;
        long save_FNR;
+       bool isconst = false;
 
        if (! initing && disallow_var_assigns)
                return false;   /* --exec */
@@ -1263,10 +1264,14 @@ arg_assign(char *arg, bool initing)
                        _("%s: `%s' argument to `-v' not in `var=value' 
form\n\n"),
                        myname, arg);
                usage(EXIT_FAILURE, stderr);
+       } else {
+               if (cp[-1] == ':') {
+                       isconst = true;
+                       cp[-1] = '\0';  /* will need restoring */
+               }
+               *cp++ = '\0';   /* temporarily nuke the = */
        }
 
-       *cp++ = '\0';
-
        /* avoid false source indications in a fatal message */
        source = NULL;
        sourceline = 0;
@@ -1334,13 +1339,19 @@ arg_assign(char *arg, bool initing)
                lhs = get_lhs(var, false);
                unref(*lhs);
                *lhs = it;
+               if (isconst)
+                       (*lhs)->flags |= VAR_CONST;
                /* check for set_FOO() routine */
                if (var->type == Node_var && var->var_assign)
                        var->var_assign();
        }
 
-       if (! initing)
+       if (! initing) {
                *--cp = '=';    /* restore original text of ARGV */
+               if (isconst)
+                       *--cp = ':';    /* restore it all the way */
+       }
+
        FNR = save_FNR;
        return ! badvar;
 }

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

Summary of changes:
 ChangeLog |    5 +++++
 main.c    |   17 ++++++++++++++---
 2 files changed, 19 insertions(+), 3 deletions(-)


hooks/post-receive
-- 
gawk



reply via email to

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