mirror of
https://github.com/Dushistov/sdcv.git
synced 2025-12-16 09:51: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 "";
|
return "";
|
||||||
|
|
||||||
std::string res;
|
std::string res;
|
||||||
guint32 data_size, sec_size=0;
|
guint32 data_size, sec_size = 0;
|
||||||
gchar *m_str;
|
gchar *m_str;
|
||||||
const gchar *p=data;
|
const gchar *p = data;
|
||||||
data_size=*((guint32 *)p);
|
data_size = get_uint32(p);
|
||||||
p+=sizeof(guint32);
|
p += sizeof(guint32);
|
||||||
while (guint32(p - data)<data_size) {
|
while (guint32(p - data)<data_size) {
|
||||||
switch (*p++) {
|
switch (*p++) {
|
||||||
case 'm':
|
case 'm':
|
||||||
@@ -180,7 +180,7 @@ static std::string parse_data(const gchar *data, bool colorize_output)
|
|||||||
break;
|
break;
|
||||||
case 'W':
|
case 'W':
|
||||||
case 'P':
|
case 'P':
|
||||||
sec_size = *((guint32 *)p);
|
sec_size = get_uint32(p);
|
||||||
sec_size += sizeof(guint32);
|
sec_size += sizeof(guint32);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -201,7 +201,6 @@ void Library::SimpleLookup(const std::string &str, TSearchResultList& res_list)
|
|||||||
TSearchResult(dict_name(idict),
|
TSearchResult(dict_name(idict),
|
||||||
poGetWord(ind, idict),
|
poGetWord(ind, idict),
|
||||||
parse_data(poGetWordData(ind, idict), colorize_output_)));
|
parse_data(poGetWordData(ind, idict), colorize_output_)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Library::LookupWithFuzzy(const std::string &str, TSearchResultList& res_list)
|
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))
|
if (!Libs::LookupWithFuzzy(str.c_str(), fuzzy_res, MAXFUZZY))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (gchar **p=fuzzy_res, **end=fuzzy_res+MAXFUZZY;
|
for (gchar **p = fuzzy_res, **end = (fuzzy_res + MAXFUZZY); p != end && *p; ++p) {
|
||||||
p!=end && *p; ++p) {
|
|
||||||
SimpleLookup(*p, res_list);
|
SimpleLookup(*p, res_list);
|
||||||
g_free(*p);
|
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());
|
std::vector<gchar *> match_res((MAX_MATCH_ITEM_PER_LIB) * ndicts());
|
||||||
|
|
||||||
const gint nfound = Libs::LookupWithRule(str.c_str(), &match_res[0]);
|
const gint nfound = Libs::LookupWithRule(str.c_str(), &match_res[0]);
|
||||||
if (!nfound)
|
if (nfound == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (gint i = 0; i < nfound; ++i) {
|
for (gint i = 0; i < nfound; ++i) {
|
||||||
|
|||||||
Reference in New Issue
Block a user