Skip to content

Commit

Permalink
Changes to cutil for 3.00
Browse files Browse the repository at this point in the history
git-svn-id: https://tesseract-ocr.googlecode.com/svn/trunk@292 d0cd1f9f-072b-0410-8dd7-cf729c803f20
  • Loading branch information
theraysmith committed Jul 11, 2009
1 parent 694d3f2 commit 82071af
Show file tree
Hide file tree
Showing 20 changed files with 491 additions and 1,284 deletions.
11 changes: 6 additions & 5 deletions cutil/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
SUBDIRS =
AM_CPPFLAGS = -I$(top_srcdir)/ccutil

EXTRA_DIST = cutil.vcproj

include_HEADERS = \
bitvec.h callcpp.h const.h cutil.h danerror.h debug.h efio.h \
bitvec.h callcpp.h const.h cutil.h cutil_class.h danerror.h efio.h \
emalloc.h freelist.h funcdefs.h general.h globals.h listio.h \
minmax.h oldheap.h oldlist.h structures.h tessarray.h \
tordvars.h variables.h
oldheap.h oldlist.h structures.h tessarray.h

lib_LIBRARIES = libtesseract_cutil.a
libtesseract_cutil_a_SOURCES = \
tessarray.cpp bitvec.cpp cutil.cpp danerror.cpp debug.cpp efio.cpp \
bitvec.cpp cutil.cpp cutil_class.cpp danerror.cpp efio.cpp \
emalloc.cpp freelist.cpp globals.cpp listio.cpp oldheap.cpp \
oldlist.cpp structures.cpp tordvars.cpp variables.cpp
oldlist.cpp structures.cpp tessarray.cpp
25 changes: 11 additions & 14 deletions cutil/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,11 @@ AR = ar
ARFLAGS = cru
libtesseract_cutil_a_AR = $(AR) $(ARFLAGS)
libtesseract_cutil_a_LIBADD =
am_libtesseract_cutil_a_OBJECTS = tessarray.$(OBJEXT) bitvec.$(OBJEXT) \
cutil.$(OBJEXT) danerror.$(OBJEXT) debug.$(OBJEXT) \
efio.$(OBJEXT) emalloc.$(OBJEXT) freelist.$(OBJEXT) \
globals.$(OBJEXT) listio.$(OBJEXT) oldheap.$(OBJEXT) \
oldlist.$(OBJEXT) structures.$(OBJEXT) tordvars.$(OBJEXT) \
variables.$(OBJEXT)
am_libtesseract_cutil_a_OBJECTS = bitvec.$(OBJEXT) cutil.$(OBJEXT) \
cutil_class.$(OBJEXT) danerror.$(OBJEXT) efio.$(OBJEXT) \
emalloc.$(OBJEXT) freelist.$(OBJEXT) globals.$(OBJEXT) \
listio.$(OBJEXT) oldheap.$(OBJEXT) oldlist.$(OBJEXT) \
structures.$(OBJEXT) tessarray.$(OBJEXT)
libtesseract_cutil_a_OBJECTS = $(am_libtesseract_cutil_a_OBJECTS)
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/config/depcomp
Expand Down Expand Up @@ -194,17 +193,17 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
SUBDIRS =
AM_CPPFLAGS = -I$(top_srcdir)/ccutil
EXTRA_DIST = cutil.vcproj
include_HEADERS = \
bitvec.h callcpp.h const.h cutil.h danerror.h debug.h efio.h \
bitvec.h callcpp.h const.h cutil.h cutil_class.h danerror.h efio.h \
emalloc.h freelist.h funcdefs.h general.h globals.h listio.h \
minmax.h oldheap.h oldlist.h structures.h tessarray.h \
tordvars.h variables.h
oldheap.h oldlist.h structures.h tessarray.h

lib_LIBRARIES = libtesseract_cutil.a
libtesseract_cutil_a_SOURCES = \
tessarray.cpp bitvec.cpp cutil.cpp danerror.cpp debug.cpp efio.cpp \
bitvec.cpp cutil.cpp cutil_class.cpp danerror.cpp efio.cpp \
emalloc.cpp freelist.cpp globals.cpp listio.cpp oldheap.cpp \
oldlist.cpp structures.cpp tordvars.cpp variables.cpp
oldlist.cpp structures.cpp tessarray.cpp

all: all-recursive

Expand Down Expand Up @@ -281,8 +280,8 @@ distclean-compile:

@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bitvec.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cutil.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cutil_class.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/danerror.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/debug.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/efio.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/emalloc.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/freelist.Po@am__quote@
Expand All @@ -292,8 +291,6 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/oldlist.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/structures.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tessarray.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tordvars.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/variables.Po@am__quote@

.cpp.o:
@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
Expand Down
59 changes: 3 additions & 56 deletions cutil/callcpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
#ifndef CALLCPP_H
#define CALLCPP_H

#ifndef __UNIX__
#include <assert.h>
#endif
#include "host.h"
#include "varable.h"
#include "unichar.h"

class ScrollView;

