code cleanups + use where possible get_uint32 instead of not safe cast

This commit is contained in:
Evgeniy Dushistov
2013-07-07 17:05:55 +00:00
parent fae4b432e1
commit 9034e792b6

View File

@@ -136,7 +136,7 @@ static std::string parse_data(const gchar *data, bool colorize_output)
guint32 data_size, sec_size = 0;
gchar *m_str;
const gchar *p = data;
data_size=*((guint32 *)p);
data_size = get_uint32(p);
p += sizeof(guint32);
while (guint32(p - data)<data_size) {
switch (*p++) {
@@ -180,7 +180,7 @@ static std::string parse_data(const gchar *data, bool colorize_output)
break;
case 'W':
case 'P':
sec_size = *((guint32 *)p);
sec_size = get_uint32(p);
sec_size += sizeof(guint32);
break;
}
@@ -201,7 +201,6 @@ void Library::SimpleLookup(const std::string &str, TSearchResultList& res_list)
TSearchResult(dict_name(idict),
poGetWord(ind, idict),
parse_data(poGetWordData(ind, idict), colorize_output_)));
}
void Library::LookupWithFuzzy(const std::string &str, TSearchResultList& res_list)
@@ -212,8 +211,7 @@ void Library::LookupWithFuzzy(const std::string &str, TSearchResultList& res_lis
if (!Libs::LookupWithFuzzy(str.c_str(), fuzzy_res, MAXFUZZY))
return;
for (gchar **p=fuzzy_res, **end=fuzzy_res+MAXFUZZY;
p!=end && *p; ++p) {
for (gchar **p = fuzzy_res, **end = (fuzzy_res + MAXFUZZY); p != end && *p; ++p) {
SimpleLookup(*p, res_list);
g_free(*p);
}
@@ -224,7 +222,7 @@ void Library::LookupWithRule(const std::string &str, TSearchResultList& res_list
std::vector<gchar *> match_res((MAX_MATCH_ITEM_PER_LIB) * ndicts());
const gint nfound = Libs::LookupWithRule(str.c_str(), &match_res[0]);
if (!nfound)
if (nfound == 0)
return;
for (gint i = 0; i < nfound; ++i) {