public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/libbash:master commit in: src/core/
@ 2011-04-02 15:50 Petteri Räty
  0 siblings, 0 replies; 13+ messages in thread
From: Petteri Räty @ 2011-04-02 15:50 UTC (permalink / raw
  To: gentoo-commits

commit:     d732ef09039f155b824086d43c13b23ff7698ffc
Author:     Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Fri Apr  1 05:23:49 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Sat Apr  2 00:55:07 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=d732ef09

Add member functions to support variable traversal

Add begin() and end() method to the scope and interpreter class to
allow variable traversal.

---
 src/core/interpreter.h |   43 +++++++++++++++++++++++++++++++++++++++++++
 src/core/symbols.hpp   |   48 ++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 91 insertions(+), 0 deletions(-)

diff --git a/src/core/interpreter.h b/src/core/interpreter.h
index 1da370c..ef95caa 100644
--- a/src/core/interpreter.h
+++ b/src/core/interpreter.h
@@ -46,6 +46,49 @@ class interpreter{
   scope members;
 public:
 
+  ///
+  /// \brief return the number of variables
+  /// \return the number of variables
+  scope::size_type size()
+  {
+    return members.size();
+  }
+
+  ///
+  /// \brief return an iterator referring to the first variable
+  /// \return iterator referring to the first variable
+  scope::iterator begin()
+  {
+    return members.begin();
+  }
+
+  ///
+  /// \brief return a const iterator referring to the first variable
+  /// \return const iterator referring to the first variable
+  scope::const_iterator begin() const
+  {
+    return members.begin();
+  }
+
+  ///
+  /// \brief return an iterator referring to the next element after the
+  ///        last variable
+  /// \return iterator referring to he next element after the last variable
+  scope::iterator end()
+  {
+    return members.end();
+  }
+
+  ///
+  /// \brief return a const iterator referring to the next element after
+  ///        the last variable
+  /// \return const iterator referring to he next element after the last
+  ///         variable
+  scope::const_iterator end() const
+  {
+    return members.end();
+  }
+
   /// \brief parse the text value of a tree to integer
   /// \param the target tree
   /// \return the parsed value

diff --git a/src/core/symbols.hpp b/src/core/symbols.hpp
index bde05fb..53b699e 100644
--- a/src/core/symbols.hpp
+++ b/src/core/symbols.hpp
@@ -175,6 +175,54 @@ class scope
 public:
   typedef std::unordered_map<std::string, std::shared_ptr<symbol>>
     table_type;
+  typedef table_type::iterator iterator;
+  typedef table_type::const_iterator const_iterator;
+  typedef table_type::size_type size_type;
+  typedef table_type::value_type value_type;
+
+  ///
+  /// \brief return the number of symbols in current scope
+  /// \return the number of symbols
+  size_type size()
+  {
+    return members.size();
+  }
+
+  ///
+  /// \brief return an iterator referring to the first symbol
+  /// \return iterator referring to the first symbol
+  iterator begin()
+  {
+    return members.begin();
+  }
+
+  ///
+  /// \brief return a const iterator referring to the first symbol
+  /// \return const iterator referring to the first symbol
+  const_iterator begin() const
+  {
+    return members.begin();
+  }
+
+  ///
+  /// \brief return an iterator referring to the next element after
+  ///        the last symbol in current scope
+  /// \return iterator referring to he next element after the last
+  ///         symbol in current scope
+  iterator end()
+  {
+    return members.end();
+  }
+
+  ///
+  /// \brief return a const iterator referring to the next element
+  ///        after the last symbol in current scope
+  /// \return const iterator referring to he next element after the
+  ///         last symbol in current scope
+  const_iterator end() const
+  {
+    return members.end();
+  }
 
   /// \brief define a new symbol
   /// \param the new symbol



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [gentoo-commits] proj/libbash:master commit in: src/core/
@ 2011-04-06  7:43 Petteri Räty
  0 siblings, 0 replies; 13+ messages in thread
From: Petteri Räty @ 2011-04-06  7:43 UTC (permalink / raw
  To: gentoo-commits

commit:     37b99d0aabacec4ee882b346dfcefb1abb183f57
Author:     Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Tue Apr  5 11:33:34 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Tue Apr  5 11:33:34 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=37b99d0a

Add comment for do_default_expansion

---
 src/core/interpreter.h |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/src/core/interpreter.h b/src/core/interpreter.h
index 340828a..c0cc12d 100644
--- a/src/core/interpreter.h
+++ b/src/core/interpreter.h
@@ -415,6 +415,10 @@ public:
     members.define(target);
   }
 
+  /// \brief perform ${parameter:−word} expansion
+  /// \param the name of the parameter
+  /// \param the value of the word
+  /// \return the expansion result
   const std::string do_default_expansion(const std::string& name,
                                          const std::string& value)
   {



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [gentoo-commits] proj/libbash:master commit in: src/core/
@ 2011-04-08 11:12 Petteri Räty
  0 siblings, 0 replies; 13+ messages in thread
From: Petteri Räty @ 2011-04-08 11:12 UTC (permalink / raw
  To: gentoo-commits

commit:     2b259cdcba5249a41c741c7b22b480becb4e1b0d
Author:     Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Fri Apr  8 03:16:45 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Fri Apr  8 11:01:32 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=2b259cdc

Use unique_ptr instead of shared_ptr in parser_builder

We don't want to share the ownership of the AST, so use unique_ptr
instead.

---
 src/core/parser_builder.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/core/parser_builder.h b/src/core/parser_builder.h
index 654f0eb..e6833af 100644
--- a/src/core/parser_builder.h
+++ b/src/core/parser_builder.h
@@ -46,7 +46,7 @@ class parser_builder
   libbashLexer_Ctx_struct* lxr;
   pANTLR3_COMMON_TOKEN_STREAM tstream;
   libbashParser_Ctx_struct* psr;
-  std::shared_ptr<libbashParser_start_return_struct> langAST;
+  std::unique_ptr<libbashParser_start_return_struct> langAST;
   pANTLR3_COMMON_TREE_NODE_STREAM nodes;
 
   void init_parser();



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [gentoo-commits] proj/libbash:master commit in: src/core/
@ 2011-04-20 14:04 Petteri Räty
  0 siblings, 0 replies; 13+ messages in thread
From: Petteri Räty @ 2011-04-20 14:04 UTC (permalink / raw
  To: gentoo-commits

commit:     d508b94013714beb82a73b854d1a082754b7e999
Author:     Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Thu Apr 14 05:16:57 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Wed Apr 20 12:48:43 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=d508b940

Core: add const modifier to some methods

These methods should have been declared as const methods. After
having the hash table stored inside the interpreter class, it's
easier to do it.

---
 src/core/interpreter.cpp |    6 +++---
 src/core/interpreter.h   |   30 +++++++++++++++---------------
 2 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/src/core/interpreter.cpp b/src/core/interpreter.cpp
index c723173..d9004e8 100644
--- a/src/core/interpreter.cpp
+++ b/src/core/interpreter.cpp
@@ -28,7 +28,7 @@
 
 void interpreter::get_all_elements_joined(const std::string& name,
                                           const std::string& delim,
-                                          std::string& result)
+                                          std::string& result) const
 {
   std::vector<std::string> source;
 
@@ -45,13 +45,13 @@ void interpreter::get_all_elements_joined(const std::string& name,
 }
 
 void interpreter::get_all_elements(const std::string& name,
-                                   std::string& result)
+                                   std::string& result) const
 {
   get_all_elements_joined(name, " ", result);
 }
 
 void interpreter::get_all_elements_IFS_joined(const std::string& name,
-                                              std::string& result)
+                                              std::string& result) const
 {
   get_all_elements_joined(name,
                           resolve<std::string>("IFS").substr(0, 1),

diff --git a/src/core/interpreter.h b/src/core/interpreter.h
index e61748a..6385e6e 100644
--- a/src/core/interpreter.h
+++ b/src/core/interpreter.h
@@ -52,7 +52,7 @@ class interpreter{
   /// \param[in,out] a value/result argument referring to offset
   /// \param[in] the original string
   /// \return whether the real offset is in legal range
-  bool get_real_offset(int& offset, const std::string& str)
+  bool get_real_offset(int& offset, const std::string& str) const
   {
     offset = (offset >= 0? offset : str.size() + offset);
     return !(offset < 0 || offset >= static_cast<int>(str.size()));
@@ -60,7 +60,7 @@ class interpreter{
 
   void get_all_elements_joined(const std::string& name,
                                const std::string& delim,
-                               std::string& result);
+                               std::string& result) const;
 
 public:
 
@@ -72,7 +72,7 @@ public:
   ///
   /// \brief return the number of variables
   /// \return the number of variables
-  scope::size_type size()
+  scope::size_type size() const
   {
     return members.size();
   }
@@ -378,7 +378,7 @@ public:
   /// \return the value of the variable, call default constructor if
   ///         it's undefined
   template <typename T>
-  T resolve(const std::string& name, const unsigned index=0)
+  T resolve(const std::string& name, const unsigned index=0) const
   {
     auto i = members.find(name);
     if(i == members.end())
@@ -390,7 +390,7 @@ public:
   /// \param variable name
   /// \param[out] vector that stores all array values
   template <typename T>
-  void resolve_array(const std::string& name, std::vector<T>& values)
+  void resolve_array(const std::string& name, std::vector<T>& values) const
   {
     auto i = members.find(name);
     if(i == members.end())
@@ -403,7 +403,7 @@ 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, const unsigned index)
+  bool is_unset_or_null(const std::string& name, const unsigned index) const
   {
     auto i = members.find(name);
     if(i == members.end())
@@ -415,7 +415,7 @@ public:
   /// \brief check whether the value of the variable is unset
   /// \param variable name
   /// \return whether the value of the variable is unset
-  bool is_unset(const std::string& name)
+  bool is_unset(const std::string& name) const
   {
     return members.find(name) == members.end();
   }
@@ -463,7 +463,7 @@ public:
   /// \return the expansion result
   const std::string do_default_expansion(const std::string& name,
                                          const std::string& value,
-                                         const unsigned index)
+                                         const unsigned index) const
   {
     return (is_unset_or_null(name, index)?
         value : resolve<std::string>(name, index));
@@ -487,7 +487,7 @@ public:
   /// \return the expansion result
   const std::string do_alternate_expansion(const std::string& name,
                                            const std::string& value,
-                                           const unsigned index)
+                                           const unsigned index) const
   {
     return (is_unset_or_null(name, index)? "" : value);
   }
@@ -497,7 +497,7 @@ public:
   /// \return the expansion result
   const std::string do_substring_expansion(const std::string& name,
                                            int offset,
-                                           const unsigned index)
+                                           const unsigned index) const
   {
     std::string value = resolve<std::string>(name, index);
     if(!get_real_offset(offset, value))
@@ -512,7 +512,7 @@ public:
   const std::string do_substring_expansion(const std::string& name,
                                            int offset,
                                            int length,
-                                           const unsigned index)
+                                           const unsigned index) const
   {
     if(length < 0)
       throw interpreter_exception("length of substring expression should be greater or equal to zero");
@@ -525,7 +525,7 @@ public:
   /// \brief get the length of a string variable
   /// \param the name of the variable
   /// \return the length
-  unsigned get_length(const std::string& name, const unsigned index=0)
+  unsigned get_length(const std::string& name, const unsigned index=0) const
   {
     auto i = members.find(name);
     if(i == members.end())
@@ -536,7 +536,7 @@ public:
   /// \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)
+  unsigned get_array_length(const std::string& name) const
   {
     auto i = members.find(name);
     if(i == members.end())
@@ -545,8 +545,8 @@ public:
       return i->second->get_array_length();
   }
 
-  void get_all_elements(const std::string&, std::string&);
+  void get_all_elements(const std::string&, std::string&) const;
 
-  void get_all_elements_IFS_joined(const std::string&, std::string&);
+  void get_all_elements_IFS_joined(const std::string&, std::string&) const;
 };
 #endif



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [gentoo-commits] proj/libbash:master commit in: src/core/
@ 2011-05-06 10:29 Petteri Räty
  0 siblings, 0 replies; 13+ messages in thread
From: Petteri Räty @ 2011-05-06 10:29 UTC (permalink / raw
  To: gentoo-commits

commit:     57e1da1c18d5c9f7c6f5e35bd9146cacf0ace689
Author:     Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Thu May  5 12:09:10 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Fri May  6 10:26:56 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=57e1da1c

Core: refactor interpreter class

Some large methods are moved into cpp source file.

---
 src/core/interpreter.cpp |   73 ++++++++++++++++++++++++++++++++++++++++++++++
 src/core/interpreter.h   |   64 ++++------------------------------------
 2 files changed, 80 insertions(+), 57 deletions(-)

diff --git a/src/core/interpreter.cpp b/src/core/interpreter.cpp
index f0bf61e..5363636 100644
--- a/src/core/interpreter.cpp
+++ b/src/core/interpreter.cpp
@@ -36,6 +36,79 @@
 
 #include "libbashWalker.h"
 
+std::string interpreter::get_string(pANTLR3_BASE_TREE node)
+{
+  pANTLR3_COMMON_TOKEN token = node->getToken(node);
+  // The tree walker may send null pointer here, so return an empty
+  // string if that's the case.
+  if(!token->start)
+    return "";
+  // Use reinterpret_cast here because we have to cast C code.
+  // The real type here is int64_t which is used as a pointer.
+  return std::string(reinterpret_cast<const char *>(token->start),
+                     token->stop - token->start + 1);
+}
+
+bool interpreter::is_unset_or_null(const std::string& name,
+                                   const unsigned index) const
+{
+  auto i = members.find(name);
+  if(i == members.end())
+    return true;
+  else
+    return i->second->is_null(index);
+}
+
+const std::string interpreter::do_substring_expansion(const std::string& name,
+                                                      int offset,
+                                                      const unsigned index) const
+{
+  std::string value = resolve<std::string>(name, index);
+  if(!get_real_offset(offset, value))
+    return "";
+  return value.substr(offset);
+}
+
+const std::string interpreter::do_substring_expansion(const std::string& name,
+                                                      int offset,
+                                                      int length,
+                                                      const unsigned index) const
+{
+  if(length < 0)
+    throw interpreter_exception("length of substring expression should be greater or equal to zero");
+  std::string value = resolve<std::string>(name, index);
+  if(!get_real_offset(offset, value))
+    return "";
+  return value.substr(offset, length);
+}
+
+std::string interpreter::do_replace_expansion(const std::string& name,
+                                              std::function<void(std::string&)> replacer,
+                                              const unsigned index) const
+{
+  std::string value = resolve<std::string>(name, index);
+  replacer(value);
+  return value;
+}
+
+unsigned interpreter::get_length(const std::string& name,
+                                 const unsigned index) const
+{
+  auto i = members.find(name);
+  if(i == members.end())
+    return 0;
+  return i->second->get_length(index);
+}
+
+unsigned interpreter::get_array_length(const std::string& name) const
+{
+  auto i = members.find(name);
+  if(i == members.end())
+    return 0;
+  else
+    return i->second->get_array_length();
+}
+
 void interpreter::get_all_elements_joined(const std::string& name,
                                           const std::string& delim,
                                           std::string& result) const

diff --git a/src/core/interpreter.h b/src/core/interpreter.h
index dc446fc..35ae8ac 100644
--- a/src/core/interpreter.h
+++ b/src/core/interpreter.h
@@ -155,18 +155,7 @@ public:
   ///        of the given pANTLR3_BASE_TREE node.
   /// \param the target tree node
   /// \return the value of node->text
-  static std::string get_string(pANTLR3_BASE_TREE node)
-  {
-    pANTLR3_COMMON_TOKEN token = node->getToken(node);
-    // The tree walker may send null pointer here, so return an empty
-    // string if that's the case.
-    if(!token->start)
-      return "";
-    // Use reinterpret_cast here because we have to cast C code.
-    // The real type here is int64_t which is used as a pointer.
-    return std::string(reinterpret_cast<const char *>(token->start),
-                       token->stop - token->start + 1);
-  }
+  static std::string get_string(pANTLR3_BASE_TREE node);
 
   /// \brief perform logic or
   /// \param the first operand
@@ -442,14 +431,7 @@ 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, const unsigned index) const
-  {
-    auto i = members.find(name);
-    if(i == members.end())
-      return true;
-    else
-      return i->second->is_null(index);
-  }
+  bool is_unset_or_null(const std::string& name, const unsigned index) const;
 
   /// \brief check whether the value of the variable is unset
   /// \param variable name
@@ -598,13 +580,7 @@ public:
   /// \return the expansion result
   const std::string do_substring_expansion(const std::string& name,
                                            int offset,
-                                           const unsigned index) const
-  {
-    std::string value = resolve<std::string>(name, index);
-    if(!get_real_offset(offset, value))
-      return "";
-    return value.substr(offset);
-  }
+                                           const unsigned index) const;
 
   /// \brief perform substring expansion
   /// \param the offset of the substring
@@ -613,15 +589,7 @@ public:
   const std::string do_substring_expansion(const std::string& name,
                                            int offset,
                                            int length,
-                                           const unsigned index) const
-  {
-    if(length < 0)
-      throw interpreter_exception("length of substring expression should be greater or equal to zero");
-    std::string value = resolve<std::string>(name, index);
-    if(!get_real_offset(offset, value))
-      return "";
-    return value.substr(offset, length);
-  }
+                                           const unsigned index) const;
 
   /// \brief perform replacement expansion
   /// \param the name of the varaible that needs to be expanded
@@ -630,35 +598,17 @@ public:
   /// \return the expanded value
   std::string do_replace_expansion(const std::string& name,
                                    std::function<void(std::string&)> replacer,
-                                   const unsigned index) const
-  {
-    std::string value = resolve<std::string>(name, index);
-    replacer(value);
-    return value;
-  }
+                                   const unsigned index) const;
 
   /// \brief get the length of a string variable
   /// \param the name of the variable
   /// \return the length
-  unsigned get_length(const std::string& name, const unsigned index=0) const
-  {
-    auto i = members.find(name);
-    if(i == members.end())
-      return 0;
-    return i->second->get_length(index);
-  }
+  unsigned get_length(const std::string& name, const unsigned index=0) const;
 
   /// \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) const
-  {
-    auto i = members.find(name);
-    if(i == members.end())
-      return 0;
-    else
-      return i->second->get_array_length();
-  }
+  unsigned get_array_length(const std::string& name) const;
 
   /// \brief get all array elements concatenated by space
   /// \param the name of the array



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [gentoo-commits] proj/libbash:master commit in: src/core/
@ 2011-05-23 14:34 Petteri Räty
  0 siblings, 0 replies; 13+ messages in thread
From: Petteri Räty @ 2011-05-23 14:34 UTC (permalink / raw
  To: gentoo-commits

commit:     4b15b140c2bf80a536f1116373fad87dcee843c4
Author:     Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Mon May 23 14:41:45 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Mon May 23 14:41:45 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=4b15b140

Core: avoid abbreviations for member names

---
 src/core/bash_ast.cpp |   38 +++++++++++++++++++-------------------
 src/core/bash_ast.h   |    8 ++++----
 2 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/src/core/bash_ast.cpp b/src/core/bash_ast.cpp
index 0bf8938..d70520e 100644
--- a/src/core/bash_ast.cpp
+++ b/src/core/bash_ast.cpp
@@ -52,62 +52,62 @@ bash_ast::bash_ast(std::istream& source): error_count(0)
 bash_ast::~bash_ast()
 {
   nodes->free(nodes);
-  psr->free(psr);
-  tstream->free(tstream);
-  lxr->free(lxr);
+  parser->free(parser);
+  token_stream->free(token_stream);
+  lexer->free(lexer);
   input->close(input);
 }
 
 void bash_ast::init_parser()
 {
-  lxr = libbashLexerNew(input);
-  if ( lxr == NULL )
+  lexer = libbashLexerNew(input);
+  if ( lexer == NULL )
   {
     std::cerr << "Unable to create the lexer due to malloc() failure" << std::endl;
     error_count = 1;
     return;
   }
 
-  tstream = antlr3CommonTokenStreamSourceNew(
-      ANTLR3_SIZE_HINT, lxr->pLexer->rec->state->tokSource);
-  if (tstream == NULL)
+  token_stream = antlr3CommonTokenStreamSourceNew(
+      ANTLR3_SIZE_HINT, lexer->pLexer->rec->state->tokSource);
+  if (token_stream == NULL)
   {
     std::cerr << "Out of memory trying to allocate token stream" << std::endl;
     error_count = 1;
     return;
   }
 
-  psr = libbashParserNew(tstream);
-  if (psr == NULL)
+  parser = libbashParserNew(token_stream);
+  if (parser == NULL)
   {
     std::cerr << "Out of memory trying to allocate parser" << std::endl;
     error_count = 1;
     return;
   }
 
-  langAST.reset(new libbashParser_start_return(psr->start(psr)));
-  error_count = psr->pParser->rec->getNumberOfSyntaxErrors(psr->pParser->rec);
-  nodes = antlr3CommonTreeNodeStreamNewTree(langAST->tree, ANTLR3_SIZE_HINT);
+  ast.reset(new libbashParser_start_return(parser->start(parser)));
+  error_count = parser->pParser->rec->getNumberOfSyntaxErrors(parser->pParser->rec);
+  nodes = antlr3CommonTreeNodeStreamNewTree(ast->tree, ANTLR3_SIZE_HINT);
 }
 
 void bash_ast::interpret_with(interpreter& walker)
 {
   set_interpreter(&walker);
-  plibbashWalker treePsr = libbashWalkerNew(nodes);
-  treePsr->start(treePsr);
-  treePsr->free(treePsr);
+  plibbashWalker treeparser = libbashWalkerNew(nodes);
+  treeparser->start(treeparser);
+  treeparser->free(treeparser);
 }
 
 std::string bash_ast::get_dot_graph()
 {
-  pANTLR3_STRING graph = nodes->adaptor->makeDot(nodes->adaptor, langAST->tree);
+  pANTLR3_STRING graph = nodes->adaptor->makeDot(nodes->adaptor, ast->tree);
   return std::string(reinterpret_cast<char*>(graph->chars));
 }
 
 std::string bash_ast::get_string_tree()
 {
   return std::string(reinterpret_cast<char*>(
-        langAST->tree->toStringTree(langAST->tree)->chars));
+        ast->tree->toStringTree(ast->tree)->chars));
 }
 
 namespace
@@ -131,7 +131,7 @@ std::string bash_ast::get_tokens(std::function<std::string(ANTLR3_INT32)> token_
   // output line number for the first line
   result << line_counter++ << "\t";
 
-  pANTLR3_VECTOR token_list = tstream->getTokens(tstream);
+  pANTLR3_VECTOR token_list = token_stream->getTokens(token_stream);
   unsigned token_size = token_list->size(token_list);
 
   for(unsigned i = 0; i != token_size; ++i)

diff --git a/src/core/bash_ast.h b/src/core/bash_ast.h
index e587d81..168d012 100644
--- a/src/core/bash_ast.h
+++ b/src/core/bash_ast.h
@@ -43,10 +43,10 @@ class bash_ast
 {
   pANTLR3_INPUT_STREAM input;
   std::string script;
-  libbashLexer_Ctx_struct* lxr;
-  pANTLR3_COMMON_TOKEN_STREAM tstream;
-  libbashParser_Ctx_struct* psr;
-  std::unique_ptr<libbashParser_start_return_struct> langAST;
+  libbashLexer_Ctx_struct* lexer;
+  pANTLR3_COMMON_TOKEN_STREAM token_stream;
+  libbashParser_Ctx_struct* parser;
+  std::unique_ptr<libbashParser_start_return_struct> ast;
   pANTLR3_COMMON_TREE_NODE_STREAM nodes;
   int error_count;
 



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [gentoo-commits] proj/libbash:master commit in: src/core/
@ 2011-06-03 14:48 Petteri Räty
  0 siblings, 0 replies; 13+ messages in thread
From: Petteri Räty @ 2011-06-03 14:48 UTC (permalink / raw
  To: gentoo-commits

commit:     0d0d5f090555c638b8d06767a14f800e9aecedec
Author:     Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Fri Jun  3 07:19:29 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Fri Jun  3 12:53:53 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=0d0d5f09

Core: rename internal streams to avoid conflicts

---
 src/core/interpreter.cpp |    2 +-
 src/core/interpreter.h   |   16 ++++++++--------
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/core/interpreter.cpp b/src/core/interpreter.cpp
index fc12a7a..3a065cb 100644
--- a/src/core/interpreter.cpp
+++ b/src/core/interpreter.cpp
@@ -40,7 +40,7 @@
 
 #include "core/interpreter.h"
 
-interpreter::interpreter(): out(&std::cout), err(&std::cerr), in(&std::cin), bash_options(
+interpreter::interpreter(): _out(&std::cout), _err(&std::cerr), _in(&std::cin), bash_options(
     {
       {"autocd", false},
       {"cdable_vars", false},

diff --git a/src/core/interpreter.h b/src/core/interpreter.h
index 2c5f383..40d3d51 100644
--- a/src/core/interpreter.h
+++ b/src/core/interpreter.h
@@ -62,11 +62,11 @@ class interpreter
   ///        local variables
   std::vector<scope> local_members;
 
-  std::ostream* out;
+  std::ostream* _out;
 
-  std::ostream* err;
+  std::ostream* _err;
 
-  std::istream* in;
+  std::istream* _in;
 
   std::unordered_map<std::string, bool> bash_options;
 
@@ -163,12 +163,12 @@ public:
 
   void set_output_stream(std::ostream* stream)
   {
-    out = stream;
+    _out = stream;
   }
 
   void restore_output_stream()
   {
-    out = &std::cout;
+    _out = &std::cout;
   }
 
   /// \brief parse the text value of a tree to integer
@@ -581,9 +581,9 @@ public:
   {
     return cppbash_builtin::exec(name,
                                  args,
-                                 output == 0 ? *out : *output,
-                                 error == 0 ? *err : *error,
-                                 input == 0 ? *in : *input,
+                                 output == 0 ? *_out : *output,
+                                 error == 0 ? *_err : *error,
+                                 input == 0 ? *_in : *input,
                                  *this);
   }
 



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [gentoo-commits] proj/libbash:master commit in: src/core/
@ 2011-06-09  7:27 Petteri Räty
  0 siblings, 0 replies; 13+ messages in thread
From: Petteri Räty @ 2011-06-09  7:27 UTC (permalink / raw
  To: gentoo-commits

commit:     96ad12582fcae25e1fc49d3848a77a27952df15a
Author:     Petteri Räty <petsku <AT> petteriraty <DOT> eu>
AuthorDate: Fri Jun  3 16:57:32 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Mon Jun  6 07:06:20 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=96ad1258

Core: fix memory leaks in bash_ast::init_parser

If init_parser threw an exception the already allocated memory wasn't
freed. Now we use our own wrapper antlr_pointer to make sure the memory
always gets freed.

---
 src/core/bash_ast.cpp |   35 +++++++++++++----------------------
 src/core/bash_ast.h   |   24 ++++++++++++++----------
 2 files changed, 27 insertions(+), 32 deletions(-)

diff --git a/src/core/bash_ast.cpp b/src/core/bash_ast.cpp
index 8f06311..b0ef4f8 100644
--- a/src/core/bash_ast.cpp
+++ b/src/core/bash_ast.cpp
@@ -52,47 +52,38 @@ bash_ast::bash_ast(const std::string& script_path,
   init_parser(script, script_path);
 }
 
-bash_ast::~bash_ast()
-{
-  nodes->free(nodes);
-  parser->free(parser);
-  token_stream->free(token_stream);
-  lexer->free(lexer);
-  input->close(input);
-}
-
 void bash_ast::init_parser(const std::string& script, const std::string& script_path)
 {
-  input = antlr3NewAsciiStringInPlaceStream(
+  input.reset(antlr3NewAsciiStringInPlaceStream(
     reinterpret_cast<pANTLR3_UINT8>(const_cast<char*>(script.c_str())),
     // We do not support strings longer than the max value of ANTLR3_UNIT32
     boost::numeric_cast<ANTLR3_UINT32>(script.size()),
-    NULL);
+    NULL));
 
-  if(input == NULL)
+  if(!input)
     throw interpreter_exception("Unable to open file " + script + " due to malloc() failure");
 
   input->fileName = input->strFactory->newStr(
       input->strFactory,
       reinterpret_cast<pANTLR3_UINT8>(const_cast<char*>(script_path.c_str())));
 
-  lexer = libbashLexerNew(input);
-  if ( lexer == NULL )
+  lexer.reset(libbashLexerNew(input.get()));
+  if(!lexer)
     throw interpreter_exception("Unable to create the lexer due to malloc() failure");
 
-  token_stream = antlr3CommonTokenStreamSourceNew(
-      ANTLR3_SIZE_HINT, lexer->pLexer->rec->state->tokSource);
-  if (token_stream == NULL)
+  token_stream.reset(antlr3CommonTokenStreamSourceNew(
+      ANTLR3_SIZE_HINT, lexer->pLexer->rec->state->tokSource));
+  if(!token_stream)
     throw interpreter_exception("Out of memory trying to allocate token stream");
 
-  parser = libbashParserNew(token_stream);
-  if (parser == NULL)
+  parser.reset(libbashParserNew(token_stream.get()));
+  if(!parser)
     throw interpreter_exception("Out of memory trying to allocate parser");
 
-  ast = parse(parser);
+  ast = parse(parser.get());
   if(parser->pParser->rec->getNumberOfSyntaxErrors(parser->pParser->rec))
     throw interpreter_exception("Something wrong happened while parsing");
-  nodes = antlr3CommonTreeNodeStreamNewTree(ast, ANTLR3_SIZE_HINT);
+  nodes.reset(antlr3CommonTreeNodeStreamNewTree(ast, ANTLR3_SIZE_HINT));
 }
 
 std::string bash_ast::get_dot_graph()
@@ -127,7 +118,7 @@ std::string bash_ast::get_tokens(std::function<std::string(ANTLR3_UINT32)> token
   // output line number for the first line
   result << line_counter++ << "\t";
 
-  pANTLR3_VECTOR token_list = token_stream->getTokens(token_stream);
+  pANTLR3_VECTOR token_list = token_stream->getTokens(token_stream.get());
   unsigned token_size = token_list->size(token_list);
 
   for(unsigned i = 0u; i != token_size; ++i)

diff --git a/src/core/bash_ast.h b/src/core/bash_ast.h
index d5d7f83..aa045bf 100644
--- a/src/core/bash_ast.h
+++ b/src/core/bash_ast.h
@@ -40,17 +40,25 @@ struct libbashLexer_Ctx_struct;
 struct libbashParser_Ctx_struct;
 class interpreter;
 
+template<typename T>
+class antlr_pointer: public std::unique_ptr<T, std::function<void(T*)>>
+{
+  typedef std::unique_ptr<T, std::function<void(T*)>> parent;
+public:
+  antlr_pointer(T* p = 0) : parent(p, [](T* to_delete) { to_delete->free(to_delete); }) {};
+};
+
 /// \class bash_ast
 /// \brief a wrapper class that helps interpret from istream and string
 class bash_ast: public boost::noncopyable
 {
-  pANTLR3_INPUT_STREAM input;
+  antlr_pointer<ANTLR3_INPUT_STREAM_struct> input;
   std::string script;
-  libbashLexer_Ctx_struct* lexer;
-  pANTLR3_COMMON_TOKEN_STREAM token_stream;
-  libbashParser_Ctx_struct* parser;
+  antlr_pointer<libbashLexer_Ctx_struct> lexer;
+  antlr_pointer<ANTLR3_COMMON_TOKEN_STREAM_struct> token_stream;
+  antlr_pointer<libbashParser_Ctx_struct> parser;
   pANTLR3_BASE_TREE ast;
-  pANTLR3_COMMON_TREE_NODE_STREAM nodes;
+  antlr_pointer<ANTLR3_COMMON_TREE_NODE_STREAM_struct> nodes;
   std::function<pANTLR3_BASE_TREE(libbashParser_Ctx_struct*)> parse;
 
   void init_parser(const std::string& script, const std::string& script_path);
@@ -62,8 +70,6 @@ public:
   bash_ast(const std::string& script_path,
            std::function<pANTLR3_BASE_TREE(libbashParser_Ctx_struct*)> p=parser_start);
 
-  ~bash_ast();
-
   static void walker_start(plibbashWalker tree_parser);
 
   static int walker_arithmetics(plibbashWalker tree_parser);
@@ -81,9 +87,7 @@ public:
   interpret_with(interpreter& walker, Functor walk)
   {
     set_interpreter(&walker);
-    std::unique_ptr<libbashWalker_Ctx_struct, std::function<void(plibbashWalker)>> p_tree_parser(
-        libbashWalkerNew(nodes),
-        [](plibbashWalker tree_parser) { tree_parser->free(tree_parser); });
+    antlr_pointer<libbashWalker_Ctx_struct> p_tree_parser(libbashWalkerNew(nodes.get()));
     return walk(p_tree_parser.get());
   }
 



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [gentoo-commits] proj/libbash:master commit in: src/core/
@ 2011-06-09 11:46 Petteri Räty
  0 siblings, 0 replies; 13+ messages in thread
From: Petteri Räty @ 2011-06-09 11:46 UTC (permalink / raw
  To: gentoo-commits

commit:     897042d1040c866d8bcfb151c3f168b3fbc4480a
Author:     Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Wed Jun  8 09:35:04 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Thu Jun  9 11:41:23 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=897042d1

Core: remove unnecessary include

---
 src/core/interpreter.h |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/src/core/interpreter.h b/src/core/interpreter.h
index 3ed4664..1e47fc9 100644
--- a/src/core/interpreter.h
+++ b/src/core/interpreter.h
@@ -37,7 +37,6 @@
 
 #include "core/symbols.hpp"
 #include "cppbash_builtin.h"
-#include "libbashLexer.h"
 
 typedef std::unordered_map<std::string, std::shared_ptr<variable>> scope;
 struct libbashWalker_Ctx_struct;



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [gentoo-commits] proj/libbash:master commit in: src/core/
@ 2011-06-11  8:24 Petteri Räty
  0 siblings, 0 replies; 13+ messages in thread
From: Petteri Räty @ 2011-06-11  8:24 UTC (permalink / raw
  To: gentoo-commits

commit:     6b9f53515fa8111bf486324cfb33a22d31c0e046
Author:     Petteri Räty <petsku <AT> petteriraty <DOT> eu>
AuthorDate: Thu Jun  9 21:17:36 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Fri Jun 10 14:51:40 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=6b9f5351

Core: reduce file dependencies

Now bash_ast.h doesn't include libbashWalker.h any more. This means much
less files have to be recompiled after touching bashast.g. For example
for unit tests it's only required to relink the cppunittests binary.

---
 src/core/bash_ast.cpp |   16 ++++++++++++++++
 src/core/bash_ast.h   |   19 +++++++------------
 2 files changed, 23 insertions(+), 12 deletions(-)

diff --git a/src/core/bash_ast.cpp b/src/core/bash_ast.cpp
index cb85e2e..c029d6f 100644
--- a/src/core/bash_ast.cpp
+++ b/src/core/bash_ast.cpp
@@ -27,8 +27,10 @@
 #include <boost/numeric/conversion/cast.hpp>
 
 #include "core/interpreter_exception.h"
+#include "core/interpreter.h"
 #include "libbashLexer.h"
 #include "libbashParser.h"
+#include "libbashWalker.h"
 
 bash_ast::bash_ast(const std::istream& source,
                    std::function<pANTLR3_BASE_TREE(plibbashParser)> p): parse(p)
@@ -179,3 +181,17 @@ void bash_ast::call_function(plibbashWalker ctx,
   // Execute function body
   ctx->compound_command(ctx);
 }
+
+bash_ast::walker_pointer bash_ast::create_walker(interpreter& walker)
+{
+    set_interpreter(&walker);
+    walker.push_current_ast(this);
+
+    auto deleter = [&](plibbashWalker tree_parser)
+    {
+      tree_parser->free(tree_parser);
+      walker.pop_current_ast();
+    };
+
+    return walker_pointer(libbashWalkerNew(nodes.get()), deleter);
+}

diff --git a/src/core/bash_ast.h b/src/core/bash_ast.h
index 4163ad4..63e35d1 100644
--- a/src/core/bash_ast.h
+++ b/src/core/bash_ast.h
@@ -34,11 +34,11 @@
 #include <antlr3.h>
 #include <boost/utility.hpp>
 
-#include "core/interpreter.h"
-#include "libbashWalker.h"
-
 struct libbashLexer_Ctx_struct;
 struct libbashParser_Ctx_struct;
+struct libbashWalker_Ctx_struct;
+typedef libbashWalker_Ctx_struct* plibbashWalker;
+class interpreter;
 
 template<typename T>
 class antlr_pointer: public std::unique_ptr<T, std::function<void(T*)>>
@@ -61,7 +61,10 @@ class bash_ast: public boost::noncopyable
   antlr_pointer<ANTLR3_COMMON_TREE_NODE_STREAM_struct> nodes;
   std::function<pANTLR3_BASE_TREE(libbashParser_Ctx_struct*)> parse;
 
+  typedef std::unique_ptr<libbashWalker_Ctx_struct, std::function<void(plibbashWalker)>> walker_pointer;
+
   void init_parser(const std::string& script, const std::string& script_path);
+  walker_pointer create_walker(interpreter& walker);
 
 public:
   bash_ast(const std::istream& source,
@@ -89,15 +92,7 @@ public:
   typename std::result_of<Functor(plibbashWalker)>::type
   interpret_with(interpreter& walker, Functor walk)
   {
-    set_interpreter(&walker);
-    walker.push_current_ast(this);
-    std::unique_ptr<libbashWalker_Ctx_struct, std::function<void(plibbashWalker)>> p_tree_parser(
-        libbashWalkerNew(nodes.get()),
-        [&](plibbashWalker tree_parser)
-        {
-          tree_parser->free(tree_parser);
-          walker.pop_current_ast();
-        });
+    walker_pointer p_tree_parser = create_walker(walker);
     return walk(p_tree_parser.get());
   }
 



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [gentoo-commits] proj/libbash:master commit in: src/core/
@ 2011-06-11  8:52 Petteri Räty
  0 siblings, 0 replies; 13+ messages in thread
From: Petteri Räty @ 2011-06-11  8:52 UTC (permalink / raw
  To: gentoo-commits

commit:     a10aa4fcd41b4b636a36e42ddbf60650108c20d8
Author:     Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Fri Jun 10 03:42:47 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Fri Jun 10 08:25:09 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=a10aa4fc

Core: declared some methods to be const

Some methods should have been declared to be const. Now this is fixed.

---
 src/core/interpreter.cpp |    4 ++--
 src/core/interpreter.h   |    8 ++++----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/core/interpreter.cpp b/src/core/interpreter.cpp
index d1eb411..fedbee4 100644
--- a/src/core/interpreter.cpp
+++ b/src/core/interpreter.cpp
@@ -236,7 +236,7 @@ void interpreter::get_all_elements_IFS_joined(const std::string& name,
                           result);
 }
 
-void interpreter::split_word(const std::string& word, std::vector<std::string>& output)
+void interpreter::split_word(const std::string& word, std::vector<std::string>& output) const
 {
   const std::string& delimeter = resolve<std::string>("IFS");
   std::string trimmed(word);
@@ -313,7 +313,7 @@ void interpreter::trim_trailing_eols(std::string& value)
   boost::trim_right_if(value, boost::is_any_of("\n"));
 }
 
-void interpreter::get_all_function_names(std::vector<std::string>& function_names)
+void interpreter::get_all_function_names(std::vector<std::string>& function_names) const
 {
   boost::copy(functions | boost::adaptors::map_keys, back_inserter(function_names));
 }

diff --git a/src/core/interpreter.h b/src/core/interpreter.h
index 38b4c94..937edd8 100644
--- a/src/core/interpreter.h
+++ b/src/core/interpreter.h
@@ -245,7 +245,7 @@ public:
   /// \brief get the return status of the last command
   /// \param the value of the return status
   template <typename T=int>
-  T get_status(void)
+  T get_status(void) const
   {
     return resolve<T>("?");
   }
@@ -322,12 +322,12 @@ public:
   /// \brief check if we have 'name' defined as a function
   /// \param function name
   /// \return whether 'name' is a function
-  bool has_function(const std::string& name)
+  bool has_function(const std::string& name) const
   {
     return functions.find(name) != functions.end();
   }
 
-  void get_all_function_names(std::vector<std::string>& function_names);
+  void get_all_function_names(std::vector<std::string>& function_names) const;
 
   /// \brief execute builtin
   /// \param builtin name
@@ -430,7 +430,7 @@ public:
   /// \brief implementation of word splitting
   /// \param the value of the word
   //. \param[out] the splitted result will be appended to output
-  void split_word(const std::string& word, std::vector<std::string>& output);
+  void split_word(const std::string& word, std::vector<std::string>& output) const;
 
   /// \brief get the status of shell optional behavior
   /// \param the option name



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [gentoo-commits] proj/libbash:master commit in: src/core/
@ 2011-07-08 14:03 Petteri Räty
  0 siblings, 0 replies; 13+ messages in thread
From: Petteri Räty @ 2011-07-08 14:03 UTC (permalink / raw
  To: gentoo-commits

commit:     8c2eecbbb064f86c1e81323dbfb6c315fc1b2631
Author:     Petteri Räty <petsku <AT> petteriraty <DOT> eu>
AuthorDate: Wed May 18 09:55:03 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Wed May 18 12:43:01 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=8c2eecbb

Core: fix memory leak

bash_ast::interpret_with was leaking memory when return_exception was
thrown when interpreting.

---
 src/core/bash_ast.cpp |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/src/core/bash_ast.cpp b/src/core/bash_ast.cpp
index 2f729a4..22c7f22 100644
--- a/src/core/bash_ast.cpp
+++ b/src/core/bash_ast.cpp
@@ -119,7 +119,15 @@ void bash_ast::interpret_with(interpreter& walker)
 
   auto nodes = antlr3CommonTreeNodeStreamNewTree(langAST->tree, ANTLR3_SIZE_HINT);
   plibbashWalker treePsr = libbashWalkerNew(nodes);
-  treePsr->start(treePsr);
+  try
+  {
+    treePsr->start(treePsr);
+  }
+  catch(...)
+  {
+    treePsr->free(treePsr);
+    throw;
+  }
   treePsr->free(treePsr);
   nodes->free(nodes);
 }



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [gentoo-commits] proj/libbash:master commit in: src/core/
@ 2011-08-04 14:24 Petteri Räty
  0 siblings, 0 replies; 13+ messages in thread
From: Petteri Räty @ 2011-08-04 14:24 UTC (permalink / raw
  To: gentoo-commits

commit:     fd5fae5995f7ff66358268bb0dd15a072f4a6f57
Author:     Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Thu Aug  4 07:58:16 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Thu Aug  4 14:15:15 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=fd5fae59

Doc: reduce doxygen warnings

---
 src/core/bash_ast.h    |    1 +
 src/core/interpreter.h |   13 +++++++------
 src/core/symbols.hpp   |    2 +-
 3 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/src/core/bash_ast.h b/src/core/bash_ast.h
index dd85ae8..50ca7a6 100644
--- a/src/core/bash_ast.h
+++ b/src/core/bash_ast.h
@@ -117,6 +117,7 @@ public:
 
   /// \brief the functor for parser builtin_variable_definitions rule
   /// \param parser the pointer to the parser
+  /// \param local whether to define the variables in local scope
   static pANTLR3_BASE_TREE parser_builtin_variable_definitions(libbashParser_Ctx_struct* parser, bool local);
 
   ///

diff --git a/src/core/interpreter.h b/src/core/interpreter.h
index 091d4b7..fcc3294 100644
--- a/src/core/interpreter.h
+++ b/src/core/interpreter.h
@@ -76,8 +76,8 @@ class interpreter: public boost::noncopyable
 
   /// \brief calculate the correct offset when offset < 0 and check whether
   ///        the real offset is in legal range
-  /// \param[in,out] a value/result argument referring to offset
-  /// \param[in] the original string
+  /// \param[in,out] offset a value/result argument referring to offset
+  /// \param[in] size the size of the original string
   /// \return whether the real offset is in legal range
   bool get_real_offset(long long& offset, const unsigned size) const
   {
@@ -368,6 +368,7 @@ public:
   }
 
   /// \brief perform ${parameter:−word} expansion
+  /// \param cond whether to perform expansion
   /// \param name the name of the parameter
   /// \param value the value of the word
   /// \param index the index of the paramter
@@ -381,6 +382,7 @@ public:
   }
 
   /// \brief perform ${parameter:=word} expansion
+  /// \param cond whether to perform expansion
   /// \param name the name of the parameter
   /// \param value the value of the word
   /// \param index the index of the paramter
@@ -394,9 +396,8 @@ public:
   }
 
   /// \brief perform ${parameter:+word} expansion
-  /// \param name the name of the parameter
+  /// \param cond whether to perform expansion
   /// \param value the value of the word
-  /// \param index the index of the paramter
   /// \return the expansion result
   const std::string do_alternate_expansion(bool cond,
                                            const std::string& value) const
@@ -472,7 +473,7 @@ public:
 
   /// \brief implementation of word splitting
   /// \param word the value of the word
-  //. \param[out] output the splitted result will be appended to output
+  ///.\param[out] output the splitted result will be appended to output
   void split_word(const std::string& word, std::vector<std::string>& output) const;
 
   /// \brief get the status of shell optional behavior
@@ -507,7 +508,7 @@ public:
   long eval_arithmetic(const std::string& expression);
 
   /// \brief shift the positional parameters to the left by n.
-  /// \param the number to be shifted
+  /// \param shift_number the number to be shifted
   /// \return zero unless n is greater than $# or less than zero, non-zero otherwise.
   int shift(int shift_number);
 

diff --git a/src/core/symbols.hpp b/src/core/symbols.hpp
index 15a3fa0..8dd8cd3 100644
--- a/src/core/symbols.hpp
+++ b/src/core/symbols.hpp
@@ -267,7 +267,7 @@ public:
 
 /// \brief the specialized constructor for arrays
 /// \param name the variable name
-/// \param value the variable value
+/// \param v the variable value
 /// \param ro whether the variable readonly
 template <>
 inline variable::variable<>(const std::string& name,



^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2011-08-04 14:25 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-09 11:46 [gentoo-commits] proj/libbash:master commit in: src/core/ Petteri Räty
  -- strict thread matches above, loose matches on Subject: below --
2011-08-04 14:24 Petteri Räty
2011-07-08 14:03 Petteri Räty
2011-06-11  8:52 Petteri Räty
2011-06-11  8:24 Petteri Räty
2011-06-09  7:27 Petteri Räty
2011-06-03 14:48 Petteri Räty
2011-05-23 14:34 Petteri Räty
2011-05-06 10:29 Petteri Räty
2011-04-20 14:04 Petteri Räty
2011-04-08 11:12 Petteri Räty
2011-04-06  7:43 Petteri Räty
2011-04-02 15:50 Petteri Räty

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox