simplify parsing of integers in ifo file

This commit is contained in:
Evgeniy A. Dushistov
2017-07-06 13:11:02 +03:00
parent 4c367fc12c
commit 72a15b70a7

View File

@@ -99,10 +99,8 @@ bool DictInfo::load_from_ifo_file(const std::string& ifofilename,
return false; return false;
gchar *p3 = strchr(p2 + sizeof("\nwordcount=") - 1, '\n'); gchar *p3 = strchr(p2 + sizeof("\nwordcount=") - 1, '\n');
gchar *tmpstr = (gchar *)g_memdup(p2+sizeof("\nwordcount=")-1, p3-(p2+sizeof("\nwordcount=")-1)+1);
tmpstr[p3-(p2+sizeof("\nwordcount=")-1)] = '\0'; wordcount = atol(std::string(p2+sizeof("\nwordcount=")-1, p3-(p2+sizeof("\nwordcount=")-1)).c_str());
wordcount = atol(tmpstr);
g_free(tmpstr);
if (istreedict) { if (istreedict) {
p2 = strstr(p1,"\ntdxfilesize="); p2 = strstr(p1,"\ntdxfilesize=");
@@ -110,10 +108,9 @@ bool DictInfo::load_from_ifo_file(const std::string& ifofilename,
return false; return false;
p3 = strchr(p2+ sizeof("\ntdxfilesize=")-1,'\n'); p3 = strchr(p2+ sizeof("\ntdxfilesize=")-1,'\n');
tmpstr = (gchar *)g_memdup(p2+sizeof("\ntdxfilesize=")-1, p3-(p2+sizeof("\ntdxfilesize=")-1)+1);
tmpstr[p3-(p2+sizeof("\ntdxfilesize=")-1)] = '\0'; index_file_size = atol(std::string(p2+sizeof("\ntdxfilesize=")-1, p3-(p2+sizeof("\ntdxfilesize=")-1)).c_str());
index_file_size = atol(tmpstr);
g_free(tmpstr);
} else { } else {
p2 = strstr(p1,"\nidxfilesize="); p2 = strstr(p1,"\nidxfilesize=");
@@ -121,10 +118,7 @@ bool DictInfo::load_from_ifo_file(const std::string& ifofilename,
return false; return false;
p3 = strchr(p2+ sizeof("\nidxfilesize=")-1,'\n'); p3 = strchr(p2+ sizeof("\nidxfilesize=")-1,'\n');
tmpstr = (gchar *)g_memdup(p2+sizeof("\nidxfilesize=")-1, p3-(p2+sizeof("\nidxfilesize=")-1)+1); index_file_size = atol(std::string(p2+sizeof("\nidxfilesize=")-1, p3-(p2+sizeof("\nidxfilesize=")-1)).c_str());
tmpstr[p3-(p2+sizeof("\nidxfilesize=")-1)] = '\0';
index_file_size = atol(tmpstr);
g_free(tmpstr);
} }
p2 = strstr(p1,"\nbookname="); p2 = strstr(p1,"\nbookname=");