From 8c83a4a2129a08e44f7c8227dbc7f6c9ecda5285 Mon Sep 17 00:00:00 2001 From: whitequark Date: Fri, 12 Feb 2016 05:25:19 +0000 Subject: [PATCH] Use size_t for indexing where appropriate. MSVC (rightly) complains about this. --- src/export.cpp | 2 +- src/file.cpp | 10 +++++----- src/group.cpp | 2 +- src/style.cpp | 2 +- tools/unifont2c.cpp | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/export.cpp b/src/export.cpp index 46ab0760..f670f1b2 100644 --- a/src/export.cpp +++ b/src/export.cpp @@ -890,7 +890,7 @@ void SolveSpaceUI::ExportMeshAsThreeJsTo(FILE *f, const std::string &filename, if(lastSlash == std::string::npos) oops(); baseFilename.erase(0, lastSlash + 1); - for(int i = 0; i < baseFilename.length(); i++) { + for(size_t i = 0; i < baseFilename.length(); i++) { if(!isalpha(baseFilename[i]) && /* also permit UTF-8 */ !((unsigned char)baseFilename[i] >= 0x80)) baseFilename[i] = '_'; diff --git a/src/file.cpp b/src/file.cpp index 61d1c24e..a404f930 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -695,13 +695,13 @@ static std::string MakePathRelative(const std::string &base, const std::string & resultParts; baseParts.pop_back(); - int common; + size_t common; for(common = 0; common < baseParts.size() && common < pathParts.size(); common++) { if(!PlatformPathEqual(baseParts[common], pathParts[common])) break; } - for(int i = common; i < baseParts.size(); i++) + for(size_t i = common; i < baseParts.size(); i++) resultParts.push_back(".."); resultParts.insert(resultParts.end(), @@ -732,7 +732,7 @@ static std::string MakePathAbsolute(const std::string &base, const std::string & static void PathSepNormalize(std::string &filename) { - for(int i = 0; i < filename.length(); i++) { + for(size_t i = 0; i < filename.length(); i++) { if(filename[i] == '\\') filename[i] = '/'; } @@ -742,7 +742,7 @@ static std::string PathSepPlatformToUNIX(const std::string &filename) { #if defined(WIN32) std::string result = filename; - for(int i = 0; i < result.length(); i++) { + for(size_t i = 0; i < result.length(); i++) { if(result[i] == '\\') result[i] = '/'; } @@ -756,7 +756,7 @@ static std::string PathSepUNIXToPlatform(const std::string &filename) { #if defined(WIN32) std::string result = filename; - for(int i = 0; i < result.length(); i++) { + for(size_t i = 0; i < result.length(); i++) { if(result[i] == '/') result[i] = '\\'; } diff --git a/src/group.cpp b/src/group.cpp index f7367748..fa704083 100644 --- a/src/group.cpp +++ b/src/group.cpp @@ -204,7 +204,7 @@ void Group::MenuGroup(int id) { if(pos != std::string::npos) groupName.erase(pos); - for(int i = 0; i < groupName.length(); i++) { + for(size_t i = 0; i < groupName.length(); i++) { if(!(isalnum(groupName[i]) || (unsigned)groupName[i] >= 0x80)) { // convert punctuation to dashes groupName[i] = '-'; diff --git a/src/style.cpp b/src/style.cpp index c1dd0b25..76cf353b 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -35,7 +35,7 @@ std::string Style::CnfWidth(const std::string &prefix) { std::string Style::CnfPrefixToName(const std::string &prefix) { std::string name = "#def-"; - for(int i = 0; i < prefix.length(); i++) { + for(size_t i = 0; i < prefix.length(); i++) { if(isupper(prefix[i]) && i != 0) name += '-'; name += tolower(prefix[i]); diff --git a/tools/unifont2c.cpp b/tools/unifont2c.cpp index 8def106a..7e9bf7a7 100644 --- a/tools/unifont2c.cpp +++ b/tools/unifont2c.cpp @@ -217,7 +217,7 @@ int main(int argc, char** argv) { deflate(&stream, Z_FINISH); chunk_output_size[chunk_index] += sizeof(compressed_chunk_data) - stream.avail_out; - for(int i = 0; i < sizeof(compressed_chunk_data) - stream.avail_out; i += 16) { + for(size_t i = 0; i < sizeof(compressed_chunk_data) - stream.avail_out; i += 16) { unsigned char *d = &compressed_chunk_data[i]; fprintf(source, " %3d, %3d, %3d, %3d, %3d, %3d, %3d, %3d, " "%3d, %3d, %3d, %3d, %3d, %3d, %3d, %3d,\n",