Skip to content

Commit ff267a4

Browse files
committed
PrintF refactored completely.
1 parent b0856e0 commit ff267a4

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

src/codegen/c-main-generator.cpp

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ void CiMainGenerator::Generate(std::vector<MessageDescriptor_t*>& msgs, const Fs
5959
fwriter->AppendLine("#ifdef __cplusplus\nextern \"C\" {\n#endif", 2);
6060
fwriter->AppendLine("#include <stdint.h>", 2);
6161

62-
snprintf(wbuff, kWBUFF_len, "#ifdef %s", fsd.usemon_def.c_str());
63-
fwriter->AppendLine(wbuff);
62+
fwriter->AppendLine(PrintF("#ifdef %s", fsd.usemon_def.c_str()));
6463

6564
fwriter->AppendText(
6665
"// This file must define:\n"
@@ -200,8 +199,7 @@ void CiMainGenerator::WriteSigStructField(const SignalDescriptor_t& sig, bool bi
200199

201200
if (bits && (sig.LengthBit < 8))
202201
{
203-
snprintf(wbuff, kWBUFF_len, " : %d", sig.LengthBit);
204-
dtype += wbuff;
202+
dtype += PrintF(" : %d", sig.LengthBit);
205203
}
206204

207205
dtype += ";";
@@ -217,25 +215,21 @@ void CiMainGenerator::WriteSigStructField(const SignalDescriptor_t& sig, bool bi
217215

218216
fwriter->AppendText(pad);
219217

220-
snprintf(wbuff, kWBUFF_len, " Bits=%2d", sig.LengthBit);
221-
fwriter->AppendText(wbuff);
218+
fwriter->AppendText(PrintF(" Bits=%2d", sig.LengthBit));
222219

223220
if (sig.Unit.size() > 0)
224221
{
225-
snprintf(wbuff, kWBUFF_len, " Unit:'%-13s'", sig.Unit.c_str());
226-
fwriter->AppendText(wbuff);
222+
fwriter->AppendText(PrintF(" Unit:'%-13s'", sig.Unit.c_str()));
227223
}
228224

229225
if (sig.Offset != 0)
230226
{
231-
snprintf(wbuff, kWBUFF_len, " Offset= %-18f", sig.Offset);
232-
fwriter->AppendText(wbuff);
227+
fwriter->AppendText(PrintF(" Offset= %-18f", sig.Offset));
233228
}
234229

235230
if (sig.Factor != 1)
236231
{
237-
snprintf(wbuff, kWBUFF_len, " Factor= %-15d", sig.LengthBit);
238-
fwriter->AppendText(wbuff);
232+
fwriter->AppendText(PrintF(" Factor= %-15d", sig.LengthBit));
239233
}
240234

241235
fwriter->AppendLine("", 2);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy