Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AndroidSystemCore
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Werner Sembach
AndroidSystemCore
Commits
4ab75484
Commit
4ab75484
authored
Jun 7, 2016
by
Treehugger Robot
Committed by
Gerrit Code Review
Jun 7, 2016
Browse files
Options
Downloads
Plain Diff
Merge "init: Add support for ${x.y:-default} expansion"
parents
b67fed55
4b56162a
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
init/util.cpp
+13
-3
13 additions, 3 deletions
init/util.cpp
with
13 additions
and
3 deletions
init/util.cpp
+
13
−
3
View file @
4ab75484
...
...
@@ -489,6 +489,7 @@ bool expand_props(const std::string& src, std::string* dst) {
* - will accept $$ as a literal $.
* - no nested property expansion, i.e. ${foo.${bar}} is not supported,
* bad things will happen
* - ${x.y:-default} will return default value if property empty.
*/
while
(
*
src_ptr
)
{
const
char
*
c
;
...
...
@@ -511,6 +512,7 @@ bool expand_props(const std::string& src, std::string* dst) {
}
std
::
string
prop_name
;
std
::
string
def_val
;
if
(
*
c
==
'{'
)
{
c
++
;
const
char
*
end
=
strchr
(
c
,
'}'
);
...
...
@@ -521,6 +523,11 @@ bool expand_props(const std::string& src, std::string* dst) {
}
prop_name
=
std
::
string
(
c
,
end
);
c
=
end
+
1
;
size_t
def
=
prop_name
.
find
(
":-"
);
if
(
def
<
prop_name
.
size
())
{
def_val
=
prop_name
.
substr
(
def
+
2
);
prop_name
=
prop_name
.
substr
(
0
,
def
);
}
}
else
{
prop_name
=
c
;
ERROR
(
"using deprecated syntax for specifying property '%s', use ${name} instead
\n
"
,
...
...
@@ -535,10 +542,13 @@ bool expand_props(const std::string& src, std::string* dst) {
std
::
string
prop_val
=
property_get
(
prop_name
.
c_str
());
if
(
prop_val
.
empty
())
{
if
(
def_val
.
empty
())
{
ERROR
(
"property '%s' doesn't exist while expanding '%s'
\n
"
,
prop_name
.
c_str
(),
src
.
c_str
());
return
false
;
}
prop_val
=
def_val
;
}
dst
->
append
(
prop_val
);
src_ptr
=
c
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment