From: "Petteri Räty" <betelgeuse@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/libbash:master commit in: scripts/, src/core/, bashast/
Date: Wed, 6 Apr 2011 15:07:11 +0000 (UTC) [thread overview]
Message-ID: <3c91e9d0018e0763dff71c856bd9c0c3fd4b83aa.betelgeuse@gentoo> (raw)
commit: 3c91e9d0018e0763dff71c856bd9c0c3fd4b83aa
Author: Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Wed Apr 6 10:25:29 2011 +0000
Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Wed Apr 6 10:25:29 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=3c91e9d0
Implement ${#parameter} expansion
---
bashast/libbashWalker.g | 3 +++
scripts/var_expansion.ebuild | 2 ++
scripts/var_expansion.ebuild.result | 2 ++
src/core/interpreter.h | 8 ++++++++
4 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/bashast/libbashWalker.g b/bashast/libbashWalker.g
index e6f4393..71aba2e 100644
--- a/bashast/libbashWalker.g
+++ b/bashast/libbashWalker.g
@@ -104,6 +104,9 @@ var_expansion returns[std::string libbash_value]
libbash_value = walker->do_substring_expansion($var_name.libbash_value, offset, length);
else
libbash_value = walker->do_substring_expansion($var_name.libbash_value, offset);
+ }
+ |^(POUND var_name) {
+ libbash_value = boost::lexical_cast<std::string>(walker->get_length($var_name.libbash_value));
};
word returns[std::string libbash_value]:
diff --git a/scripts/var_expansion.ebuild b/scripts/var_expansion.ebuild
index b0402a8..0045b5e 100644
--- a/scripts/var_expansion.ebuild
+++ b/scripts/var_expansion.ebuild
@@ -22,3 +22,5 @@ FOO020=${FOO009: -2:2}
FOO021=${FOO009:2:100}
FOO022=${FOO009: -2:100}
FOO023=${NOT_EXIST:0:2}
+FOO024=${#FOO009}
+FOO025=${#NOT_EXIST}
diff --git a/scripts/var_expansion.ebuild.result b/scripts/var_expansion.ebuild.result
index 5695d1a..e7b767a 100644
--- a/scripts/var_expansion.ebuild.result
+++ b/scripts/var_expansion.ebuild.result
@@ -23,3 +23,5 @@ FOO020=lo
FOO021=llo
FOO022=lo
FOO023=
+FOO024=5
+FOO025=0
diff --git a/src/core/interpreter.h b/src/core/interpreter.h
index cde08ac..1e5f1dc 100644
--- a/src/core/interpreter.h
+++ b/src/core/interpreter.h
@@ -485,5 +485,13 @@ public:
return value.substr(offset, length);
}
+ /// \brief get the length of a string variable
+ /// \param the name of the variable
+ /// \return the length
+ int get_length(const std::string& name)
+ {
+ return resolve<std::string>(name).size();
+ }
+
};
#endif
next reply other threads:[~2011-04-06 15:07 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-06 15:07 Petteri Räty [this message]
-- strict thread matches above, loose matches on Subject: below --
2012-08-19 14:54 [gentoo-commits] proj/libbash:master commit in: scripts/, src/core/, bashast/ Petteri Räty
2011-08-04 13:53 Petteri Räty
2011-06-09 8:15 Petteri Räty
2011-06-03 14:48 Petteri Räty
2011-05-15 11:19 Petteri Räty
2011-05-11 7:19 Petteri Räty
2011-05-07 12:25 Petteri Räty
2011-04-20 14:04 Petteri Räty
2011-04-20 14:04 Petteri Räty
2011-04-20 14:04 Petteri Räty
2011-04-14 4:50 Petteri Räty
2011-04-06 7:43 Petteri Räty
2011-04-04 16:09 Petteri Räty
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3c91e9d0018e0763dff71c856bd9c0c3fd4b83aa.betelgeuse@gentoo \
--to=betelgeuse@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox