]> OCCT Git - occt.git/commitdiff
0032119: Coding Rules - eliminate msvc warning C4800 (implicit cast to bool) after...
authordpasukhi <dpasukhi@opencascade.com>
Sat, 6 Feb 2021 15:43:43 +0000 (18:43 +0300)
committerbugmaster <bugmaster@opencascade.com>
Wed, 10 Feb 2021 17:45:26 +0000 (20:45 +0300)
Fixed incorrect comparison and forcing cast

src/StepFile/step.tab.cxx
src/StepFile/step.yacc

index 473d65f55905275af2b795ce615592479e7a1468..32a8fee759fa1c58d174ed9ec8165494360c8add 100644 (file)
@@ -1219,13 +1219,13 @@ namespace step {
 void step::parser::error(const std::string& m)
 {
   char newmess[120];
-  Standard_Boolean isSyntax = (Standard_Boolean)strncmp(m.c_str(), "syntax error", 13);
-  if (isSyntax && strlen(m.c_str()) > 13)
-    sprintf(newmess, "Undefined Parsing: Line %d: %s: %s", scanner->lineno() + 1, "Incorrect syntax", m.c_str() + 14);
+  Standard_Boolean isSyntax = strncmp(m.c_str(), "syntax error", 12) == 0;
+  if (isSyntax && m.length() > 13)
+    Sprintf(newmess, "Undefined Parsing: Line %d: %s: %s", scanner->lineno() + 1, "Incorrect syntax", m.c_str() + 14);
   else if (isSyntax)
-    sprintf(newmess, "Undefined Parsing: Line %d: Incorrect syntax", scanner->lineno() + 1);
+    Sprintf(newmess, "Undefined Parsing: Line %d: Incorrect syntax", scanner->lineno() + 1);
   else
-    sprintf(newmess, "Undefined Parsing: Line %d: %s", scanner->lineno() + 1, m.c_str());
+    Sprintf(newmess, "Undefined Parsing: Line %d: %s", scanner->lineno() + 1, m.c_str());
 
   StepFile_Interrupt(newmess, Standard_False);
 
index de2f1278d929c463d716552239f4553e40515599..6b6f72e3cba93b6da3d87be96f3c2a2c05088d41 100644 (file)
@@ -181,13 +181,13 @@ enttype   : TYPE
 void step::parser::error(const std::string& m)
 {
   char newmess[120];
-  Standard_Boolean isSyntax = (Standard_Boolean)strncmp(m.c_str(), "syntax error", 13);
-  if (isSyntax && strlen(m.c_str()) > 13)
-    sprintf(newmess, "Undefined Parsing: Line %d: %s: %s", scanner->lineno() + 1, "Incorrect syntax", m.c_str() + 14);
+  Standard_Boolean isSyntax = strncmp(m.c_str(), "syntax error", 12) == 0;
+  if (isSyntax && m.length() > 13)
+    Sprintf(newmess, "Undefined Parsing: Line %d: %s: %s", scanner->lineno() + 1, "Incorrect syntax", m.c_str() + 14);
   else if (isSyntax)
-    sprintf(newmess, "Undefined Parsing: Line %d: Incorrect syntax", scanner->lineno() + 1);
+    Sprintf(newmess, "Undefined Parsing: Line %d: Incorrect syntax", scanner->lineno() + 1);
   else
-    sprintf(newmess, "Undefined Parsing: Line %d: %s", scanner->lineno() + 1, m.c_str());
+    Sprintf(newmess, "Undefined Parsing: Line %d: %s", scanner->lineno() + 1, m.c_str());
 
   StepFile_Interrupt(newmess, Standard_False);