diff options
author | Andreas Schuh <andreas.schuh.84@gmail.com> | 2016-06-28 12:15:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-06-28 12:15:02 +0100 |
commit | 546819b1d91d666c9e98a061fe2ff19f63cac9a7 (patch) | |
tree | 7230f3a224b3df621ae5079cd5d6e5c4c20e5e70 /src | |
parent | ac1a925c2bdec48e010020df93732badf75970e9 (diff) | |
parent | 0c17f1ee026694c37b09e8d07e19471e0fe48131 (diff) | |
download | gflags-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.cc | 6 |
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); |