From mboxrd@z Thu Jan  1 00:00:00 1970
Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org)
	by finch.gentoo.org with esmtp (Exim 4.60)
	(envelope-from <gentoo-commits+bounces-336009-garchives=archives.gentoo.org@lists.gentoo.org>)
	id 1QAEWE-0001W5-PO
	for garchives@archives.gentoo.org; Thu, 14 Apr 2011 04:51:05 +0000
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 373411C03C;
	Thu, 14 Apr 2011 04:50:18 +0000 (UTC)
Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183])
	by pigeon.gentoo.org (Postfix) with ESMTP id E63E11C03A
	for <gentoo-commits@lists.gentoo.org>; Thu, 14 Apr 2011 04:50:17 +0000 (UTC)
Received: from pelican.gentoo.org (unknown [66.219.59.40])
	(using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits))
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id 8E0131B4158
	for <gentoo-commits@lists.gentoo.org>; Thu, 14 Apr 2011 04:50:17 +0000 (UTC)
Received: from localhost.localdomain (localhost [127.0.0.1])
	by pelican.gentoo.org (Postfix) with ESMTP id EAE5880072
	for <gentoo-commits@lists.gentoo.org>; Thu, 14 Apr 2011 04:50:16 +0000 (UTC)
From: "Petteri Räty" <betelgeuse@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Petteri Räty" <betelgeuse@gentoo.org>
Message-ID: <9b72788bf2f6cd763a4f99f39827b1a8c19e8cb2.betelgeuse@gentoo>
Subject: [gentoo-commits] proj/libbash:master commit in: /
X-VCS-Repository: proj/libbash
X-VCS-Committer: betelgeuse
X-VCS-Committer-Name: Petteri Räty
X-VCS-Revision: 9b72788bf2f6cd763a4f99f39827b1a8c19e8cb2
Date: Thu, 14 Apr 2011 04:50:16 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: quoted-printable
X-Archives-Salt: 
X-Archives-Hash: 005f7d2a95d6e123beb954d33c4bdb6d

commit:     9b72788bf2f6cd763a4f99f39827b1a8c19e8cb2
Author:     Petteri R=C3=A4ty <petsku <AT> petteriraty <DOT> eu>
AuthorDate: Thu Apr 14 04:48:54 2011 +0000
Commit:     Petteri R=C3=A4ty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Thu Apr 14 04:48:54 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=3Dproj/libbash.git;a=
=3Dcommit;h=3D9b72788b

Merge remote-tracking branch 'mu/master'

Conflicts:
	src/core/interpreter.h


 bashast/bashast.g                           |   19 +++-
 bashast/features_script/features.sh.ast     |    2 +-
 bashast/gunit/arith_main.gunit              |   14 ++-
 bashast/gunit/array.gunit                   |    6 +-
 bashast/gunit/assoc_array.gunit             |    2 +-
 bashast/gunit/expansions.gunit              |    2 +-
 bashast/libbashWalker.g                     |  138 ++++++++++++++++++---=
------
 scripts/arithmetic_assignment.ebuild        |    2 +
 scripts/arithmetic_assignment.ebuild.result |    3 +
 scripts/binary_arithmetic.ebuild            |   30 ++++++-
 scripts/binary_arithmetic.ebuild.result     |   26 +++++-
 scripts/var_def.ebuild                      |   22 ++++-
 scripts/var_def.ebuild.result               |   14 +++-
 scripts/var_expansion.ebuild                |   15 +++-
 scripts/var_expansion.ebuild.result         |   14 +++
 src/core/interpreter.cpp                    |   36 +++++++
 src/core/interpreter.h                      |   89 ++++++++++++------
 src/core/symbols.hpp                        |   26 +++---
 src/core/tests/interpreter_test.cpp         |   17 +++-
 test/variable_printer.cpp                   |    4 +-
 test/walker_test.cpp                        |   13 +++
 21 files changed, 382 insertions(+), 112 deletions(-)

diff --cc src/core/interpreter.cpp
index 0086216,9f10949..c723173
--- a/src/core/interpreter.cpp
+++ b/src/core/interpreter.cpp
@@@ -21,3 -21,38 +21,39 @@@
  /// \author Mu Qiao
  /// \brief implementations for bash interpreter (visitor pattern).
  ///
