Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/sbml/Model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6444,7 +6444,7 @@ Model::createConstraintUnitsData(UnitFormulaFormatter * unitFormatter)
for (unsigned int n = 0; n < getNumConstraints(); n++)
{
Constraint* c = getConstraint(n);
sprintf(newId, "constraint_%u", n);
snprintf(newId, 15, "constraint_%u", n);
newID.assign(newId);
c->setInternalId(newID);

Expand All @@ -6470,7 +6470,7 @@ Model::createRuleUnitsData(UnitFormulaFormatter * unitFormatter)
// need to create an id for an algebbraic rule
if (r->getTypeCode() == SBML_ALGEBRAIC_RULE)
{
sprintf(newId, "alg_rule_%u", countAlg);
snprintf(newId, 12, "alg_rule_%u", countAlg);
newID.assign(newId);
r->setInternalId(newID);
static_cast <AlgebraicRule *> (r)->setInternalIdOnly();
Expand Down Expand Up @@ -6647,7 +6647,7 @@ Model::createEventUnitsData(UnitFormulaFormatter * unitFormatter)
{
Event* e = getEvent(n);

sprintf(newId, "event_%u", countEvents);
snprintf(newId, 12, "event_%u", countEvents);
newID.assign(newId);
e->setInternalId(newID);
countEvents++;
Expand Down
4 changes: 2 additions & 2 deletions src/sbml/conversion/SBMLInferUnitsConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,14 +221,14 @@ SBMLInferUnitsConverter::convert()
if (newId.empty())
{
/* create an id for the unitDef */
sprintf(number, "%u", newIdCount);
snprintf(number, 4, "%u", newIdCount);
newId = "unitSid_" + string(number);
newIdCount++;

/* double check that this id has not been used */
while (mModel->getUnitDefinition(newId) != NULL)
{
sprintf(number, "%u", newIdCount);
snprintf(number, 4, "%u", newIdCount);
newId = "unitSid_" + string(number);
newIdCount++;
}
Expand Down
2 changes: 1 addition & 1 deletion src/sbml/conversion/SBMLRateRuleConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1334,7 +1334,7 @@ SBMLRateRuleConverter::createReactions()
r->setReversible(false);
r->setFast(false);
int id = mDocument->getModel()->getNumReactions();
sprintf(number, "%u", id);
snprintf(number, 4, "%u", id);
const std::string reactionId = "J" + string(number);
r->setId(reactionId);
bool itemAdded = false;
Expand Down
4 changes: 2 additions & 2 deletions src/sbml/conversion/SBMLUnitsConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -900,14 +900,14 @@ SBMLUnitsConverter::applyNewUnitDefinition(SBase &sb, Model &m,
}
if (newId.empty())
{
sprintf(number, "%u", newIdCount);
snprintf(number, 4, "%u", newIdCount);
newId = "unitSid_" + string(number);
newIdCount++;

/* double check that this id has not been used */
while (m.getUnitDefinition(newId) != NULL)
{
sprintf(number, "%u", newIdCount);
snprintf(number, 4, "%u", newIdCount);
newId = "unitSid_" + string(number);
newIdCount++;
}
Expand Down
6 changes: 5 additions & 1 deletion src/sbml/math/ASTNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1176,7 +1176,7 @@ ASTNode::fillListOfNodes (ASTNodePredicate predicate, List* lst) const

void ASTNode::fillListOfNodesWithLevel(ASTNodePredicate predicate, ASTNodeLevels& vector_pairs, unsigned int level) const
{
if (this == NULL ||
if (this==NULL ||
(vector_pairs.size() == 1 && vector_pairs.back().second == NULL) ||
predicate == NULL)
return;
Expand Down Expand Up @@ -3803,6 +3803,8 @@ ASTNode::combineNumbers(std::vector<unsigned int>& numbers)
case AST_FUNCTION_POWER:
number = pow(number, getChild(*it)->getValue());
break;
default:
break;
}

}
Expand All @@ -3818,6 +3820,8 @@ ASTNode::combineNumbers(std::vector<unsigned int>& numbers)
case AST_PLUS:
number = number + (getChild(*it)->getValue());
break;
default:
break;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,9 @@ DistribToAnnotationConverter::addFunctionDefinitionWith(Model* model, const stri
args = "scale";
ret = "scale*sqrt(pi/2)";
break;
default:
//This function should never be called with any other types.
break;
}

if (!getWriteMeans()) {
Expand Down
6 changes: 3 additions & 3 deletions src/sbml/packages/render/sbml/Style.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ Style::getGroup()
bool
Style::isSetGroup() const
{
return (&mGroup != NULL);
return true; // (&mGroup != NULL) is always true.
}


Expand Down Expand Up @@ -1176,7 +1176,7 @@ Style::getElementBySId(const std::string& id)

SBase* obj = NULL;

if (&mGroup != NULL)
if (isSetGroup())
{
if (mGroup.getId() == id)
{
Expand Down Expand Up @@ -1208,7 +1208,7 @@ Style::getElementByMetaId(const std::string& metaid)

SBase* obj = NULL;

if (&mGroup != NULL)
if (isSetGroup())
{
if (mGroup.getMetaId() == metaid)
{
Expand Down
2 changes: 1 addition & 1 deletion src/sbml/xml/XMLOutputStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,7 @@ XMLOutputStream::writeComment (const std::string& programName,
now->tm_year+1900, now->tm_mon+1, now->tm_mday,
now->tm_hour, now->tm_min);
#else
sprintf(formattedDateAndTime, "%d-%02d-%02d %02d:%02d",
snprintf(formattedDateAndTime, 17, "%d-%02d-%02d %02d:%02d",
now->tm_year+1900, now->tm_mon+1, now->tm_mday,
now->tm_hour, now->tm_min);
#endif
Expand Down
Loading