View Single Post
Old 12-27-2012, 04:56 PM   #456
Sergey Dubinets
Junior Member
Sergey Dubinets began at the beginning.
 
Posts: 6
Karma: 10
Join Date: Dec 2012
Device: Kindle
A few (possible) bugs I noticed reading the code.

1. PalmdocReader misses the case where c == 0
2. MobiHeader.__init__() assignes self.othidx = 0xfffffff instead of 0xffffffff
3. getLanguage 26 has two entries.
4. mobi_unpack.py:727 "# bytes 19 - 23: start of xor string" => "# bytes 20 - 23: start of xor string"
5. mobi_k8proc.__init__() adds 0xfffffff (instead of 0xffffffff) to the end of self.fdsttbl list
6. getVariableWidthValue() and readTagSection() are defined twice: in mobi_utils.py and mobi_index.py
7. countSetBits() is defined twice: in mobi_index.py and mobi_dict.py; It doesn't need to be a member functions.
8. the same with getTagMap().
9. This is not the most optimum way to write countSetBits(). See bellow (sorry for C#).
10. num += 1 at the end of parseNCX() is redundant
11. re: '''<[^<>]+filepos=['"]{0,1}(\d+)[^<>]*>'''. What about closing quite or apos?
12. re: join removing empty anchors in sigle substitution. Existent re doesn't handle all all possible WS.
13. mobi_opf.py:127. print format parameters are missing.
14. mobi_opf.py:51 escape() function is for escaping HTML text nodes not attribute values. It doesn't escape " to &quot;
15. mobi_opf.py:222 tries to find 'StartOffset' in the metadata. This is hopeless becuase all keys including ('StartOffset') ware deleted at line 154.




public static int countSetBits(int value) {
int count = 0;
while (value != 0) {
count ++;
value &= value - 1; // "eats" lowest 1 bit in the value
}
return count;
}
Sergey Dubinets is offline   Reply With Quote