+=20
+ #include "core/interpreter.h"
+=20
+ #include <boost/algorithm/string/join.hpp>
+=20
+ void interpreter::get_all_elements_joined(const std::string& name,
+                                           const std::string& delim,
+                                           std::string& result)
+ {
+   std::vector<std::string> source;
 -  std::shared_ptr<variable> value =3D members.resolve(name);
 -  if(value)
++
++  auto i =3D members.find(name);
++  if(i !=3D members.end())
+   {
 -    value->get_all_values(source);
++    i->second->get_all_values(source);
+     result =3D boost::algorithm::join(source, delim);
+   }
+   else
+   {
+     result =3D "";
+   }
+ }
+=20
+ void interpreter::get_all_elements(const std::string& name,
+                                    std::string& result)
+ {
+   get_all_elements_joined(name, " ", result);
+ }
+=20
+ void interpreter::get_all_elements_IFS_joined(const std::string& name,
+                                               std::string& result)
+ {
+   get_all_elements_joined(name,
+                           resolve<std::string>("IFS").substr(0, 1),
+                           result);
+ }
diff --cc src/core/interpreter.h
index 3baf029,5ac5027..e61748a
--- a/src/core/interpreter.h
+++ b/src/core/interpreter.h
@@@ -394,13 -401,13 +403,13 @@@ public
    ///        if the variable is undefined
    /// \param variable name
    /// \return whether the value of the variable is null
-   bool is_unset_or_null(const std::string& name)
+   bool is_unset_or_null(const std::string& name, const unsigned index)
    {
 -    std::shared_ptr<variable> value =3D members.resolve(name);
 -    if(value)
 -      return value->is_null(index);
 -    else
 +    auto i =3D members.find(name);
 +    if(i =3D=3D members.end())
        return true;
 +    else
-       return i->second->is_null();
++      return i->second->is_null(index);
    }
 =20
    /// \brief check whether the value of the variable is unset
@@@ -420,13 -427,14 +429,14 @@@
    template <typename T>
    const T& set_value(const std::string& name,
                       const T& new_value,
-                      const unsigned index=3D0)
+                      const unsigned index=3D0,
+                      bool is_null=3Dfalse)
    {
 -    std::shared_ptr<variable> value =3D members.resolve(name);
 -    if(!value)
 +    auto i =3D members.find(name);
 +    if(i =3D=3D members.end())
-       define(name, new_value, false);
+       define(name, new_value, false, is_null, index);
      else
-       i->second->set_value(new_value, index);
 -      value->set_value(new_value, index, is_null);
++      i->second->set_value(new_value, index, is_null);
      return new_value;
    }
 =20
@@@ -439,11 -447,12 +449,12 @@@
    void define(const std::string& name,
                const T& value,
                bool readonly=3Dfalse,
-               bool is_null=3Dfalse)
+               bool is_null=3Dfalse,
+               const unsigned index=3D0)
    {
      std::shared_ptr<variable> target(
-         new variable(name, value, readonly, is_null));
+         new variable(name, value, readonly, is_null, index));
 -    members.define(target);
 +    members[name] =3D target;
    }
 =20
    /// \brief perform ${parameter:=E2=88=92word} expansion
@@@ -509,11 -525,25 +527,26 @@@
    /// \return the length
    unsigned get_length(const std::string& name, const unsigned index=3D0=
)
    {
 -    std::shared_ptr<variable> value =3D members.resolve(name);
 -    if(!value)
 +    auto i =3D members.find(name);
 +    if(i =3D=3D members.end())
        return 0;
 -    return value->get_length(index);
 +    return i->second->get_length(index);
    }
 =20
+   /// \brief get the length of an array
+   /// \param the name of the array
+   /// \return the length of the array
+   unsigned get_array_length(const std::string& name)
+   {
 -    std::shared_ptr<variable> value =3D members.resolve(name);
 -    if(!value)
++    auto i =3D members.find(name);
++    if(i =3D=3D members.end())
+       return 0;
 -    return value->get_array_length();
++    else
++      return i->second->get_array_length();
+   }
+=20
+   void get_all_elements(const std::string&, std::string&);
+=20
+   void get_all_elements_IFS_joined(const std::string&, std::string&);
  };
  #endif