Fix a bunch of warnings when building with gcc on linux

This commit is contained in:
Thomas Goyne 2014-05-20 07:05:07 -07:00
parent 291437eed6
commit 53f02d33a6
9 changed files with 18 additions and 15 deletions

View file

@ -151,6 +151,7 @@ AS_IF([test x$enable_compiler_flags != xno], [
CXXFLAGS="$CXXFLAGS -Wall -Wextra -Wno-unused-parameter -fno-strict-aliasing -pipe -g"
AC_CXX_FLAG([-std=c++11])
AC_CXX_FLAG([-Wno-c++11-narrowing])
AC_C_FLAG([-Wno-unused-local-typedefs])
AC_CXX_FLAG([-Wno-unused-local-typedefs])
# -O* messes with debugging.

View file

@ -34,7 +34,7 @@ class SyntaxHighlighter {
std::string const& text;
agi::SpellChecker *spellchecker;
void SetStyling(int len, int type) {
void SetStyling(size_t len, int type) {
if (ranges.size() && ranges.back().type == type)
ranges.back().length += len;
else

View file

@ -121,7 +121,7 @@ file_mapping::~file_mapping() {
read_file_mapping::read_file_mapping(fs::path const& filename)
: file(filename, false)
{
offset_t size;
offset_t size = 0;
ipcdetail::get_file_size(file.get_mapping_handle().handle, size);
file_size = static_cast<uint64_t>(size);
}

View file

@ -218,7 +218,7 @@ namespace ass {
ptrdiff_t len = it->value().end() - it->value().begin();
assert(len > 0);
if (data.empty() || data.back().type != id)
data.push_back(DialogueToken{id, len});
data.push_back(DialogueToken{id, static_cast<size_t>(len)});
else
data.back().length += len;
}

View file

@ -50,7 +50,7 @@ Thesaurus::Thesaurus(agi::fs::path const& dat_path, agi::fs::path const& idx_pat
std::vector<std::string> chunks;
boost::split(chunks, line, _1 == '|');
if (chunks.size() == 2)
offsets[chunks[0]] = atoi(chunks[1].c_str());
offsets[chunks[0]] = static_cast<size_t>(atoi(chunks[1].c_str()));
}
}

View file

@ -31,7 +31,7 @@ namespace charset { class IconvWrapper; }
class Thesaurus {
/// Map of word -> byte position in the data file
boost::container::flat_map<std::string, int> offsets;
boost::container::flat_map<std::string, size_t> offsets;
/// Read handle to the data file
std::unique_ptr<read_file_mapping> dat;
/// Converter from the data file's charset to UTF-8

View file

@ -346,7 +346,9 @@ public:
throw agi::AudioProviderOpenError("Found 'data' chunk before 'fmt ' chunk, file is invalid.", nullptr);
auto samples = chunk_size / bytes_per_sample / channels;
index_points.push_back(IndexPoint{filepos, samples});
index_points.push_back(IndexPoint{
static_cast<int64_t>(filepos),
static_cast<int64_t>(samples)});
num_samples += samples;
}

View file

@ -28,9 +28,10 @@
#include <wx/msgdlg.h>
static const size_t bad_pos = -1;
namespace {
static const size_t bad_pos = -1;
static const MatchState bad_match{nullptr, 0, bad_pos};
auto get_dialogue_field(SearchReplaceSettings::Field field) -> decltype(&AssDialogueBase::Text) {
switch (field) {
case SearchReplaceSettings::Field::TEXT: return &AssDialogueBase::Text;
@ -157,7 +158,7 @@ matcher get_matcher(SearchReplaceSettings const& settings, Accessor&& a) {
boost::smatch result;
auto const& str = a.get(diag, start);
if (!u32regex_search(str, result, regex, start > 0 ? boost::match_not_bol : boost::match_default))
return {nullptr, 0, -1};
return bad_match;
return a.make_match_state(result.position(), result.position() + result.length(), &regex);
};
}
@ -169,19 +170,18 @@ matcher get_matcher(SearchReplaceSettings const& settings, Accessor&& a) {
if (!settings.match_case)
look_for = boost::locale::fold_case(look_for);
MatchState invalid{nullptr, 0, -1};
return [=](const AssDialogue *diag, size_t start) mutable -> MatchState {
const auto str = a.get(diag, start);
if (full_match_only && str.size() != look_for.size())
return invalid;
return bad_match;
if (match_case) {
const auto pos = str.find(look_for);
return pos == std::string::npos ? invalid : a.make_match_state(pos, pos + look_for.size());
return pos == std::string::npos ? bad_match : a.make_match_state(pos, pos + look_for.size());
}
const auto pos = agi::util::ifind(str, look_for);
return pos.first == bad_pos ? invalid : a.make_match_state(pos.first, pos.second);
return pos.first == bad_pos ? bad_match : a.make_match_state(pos.first, pos.second);
};
}
@ -230,7 +230,7 @@ bool SearchReplaceEngine::FindReplace(bool replace) {
auto it = context->ass->iterator_to(*line);
size_t pos = 0;
MatchState replace_ms{nullptr, 0, -1};
auto replace_ms = bad_match;
if (replace) {
if (settings.field == SearchReplaceSettings::Field::TEXT)
pos = context->textSelectionController->GetSelectionStart();

View file

@ -89,7 +89,7 @@ void SubtitlesProvider::LoadSubtitles(AssFile *subs, int time) {
push_header("[Events]\n");
for (auto const& line : subs->Events) {
if (!line.Comment && time < 0 || !(line.Start > time || line.End <= time))
if (!line.Comment && (time < 0 || !(line.Start > time || line.End <= time)))
push_line(line.GetEntryData());
}