Skip to content

Commit

Permalink
Fix MSVC compilation and warnings
Browse files Browse the repository at this point in the history
* Suppress size_t -> int warnings
* Avoid implicit cast to shorter integers
  • Loading branch information
orgads committed Jul 4, 2018
1 parent 89d1084 commit bc63132
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 37 deletions.
10 changes: 5 additions & 5 deletions msvc/hunspell.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
<ProgramDataBaseFileName>$(IntDir)$(ProjectName).pdb</ProgramDataBaseFileName>
<WarningLevel>Level4</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<DisableSpecificWarnings>4127;4706</DisableSpecificWarnings>
<DisableSpecificWarnings>4127;4267;4706</DisableSpecificWarnings>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
Expand All @@ -118,7 +118,7 @@
<WarningLevel>Level4</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<ProgramDataBaseFileName>$(IntDir)$(ProjectName).pdb</ProgramDataBaseFileName>
<DisableSpecificWarnings>4127;4706</DisableSpecificWarnings>
<DisableSpecificWarnings>4127;4267;4706</DisableSpecificWarnings>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
Expand All @@ -139,7 +139,7 @@
<ProgramDataBaseFileName>$(IntDir)$(ProjectName).pdb</ProgramDataBaseFileName>
<WarningLevel>Level4</WarningLevel>
<DebugInformationFormat />
<DisableSpecificWarnings>4127;4706</DisableSpecificWarnings>
<DisableSpecificWarnings>4127;4267;4706</DisableSpecificWarnings>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
Expand All @@ -164,7 +164,7 @@
<WarningLevel>Level4</WarningLevel>
<DebugInformationFormat>
</DebugInformationFormat>
<DisableSpecificWarnings>4127;4706</DisableSpecificWarnings>
<DisableSpecificWarnings>4127;4267;4706</DisableSpecificWarnings>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
Expand Down Expand Up @@ -204,4 +204,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
18 changes: 9 additions & 9 deletions msvc/libhunspell.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
<ProgramDataBaseFileName>$(IntDir)$(ProjectName).pdb</ProgramDataBaseFileName>
<WarningLevel>Level4</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<DisableSpecificWarnings>4706</DisableSpecificWarnings>
<DisableSpecificWarnings>4706;4251;4267</DisableSpecificWarnings>
</ClCompile>
<Lib>
<AdditionalOptions>/MACHINE:X86 %(AdditionalOptions)</AdditionalOptions>
Expand All @@ -192,7 +192,7 @@
</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<DisableSpecificWarnings>4706</DisableSpecificWarnings>
<DisableSpecificWarnings>4706;4251;4267</DisableSpecificWarnings>
</ClCompile>
<Lib />
</ItemDefinitionGroup>
Expand All @@ -212,7 +212,7 @@
<ProgramDataBaseFileName>$(IntDir)$(ProjectName).pdb</ProgramDataBaseFileName>
<WarningLevel>Level4</WarningLevel>
<DebugInformationFormat />
<DisableSpecificWarnings>4706</DisableSpecificWarnings>
<DisableSpecificWarnings>4706;4251;4267</DisableSpecificWarnings>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
Expand Down Expand Up @@ -240,7 +240,7 @@
<WarningLevel>Level4</WarningLevel>
<DebugInformationFormat>
</DebugInformationFormat>
<DisableSpecificWarnings>4706</DisableSpecificWarnings>
<DisableSpecificWarnings>4706;4251;4267</DisableSpecificWarnings>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
Expand All @@ -266,7 +266,7 @@
<ProgramDataBaseFileName>$(IntDir)$(ProjectName).pdb</ProgramDataBaseFileName>
<WarningLevel>Level4</WarningLevel>
<DebugInformationFormat />
<DisableSpecificWarnings>4706</DisableSpecificWarnings>
<DisableSpecificWarnings>4706;4251;4267</DisableSpecificWarnings>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
Expand Down Expand Up @@ -299,7 +299,7 @@
<WarningLevel>Level4</WarningLevel>
<DebugInformationFormat>
</DebugInformationFormat>
<DisableSpecificWarnings>4706</DisableSpecificWarnings>
<DisableSpecificWarnings>4706;4251;4267</DisableSpecificWarnings>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
Expand Down Expand Up @@ -330,7 +330,7 @@
<ProgramDataBaseFileName>$(IntDir)$(ProjectName).pdb</ProgramDataBaseFileName>
<WarningLevel>Level4</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<DisableSpecificWarnings>4706</DisableSpecificWarnings>
<DisableSpecificWarnings>4706;4251;4267</DisableSpecificWarnings>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
Expand All @@ -356,7 +356,7 @@
<ProgramDataBaseFileName>$(IntDir)$(ProjectName).pdb</ProgramDataBaseFileName>
<WarningLevel>Level4</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<DisableSpecificWarnings>4706</DisableSpecificWarnings>
<DisableSpecificWarnings>4706;4251;4267</DisableSpecificWarnings>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
Expand Down Expand Up @@ -403,4 +403,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
8 changes: 4 additions & 4 deletions src/hunspell/affixmgr.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2021,9 +2021,9 @@ struct hentry* AffixMgr::compound_check(const std::string& word,
if (sfxappnd) {
std::string tmp(sfxappnd);
reverseword(tmp);
numsyllable -= get_syllable(tmp) + sfxextra;
numsyllable -= short(get_syllable(tmp) + sfxextra);
} else {
numsyllable -= sfxextra;
numsyllable -= short(sfxextra);
}

// + 1 word, if syllable number of the prefix > 1 (hungarian
Expand Down Expand Up @@ -2614,9 +2614,9 @@ int AffixMgr::compound_check_morph(const char* word,
if (sfxappnd) {
std::string tmp(sfxappnd);
reverseword(tmp);
numsyllable -= get_syllable(tmp) + sfxextra;
numsyllable -= short(get_syllable(tmp) + sfxextra);
} else {
numsyllable -= sfxextra;
numsyllable -= short(sfxextra);
}

// + 1 word, if syllable number of the prefix > 1 (hungarian
Expand Down
10 changes: 4 additions & 6 deletions src/hunspell/csutil.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
*/

#include <algorithm>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
Expand Down Expand Up @@ -486,20 +487,17 @@ void uniqlist(std::vector<std::string>& list) {

namespace {
unsigned char cupper(const struct cs_info* csconv, int nIndex) {
if (nIndex < 0 || nIndex > 255)
return nIndex;
assert(nIndex >= 0 && nIndex <= 255);
return csconv[nIndex].cupper;
}

unsigned char clower(const struct cs_info* csconv, int nIndex) {
if (nIndex < 0 || nIndex > 255)
return nIndex;
assert(nIndex >= 0 && nIndex <= 255);
return csconv[nIndex].clower;
}

unsigned char ccase(const struct cs_info* csconv, int nIndex) {
if (nIndex < 0 || nIndex > 255)
return nIndex;
assert(nIndex >= 0 && nIndex <= 255);
return csconv[nIndex].ccase;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/hunspell/hunzip.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ int Hunzip::getbuf() {
do {
if (inc == 0) {
fin.read(in, BUFSIZE);
inbits = fin.gcount() * 8;
inbits = int(fin.gcount() * 8);
}
for (; inc < inbits; inc++) {
int b = (in[inc / 8] & (1 << (7 - (inc % 8)))) ? 1 : 0;
Expand Down
4 changes: 2 additions & 2 deletions src/parsers/odfparser.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ bool ODFParser::next_token(std::string& t) {
return XMLParser::next_token(PATTERN, PATTERN_LEN, PATTERN2, PATTERN_LEN2, PATTERN3, PATTERN_LEN3, t);
}

std::string ODFParser::get_word(const std::string token) {
return XMLParser::get_word(PATTERN3, PATTERN_LEN3, token);
std::string ODFParser::get_word(const std::string &tok) {
return XMLParser::get_word(PATTERN3, PATTERN_LEN3, tok);
}

ODFParser::~ODFParser() {}
2 changes: 1 addition & 1 deletion src/parsers/odfparser.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class ODFParser : public XMLParser {
explicit ODFParser(const char* wc);
ODFParser(const w_char* wordchars, int len);
virtual bool next_token(std::string&);
virtual std::string get_word(const std::string token);
virtual std::string get_word(const std::string &tok);
virtual ~ODFParser();
};

Expand Down
4 changes: 2 additions & 2 deletions src/parsers/textparser.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ int TextParser::change_token(const char* word) {
return 0;
}

std::string TextParser::get_word(const std::string token) {
return token;
std::string TextParser::get_word(const std::string &tok) {
return tok;
}

void TextParser::check_urls() {
Expand Down
2 changes: 1 addition & 1 deletion src/parsers/textparser.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class TextParser {
std::string get_line() const;
std::string get_prevline(int n) const;
virtual bool next_token(std::string&);
virtual std::string get_word(const std::string token);
virtual std::string get_word(const std::string &tok);
virtual int change_token(const char* word);
void set_url_checking(int check);

Expand Down
4 changes: 2 additions & 2 deletions src/parsers/xmlparser.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ bool XMLParser::next_token(std::string& t) {
std::string XMLParser::get_word(
const char* PATTERN3[][2],
unsigned int PATTERN_LEN3,
const std::string token) {
std::string word = token;
const std::string &tok) {
std::string word = tok;
for (unsigned int i = 0; i < PATTERN_LEN3; i++) {
size_t pos;
while ((pos = word.find(PATTERN3[i][0])) != -1) {
Expand Down
2 changes: 1 addition & 1 deletion src/parsers/xmlparser.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class XMLParser : public TextParser {
virtual bool next_token(std::string&);
std::string get_word(const char* p2[][2],
unsigned int len2,
const std::string token);
const std::string &tok);
int change_token(const char* word);
virtual ~XMLParser();

Expand Down
7 changes: 4 additions & 3 deletions src/tools/hunspell.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#include <sstream>
#include <string>
#include <string.h>
#include "../../config.h"
#include <config.h>
#include "../hunspell/atypes.hxx"
#include "../hunspell/hunspell.hxx"
#include "../hunspell/csutil.hxx"
Expand Down Expand Up @@ -617,7 +617,7 @@ bool check(Hunspell** pMS, int* d, const std::string& token, int* info, std::str
return false;
}

static int is_zipped_odf(TextParser* parser, const char* extension) {
static bool is_zipped_odf(TextParser* parser, const char* extension) {
// ODFParser and not flat ODF
return dynamic_cast<ODFParser*>(parser) && (extension && extension[0] != 'f');
}
Expand All @@ -631,6 +631,7 @@ static bool secure_filename(const char* filename) {

char* mymkdtemp(char *templ) {
#ifdef WIN32
(void)templ;
char *odftmpdir = tmpnam(NULL);
if (!odftmpdir) {
return NULL;
Expand Down Expand Up @@ -1740,7 +1741,7 @@ char* search(char* begin, char* name, const char* ext) {
end++;
char* res = NULL;
if (name) {
res = exist2(begin, end - begin, name, ext);
res = exist2(begin, int(end - begin), name, ext);
} else {
#if !defined(WIN32) || defined(__MINGW32__)
listdicpath(begin, end - begin);
Expand Down

0 comments on commit bc63132

Please sign in to comment.