tesseract_bin 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.document +5 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +23 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +46 -0
- data/VERSION +1 -0
- data/ext/tesseract_bin/extconf.rb +17 -0
- data/lib/tesseract_bin.rb +12 -0
- data/tesseract_bin.gemspec +660 -0
- data/test/helper.rb +18 -0
- data/test/test_tesseract_bin.rb +7 -0
- data/vendor/tesseract-2.04/AUTHORS +8 -0
- data/vendor/tesseract-2.04/COPYING +23 -0
- data/vendor/tesseract-2.04/ChangeLog +71 -0
- data/vendor/tesseract-2.04/INSTALL +229 -0
- data/vendor/tesseract-2.04/Makefile.am +20 -0
- data/vendor/tesseract-2.04/Makefile.in +641 -0
- data/vendor/tesseract-2.04/NEWS +1 -0
- data/vendor/tesseract-2.04/README +138 -0
- data/vendor/tesseract-2.04/ReleaseNotes +213 -0
- data/vendor/tesseract-2.04/StdAfx.cpp +8 -0
- data/vendor/tesseract-2.04/StdAfx.h +24 -0
- data/vendor/tesseract-2.04/ccmain/Makefile.am +63 -0
- data/vendor/tesseract-2.04/ccmain/Makefile.in +735 -0
- data/vendor/tesseract-2.04/ccmain/adaptions.cpp +1082 -0
- data/vendor/tesseract-2.04/ccmain/adaptions.h +109 -0
- data/vendor/tesseract-2.04/ccmain/applybox.cpp +891 -0
- data/vendor/tesseract-2.04/ccmain/applybox.h +73 -0
- data/vendor/tesseract-2.04/ccmain/baseapi.cpp +1105 -0
- data/vendor/tesseract-2.04/ccmain/baseapi.h +256 -0
- data/vendor/tesseract-2.04/ccmain/blobcmp.cpp +76 -0
- data/vendor/tesseract-2.04/ccmain/blobcmp.h +29 -0
- data/vendor/tesseract-2.04/ccmain/callnet.cpp +93 -0
- data/vendor/tesseract-2.04/ccmain/callnet.h +32 -0
- data/vendor/tesseract-2.04/ccmain/charcut.cpp +704 -0
- data/vendor/tesseract-2.04/ccmain/charcut.h +120 -0
- data/vendor/tesseract-2.04/ccmain/charsample.cpp +699 -0
- data/vendor/tesseract-2.04/ccmain/control.cpp +1842 -0
- data/vendor/tesseract-2.04/ccmain/control.h +198 -0
- data/vendor/tesseract-2.04/ccmain/docqual.cpp +1481 -0
- data/vendor/tesseract-2.04/ccmain/docqual.h +155 -0
- data/vendor/tesseract-2.04/ccmain/expandblob.cpp +82 -0
- data/vendor/tesseract-2.04/ccmain/expandblob.h +13 -0
- data/vendor/tesseract-2.04/ccmain/fixspace.cpp +989 -0
- data/vendor/tesseract-2.04/ccmain/fixspace.h +72 -0
- data/vendor/tesseract-2.04/ccmain/fixxht.cpp +825 -0
- data/vendor/tesseract-2.04/ccmain/fixxht.h +93 -0
- data/vendor/tesseract-2.04/ccmain/imgscale.cpp +154 -0
- data/vendor/tesseract-2.04/ccmain/imgscale.h +32 -0
- data/vendor/tesseract-2.04/ccmain/matmatch.cpp +391 -0
- data/vendor/tesseract-2.04/ccmain/matmatch.h +48 -0
- data/vendor/tesseract-2.04/ccmain/output.cpp +1273 -0
- data/vendor/tesseract-2.04/ccmain/output.h +116 -0
- data/vendor/tesseract-2.04/ccmain/pagewalk.cpp +666 -0
- data/vendor/tesseract-2.04/ccmain/pagewalk.h +155 -0
- data/vendor/tesseract-2.04/ccmain/paircmp.cpp +107 -0
- data/vendor/tesseract-2.04/ccmain/paircmp.h +43 -0
- data/vendor/tesseract-2.04/ccmain/pgedit.cpp +1867 -0
- data/vendor/tesseract-2.04/ccmain/pgedit.h +181 -0
- data/vendor/tesseract-2.04/ccmain/reject.cpp +1775 -0
- data/vendor/tesseract-2.04/ccmain/reject.h +181 -0
- data/vendor/tesseract-2.04/ccmain/scaleimg.cpp +366 -0
- data/vendor/tesseract-2.04/ccmain/scaleimg.h +35 -0
- data/vendor/tesseract-2.04/ccmain/tessbox.cpp +375 -0
- data/vendor/tesseract-2.04/ccmain/tessbox.h +110 -0
- data/vendor/tesseract-2.04/ccmain/tessedit.cpp +278 -0
- data/vendor/tesseract-2.04/ccmain/tessedit.h +49 -0
- data/vendor/tesseract-2.04/ccmain/tessembedded.cpp +110 -0
- data/vendor/tesseract-2.04/ccmain/tessembedded.h +38 -0
- data/vendor/tesseract-2.04/ccmain/tesseractfull.cc +37 -0
- data/vendor/tesseract-2.04/ccmain/tesseractmain.cpp +387 -0
- data/vendor/tesseract-2.04/ccmain/tesseractmain.h +58 -0
- data/vendor/tesseract-2.04/ccmain/tessio.h +110 -0
- data/vendor/tesseract-2.04/ccmain/tessvars.cpp +38 -0
- data/vendor/tesseract-2.04/ccmain/tessvars.h +48 -0
- data/vendor/tesseract-2.04/ccmain/tfacep.h +62 -0
- data/vendor/tesseract-2.04/ccmain/tfacepp.cpp +443 -0
- data/vendor/tesseract-2.04/ccmain/tfacepp.h +85 -0
- data/vendor/tesseract-2.04/ccmain/tstruct.cpp +549 -0
- data/vendor/tesseract-2.04/ccmain/tstruct.h +108 -0
- data/vendor/tesseract-2.04/ccmain/varabled.cpp +346 -0
- data/vendor/tesseract-2.04/ccmain/varabled.h +125 -0
- data/vendor/tesseract-2.04/ccmain/werdit.cpp +193 -0
- data/vendor/tesseract-2.04/ccmain/werdit.h +67 -0
- data/vendor/tesseract-2.04/ccstruct/Makefile.am +25 -0
- data/vendor/tesseract-2.04/ccstruct/Makefile.in +650 -0
- data/vendor/tesseract-2.04/ccstruct/blckerr.h +29 -0
- data/vendor/tesseract-2.04/ccstruct/blobbox.cpp +778 -0
- data/vendor/tesseract-2.04/ccstruct/blobbox.h +381 -0
- data/vendor/tesseract-2.04/ccstruct/blobs.cpp +247 -0
- data/vendor/tesseract-2.04/ccstruct/blobs.h +119 -0
- data/vendor/tesseract-2.04/ccstruct/blread.cpp +537 -0
- data/vendor/tesseract-2.04/ccstruct/blread.h +63 -0
- data/vendor/tesseract-2.04/ccstruct/callcpp.cpp +252 -0
- data/vendor/tesseract-2.04/ccstruct/coutln.cpp +650 -0
- data/vendor/tesseract-2.04/ccstruct/coutln.h +186 -0
- data/vendor/tesseract-2.04/ccstruct/crakedge.h +39 -0
- data/vendor/tesseract-2.04/ccstruct/genblob.cpp +133 -0
- data/vendor/tesseract-2.04/ccstruct/genblob.h +52 -0
- data/vendor/tesseract-2.04/ccstruct/hpddef.h +39 -0
- data/vendor/tesseract-2.04/ccstruct/hpdsizes.h +8 -0
- data/vendor/tesseract-2.04/ccstruct/ipoints.h +479 -0
- data/vendor/tesseract-2.04/ccstruct/labls.cpp +188 -0
- data/vendor/tesseract-2.04/ccstruct/labls.h +38 -0
- data/vendor/tesseract-2.04/ccstruct/linlsq.cpp +249 -0
- data/vendor/tesseract-2.04/ccstruct/linlsq.h +102 -0
- data/vendor/tesseract-2.04/ccstruct/lmedsq.cpp +453 -0
- data/vendor/tesseract-2.04/ccstruct/lmedsq.h +84 -0
- data/vendor/tesseract-2.04/ccstruct/mod128.cpp +100 -0
- data/vendor/tesseract-2.04/ccstruct/mod128.h +85 -0
- data/vendor/tesseract-2.04/ccstruct/normalis.cpp +176 -0
- data/vendor/tesseract-2.04/ccstruct/normalis.h +108 -0
- data/vendor/tesseract-2.04/ccstruct/ocrblock.cpp +369 -0
- data/vendor/tesseract-2.04/ccstruct/ocrblock.h +235 -0
- data/vendor/tesseract-2.04/ccstruct/ocrrow.cpp +216 -0
- data/vendor/tesseract-2.04/ccstruct/ocrrow.h +133 -0
- data/vendor/tesseract-2.04/ccstruct/pageblk.cpp +879 -0
- data/vendor/tesseract-2.04/ccstruct/pageblk.h +318 -0
- data/vendor/tesseract-2.04/ccstruct/pageres.cpp +330 -0
- data/vendor/tesseract-2.04/ccstruct/pageres.h +313 -0
- data/vendor/tesseract-2.04/ccstruct/pdblock.cpp +361 -0
- data/vendor/tesseract-2.04/ccstruct/pdblock.h +181 -0
- data/vendor/tesseract-2.04/ccstruct/pdclass.h +54 -0
- data/vendor/tesseract-2.04/ccstruct/points.cpp +102 -0
- data/vendor/tesseract-2.04/ccstruct/points.h +299 -0
- data/vendor/tesseract-2.04/ccstruct/polyaprx.cpp +588 -0
- data/vendor/tesseract-2.04/ccstruct/polyaprx.h +51 -0
- data/vendor/tesseract-2.04/ccstruct/polyblk.cpp +398 -0
- data/vendor/tesseract-2.04/ccstruct/polyblk.h +122 -0
- data/vendor/tesseract-2.04/ccstruct/polyblob.cpp +357 -0
- data/vendor/tesseract-2.04/ccstruct/polyblob.h +102 -0
- data/vendor/tesseract-2.04/ccstruct/polyvert.cpp +23 -0
- data/vendor/tesseract-2.04/ccstruct/polyvert.h +58 -0
- data/vendor/tesseract-2.04/ccstruct/poutline.cpp +441 -0
- data/vendor/tesseract-2.04/ccstruct/poutline.h +125 -0
- data/vendor/tesseract-2.04/ccstruct/quadlsq.cpp +147 -0
- data/vendor/tesseract-2.04/ccstruct/quadlsq.h +67 -0
- data/vendor/tesseract-2.04/ccstruct/quadratc.cpp +21 -0
- data/vendor/tesseract-2.04/ccstruct/quadratc.h +63 -0
- data/vendor/tesseract-2.04/ccstruct/quspline.cpp +382 -0
- data/vendor/tesseract-2.04/ccstruct/quspline.h +113 -0
- data/vendor/tesseract-2.04/ccstruct/ratngs.cpp +372 -0
- data/vendor/tesseract-2.04/ccstruct/ratngs.h +198 -0
- data/vendor/tesseract-2.04/ccstruct/rect.cpp +229 -0
- data/vendor/tesseract-2.04/ccstruct/rect.h +320 -0
- data/vendor/tesseract-2.04/ccstruct/rejctmap.cpp +545 -0
- data/vendor/tesseract-2.04/ccstruct/rejctmap.h +284 -0
- data/vendor/tesseract-2.04/ccstruct/rwpoly.cpp +89 -0
- data/vendor/tesseract-2.04/ccstruct/rwpoly.h +45 -0
- data/vendor/tesseract-2.04/ccstruct/statistc.cpp +905 -0
- data/vendor/tesseract-2.04/ccstruct/statistc.h +135 -0
- data/vendor/tesseract-2.04/ccstruct/stepblob.cpp +296 -0
- data/vendor/tesseract-2.04/ccstruct/stepblob.h +88 -0
- data/vendor/tesseract-2.04/ccstruct/txtregn.cpp +230 -0
- data/vendor/tesseract-2.04/ccstruct/txtregn.h +155 -0
- data/vendor/tesseract-2.04/ccstruct/vecfuncs.cpp +63 -0
- data/vendor/tesseract-2.04/ccstruct/vecfuncs.h +91 -0
- data/vendor/tesseract-2.04/ccstruct/werd.cpp +967 -0
- data/vendor/tesseract-2.04/ccstruct/werd.h +277 -0
- data/vendor/tesseract-2.04/ccutil/Makefile.am +19 -0
- data/vendor/tesseract-2.04/ccutil/Makefile.in +626 -0
- data/vendor/tesseract-2.04/ccutil/basedir.cpp +118 -0
- data/vendor/tesseract-2.04/ccutil/basedir.h +32 -0
- data/vendor/tesseract-2.04/ccutil/bits16.cpp +30 -0
- data/vendor/tesseract-2.04/ccutil/bits16.h +61 -0
- data/vendor/tesseract-2.04/ccutil/boxread.cpp +105 -0
- data/vendor/tesseract-2.04/ccutil/boxread.h +44 -0
- data/vendor/tesseract-2.04/ccutil/clst.cpp +626 -0
- data/vendor/tesseract-2.04/ccutil/clst.h +1085 -0
- data/vendor/tesseract-2.04/ccutil/debugwin.cpp +500 -0
- data/vendor/tesseract-2.04/ccutil/debugwin.h +103 -0
- data/vendor/tesseract-2.04/ccutil/elst.cpp +593 -0
- data/vendor/tesseract-2.04/ccutil/elst.h +1125 -0
- data/vendor/tesseract-2.04/ccutil/elst2.cpp +606 -0
- data/vendor/tesseract-2.04/ccutil/elst2.h +1121 -0
- data/vendor/tesseract-2.04/ccutil/errcode.cpp +104 -0
- data/vendor/tesseract-2.04/ccutil/errcode.h +104 -0
- data/vendor/tesseract-2.04/ccutil/fileerr.h +34 -0
- data/vendor/tesseract-2.04/ccutil/globaloc.cpp +115 -0
- data/vendor/tesseract-2.04/ccutil/globaloc.h +40 -0
- data/vendor/tesseract-2.04/ccutil/hashfn.cpp +57 -0
- data/vendor/tesseract-2.04/ccutil/hashfn.h +30 -0
- data/vendor/tesseract-2.04/ccutil/host.h +180 -0
- data/vendor/tesseract-2.04/ccutil/hosthplb.h +1 -0
- data/vendor/tesseract-2.04/ccutil/lsterr.h +43 -0
- data/vendor/tesseract-2.04/ccutil/mainblk.cpp +126 -0
- data/vendor/tesseract-2.04/ccutil/mainblk.h +39 -0
- data/vendor/tesseract-2.04/ccutil/memblk.cpp +1106 -0
- data/vendor/tesseract-2.04/ccutil/memblk.h +189 -0
- data/vendor/tesseract-2.04/ccutil/memry.cpp +532 -0
- data/vendor/tesseract-2.04/ccutil/memry.h +192 -0
- data/vendor/tesseract-2.04/ccutil/memryerr.h +38 -0
- data/vendor/tesseract-2.04/ccutil/mfcpch.cpp +5 -0
- data/vendor/tesseract-2.04/ccutil/mfcpch.h +37 -0
- data/vendor/tesseract-2.04/ccutil/ndminx.h +31 -0
- data/vendor/tesseract-2.04/ccutil/notdll.h +28 -0
- data/vendor/tesseract-2.04/ccutil/nwmain.h +176 -0
- data/vendor/tesseract-2.04/ccutil/ocrclass.h +345 -0
- data/vendor/tesseract-2.04/ccutil/ocrshell.cpp +772 -0
- data/vendor/tesseract-2.04/ccutil/ocrshell.h +191 -0
- data/vendor/tesseract-2.04/ccutil/platform.h +18 -0
- data/vendor/tesseract-2.04/ccutil/scanutils.cpp +543 -0
- data/vendor/tesseract-2.04/ccutil/scanutils.h +55 -0
- data/vendor/tesseract-2.04/ccutil/secname.h +9 -0
- data/vendor/tesseract-2.04/ccutil/serialis.cpp +117 -0
- data/vendor/tesseract-2.04/ccutil/serialis.h +93 -0
- data/vendor/tesseract-2.04/ccutil/stderr.h +26 -0
- data/vendor/tesseract-2.04/ccutil/strngs.cpp +495 -0
- data/vendor/tesseract-2.04/ccutil/strngs.h +138 -0
- data/vendor/tesseract-2.04/ccutil/tessclas.h +135 -0
- data/vendor/tesseract-2.04/ccutil/tessopt.cpp +61 -0
- data/vendor/tesseract-2.04/ccutil/tessopt.h +30 -0
- data/vendor/tesseract-2.04/ccutil/tprintf.cpp +122 -0
- data/vendor/tesseract-2.04/ccutil/tprintf.h +35 -0
- data/vendor/tesseract-2.04/ccutil/unichar.cpp +144 -0
- data/vendor/tesseract-2.04/ccutil/unichar.h +84 -0
- data/vendor/tesseract-2.04/ccutil/unicharmap.cpp +172 -0
- data/vendor/tesseract-2.04/ccutil/unicharmap.h +82 -0
- data/vendor/tesseract-2.04/ccutil/unicharset.cpp +307 -0
- data/vendor/tesseract-2.04/ccutil/unicharset.h +267 -0
- data/vendor/tesseract-2.04/ccutil/varable.cpp +672 -0
- data/vendor/tesseract-2.04/ccutil/varable.h +419 -0
- data/vendor/tesseract-2.04/classify/Makefile.am +24 -0
- data/vendor/tesseract-2.04/classify/Makefile.in +647 -0
- data/vendor/tesseract-2.04/classify/adaptive.cpp +535 -0
- data/vendor/tesseract-2.04/classify/adaptive.h +199 -0
- data/vendor/tesseract-2.04/classify/adaptmatch.cpp +2958 -0
- data/vendor/tesseract-2.04/classify/adaptmatch.h +86 -0
- data/vendor/tesseract-2.04/classify/baseline.cpp +58 -0
- data/vendor/tesseract-2.04/classify/baseline.h +91 -0
- data/vendor/tesseract-2.04/classify/blobclass.cpp +123 -0
- data/vendor/tesseract-2.04/classify/blobclass.h +49 -0
- data/vendor/tesseract-2.04/classify/chartoname.cpp +74 -0
- data/vendor/tesseract-2.04/classify/chartoname.h +21 -0
- data/vendor/tesseract-2.04/classify/cluster.cpp +2834 -0
- data/vendor/tesseract-2.04/classify/cluster.h +158 -0
- data/vendor/tesseract-2.04/classify/clusttool.cpp +507 -0
- data/vendor/tesseract-2.04/classify/clusttool.h +70 -0
- data/vendor/tesseract-2.04/classify/cutoffs.cpp +73 -0
- data/vendor/tesseract-2.04/classify/cutoffs.h +49 -0
- data/vendor/tesseract-2.04/classify/extern.h +32 -0
- data/vendor/tesseract-2.04/classify/extract.cpp +100 -0
- data/vendor/tesseract-2.04/classify/extract.h +36 -0
- data/vendor/tesseract-2.04/classify/featdefs.cpp +244 -0
- data/vendor/tesseract-2.04/classify/featdefs.h +71 -0
- data/vendor/tesseract-2.04/classify/flexfx.cpp +87 -0
- data/vendor/tesseract-2.04/classify/flexfx.h +34 -0
- data/vendor/tesseract-2.04/classify/float2int.cpp +126 -0
- data/vendor/tesseract-2.04/classify/float2int.h +65 -0
- data/vendor/tesseract-2.04/classify/fpoint.cpp +73 -0
- data/vendor/tesseract-2.04/classify/fpoint.h +63 -0
- data/vendor/tesseract-2.04/classify/fxdefs.cpp +74 -0
- data/vendor/tesseract-2.04/classify/fxdefs.h +93 -0
- data/vendor/tesseract-2.04/classify/fxid.h +69 -0
- data/vendor/tesseract-2.04/classify/hideedge.cpp +35 -0
- data/vendor/tesseract-2.04/classify/hideedge.h +76 -0
- data/vendor/tesseract-2.04/classify/intfx.cpp +608 -0
- data/vendor/tesseract-2.04/classify/intfx.h +63 -0
- data/vendor/tesseract-2.04/classify/intmatcher.cpp +1524 -0
- data/vendor/tesseract-2.04/classify/intmatcher.h +199 -0
- data/vendor/tesseract-2.04/classify/intproto.cpp +1823 -0
- data/vendor/tesseract-2.04/classify/intproto.h +320 -0
- data/vendor/tesseract-2.04/classify/kdtree.cpp +884 -0
- data/vendor/tesseract-2.04/classify/kdtree.h +118 -0
- data/vendor/tesseract-2.04/classify/mf.cpp +106 -0
- data/vendor/tesseract-2.04/classify/mf.h +43 -0
- data/vendor/tesseract-2.04/classify/mfdefs.cpp +58 -0
- data/vendor/tesseract-2.04/classify/mfdefs.h +60 -0
- data/vendor/tesseract-2.04/classify/mfoutline.cpp +1087 -0
- data/vendor/tesseract-2.04/classify/mfoutline.h +277 -0
- data/vendor/tesseract-2.04/classify/mfx.cpp +436 -0
- data/vendor/tesseract-2.04/classify/mfx.h +52 -0
- data/vendor/tesseract-2.04/classify/normfeat.cpp +132 -0
- data/vendor/tesseract-2.04/classify/normfeat.h +63 -0
- data/vendor/tesseract-2.04/classify/normmatch.cpp +305 -0
- data/vendor/tesseract-2.04/classify/normmatch.h +38 -0
- data/vendor/tesseract-2.04/classify/ocrfeatures.cpp +310 -0
- data/vendor/tesseract-2.04/classify/ocrfeatures.h +148 -0
- data/vendor/tesseract-2.04/classify/outfeat.cpp +262 -0
- data/vendor/tesseract-2.04/classify/outfeat.h +76 -0
- data/vendor/tesseract-2.04/classify/picofeat.cpp +297 -0
- data/vendor/tesseract-2.04/classify/picofeat.h +65 -0
- data/vendor/tesseract-2.04/classify/protos.cpp +472 -0
- data/vendor/tesseract-2.04/classify/protos.h +258 -0
- data/vendor/tesseract-2.04/classify/sigmenu.cpp +225 -0
- data/vendor/tesseract-2.04/classify/sigmenu.h +39 -0
- data/vendor/tesseract-2.04/classify/speckle.cpp +127 -0
- data/vendor/tesseract-2.04/classify/speckle.h +69 -0
- data/vendor/tesseract-2.04/classify/xform2d.cpp +120 -0
- data/vendor/tesseract-2.04/classify/xform2d.h +60 -0
- data/vendor/tesseract-2.04/config/config.guess +1466 -0
- data/vendor/tesseract-2.04/config/config.h.in +188 -0
- data/vendor/tesseract-2.04/config/config.sub +1579 -0
- data/vendor/tesseract-2.04/config/depcomp +530 -0
- data/vendor/tesseract-2.04/config/install-sh +269 -0
- data/vendor/tesseract-2.04/config/missing +198 -0
- data/vendor/tesseract-2.04/config/mkinstalldirs +40 -0
- data/vendor/tesseract-2.04/config/stamp-h.in +0 -0
- data/vendor/tesseract-2.04/configure +10424 -0
- data/vendor/tesseract-2.04/cutil/Makefile.am +14 -0
- data/vendor/tesseract-2.04/cutil/Makefile.in +612 -0
- data/vendor/tesseract-2.04/cutil/bitvec.cpp +115 -0
- data/vendor/tesseract-2.04/cutil/bitvec.h +100 -0
- data/vendor/tesseract-2.04/cutil/callcpp.h +190 -0
- data/vendor/tesseract-2.04/cutil/const.h +108 -0
- data/vendor/tesseract-2.04/cutil/cutil.cpp +92 -0
- data/vendor/tesseract-2.04/cutil/cutil.h +159 -0
- data/vendor/tesseract-2.04/cutil/danerror.cpp +144 -0
- data/vendor/tesseract-2.04/cutil/danerror.h +41 -0
- data/vendor/tesseract-2.04/cutil/debug.cpp +97 -0
- data/vendor/tesseract-2.04/cutil/debug.h +348 -0
- data/vendor/tesseract-2.04/cutil/efio.cpp +62 -0
- data/vendor/tesseract-2.04/cutil/efio.h +32 -0
- data/vendor/tesseract-2.04/cutil/emalloc.cpp +91 -0
- data/vendor/tesseract-2.04/cutil/emalloc.h +44 -0
- data/vendor/tesseract-2.04/cutil/freelist.cpp +75 -0
- data/vendor/tesseract-2.04/cutil/freelist.h +45 -0
- data/vendor/tesseract-2.04/cutil/funcdefs.h +35 -0
- data/vendor/tesseract-2.04/cutil/general.h +33 -0
- data/vendor/tesseract-2.04/cutil/globals.cpp +69 -0
- data/vendor/tesseract-2.04/cutil/globals.h +70 -0
- data/vendor/tesseract-2.04/cutil/listio.cpp +68 -0
- data/vendor/tesseract-2.04/cutil/listio.h +43 -0
- data/vendor/tesseract-2.04/cutil/minmax.h +40 -0
- data/vendor/tesseract-2.04/cutil/oldheap.cpp +337 -0
- data/vendor/tesseract-2.04/cutil/oldheap.h +126 -0
- data/vendor/tesseract-2.04/cutil/oldlist.cpp +393 -0
- data/vendor/tesseract-2.04/cutil/oldlist.h +350 -0
- data/vendor/tesseract-2.04/cutil/structures.cpp +66 -0
- data/vendor/tesseract-2.04/cutil/structures.h +112 -0
- data/vendor/tesseract-2.04/cutil/tessarray.cpp +115 -0
- data/vendor/tesseract-2.04/cutil/tessarray.h +166 -0
- data/vendor/tesseract-2.04/cutil/tordvars.cpp +95 -0
- data/vendor/tesseract-2.04/cutil/tordvars.h +61 -0
- data/vendor/tesseract-2.04/cutil/variables.cpp +317 -0
- data/vendor/tesseract-2.04/cutil/variables.h +170 -0
- data/vendor/tesseract-2.04/dict/Makefile.am +13 -0
- data/vendor/tesseract-2.04/dict/Makefile.in +609 -0
- data/vendor/tesseract-2.04/dict/choicearr.h +96 -0
- data/vendor/tesseract-2.04/dict/choices.cpp +210 -0
- data/vendor/tesseract-2.04/dict/choices.h +241 -0
- data/vendor/tesseract-2.04/dict/context.cpp +270 -0
- data/vendor/tesseract-2.04/dict/context.h +82 -0
- data/vendor/tesseract-2.04/dict/dawg.cpp +363 -0
- data/vendor/tesseract-2.04/dict/dawg.h +394 -0
- data/vendor/tesseract-2.04/dict/hyphen.cpp +84 -0
- data/vendor/tesseract-2.04/dict/hyphen.h +125 -0
- data/vendor/tesseract-2.04/dict/lookdawg.cpp +228 -0
- data/vendor/tesseract-2.04/dict/lookdawg.h +76 -0
- data/vendor/tesseract-2.04/dict/makedawg.cpp +449 -0
- data/vendor/tesseract-2.04/dict/makedawg.h +83 -0
- data/vendor/tesseract-2.04/dict/matchdefs.h +145 -0
- data/vendor/tesseract-2.04/dict/permdawg.cpp +415 -0
- data/vendor/tesseract-2.04/dict/permdawg.h +98 -0
- data/vendor/tesseract-2.04/dict/permngram.cpp +358 -0
- data/vendor/tesseract-2.04/dict/permngram.h +33 -0
- data/vendor/tesseract-2.04/dict/permnum.cpp +522 -0
- data/vendor/tesseract-2.04/dict/permnum.h +83 -0
- data/vendor/tesseract-2.04/dict/permute.cpp +1704 -0
- data/vendor/tesseract-2.04/dict/permute.h +93 -0
- data/vendor/tesseract-2.04/dict/reduce.cpp +424 -0
- data/vendor/tesseract-2.04/dict/reduce.h +112 -0
- data/vendor/tesseract-2.04/dict/states.cpp +382 -0
- data/vendor/tesseract-2.04/dict/states.h +111 -0
- data/vendor/tesseract-2.04/dict/stopper.cpp +1458 -0
- data/vendor/tesseract-2.04/dict/stopper.h +103 -0
- data/vendor/tesseract-2.04/dict/trie.cpp +683 -0
- data/vendor/tesseract-2.04/dict/trie.h +190 -0
- data/vendor/tesseract-2.04/dlltest/Makefile.am +2 -0
- data/vendor/tesseract-2.04/dlltest/Makefile.in +388 -0
- data/vendor/tesseract-2.04/dlltest/dlltest.cpp +163 -0
- data/vendor/tesseract-2.04/dlltest/dlltest.dsp +186 -0
- data/vendor/tesseract-2.04/dlltest/dlltest.vcproj +637 -0
- data/vendor/tesseract-2.04/eurotext.tif +0 -0
- data/vendor/tesseract-2.04/image/Makefile.am +10 -0
- data/vendor/tesseract-2.04/image/Makefile.in +596 -0
- data/vendor/tesseract-2.04/image/bitstrm.cpp +157 -0
- data/vendor/tesseract-2.04/image/bitstrm.h +73 -0
- data/vendor/tesseract-2.04/image/img.h +336 -0
- data/vendor/tesseract-2.04/image/imgbmp.cpp +223 -0
- data/vendor/tesseract-2.04/image/imgbmp.h +50 -0
- data/vendor/tesseract-2.04/image/imgerrs.h +35 -0
- data/vendor/tesseract-2.04/image/imgio.cpp +321 -0
- data/vendor/tesseract-2.04/image/imgio.h +22 -0
- data/vendor/tesseract-2.04/image/imgs.cpp +1764 -0
- data/vendor/tesseract-2.04/image/imgs.h +102 -0
- data/vendor/tesseract-2.04/image/imgtiff.cpp +723 -0
- data/vendor/tesseract-2.04/image/imgtiff.h +89 -0
- data/vendor/tesseract-2.04/image/imgunpk.h +1377 -0
- data/vendor/tesseract-2.04/image/svshowim.cpp +40 -0
- data/vendor/tesseract-2.04/image/svshowim.h +25 -0
- data/vendor/tesseract-2.04/java/Makefile.am +4 -0
- data/vendor/tesseract-2.04/java/Makefile.in +473 -0
- data/vendor/tesseract-2.04/java/com/Makefile.am +1 -0
- data/vendor/tesseract-2.04/java/com/Makefile.in +470 -0
- data/vendor/tesseract-2.04/java/com/google/Makefile.am +1 -0
- data/vendor/tesseract-2.04/java/com/google/Makefile.in +470 -0
- data/vendor/tesseract-2.04/java/com/google/scrollview/Makefile.am +4 -0
- data/vendor/tesseract-2.04/java/com/google/scrollview/Makefile.in +473 -0
- data/vendor/tesseract-2.04/java/com/google/scrollview/ScrollView.java +421 -0
- data/vendor/tesseract-2.04/java/com/google/scrollview/events/Makefile.am +5 -0
- data/vendor/tesseract-2.04/java/com/google/scrollview/events/Makefile.in +474 -0
- data/vendor/tesseract-2.04/java/com/google/scrollview/events/SVEvent.java +87 -0
- data/vendor/tesseract-2.04/java/com/google/scrollview/events/SVEventHandler.java +296 -0
- data/vendor/tesseract-2.04/java/com/google/scrollview/events/SVEventType.java +31 -0
- data/vendor/tesseract-2.04/java/com/google/scrollview/ui/Makefile.am +7 -0
- data/vendor/tesseract-2.04/java/com/google/scrollview/ui/Makefile.in +476 -0
- data/vendor/tesseract-2.04/java/com/google/scrollview/ui/SVAbstractMenuItem.java +58 -0
- data/vendor/tesseract-2.04/java/com/google/scrollview/ui/SVCheckboxMenuItem.java +60 -0
- data/vendor/tesseract-2.04/java/com/google/scrollview/ui/SVEmptyMenuItem.java +48 -0
- data/vendor/tesseract-2.04/java/com/google/scrollview/ui/SVImageHandler.java +228 -0
- data/vendor/tesseract-2.04/java/com/google/scrollview/ui/SVMenuBar.java +130 -0
- data/vendor/tesseract-2.04/java/com/google/scrollview/ui/SVMenuItem.java +61 -0
- data/vendor/tesseract-2.04/java/com/google/scrollview/ui/SVPopupMenu.java +142 -0
- data/vendor/tesseract-2.04/java/com/google/scrollview/ui/SVSubMenuItem.java +41 -0
- data/vendor/tesseract-2.04/java/com/google/scrollview/ui/SVWindow.java +643 -0
- data/vendor/tesseract-2.04/java/makefile +55 -0
- data/vendor/tesseract-2.04/pageseg/Makefile.am +13 -0
- data/vendor/tesseract-2.04/pageseg/Makefile.in +596 -0
- data/vendor/tesseract-2.04/pageseg/leptonica_pageseg.cpp +363 -0
- data/vendor/tesseract-2.04/pageseg/leptonica_pageseg.h +90 -0
- data/vendor/tesseract-2.04/pageseg/leptonica_pageseg_interface.cpp +82 -0
- data/vendor/tesseract-2.04/pageseg/leptonica_pageseg_interface.h +30 -0
- data/vendor/tesseract-2.04/pageseg/pageseg.cpp +170 -0
- data/vendor/tesseract-2.04/pageseg/pageseg.h +29 -0
- data/vendor/tesseract-2.04/phototest.tif +0 -0
- data/vendor/tesseract-2.04/tessdata/Makefile.am +31 -0
- data/vendor/tesseract-2.04/tessdata/Makefile.in +529 -0
- data/vendor/tesseract-2.04/tessdata/configs/Makefile.am +3 -0
- data/vendor/tesseract-2.04/tessdata/configs/Makefile.in +344 -0
- data/vendor/tesseract-2.04/tessdata/configs/api_config +1 -0
- data/vendor/tesseract-2.04/tessdata/configs/box.train +19 -0
- data/vendor/tesseract-2.04/tessdata/configs/box.train.stderr +18 -0
- data/vendor/tesseract-2.04/tessdata/configs/inter +4 -0
- data/vendor/tesseract-2.04/tessdata/configs/kannada +4 -0
- data/vendor/tesseract-2.04/tessdata/configs/makebox +1 -0
- data/vendor/tesseract-2.04/tessdata/configs/unlv +3 -0
- data/vendor/tesseract-2.04/tessdata/confsets +3 -0
- data/vendor/tesseract-2.04/tessdata/eng.DangAmbigs +39 -0
- data/vendor/tesseract-2.04/tessdata/eng.freq-dawg +0 -0
- data/vendor/tesseract-2.04/tessdata/eng.inttemp +0 -0
- data/vendor/tesseract-2.04/tessdata/eng.normproto +1247 -0
- data/vendor/tesseract-2.04/tessdata/eng.pffmtable +111 -0
- data/vendor/tesseract-2.04/tessdata/eng.unicharset +113 -0
- data/vendor/tesseract-2.04/tessdata/eng.user-words +921 -0
- data/vendor/tesseract-2.04/tessdata/eng.word-dawg +0 -0
- data/vendor/tesseract-2.04/tessdata/makedummies +8 -0
- data/vendor/tesseract-2.04/tessdata/tessconfigs/Makefile.am +3 -0
- data/vendor/tesseract-2.04/tessdata/tessconfigs/Makefile.in +344 -0
- data/vendor/tesseract-2.04/tessdata/tessconfigs/batch +2 -0
- data/vendor/tesseract-2.04/tessdata/tessconfigs/batch.nochop +2 -0
- data/vendor/tesseract-2.04/tessdata/tessconfigs/matdemo +7 -0
- data/vendor/tesseract-2.04/tessdata/tessconfigs/msdemo +13 -0
- data/vendor/tesseract-2.04/tessdata/tessconfigs/nobatch +2 -0
- data/vendor/tesseract-2.04/tessdata/tessconfigs/segdemo +9 -0
- data/vendor/tesseract-2.04/tessdll.cpp +351 -0
- data/vendor/tesseract-2.04/tessdll.dsp +2050 -0
- data/vendor/tesseract-2.04/tessdll.h +143 -0
- data/vendor/tesseract-2.04/tessdll.vcproj +5495 -0
- data/vendor/tesseract-2.04/tesseract.dsp +2124 -0
- data/vendor/tesseract-2.04/tesseract.dsw +116 -0
- data/vendor/tesseract-2.04/tesseract.sln +59 -0
- data/vendor/tesseract-2.04/tesseract.spec +188 -0
- data/vendor/tesseract-2.04/tesseract.vcproj +5859 -0
- data/vendor/tesseract-2.04/testing/Makefile.am +2 -0
- data/vendor/tesseract-2.04/testing/Makefile.in +312 -0
- data/vendor/tesseract-2.04/testing/README +43 -0
- data/vendor/tesseract-2.04/testing/counttestset.sh +61 -0
- data/vendor/tesseract-2.04/testing/reorgdata.sh +44 -0
- data/vendor/tesseract-2.04/testing/reports/1995.bus.3B.sum +1 -0
- data/vendor/tesseract-2.04/testing/reports/1995.doe3.3B.sum +1 -0
- data/vendor/tesseract-2.04/testing/reports/1995.mag.3B.sum +1 -0
- data/vendor/tesseract-2.04/testing/reports/1995.news.3B.sum +1 -0
- data/vendor/tesseract-2.04/testing/reports/2.03.summary +9 -0
- data/vendor/tesseract-2.04/testing/reports/2.04.summary +9 -0
- data/vendor/tesseract-2.04/testing/runalltests.sh +110 -0
- data/vendor/tesseract-2.04/testing/runtestset.sh +61 -0
- data/vendor/tesseract-2.04/textord/Makefile.am +20 -0
- data/vendor/tesseract-2.04/textord/Makefile.in +624 -0
- data/vendor/tesseract-2.04/textord/blkocc.cpp +809 -0
- data/vendor/tesseract-2.04/textord/blkocc.h +327 -0
- data/vendor/tesseract-2.04/textord/blobcmpl.h +31 -0
- data/vendor/tesseract-2.04/textord/drawedg.cpp +77 -0
- data/vendor/tesseract-2.04/textord/drawedg.h +34 -0
- data/vendor/tesseract-2.04/textord/drawtord.cpp +469 -0
- data/vendor/tesseract-2.04/textord/drawtord.h +107 -0
- data/vendor/tesseract-2.04/textord/edgblob.cpp +412 -0
- data/vendor/tesseract-2.04/textord/edgblob.h +100 -0
- data/vendor/tesseract-2.04/textord/edgloop.cpp +211 -0
- data/vendor/tesseract-2.04/textord/edgloop.h +66 -0
- data/vendor/tesseract-2.04/textord/fpchop.cpp +1641 -0
- data/vendor/tesseract-2.04/textord/fpchop.h +238 -0
- data/vendor/tesseract-2.04/textord/gap_map.cpp +166 -0
- data/vendor/tesseract-2.04/textord/gap_map.h +40 -0
- data/vendor/tesseract-2.04/textord/makerow.cpp +2628 -0
- data/vendor/tesseract-2.04/textord/makerow.h +295 -0
- data/vendor/tesseract-2.04/textord/oldbasel.cpp +1761 -0
- data/vendor/tesseract-2.04/textord/oldbasel.h +195 -0
- data/vendor/tesseract-2.04/textord/pithsync.cpp +696 -0
- data/vendor/tesseract-2.04/textord/pithsync.h +134 -0
- data/vendor/tesseract-2.04/textord/pitsync1.cpp +425 -0
- data/vendor/tesseract-2.04/textord/pitsync1.h +135 -0
- data/vendor/tesseract-2.04/textord/scanedg.cpp +452 -0
- data/vendor/tesseract-2.04/textord/scanedg.h +74 -0
- data/vendor/tesseract-2.04/textord/sortflts.cpp +80 -0
- data/vendor/tesseract-2.04/textord/sortflts.h +64 -0
- data/vendor/tesseract-2.04/textord/tessout.h +76 -0
- data/vendor/tesseract-2.04/textord/topitch.cpp +2019 -0
- data/vendor/tesseract-2.04/textord/topitch.h +195 -0
- data/vendor/tesseract-2.04/textord/tordmain.cpp +907 -0
- data/vendor/tesseract-2.04/textord/tordmain.h +132 -0
- data/vendor/tesseract-2.04/textord/tospace.cpp +1939 -0
- data/vendor/tesseract-2.04/textord/tospace.h +193 -0
- data/vendor/tesseract-2.04/textord/tovars.cpp +87 -0
- data/vendor/tesseract-2.04/textord/tovars.h +94 -0
- data/vendor/tesseract-2.04/textord/underlin.cpp +312 -0
- data/vendor/tesseract-2.04/textord/underlin.h +53 -0
- data/vendor/tesseract-2.04/textord/wordseg.cpp +620 -0
- data/vendor/tesseract-2.04/textord/wordseg.h +70 -0
- data/vendor/tesseract-2.04/training/Makefile.am +54 -0
- data/vendor/tesseract-2.04/training/Makefile.in +720 -0
- data/vendor/tesseract-2.04/training/cnTraining.cpp +855 -0
- data/vendor/tesseract-2.04/training/cntraining.dsp +243 -0
- data/vendor/tesseract-2.04/training/cntraining.vcproj +950 -0
- data/vendor/tesseract-2.04/training/mergenf.cpp +451 -0
- data/vendor/tesseract-2.04/training/mergenf.h +106 -0
- data/vendor/tesseract-2.04/training/mfTraining.cpp +1341 -0
- data/vendor/tesseract-2.04/training/mftraining.dsp +285 -0
- data/vendor/tesseract-2.04/training/mftraining.vcproj +1055 -0
- data/vendor/tesseract-2.04/training/name2char.cpp +166 -0
- data/vendor/tesseract-2.04/training/name2char.h +38 -0
- data/vendor/tesseract-2.04/training/training.cpp +190 -0
- data/vendor/tesseract-2.04/training/training.h +130 -0
- data/vendor/tesseract-2.04/training/unicharset_extractor.cpp +140 -0
- data/vendor/tesseract-2.04/training/unicharset_extractor.dsp +335 -0
- data/vendor/tesseract-2.04/training/unicharset_extractor.vcproj +769 -0
- data/vendor/tesseract-2.04/training/wordlist2dawg.cpp +69 -0
- data/vendor/tesseract-2.04/training/wordlist2dawg.dsp +319 -0
- data/vendor/tesseract-2.04/training/wordlist2dawg.vcproj +1113 -0
- data/vendor/tesseract-2.04/viewer/Makefile.am +9 -0
- data/vendor/tesseract-2.04/viewer/Makefile.in +591 -0
- data/vendor/tesseract-2.04/viewer/scrollview.cpp +825 -0
- data/vendor/tesseract-2.04/viewer/scrollview.h +414 -0
- data/vendor/tesseract-2.04/viewer/svmnode.cpp +140 -0
- data/vendor/tesseract-2.04/viewer/svmnode.h +94 -0
- data/vendor/tesseract-2.04/viewer/svpaint.cpp +220 -0
- data/vendor/tesseract-2.04/viewer/svutil.cpp +347 -0
- data/vendor/tesseract-2.04/viewer/svutil.h +138 -0
- data/vendor/tesseract-2.04/wordrec/Makefile.am +23 -0
- data/vendor/tesseract-2.04/wordrec/Makefile.in +641 -0
- data/vendor/tesseract-2.04/wordrec/associate.cpp +62 -0
- data/vendor/tesseract-2.04/wordrec/associate.h +93 -0
- data/vendor/tesseract-2.04/wordrec/badwords.cpp +106 -0
- data/vendor/tesseract-2.04/wordrec/badwords.h +51 -0
- data/vendor/tesseract-2.04/wordrec/bestfirst.cpp +526 -0
- data/vendor/tesseract-2.04/wordrec/bestfirst.h +203 -0
- data/vendor/tesseract-2.04/wordrec/charsample.h +208 -0
- data/vendor/tesseract-2.04/wordrec/chop.cpp +458 -0
- data/vendor/tesseract-2.04/wordrec/chop.h +153 -0
- data/vendor/tesseract-2.04/wordrec/chopper.cpp +750 -0
- data/vendor/tesseract-2.04/wordrec/chopper.h +104 -0
- data/vendor/tesseract-2.04/wordrec/closed.cpp +136 -0
- data/vendor/tesseract-2.04/wordrec/closed.h +65 -0
- data/vendor/tesseract-2.04/wordrec/djmenus.cpp +118 -0
- data/vendor/tesseract-2.04/wordrec/djmenus.h +33 -0
- data/vendor/tesseract-2.04/wordrec/drawfx.cpp +92 -0
- data/vendor/tesseract-2.04/wordrec/drawfx.h +33 -0
- data/vendor/tesseract-2.04/wordrec/findseam.cpp +566 -0
- data/vendor/tesseract-2.04/wordrec/findseam.h +69 -0
- data/vendor/tesseract-2.04/wordrec/gradechop.cpp +226 -0
- data/vendor/tesseract-2.04/wordrec/gradechop.h +91 -0
- data/vendor/tesseract-2.04/wordrec/heuristic.cpp +194 -0
- data/vendor/tesseract-2.04/wordrec/heuristic.h +120 -0
- data/vendor/tesseract-2.04/wordrec/makechop.cpp +281 -0
- data/vendor/tesseract-2.04/wordrec/makechop.h +69 -0
- data/vendor/tesseract-2.04/wordrec/matchtab.cpp +191 -0
- data/vendor/tesseract-2.04/wordrec/matchtab.h +45 -0
- data/vendor/tesseract-2.04/wordrec/matrix.cpp +118 -0
- data/vendor/tesseract-2.04/wordrec/matrix.h +104 -0
- data/vendor/tesseract-2.04/wordrec/measure.h +135 -0
- data/vendor/tesseract-2.04/wordrec/metrics.cpp +363 -0
- data/vendor/tesseract-2.04/wordrec/metrics.h +130 -0
- data/vendor/tesseract-2.04/wordrec/mfvars.cpp +51 -0
- data/vendor/tesseract-2.04/wordrec/mfvars.h +27 -0
- data/vendor/tesseract-2.04/wordrec/msmenus.cpp +110 -0
- data/vendor/tesseract-2.04/wordrec/msmenus.h +45 -0
- data/vendor/tesseract-2.04/wordrec/olutil.cpp +153 -0
- data/vendor/tesseract-2.04/wordrec/olutil.h +128 -0
- data/vendor/tesseract-2.04/wordrec/outlines.cpp +172 -0
- data/vendor/tesseract-2.04/wordrec/outlines.h +148 -0
- data/vendor/tesseract-2.04/wordrec/pieces.cpp +410 -0
- data/vendor/tesseract-2.04/wordrec/pieces.h +154 -0
- data/vendor/tesseract-2.04/wordrec/plotedges.cpp +134 -0
- data/vendor/tesseract-2.04/wordrec/plotedges.h +71 -0
- data/vendor/tesseract-2.04/wordrec/plotseg.cpp +116 -0
- data/vendor/tesseract-2.04/wordrec/plotseg.h +73 -0
- data/vendor/tesseract-2.04/wordrec/render.cpp +152 -0
- data/vendor/tesseract-2.04/wordrec/render.h +58 -0
- data/vendor/tesseract-2.04/wordrec/seam.cpp +482 -0
- data/vendor/tesseract-2.04/wordrec/seam.h +136 -0
- data/vendor/tesseract-2.04/wordrec/split.cpp +182 -0
- data/vendor/tesseract-2.04/wordrec/split.h +115 -0
- data/vendor/tesseract-2.04/wordrec/tally.cpp +68 -0
- data/vendor/tesseract-2.04/wordrec/tally.h +94 -0
- data/vendor/tesseract-2.04/wordrec/tessinit.cpp +108 -0
- data/vendor/tesseract-2.04/wordrec/tessinit.h +46 -0
- data/vendor/tesseract-2.04/wordrec/tface.cpp +272 -0
- data/vendor/tesseract-2.04/wordrec/tface.h +35 -0
- data/vendor/tesseract-2.04/wordrec/wordclass.cpp +284 -0
- data/vendor/tesseract-2.04/wordrec/wordclass.h +64 -0
- metadata +708 -0
|
@@ -0,0 +1,495 @@
|
|
|
1
|
+
/**********************************************************************
|
|
2
|
+
* File: strngs.c (Formerly strings.c)
|
|
3
|
+
* Description: STRING class functions.
|
|
4
|
+
* Author: Ray Smith
|
|
5
|
+
* Created: Fri Feb 15 09:13:30 GMT 1991
|
|
6
|
+
*
|
|
7
|
+
* (C) Copyright 1991, Hewlett-Packard Ltd.
|
|
8
|
+
** Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
|
+
** you may not use this file except in compliance with the License.
|
|
10
|
+
** You may obtain a copy of the License at
|
|
11
|
+
** http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
** Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
** distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
** See the License for the specific language governing permissions and
|
|
16
|
+
** limitations under the License.
|
|
17
|
+
*
|
|
18
|
+
**********************************************************************/
|
|
19
|
+
|
|
20
|
+
#include "mfcpch.h" //precompiled headers
|
|
21
|
+
#include "tprintf.h"
|
|
22
|
+
#include "strngs.h"
|
|
23
|
+
|
|
24
|
+
/**********************************************************************
|
|
25
|
+
* DataCache for reducing initial allocations, such as the default
|
|
26
|
+
* constructor. The memory in this cache is not special, it is just
|
|
27
|
+
* held locally rather than freeing. Only blocks with the default
|
|
28
|
+
* capacity are considered for the cache.
|
|
29
|
+
*
|
|
30
|
+
* In practice it does not appear that this cache grows very big,
|
|
31
|
+
* so even 2-4 elements are probably sufficient to realize most
|
|
32
|
+
* gains.
|
|
33
|
+
*
|
|
34
|
+
* The cache is maintained globally with a global destructor to
|
|
35
|
+
* avoid memory leaks being reported on exit.
|
|
36
|
+
**********************************************************************/
|
|
37
|
+
// kDataCacheSize is cache of last n min sized buffers freed for
|
|
38
|
+
// cheap recyling
|
|
39
|
+
const int kDataCacheSize = 8; // max number of buffers cached
|
|
40
|
+
|
|
41
|
+
#if 1
|
|
42
|
+
#define CHECK_INVARIANT(s) // EMPTY
|
|
43
|
+
#else
|
|
44
|
+
static void check_used_(int len, const char *s) {
|
|
45
|
+
bool ok;
|
|
46
|
+
|
|
47
|
+
if (len == 0)
|
|
48
|
+
ok = (s == NULL);
|
|
49
|
+
else
|
|
50
|
+
ok = (len == (strlen(s) + 1));
|
|
51
|
+
|
|
52
|
+
if (!ok)
|
|
53
|
+
abort();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
#define CHECK_INVARIANT(s) check_used_(s->GetHeader()->used_, s->string())
|
|
57
|
+
#endif
|
|
58
|
+
|
|
59
|
+
// put recycled buffers into a class so we can destroy it on exit
|
|
60
|
+
class DataCache {
|
|
61
|
+
public:
|
|
62
|
+
DataCache() {
|
|
63
|
+
top_ = 0;
|
|
64
|
+
}
|
|
65
|
+
~DataCache() {
|
|
66
|
+
while (--top_ >= 0)
|
|
67
|
+
free_string((char *)stack_[top_]);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Allocate a buffer out of this cache.
|
|
71
|
+
// Returs NULL if there are no cached buffers.
|
|
72
|
+
// The buffers in the cache can be freed using string_free.
|
|
73
|
+
void* alloc() {
|
|
74
|
+
if (top_ == 0)
|
|
75
|
+
return NULL;
|
|
76
|
+
|
|
77
|
+
return stack_[--top_];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Free pointer either by caching it on the stack of pointers
|
|
81
|
+
// or freeing it with string_free if there isnt space left to cache it.
|
|
82
|
+
// s should have capacity kMinCapacity.
|
|
83
|
+
void free(void* p) {
|
|
84
|
+
if (top_ == kDataCacheSize)
|
|
85
|
+
free_string((char *)p);
|
|
86
|
+
else
|
|
87
|
+
stack_[top_++] = p;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Stack of discarded but not-yet freed pointers.
|
|
91
|
+
void* stack_[kDataCacheSize];
|
|
92
|
+
|
|
93
|
+
// Top of stack, points to element after last cached pointer
|
|
94
|
+
int top_;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
static DataCache MinCapacityDataCache;
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
/**********************************************************************
|
|
101
|
+
* STRING_HEADER provides metadata about the allocated buffer,
|
|
102
|
+
* including total capacity and how much used (strlen with '\0').
|
|
103
|
+
*
|
|
104
|
+
* The implementation hides this header at the start of the data
|
|
105
|
+
* buffer and appends the string on the end to keep sizeof(STRING)
|
|
106
|
+
* unchanged from earlier versions so serialization is not affected.
|
|
107
|
+
*
|
|
108
|
+
* The collection of MACROS provide different implementations depending
|
|
109
|
+
* on whether the string keeps track of its strlen or not so that this
|
|
110
|
+
* feature can be added in later when consumers dont modifify the string
|
|
111
|
+
**********************************************************************/
|
|
112
|
+
|
|
113
|
+
// Smallest string to allocate by default
|
|
114
|
+
const int kMinCapacity = 16;
|
|
115
|
+
|
|
116
|
+
char* STRING::AllocData(int used, int capacity) {
|
|
117
|
+
if ((capacity != kMinCapacity)
|
|
118
|
+
|| ((data_ = (STRING_HEADER *)MinCapacityDataCache.alloc()) == NULL))
|
|
119
|
+
data_ = (STRING_HEADER *)alloc_string(capacity + sizeof(STRING_HEADER));
|
|
120
|
+
|
|
121
|
+
// header is the metadata for this memory block
|
|
122
|
+
STRING_HEADER* header = GetHeader();
|
|
123
|
+
header->capacity_ = capacity;
|
|
124
|
+
header->used_ = used;
|
|
125
|
+
return GetCStr();
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
void STRING::DiscardData() {
|
|
129
|
+
STRING_HEADER* header = GetHeader();
|
|
130
|
+
if (header->capacity_ == kMinCapacity)
|
|
131
|
+
MinCapacityDataCache.free(data_);
|
|
132
|
+
else
|
|
133
|
+
free_string((char *)data_);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// This is a private method; ensure FixHeader is called (or used_ is well defined)
|
|
137
|
+
// beforehand
|
|
138
|
+
char* STRING::ensure_cstr(inT32 min_capacity) {
|
|
139
|
+
STRING_HEADER* orig_header = GetHeader();
|
|
140
|
+
if (min_capacity <= orig_header->capacity_)
|
|
141
|
+
return ((char *)this->data_) + sizeof(STRING_HEADER);
|
|
142
|
+
|
|
143
|
+
// if we are going to grow bigger, than double our existing
|
|
144
|
+
// size, but if that still is not big enough then keep the
|
|
145
|
+
// requested capacity
|
|
146
|
+
if (min_capacity < 2 * orig_header->capacity_)
|
|
147
|
+
min_capacity = 2 * orig_header->capacity_;
|
|
148
|
+
|
|
149
|
+
int alloc = sizeof(STRING_HEADER) + min_capacity;
|
|
150
|
+
STRING_HEADER* new_header = (STRING_HEADER*)(alloc_string(alloc));
|
|
151
|
+
|
|
152
|
+
memcpy(&new_header[1], GetCStr(), orig_header->used_);
|
|
153
|
+
new_header->capacity_ = min_capacity;
|
|
154
|
+
new_header->used_ = orig_header->used_;
|
|
155
|
+
|
|
156
|
+
// free old memory, then rebind to new memory
|
|
157
|
+
DiscardData();
|
|
158
|
+
data_ = new_header;
|
|
159
|
+
|
|
160
|
+
CHECK_INVARIANT(this);
|
|
161
|
+
return ((char *)data_) + sizeof(STRING_HEADER);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// This is const, but is modifying a mutable field
|
|
165
|
+
// this way it can be used on const or non-const instances.
|
|
166
|
+
void STRING::FixHeader() const {
|
|
167
|
+
const STRING_HEADER* header = GetHeader();
|
|
168
|
+
if (header->used_ < 0)
|
|
169
|
+
header->used_ = strlen(GetCStr()) + 1;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
STRING::STRING() {
|
|
174
|
+
// 0 indicates old NULL -- it doesnt even have '\0'
|
|
175
|
+
AllocData(0, kMinCapacity);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
STRING::STRING(const STRING& str) {
|
|
179
|
+
str.FixHeader();
|
|
180
|
+
const STRING_HEADER* str_header = str.GetHeader();
|
|
181
|
+
int str_used = str_header->used_;
|
|
182
|
+
char *this_cstr = AllocData(str_used, str_used);
|
|
183
|
+
memcpy(this_cstr, str.GetCStr(), str_used);
|
|
184
|
+
CHECK_INVARIANT(this);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
STRING::STRING(const char* cstr) {
|
|
188
|
+
if (cstr == NULL) {
|
|
189
|
+
AllocData(0, 0);
|
|
190
|
+
} else {
|
|
191
|
+
int len = strlen(cstr) + 1;
|
|
192
|
+
char* this_cstr = AllocData(len, len);
|
|
193
|
+
memcpy(this_cstr, cstr, len);
|
|
194
|
+
}
|
|
195
|
+
CHECK_INVARIANT(this);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
STRING::~STRING() {
|
|
199
|
+
DiscardData();
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
BOOL8 STRING::contains(const char c) const {
|
|
203
|
+
return (c != '\0') && (strchr (GetCStr(), c) != NULL);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
inT32 STRING::length() const {
|
|
207
|
+
FixHeader();
|
|
208
|
+
return GetHeader()->used_ - 1;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
const char* STRING::string() const {
|
|
212
|
+
const STRING_HEADER* header = GetHeader();
|
|
213
|
+
if (header->used_ == 0)
|
|
214
|
+
return NULL;
|
|
215
|
+
|
|
216
|
+
// mark header length unreliable because tesseract might
|
|
217
|
+
// cast away the const and mutate the string directly.
|
|
218
|
+
header->used_ = -1;
|
|
219
|
+
return GetCStr();
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/******
|
|
223
|
+
* The STRING_IS_PROTECTED interface adds additional support to migrate
|
|
224
|
+
* code that needs to modify the STRING in ways not otherwise supported
|
|
225
|
+
* without violating encapsulation.
|
|
226
|
+
*
|
|
227
|
+
* Also makes the [] operator return a const so it is immutable
|
|
228
|
+
*/
|
|
229
|
+
#if STRING_IS_PROTECTED
|
|
230
|
+
const char& STRING::operator[](inT32 index) const {
|
|
231
|
+
return GetCStr()[index];
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
void STRING::insert_range(inT32 index, const char* str, int len) {
|
|
235
|
+
// if index is outside current range, then also grow size of string
|
|
236
|
+
// to accmodate the requested range.
|
|
237
|
+
STRING_HEADER* this_header = GetHeader();
|
|
238
|
+
int used = this_header->used_;
|
|
239
|
+
if (index > used)
|
|
240
|
+
used = index;
|
|
241
|
+
|
|
242
|
+
char* this_cstr = ensure_cstr(used + len + 1);
|
|
243
|
+
if (index < used) {
|
|
244
|
+
// move existing string from index to '\0' inclusive.
|
|
245
|
+
memmove(this_cstr + index + len,
|
|
246
|
+
this_cstr + index,
|
|
247
|
+
this_header->used_ - index);
|
|
248
|
+
} else if (len > 0) {
|
|
249
|
+
// We are going to overwrite previous null terminator, so write the new one.
|
|
250
|
+
this_cstr[this_header->used_ + len - 1] = '\0';
|
|
251
|
+
|
|
252
|
+
// If the old header did not have the terminator,
|
|
253
|
+
// then we need to account for it now that we've added it.
|
|
254
|
+
// Otherwise it was already accounted for; we just moved it.
|
|
255
|
+
if (this_header->used_ == 0)
|
|
256
|
+
++this_header->used_;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// Write new string to index.
|
|
260
|
+
// The string is already terminated from the conditions above.
|
|
261
|
+
memcpy(this_cstr + index, str, len);
|
|
262
|
+
this_header->used_ += len;
|
|
263
|
+
|
|
264
|
+
CHECK_INVARIANT(this);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
void STRING::erase_range(inT32 index, int len) {
|
|
268
|
+
char* this_cstr = GetCStr();
|
|
269
|
+
STRING_HEADER* this_header = GetHeader();
|
|
270
|
+
|
|
271
|
+
memcpy(this_cstr+index, this_cstr+index+len,
|
|
272
|
+
this_header->used_ - index - len);
|
|
273
|
+
this_header->used_ -= len;
|
|
274
|
+
CHECK_INVARIANT(this);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
void STRING::truncate_at(inT32 index) {
|
|
278
|
+
char* this_cstr = ensure_cstr(index);
|
|
279
|
+
this_cstr[index] = '\0';
|
|
280
|
+
GetHeader()->used_ = index;
|
|
281
|
+
CHECK_INVARIANT(this);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
#else
|
|
285
|
+
char& STRING::operator[](inT32 index) const {
|
|
286
|
+
// Code is casting away this const and mutating the string,
|
|
287
|
+
// so mark used_ as -1 to flag it unreliable.
|
|
288
|
+
GetHeader()->used_ = -1;
|
|
289
|
+
return ((char *)GetCStr())[index];
|
|
290
|
+
}
|
|
291
|
+
#endif
|
|
292
|
+
|
|
293
|
+
BOOL8 STRING::operator==(const STRING& str) const {
|
|
294
|
+
FixHeader();
|
|
295
|
+
str.FixHeader();
|
|
296
|
+
const STRING_HEADER* str_header = str.GetHeader();
|
|
297
|
+
const STRING_HEADER* this_header = GetHeader();
|
|
298
|
+
int this_used = this_header->used_;
|
|
299
|
+
int str_used = str_header->used_;
|
|
300
|
+
|
|
301
|
+
return (this_used == str_used)
|
|
302
|
+
&& (memcmp(GetCStr(), str.GetCStr(), this_used) == 0);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
BOOL8 STRING::operator!=(const STRING& str) const {
|
|
306
|
+
FixHeader();
|
|
307
|
+
str.FixHeader();
|
|
308
|
+
const STRING_HEADER* str_header = str.GetHeader();
|
|
309
|
+
const STRING_HEADER* this_header = GetHeader();
|
|
310
|
+
int this_used = this_header->used_;
|
|
311
|
+
int str_used = str_header->used_;
|
|
312
|
+
|
|
313
|
+
return (this_used != str_used)
|
|
314
|
+
|| (memcmp(GetCStr(), str.GetCStr(), this_used) != 0);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
BOOL8 STRING::operator!=(const char* cstr) const {
|
|
318
|
+
FixHeader();
|
|
319
|
+
const STRING_HEADER* this_header = GetHeader();
|
|
320
|
+
|
|
321
|
+
if (cstr == NULL)
|
|
322
|
+
return this_header->used_ > 1; // either '\0' or NULL
|
|
323
|
+
else {
|
|
324
|
+
inT32 length = strlen(cstr) + 1;
|
|
325
|
+
return (this_header->used_ != length)
|
|
326
|
+
|| (memcmp(GetCStr(), cstr, length) != 0);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
STRING& STRING::operator=(const STRING& str) {
|
|
331
|
+
str.FixHeader();
|
|
332
|
+
const STRING_HEADER* str_header = str.GetHeader();
|
|
333
|
+
int str_used = str_header->used_;
|
|
334
|
+
|
|
335
|
+
GetHeader()->used_ = 0; // clear since ensure doesnt need to copy data
|
|
336
|
+
char* this_cstr = ensure_cstr(str_used);
|
|
337
|
+
STRING_HEADER* this_header = GetHeader();
|
|
338
|
+
|
|
339
|
+
memcpy(this_cstr, str.GetCStr(), str_used);
|
|
340
|
+
this_header->used_ = str_used;
|
|
341
|
+
|
|
342
|
+
CHECK_INVARIANT(this);
|
|
343
|
+
return *this;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
STRING & STRING::operator+=(const STRING& str) {
|
|
347
|
+
FixHeader();
|
|
348
|
+
str.FixHeader();
|
|
349
|
+
const STRING_HEADER* str_header = str.GetHeader();
|
|
350
|
+
const char* str_cstr = str.GetCStr();
|
|
351
|
+
int str_used = str_header->used_;
|
|
352
|
+
int this_used = GetHeader()->used_;
|
|
353
|
+
char* this_cstr = ensure_cstr(this_used + str_used);
|
|
354
|
+
|
|
355
|
+
STRING_HEADER* this_header = GetHeader(); // after ensure for realloc
|
|
356
|
+
|
|
357
|
+
if (this_used > 1) {
|
|
358
|
+
memcpy(this_cstr + this_used - 1, str_cstr, str_used);
|
|
359
|
+
this_header->used_ += str_used - 1; // overwrite '\0'
|
|
360
|
+
} else {
|
|
361
|
+
memcpy(this_cstr, str_cstr, str_used);
|
|
362
|
+
this_header->used_ = str_used;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
CHECK_INVARIANT(this);
|
|
366
|
+
return *this;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
void STRING::prep_serialise() {
|
|
370
|
+
// WARNING
|
|
371
|
+
// This method should only be called on a shallow bitwise copy
|
|
372
|
+
// by the serialise() method (see serialis.h).
|
|
373
|
+
FixHeader();
|
|
374
|
+
data_ = (STRING_HEADER *)GetHeader()->used_;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
void STRING::dump(FILE* f) {
|
|
379
|
+
FixHeader();
|
|
380
|
+
serialise_bytes (f, data_, GetHeader()->used_);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
void STRING::de_dump(FILE* f) {
|
|
384
|
+
char *instring; //input from read
|
|
385
|
+
fprintf(stderr, "de_dump\n");
|
|
386
|
+
instring = (char *)de_serialise_bytes(f, (ptrdiff_t)data_);
|
|
387
|
+
int len = strlen(instring) + 1;
|
|
388
|
+
|
|
389
|
+
char* this_cstr = AllocData(len, len);
|
|
390
|
+
STRING_HEADER* this_header = GetHeader();
|
|
391
|
+
|
|
392
|
+
memcpy(this_cstr, instring, len);
|
|
393
|
+
this_header->used_ = len;
|
|
394
|
+
|
|
395
|
+
free_mem(instring);
|
|
396
|
+
CHECK_INVARIANT(this);
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
|
|
400
|
+
STRING & STRING::operator=(const char* cstr) {
|
|
401
|
+
STRING_HEADER* this_header = GetHeader();
|
|
402
|
+
if (cstr) {
|
|
403
|
+
int len = strlen(cstr) + 1;
|
|
404
|
+
|
|
405
|
+
this_header->used_ = 0; // dont bother copying data if need to realloc
|
|
406
|
+
char* this_cstr = ensure_cstr(len);
|
|
407
|
+
this_header = GetHeader(); // for realloc
|
|
408
|
+
memcpy(this_cstr, cstr, len);
|
|
409
|
+
this_header->used_ = len;
|
|
410
|
+
}
|
|
411
|
+
else {
|
|
412
|
+
// Reallocate to zero capacity buffer, consistent with the corresponding
|
|
413
|
+
// copy constructor.
|
|
414
|
+
DiscardData();
|
|
415
|
+
AllocData(0, 0);
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
CHECK_INVARIANT(this);
|
|
419
|
+
return *this;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+
STRING STRING::operator+(const STRING& str) const {
|
|
424
|
+
STRING result(*this);
|
|
425
|
+
result += str;
|
|
426
|
+
|
|
427
|
+
CHECK_INVARIANT(this);
|
|
428
|
+
return result;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
|
|
432
|
+
STRING STRING::operator+(const char ch) const {
|
|
433
|
+
STRING result;
|
|
434
|
+
FixHeader();
|
|
435
|
+
const STRING_HEADER* this_header = GetHeader();
|
|
436
|
+
int this_used = this_header->used_;
|
|
437
|
+
char* result_cstr = result.ensure_cstr(this_used + 1);
|
|
438
|
+
STRING_HEADER* result_header = result.GetHeader();
|
|
439
|
+
int result_used = result_header->used_;
|
|
440
|
+
|
|
441
|
+
// copies '\0' but we'll overwrite that
|
|
442
|
+
memcpy(result_cstr, GetCStr(), this_used);
|
|
443
|
+
result_cstr[result_used] = ch; // overwrite old '\0'
|
|
444
|
+
result_cstr[result_used + 1] = '\0'; // append on '\0'
|
|
445
|
+
++result_header->used_;
|
|
446
|
+
|
|
447
|
+
CHECK_INVARIANT(this);
|
|
448
|
+
return result;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
|
|
452
|
+
STRING& STRING::operator+=(const char *str) {
|
|
453
|
+
if (!str || !*str) // empty string has no effect
|
|
454
|
+
return *this;
|
|
455
|
+
|
|
456
|
+
FixHeader();
|
|
457
|
+
int len = strlen(str) + 1;
|
|
458
|
+
int this_used = GetHeader()->used_;
|
|
459
|
+
char* this_cstr = ensure_cstr(this_used + len);
|
|
460
|
+
STRING_HEADER* this_header = GetHeader(); // after ensure for realloc
|
|
461
|
+
|
|
462
|
+
// if we had non-empty string then append overwriting old '\0'
|
|
463
|
+
// otherwise replace
|
|
464
|
+
if (this_used > 0) {
|
|
465
|
+
memcpy(this_cstr + this_used - 1, str, len);
|
|
466
|
+
this_header->used_ += len - 1;
|
|
467
|
+
} else {
|
|
468
|
+
memcpy(this_cstr, str, len);
|
|
469
|
+
this_header->used_ = len;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
CHECK_INVARIANT(this);
|
|
473
|
+
return *this;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
|
|
477
|
+
STRING& STRING::operator+=(const char ch) {
|
|
478
|
+
if (ch == '\0')
|
|
479
|
+
return *this;
|
|
480
|
+
|
|
481
|
+
FixHeader();
|
|
482
|
+
int this_used = GetHeader()->used_;
|
|
483
|
+
char* this_cstr = ensure_cstr(this_used + 1);
|
|
484
|
+
STRING_HEADER* this_header = GetHeader();
|
|
485
|
+
|
|
486
|
+
if (this_used > 0)
|
|
487
|
+
--this_used; // undo old empty null if there was one
|
|
488
|
+
|
|
489
|
+
this_cstr[this_used++] = ch; // append ch to end
|
|
490
|
+
this_cstr[this_used++] = '\0'; // append '\0' after ch
|
|
491
|
+
this_header->used_ = this_used;
|
|
492
|
+
|
|
493
|
+
CHECK_INVARIANT(this);
|
|
494
|
+
return *this;
|
|
495
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**********************************************************************
|
|
2
|
+
* File: strngs.h (Formerly strings.h)
|
|
3
|
+
* Description: STRING class definition.
|
|
4
|
+
* Author: Ray Smith
|
|
5
|
+
* Created: Fri Feb 15 09:15:01 GMT 1991
|
|
6
|
+
*
|
|
7
|
+
* (C) Copyright 1991, Hewlett-Packard Ltd.
|
|
8
|
+
** Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
|
+
** you may not use this file except in compliance with the License.
|
|
10
|
+
** You may obtain a copy of the License at
|
|
11
|
+
** http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
** Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
** distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
** See the License for the specific language governing permissions and
|
|
16
|
+
** limitations under the License.
|
|
17
|
+
*
|
|
18
|
+
**********************************************************************/
|
|
19
|
+
|
|
20
|
+
#ifndef STRNGS_H
|
|
21
|
+
#define STRNGS_H
|
|
22
|
+
|
|
23
|
+
#include <string.h>
|
|
24
|
+
#include "memry.h"
|
|
25
|
+
#include "serialis.h"
|
|
26
|
+
|
|
27
|
+
// STRING_IS_PROTECTED means that string[index] = X is invalid
|
|
28
|
+
// because you have to go through strings interface to modify it.
|
|
29
|
+
// This allows the string to ensure internal integrity and maintain
|
|
30
|
+
// its own string length. Unfortunately this is not possible because
|
|
31
|
+
// STRINGS are used as direct-manipulation data buffers for things
|
|
32
|
+
// like length arrays and many places cast away the const on string()
|
|
33
|
+
// to mutate the string. Turning this off means that internally we
|
|
34
|
+
// cannot assume we know the strlen.
|
|
35
|
+
#define STRING_IS_PROTECTED 0
|
|
36
|
+
|
|
37
|
+
class DLLSYM STRING
|
|
38
|
+
{
|
|
39
|
+
public:
|
|
40
|
+
STRING();
|
|
41
|
+
STRING(const STRING &string);
|
|
42
|
+
STRING(const char *string);
|
|
43
|
+
~STRING ();
|
|
44
|
+
|
|
45
|
+
BOOL8 contains(const char c) const;
|
|
46
|
+
inT32 length() const;
|
|
47
|
+
const char *string() const;
|
|
48
|
+
|
|
49
|
+
#if STRING_IS_PROTECTED
|
|
50
|
+
const char &operator[] (inT32 index) const;
|
|
51
|
+
// len is number of chars in s to insert starting at index in this string
|
|
52
|
+
void insert_range(inT32 index, const char*s, int len);
|
|
53
|
+
void erase_range(inT32 index, int len);
|
|
54
|
+
void truncate_at(inT32 index);
|
|
55
|
+
#else
|
|
56
|
+
char &operator[] (inT32 index) const;
|
|
57
|
+
#endif
|
|
58
|
+
|
|
59
|
+
BOOL8 operator== (const STRING & string) const;
|
|
60
|
+
BOOL8 operator!= (const STRING & string) const;
|
|
61
|
+
BOOL8 operator!= (const char *string) const;
|
|
62
|
+
|
|
63
|
+
STRING & operator= (const char *string);
|
|
64
|
+
STRING & operator= (const STRING & string);
|
|
65
|
+
|
|
66
|
+
STRING operator+ (const STRING & string) const;
|
|
67
|
+
STRING operator+ (const char ch) const;
|
|
68
|
+
|
|
69
|
+
STRING & operator+= (const char *string);
|
|
70
|
+
STRING & operator+= (const STRING & string);
|
|
71
|
+
STRING & operator+= (const char ch);
|
|
72
|
+
|
|
73
|
+
// WARNING
|
|
74
|
+
// This method leaks the underlying pointer,
|
|
75
|
+
// but that is what the original implementation did
|
|
76
|
+
void prep_serialise();
|
|
77
|
+
|
|
78
|
+
void dump(FILE *f);
|
|
79
|
+
void de_dump(FILE *f);
|
|
80
|
+
|
|
81
|
+
make_serialise (STRING)
|
|
82
|
+
|
|
83
|
+
// ensure capcaity but keep pointer encapsulated
|
|
84
|
+
inline void ensure(inT32 min_capacity) { ensure_cstr(min_capacity); }
|
|
85
|
+
|
|
86
|
+
private:
|
|
87
|
+
typedef struct STRING_HEADER {
|
|
88
|
+
// How much space was allocated in the string buffer for char data.
|
|
89
|
+
int capacity_;
|
|
90
|
+
|
|
91
|
+
// used_ is how much of the capacity is currently being used,
|
|
92
|
+
// including a '\0' terminator.
|
|
93
|
+
//
|
|
94
|
+
// If used_ is 0 then string is NULL (not even the '\0')
|
|
95
|
+
// else if used_ > 0 then it is strlen() + 1 (because it includes '\0')
|
|
96
|
+
// else strlen is >= 0 (not NULL) but needs to be computed.
|
|
97
|
+
// this condition is set when encapsulation is violated because
|
|
98
|
+
// an API returned a mutable string.
|
|
99
|
+
//
|
|
100
|
+
// capacity_ - used_ = excess capacity that the string can grow
|
|
101
|
+
// without reallocating
|
|
102
|
+
mutable int used_;
|
|
103
|
+
} STRING_HEADER;
|
|
104
|
+
|
|
105
|
+
// To preserve the behavior of the old serialization, we only have space
|
|
106
|
+
// for one pointer in this structure. So we are embedding a data structure
|
|
107
|
+
// at the start of the storage that will hold additional state variables,
|
|
108
|
+
// then storing the actual string contents immediately after.
|
|
109
|
+
STRING_HEADER* data_;
|
|
110
|
+
|
|
111
|
+
// returns the header part of the storage
|
|
112
|
+
inline STRING_HEADER* GetHeader() {
|
|
113
|
+
return data_;
|
|
114
|
+
}
|
|
115
|
+
inline const STRING_HEADER* GetHeader() const {
|
|
116
|
+
return data_;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// returns the string data part of storage
|
|
120
|
+
inline char* GetCStr() {
|
|
121
|
+
return ((char *)data_) + sizeof(STRING_HEADER);
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
inline const char* GetCStr() const {
|
|
125
|
+
return ((const char *)data_) + sizeof(STRING_HEADER);
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
// Ensure string has requested capacity as optimization
|
|
129
|
+
// to avoid unnecessary reallocations.
|
|
130
|
+
// The return value is a cstr buffer with at least requested capacity
|
|
131
|
+
char* ensure_cstr(inT32 min_capacity);
|
|
132
|
+
|
|
133
|
+
void FixHeader() const; // make used_ non-negative, even if const
|
|
134
|
+
|
|
135
|
+
char* AllocData(int used, int capacity);
|
|
136
|
+
void DiscardData();
|
|
137
|
+
};
|
|
138
|
+
#endif
|