Просмотр исходного кода

Remove newline in version (#1891)

* remove newline in version

* .

* .

Co-authored-by: CaCO3 <caco@ruinelli.ch>
CaCO3 3 лет назад
Родитель
Сommit
457a526792
1 измененных файлов с 9 добавлено и 2 удалено
  1. 9 2
      code/main/version.h

+ 9 - 2
code/main/version.h

@@ -15,6 +15,7 @@ extern "C"
 #include <string.h>
 #include "Helper.h"
 #include <fstream>
+#include <algorithm>
 
 
 const char* build_time(void)
@@ -63,7 +64,10 @@ std::string getHTMLversion(void){
     fgets(buf, sizeof(buf), pFile); // Line 1: Version
     fclose(pFile);
 
-    return std::string(buf);
+    string value = string(buf);
+    value.erase(std::remove(value.begin(), value.end(), '\n'), value.end()); // Remove any newlines
+
+    return value;
 }
 
 std::string getHTMLcommit(void){
@@ -79,7 +83,10 @@ std::string getHTMLcommit(void){
     fgets(buf, sizeof(buf), pFile); // Line 2: Commit
     fclose(pFile);
 
-    return std::string(buf);
+    string value = string(buf);
+    value.erase(std::remove(value.begin(), value.end(), '\n'), value.end()); // Remove any newlines
+
+    return value;
 }
 
 #endif // _VERSION_H