Fix compile warnings under VS 2013 /W4 warning level
This commit is contained in:
@@ -76,7 +76,7 @@ static inline int fixIndex(int idx, int n) {
|
|||||||
static inline std::string parseString(const char *&token) {
|
static inline std::string parseString(const char *&token) {
|
||||||
std::string s;
|
std::string s;
|
||||||
token += strspn(token, " \t");
|
token += strspn(token, " \t");
|
||||||
int e = strcspn(token, " \t\r");
|
size_t e = strcspn(token, " \t\r");
|
||||||
s = std::string(token, &token[e]);
|
s = std::string(token, &token[e]);
|
||||||
token += e;
|
token += e;
|
||||||
return s;
|
return s;
|
||||||
@@ -325,7 +325,7 @@ updateVertex(std::map<vertex_index, unsigned int> &vertexCache,
|
|||||||
texcoords.push_back(in_texcoords[2 * i.vt_idx + 1]);
|
texcoords.push_back(in_texcoords[2 * i.vt_idx + 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int idx = positions.size() / 3 - 1;
|
unsigned int idx = static_cast<unsigned int>(positions.size() / 3 - 1);
|
||||||
vertexCache[i] = idx;
|
vertexCache[i] = idx;
|
||||||
|
|
||||||
return idx;
|
return idx;
|
||||||
@@ -448,7 +448,7 @@ std::string LoadMtl(std::map<std::string, int> &material_map,
|
|||||||
// flush previous material.
|
// flush previous material.
|
||||||
if (!material.name.empty()) {
|
if (!material.name.empty()) {
|
||||||
material_map.insert(
|
material_map.insert(
|
||||||
std::pair<std::string, int>(material.name, materials.size()));
|
std::pair<std::string, int>(material.name, static_cast<int>(materials.size())));
|
||||||
materials.push_back(material);
|
materials.push_back(material);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -458,7 +458,11 @@ std::string LoadMtl(std::map<std::string, int> &material_map,
|
|||||||
// set new mtl name
|
// set new mtl name
|
||||||
char namebuf[4096];
|
char namebuf[4096];
|
||||||
token += 7;
|
token += 7;
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
sscanf_s(token, "%s", namebuf);
|
||||||
|
#else
|
||||||
sscanf(token, "%s", namebuf);
|
sscanf(token, "%s", namebuf);
|
||||||
|
#endif
|
||||||
material.name = namebuf;
|
material.name = namebuf;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -585,7 +589,7 @@ std::string LoadMtl(std::map<std::string, int> &material_map,
|
|||||||
_space = strchr(token, '\t');
|
_space = strchr(token, '\t');
|
||||||
}
|
}
|
||||||
if (_space) {
|
if (_space) {
|
||||||
int len = _space - token;
|
ptrdiff_t len = _space - token;
|
||||||
std::string key(token, len);
|
std::string key(token, len);
|
||||||
std::string value = _space + 1;
|
std::string value = _space + 1;
|
||||||
material.unknown_parameter.insert(
|
material.unknown_parameter.insert(
|
||||||
@@ -594,7 +598,7 @@ std::string LoadMtl(std::map<std::string, int> &material_map,
|
|||||||
}
|
}
|
||||||
// flush last material.
|
// flush last material.
|
||||||
material_map.insert(
|
material_map.insert(
|
||||||
std::pair<std::string, int>(material.name, materials.size()));
|
std::pair<std::string, int>(material.name, static_cast<int>(materials.size())));
|
||||||
materials.push_back(material);
|
materials.push_back(material);
|
||||||
|
|
||||||
return err.str();
|
return err.str();
|
||||||
@@ -729,9 +733,9 @@ std::string LoadObj(std::vector<shape_t> &shapes,
|
|||||||
std::vector<vertex_index> face;
|
std::vector<vertex_index> face;
|
||||||
while (!isNewLine(token[0])) {
|
while (!isNewLine(token[0])) {
|
||||||
vertex_index vi =
|
vertex_index vi =
|
||||||
parseTriple(token, v.size() / 3, vn.size() / 3, vt.size() / 2);
|
parseTriple(token, static_cast<int>(v.size() / 3), static_cast<int>(vn.size() / 3), static_cast<int>(vt.size() / 2));
|
||||||
face.push_back(vi);
|
face.push_back(vi);
|
||||||
int n = strspn(token, " \t\r");
|
size_t n = strspn(token, " \t\r");
|
||||||
token += n;
|
token += n;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -745,7 +749,11 @@ std::string LoadObj(std::vector<shape_t> &shapes,
|
|||||||
|
|
||||||
char namebuf[4096];
|
char namebuf[4096];
|
||||||
token += 7;
|
token += 7;
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
sscanf_s(token, "%s", namebuf);
|
||||||
|
#else
|
||||||
sscanf(token, "%s", namebuf);
|
sscanf(token, "%s", namebuf);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Create face group per material.
|
// Create face group per material.
|
||||||
bool ret = exportFaceGroupToShape(shape, vertexCache, v, vn, vt,
|
bool ret = exportFaceGroupToShape(shape, vertexCache, v, vn, vt,
|
||||||
@@ -768,7 +776,11 @@ std::string LoadObj(std::vector<shape_t> &shapes,
|
|||||||
if ((0 == strncmp(token, "mtllib", 6)) && isSpace((token[6]))) {
|
if ((0 == strncmp(token, "mtllib", 6)) && isSpace((token[6]))) {
|
||||||
char namebuf[4096];
|
char namebuf[4096];
|
||||||
token += 7;
|
token += 7;
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
sscanf_s(token, "%s", namebuf);
|
||||||
|
#else
|
||||||
sscanf(token, "%s", namebuf);
|
sscanf(token, "%s", namebuf);
|
||||||
|
#endif
|
||||||
|
|
||||||
std::string err_mtl = readMatFn(namebuf, materials, material_map);
|
std::string err_mtl = readMatFn(namebuf, materials, material_map);
|
||||||
if (!err_mtl.empty()) {
|
if (!err_mtl.empty()) {
|
||||||
@@ -830,7 +842,11 @@ std::string LoadObj(std::vector<shape_t> &shapes,
|
|||||||
// @todo { multiple object name? }
|
// @todo { multiple object name? }
|
||||||
char namebuf[4096];
|
char namebuf[4096];
|
||||||
token += 2;
|
token += 2;
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
sscanf_s(token, "%s", namebuf);
|
||||||
|
#else
|
||||||
sscanf(token, "%s", namebuf);
|
sscanf(token, "%s", namebuf);
|
||||||
|
#endif
|
||||||
name = std::string(namebuf);
|
name = std::string(namebuf);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
Reference in New Issue
Block a user