Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
G
gflags
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
gflags
Commits
14c0e937
Commit
14c0e937
authored
Oct 12, 2016
by
Todd Lipcon
Committed by
Andreas Schuh
Nov 22, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert dashes to underscores for unknown flags (#177)
parent
cce68f0c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
1 deletion
+19
-1
gflags.cc
src/gflags.cc
+6
-1
gflags_unittest.cc
test/gflags_unittest.cc
+13
-0
No files found.
src/gflags.cc
View file @
14c0e937
...
...
@@ -771,7 +771,12 @@ void FlagRegistry::RegisterFlag(CommandLineFlag* flag) {
CommandLineFlag
*
FlagRegistry
::
FindFlagLocked
(
const
char
*
name
)
{
FlagConstIterator
i
=
flags_
.
find
(
name
);
if
(
i
==
flags_
.
end
())
{
return
NULL
;
// If the name has dashes in it, try again after replacing with
// underscores.
if
(
strchr
(
name
,
'-'
)
==
NULL
)
return
NULL
;
string
name_rep
=
name
;
std
::
replace
(
name_rep
.
begin
(),
name_rep
.
end
(),
'-'
,
'_'
);
return
FindFlagLocked
(
name_rep
.
c_str
());
}
else
{
return
i
->
second
;
}
...
...
test/gflags_unittest.cc
View file @
14c0e937
...
...
@@ -357,6 +357,19 @@ TEST(FlagFileTest, ReadFlagsFromString) {
false
,
123
,
123.0
);
// Test that flags can use dashes instead of underscores.
TestFlagString
(
// Flag string
"-test-string=initial
\n
"
"--test-bool=false
\n
"
"--test-int32=123
\n
"
"--test-double=123.0
\n
"
,
// Expected values
"initial"
,
false
,
123
,
123.0
);
}
// Tests the filename part of the flagfile
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment