mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-11 17:59:03 +00:00
Changed: #142 Replace atoi and sscanf by fromString when it's possible
This commit is contained in:
parent
c3d577eb0e
commit
eff593fcf3
13 changed files with 31 additions and 17 deletions
|
@ -56,7 +56,8 @@ NLMISC_COMMAND(square,"display the square of the parameter","<value>")
|
|||
// check args, if there is not the right number of parameters, return bad status.
|
||||
if (args.size() != 1) return false;
|
||||
|
||||
uint32 val = atoi(args[0].c_str());
|
||||
uint32 val;
|
||||
NLMISC::fromString(args[0], val);
|
||||
|
||||
// display the result.
|
||||
log.displayNL("The square of %d is %d", val, val*val);
|
||||
|
|
|
@ -215,8 +215,9 @@ void cbInfo (CMessage &msgin, TSockId from, CCallbackNetBase &netbase)
|
|||
string token = "MeanPongTime ";
|
||||
string::size_type pos=line.find (token);
|
||||
string::size_type pos2=line.find (" ", pos+token.size());
|
||||
uint32 val = atoi(line.substr (pos+token.size(), pos2-pos-token.size()).c_str());
|
||||
LagGraph.addOneValue ((float)val);
|
||||
float val;
|
||||
NLMISC::fromString(line.substr (pos+token.size(), pos2-pos-token.size()), val);
|
||||
LagGraph.addOneValue (val);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -381,7 +381,7 @@ void CLogicCounter::read (xmlNodePtr node)
|
|||
|
||||
_Name = getXMLProp (node, "Name");
|
||||
_Value = atoiInt64 (getXMLProp (node, "Value").c_str());
|
||||
_Verbose = atoi(getXMLProp (node, "Verbose").c_str()) == 1;
|
||||
NLMISC::fromString(getXMLProp (node, "Verbose"), _Verbose);
|
||||
Period.setValue(atoiInt64(getXMLProp (node, "Period").c_str()));
|
||||
Phase.setValue(atoiInt64(getXMLProp (node, "Phase").c_str()));
|
||||
Step.setValue(atoiInt64(getXMLProp (node, "Step").c_str()));
|
||||
|
|
|
@ -56,8 +56,12 @@ int CConfigFile::CVar::asInt (int index) const
|
|||
switch (Type)
|
||||
{
|
||||
case T_STRING:
|
||||
{
|
||||
if (index >= (int)StrValues.size () || index < 0) throw EBadSize (Name, (int)StrValues.size (), index);
|
||||
return atoi(StrValues[index].c_str());
|
||||
int ret = 0;
|
||||
NLMISC::fromString(StrValues[index], ret);
|
||||
return ret;
|
||||
}
|
||||
case T_REAL:
|
||||
if (index >= (int)RealValues.size () || index < 0) throw EBadSize (Name, (int)RealValues.size (), index);
|
||||
return (int)RealValues[index];
|
||||
|
|
|
@ -314,9 +314,9 @@ int main(int argc, char *argv[])
|
|||
sint percentageFace= 100;
|
||||
sint maxFace= INT_MAX;
|
||||
if(argc>=4)
|
||||
percentageFace= atoi(argv[3]);
|
||||
NLMISC::fromString(argv[3], percentageFace);
|
||||
if(argc>=5)
|
||||
maxFace= atoi(argv[4]);
|
||||
NLMISC::fromString(argv[4], maxFace);
|
||||
|
||||
// **** Load the Mesh In.
|
||||
IShape *pResult = NULL;
|
||||
|
|
|
@ -52,13 +52,17 @@ void CEditEx::OnSetFocus(CWnd* pOldWnd)
|
|||
sint CEditEx::getSInt() const
|
||||
{
|
||||
nlassert(_Type == SIntType);
|
||||
return (sint) ::atoi(getString().c_str());
|
||||
sint ret = 0;
|
||||
NLMISC::fromString(getString(), ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint CEditEx::getUInt() const
|
||||
{
|
||||
nlassert(_Type == UIntType);
|
||||
return (uint) ::atoi(getString().c_str());
|
||||
uint ret = 0;
|
||||
NLMISC::fromString(getString(), ret);
|
||||
return ret;
|
||||
}
|
||||
float CEditEx::getFloat() const
|
||||
{
|
||||
|
|
|
@ -880,7 +880,8 @@ bool ShapesExporter::createThumbnail(const string &filename, const string &path)
|
|||
if (!fgets(str, 100, fp))
|
||||
strcpy(str, "0");
|
||||
fclose(fp);
|
||||
selectedFrame = atoi(str)/2;
|
||||
NLMISC::fromString(std::string(str), selectedFrame);
|
||||
selectedFrame /= 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -116,7 +116,8 @@ bool getZoneCoordByName(const char * name, uint16& x, uint16& y)
|
|||
return false;
|
||||
}
|
||||
}
|
||||
y = atoi(ystr.c_str());
|
||||
|
||||
NLMISC::fromString(ystr, y);
|
||||
|
||||
// x
|
||||
x = 0;
|
||||
|
|
|
@ -962,7 +962,7 @@ int main(int /* argc */, char ** /* argv */)
|
|||
NLMISC::CApplicationContext myApplicationContext;
|
||||
|
||||
#ifdef NL_OS_UNIX
|
||||
NLMISC::CPath::addSearchPath(NLMISC::CFile::getApplicationDirectory("NeL"));
|
||||
NLMISC::CPath::addSearchPath(NLMISC::CPath::getApplicationDirectory("NeL"));
|
||||
#endif // NL_OS_UNIX
|
||||
|
||||
NLMISC::CPath::addSearchPath(NL_ZVIEWER_CFG);
|
||||
|
|
|
@ -59,7 +59,8 @@ afx_msg void CLAEdit::OnKeyDown( UINT nChar, UINT nRepCnt, UINT nFlags )
|
|||
int start, end;
|
||||
GetSel( start, end );
|
||||
str = str.Mid( start, end-start );
|
||||
int lineNum = atoi( str );
|
||||
sint lineNum;
|
||||
NLMISC::fromString(str, lineNum);
|
||||
if ( ! ((lineNum != 0) || (str == "0")) )
|
||||
break;
|
||||
|
||||
|
@ -713,7 +714,8 @@ void CLog_analyserDlg::insertTraceLine( int index, char *traceLine )
|
|||
char *line = strchr( traceLine, ':' );
|
||||
char scycle [10];
|
||||
strncpy( scycle, traceLine, line-traceLine );
|
||||
int cycle = atoi(scycle);
|
||||
sint cycle;
|
||||
NLMISC::fromString(scycle, cycle);
|
||||
TStampedLine stampedLine;
|
||||
stampedLine.Index = index;
|
||||
stampedLine.Line = CString(traceLine);
|
||||
|
|
|
@ -424,7 +424,7 @@ int main( int argc, char ** argv )
|
|||
NLMISC::CApplicationContext appContext;
|
||||
|
||||
#ifdef NL_OS_UNIX
|
||||
NLMISC::CPath::addSearchPath(NLMISC::CFile::getApplicationDirectory("NeL"));
|
||||
NLMISC::CPath::addSearchPath(NLMISC::CPath::getApplicationDirectory("NeL"));
|
||||
#endif // NL_OS_UNIX
|
||||
|
||||
NLMISC::CPath::addSearchPath(NL_MK_SH_ID_CFG);
|
||||
|
|
|
@ -86,7 +86,7 @@ void init()
|
|||
try
|
||||
{
|
||||
#ifdef NL_OS_UNIX
|
||||
NLMISC::CPath::addSearchPath(NLMISC::CFile::getApplicationDirectory("NeL"));
|
||||
NLMISC::CPath::addSearchPath(NLMISC::CPath::getApplicationDirectory("NeL"));
|
||||
#endif // NL_OS_UNIX
|
||||
|
||||
NLMISC::CPath::addSearchPath(NL_BIB_CFG);
|
||||
|
|
|
@ -122,7 +122,7 @@ void initConfig()
|
|||
try
|
||||
{
|
||||
#ifdef NL_OS_UNIX
|
||||
NLMISC::CPath::addSearchPath(NLMISC::CFile::getApplicationDirectory("NeL"));
|
||||
NLMISC::CPath::addSearchPath(NLMISC::CPath::getApplicationDirectory("NeL"));
|
||||
#endif // NL_OS_UNIX
|
||||
|
||||
NLMISC::CPath::addSearchPath(NL_BIRB_CFG);
|
||||
|
|
Loading…
Reference in a new issue