From 0c17f1ee026694c37b09e8d07e19471e0fe48131 Mon Sep 17 00:00:00 2001 From: liuchang0812 Date: Tue, 28 Jun 2016 17:57:02 +0800 Subject: [PATCH] fix bug about LRLF --- src/gflags.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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); -- 2.7.4