aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndreas Schuh <andreas.schuh.84@gmail.com>2016-06-28 12:15:02 +0100
committerGitHub <noreply@github.com>2016-06-28 12:15:02 +0100
commit546819b1d91d666c9e98a061fe2ff19f63cac9a7 (patch)
tree7230f3a224b3df621ae5079cd5d6e5c4c20e5e70 /src
parentac1a925c2bdec48e010020df93732badf75970e9 (diff)
parent0c17f1ee026694c37b09e8d07e19471e0fe48131 (diff)
downloadgflags-546819b1d91d666c9e98a061fe2ff19f63cac9a7.tar.gz
Merge pull request #152 from Liuchang0812/master
fix: Consider Windows-style LRLF in flag parsing
Diffstat (limited to 'src')
-rw-r--r--src/gflags.cc6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/gflags.cc b/src/gflags.cc
index c4a689d..a05d801 100644
--- a/src/gflags.cc
+++ b/src/gflags.cc
@@ -1278,7 +1278,11 @@ string CommandLineFlagParser::ProcessOptionsFromStringLocked(
for (; line_end; flagfile_contents = line_end + 1) {
while (*flagfile_contents && isspace(*flagfile_contents))
++flagfile_contents;
- line_end = strchr(flagfile_contents, '\n');
+ // Windows uses "\r\n"
+ line_end = strchr(flagfile_contents, '\r');
+ if (line_end == NULL)
+ line_end = strchr(flagfile_contents, '\n');
+
size_t len = line_end ? line_end - flagfile_contents
: strlen(flagfile_contents);
string line(flagfile_contents, len);