Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
tianlh
LightGBM-DCU
Commits
8de2bac5
Commit
8de2bac5
authored
Oct 11, 2016
by
Guolin Ke
Browse files
fix error while using quotation marks in parameters.
parent
9649512e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
4 deletions
+13
-4
include/LightGBM/utils/common.h
include/LightGBM/utils/common.h
+9
-0
src/application/application.cpp
src/application/application.cpp
+4
-4
No files found.
include/LightGBM/utils/common.h
View file @
8de2bac5
...
...
@@ -34,6 +34,15 @@ inline static std::string& Trim(std::string& str) {
return
str
;
}
inline
static
std
::
string
&
RemoveQuotationSymbol
(
std
::
string
&
str
)
{
if
(
str
.
size
()
<=
0
)
{
return
str
;
}
str
.
erase
(
str
.
find_last_not_of
(
"'
\"
"
)
+
1
);
str
.
erase
(
0
,
str
.
find_first_not_of
(
"'
\"
"
));
return
str
;
}
inline
static
std
::
vector
<
std
::
string
>
Split
(
const
char
*
str
,
char
delimiter
)
{
std
::
stringstream
ss
(
str
);
std
::
string
tmp_str
;
...
...
src/application/application.cpp
View file @
8de2bac5
...
...
@@ -61,8 +61,8 @@ void Application::LoadParameters(int argc, char** argv) {
for
(
int
i
=
0
;
i
<
argc
;
++
i
)
{
std
::
vector
<
std
::
string
>
tmp_strs
=
Common
::
Split
(
argv
[
i
],
'='
);
if
(
tmp_strs
.
size
()
==
2
)
{
std
::
string
key
=
Common
::
Trim
(
tmp_strs
[
0
]);
std
::
string
value
=
Common
::
Trim
(
tmp_strs
[
1
]);
std
::
string
key
=
Common
::
RemoveQuotationSymbol
(
Common
::
Trim
(
tmp_strs
[
0
])
)
;
std
::
string
value
=
Common
::
RemoveQuotationSymbol
(
Common
::
Trim
(
tmp_strs
[
1
])
)
;
if
(
key
.
size
()
<=
0
)
{
continue
;
}
...
...
@@ -84,8 +84,8 @@ void Application::LoadParameters(int argc, char** argv) {
}
std
::
vector
<
std
::
string
>
tmp_strs
=
Common
::
Split
(
line
.
c_str
(),
'='
);
if
(
tmp_strs
.
size
()
==
2
)
{
std
::
string
key
=
Common
::
Trim
(
tmp_strs
[
0
]);
std
::
string
value
=
Common
::
Trim
(
tmp_strs
[
1
]);
std
::
string
key
=
Common
::
RemoveQuotationSymbol
(
Common
::
Trim
(
tmp_strs
[
0
])
)
;
std
::
string
value
=
Common
::
RemoveQuotationSymbol
(
Common
::
Trim
(
tmp_strs
[
1
])
)
;
if
(
key
.
size
()
<=
0
)
{
continue
;
}
...
...
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