#ifdef __cplusplus
//extern "C" {
#endif
typedef enum {
Black,
White,
Expand Down Expand Up @@ -87,73 +87,23 @@ extern INT_VAR_H (tess_cp_mapping0, 0, "Mappings for class pruner distance");
extern INT_VAR_H (tess_cp_mapping1, 1, "Mappings for class pruner distance");
extern INT_VAR_H (tess_cp_mapping2, 2, "Mappings for class pruner distance");
extern INT_VAR_H (tess_cp_mapping3, 3, "Mappings for class pruner distance");
extern INT_VAR_H (stopper_numbers_on, 0,
"Allow numbers to be acceptable choices");
extern INT_VAR_H (config_pruner_enabled, 0, "Turn on config pruner");
extern INT_VAR_H (feature_prune_percentile, 0, "Percent of features to use");
extern INT_VAR_H (newcp_ratings_on, 0, "Use new class pruner normalisation");
extern INT_VAR_H (record_matcher_output, 0, "Record detailed matcher info");
extern INT_VAR_H (il1_adaption_test, 0,
"Dont adapt to i/I at beginning of word");
extern double_VAR_H (permuter_pending_threshold, 0.0,
"Worst conf for using pending dictionary");
extern double_VAR_H (newcp_duff_rating, 0.30,
"Worst rating for calling real matcher");
extern double_VAR_H (newcp_prune_threshold, 1.2, "Ratio of best to prune");
extern double_VAR_H (tessedit_cp_ratio, 0.0, "Ratio from best to prune");

//Global matcher info from the class pruner.
extern inT32 cp_classes;
extern inT32 cp_bestindex;
extern inT32 cp_bestrating;
extern inT32 cp_bestconf;
extern char cp_chars[2];
extern inT32 cp_ratings[2];
extern inT32 cp_confs[2];
extern inT32 cp_maps[4];
//Global info to control writes of matcher info
extern inT32 blob_type; //write control
extern char blob_answer[UNICHAR_LEN + 1]; //correct char
extern char *word_answer; //correct word
extern inT32 matcher_pass; //pass in chopper.c
extern inT32 bits_in_states; //no of bits in states

#ifndef __UNIX__
#include <assert.h>
#endif
void setup_cp_maps();
void trace_stack(); //Trace current stack
void cprintf ( //Trace printf
const char *format, ... //special message
);
char *c_alloc_string( //allocate string
inT32 count //no of chars required
);
void c_free_string( //free a string
char *string //string to free
);
void *c_alloc_struct( //allocate memory
inT32 count, //no of chars required
const char *name //class name
);
void c_free_struct( //free a structure
void *deadstruct, //structure to free
inT32 count, //no of bytes
const char *name //class name
);
void *c_alloc_mem_p( //allocate permanent space
inT32 count //block size to allocate
);
void *c_alloc_mem( //get some memory
inT32 count //no of bytes to get
);
void c_free_mem( //free mem from alloc_mem
void *oldchunk //chunk to free
);
void c_check_mem( //check consistency
const char *string, //context message
inT8 level //level of check
);
ScrollView *c_create_window( /*create a window */
const char *name, /*name/title of window */
inT16 xpos, /*coords of window */
Expand Down Expand Up @@ -184,7 +134,4 @@ char window_wait(ScrollView* win);
void reverse32(void *ptr);
void reverse16(void *ptr);

#ifdef __cplusplus
//};
#endif
#endif
3 changes: 0 additions & 3 deletions cutil/cutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ Import original HP distribution

#define RESET_COUNT 2000

void_proc deallocate = (void_proc) c_free_string;
char_proc allocate = (char_proc) c_alloc_string;

/**********************************************************************
* long_rand
*
Expand Down
31 changes: 3 additions & 28 deletions cutil/cutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,42 +64,16 @@ Import original HP distribution

//typedef int (*int_proc) (void);
typedef void (*void_proc) (...);
typedef char *(*char_proc) _ARGS ((...));
typedef void *(*void_star_proc) _ARGS ((...));

typedef int (*int_void) (void);
typedef void (*void_void) (void);
typedef int (*int_compare) (void *, void *);
typedef void (*void_dest) (void *);

extern void_proc deallocate;
extern char_proc allocate;

/*----------------------------------------------------------------------
M a c r o s
----------------------------------------------------------------------*/
/**********************************************************************
* min
*
* Minimum of two values
**********************************************************************/

#ifndef min
#define min(x,y) \
((x) < (y) ? (x) : (y))
#endif

/**********************************************************************
* max
*
* Maximum of two values
**********************************************************************/

#ifndef max
#define max(x,y) \
((y) < (x) ? (x) : (y))
#endif

/**********************************************************************
* new_line
*
Expand All @@ -125,7 +99,7 @@ extern char_proc allocate;
* to it and return the result.
**********************************************************************/

#define strfree(s) ((*deallocate) (s))
#define strfree(s) (free_string(s))

/**********************************************************************
* strsave
Expand All @@ -136,7 +110,7 @@ extern char_proc allocate;

#define strsave(s) \
((s) != NULL ? \
((char*) strcpy ((*allocate) (strlen(s)+1), s)) : \
((char*) strcpy (alloc_string(strlen(s)+1), s)) : \
(NULL))

/*----------------------------------------------------------------------
Expand All @@ -156,4 +130,5 @@ FILE *open_file
#undef _ARGS
*/
#include "cutil_class.h"
#endif
Loading

0 comments on commit 82071af

Please sign in to comment.