[swift] killed approximately 150 compiler warnings

This commit is contained in:
Mathew Sutcliffe
2014-06-21 22:52:24 +01:00
parent bf91ea6ce1
commit 237dcd0e14
10 changed files with 230 additions and 211 deletions

View File

@@ -53,12 +53,14 @@ static char * my_fgets(char * s, int n, FILE * file)
c = fgetc(file);
if (c == EOF)
{
if (/*feof(file) &&*/ p != s)
break;
else
{
return(NULL);
}
}
*p++ = c;
}
@@ -109,7 +111,7 @@ void StTextFileScanner::read_next(void)
while (mFile && /*!feof(mFile) &&*/ my_fgets(buf, sizeof(buf), mFile))
{
int len = strlen(buf);
int len = static_cast<int>(strlen(buf));
while ((len > 0) && (buf[len-1] == '\r' || buf[len-1] == '\n'))
{
buf[len-1] = 0;
@@ -223,13 +225,13 @@ int PickRandom(vector<double>& chances)
{
double v = (double) (rand() % RAND_MAX) / (double) RAND_MAX;
for (int n = 0; n < chances.size(); ++n)
for (size_t n = 0; n < chances.size(); ++n)
{
if (v < chances[n])
return n;
return static_cast<int>(n);
v -= chances[n];
}
return chances.size();
return static_cast<int>(chances.size());
}
bool RollDice(double inProb)
@@ -351,8 +353,8 @@ void ExtractFixedRecordString(
{
int sp = inBegin-1;
int ep = inEnd;
if (ep > inLine.length()) ep = inLine.length();
if (sp > inLine.length()) sp = inLine.length();
if (ep > static_cast<int>(inLine.length())) ep = static_cast<int>(inLine.length());
if (sp > static_cast<int>(inLine.length())) sp = static_cast<int>(inLine.length());
while ((sp < ep) && (inLine[sp] == ' '))
++sp;
@@ -389,7 +391,7 @@ bool ExtractFixedRecordUnsignedLong(
return true;
}
#pragma mark -
//#pragma mark -
struct XPointPool::XPointPoolImp {
@@ -408,7 +410,7 @@ struct XPointPool::XPointPoolImp {
int count(void)
{
return pts.size();
return static_cast<int>(pts.size());
}
int accumulate(const float xyz[3], const float st[2])
@@ -427,9 +429,9 @@ struct XPointPool::XPointPoolImp {
memcpy(p.xyz, xyz, sizeof(p.xyz));
memcpy(p.st, st, sizeof(p.st));
pts.push_back(p);
index.insert(map<string,int>::value_type(key, pts.size()));
index.insert(map<string,int>::value_type(key, static_cast<int>(pts.size())));
pts.push_back(p);
return pts.size()-1;
return static_cast<int>(pts.size())-1;
}
void get(int i, float xyz[3], float st[2])
@@ -501,12 +503,12 @@ void DecomposeObjCmd(const XObjCmd& inCmd, vector<XObjCmd>& outCmds, int maxVale
case obj_Polygon:
// Polygons might be ok. But if we have to break them down,
// we generate N-2 triangles in a fan configuration.
if (maxValence < inCmd.st.size())
if (maxValence < static_cast<int>(inCmd.st.size()))
{
c.st.push_back(inCmd.st[0]);
c.st.push_back(inCmd.st[1]);
c.st.push_back(inCmd.st[2]);
for (int n = 2; n < inCmd.st.size(); ++n)
for (size_t n = 2; n < inCmd.st.size(); ++n)
{
c.st[1] = inCmd.st[n-1];
c.st[2] = inCmd.st[n ];
@@ -521,7 +523,7 @@ void DecomposeObjCmd(const XObjCmd& inCmd, vector<XObjCmd>& outCmds, int maxVale
c.st.push_back(inCmd.st[0]);
c.st.push_back(inCmd.st[1]);
c.st.push_back(inCmd.st[2]);
for (int n = 2; n < inCmd.st.size(); ++n)
for (size_t n = 2; n < inCmd.st.size(); ++n)
{
if (n%2)
{
@@ -542,7 +544,7 @@ void DecomposeObjCmd(const XObjCmd& inCmd, vector<XObjCmd>& outCmds, int maxVale
c.st.push_back(inCmd.st[0]);
c.st.push_back(inCmd.st[1]);
c.st.push_back(inCmd.st[2]);
for (int n = 2; n < inCmd.st.size(); ++n)
for (size_t n = 2; n < inCmd.st.size(); ++n)
{
c.st[1] = inCmd.st[n-1];
c.st[2] = inCmd.st[n ];
@@ -558,7 +560,7 @@ void DecomposeObjCmd(const XObjCmd& inCmd, vector<XObjCmd>& outCmds, int maxVale
c.st.push_back(inCmd.st[1]);
c.st.push_back(inCmd.st[2]);
c.st.push_back(inCmd.st[3]);
for (int n = 2; n < inCmd.st.size(); n += 2)
for (size_t n = 2; n < inCmd.st.size(); n += 2)
{
c.st[0] = inCmd.st[n-2];
c.st[1] = inCmd.st[n-1];
@@ -570,7 +572,7 @@ void DecomposeObjCmd(const XObjCmd& inCmd, vector<XObjCmd>& outCmds, int maxVale
c.st.push_back(inCmd.st[0]);
c.st.push_back(inCmd.st[1]);
c.st.push_back(inCmd.st[2]);
for (int n = 2; n < inCmd.st.size(); ++n)
for (size_t n = 2; n < inCmd.st.size(); ++n)
{
if (n%2)
{