shwetapixlr / tesseract-ocr

Automatically exported from code.google.com/p/tesseract-ocr
Other
0 stars 0 forks source link

Patch to remove tons of useless and confusing defines #76

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Tesseract code seems to be filled with the following kinds of preprocessor
macros:

#define GetElementX(P) (P->x)

The only point of these is to forcibly change the syntax of C so it does
not use pointer dereferences. I assume some original coder thought that
this is somehow an improvement.

However all this does is make the code more confusing and hard to read
since it adds a totally unnecessary layer of indirection. There are also
tons of cases where, due to macro expansion, the same parameter gets used
twice, thrice or even more times in a single invocation. This is against
all proper coding guidelines and can cause bugs that are extremely
difficult to track down.

I have attached a patch that removes quite a lot of these. Much work still
remains, but it's a start.

Original issue reported on code.google.com by jpakk...@gmail.com on 27 Oct 2007 at 2:42

Attachments:

GoogleCodeExporter commented 9 years ago
How to run patch?

Original comment by withbles...@gmail.com on 27 Oct 2007 at 5:59

GoogleCodeExporter commented 9 years ago
Here's a new version of the patch. It has everything the previous patch had and 
a
whole lot more. It applies directly to a current SVN checkout. Just ignore the
previous one.

Original comment by jpakk...@gmail.com on 30 Oct 2007 at 6:07

Attachments:

GoogleCodeExporter commented 9 years ago
I have already downloaded source code of tesseractocr 2.01.
Instrucions how to run tess_define_cleanup2.patch  - Windows platform.

Original comment by withbles...@gmail.com on 30 Oct 2007 at 6:42

GoogleCodeExporter commented 9 years ago
http://en.wikipedia.org/wiki/Patch_%28Unix%29

Original comment by jpakk...@gmail.com on 30 Oct 2007 at 6:49

GoogleCodeExporter commented 9 years ago
Here is the third version. It should remove most of the useless defines in the 
code.
I have also converted the matrix computation #defines to proper functions.

Original comment by jpakk...@gmail.com on 31 Oct 2007 at 8:27

Attachments:

GoogleCodeExporter commented 9 years ago
Fixed in 2.04 svn rev 219.

Original comment by theraysm...@gmail.com on 10 Mar 2009 at 7:03