You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@kvrocks.apache.org by "PragmaTwice (via GitHub)" <gi...@apache.org> on 2023/04/20 08:38:37 UTC

[GitHub] [incubator-kvrocks] PragmaTwice commented on a diff in pull request #1397: Fix CONFIG REWRITE append duplicate newlines

PragmaTwice commented on code in PR #1397:
URL: https://github.com/apache/incubator-kvrocks/pull/1397#discussion_r1172266740


##########
src/config/config.cc:
##########
@@ -829,8 +829,8 @@ Status Config::Rewrite() {
   std::ifstream file(path_);
   if (file.is_open()) {
     std::string raw_line;
-    while (!file.eof()) {
-      std::getline(file, raw_line);
+    while (std::getline(file, raw_line)) {
+      if (file.eof()) break;

Review Comment:
   If the text file has no newline after the last line, this line will be ignored.
   
   e.g.
   ```
   file.write("a\nb\nc"); # the `c` line will be ignored
   ```
   
   Hence I think it is not a good change.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org