fix bug about LRLF
authorliuchang0812 <liuchang0812@gmail.com>
Tue, 28 Jun 2016 09:57:02 +0000 (17:57 +0800)
committerliuchang0812 <liuchang0812@gmail.com>
Tue, 28 Jun 2016 09:57:02 +0000 (17:57 +0800)
src/gflags.cc

index c4a689d..a05d801 100644 (file)
@@ -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);