Content-Length: 399979 | pFad | https://github.com/astand/c-coderdbc/commit/b714eb0a2ba33d69f382ae803796f0cf29c7064d

77 Fixed issue with big comment and localization. · astand/c-coderdbc@b714eb0 · GitHub
Skip to content

Commit b714eb0

Browse files
committed
Fixed issue with big comment and localization.
1 parent 2ccb121 commit b714eb0

File tree

4 files changed

+35
-7
lines changed

4 files changed

+35
-7
lines changed

src/helpers/formatter.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,31 @@ std::string str_tolower(std::string s)
5757
});
5858
return s;
5959
}
60+
61+
std::string str_trim(std::string s)
62+
{
63+
size_t passed = 0;
64+
65+
if (s.empty())
66+
return s + '\n';
67+
68+
passed = 0;
69+
70+
while (passed < s.size())
71+
{
72+
if (s[s.size() - passed - 1] > ' ')
73+
{
74+
break;
75+
}
76+
77+
++passed;
78+
}
79+
80+
if (passed != 0)
81+
{
82+
// remove tail with non-printable values
83+
s.erase(s.size() - passed, passed);
84+
}
85+
86+
return s;
87+
}

src/helpers/formatter.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ std::string PrintType(uint8_t tid);
1212
std::string str_toupper(std::string s);
1313

1414
std::string str_tolower(std::string s);
15+
16+
std::string str_trim(std::string s);

src/parser/dbclineparser.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,8 @@ bool DbcLineParser::ParseSignalLine(SignalDescriptor_t* sig, const std::string&
206206
//value into the signal's physical value and vice versa:
207207
// physical_value = raw_value * factor + offset
208208
// raw_value = (physical_value - offset) / factor
209+
std::setlocale(LC_ALL, "en_US.UTF-8");
210+
209211
sig->Factor = atof(valpart[3].c_str());
210212
sig->Offset = atof(valpart[4].c_str());
211213

src/parser/dbcscanner.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "dbcscanner.h"
22
#include <algorithm>
33
#include <math.h>
4+
#include "../helpers/formatter.h"
45

56
#define MAX_LINE 4096
67

@@ -67,7 +68,7 @@ void DbcScanner::ParseMessageInfo(istream& readstrm)
6768
{
6869
readstrm.getline(line, MAX_LINE);
6970

70-
sline = line;
71+
sline = str_trim(line);
7172

7273
// New message line has been found
7374
if (lparser.IsMessageLine(sline))
@@ -121,12 +122,7 @@ void DbcScanner::ParseOtherInfo(istream& readstrm)
121122
{
122123
readstrm.getline(line, MAX_LINE);
123124

124-
sline = line;
125-
126-
if (sline.size() > 0 && sline.back() < ' ')
127-
{
128-
sline.erase(sline.size() - 1, 1);
129-
}
125+
sline = str_trim(line);
130126

131127
if (lparser.ParseCommentLine(&cmmnt, sline))
132128
{

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/astand/c-coderdbc/commit/b714eb0a2ba33d69f382ae803796f0cf29c7064d

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy