mirror of
https://github.com/Dushistov/sdcv.git
synced 2025-12-15 17:31:56 +00:00
code cleanups + use where possible get_uint32 instead of not safe cast
This commit is contained in:
@@ -133,11 +133,11 @@ static std::string parse_data(const gchar *data, bool colorize_output)
|
||||
return "";
|
||||
|
||||
std::string res;
|
||||
guint32 data_size, sec_size=0;
|
||||
guint32 data_size, sec_size = 0;
|
||||
gchar *m_str;
|
||||
const gchar *p=data;
|
||||
data_size=*((guint32 *)p);
|
||||
p+=sizeof(guint32);
|
||||
const gchar *p = data;
|
||||
data_size = get_uint32(p);
|
||||
p += sizeof(guint32);
|
||||
while (guint32(p - data)<data_size) {
|
||||
switch (*p++) {
|
||||
case 'm':
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user