Skip to content

Commit

Permalink
Remove a couple sscanf's in XMLParse.
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-kristjansson committed Feb 2, 2012
1 parent 4aaac67 commit 1bd95e6
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions mythtv/libs/libmyth/xmlparse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,21 +397,32 @@ void XMLParse::normalizeRect(QRect &rect)
QPoint XMLParse::parsePoint(QString text)
{
int x, y;
QPoint retval(0, 0);
QByteArray tmp = text.toLocal8Bit();
if (sscanf(tmp.constData(), "%d,%d", &x, &y) == 2)
retval = QPoint(x, y);
QPoint retval(0,0);
QStringList tmp = text.split(',', QString::SkipEmptyParts);
bool x_ok = false, y_ok = false;
if (tmp.size() >= 2)
{
retval = QPoint(tmp[0].toInt(&x_ok), tmp[1].toInt(&y_ok));
if (!x_ok || !y_ok)
retval = QPoint(0,0);
}
return retval;
}

QRect XMLParse::parseRect(QString text)
{
int x, y, w, h;
bool x_ok = false, y_ok = false;
bool w_ok = false, h_ok = false;
QRect retval(0, 0, 0, 0);
QByteArray tmp = text.toLocal8Bit();
if (sscanf(tmp.constData(), "%d,%d,%d,%d", &x, &y, &w, &h) == 4)
retval = QRect(x, y, w, h);

QStringList tmp = text.split(',', QString::SkipEmptyParts);
if (tmp.size() >= 4)
{
retval = QRect(tmp[0].toInt(&x_ok), tmp[1].toInt(&y_ok),
tmp[2].toInt(&w_ok), tmp[3].toInt(&h_ok));
if (!x_ok || !y_ok || !w_ok || !h_ok)
retval = QRect(0,0,0,0);
}
return retval;
}

Expand Down

1 comment on commit 1bd95e6

@stuarta
Copy link
Member

@stuarta stuarta commented on 1bd95e6 Feb 3, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The builds are now flagging that x, y, w & h are no longer used.

Please sign in to comment.