+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-<svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://web.resource.org/cc/"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
- xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- width="770"
- height="470"
- id="svg2"
- sodipodi:version="0.32"
- inkscape:version="0.45.1"
- version="1.0"
- sodipodi:docbase="/home/kramm/c/swftools/doc"
- sodipodi:docname="pygfx.svg"
- inkscape:output_extension="org.inkscape.output.svg.inkscape"
- inkscape:export-filename="/home/kramm/c/swftools/doc/pygfx.png"
- inkscape:export-xdpi="43.200001"
- inkscape:export-ydpi="43.200001">
- <defs
- id="defs4">
- <marker
- inkscape:stockid="Arrow1Lend"
- orient="auto"
- refY="0"
- refX="0"
- id="Arrow1Lend"
- style="overflow:visible">
- <path
- id="path4141"
- d="M 0,0 L 5,-5 L -12.5,0 L 5,5 L 0,0 z "
- style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;marker-start:none"
- transform="matrix(-0.8,0,0,-0.8,-10,0)" />
- </marker>
- </defs>
- <sodipodi:namedview
- id="base"
- pagecolor="#ffffff"
- bordercolor="#666666"
- borderopacity="1.0"
- gridtolerance="10000"
- guidetolerance="10"
- objecttolerance="10"
- inkscape:pageopacity="0.0"
- inkscape:pageshadow="2"
- inkscape:zoom="0.98994949"
- inkscape:cx="323.79995"
- inkscape:cy="334.01124"
- inkscape:document-units="px"
- inkscape:current-layer="layer1"
- showgrid="true"
- inkscape:object-bbox="false"
- inkscape:grid-points="true"
- inkscape:window-width="1163"
- inkscape:window-height="893"
- inkscape:window-x="70"
- inkscape:window-y="40" />
- <metadata
- id="metadata7">
- <rdf:RDF>
- <cc:Work
- rdf:about="">
- <dc:format>image/svg+xml</dc:format>
- <dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- </cc:Work>
- </rdf:RDF>
- </metadata>
- <g
- inkscape:label="Layer 1"
- inkscape:groupmode="layer"
- id="layer1"
- transform="translate(-20,17.637817)">
- <rect
- style="fill:#c0c0c0;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect6367"
- width="770"
- height="470"
- x="20"
- y="-17.637817"
- inkscape:export-xdpi="43.200001"
- inkscape:export-ydpi="43.200001" />
- <rect
- style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:1.99999988;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect2164"
- width="338"
- height="58.857143"
- x="211"
- y="142.50505" />
- <rect
- style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:2.00000024;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect3136"
- width="118.56873"
- height="40.591553"
- x="31.000002"
- y="91.362183" />
- <rect
- style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:2.00000024;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect3138"
- width="118.56873"
- height="40.591553"
- x="31.431267"
- y="211.77063" />
- <rect
- style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:2.00000024;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect3140"
- width="118.56873"
- height="40.591553"
- x="30"
- y="151.77063" />
- <rect
- style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:2.00000024;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect3146"
- width="150.26286"
- height="39.985775"
- x="618.73712"
- y="23.362183" />
- <rect
- style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:2.00000024;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect3148"
- width="150.26286"
- height="40.591553"
- x="618.73712"
- y="82.77063" />
- <rect
- style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:2.00000024;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect3150"
- width="150.26286"
- height="40.591553"
- x="618.73712"
- y="142.77063" />
- <rect
- style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:2.00000024;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect3152"
- width="150.26286"
- height="40.591553"
- x="618.73712"
- y="202.77063" />
- <rect
- style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:2.00000024;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect3154"
- width="150.26286"
- height="40.591553"
- x="618.73712"
- y="262.77063" />
- <path
- style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;marker-end:url(#Arrow1Lend);stroke-opacity:1"
- d="M 549.5,142.86218 L 619.5,42.862183"
- id="path3156"
- sodipodi:nodetypes="cc" />
- <path
- style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;marker-end:url(#Arrow1Lend);stroke-opacity:1"
- d="M 549.5,192.86218 L 620,282.36218"
- id="path3158"
- sodipodi:nodetypes="cc" />
- <path
- style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;marker-end:url(#Arrow1Lend);stroke-opacity:1"
- d="M 549.5,152.86218 L 619.5,102.86218"
- id="path3160"
- sodipodi:nodetypes="cc" />
- <path
- style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;marker-end:url(#Arrow1Lend);stroke-opacity:1"
- d="M 550,162.36218 C 601.53996,162.36218 600,162.36218 620,162.36218"
- id="path3162"
- sodipodi:nodetypes="cc" />
- <path
- style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;marker-end:url(#Arrow1Lend);stroke-opacity:1"
- d="M 549.5,182.86218 L 620,222.36218"
- id="path3164"
- sodipodi:nodetypes="cc" />
- <text
- xml:space="preserve"
- style="font-size:20px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
- x="646.77423"
- y="53.078979"
- id="text4337"><tspan
- sodipodi:role="line"
- id="tspan4339"
- x="646.77423"
- y="53.078979">Flash</tspan></text>
- <text
- xml:space="preserve"
- style="font-size:20px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
- x="643.71698"
- y="112.00154"
- id="text4341"><tspan
- sodipodi:role="line"
- id="tspan4343"
- x="643.71698"
- y="112.00154">Bitmap</tspan></text>
- <text
- xml:space="preserve"
- style="font-size:20px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
- x="648.73712"
- y="173.36218"
- id="text4345"><tspan
- sodipodi:role="line"
- id="tspan4347"
- x="648.73712"
- y="173.36218">OCR</tspan></text>
- <text
- xml:space="preserve"
- style="font-size:20px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
- x="637.65607"
- y="231.19954"
- id="text4349"><tspan
- sodipodi:role="line"
- id="tspan4351"
- x="637.65607"
- y="231.19954">OpenGL</tspan></text>
- <text
- xml:space="preserve"
- style="font-size:20px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
- x="628.73712"
- y="293.36218"
- id="text4353"><tspan
- sodipodi:role="line"
- id="tspan4355"
- x="628.73712"
- y="293.36218">eBooks (LRF)</tspan></text>
- <text
- xml:space="preserve"
- style="font-size:20px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
- x="320"
- y="182.36218"
- id="text4357"><tspan
- sodipodi:role="line"
- id="tspan4359"
- x="320"
- y="182.36218">pygfx</tspan></text>
- <text
- xml:space="preserve"
- style="font-size:20px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
- x="50"
- y="122.36218"
- id="text4361"><tspan
- sodipodi:role="line"
- id="tspan4363"
- x="50"
- y="122.36218">PDF</tspan></text>
- <text
- xml:space="preserve"
- style="font-size:20px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
- x="50.431267"
- y="243.36218"
- id="text4365"><tspan
- sodipodi:role="line"
- id="tspan4367"
- x="50.431267"
- y="243.36218">Flash</tspan></text>
- <text
- xml:space="preserve"
- style="font-size:20px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
- x="49"
- y="183.36218"
- id="text4369"><tspan
- sodipodi:role="line"
- id="tspan4371"
- x="49"
- y="183.36218">Bitmap</tspan></text>
- <path
- style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow1Lend)"
- d="M 150,112.36218 L 210,152.36218"
- id="path4373"
- sodipodi:nodetypes="cc" />
- <path
- style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow1Lend)"
- d="M 150,172.36218 L 210,172.36218"
- id="path4375"
- sodipodi:nodetypes="cc" />
- <path
- style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow1Lend)"
- d="M 150,232.36218 L 210,192.36218"
- id="path4377"
- sodipodi:nodetypes="cc" />
- <rect
- style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:2.00000024;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect4379"
- width="259.73959"
- height="40.591553"
- x="249.26041"
- y="273.36218" />
- <text
- xml:space="preserve"
- style="font-size:20px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
- x="260"
- y="302.36218"
- id="text4381"><tspan
- sodipodi:role="line"
- id="tspan4383"
- x="260"
- y="302.36218">Hidden polygon removal</tspan></text>
- <rect
- style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect4385"
- width="260"
- height="40"
- x="248.26041"
- y="324.95374" />
- <text
- xml:space="preserve"
- style="font-size:20px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
- x="260"
- y="352.36218"
- id="text4387"><tspan
- sodipodi:role="line"
- id="tspan4389"
- x="260"
- y="352.36218">Rescaling</tspan></text>
- <rect
- style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect4391"
- width="260"
- height="40"
- x="248.26041"
- y="374.95374" />
- <text
- xml:space="preserve"
- style="font-size:20px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
- x="260"
- y="402.36218"
- id="text4397"><tspan
- sodipodi:role="line"
- id="tspan4399"
- x="260"
- y="402.36218">Rendering / Optimizing</tspan></text>
- <text
- xml:space="preserve"
- style="font-size:20px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
- x="264.45691"
- y="438.99655"
- id="text4401"><tspan
- sodipodi:role="line"
- id="tspan4403"
- x="264.45691"
- y="438.99655">...</tspan></text>
- <text
- xml:space="preserve"
- style="font-size:20px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
- x="250.98633"
- y="267.5575"
- id="text4405"><tspan
- sodipodi:role="line"
- id="tspan4407"
- x="250.98633"
- y="267.5575">Filters</tspan></text>
- <path
- style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;marker-end:url(#Arrow1Lend);stroke-opacity:1"
- d="M 520,202.36218 L 520,292.36218 L 510,292.36218"
- id="path4409"
- sodipodi:nodetypes="ccc" />
- <path
- style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;marker-end:url(#Arrow1Lend);stroke-opacity:1"
- d="M 530,202.36218 L 530,342.36218 L 510,342.36218"
- id="path4411" />
- <path
- style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;marker-end:url(#Arrow1Lend);stroke-opacity:1"
- d="M 540,202.36218 L 540,392.36218 L 510,392.36218"
- id="path4413" />
- <path
- style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;marker-end:url(#Arrow1Lend);stroke-opacity:1"
- d="M 250,292.36218 L 240,292.36218 L 240,202.36218"
- id="path5384" />
- <path
- style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;marker-end:url(#Arrow1Lend);stroke-opacity:1"
- d="M 250,342.36218 L 230,342.36218 L 230,202.36218"
- id="path5386" />
- <path
- style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;marker-end:url(#Arrow1Lend);stroke-opacity:1"
- d="M 250,392.36218 L 220,392.36218 L 220,202.36218"
- id="path5388" />
- <text
- xml:space="preserve"
- style="font-size:20px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
- x="32.324883"
- y="77.56498"
- id="text6359"><tspan
- sodipodi:role="line"
- id="tspan6361"
- x="32.324883"
- y="77.56498">Input Formats</tspan></text>
- <text
- xml:space="preserve"
- style="font-size:20px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
- x="622.25397"
- y="9.8847561"
- id="text6363"><tspan
- sodipodi:role="line"
- id="tspan6365"
- x="622.25397"
- y="9.8847561">Output Formats</tspan></text>
- </g>
-</svg>
+++ /dev/null
-static void tball(HDC hdc, double px, double py, double sx, double sy)
-{
- MoveToEx(hdc, 75.25*sx+px, -32.50*sy+py, 0);
- LineTo(hdc, 74.75*sx+px, -24.80*sy+py); LineTo(hdc, 74.95*sx+px, -3.45*sy+py); LineTo(hdc, 75.25*sx+px, -32.50*sy+py);
- LineTo(hdc, 44.85*sx+px, -104.30*sy+py); LineTo(hdc, 74.75*sx+px, -24.80*sy+py); LineTo(hdc, 17.30*sx+px, -91.80*sy+py);
- LineTo(hdc, 29.35*sx+px, -10.10*sy+py); LineTo(hdc, 74.75*sx+px, -24.80*sy+py); LineTo(hdc, 47.60*sx+px, 63.80*sy+py);
- LineTo(hdc, 74.75*sx+px, 51.10*sy+py); LineTo(hdc, 74.95*sx+px, -3.45*sy+py);
- MoveToEx(hdc, 74.75*sx+px, 51.10*sy+py, 0);
- LineTo(hdc, 29.35*sx+px, 118.75*sy+py); LineTo(hdc, -45.20*sx+px, 155.35*sy+py);
- LineTo(hdc, -127.95*sx+px, 145.10*sy+py); LineTo(hdc, -194.85*sx+px, 104.30*sy+py);
- LineTo(hdc, -225.25*sx+px, 32.50*sy+py); LineTo(hdc, -224.75*sx+px, -51.10*sy+py);
- LineTo(hdc, -179.35*sx+px, -118.75*sy+py); LineTo(hdc, -104.80*sx+px, -155.35*sy+py);
- LineTo(hdc, -22.05*sx+px, -145.10*sy+py); LineTo(hdc, 44.85*sx+px, -104.30*sy+py);
- LineTo(hdc, 17.30*sx+px, -91.80*sy+py); LineTo(hdc, -75.00*sx+px, -122.60*sy+py);
- LineTo(hdc, -45.20*sx+px, -43.70*sy+py); LineTo(hdc, 17.30*sx+px, -91.80*sy+py);
- LineTo(hdc, -22.05*sx+px, -145.10*sy+py); LineTo(hdc, -75.00*sx+px, -122.60*sy+py);
- LineTo(hdc, -104.80*sx+px, -155.35*sy+py); LineTo(hdc, -167.30*sx+px, -107.25*sy+py);
- LineTo(hdc, -75.00*sx+px, -122.60*sy+py); LineTo(hdc, -127.95*sx+px, -63.55*sy+py);
- LineTo(hdc, -45.20*sx+px, -43.70*sy+py); LineTo(hdc, 29.35*sx+px, -10.10*sy+py);
- LineTo(hdc, 47.60*sx+px, 63.80*sy+py); LineTo(hdc, -25.70*sx+px, 52.45*sy+py);
- LineTo(hdc, -25.70*sx+px, 128.45*sy+py); LineTo(hdc, 47.60*sx+px, 63.80*sy+py);
- LineTo(hdc, 29.35*sx+px, 118.75*sy+py); LineTo(hdc, -25.70*sx+px, 128.45*sy+py);
- LineTo(hdc, -45.20*sx+px, 155.35*sy+py); LineTo(hdc, -118.85*sx+px, 143.85*sy+py);
- LineTo(hdc, -127.95*sx+px, 145.10*sy+py);
- MoveToEx(hdc, -179.35*sx+px, -118.75*sy+py, 0);
- LineTo(hdc, -167.30*sx+px, -107.25*sy+py); LineTo(hdc, -127.95*sx+px, -63.55*sy+py);
- LineTo(hdc, -118.85*sx+px, 21.65*sy+py); LineTo(hdc, -45.20*sx+px, -43.70*sy+py);
- LineTo(hdc, -25.70*sx+px, 52.45*sy+py); LineTo(hdc, 29.35*sx+px, -10.10*sy+py);
- MoveToEx(hdc, -225.25*sx+px, 32.50*sy+py, 0);
- LineTo(hdc, -194.85*sx+px, -17.85*sy+py); LineTo(hdc, -224.75*sx+px, -51.10*sy+py);
- LineTo(hdc, -167.30*sx+px, -107.25*sy+py); LineTo(hdc, -194.85*sx+px, -17.85*sy+py);
- LineTo(hdc, -127.95*sx+px, -63.55*sy+py);
- MoveToEx(hdc, -175.85*sx+px, 77.60*sy+py, 0);
- LineTo(hdc, -96.35*sx+px, 99.55*sy+py); LineTo(hdc, -118.85*sx+px, 21.65*sy+py);
- LineTo(hdc, -175.85*sx+px, 77.60*sy+py); LineTo(hdc, -225.25*sx+px, 32.50*sy+py);
- MoveToEx(hdc, -118.85*sx+px, 143.85*sy+py, 0);
- LineTo(hdc, -175.85*sx+px, 77.60*sy+py); LineTo(hdc, -194.85*sx+px, 104.30*sy+py);
- LineTo(hdc, -118.85*sx+px, 143.85*sy+py); LineTo(hdc, -96.35*sx+px, 99.55*sy+py);
- LineTo(hdc, -25.70*sx+px, 52.45*sy+py); LineTo(hdc, -118.85*sx+px, 21.65*sy+py);
- LineTo(hdc, -194.85*sx+px, -17.85*sy+py); LineTo(hdc, -175.85*sx+px, 77.60*sy+py);
- MoveToEx(hdc, -96.35*sx+px, 99.55*sy+py, 0);
- LineTo(hdc, -25.70*sx+px, 128.45*sy+py); LineTo(hdc, -118.85*sx+px, 143.85*sy+py);
-}
-
-static HWND wnd_background = 0;
-LRESULT CALLBACK WindowFunc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
-{
- if(message == WM_CREATE) {
- CREATESTRUCT*cs = ((LPCREATESTRUCT)lParam);
- if(cs->lpCreateParams && !strcmp((char*)cs->lpCreateParams, "background")) {
- wnd_background = hwnd;
- }
- }
- if(hwnd == wnd_background && message == WM_PAINT) {
- HDC hdc;
- PAINTSTRUCT ps;
- RECT rc;
- GetWindowRect(hwnd, &rc);
- int width = rc.right - rc.left;
- int height = rc.bottom - rc.top;
-
- hdc = BeginPaint(hwnd, &ps);
- SetBkMode(hdc, TRANSPARENT);
-
- double s = width / 1282.0;
-
- HPEN pen0 = CreatePen(PS_SOLID, 2, RGB(0, 32, 128));
- HPEN oldPen = (HPEN)SelectObject(hdc, pen0);
- tball(hdc, 0.7*width,0.2*height,s,s);
-
- HPEN pen1 = CreatePen(PS_SOLID, 2, RGB(0, 48, 128));
- (HPEN)SelectObject(hdc, pen1);
- tball(hdc, 0.233*width,0.3*height,s*2,s*2);
-
- HPEN pen2 = CreatePen(PS_SOLID, 2, RGB(0, 64, 128));
- (HPEN)SelectObject(hdc, pen2);
- tball(hdc, width, 1.2*height,s*3,-s*3);
-
- SelectObject(hdc, oldPen);
- DeleteObject(pen1);
- DeleteObject(pen2);
- EndPaint(hwnd, &ps);
- return 1;
- }
- return DefWindowProc(hwnd, message, wParam, lParam);
-}
-
-
+++ /dev/null
-char*license_text =
-"\r\n"
-" GNU GENERAL PUBLIC LICENSE\r\n"
-" Version 2, June 1991\r\n"
-"\r\n"
-" Copyright (C) 1989, 1991 Free Software Foundation, Inc.\r\n"
-" 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r\n"
-" Everyone is permitted to copy and distribute verbatim copies\r\n"
-" of this license document, but changing it is not allowed.\r\n"
-"\r\n"
-" Preamble\r\n"
-"\r\n"
-" The licenses for most software are designed to take away your\r\n"
-"freedom to share and change it. By contrast, the GNU General Public\r\n"
-"License is intended to guarantee your freedom to share and change free\r\n"
-"software--to make sure the software is free for all its users. This\r\n"
-"General Public License applies to most of the Free Software\r\n"
-"Foundation's software and to any other program whose authors commit to\r\n"
-"using it. (Some other Free Software Foundation software is covered by\r\n"
-"the GNU Library General Public License instead.) You can apply it to\r\n"
-"your programs, too.\r\n"
-"\r\n"
-" When we speak of free software, we are referring to freedom, not\r\n"
-"price. Our General Public Licenses are designed to make sure that you\r\n"
-"have the freedom to distribute copies of free software (and charge for\r\n"
-"this service if you wish), that you receive source code or can get it\r\n"
-"if you want it, that you can change the software or use pieces of it\r\n"
-"in new free programs; and that you know you can do these things.\r\n"
-"\r\n"
-" To protect your rights, we need to make restrictions that forbid\r\n"
-"anyone to deny you these rights or to ask you to surrender the rights.\r\n"
-"These restrictions translate to certain responsibilities for you if you\r\n"
-"distribute copies of the software, or if you modify it.\r\n"
-"\r\n"
-" For example, if you distribute copies of such a program, whether\r\n"
-"gratis or for a fee, you must give the recipients all the rights that\r\n"
-"you have. You must make sure that they, too, receive or can get the\r\n"
-"source code. And you must show them these terms so they know their\r\n"
-"rights.\r\n"
-"\r\n"
-" We protect your rights with two steps: (1) copyright the software, and\r\n"
-"(2) offer you this license which gives you legal permission to copy,\r\n"
-"distribute and/or modify the software.\r\n"
-"\r\n"
-" Also, for each author's protection and ours, we want to make certain\r\n"
-"that everyone understands that there is no warranty for this free\r\n"
-"software. If the software is modified by someone else and passed on, we\r\n"
-"want its recipients to know that what they have is not the original, so\r\n"
-"that any problems introduced by others will not reflect on the original\r\n"
-"authors' reputations.\r\n"
-"\r\n"
-" Finally, any free program is threatened constantly by software\r\n"
-"patents. We wish to avoid the danger that redistributors of a free\r\n"
-"program will individually obtain patent licenses, in effect making the\r\n"
-"program proprietary. To prevent this, we have made it clear that any\r\n"
-"patent must be licensed for everyone's free use or not licensed at all.\r\n"
-"\r\n"
-" The precise terms and conditions for copying, distribution and\r\n"
-"modification follow.\r\n"
-"\f\r\n"
-" GNU GENERAL PUBLIC LICENSE\r\n"
-" TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\r\n"
-"\r\n"
-" 0. This License applies to any program or other work which contains\r\n"
-"a notice placed by the copyright holder saying it may be distributed\r\n"
-"under the terms of this General Public License. The \"Program\", below,\r\n"
-"refers to any such program or work, and a \"work based on the Program\"\r\n"
-"means either the Program or any derivative work under copyright law:\r\n"
-"that is to say, a work containing the Program or a portion of it,\r\n"
-"either verbatim or with modifications and/or translated into another\r\n"
-"language. (Hereinafter, translation is included without limitation in\r\n"
-"the term \"modification\".) Each licensee is addressed as \"you\".\r\n"
-"\r\n"
-"Activities other than copying, distribution and modification are not\r\n"
-"covered by this License; they are outside its scope. The act of\r\n"
-"running the Program is not restricted, and the output from the Program\r\n"
-"is covered only if its contents constitute a work based on the\r\n"
-"Program (independent of having been made by running the Program).\r\n"
-"Whether that is true depends on what the Program does.\r\n"
-"\r\n"
-" 1. You may copy and distribute verbatim copies of the Program's\r\n"
-"source code as you receive it, in any medium, provided that you\r\n"
-"conspicuously and appropriately publish on each copy an appropriate\r\n"
-"copyright notice and disclaimer of warranty; keep intact all the\r\n"
-"notices that refer to this License and to the absence of any warranty;\r\n"
-"and give any other recipients of the Program a copy of this License\r\n"
-"along with the Program.\r\n"
-"\r\n"
-"You may charge a fee for the physical act of transferring a copy, and\r\n"
-"you may at your option offer warranty protection in exchange for a fee.\r\n"
-"\r\n"
-" 2. You may modify your copy or copies of the Program or any portion\r\n"
-"of it, thus forming a work based on the Program, and copy and\r\n"
-"distribute such modifications or work under the terms of Section 1\r\n"
-"above, provided that you also meet all of these conditions:\r\n"
-"\r\n"
-" a) You must cause the modified files to carry prominent notices\r\n"
-" stating that you changed the files and the date of any change.\r\n"
-"\r\n"
-" b) You must cause any work that you distribute or publish, that in\r\n"
-" whole or in part contains or is derived from the Program or any\r\n"
-" part thereof, to be licensed as a whole at no charge to all third\r\n"
-" parties under the terms of this License.\r\n"
-"\r\n"
-" c) If the modified program normally reads commands interactively\r\n"
-" when run, you must cause it, when started running for such\r\n"
-" interactive use in the most ordinary way, to print or display an\r\n"
-" announcement including an appropriate copyright notice and a\r\n"
-" notice that there is no warranty (or else, saying that you provide\r\n"
-" a warranty) and that users may redistribute the program under\r\n"
-" these conditions, and telling the user how to view a copy of this\r\n"
-" License. (Exception: if the Program itself is interactive but\r\n"
-" does not normally print such an announcement, your work based on\r\n"
-" the Program is not required to print an announcement.)\r\n"
-"\f\r\n"
-"These requirements apply to the modified work as a whole. If\r\n"
-"identifiable sections of that work are not derived from the Program,\r\n"
-"and can be reasonably considered independent and separate works in\r\n"
-"themselves, then this License, and its terms, do not apply to those\r\n"
-"sections when you distribute them as separate works. But when you\r\n"
-"distribute the same sections as part of a whole which is a work based\r\n"
-"on the Program, the distribution of the whole must be on the terms of\r\n"
-"this License, whose permissions for other licensees extend to the\r\n"
-"entire whole, and thus to each and every part regardless of who wrote it.\r\n"
-"\r\n"
-"Thus, it is not the intent of this section to claim rights or contest\r\n"
-"your rights to work written entirely by you; rather, the intent is to\r\n"
-"exercise the right to control the distribution of derivative or\r\n"
-"collective works based on the Program.\r\n"
-"\r\n"
-"In addition, mere aggregation of another work not based on the Program\r\n"
-"with the Program (or with a work based on the Program) on a volume of\r\n"
-"a storage or distribution medium does not bring the other work under\r\n"
-"the scope of this License.\r\n"
-"\r\n"
-" 3. You may copy and distribute the Program (or a work based on it,\r\n"
-"under Section 2) in object code or executable form under the terms of\r\n"
-"Sections 1 and 2 above provided that you also do one of the following:\r\n"
-"\r\n"
-" a) Accompany it with the complete corresponding machine-readable\r\n"
-" source code, which must be distributed under the terms of Sections\r\n"
-" 1 and 2 above on a medium customarily used for software interchange; or,\r\n"
-"\r\n"
-" b) Accompany it with a written offer, valid for at least three\r\n"
-" years, to give any third party, for a charge no more than your\r\n"
-" cost of physically performing source distribution, a complete\r\n"
-" machine-readable copy of the corresponding source code, to be\r\n"
-" distributed under the terms of Sections 1 and 2 above on a medium\r\n"
-" customarily used for software interchange; or,\r\n"
-"\r\n"
-" c) Accompany it with the information you received as to the offer\r\n"
-" to distribute corresponding source code. (This alternative is\r\n"
-" allowed only for noncommercial distribution and only if you\r\n"
-" received the program in object code or executable form with such\r\n"
-" an offer, in accord with Subsection b above.)\r\n"
-"\r\n"
-"The source code for a work means the preferred form of the work for\r\n"
-"making modifications to it. For an executable work, complete source\r\n"
-"code means all the source code for all modules it contains, plus any\r\n"
-"associated interface definition files, plus the scripts used to\r\n"
-"control compilation and installation of the executable. However, as a\r\n"
-"special exception, the source code distributed need not include\r\n"
-"anything that is normally distributed (in either source or binary\r\n"
-"form) with the major components (compiler, kernel, and so on) of the\r\n"
-"operating system on which the executable runs, unless that component\r\n"
-"itself accompanies the executable.\r\n"
-"\r\n"
-"If distribution of executable or object code is made by offering\r\n"
-"access to copy from a designated place, then offering equivalent\r\n"
-"access to copy the source code from the same place counts as\r\n"
-"distribution of the source code, even though third parties are not\r\n"
-"compelled to copy the source along with the object code.\r\n"
-"\f\r\n"
-" 4. You may not copy, modify, sublicense, or distribute the Program\r\n"
-"except as expressly provided under this License. Any attempt\r\n"
-"otherwise to copy, modify, sublicense or distribute the Program is\r\n"
-"void, and will automatically terminate your rights under this License.\r\n"
-"However, parties who have received copies, or rights, from you under\r\n"
-"this License will not have their licenses terminated so long as such\r\n"
-"parties remain in full compliance.\r\n"
-"\r\n"
-" 5. You are not required to accept this License, since you have not\r\n"
-"signed it. However, nothing else grants you permission to modify or\r\n"
-"distribute the Program or its derivative works. These actions are\r\n"
-"prohibited by law if you do not accept this License. Therefore, by\r\n"
-"modifying or distributing the Program (or any work based on the\r\n"
-"Program), you indicate your acceptance of this License to do so, and\r\n"
-"all its terms and conditions for copying, distributing or modifying\r\n"
-"the Program or works based on it.\r\n"
-"\r\n"
-" 6. Each time you redistribute the Program (or any work based on the\r\n"
-"Program), the recipient automatically receives a license from the\r\n"
-"original licensor to copy, distribute or modify the Program subject to\r\n"
-"these terms and conditions. You may not impose any further\r\n"
-"restrictions on the recipients' exercise of the rights granted herein.\r\n"
-"You are not responsible for enforcing compliance by third parties to\r\n"
-"this License.\r\n"
-"\r\n"
-" 7. If, as a consequence of a court judgment or allegation of patent\r\n"
-"infringement or for any other reason (not limited to patent issues),\r\n"
-"conditions are imposed on you (whether by court order, agreement or\r\n"
-"otherwise) that contradict the conditions of this License, they do not\r\n"
-"excuse you from the conditions of this License. If you cannot\r\n"
-"distribute so as to satisfy simultaneously your obligations under this\r\n"
-"License and any other pertinent obligations, then as a consequence you\r\n"
-"may not distribute the Program at all. For example, if a patent\r\n"
-"license would not permit royalty-free redistribution of the Program by\r\n"
-"all those who receive copies directly or indirectly through you, then\r\n"
-"the only way you could satisfy both it and this License would be to\r\n"
-"refrain entirely from distribution of the Program.\r\n"
-"\r\n"
-"If any portion of this section is held invalid or unenforceable under\r\n"
-"any particular circumstance, the balance of the section is intended to\r\n"
-"apply and the section as a whole is intended to apply in other\r\n"
-"circumstances.\r\n"
-"\r\n"
-"It is not the purpose of this section to induce you to infringe any\r\n"
-"patents or other property right claims or to contest validity of any\r\n"
-"such claims; this section has the sole purpose of protecting the\r\n"
-"integrity of the free software distribution system, which is\r\n"
-"implemented by public license practices. Many people have made\r\n"
-"generous contributions to the wide range of software distributed\r\n"
-"through that system in reliance on consistent application of that\r\n"
-"system; it is up to the author/donor to decide if he or she is willing\r\n"
-"to distribute software through any other system and a licensee cannot\r\n"
-"impose that choice.\r\n"
-"\r\n"
-"This section is intended to make thoroughly clear what is believed to\r\n"
-"be a consequence of the rest of this License.\r\n"
-"\f\r\n"
-" 8. If the distribution and/or use of the Program is restricted in\r\n"
-"certain countries either by patents or by copyrighted interfaces, the\r\n"
-"original copyright holder who places the Program under this License\r\n"
-"may add an explicit geographical distribution limitation excluding\r\n"
-"those countries, so that distribution is permitted only in or among\r\n"
-"countries not thus excluded. In such case, this License incorporates\r\n"
-"the limitation as if written in the body of this License.\r\n"
-"\r\n"
-" 9. The Free Software Foundation may publish revised and/or new versions\r\n"
-"of the General Public License from time to time. Such new versions will\r\n"
-"be similar in spirit to the present version, but may differ in detail to\r\n"
-"address new problems or concerns.\r\n"
-"\r\n"
-"Each version is given a distinguishing version number. If the Program\r\n"
-"specifies a version number of this License which applies to it and \"any\r\n"
-"later version\", you have the option of following the terms and conditions\r\n"
-"either of that version or of any later version published by the Free\r\n"
-"Software Foundation. If the Program does not specify a version number of\r\n"
-"this License, you may choose any version ever published by the Free Software\r\n"
-"Foundation.\r\n"
-"\r\n"
-" 10. If you wish to incorporate parts of the Program into other free\r\n"
-"programs whose distribution conditions are different, write to the author\r\n"
-"to ask for permission. For software which is copyrighted by the Free\r\n"
-"Software Foundation, write to the Free Software Foundation; we sometimes\r\n"
-"make exceptions for this. Our decision will be guided by the two goals\r\n"
-"of preserving the free status of all derivatives of our free software and\r\n"
-"of promoting the sharing and reuse of software generally.\r\n"
-"\r\n"
-" NO WARRANTY\r\n"
-"\r\n"
-" 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY\r\n"
-"FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN\r\n"
-"OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES\r\n"
-"PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED\r\n"
-"OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r\n"
-"MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS\r\n"
-"TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE\r\n"
-"PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,\r\n"
-"REPAIR OR CORRECTION.\r\n"
-"\r\n"
-" 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\r\n"
-"WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR\r\n"
-"REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,\r\n"
-"INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING\r\n"
-"OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED\r\n"
-"TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY\r\n"
-"YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER\r\n"
-"PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE\r\n"
-"POSSIBILITY OF SUCH DAMAGES.\r\n"
-"\r\n"
-" END OF TERMS AND CONDITIONS\r\n"
-"\f\r\n"
-" How to Apply These Terms to Your New Programs\r\n"
-"\r\n"
-" If you develop a new program, and you want it to be of the greatest\r\n"
-"possible use to the public, the best way to achieve this is to make it\r\n"
-"free software which everyone can redistribute and change under these terms.\r\n"
-"\r\n"
-" To do so, attach the following notices to the program. It is safest\r\n"
-"to attach them to the start of each source file to most effectively\r\n"
-"convey the exclusion of warranty; and each file should have at least\r\n"
-"the \"copyright\" line and a pointer to where the full notice is found.\r\n"
-"\r\n"
-" <one line to give the program's name and a brief idea of what it does.>\r\n"
-" Copyright (C) <year> <name of author>\r\n"
-"\r\n"
-" This program is free software; you can redistribute it and/or modify\r\n"
-" it under the terms of the GNU General Public License as published by\r\n"
-" the Free Software Foundation; either version 2 of the License, or\r\n"
-" (at your option) any later version.\r\n"
-"\r\n"
-" This program is distributed in the hope that it will be useful,\r\n"
-" but WITHOUT ANY WARRANTY; without even the implied warranty of\r\n"
-" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r\n"
-" GNU General Public License for more details.\r\n"
-"\r\n"
-" You should have received a copy of the GNU General Public License\r\n"
-" along with this program; if not, write to the Free Software\r\n"
-" Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r\n"
-"\r\n"
-"\r\n"
-"Also add information on how to contact you by electronic and paper mail.\r\n"
-"\r\n"
-"If the program is interactive, make it output a short notice like this\r\n"
-"when it starts in an interactive mode:\r\n"
-"\r\n"
-" Gnomovision version 69, Copyright (C) year name of author\r\n"
-" Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\r\n"
-" This is free software, and you are welcome to redistribute it\r\n"
-" under certain conditions; type `show c' for details.\r\n"
-"\r\n"
-"The hypothetical commands `show w' and `show c' should show the appropriate\r\n"
-"parts of the General Public License. Of course, the commands you use may\r\n"
-"be called something other than `show w' and `show c'; they could even be\r\n"
-"mouse-clicks or menu items--whatever suits your program.\r\n"
-"\r\n"
-"You should also get your employer (if you work as a programmer) or your\r\n"
-"school, if any, to sign a \"copyright disclaimer\" for the program, if\r\n"
-"necessary. Here is a sample; alter the names:\r\n"
-"\r\n"
-" Yoyodyne, Inc., hereby disclaims all copyright interest in the program\r\n"
-" `Gnomovision' (which makes passes at compilers) written by James Hacker.\r\n"
-"\r\n"
-" <signature of Ty Coon>, 1 April 1989\r\n"
-" Ty Coon, President of Vice\r\n"
-"\r\n"
-"This General Public License does not permit incorporating your program into\r\n"
-"proprietary programs. If your program is a subroutine library, you may\r\n"
-"consider it more useful to permit linking proprietary applications with the\r\n"
-"library. If this is what you want to do, use the GNU Library General\r\n"
-"Public License instead of this License.\r\n";
+++ /dev/null
-#define IDD_INSTALLDIR 1101
-#define IDD_LICENSE 1102
-#define IDD_PROGRESS 1103
-#define IDD_FINISH 1104
-#define IDD_SURE 1105
-#define IDD_EXTRAFILES 1106
-#define IDD_DEINSTALLED 1107
-
-#define IDC_ALLUSERS 1012
-#define IDC_CURRENTUSER 1013
-
-#define IDC_SPACE1 1032
-#define IDC_SPACE2 1033
-
-#define IDC_TITLE 1002
-#define IDC_LICENSE 1003
-#define IDC_FILELIST 1003
-#define IDC_BITMAP 1004
-#define IDC_PATH 1006
-#define IDC_INSTALL_PATH 1007
-#define IDC_PROGRESS 1008
-#define IDC_INFO 1009
-#define IDC_STARTMENU 1010
-#define IDC_DESKTOP 1011
-#define IDC_BROWSE 1012
-#define IDC_DELETEEXTRA 1013
-#define IDC_STATIC (-1)
+++ /dev/null
-/*
- LzmaDecode.c
- LZMA Decoder (optimized for Speed version)
-
- LZMA SDK 4.40 Copyright (c) 1999-2006 Igor Pavlov (2006-05-01)
- http://www.7-zip.org/
-
- LZMA SDK is licensed under two licenses:
- 1) GNU Lesser General Public License (GNU LGPL)
- 2) Common Public License (CPL)
- It means that you can select one of these two licenses and
- follow rules of that license.
-
- SPECIAL EXCEPTION:
- Igor Pavlov, as the author of this Code, expressly permits you to
- statically or dynamically link your Code (or bind by name) to the
- interfaces of this file without subjecting your linked Code to the
- terms of the CPL or GNU LGPL. Any modifications or additions
- to this file, however, are subject to the LGPL or CPL terms.
-*/
-
-#include <stdlib.h>
-#include <stdio.h>
-
-#include "LzmaDecode.h"
-
-#define kNumTopBits 24
-#define kTopValue ((UInt32)1 << kNumTopBits)
-
-#define kNumBitModelTotalBits 11
-#define kBitModelTotal (1 << kNumBitModelTotalBits)
-#define kNumMoveBits 5
-
-#define RC_READ_BYTE (*Buffer++)
-
-#define RC_INIT2 Code = 0; Range = 0xFFFFFFFF; \
- { int i; for(i = 0; i < 5; i++) { RC_TEST; Code = (Code << 8) | RC_READ_BYTE; }}
-
-#ifdef _LZMA_IN_CB
-
-#define RC_TEST { if (Buffer == BufferLim) \
- { SizeT size; int result = InCallback->Read(InCallback, &Buffer, &size); if (result != LZMA_RESULT_OK) return result; \
- BufferLim = Buffer + size; if (size == 0) return LZMA_RESULT_DATA_ERROR; }}
-
-#define RC_INIT Buffer = BufferLim = 0; RC_INIT2
-
-#else
-
-#define RC_TEST { if (Buffer == BufferLim) return LZMA_RESULT_DATA_ERROR; }
-
-#define RC_INIT(buffer, bufferSize) Buffer = buffer; BufferLim = buffer + bufferSize; RC_INIT2
-
-#endif
-
-#define RC_NORMALIZE if (Range < kTopValue) { RC_TEST; Range <<= 8; Code = (Code << 8) | RC_READ_BYTE; }
-
-#define IfBit0(p) RC_NORMALIZE; bound = (Range >> kNumBitModelTotalBits) * *(p); if (Code < bound)
-#define UpdateBit0(p) Range = bound; *(p) += (kBitModelTotal - *(p)) >> kNumMoveBits;
-#define UpdateBit1(p) Range -= bound; Code -= bound; *(p) -= (*(p)) >> kNumMoveBits;
-
-#define RC_GET_BIT2(p, mi, A0, A1) IfBit0(p) \
- { UpdateBit0(p); mi <<= 1; A0; } else \
- { UpdateBit1(p); mi = (mi + mi) + 1; A1; }
-
-#define RC_GET_BIT(p, mi) RC_GET_BIT2(p, mi, ; , ;)
-
-#define RangeDecoderBitTreeDecode(probs, numLevels, res) \
- { int i = numLevels; res = 1; \
- do { CProb *p = probs + res; RC_GET_BIT(p, res) } while(--i != 0); \
- res -= (1 << numLevels); }
-
-
-#define kNumPosBitsMax 4
-#define kNumPosStatesMax (1 << kNumPosBitsMax)
-
-#define kLenNumLowBits 3
-#define kLenNumLowSymbols (1 << kLenNumLowBits)
-#define kLenNumMidBits 3
-#define kLenNumMidSymbols (1 << kLenNumMidBits)
-#define kLenNumHighBits 8
-#define kLenNumHighSymbols (1 << kLenNumHighBits)
-
-#define LenChoice 0
-#define LenChoice2 (LenChoice + 1)
-#define LenLow (LenChoice2 + 1)
-#define LenMid (LenLow + (kNumPosStatesMax << kLenNumLowBits))
-#define LenHigh (LenMid + (kNumPosStatesMax << kLenNumMidBits))
-#define kNumLenProbs (LenHigh + kLenNumHighSymbols)
-
-
-#define kNumStates 12
-#define kNumLitStates 7
-
-#define kStartPosModelIndex 4
-#define kEndPosModelIndex 14
-#define kNumFullDistances (1 << (kEndPosModelIndex >> 1))
-
-#define kNumPosSlotBits 6
-#define kNumLenToPosStates 4
-
-#define kNumAlignBits 4
-#define kAlignTableSize (1 << kNumAlignBits)
-
-#define kMatchMinLen 2
-
-#define IsMatch 0
-#define IsRep (IsMatch + (kNumStates << kNumPosBitsMax))
-#define IsRepG0 (IsRep + kNumStates)
-#define IsRepG1 (IsRepG0 + kNumStates)
-#define IsRepG2 (IsRepG1 + kNumStates)
-#define IsRep0Long (IsRepG2 + kNumStates)
-#define PosSlot (IsRep0Long + (kNumStates << kNumPosBitsMax))
-#define SpecPos (PosSlot + (kNumLenToPosStates << kNumPosSlotBits))
-#define Align (SpecPos + kNumFullDistances - kEndPosModelIndex)
-#define LenCoder (Align + kAlignTableSize)
-#define RepLenCoder (LenCoder + kNumLenProbs)
-#define Literal (RepLenCoder + kNumLenProbs)
-
-#if Literal != LZMA_BASE_SIZE
-StopCompilingDueBUG
-#endif
-
-int LzmaDecodeProperties(CLzmaProperties *propsRes, const unsigned char *propsData, int size)
-{
- unsigned char prop0;
- if (size < LZMA_PROPERTIES_SIZE)
- return LZMA_RESULT_DATA_ERROR;
- prop0 = propsData[0];
- if (prop0 >= (9 * 5 * 5))
- return LZMA_RESULT_DATA_ERROR;
- {
- for (propsRes->pb = 0; prop0 >= (9 * 5); propsRes->pb++, prop0 -= (9 * 5));
- for (propsRes->lp = 0; prop0 >= 9; propsRes->lp++, prop0 -= 9);
- propsRes->lc = prop0;
- /*
- unsigned char remainder = (unsigned char)(prop0 / 9);
- propsRes->lc = prop0 % 9;
- propsRes->pb = remainder / 5;
- propsRes->lp = remainder % 5;
- */
- }
-
- #ifdef _LZMA_OUT_READ
- {
- int i;
- propsRes->DictionarySize = 0;
- for (i = 0; i < 4; i++)
- propsRes->DictionarySize += (UInt32)(propsData[1 + i]) << (i * 8);
- if (propsRes->DictionarySize == 0)
- propsRes->DictionarySize = 1;
- }
- #endif
- return LZMA_RESULT_OK;
-}
-
-#define kLzmaStreamWasFinishedId (-1)
-
-int LzmaDecode(CLzmaDecoderState *vs,
- #ifdef _LZMA_IN_CB
- ILzmaInCallback *InCallback,
- #else
- const unsigned char *inStream, SizeT inSize, SizeT *inSizeProcessed,
- #endif
- unsigned char *outStream, SizeT outSize, SizeT *outSizeProcessed)
-{
- CProb *p = vs->Probs;
- SizeT nowPos = 0;
- Byte previousByte = 0;
- UInt32 posStateMask = (1 << (vs->Properties.pb)) - 1;
- UInt32 literalPosMask = (1 << (vs->Properties.lp)) - 1;
- int lc = vs->Properties.lc;
-
- #ifdef _LZMA_OUT_READ
-
- UInt32 Range = vs->Range;
- UInt32 Code = vs->Code;
- #ifdef _LZMA_IN_CB
- const Byte *Buffer = vs->Buffer;
- const Byte *BufferLim = vs->BufferLim;
- #else
- const Byte *Buffer = inStream;
- const Byte *BufferLim = inStream + inSize;
- #endif
- int state = vs->State;
- UInt32 rep0 = vs->Reps[0], rep1 = vs->Reps[1], rep2 = vs->Reps[2], rep3 = vs->Reps[3];
- int len = vs->RemainLen;
- UInt32 globalPos = vs->GlobalPos;
- UInt32 distanceLimit = vs->DistanceLimit;
-
- Byte *dictionary = vs->Dictionary;
- UInt32 dictionarySize = vs->Properties.DictionarySize;
- UInt32 dictionaryPos = vs->DictionaryPos;
-
- Byte tempDictionary[4];
-
- #ifndef _LZMA_IN_CB
- *inSizeProcessed = 0;
- #endif
- *outSizeProcessed = 0;
- if (len == kLzmaStreamWasFinishedId)
- return LZMA_RESULT_OK;
-
- if (dictionarySize == 0)
- {
- dictionary = tempDictionary;
- dictionarySize = 1;
- tempDictionary[0] = vs->TempDictionary[0];
- }
-
- if (len == kLzmaNeedInitId)
- {
- {
- UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (lc + vs->Properties.lp));
- UInt32 i;
- for (i = 0; i < numProbs; i++)
- p[i] = kBitModelTotal >> 1;
- rep0 = rep1 = rep2 = rep3 = 1;
- state = 0;
- globalPos = 0;
- distanceLimit = 0;
- dictionaryPos = 0;
- dictionary[dictionarySize - 1] = 0;
- #ifdef _LZMA_IN_CB
- RC_INIT;
- #else
- RC_INIT(inStream, inSize);
- #endif
- }
- len = 0;
- }
- while(len != 0 && nowPos < outSize)
- {
- UInt32 pos = dictionaryPos - rep0;
- if (pos >= dictionarySize)
- pos += dictionarySize;
- outStream[nowPos++] = dictionary[dictionaryPos] = dictionary[pos];
- if (++dictionaryPos == dictionarySize)
- dictionaryPos = 0;
- len--;
- }
- if (dictionaryPos == 0)
- previousByte = dictionary[dictionarySize - 1];
- else
- previousByte = dictionary[dictionaryPos - 1];
-
- #else /* if !_LZMA_OUT_READ */
-
- int state = 0;
- UInt32 rep0 = 1, rep1 = 1, rep2 = 1, rep3 = 1;
- int len = 0;
- const Byte *Buffer;
- const Byte *BufferLim;
- UInt32 Range;
- UInt32 Code;
-
- #ifndef _LZMA_IN_CB
- *inSizeProcessed = 0;
- #endif
- *outSizeProcessed = 0;
-
- {
- UInt32 i;
- UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (lc + vs->Properties.lp));
- for (i = 0; i < numProbs; i++)
- p[i] = kBitModelTotal >> 1;
- }
-
- #ifdef _LZMA_IN_CB
- RC_INIT;
- #else
- RC_INIT(inStream, inSize);
- #endif
-
- #endif /* _LZMA_OUT_READ */
-
- while(nowPos < outSize)
- {
- CProb *prob;
- UInt32 bound;
- int posState = (int)(
- (nowPos
- #ifdef _LZMA_OUT_READ
- + globalPos
- #endif
- )
- & posStateMask);
-
- prob = p + IsMatch + (state << kNumPosBitsMax) + posState;
- IfBit0(prob)
- {
- int symbol = 1;
- UpdateBit0(prob)
- prob = p + Literal + (LZMA_LIT_SIZE *
- (((
- (nowPos
- #ifdef _LZMA_OUT_READ
- + globalPos
- #endif
- )
- & literalPosMask) << lc) + (previousByte >> (8 - lc))));
-
- if (state >= kNumLitStates)
- {
- int matchByte;
- #ifdef _LZMA_OUT_READ
- UInt32 pos = dictionaryPos - rep0;
- if (pos >= dictionarySize)
- pos += dictionarySize;
- matchByte = dictionary[pos];
- #else
- matchByte = outStream[nowPos - rep0];
- #endif
- do
- {
- int bit;
- CProb *probLit;
- matchByte <<= 1;
- bit = (matchByte & 0x100);
- probLit = prob + 0x100 + bit + symbol;
- RC_GET_BIT2(probLit, symbol, if (bit != 0) break, if (bit == 0) break)
- }
- while (symbol < 0x100);
- }
- while (symbol < 0x100)
- {
- CProb *probLit = prob + symbol;
- RC_GET_BIT(probLit, symbol)
- }
- previousByte = (Byte)symbol;
-
- outStream[nowPos++] = previousByte;
- #ifdef _LZMA_OUT_READ
- if (distanceLimit < dictionarySize)
- distanceLimit++;
-
- dictionary[dictionaryPos] = previousByte;
- if (++dictionaryPos == dictionarySize)
- dictionaryPos = 0;
- #endif
- if (state < 4) state = 0;
- else if (state < 10) state -= 3;
- else state -= 6;
- }
- else
- {
- UpdateBit1(prob);
- prob = p + IsRep + state;
- IfBit0(prob)
- {
- UpdateBit0(prob);
- rep3 = rep2;
- rep2 = rep1;
- rep1 = rep0;
- state = state < kNumLitStates ? 0 : 3;
- prob = p + LenCoder;
- }
- else
- {
- UpdateBit1(prob);
- prob = p + IsRepG0 + state;
- IfBit0(prob)
- {
- UpdateBit0(prob);
- prob = p + IsRep0Long + (state << kNumPosBitsMax) + posState;
- IfBit0(prob)
- {
- #ifdef _LZMA_OUT_READ
- UInt32 pos;
- #endif
- UpdateBit0(prob);
-
- #ifdef _LZMA_OUT_READ
- if (distanceLimit == 0)
- #else
- if (nowPos == 0)
- #endif
- {
- printf("distanceLimit == 0\n");
- return LZMA_RESULT_DATA_ERROR;
- }
-
- state = state < kNumLitStates ? 9 : 11;
- #ifdef _LZMA_OUT_READ
- pos = dictionaryPos - rep0;
- if (pos >= dictionarySize)
- pos += dictionarySize;
- previousByte = dictionary[pos];
- dictionary[dictionaryPos] = previousByte;
- if (++dictionaryPos == dictionarySize)
- dictionaryPos = 0;
- #else
- previousByte = outStream[nowPos - rep0];
- #endif
- outStream[nowPos++] = previousByte;
- #ifdef _LZMA_OUT_READ
- if (distanceLimit < dictionarySize)
- distanceLimit++;
- #endif
-
- continue;
- }
- else
- {
- UpdateBit1(prob);
- }
- }
- else
- {
- UInt32 distance;
- UpdateBit1(prob);
- prob = p + IsRepG1 + state;
- IfBit0(prob)
- {
- UpdateBit0(prob);
- distance = rep1;
- }
- else
- {
- UpdateBit1(prob);
- prob = p + IsRepG2 + state;
- IfBit0(prob)
- {
- UpdateBit0(prob);
- distance = rep2;
- }
- else
- {
- UpdateBit1(prob);
- distance = rep3;
- rep3 = rep2;
- }
- rep2 = rep1;
- }
- rep1 = rep0;
- rep0 = distance;
- }
- state = state < kNumLitStates ? 8 : 11;
- prob = p + RepLenCoder;
- }
- {
- int numBits, offset;
- CProb *probLen = prob + LenChoice;
- IfBit0(probLen)
- {
- UpdateBit0(probLen);
- probLen = prob + LenLow + (posState << kLenNumLowBits);
- offset = 0;
- numBits = kLenNumLowBits;
- }
- else
- {
- UpdateBit1(probLen);
- probLen = prob + LenChoice2;
- IfBit0(probLen)
- {
- UpdateBit0(probLen);
- probLen = prob + LenMid + (posState << kLenNumMidBits);
- offset = kLenNumLowSymbols;
- numBits = kLenNumMidBits;
- }
- else
- {
- UpdateBit1(probLen);
- probLen = prob + LenHigh;
- offset = kLenNumLowSymbols + kLenNumMidSymbols;
- numBits = kLenNumHighBits;
- }
- }
- RangeDecoderBitTreeDecode(probLen, numBits, len);
- len += offset;
- }
-
- if (state < 4)
- {
- int posSlot;
- state += kNumLitStates;
- prob = p + PosSlot +
- ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) <<
- kNumPosSlotBits);
- RangeDecoderBitTreeDecode(prob, kNumPosSlotBits, posSlot);
- if (posSlot >= kStartPosModelIndex)
- {
- int numDirectBits = ((posSlot >> 1) - 1);
- rep0 = (2 | ((UInt32)posSlot & 1));
- if (posSlot < kEndPosModelIndex)
- {
- rep0 <<= numDirectBits;
- prob = p + SpecPos + rep0 - posSlot - 1;
- }
- else
- {
- numDirectBits -= kNumAlignBits;
- do
- {
- RC_NORMALIZE
- Range >>= 1;
- rep0 <<= 1;
- if (Code >= Range)
- {
- Code -= Range;
- rep0 |= 1;
- }
- }
- while (--numDirectBits != 0);
- prob = p + Align;
- rep0 <<= kNumAlignBits;
- numDirectBits = kNumAlignBits;
- }
- {
- int i = 1;
- int mi = 1;
- do
- {
- CProb *prob3 = prob + mi;
- RC_GET_BIT2(prob3, mi, ; , rep0 |= i);
- i <<= 1;
- }
- while(--numDirectBits != 0);
- }
- }
- else
- rep0 = posSlot;
- if (++rep0 == (UInt32)(0))
- {
- /* it's for stream version */
- len = kLzmaStreamWasFinishedId;
- break;
- }
- }
-
- len += kMatchMinLen;
- #ifdef _LZMA_OUT_READ
- if (rep0 > distanceLimit)
- #else
- if (rep0 > nowPos)
- #endif
- {
- printf("rep0 %d > distanceLimit %d\n", rep0, distanceLimit);
- return LZMA_RESULT_DATA_ERROR;
- }
-
- #ifdef _LZMA_OUT_READ
- if (dictionarySize - distanceLimit > (UInt32)len)
- distanceLimit += len;
- else
- distanceLimit = dictionarySize;
- #endif
-
- do
- {
- #ifdef _LZMA_OUT_READ
- UInt32 pos = dictionaryPos - rep0;
- if (pos >= dictionarySize)
- pos += dictionarySize;
- previousByte = dictionary[pos];
- dictionary[dictionaryPos] = previousByte;
- if (++dictionaryPos == dictionarySize)
- dictionaryPos = 0;
- #else
- previousByte = outStream[nowPos - rep0];
- #endif
- len--;
- outStream[nowPos++] = previousByte;
- }
- while(len != 0 && nowPos < outSize);
- }
- }
- RC_NORMALIZE;
-
- #ifdef _LZMA_OUT_READ
- vs->Range = Range;
- vs->Code = Code;
- vs->DictionaryPos = dictionaryPos;
- vs->GlobalPos = globalPos + (UInt32)nowPos;
- vs->DistanceLimit = distanceLimit;
- vs->Reps[0] = rep0;
- vs->Reps[1] = rep1;
- vs->Reps[2] = rep2;
- vs->Reps[3] = rep3;
- vs->State = state;
- vs->RemainLen = len;
- vs->TempDictionary[0] = tempDictionary[0];
- #endif
-
- #ifdef _LZMA_IN_CB
- vs->Buffer = Buffer;
- vs->BufferLim = BufferLim;
- #else
- *inSizeProcessed = (SizeT)(Buffer - inStream);
- #endif
- *outSizeProcessed = nowPos;
- return LZMA_RESULT_OK;
-}
+++ /dev/null
-/*
- LzmaDecode.h
- LZMA Decoder interface
-
- LZMA SDK 4.40 Copyright (c) 1999-2006 Igor Pavlov (2006-05-01)
- http://www.7-zip.org/
-
- LZMA SDK is licensed under two licenses:
- 1) GNU Lesser General Public License (GNU LGPL)
- 2) Common Public License (CPL)
- It means that you can select one of these two licenses and
- follow rules of that license.
-
- SPECIAL EXCEPTION:
- Igor Pavlov, as the author of this code, expressly permits you to
- statically or dynamically link your code (or bind by name) to the
- interfaces of this file without subjecting your linked code to the
- terms of the CPL or GNU LGPL. Any modifications or additions
- to this file, however, are subject to the LGPL or CPL terms.
-*/
-
-#ifndef __LZMADECODE_H
-#define __LZMADECODE_H
-
-#include "LzmaTypes.h"
-
-/* #define _LZMA_IN_CB */
-/* Use callback for input data */
-
-#define _LZMA_OUT_READ
-/* Use read function for output data */
-
-/* #define _LZMA_PROB32 */
-/* It can increase speed on some 32-bit CPUs,
- but memory usage will be doubled in that case */
-
-/* #define _LZMA_LOC_OPT */
-/* Enable local speed optimizations inside code */
-
-#ifdef _LZMA_PROB32
-#define CProb UInt32
-#else
-#define CProb UInt16
-#endif
-
-
-#define LZMA_RESULT_OK 0
-#define LZMA_RESULT_DATA_ERROR 1
-
-#ifdef _LZMA_IN_CB
-typedef struct _ILzmaInCallback
-{
- int (*Read)(void *object, const unsigned char **buffer, SizeT *bufferSize);
-} ILzmaInCallback;
-#endif
-
-#define LZMA_BASE_SIZE 1846
-#define LZMA_LIT_SIZE 768
-
-#define LZMA_PROPERTIES_SIZE 5
-
-typedef struct _CLzmaProperties
-{
- int lc;
- int lp;
- int pb;
- #ifdef _LZMA_OUT_READ
- UInt32 DictionarySize;
- #endif
-}CLzmaProperties;
-
-int LzmaDecodeProperties(CLzmaProperties *propsRes, const unsigned char *propsData, int size);
-
-#define LzmaGetNumProbs(Properties) (LZMA_BASE_SIZE + (LZMA_LIT_SIZE << ((Properties)->lc + (Properties)->lp)))
-
-#define kLzmaNeedInitId (-2)
-
-typedef struct _CLzmaDecoderState
-{
- CLzmaProperties Properties;
- CProb *Probs;
-
- #ifdef _LZMA_IN_CB
- const unsigned char *Buffer;
- const unsigned char *BufferLim;
- #endif
-
- #ifdef _LZMA_OUT_READ
- unsigned char *Dictionary;
- UInt32 Range;
- UInt32 Code;
- UInt32 DictionaryPos;
- UInt32 GlobalPos;
- UInt32 DistanceLimit;
- UInt32 Reps[4];
- int State;
- int RemainLen;
- unsigned char TempDictionary[4];
- #endif
-} CLzmaDecoderState;
-
-#ifdef _LZMA_OUT_READ
-#define LzmaDecoderInit(vs) { (vs)->RemainLen = kLzmaNeedInitId; }
-#endif
-
-int LzmaDecode(CLzmaDecoderState *vs,
- #ifdef _LZMA_IN_CB
- ILzmaInCallback *inCallback,
- #else
- const unsigned char *inStream, SizeT inSize, SizeT *inSizeProcessed,
- #endif
- unsigned char *outStream, SizeT outSize, SizeT *outSizeProcessed);
-
-#endif
+++ /dev/null
-/*
-LzmaTypes.h
-
-Types for LZMA Decoder
-
-This file written and distributed to public domain by Igor Pavlov.
-This file is part of LZMA SDK 4.40 (2006-05-01)
-*/
-
-#ifndef __LZMATYPES_H
-#define __LZMATYPES_H
-
-#ifndef _7ZIP_BYTE_DEFINED
-#define _7ZIP_BYTE_DEFINED
-typedef unsigned char Byte;
-#endif
-
-#ifndef _7ZIP_UINT16_DEFINED
-#define _7ZIP_UINT16_DEFINED
-typedef unsigned short UInt16;
-#endif
-
-#ifndef _7ZIP_UINT32_DEFINED
-#define _7ZIP_UINT32_DEFINED
-#ifdef _LZMA_UINT32_IS_ULONG
-typedef unsigned long UInt32;
-#else
-typedef unsigned int UInt32;
-#endif
-#endif
-
-/* #define _LZMA_NO_SYSTEM_SIZE_T */
-/* You can use it, if you don't want <stddef.h> */
-
-#ifndef _7ZIP_SIZET_DEFINED
-#define _7ZIP_SIZET_DEFINED
-#ifdef _LZMA_NO_SYSTEM_SIZE_T
-typedef UInt32 SizeT;
-#else
-#include <stddef.h>
-typedef size_t SizeT;
-#endif
-#endif
-
-#endif
+++ /dev/null
-/* makegui.c
-
- Small program to set the gui flag in Win32 executables.
-
- Copyright (c) 2004 Matthias Kramm <kramm@quiss.org>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-#include <stdio.h>
-#include <stdlib.h>
-
-int main(int argn, char*argv[])
-{
- char flag = 2;
- FILE*fi = fopen(argv[1], "rb+");
- if(argn<2) {
- printf("Usage:\n");
- printf("\t%s program.exe [console]\n", argv[0]);
- return 0;
- }
- if(argn==3) {
- if(!strcmp(argv[2], "console")) {
- flag = 3;
- }
- }
-
- if(!fi) {
- perror(argv[1]);
- exit(1);
- }
- fseek(fi,220,SEEK_SET);
- if(flag == 2)
- printf("Setting Win32 GUI flag in %s\n", argv[1]);
- else if(flag == 3)
- printf("Setting Win32 Console flag in %s\n", argv[1]);
-
- fwrite(&flag, 1, 1, fi);
- fclose(fi);
- return 0;
-}
-
+++ /dev/null
-/* mkarchive.c
-
- Part of the rfx installer (Main program).
-
- Copyright (c) 2004-2008 Matthias Kramm <kramm@quiss.org>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <memory.h>
-#include <zlib.h>
-#define ZLIB_BUFFER_SIZE 16384
-
-typedef struct _writer
-{
- int (*write)(struct _writer*, void*data, int len);
- void (*finish)(struct _writer*);
- void *internal;
-} writer_t;
-
-/* ---------------------------- file writer ------------------------------- */
-
-typedef struct
-{
- FILE*fi;
-} filewrite_t;
-static int writer_filewrite_write(writer_t*w, void* data, int len)
-{
- filewrite_t * fw= (filewrite_t*)w->internal;
- return fwrite(data, len, 1, fw->fi);
-}
-static void writer_filewrite_finish(writer_t*w)
-{
- filewrite_t *mr = (filewrite_t*)w->internal;
- fclose(mr->fi);
- free(w->internal);
- memset(w, 0, sizeof(writer_t));
-}
-writer_t*writer_init_filewriter(char*filename)
-{
- writer_t*w = malloc(sizeof(writer_t));
- FILE*fi = fopen(filename, "wb");
- filewrite_t *mr = (filewrite_t *)malloc(sizeof(filewrite_t));
- mr->fi = fi;
- memset(w, 0, sizeof(writer_t));
- w->write = writer_filewrite_write;
- w->finish = writer_filewrite_finish;
- w->internal = mr;
- return w;
-}
-
-/* ---------------------------- include file filter ------------------------------- */
-
-typedef struct _ifwrite
-{
- FILE*fi;
- int bp;
- int pos;
- int last;
- char buf[1024];
- char*filename;
-} ifwrite_t;
-
-static int writer_ifwrite_write(writer_t*out, void*data, int len)
-{
- ifwrite_t*i = (ifwrite_t*)out->internal;
- FILE*fo = i->fi;
- int t;
- for(t=0;t<len;t++) {
- unsigned char c = ((unsigned char*)data)[t];
- if(i->bp>=80) {
- fprintf(fo, "\"%s\"\n", i->buf);
- i->bp = 0;
- }
- if(c<=32 || c>0x7e || c=='"' || c == '\\' || c == '%'
- || (i->last && c>='0' && c<='9')
- || (i->last && c>='a' && c<='f')
- || (i->last && c>='A' && c<='F')
- ) {
- i->bp += sprintf(i->buf+i->bp, "\\x%x",c);
- i->last = 1;
- } else {
- i->buf[i->bp] = c;
- i->buf[i->bp+1] = 0;
- i->last = 0;
- i->bp++;
- }
- i->pos++;
- }
-}
-static void writer_ifwrite_finish(writer_t*w)
-{
- ifwrite_t *i= (ifwrite_t*)w->internal;
- fprintf(i->fi, "\"%s\"\n", i->buf);
- fprintf(i->fi, ";\n");
- fprintf(i->fi, "int crndata_len = %d;\n", i->pos);
- fclose(i->fi);
- printf("wrote file %s\n", i->filename);
- free(w->internal);w->internal = 0;
-}
-
-writer_t*writer_init_includewriter(char*filename)
-{
- writer_t*w = malloc(sizeof(writer_t));
- FILE*fi = fopen(filename, "wb");
- memset(w, 0, sizeof(writer_t));
- w->write = writer_ifwrite_write;
- w->finish = writer_ifwrite_finish;
- ifwrite_t*i = (ifwrite_t *)malloc(sizeof(ifwrite_t));
- i->fi = fi;
- i->pos = 0;
- i->bp=0;
- i->last = 0;
- i->filename = filename;
- w->internal = i;
-
- fprintf(i->fi, "char* crndata =\n");
- return w;
-
-}
-
-/* ---------------------------- zlibdeflate writer -------------------------- */
-
-struct zlibdeflate_t
-{
- z_stream zs;
- writer_t*output;
- int written;
- int zwritten;
- unsigned char writebuffer[ZLIB_BUFFER_SIZE];
-};
-
-static void zlib_error(int ret, char* msg, z_stream*zs)
-{
- fprintf(stderr, "%s: zlib error (%d): last zlib error: %s\n",
- msg,
- ret,
- zs->msg?zs->msg:"unknown");
- perror("errno:");
- exit(1);
-}
-
-static int writer_zlibdeflate_write(writer_t*writer, void* data, int len)
-{
- struct zlibdeflate_t*z = (struct zlibdeflate_t*)writer->internal;
- int ret;
-
- if(!z) {
- fprintf(stderr, "zlib not initialized!\n");
- return 0;
- }
- if(!len)
- return 0;
-
- z->zs.next_in = (Bytef *)data;
- z->zs.avail_in = len;
-
- while(1) {
- ret = deflate(&z->zs, Z_NO_FLUSH);
-
- if (ret != Z_OK) zlib_error(ret, "bitio:deflate_deflate", &z->zs);
-
- if(z->zs.next_out != z->writebuffer) {
- z->zwritten += z->zs.next_out - (Bytef*)z->writebuffer;
- z->output->write(z->output, z->writebuffer, z->zs.next_out - (Bytef*)z->writebuffer);
- z->zs.next_out = z->writebuffer;
- z->zs.avail_out = ZLIB_BUFFER_SIZE;
- }
-
- if(!z->zs.avail_in) {
- break;
- }
- }
- z->written += len;
- return len;
-}
-static void writer_zlibdeflate_finish(writer_t*writer)
-{
- struct zlibdeflate_t*z = (struct zlibdeflate_t*)writer->internal;
- writer_t*output;
- int ret;
- if(!z)
- return;
- output= z->output;
- while(1) {
- ret = deflate(&z->zs, Z_FINISH);
- if (ret != Z_OK &&
- ret != Z_STREAM_END) zlib_error(ret, "bitio:deflate_finish", &z->zs);
-
- if(z->zs.next_out != z->writebuffer) {
- z->zwritten += z->zs.next_out - (Bytef*)z->writebuffer;
- z->output->write(z->output, z->writebuffer, z->zs.next_out - (Bytef*)z->writebuffer);
- z->zs.next_out = z->writebuffer;
- z->zs.avail_out = ZLIB_BUFFER_SIZE;
- }
-
- if (ret == Z_STREAM_END) {
- break;
-
- }
- }
- ret = deflateEnd(&z->zs);
- if (ret != Z_OK) zlib_error(ret, "bitio:deflate_end", &z->zs);
-
- if(z->written) {
- printf("Compression ratio: %.2f%% (%d bytes of input data, %d bytes of output data)\n",
- z->zwritten*100.0 / z->written,
- z->written, z->zwritten);
- } else {
- printf("Compression ratio: 0%% (0 bytes of input data, %d bytes of output data)\n", z->zwritten);
- }
-
- free(writer->internal);
- memset(writer, 0, sizeof(writer_t));
- output->finish(output);
-}
-writer_t*writer_init_zwriter(writer_t*output)
-{
- writer_t*w = malloc(sizeof(writer_t));
- struct zlibdeflate_t*z;
- int ret;
- memset(w, 0, sizeof(writer_t));
- z = (struct zlibdeflate_t*)malloc(sizeof(struct zlibdeflate_t));
- memset(z, 0, sizeof(struct zlibdeflate_t));
- w->internal = z;
- w->write = writer_zlibdeflate_write;
- w->finish = writer_zlibdeflate_finish;
- z->output = output;
- memset(&z->zs,0,sizeof(z_stream));
- z->zs.zalloc = Z_NULL;
- z->zs.zfree = Z_NULL;
- z->zs.opaque = Z_NULL;
- ret = deflateInit(&z->zs, 9);
- if (ret != Z_OK) zlib_error(ret, "bitio:deflate_init", &z->zs);
- z->zs.next_out = z->writebuffer;
- z->zs.avail_out = ZLIB_BUFFER_SIZE;
- z->written = 0;
- z->zwritten = 0;
- return w;
-}
-
-/* ------------------------------- main ----------- ------------------------------- */
-
-static int compare_filenames(const void*_n1, const void*_n2)
-{
- const char*s1 = *(const char**)_n1;
- const char*s2 = *(const char**)_n2;
-
- char*e1 = strrchr(s1, '.');
- char*e2 = strrchr(s2, '.');
- if(!e1 && !e2)
- return 0;
- if(e1 && !e2)
- return 1;
- if(!e1 && e2)
- return -1;
- int c = strcasecmp(e1+1,e2+1);
- if(c)
- return c;
- return strcasecmp(s1,s2);
-}
-
-int main (int argn, char*argv[])
-{
- int t;
- char buf[320];
- int num = 0;
-
- int fullsize = 0;
- for(t=1;t<argn;t++)
- {
- if(argv[t][0]!='-')
- {
- FILE*fi=fopen(argv[t],"rb");
- if(fi) {
- fseek(fi,0,SEEK_END);
- long l=ftell(fi);
- fclose(fi);
- fullsize += l;
- num++;
- }
- }
- }
-
-
-#ifdef ZLIB
- writer_t*include_writer = writer_init_includewriter("crnfiles.c");
- writer_t*zwriter = writer_init_zwriter(include_writer);
-#else //LZMA
- unlink("crnfiles.dat");
- unlink("crnfiles.7z");
- unlink("crnfiles.c");
- writer_t*zwriter = writer_init_filewriter("crnfiles.dat");
-#endif
- unsigned char n1=num;
- unsigned char n2=num>>8;
- unsigned char n3=num>>16;
- unsigned char n4=num>>24;
- zwriter->write(zwriter,&n1,1);
- zwriter->write(zwriter,&n2,1);
- zwriter->write(zwriter,&n3,1);
- zwriter->write(zwriter,&n4,1);
-
- qsort(argv+1, argn-1, sizeof(argv[0]), compare_filenames);
-
- for(t=1;t<argn;t++)
- {
- if(argv[t][0]!='-')
- {
- FILE*fi=fopen(argv[t],"rb");
- if(fi)
- {
- fseek(fi,0,SEEK_END);
- long l=ftell(fi);
- fseek(fi,0,SEEK_SET);
-
- char*buf=(char*)malloc(l);
- char*id="NUL";
- struct stat st;
- fstat(fileno(fi),&st);
- if(S_ISDIR(st.st_mode)) {id ="DIR";l=0;}
- else if(strstr(argv[t],".swf")) id="SWF";
- else if(strstr(argv[t],".gif")) id="PIC";
- else if(strstr(argv[t],".png")) id="PIC";
- else if(strstr(argv[t],".jpeg")) id="PIC";
- else if(strstr(argv[t],".jpg")) id="PIC";
- else if(strstr(argv[t],".tif")) id="PIC";
- else if(strstr(argv[t],".ico")) id="PIC";
- else if(strstr(argv[t],".c")) id="SRC";
- else if(strstr(argv[t],".cc")) id="SRC";
- else if(strstr(argv[t],".cpp")) id="SRC";
- else if(strstr(argv[t],".h")) id="SRC";
- else if(strstr(argv[t],".class")) id="CLA";
- else if(strstr(argv[t],".java")) id="SRC";
- else if(strstr(argv[t],".exe")) id="EXE";
- else if(strstr(argv[t],".ttf")) id="FON";
- else if(strstr(argv[t],".pfa")) id="FON";
- else if(strstr(argv[t],".pfb")) id="FON";
- else if(strstr(argv[t],".afm")) id="FON";
- else if(strstr(argv[t],".1")) id="DOC";
- else if(strstr(argv[t],".doc")) id="DOC";
- else if(strstr(argv[t],".txt")) id="TXT";
- else if(strstr(argv[t],".hlp")) id="DOC";
- else if(strstr(argv[t],".dll")) id="DLL";
-
- fread(buf,l,1,fi);
- zwriter->write(zwriter,id,3);
- unsigned char b1=l;
- unsigned char b2=l>>8;
- unsigned char b3=l>>16;
- unsigned char b4=l>>24;
- zwriter->write(zwriter,&b1,1);
- zwriter->write(zwriter,&b2,1);
- zwriter->write(zwriter,&b3,1);
- zwriter->write(zwriter,&b4,1);
- int sl=strlen(argv[t]);
- if(sl>255) {
- fprintf(stderr, "Error: filename %s too long\n", argv[t]);
- }
- unsigned char b = sl;
- zwriter->write(zwriter,&b,1); //write filename len
- zwriter->write(zwriter,argv[t],sl); //write filename
- zwriter->write(zwriter,buf,l); //write data
- fprintf(stderr,"[%s] %s: %d bytes written.\n", id, argv[t], l);
- fclose(fi);
- free(buf);
- }
- else
- {
- fprintf(stderr,"%s not found.\n", argv[t]);
- }
- }
- }
- char*id_end = "END";
- zwriter->write(zwriter,id_end,3);
- zwriter->finish(zwriter);
-
-#ifndef ZLIB
- if(system("do_lzma e crnfiles.dat crnfiles.7z")&0xff00) {
- perror("do_lzma");
- exit(1);
- }
- FILE*fi = fopen("crnfiles.7z", "rb");
- if(!fi) {
- perror("crnfiles.7z");
- exit(1);
- }
- writer_t*w = writer_init_includewriter("crnfiles.c");
- while(!feof(fi)) {
- char buf[4096];
- int len = fread(buf,1,4096,fi);
- if(!len)
- break;
- w->write(w, buf, len);
- }
- w->finish(w);
- fclose(fi);
- if(unlink("crnfiles.dat")) {
- perror("crnfiles.dat");
- exit(1);
- }
- if(unlink("crnfiles.7z")) {
- perror("crnfiles.7z");
- exit(1);
- }
-#endif
-
- fi = fopen("crnfiles.c", "ab+");
- fprintf(fi, "\nint crn_decompressed_size=%d;\n", fullsize);
- fclose(fi);
-
- return 0;
-}
-
+++ /dev/null
-char* concatPaths(const char*base, const char*add)
-{
- int l1 = strlen(base);
- int l2 = strlen(add);
- int pos = 0;
- char*n = 0;
- while(l1 && base[l1-1] == '\\')
- l1--;
- while(pos < l2 && add[pos] == '\\')
- pos++;
-
- n = (char*)malloc(l1 + (l2-pos) + 2);
- memcpy(n,base,l1);
- n[l1]='\\';
- strcpy(&n[l1+1],&add[pos]);
- return n;
-}
-
+++ /dev/null
-#ifndef __utils_h__
-#define __utils_h__
-char* concatPaths(const char*base, const char*add);
-#endif
+++ /dev/null
-
-#line 3 "lex.swf4.c"
-
-#define YY_INT_ALIGNED short int
-
-/* A lexical scanner generated by flex */
-
-#define FLEX_SCANNER
-#define YY_FLEX_MAJOR_VERSION 2
-#define YY_FLEX_MINOR_VERSION 5
-#define YY_FLEX_SUBMINOR_VERSION 33
-#if YY_FLEX_SUBMINOR_VERSION > 0
-#define FLEX_BETA
-#endif
-
-/* First, we deal with platform-specific or compiler-specific issues. */
-
-/* begin standard C headers. */
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <stdlib.h>
-
-/* end standard C headers. */
-
-/* flex integer type definitions */
-
-#ifndef FLEXINT_H
-#define FLEXINT_H
-
-/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
-
-#if __STDC_VERSION__ >= 199901L
-
-/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
- * if you want the limit (max/min) macros for int types.
- */
-#ifndef __STDC_LIMIT_MACROS
-#define __STDC_LIMIT_MACROS 1
-#endif
-
-#include <inttypes.h>
-typedef int8_t flex_int8_t;
-typedef uint8_t flex_uint8_t;
-typedef int16_t flex_int16_t;
-typedef uint16_t flex_uint16_t;
-typedef int32_t flex_int32_t;
-typedef uint32_t flex_uint32_t;
-#else
-typedef signed char flex_int8_t;
-typedef short int flex_int16_t;
-typedef int flex_int32_t;
-typedef unsigned char flex_uint8_t;
-typedef unsigned short int flex_uint16_t;
-typedef unsigned int flex_uint32_t;
-#endif /* ! C99 */
-
-/* Limits of integral types. */
-#ifndef INT8_MIN
-#define INT8_MIN (-128)
-#endif
-#ifndef INT16_MIN
-#define INT16_MIN (-32767-1)
-#endif
-#ifndef INT32_MIN
-#define INT32_MIN (-2147483647-1)
-#endif
-#ifndef INT8_MAX
-#define INT8_MAX (127)
-#endif
-#ifndef INT16_MAX
-#define INT16_MAX (32767)
-#endif
-#ifndef INT32_MAX
-#define INT32_MAX (2147483647)
-#endif
-#ifndef UINT8_MAX
-#define UINT8_MAX (255U)
-#endif
-#ifndef UINT16_MAX
-#define UINT16_MAX (65535U)
-#endif
-#ifndef UINT32_MAX
-#define UINT32_MAX (4294967295U)
-#endif
-
-#endif /* ! FLEXINT_H */
-
-#ifdef __cplusplus
-
-/* The "const" storage-class-modifier is valid. */
-#define YY_USE_CONST
-
-#else /* ! __cplusplus */
-
-#if __STDC__
-
-#define YY_USE_CONST
-
-#endif /* __STDC__ */
-#endif /* ! __cplusplus */
-
-#ifdef YY_USE_CONST
-#define yyconst const
-#else
-#define yyconst
-#endif
-
-/* Returned upon end-of-file. */
-#define YY_NULL 0
-
-/* Promotes a possibly negative, possibly signed char to an unsigned
- * integer for use as an array index. If the signed char is negative,
- * we want to instead treat it as an 8-bit unsigned char, hence the
- * double cast.
- */
-#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
-
-/* Enter a start condition. This macro really ought to take a parameter,
- * but we do it the disgusting crufty way forced on us by the ()-less
- * definition of BEGIN.
- */
-#define BEGIN (yy_start) = 1 + 2 *
-
-/* Translate the current start state into a value that can be later handed
- * to BEGIN to return to the state. The YYSTATE alias is for lex
- * compatibility.
- */
-#define YY_START (((yy_start) - 1) / 2)
-#define YYSTATE YY_START
-
-/* Action number for EOF rule of a given start state. */
-#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
-
-/* Special action meaning "start processing a new file". */
-#define YY_NEW_FILE swf4restart(swf4in )
-
-#define YY_END_OF_BUFFER_CHAR 0
-
-/* Size of default input buffer. */
-#ifndef YY_BUF_SIZE
-#define YY_BUF_SIZE 16384
-#endif
-
-/* The state buf must be large enough to hold one state per character in the main buffer.
- */
-#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
-
-#ifndef YY_TYPEDEF_YY_BUFFER_STATE
-#define YY_TYPEDEF_YY_BUFFER_STATE
-typedef struct yy_buffer_state *YY_BUFFER_STATE;
-#endif
-
-extern int swf4leng;
-
-extern FILE *swf4in, *swf4out;
-
-#define EOB_ACT_CONTINUE_SCAN 0
-#define EOB_ACT_END_OF_FILE 1
-#define EOB_ACT_LAST_MATCH 2
-
- #define YY_LESS_LINENO(n)
-
-/* Return all but the first "n" matched characters back to the input stream. */
-#define yyless(n) \
- do \
- { \
- /* Undo effects of setting up swf4text. */ \
- int yyless_macro_arg = (n); \
- YY_LESS_LINENO(yyless_macro_arg);\
- *yy_cp = (yy_hold_char); \
- YY_RESTORE_YY_MORE_OFFSET \
- (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
- YY_DO_BEFORE_ACTION; /* set up swf4text again */ \
- } \
- while ( 0 )
-
-#define unput(c) yyunput( c, (yytext_ptr) )
-
-/* The following is because we cannot portably get our hands on size_t
- * (without autoconf's help, which isn't available because we want
- * flex-generated scanners to compile on their own).
- */
-
-#ifndef YY_TYPEDEF_YY_SIZE_T
-#define YY_TYPEDEF_YY_SIZE_T
-typedef unsigned int yy_size_t;
-#endif
-
-#ifndef YY_STRUCT_YY_BUFFER_STATE
-#define YY_STRUCT_YY_BUFFER_STATE
-struct yy_buffer_state
- {
- FILE *yy_input_file;
-
- char *yy_ch_buf; /* input buffer */
- char *yy_buf_pos; /* current position in input buffer */
-
- /* Size of input buffer in bytes, not including room for EOB
- * characters.
- */
- yy_size_t yy_buf_size;
-
- /* Number of characters read into yy_ch_buf, not including EOB
- * characters.
- */
- int yy_n_chars;
-
- /* Whether we "own" the buffer - i.e., we know we created it,
- * and can realloc() it to grow it, and should free() it to
- * delete it.
- */
- int yy_is_our_buffer;
-
- /* Whether this is an "interactive" input source; if so, and
- * if we're using stdio for input, then we want to use getc()
- * instead of fread(), to make sure we stop fetching input after
- * each newline.
- */
- int yy_is_interactive;
-
- /* Whether we're considered to be at the beginning of a line.
- * If so, '^' rules will be active on the next match, otherwise
- * not.
- */
- int yy_at_bol;
-
- int yy_bs_lineno; /**< The line count. */
- int yy_bs_column; /**< The column count. */
-
- /* Whether to try to fill the input buffer when we reach the
- * end of it.
- */
- int yy_fill_buffer;
-
- int yy_buffer_status;
-
-#define YY_BUFFER_NEW 0
-#define YY_BUFFER_NORMAL 1
- /* When an EOF's been seen but there's still some text to process
- * then we mark the buffer as YY_EOF_PENDING, to indicate that we
- * shouldn't try reading from the input source any more. We might
- * still have a bunch of tokens to match, though, because of
- * possible backing-up.
- *
- * When we actually see the EOF, we change the status to "new"
- * (via swf4restart()), so that the user can continue scanning by
- * just pointing swf4in at a new input file.
- */
-#define YY_BUFFER_EOF_PENDING 2
-
- };
-#endif /* !YY_STRUCT_YY_BUFFER_STATE */
-
-/* Stack of input buffers. */
-static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
-static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
-static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
-
-/* We provide macros for accessing buffer states in case in the
- * future we want to put the buffer states in a more general
- * "scanner state".
- *
- * Returns the top of the stack, or NULL.
- */
-#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
- ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
- : NULL)
-
-/* Same as previous macro, but useful when we know that the buffer stack is not
- * NULL or when we need an lvalue. For internal use only.
- */
-#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
-
-/* yy_hold_char holds the character lost when swf4text is formed. */
-static char yy_hold_char;
-static int yy_n_chars; /* number of characters read into yy_ch_buf */
-int swf4leng;
-
-/* Points to current character in buffer. */
-static char *yy_c_buf_p = (char *) 0;
-static int yy_init = 0; /* whether we need to initialize */
-static int yy_start = 0; /* start state number */
-
-/* Flag which is used to allow swf4wrap()'s to do buffer switches
- * instead of setting up a fresh swf4in. A bit of a hack ...
- */
-static int yy_did_buffer_switch_on_eof;
-
-void swf4restart (FILE *input_file );
-void swf4_switch_to_buffer (YY_BUFFER_STATE new_buffer );
-YY_BUFFER_STATE swf4_create_buffer (FILE *file,int size );
-void swf4_delete_buffer (YY_BUFFER_STATE b );
-void swf4_flush_buffer (YY_BUFFER_STATE b );
-void swf4push_buffer_state (YY_BUFFER_STATE new_buffer );
-void swf4pop_buffer_state (void );
-
-static void swf4ensure_buffer_stack (void );
-static void swf4_load_buffer_state (void );
-static void swf4_init_buffer (YY_BUFFER_STATE b,FILE *file );
-
-#define YY_FLUSH_BUFFER swf4_flush_buffer(YY_CURRENT_BUFFER )
-
-YY_BUFFER_STATE swf4_scan_buffer (char *base,yy_size_t size );
-YY_BUFFER_STATE swf4_scan_string (yyconst char *yy_str );
-YY_BUFFER_STATE swf4_scan_bytes (yyconst char *bytes,int len );
-
-void *swf4alloc (yy_size_t );
-void *swf4realloc (void *,yy_size_t );
-void swf4free (void * );
-
-#define yy_new_buffer swf4_create_buffer
-
-#define yy_set_interactive(is_interactive) \
- { \
- if ( ! YY_CURRENT_BUFFER ){ \
- swf4ensure_buffer_stack (); \
- YY_CURRENT_BUFFER_LVALUE = \
- swf4_create_buffer(swf4in,YY_BUF_SIZE ); \
- } \
- YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
- }
-
-#define yy_set_bol(at_bol) \
- { \
- if ( ! YY_CURRENT_BUFFER ){\
- swf4ensure_buffer_stack (); \
- YY_CURRENT_BUFFER_LVALUE = \
- swf4_create_buffer(swf4in,YY_BUF_SIZE ); \
- } \
- YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
- }
-
-#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
-
-/* Begin user sect3 */
-
-typedef unsigned char YY_CHAR;
-
-FILE *swf4in = (FILE *) 0, *swf4out = (FILE *) 0;
-
-typedef int yy_state_type;
-
-extern int swf4lineno;
-
-int swf4lineno = 1;
-
-extern char *swf4text;
-#define yytext_ptr swf4text
-
-static yy_state_type yy_get_previous_state (void );
-static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
-static int yy_get_next_buffer (void );
-static void yy_fatal_error (yyconst char msg[] );
-
-/* Done after the current pattern has been matched and before the
- * corresponding action - sets up swf4text.
- */
-#define YY_DO_BEFORE_ACTION \
- (yytext_ptr) = yy_bp; \
- swf4leng = (size_t) (yy_cp - yy_bp); \
- (yy_hold_char) = *yy_cp; \
- *yy_cp = '\0'; \
- (yy_c_buf_p) = yy_cp;
-
-#define YY_NUM_RULES 95
-#define YY_END_OF_BUFFER 96
-/* This struct is not used in this scanner,
- but its presence is necessary. */
-struct yy_trans_info
- {
- flex_int32_t yy_verify;
- flex_int32_t yy_nxt;
- };
-static yyconst flex_int16_t yy_accept[320] =
- { 0,
- 0, 0, 96, 94, 56, 93, 94, 82, 94, 79,
- 94, 83, 84, 80, 77, 89, 78, 90, 81, 1,
- 92, 75, 59, 76, 60, 91, 85, 86, 47, 47,
- 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
- 47, 47, 47, 47, 47, 87, 94, 88, 93, 64,
- 0, 52, 50, 0, 65, 0, 53, 51, 0, 67,
- 57, 69, 58, 70, 74, 0, 54, 48, 55, 68,
- 48, 2, 1, 61, 63, 62, 0, 47, 47, 47,
- 47, 47, 11, 47, 47, 47, 47, 47, 47, 47,
- 9, 47, 47, 47, 47, 47, 47, 47, 47, 47,
-
- 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
- 47, 47, 66, 72, 48, 48, 2, 73, 71, 49,
- 49, 47, 47, 24, 47, 47, 47, 47, 8, 47,
- 33, 47, 16, 47, 47, 47, 47, 23, 47, 47,
- 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
- 47, 47, 47, 47, 47, 49, 49, 47, 47, 47,
- 47, 47, 7, 47, 47, 47, 47, 47, 47, 47,
- 47, 47, 37, 32, 47, 47, 47, 47, 47, 38,
- 47, 47, 46, 14, 47, 47, 3, 47, 47, 5,
- 47, 47, 47, 47, 4, 47, 47, 47, 47, 47,
-
- 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
- 47, 47, 47, 47, 47, 20, 47, 10, 47, 17,
- 47, 47, 47, 47, 26, 47, 47, 15, 47, 47,
- 47, 34, 47, 13, 47, 47, 47, 47, 47, 30,
- 47, 47, 47, 47, 47, 47, 47, 47, 27, 47,
- 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
- 47, 47, 12, 47, 6, 47, 47, 47, 47, 47,
- 47, 47, 47, 47, 47, 47, 47, 22, 47, 47,
- 47, 25, 47, 47, 47, 47, 41, 28, 47, 35,
- 36, 47, 44, 21, 47, 47, 47, 47, 47, 47,
-
- 47, 47, 19, 40, 45, 47, 47, 43, 31, 42,
- 47, 47, 47, 47, 47, 18, 29, 39, 0
- } ;
-
-static yyconst flex_int32_t yy_ec[256] =
- { 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
- 2, 2, 4, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 2, 5, 6, 1, 1, 1, 7, 8, 9,
- 10, 11, 12, 13, 14, 15, 16, 17, 18, 17,
- 17, 17, 17, 17, 17, 17, 17, 19, 20, 21,
- 22, 23, 24, 1, 29, 30, 31, 32, 33, 34,
- 35, 36, 37, 28, 38, 39, 40, 41, 42, 43,
- 44, 45, 46, 47, 48, 49, 50, 51, 52, 28,
- 25, 26, 27, 1, 28, 1, 29, 30, 31, 32,
-
- 33, 34, 35, 36, 37, 28, 38, 39, 40, 41,
- 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
- 52, 28, 53, 54, 55, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1
- } ;
-
-static yyconst flex_int32_t yy_meta[56] =
- { 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 2, 1, 1, 1, 3, 4, 5, 5, 1, 1,
- 1, 2, 1, 1, 1, 1, 1, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 1, 1, 1
- } ;
-
-static yyconst flex_int16_t yy_base[327] =
- { 0,
- 0, 0, 626, 627, 627, 627, 622, 602, 53, 616,
- 54, 627, 627, 600, 46, 627, 47, 48, 55, 57,
- 627, 627, 599, 598, 597, 627, 627, 627, 602, 44,
- 49, 51, 57, 65, 67, 70, 72, 79, 68, 81,
- 86, 85, 92, 74, 100, 627, 563, 627, 627, 594,
- 121, 132, 627, 612, 627, 114, 136, 627, 611, 627,
- 627, 627, 627, 627, 597, 130, 627, 115, 627, 627,
- 596, 125, 133, 588, 588, 627, 594, 592, 133, 137,
- 138, 139, 591, 141, 60, 140, 143, 144, 145, 147,
- 590, 148, 149, 152, 151, 153, 66, 156, 154, 158,
-
- 155, 161, 159, 181, 173, 166, 170, 171, 177, 188,
- 182, 192, 627, 627, 589, 588, 196, 627, 627, 200,
- 587, 193, 202, 586, 203, 204, 209, 208, 585, 211,
- 210, 214, 584, 212, 216, 215, 219, 583, 217, 221,
- 222, 223, 224, 228, 229, 230, 233, 241, 243, 244,
- 247, 245, 248, 249, 251, 582, 581, 254, 262, 256,
- 267, 268, 580, 270, 275, 271, 272, 277, 278, 279,
- 284, 282, 579, 578, 286, 285, 283, 293, 291, 294,
- 296, 297, 577, 576, 298, 308, 575, 313, 314, 574,
- 305, 315, 317, 318, 573, 320, 319, 326, 323, 329,
-
- 332, 335, 337, 336, 338, 339, 340, 353, 344, 341,
- 347, 351, 355, 356, 362, 572, 359, 571, 367, 566,
- 360, 374, 363, 366, 381, 372, 378, 565, 371, 382,
- 386, 556, 390, 539, 394, 395, 396, 397, 375, 538,
- 398, 400, 401, 402, 405, 406, 408, 412, 537, 413,
- 415, 417, 420, 418, 423, 430, 416, 431, 424, 432,
- 435, 434, 535, 445, 533, 446, 436, 448, 449, 450,
- 451, 456, 458, 459, 460, 455, 461, 530, 471, 465,
- 470, 529, 464, 473, 474, 478, 527, 526, 484, 525,
- 524, 485, 519, 517, 488, 489, 492, 493, 494, 495,
-
- 496, 499, 513, 511, 509, 500, 502, 508, 507, 299,
- 497, 503, 501, 506, 504, 162, 76, 71, 627, 556,
- 562, 567, 570, 573, 577, 580
- } ;
-
-static yyconst flex_int16_t yy_def[327] =
- { 0,
- 319, 1, 319, 319, 319, 319, 319, 319, 320, 319,
- 321, 319, 319, 319, 319, 319, 319, 319, 322, 319,
- 319, 319, 319, 319, 319, 319, 319, 319, 323, 323,
- 323, 323, 323, 323, 323, 323, 323, 323, 323, 323,
- 323, 323, 323, 323, 323, 319, 319, 319, 319, 319,
- 320, 320, 319, 320, 319, 321, 321, 319, 321, 319,
- 319, 319, 319, 319, 319, 322, 319, 319, 319, 319,
- 324, 319, 319, 319, 319, 319, 325, 323, 323, 323,
- 323, 323, 323, 323, 323, 323, 323, 323, 323, 323,
- 323, 323, 323, 323, 323, 323, 323, 323, 323, 323,
-
- 323, 323, 323, 323, 323, 323, 323, 323, 323, 323,
- 323, 323, 319, 319, 319, 324, 319, 319, 319, 319,
- 326, 323, 323, 323, 323, 323, 323, 323, 323, 323,
- 323, 323, 323, 323, 323, 323, 323, 323, 323, 323,
- 323, 323, 323, 323, 323, 323, 323, 323, 323, 323,
- 323, 323, 323, 323, 323, 319, 326, 323, 323, 323,
- 323, 323, 323, 323, 323, 323, 323, 323, 323, 323,
- 323, 323, 323, 323, 323, 323, 323, 323, 323, 323,
- 323, 323, 323, 323, 323, 323, 323, 323, 323, 323,
- 323, 323, 323, 323, 323, 323, 323, 323, 323, 323,
-
- 323, 323, 323, 323, 323, 323, 323, 323, 323, 323,
- 323, 323, 323, 323, 323, 323, 323, 323, 323, 323,
- 323, 323, 323, 323, 323, 323, 323, 323, 323, 323,
- 323, 323, 323, 323, 323, 323, 323, 323, 323, 323,
- 323, 323, 323, 323, 323, 323, 323, 323, 323, 323,
- 323, 323, 323, 323, 323, 323, 323, 323, 323, 323,
- 323, 323, 323, 323, 323, 323, 323, 323, 323, 323,
- 323, 323, 323, 323, 323, 323, 323, 323, 323, 323,
- 323, 323, 323, 323, 323, 323, 323, 323, 323, 323,
- 323, 323, 323, 323, 323, 323, 323, 323, 323, 323,
-
- 323, 323, 323, 323, 323, 323, 323, 323, 323, 323,
- 323, 323, 323, 323, 323, 323, 323, 323, 0, 319,
- 319, 319, 319, 319, 319, 319
- } ;
-
-static yyconst flex_int16_t yy_nxt[683] =
- { 0,
- 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
- 14, 15, 16, 17, 18, 19, 20, 20, 21, 22,
- 23, 24, 25, 26, 27, 4, 28, 29, 29, 30,
- 31, 32, 33, 34, 35, 29, 36, 29, 37, 29,
- 38, 39, 40, 29, 41, 42, 43, 29, 44, 45,
- 29, 29, 46, 47, 48, 52, 57, 61, 53, 77,
- 63, 58, 65, 66, 77, 67, 77, 62, 64, 68,
- 69, 72, 77, 73, 73, 77, 70, 80, 54, 59,
- 77, 77, 77, 77, 81, 77, 77, 77, 79, 77,
- 82, 77, 83, 86, 77, 85, 77, 138, 84, 89,
-
- 77, 77, 111, 91, 93, 127, 87, 77, 90, 88,
- 92, 95, 97, 94, 101, 77, 57, 103, 102, 98,
- 96, 58, 99, 52, 106, 100, 53, 107, 108, 115,
- 66, 104, 105, 109, 52, 112, 110, 53, 57, 59,
- 319, 117, 117, 58, 68, 319, 54, 72, 77, 73,
- 73, 319, 77, 77, 77, 77, 77, 54, 77, 77,
- 77, 59, 77, 77, 77, 122, 77, 77, 77, 77,
- 77, 77, 130, 77, 77, 123, 77, 77, 128, 125,
- 135, 77, 124, 126, 139, 77, 77, 129, 77, 134,
- 141, 131, 77, 132, 133, 142, 77, 77, 137, 140,
-
- 143, 136, 147, 77, 148, 144, 149, 77, 77, 145,
- 150, 151, 117, 117, 156, 77, 152, 77, 77, 77,
- 154, 158, 146, 77, 77, 77, 77, 77, 155, 77,
- 77, 77, 77, 160, 77, 153, 77, 77, 77, 77,
- 159, 163, 162, 77, 77, 77, 169, 170, 77, 161,
- 165, 172, 166, 164, 176, 168, 77, 167, 77, 77,
- 77, 171, 77, 77, 77, 177, 77, 174, 173, 77,
- 175, 77, 180, 179, 178, 186, 184, 77, 181, 182,
- 187, 185, 77, 77, 192, 77, 77, 77, 183, 189,
- 77, 190, 77, 77, 77, 191, 188, 77, 77, 77,
-
- 77, 77, 195, 193, 194, 199, 77, 196, 77, 77,
- 200, 77, 77, 77, 77, 197, 198, 204, 202, 206,
- 77, 209, 205, 77, 201, 211, 207, 203, 77, 77,
- 77, 208, 77, 77, 77, 77, 215, 210, 77, 212,
- 216, 77, 213, 214, 77, 217, 218, 77, 222, 219,
- 77, 77, 77, 77, 77, 77, 77, 221, 223, 77,
- 224, 220, 77, 226, 225, 230, 77, 228, 77, 232,
- 77, 77, 237, 227, 77, 77, 229, 77, 77, 234,
- 231, 77, 77, 233, 241, 235, 77, 77, 236, 77,
- 77, 238, 239, 77, 242, 244, 77, 77, 249, 240,
-
- 243, 77, 246, 250, 247, 77, 251, 245, 248, 77,
- 77, 77, 77, 77, 254, 77, 77, 77, 255, 252,
- 77, 77, 260, 77, 256, 259, 253, 77, 77, 257,
- 77, 77, 77, 77, 263, 77, 267, 265, 77, 77,
- 258, 264, 261, 262, 268, 77, 77, 77, 276, 77,
- 77, 77, 266, 271, 270, 269, 272, 273, 278, 277,
- 77, 77, 274, 77, 77, 77, 77, 284, 275, 280,
- 77, 77, 279, 77, 77, 77, 77, 282, 283, 77,
- 77, 281, 287, 288, 289, 77, 77, 286, 77, 77,
- 290, 291, 285, 77, 298, 294, 292, 296, 297, 77,
-
- 77, 293, 295, 77, 77, 299, 301, 77, 77, 77,
- 77, 77, 77, 302, 77, 77, 77, 77, 77, 77,
- 300, 77, 77, 77, 77, 308, 77, 303, 77, 314,
- 306, 307, 77, 304, 77, 305, 312, 311, 313, 77,
- 77, 77, 77, 316, 77, 77, 309, 310, 77, 315,
- 77, 317, 77, 77, 77, 318, 51, 51, 51, 51,
- 51, 51, 56, 56, 56, 56, 56, 56, 71, 71,
- 71, 77, 71, 78, 78, 78, 116, 116, 116, 121,
- 77, 77, 121, 157, 157, 157, 77, 77, 77, 77,
- 77, 77, 77, 77, 77, 77, 77, 77, 77, 77,
-
- 77, 77, 77, 66, 66, 77, 77, 77, 120, 119,
- 118, 66, 66, 319, 319, 114, 113, 77, 76, 75,
- 74, 60, 55, 50, 49, 319, 3, 319, 319, 319,
- 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
- 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
- 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
- 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
- 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
- 319, 319
- } ;
-
-static yyconst flex_int16_t yy_chk[683] =
- { 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 9, 11, 15, 9, 30,
- 17, 11, 18, 18, 31, 19, 32, 15, 17, 19,
- 19, 20, 33, 20, 20, 85, 19, 31, 9, 11,
- 34, 97, 35, 39, 31, 36, 318, 37, 30, 44,
- 31, 317, 32, 34, 38, 33, 40, 97, 32, 35,
-
- 42, 41, 44, 36, 37, 85, 34, 43, 35, 34,
- 36, 38, 39, 37, 41, 45, 56, 42, 41, 40,
- 38, 56, 40, 51, 43, 40, 51, 43, 43, 68,
- 68, 42, 42, 43, 52, 45, 43, 52, 57, 56,
- 66, 72, 72, 57, 66, 66, 51, 73, 79, 73,
- 73, 66, 80, 81, 82, 86, 84, 52, 87, 88,
- 89, 57, 90, 92, 93, 79, 95, 94, 96, 99,
- 101, 98, 88, 100, 103, 80, 102, 316, 86, 82,
- 94, 106, 81, 84, 98, 107, 108, 87, 105, 93,
- 100, 89, 109, 90, 92, 101, 104, 111, 96, 99,
-
- 102, 95, 105, 110, 106, 103, 107, 112, 122, 104,
- 108, 109, 117, 117, 120, 120, 110, 123, 125, 126,
- 111, 122, 104, 128, 127, 131, 130, 134, 112, 132,
- 136, 135, 139, 125, 137, 110, 140, 141, 142, 143,
- 123, 127, 126, 144, 145, 146, 134, 135, 147, 125,
- 130, 137, 131, 128, 142, 132, 148, 131, 149, 150,
- 152, 136, 151, 153, 154, 143, 155, 140, 139, 158,
- 141, 160, 146, 145, 144, 152, 150, 159, 147, 148,
- 153, 151, 161, 162, 160, 164, 166, 167, 149, 155,
- 165, 158, 168, 169, 170, 159, 154, 172, 177, 171,
-
- 176, 175, 164, 161, 162, 168, 179, 165, 178, 180,
- 168, 181, 182, 185, 310, 166, 167, 171, 170, 175,
- 191, 178, 172, 186, 169, 180, 176, 170, 188, 189,
- 192, 177, 193, 194, 197, 196, 185, 179, 199, 180,
- 186, 198, 181, 182, 200, 188, 189, 201, 194, 191,
- 202, 204, 203, 205, 206, 207, 210, 193, 196, 209,
- 197, 192, 211, 199, 198, 203, 212, 201, 208, 205,
- 213, 214, 210, 200, 217, 221, 202, 215, 223, 207,
- 204, 224, 219, 206, 214, 208, 229, 226, 209, 222,
- 239, 211, 212, 227, 215, 219, 225, 230, 225, 213,
-
- 217, 231, 222, 226, 223, 233, 227, 221, 224, 235,
- 236, 237, 238, 241, 231, 242, 243, 244, 233, 229,
- 245, 246, 239, 247, 235, 238, 230, 248, 250, 236,
- 251, 257, 252, 254, 243, 253, 247, 245, 255, 259,
- 237, 244, 241, 242, 248, 256, 258, 260, 257, 262,
- 261, 267, 246, 252, 251, 250, 253, 254, 259, 258,
- 264, 266, 255, 268, 269, 270, 271, 267, 256, 261,
- 276, 272, 260, 273, 274, 275, 277, 264, 266, 283,
- 280, 262, 270, 271, 272, 281, 279, 269, 284, 285,
- 273, 274, 268, 286, 283, 277, 275, 280, 281, 289,
-
- 292, 276, 279, 295, 296, 284, 286, 297, 298, 299,
- 300, 301, 311, 289, 302, 306, 313, 307, 312, 315,
- 285, 314, 309, 308, 305, 299, 304, 292, 303, 311,
- 297, 298, 294, 295, 293, 296, 306, 302, 307, 291,
- 290, 288, 287, 313, 282, 278, 300, 301, 265, 312,
- 263, 314, 249, 240, 234, 315, 320, 320, 320, 320,
- 320, 320, 321, 321, 321, 321, 321, 321, 322, 322,
- 322, 232, 322, 323, 323, 323, 324, 324, 324, 325,
- 228, 220, 325, 326, 326, 326, 218, 216, 195, 190,
- 187, 184, 183, 174, 173, 163, 157, 156, 138, 133,
-
- 129, 124, 121, 116, 115, 91, 83, 78, 77, 75,
- 74, 71, 65, 59, 54, 50, 47, 29, 25, 24,
- 23, 14, 10, 8, 7, 3, 319, 319, 319, 319,
- 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
- 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
- 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
- 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
- 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
- 319, 319
- } ;
-
-static yy_state_type yy_last_accepting_state;
-static char *yy_last_accepting_cpos;
-
-extern int swf4_flex_debug;
-int swf4_flex_debug = 0;
-
-/* The intent behind this definition is that it'll catch
- * any uses of REJECT which flex missed.
- */
-#define REJECT reject_used_but_not_detected
-#define yymore() yymore_used_but_not_detected
-#define YY_MORE_ADJ 0
-#define YY_RESTORE_YY_MORE_OFFSET
-char *swf4text;
-#line 1 "swf4compiler.flex"
-#line 2 "swf4compiler.flex"
-
-#include <math.h>
-#include <string.h>
-
-#include "compile.h"
-#include "action.h"
-#include "blocks/error.h"
-#include "swf4compiler.tab.h" /* defines token types */
-
-static int swf4debug;
-
-static const char *lexBuffer = NULL;
-static int lexBufferLen = 0;
-
-static int sLineNumber = 0;
-static char szLine[1024];
-static char msgbufs[2][1024] = { {0}, {0} }, *msgline = {0};
-static int column = 0;
-
-static void comment();
-static void comment1();
-static void count();
-static void warning(char *msg);
-
-#define YY_INPUT(buf,result,max_size) result=lexBufferInput(buf, max_size)
-
-/* thanks to the prolific and brilliant Raff: */
-static int lexBufferInput(char *buf, int max_size)
-{
- int l = lexBufferLen > max_size ? max_size : lexBufferLen;
-
- if (lexBufferLen <= 0)
- return YY_NULL;
-
- memcpy(buf, lexBuffer, l);
- lexBuffer += l;
- lexBufferLen -= l;
- return l;
-}
-
- /* very inefficient method of unescaping strings */
-static void unescape(char *buf)
-{
- char *p, *p1;
-
- for (p1=buf; (p=strchr(p1, '\\')) != 0; p1 = p+1) {
- switch(p[1])
- {
- case 'b' : p[1] = '\b'; break;
- case 'f' : p[1] = '\f'; break;
- case 'n' : p[1] = '\n'; break;
- case 'r' : p[1] = '\r'; break;
- case 't' : p[1] = '\t'; break;
- case 'x' :
- case 'u' : warning("unsupported escape sequence");
- }
- strcpy(p, p+1);
- }
-}
-
-void swf4ParseInit(const char *script, int debug)
-{
- checkByteOrder();
- swf4restart(NULL);
-
- swf4debug = debug;
-
- lexBuffer = script;
- lexBufferLen = strlen(script);
- sLineNumber = 0;
- column = 0;
- msgline = msgbufs[0];
-}
-
-#line 79 "swf4compiler.flex"
- // forward declaration needed by the following function
-#ifndef YY_PROTO
-#ifdef YY_USE_PROTOS
-#define YY_PROTO(proto) proto
-#else
-#define YY_PROTO(proto) ()
-#endif
-#endif
- static void yyunput YY_PROTO(( int c, char *buf_ptr ));
-
- void do_unput4(const char c) { unput(c); }
-#line 797 "lex.swf4.c"
-
-#define INITIAL 0
-
-#ifndef YY_NO_UNISTD_H
-/* Special case for "unistd.h", since it is non-ANSI. We include it way
- * down here because we want the user's section 1 to have been scanned first.
- * The user has a chance to override it with an option.
- */
-#include <unistd.h>
-#endif
-
-#ifndef YY_EXTRA_TYPE
-#define YY_EXTRA_TYPE void *
-#endif
-
-static int yy_init_globals (void );
-
-/* Macros after this point can all be overridden by user definitions in
- * section 1.
- */
-
-#ifndef YY_SKIP_YYWRAP
-#ifdef __cplusplus
-extern "C" int swf4wrap (void );
-#else
-extern int swf4wrap (void );
-#endif
-#endif
-
- static void yyunput (int c,char *buf_ptr );
-
-#ifndef yytext_ptr
-static void yy_flex_strncpy (char *,yyconst char *,int );
-#endif
-
-#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen (yyconst char * );
-#endif
-
-#ifndef YY_NO_INPUT
-
-#ifdef __cplusplus
-static int yyinput (void );
-#else
-static int input (void );
-#endif
-
-#endif
-
-/* Amount of stuff to slurp up with each read. */
-#ifndef YY_READ_BUF_SIZE
-#define YY_READ_BUF_SIZE 8192
-#endif
-
-/* Copy whatever the last rule matched to the standard output. */
-#ifndef ECHO
-/* This used to be an fputs(), but since the string might contain NUL's,
- * we now use fwrite().
- */
-#define ECHO (void) fwrite( swf4text, swf4leng, 1, swf4out )
-#endif
-
-/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
- * is returned in "result".
- */
-#ifndef YY_INPUT
-#define YY_INPUT(buf,result,max_size) \
- if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
- { \
- int c = '*'; \
- size_t n; \
- for ( n = 0; n < max_size && \
- (c = getc( swf4in )) != EOF && c != '\n'; ++n ) \
- buf[n] = (char) c; \
- if ( c == '\n' ) \
- buf[n++] = (char) c; \
- if ( c == EOF && ferror( swf4in ) ) \
- YY_FATAL_ERROR( "input in flex scanner failed" ); \
- result = n; \
- } \
- else \
- { \
- errno=0; \
- while ( (result = fread(buf, 1, max_size, swf4in))==0 && ferror(swf4in)) \
- { \
- if( errno != EINTR) \
- { \
- YY_FATAL_ERROR( "input in flex scanner failed" ); \
- break; \
- } \
- errno=0; \
- clearerr(swf4in); \
- } \
- }\
-\
-
-#endif
-
-/* No semi-colon after return; correct usage is to write "yyterminate();" -
- * we don't want an extra ';' after the "return" because that will cause
- * some compilers to complain about unreachable statements.
- */
-#ifndef yyterminate
-#define yyterminate() return YY_NULL
-#endif
-
-/* Number of entries by which start-condition stack grows. */
-#ifndef YY_START_STACK_INCR
-#define YY_START_STACK_INCR 25
-#endif
-
-/* Report a fatal error. */
-#ifndef YY_FATAL_ERROR
-#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
-#endif
-
-/* end tables serialization structures and prototypes */
-
-/* Default declaration of generated scanner - a define so the user can
- * easily add parameters.
- */
-#ifndef YY_DECL
-#define YY_DECL_IS_OURS 1
-
-extern int swf4lex (void);
-
-#define YY_DECL int swf4lex (void)
-#endif /* !YY_DECL */
-
-/* Code executed at the beginning of each rule, after swf4text and swf4leng
- * have been set up.
- */
-#ifndef YY_USER_ACTION
-#define YY_USER_ACTION
-#endif
-
-/* Code executed at the end of each rule. */
-#ifndef YY_BREAK
-#define YY_BREAK break;
-#endif
-
-#define YY_RULE_SETUP \
- YY_USER_ACTION
-
-/** The main scanner function which does all the work.
- */
-YY_DECL
-{
- register yy_state_type yy_current_state;
- register char *yy_cp, *yy_bp;
- register int yy_act;
-
-#line 96 "swf4compiler.flex"
-
-
-#line 953 "lex.swf4.c"
-
- if ( !(yy_init) )
- {
- (yy_init) = 1;
-
-#ifdef YY_USER_INIT
- YY_USER_INIT;
-#endif
-
- if ( ! (yy_start) )
- (yy_start) = 1; /* first start state */
-
- if ( ! swf4in )
- swf4in = stdin;
-
- if ( ! swf4out )
- swf4out = stdout;
-
- if ( ! YY_CURRENT_BUFFER ) {
- swf4ensure_buffer_stack ();
- YY_CURRENT_BUFFER_LVALUE =
- swf4_create_buffer(swf4in,YY_BUF_SIZE );
- }
-
- swf4_load_buffer_state( );
- }
-
- while ( 1 ) /* loops until end-of-file is reached */
- {
- yy_cp = (yy_c_buf_p);
-
- /* Support of swf4text. */
- *yy_cp = (yy_hold_char);
-
- /* yy_bp points to the position in yy_ch_buf of the start of
- * the current run.
- */
- yy_bp = yy_cp;
-
- yy_current_state = (yy_start);
-yy_match:
- do
- {
- register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
- if ( yy_accept[yy_current_state] )
- {
- (yy_last_accepting_state) = yy_current_state;
- (yy_last_accepting_cpos) = yy_cp;
- }
- while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
- {
- yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 320 )
- yy_c = yy_meta[(unsigned int) yy_c];
- }
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
- ++yy_cp;
- }
- while ( yy_base[yy_current_state] != 627 );
-
-yy_find_action:
- yy_act = yy_accept[yy_current_state];
- if ( yy_act == 0 )
- { /* have to back up */
- yy_cp = (yy_last_accepting_cpos);
- yy_current_state = (yy_last_accepting_state);
- yy_act = yy_accept[yy_current_state];
- }
-
- YY_DO_BEFORE_ACTION;
-
-do_action: /* This label is used only to access EOF actions. */
-
- switch ( yy_act )
- { /* beginning of action switch */
- case 0: /* must back up */
- /* undo the effects of YY_DO_BEFORE_ACTION */
- *yy_cp = (yy_hold_char);
- yy_cp = (yy_last_accepting_cpos);
- yy_current_state = (yy_last_accepting_state);
- goto yy_find_action;
-
-case 1:
-YY_RULE_SETUP
-#line 98 "swf4compiler.flex"
-{ count(); swf4lval.str = strdup(swf4text);
- return NUMBER; }
- YY_BREAK
-case 2:
-YY_RULE_SETUP
-#line 100 "swf4compiler.flex"
-{ count(); swf4lval.str = strdup(swf4text);
- return NUMBER; }
- YY_BREAK
-case 3:
-YY_RULE_SETUP
-#line 102 "swf4compiler.flex"
-{ count(); swf4lval.str = strdup("1");
- return NUMBER; }
- YY_BREAK
-case 4:
-YY_RULE_SETUP
-#line 104 "swf4compiler.flex"
-{ count(); swf4lval.str = strdup("0");
- return NUMBER; }
- YY_BREAK
-case 5:
-YY_RULE_SETUP
-#line 106 "swf4compiler.flex"
-{ count(); return BREAK; }
- YY_BREAK
-case 6:
-YY_RULE_SETUP
-#line 107 "swf4compiler.flex"
-{ count(); return CONTINUE; }
- YY_BREAK
-case 7:
-YY_RULE_SETUP
-#line 108 "swf4compiler.flex"
-{ count(); return ELSE; }
- YY_BREAK
-case 8:
-YY_RULE_SETUP
-#line 109 "swf4compiler.flex"
-{ count(); return FOR; }
- YY_BREAK
-case 9:
-YY_RULE_SETUP
-#line 110 "swf4compiler.flex"
-{ count(); return IF; }
- YY_BREAK
-case 10:
-YY_RULE_SETUP
-#line 111 "swf4compiler.flex"
-{ count(); return WHILE; }
- YY_BREAK
-case 11:
-YY_RULE_SETUP
-#line 112 "swf4compiler.flex"
-{ count(); return DO; }
- YY_BREAK
-case 12:
-YY_RULE_SETUP
-#line 113 "swf4compiler.flex"
-{ count(); return EVAL; }
- YY_BREAK
-/* functions */
-case 13:
-YY_RULE_SETUP
-#line 116 "swf4compiler.flex"
-{ count(); return RANDOM; }
- YY_BREAK
-case 14:
-YY_RULE_SETUP
-#line 117 "swf4compiler.flex"
-{ count(); return TIME; }
- YY_BREAK
-case 15:
-YY_RULE_SETUP
-#line 118 "swf4compiler.flex"
-{ count(); return LENGTH; }
- YY_BREAK
-case 16:
-YY_RULE_SETUP
-#line 119 "swf4compiler.flex"
-{ count(); return INT; }
- YY_BREAK
-case 17:
-YY_RULE_SETUP
-#line 120 "swf4compiler.flex"
-{ count(); return CONCAT; }
- YY_BREAK
-case 18:
-YY_RULE_SETUP
-#line 121 "swf4compiler.flex"
-{ count(); return DUPLICATECLIP; }
- YY_BREAK
-case 19:
-YY_RULE_SETUP
-#line 122 "swf4compiler.flex"
-{ count(); return REMOVECLIP; }
- YY_BREAK
-case 20:
-YY_RULE_SETUP
-#line 123 "swf4compiler.flex"
-{ count(); return TRACE; }
- YY_BREAK
-case 21:
-YY_RULE_SETUP
-#line 124 "swf4compiler.flex"
-{ count(); return STARTDRAG; }
- YY_BREAK
-case 22:
-YY_RULE_SETUP
-#line 125 "swf4compiler.flex"
-{ count(); return STOPDRAG; }
- YY_BREAK
-case 23:
-YY_RULE_SETUP
-#line 126 "swf4compiler.flex"
-{ count(); return ORD; }
- YY_BREAK
-case 24:
-YY_RULE_SETUP
-#line 127 "swf4compiler.flex"
-{ count(); return CHR; }
- YY_BREAK
-case 25:
-YY_RULE_SETUP
-#line 128 "swf4compiler.flex"
-{ count(); return CALLFRAME; }
- YY_BREAK
-case 26:
-YY_RULE_SETUP
-#line 129 "swf4compiler.flex"
-{ count(); return GETURL; }
- YY_BREAK
-case 27:
-YY_RULE_SETUP
-#line 130 "swf4compiler.flex"
-{ count(); return GETURL1; }
- YY_BREAK
-case 28:
-YY_RULE_SETUP
-#line 131 "swf4compiler.flex"
-{ count(); return LOADMOVIE; }
- YY_BREAK
-case 29:
-YY_RULE_SETUP
-#line 132 "swf4compiler.flex"
-{ count(); return LOADVARIABLES; }
- YY_BREAK
-case 30:
-YY_RULE_SETUP
-#line 133 "swf4compiler.flex"
-{ count(); return SUBSTR; }
- YY_BREAK
-case 31:
-YY_RULE_SETUP
-#line 135 "swf4compiler.flex"
-{ count(); return GETPROPERTY; }
- YY_BREAK
-/* getURL2 methods */
-case 32:
-YY_RULE_SETUP
-#line 138 "swf4compiler.flex"
-{ count(); swf4lval.getURLMethod = GETURL_METHOD_POST;
- return GETURL_METHOD; }
- YY_BREAK
-case 33:
-YY_RULE_SETUP
-#line 140 "swf4compiler.flex"
-{ count(); swf4lval.getURLMethod = GETURL_METHOD_GET;
- return GETURL_METHOD; }
- YY_BREAK
-case 34:
-YY_RULE_SETUP
-#line 142 "swf4compiler.flex"
-{ count(); swf4lval.getURLMethod = GETURL_METHOD_NOSEND;
- return GETURL_METHOD; }
- YY_BREAK
-/* v3 functions */
-case 35:
-YY_RULE_SETUP
-#line 147 "swf4compiler.flex"
-{ count(); return NEXTFRAME; }
- YY_BREAK
-case 36:
-YY_RULE_SETUP
-#line 148 "swf4compiler.flex"
-{ count(); return PREVFRAME; }
- YY_BREAK
-case 37:
-YY_RULE_SETUP
-#line 149 "swf4compiler.flex"
-{ count(); return PLAY; }
- YY_BREAK
-case 38:
-YY_RULE_SETUP
-#line 150 "swf4compiler.flex"
-{ count(); return STOP; }
- YY_BREAK
-case 39:
-YY_RULE_SETUP
-#line 151 "swf4compiler.flex"
-{ count(); return TOGGLEQUALITY; }
- YY_BREAK
-case 40:
-YY_RULE_SETUP
-#line 152 "swf4compiler.flex"
-{ count(); return STOPSOUNDS; }
- YY_BREAK
-case 41:
-YY_RULE_SETUP
-#line 153 "swf4compiler.flex"
-{ count(); return GOTOFRAME; }
- YY_BREAK
-case 42:
-YY_RULE_SETUP
-#line 154 "swf4compiler.flex"
-{ count(); return GOTOANDPLAY; }
- YY_BREAK
-case 43:
-YY_RULE_SETUP
-#line 155 "swf4compiler.flex"
-{ count(); return FRAMELOADED; }
- YY_BREAK
-case 44:
-YY_RULE_SETUP
-#line 156 "swf4compiler.flex"
-{ count(); return SETTARGET; }
- YY_BREAK
-/* high level functions */
-case 45:
-YY_RULE_SETUP
-#line 159 "swf4compiler.flex"
-{ count(); return TELLTARGET; }
- YY_BREAK
-case 46:
-YY_RULE_SETUP
-#line 162 "swf4compiler.flex"
-{ count(); return THIS; }
- YY_BREAK
-case 47:
-YY_RULE_SETUP
-#line 164 "swf4compiler.flex"
-{ count(); swf4lval.str = strdup(swf4text);
- return IDENTIFIER; }
- YY_BREAK
-case 48:
-YY_RULE_SETUP
-#line 167 "swf4compiler.flex"
-{ count(); swf4lval.str = strdup(swf4text);
- return PATH; }
- YY_BREAK
-case 49:
-YY_RULE_SETUP
-#line 170 "swf4compiler.flex"
-{ count(); swf4lval.str = strdup(swf4text);
- return PATH; }
- YY_BREAK
-case 50:
-/* rule 50 can match eol */
-YY_RULE_SETUP
-#line 173 "swf4compiler.flex"
-{ count(); swf4lval.str = strdup(swf4text+1);
- swf4lval.str[strlen(swf4lval.str)-1]=0;
- unescape(swf4lval.str);
- return STRING; }
- YY_BREAK
-case 51:
-/* rule 51 can match eol */
-YY_RULE_SETUP
-#line 178 "swf4compiler.flex"
-{ count(); swf4lval.str = strdup(swf4text+1);
- swf4lval.str[strlen(swf4lval.str)-1]=0;
- unescape(swf4lval.str);
- return STRING; }
- YY_BREAK
-case 52:
-/* rule 52 can match eol */
-*yy_cp = (yy_hold_char); /* undo effects of setting up swf4text */
-(yy_c_buf_p) = yy_cp -= 1;
-YY_DO_BEFORE_ACTION; /* set up swf4text again */
-YY_RULE_SETUP
-#line 183 "swf4compiler.flex"
-{ count(); swf4lval.str = strdup("");
- warning("Unterminated string!");
- return STRING; }
- YY_BREAK
-case 53:
-/* rule 53 can match eol */
-*yy_cp = (yy_hold_char); /* undo effects of setting up swf4text */
-(yy_c_buf_p) = yy_cp -= 1;
-YY_DO_BEFORE_ACTION; /* set up swf4text again */
-YY_RULE_SETUP
-#line 187 "swf4compiler.flex"
-{ count(); swf4lval.str = strdup("");
- warning("Unterminated string!");
- return STRING; }
- YY_BREAK
-case 54:
-YY_RULE_SETUP
-#line 191 "swf4compiler.flex"
-{ count(); comment(); }
- YY_BREAK
-case 55:
-YY_RULE_SETUP
-#line 192 "swf4compiler.flex"
-{ count(); comment1(); }
- YY_BREAK
-case 56:
-YY_RULE_SETUP
-#line 193 "swf4compiler.flex"
-{ count(); }
- YY_BREAK
-case 57:
-YY_RULE_SETUP
-#line 195 "swf4compiler.flex"
-{ count(); return INC; }
- YY_BREAK
-case 58:
-YY_RULE_SETUP
-#line 196 "swf4compiler.flex"
-{ count(); return DEC; }
- YY_BREAK
-case 59:
-YY_RULE_SETUP
-#line 197 "swf4compiler.flex"
-{ count(); return '<'; }
- YY_BREAK
-case 60:
-YY_RULE_SETUP
-#line 198 "swf4compiler.flex"
-{ count(); return '>'; }
- YY_BREAK
-case 61:
-YY_RULE_SETUP
-#line 199 "swf4compiler.flex"
-{ count(); return LE; }
- YY_BREAK
-case 62:
-YY_RULE_SETUP
-#line 200 "swf4compiler.flex"
-{ count(); return GE; }
- YY_BREAK
-case 63:
-YY_RULE_SETUP
-#line 201 "swf4compiler.flex"
-{ count(); return EQ; }
- YY_BREAK
-case 64:
-YY_RULE_SETUP
-#line 202 "swf4compiler.flex"
-{ count(); return NE; }
- YY_BREAK
-case 65:
-YY_RULE_SETUP
-#line 203 "swf4compiler.flex"
-{ count(); return LAN; }
- YY_BREAK
-case 66:
-YY_RULE_SETUP
-#line 204 "swf4compiler.flex"
-{ count(); return LOR; }
- YY_BREAK
-case 67:
-YY_RULE_SETUP
-#line 205 "swf4compiler.flex"
-{ count(); return MEQ; }
- YY_BREAK
-case 68:
-YY_RULE_SETUP
-#line 206 "swf4compiler.flex"
-{ count(); return DEQ; }
- YY_BREAK
-case 69:
-YY_RULE_SETUP
-#line 207 "swf4compiler.flex"
-{ count(); return IEQ; }
- YY_BREAK
-case 70:
-YY_RULE_SETUP
-#line 208 "swf4compiler.flex"
-{ count(); return SEQ; }
- YY_BREAK
-case 71:
-YY_RULE_SETUP
-#line 209 "swf4compiler.flex"
-{ count(); return STREQ; }
- YY_BREAK
-case 72:
-YY_RULE_SETUP
-#line 210 "swf4compiler.flex"
-{ count(); return STRNE; }
- YY_BREAK
-case 73:
-YY_RULE_SETUP
-#line 211 "swf4compiler.flex"
-{ count(); return STRCMP; }
- YY_BREAK
-case 74:
-YY_RULE_SETUP
-#line 212 "swf4compiler.flex"
-{ count(); return PARENT; }
- YY_BREAK
-case 75:
-YY_RULE_SETUP
-#line 214 "swf4compiler.flex"
-{ count(); return ';'; }
- YY_BREAK
-case 76:
-YY_RULE_SETUP
-#line 215 "swf4compiler.flex"
-{ count(); return '='; }
- YY_BREAK
-case 77:
-YY_RULE_SETUP
-#line 216 "swf4compiler.flex"
-{ count(); return '+'; }
- YY_BREAK
-case 78:
-YY_RULE_SETUP
-#line 217 "swf4compiler.flex"
-{ count(); return '-'; }
- YY_BREAK
-case 79:
-YY_RULE_SETUP
-#line 218 "swf4compiler.flex"
-{ count(); return '&'; }
- YY_BREAK
-case 80:
-YY_RULE_SETUP
-#line 219 "swf4compiler.flex"
-{ count(); return '*'; }
- YY_BREAK
-case 81:
-YY_RULE_SETUP
-#line 220 "swf4compiler.flex"
-{ count(); return '/'; }
- YY_BREAK
-case 82:
-YY_RULE_SETUP
-#line 221 "swf4compiler.flex"
-{ count(); return '!'; }
- YY_BREAK
-case 83:
-YY_RULE_SETUP
-#line 222 "swf4compiler.flex"
-{ count(); return '('; }
- YY_BREAK
-case 84:
-YY_RULE_SETUP
-#line 223 "swf4compiler.flex"
-{ count(); return ')'; }
- YY_BREAK
-case 85:
-YY_RULE_SETUP
-#line 224 "swf4compiler.flex"
-{ count(); return '['; }
- YY_BREAK
-case 86:
-YY_RULE_SETUP
-#line 225 "swf4compiler.flex"
-{ count(); return ']'; }
- YY_BREAK
-case 87:
-YY_RULE_SETUP
-#line 226 "swf4compiler.flex"
-{ count(); return '{'; }
- YY_BREAK
-case 88:
-YY_RULE_SETUP
-#line 227 "swf4compiler.flex"
-{ count(); return '}'; }
- YY_BREAK
-case 89:
-YY_RULE_SETUP
-#line 228 "swf4compiler.flex"
-{ count(); return ','; }
- YY_BREAK
-case 90:
-YY_RULE_SETUP
-#line 229 "swf4compiler.flex"
-{ count(); return '.'; }
- YY_BREAK
-case 91:
-YY_RULE_SETUP
-#line 230 "swf4compiler.flex"
-{ count(); return '?'; }
- YY_BREAK
-case 92:
-YY_RULE_SETUP
-#line 231 "swf4compiler.flex"
-{ count(); return ':'; }
- YY_BREAK
-case 93:
-/* rule 93 can match eol */
-YY_RULE_SETUP
-#line 233 "swf4compiler.flex"
-{ count(); column = 0;
- strcpy(szLine, swf4text + 1);
- ++sLineNumber; yyless(1); }
- YY_BREAK
-case 94:
-YY_RULE_SETUP
-#line 237 "swf4compiler.flex"
-printf( "Unrecognized character: %s\n", swf4text );
- YY_BREAK
-case 95:
-YY_RULE_SETUP
-#line 239 "swf4compiler.flex"
-ECHO;
- YY_BREAK
-#line 1548 "lex.swf4.c"
-case YY_STATE_EOF(INITIAL):
- yyterminate();
-
- case YY_END_OF_BUFFER:
- {
- /* Amount of text matched not including the EOB char. */
- int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
-
- /* Undo the effects of YY_DO_BEFORE_ACTION. */
- *yy_cp = (yy_hold_char);
- YY_RESTORE_YY_MORE_OFFSET
-
- if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
- {
- /* We're scanning a new file or input source. It's
- * possible that this happened because the user
- * just pointed swf4in at a new source and called
- * swf4lex(). If so, then we have to assure
- * consistency between YY_CURRENT_BUFFER and our
- * globals. Here is the right place to do so, because
- * this is the first action (other than possibly a
- * back-up) that will match for the new input source.
- */
- (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
- YY_CURRENT_BUFFER_LVALUE->yy_input_file = swf4in;
- YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
- }
-
- /* Note that here we test for yy_c_buf_p "<=" to the position
- * of the first EOB in the buffer, since yy_c_buf_p will
- * already have been incremented past the NUL character
- * (since all states make transitions on EOB to the
- * end-of-buffer state). Contrast this with the test
- * in input().
- */
- if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
- { /* This was really a NUL. */
- yy_state_type yy_next_state;
-
- (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
-
- yy_current_state = yy_get_previous_state( );
-
- /* Okay, we're now positioned to make the NUL
- * transition. We couldn't have
- * yy_get_previous_state() go ahead and do it
- * for us because it doesn't know how to deal
- * with the possibility of jamming (and we don't
- * want to build jamming into it because then it
- * will run more slowly).
- */
-
- yy_next_state = yy_try_NUL_trans( yy_current_state );
-
- yy_bp = (yytext_ptr) + YY_MORE_ADJ;
-
- if ( yy_next_state )
- {
- /* Consume the NUL. */
- yy_cp = ++(yy_c_buf_p);
- yy_current_state = yy_next_state;
- goto yy_match;
- }
-
- else
- {
- yy_cp = (yy_c_buf_p);
- goto yy_find_action;
- }
- }
-
- else switch ( yy_get_next_buffer( ) )
- {
- case EOB_ACT_END_OF_FILE:
- {
- (yy_did_buffer_switch_on_eof) = 0;
-
- if ( swf4wrap( ) )
- {
- /* Note: because we've taken care in
- * yy_get_next_buffer() to have set up
- * swf4text, we can now set up
- * yy_c_buf_p so that if some total
- * hoser (like flex itself) wants to
- * call the scanner after we return the
- * YY_NULL, it'll still work - another
- * YY_NULL will get returned.
- */
- (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
-
- yy_act = YY_STATE_EOF(YY_START);
- goto do_action;
- }
-
- else
- {
- if ( ! (yy_did_buffer_switch_on_eof) )
- YY_NEW_FILE;
- }
- break;
- }
-
- case EOB_ACT_CONTINUE_SCAN:
- (yy_c_buf_p) =
- (yytext_ptr) + yy_amount_of_matched_text;
-
- yy_current_state = yy_get_previous_state( );
-
- yy_cp = (yy_c_buf_p);
- yy_bp = (yytext_ptr) + YY_MORE_ADJ;
- goto yy_match;
-
- case EOB_ACT_LAST_MATCH:
- (yy_c_buf_p) =
- &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
-
- yy_current_state = yy_get_previous_state( );
-
- yy_cp = (yy_c_buf_p);
- yy_bp = (yytext_ptr) + YY_MORE_ADJ;
- goto yy_find_action;
- }
- break;
- }
-
- default:
- YY_FATAL_ERROR(
- "fatal flex scanner internal error--no action found" );
- } /* end of action switch */
- } /* end of scanning one token */
-} /* end of swf4lex */
-
-/* yy_get_next_buffer - try to read in a new buffer
- *
- * Returns a code representing an action:
- * EOB_ACT_LAST_MATCH -
- * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
- * EOB_ACT_END_OF_FILE - end of file
- */
-static int yy_get_next_buffer (void)
-{
- register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
- register char *source = (yytext_ptr);
- register int number_to_move, i;
- int ret_val;
-
- if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
- YY_FATAL_ERROR(
- "fatal flex scanner internal error--end of buffer missed" );
-
- if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
- { /* Don't try to fill the buffer, so this is an EOF. */
- if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
- {
- /* We matched a single character, the EOB, so
- * treat this as a final EOF.
- */
- return EOB_ACT_END_OF_FILE;
- }
-
- else
- {
- /* We matched some text prior to the EOB, first
- * process it.
- */
- return EOB_ACT_LAST_MATCH;
- }
- }
-
- /* Try to read more data. */
-
- /* First move last chars to start of buffer. */
- number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
-
- for ( i = 0; i < number_to_move; ++i )
- *(dest++) = *(source++);
-
- if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
- /* don't do the read, it's not guaranteed to return an EOF,
- * just force an EOF
- */
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
-
- else
- {
- int num_to_read =
- YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
-
- while ( num_to_read <= 0 )
- { /* Not enough room in the buffer - grow it. */
-
- /* just a shorter name for the current buffer */
- YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
-
- int yy_c_buf_p_offset =
- (int) ((yy_c_buf_p) - b->yy_ch_buf);
-
- if ( b->yy_is_our_buffer )
- {
- int new_size = b->yy_buf_size * 2;
-
- if ( new_size <= 0 )
- b->yy_buf_size += b->yy_buf_size / 8;
- else
- b->yy_buf_size *= 2;
-
- b->yy_ch_buf = (char *)
- /* Include room in for 2 EOB chars. */
- swf4realloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
- }
- else
- /* Can't grow it, we don't own it. */
- b->yy_ch_buf = 0;
-
- if ( ! b->yy_ch_buf )
- YY_FATAL_ERROR(
- "fatal error - scanner input buffer overflow" );
-
- (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
-
- num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
- number_to_move - 1;
-
- }
-
- if ( num_to_read > YY_READ_BUF_SIZE )
- num_to_read = YY_READ_BUF_SIZE;
-
- /* Read in more data. */
- YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
- (yy_n_chars), num_to_read );
-
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
- }
-
- if ( (yy_n_chars) == 0 )
- {
- if ( number_to_move == YY_MORE_ADJ )
- {
- ret_val = EOB_ACT_END_OF_FILE;
- swf4restart(swf4in );
- }
-
- else
- {
- ret_val = EOB_ACT_LAST_MATCH;
- YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
- YY_BUFFER_EOF_PENDING;
- }
- }
-
- else
- ret_val = EOB_ACT_CONTINUE_SCAN;
-
- (yy_n_chars) += number_to_move;
- YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
- YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
-
- (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
-
- return ret_val;
-}
-
-/* yy_get_previous_state - get the state just before the EOB char was reached */
-
- static yy_state_type yy_get_previous_state (void)
-{
- register yy_state_type yy_current_state;
- register char *yy_cp;
-
- yy_current_state = (yy_start);
-
- for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
- {
- register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
- if ( yy_accept[yy_current_state] )
- {
- (yy_last_accepting_state) = yy_current_state;
- (yy_last_accepting_cpos) = yy_cp;
- }
- while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
- {
- yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 320 )
- yy_c = yy_meta[(unsigned int) yy_c];
- }
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
- }
-
- return yy_current_state;
-}
-
-/* yy_try_NUL_trans - try to make a transition on the NUL character
- *
- * synopsis
- * next_state = yy_try_NUL_trans( current_state );
- */
- static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
-{
- register int yy_is_jam;
- register char *yy_cp = (yy_c_buf_p);
-
- register YY_CHAR yy_c = 1;
- if ( yy_accept[yy_current_state] )
- {
- (yy_last_accepting_state) = yy_current_state;
- (yy_last_accepting_cpos) = yy_cp;
- }
- while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
- {
- yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 320 )
- yy_c = yy_meta[(unsigned int) yy_c];
- }
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
- yy_is_jam = (yy_current_state == 319);
-
- return yy_is_jam ? 0 : yy_current_state;
-}
-
- static void yyunput (int c, register char * yy_bp )
-{
- register char *yy_cp;
-
- yy_cp = (yy_c_buf_p);
-
- /* undo effects of setting up swf4text */
- *yy_cp = (yy_hold_char);
-
- if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
- { /* need to shift things up to make room */
- /* +2 for EOB chars. */
- register int number_to_move = (yy_n_chars) + 2;
- register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
- YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
- register char *source =
- &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
-
- while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
- *--dest = *--source;
-
- yy_cp += (int) (dest - source);
- yy_bp += (int) (dest - source);
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
- (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
-
- if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
- YY_FATAL_ERROR( "flex scanner push-back overflow" );
- }
-
- *--yy_cp = (char) c;
-
- (yytext_ptr) = yy_bp;
- (yy_hold_char) = *yy_cp;
- (yy_c_buf_p) = yy_cp;
-}
-
-#ifndef YY_NO_INPUT
-#ifdef __cplusplus
- static int yyinput (void)
-#else
- static int input (void)
-#endif
-
-{
- int c;
-
- *(yy_c_buf_p) = (yy_hold_char);
-
- if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
- {
- /* yy_c_buf_p now points to the character we want to return.
- * If this occurs *before* the EOB characters, then it's a
- * valid NUL; if not, then we've hit the end of the buffer.
- */
- if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
- /* This was really a NUL. */
- *(yy_c_buf_p) = '\0';
-
- else
- { /* need more input */
- int offset = (yy_c_buf_p) - (yytext_ptr);
- ++(yy_c_buf_p);
-
- switch ( yy_get_next_buffer( ) )
- {
- case EOB_ACT_LAST_MATCH:
- /* This happens because yy_g_n_b()
- * sees that we've accumulated a
- * token and flags that we need to
- * try matching the token before
- * proceeding. But for input(),
- * there's no matching to consider.
- * So convert the EOB_ACT_LAST_MATCH
- * to EOB_ACT_END_OF_FILE.
- */
-
- /* Reset buffer status. */
- swf4restart(swf4in );
-
- /*FALLTHROUGH*/
-
- case EOB_ACT_END_OF_FILE:
- {
- if ( swf4wrap( ) )
- return EOF;
-
- if ( ! (yy_did_buffer_switch_on_eof) )
- YY_NEW_FILE;
-#ifdef __cplusplus
- return yyinput();
-#else
- return input();
-#endif
- }
-
- case EOB_ACT_CONTINUE_SCAN:
- (yy_c_buf_p) = (yytext_ptr) + offset;
- break;
- }
- }
- }
-
- c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
- *(yy_c_buf_p) = '\0'; /* preserve swf4text */
- (yy_hold_char) = *++(yy_c_buf_p);
-
- return c;
-}
-#endif /* ifndef YY_NO_INPUT */
-
-/** Immediately switch to a different input stream.
- * @param input_file A readable stream.
- *
- * @note This function does not reset the start condition to @c INITIAL .
- */
- void swf4restart (FILE * input_file )
-{
-
- if ( ! YY_CURRENT_BUFFER ){
- swf4ensure_buffer_stack ();
- YY_CURRENT_BUFFER_LVALUE =
- swf4_create_buffer(swf4in,YY_BUF_SIZE );
- }
-
- swf4_init_buffer(YY_CURRENT_BUFFER,input_file );
- swf4_load_buffer_state( );
-}
-
-/** Switch to a different input buffer.
- * @param new_buffer The new input buffer.
- *
- */
- void swf4_switch_to_buffer (YY_BUFFER_STATE new_buffer )
-{
-
- /* TODO. We should be able to replace this entire function body
- * with
- * swf4pop_buffer_state();
- * swf4push_buffer_state(new_buffer);
- */
- swf4ensure_buffer_stack ();
- if ( YY_CURRENT_BUFFER == new_buffer )
- return;
-
- if ( YY_CURRENT_BUFFER )
- {
- /* Flush out information for old buffer. */
- *(yy_c_buf_p) = (yy_hold_char);
- YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
- }
-
- YY_CURRENT_BUFFER_LVALUE = new_buffer;
- swf4_load_buffer_state( );
-
- /* We don't actually know whether we did this switch during
- * EOF (swf4wrap()) processing, but the only time this flag
- * is looked at is after swf4wrap() is called, so it's safe
- * to go ahead and always set it.
- */
- (yy_did_buffer_switch_on_eof) = 1;
-}
-
-static void swf4_load_buffer_state (void)
-{
- (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
- (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
- swf4in = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
- (yy_hold_char) = *(yy_c_buf_p);
-}
-
-/** Allocate and initialize an input buffer state.
- * @param file A readable stream.
- * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
- *
- * @return the allocated buffer state.
- */
- YY_BUFFER_STATE swf4_create_buffer (FILE * file, int size )
-{
- YY_BUFFER_STATE b;
-
- b = (YY_BUFFER_STATE) swf4alloc(sizeof( struct yy_buffer_state ) );
- if ( ! b )
- YY_FATAL_ERROR( "out of dynamic memory in swf4_create_buffer()" );
-
- b->yy_buf_size = size;
-
- /* yy_ch_buf has to be 2 characters longer than the size given because
- * we need to put in 2 end-of-buffer characters.
- */
- b->yy_ch_buf = (char *) swf4alloc(b->yy_buf_size + 2 );
- if ( ! b->yy_ch_buf )
- YY_FATAL_ERROR( "out of dynamic memory in swf4_create_buffer()" );
-
- b->yy_is_our_buffer = 1;
-
- swf4_init_buffer(b,file );
-
- return b;
-}
-
-/** Destroy the buffer.
- * @param b a buffer created with swf4_create_buffer()
- *
- */
- void swf4_delete_buffer (YY_BUFFER_STATE b )
-{
-
- if ( ! b )
- return;
-
- if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
- YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
-
- if ( b->yy_is_our_buffer )
- swf4free((void *) b->yy_ch_buf );
-
- swf4free((void *) b );
-}
-
-#ifndef _UNISTD_H /* assume unistd.h has isatty() for us */
-#ifdef __cplusplus
-extern "C" {
-#endif
-#ifdef __THROW /* this is a gnuism */
-extern int isatty (int ) __THROW;
-#else
-extern int isatty (int );
-#endif
-#ifdef __cplusplus
-}
-#endif
-#endif
-
-/* Initializes or reinitializes a buffer.
- * This function is sometimes called more than once on the same buffer,
- * such as during a swf4restart() or at EOF.
- */
- static void swf4_init_buffer (YY_BUFFER_STATE b, FILE * file )
-
-{
- int oerrno = errno;
-
- swf4_flush_buffer(b );
-
- b->yy_input_file = file;
- b->yy_fill_buffer = 1;
-
- /* If b is the current buffer, then swf4_init_buffer was _probably_
- * called from swf4restart() or through yy_get_next_buffer.
- * In that case, we don't want to reset the lineno or column.
- */
- if (b != YY_CURRENT_BUFFER){
- b->yy_bs_lineno = 1;
- b->yy_bs_column = 0;
- }
-
- b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
-
- errno = oerrno;
-}
-
-/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
- * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
- *
- */
- void swf4_flush_buffer (YY_BUFFER_STATE b )
-{
- if ( ! b )
- return;
-
- b->yy_n_chars = 0;
-
- /* We always need two end-of-buffer characters. The first causes
- * a transition to the end-of-buffer state. The second causes
- * a jam in that state.
- */
- b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
- b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
-
- b->yy_buf_pos = &b->yy_ch_buf[0];
-
- b->yy_at_bol = 1;
- b->yy_buffer_status = YY_BUFFER_NEW;
-
- if ( b == YY_CURRENT_BUFFER )
- swf4_load_buffer_state( );
-}
-
-/** Pushes the new state onto the stack. The new state becomes
- * the current state. This function will allocate the stack
- * if necessary.
- * @param new_buffer The new state.
- *
- */
-void swf4push_buffer_state (YY_BUFFER_STATE new_buffer )
-{
- if (new_buffer == NULL)
- return;
-
- swf4ensure_buffer_stack();
-
- /* This block is copied from swf4_switch_to_buffer. */
- if ( YY_CURRENT_BUFFER )
- {
- /* Flush out information for old buffer. */
- *(yy_c_buf_p) = (yy_hold_char);
- YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
- }
-
- /* Only push if top exists. Otherwise, replace top. */
- if (YY_CURRENT_BUFFER)
- (yy_buffer_stack_top)++;
- YY_CURRENT_BUFFER_LVALUE = new_buffer;
-
- /* copied from swf4_switch_to_buffer. */
- swf4_load_buffer_state( );
- (yy_did_buffer_switch_on_eof) = 1;
-}
-
-/** Removes and deletes the top of the stack, if present.
- * The next element becomes the new top.
- *
- */
-void swf4pop_buffer_state (void)
-{
- if (!YY_CURRENT_BUFFER)
- return;
-
- swf4_delete_buffer(YY_CURRENT_BUFFER );
- YY_CURRENT_BUFFER_LVALUE = NULL;
- if ((yy_buffer_stack_top) > 0)
- --(yy_buffer_stack_top);
-
- if (YY_CURRENT_BUFFER) {
- swf4_load_buffer_state( );
- (yy_did_buffer_switch_on_eof) = 1;
- }
-}
-
-/* Allocates the stack if it does not exist.
- * Guarantees space for at least one push.
- */
-static void swf4ensure_buffer_stack (void)
-{
- int num_to_alloc;
-
- if (!(yy_buffer_stack)) {
-
- /* First allocation is just for 2 elements, since we don't know if this
- * scanner will even need a stack. We use 2 instead of 1 to avoid an
- * immediate realloc on the next call.
- */
- num_to_alloc = 1;
- (yy_buffer_stack) = (struct yy_buffer_state**)swf4alloc
- (num_to_alloc * sizeof(struct yy_buffer_state*)
- );
-
- memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
-
- (yy_buffer_stack_max) = num_to_alloc;
- (yy_buffer_stack_top) = 0;
- return;
- }
-
- if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
-
- /* Increase the buffer to prepare for a possible push. */
- int grow_size = 8 /* arbitrary grow size */;
-
- num_to_alloc = (yy_buffer_stack_max) + grow_size;
- (yy_buffer_stack) = (struct yy_buffer_state**)swf4realloc
- ((yy_buffer_stack),
- num_to_alloc * sizeof(struct yy_buffer_state*)
- );
-
- /* zero only the new slots.*/
- memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
- (yy_buffer_stack_max) = num_to_alloc;
- }
-}
-
-/** Setup the input buffer state to scan directly from a user-specified character buffer.
- * @param base the character buffer
- * @param size the size in bytes of the character buffer
- *
- * @return the newly allocated buffer state object.
- */
-YY_BUFFER_STATE swf4_scan_buffer (char * base, yy_size_t size )
-{
- YY_BUFFER_STATE b;
-
- if ( size < 2 ||
- base[size-2] != YY_END_OF_BUFFER_CHAR ||
- base[size-1] != YY_END_OF_BUFFER_CHAR )
- /* They forgot to leave room for the EOB's. */
- return 0;
-
- b = (YY_BUFFER_STATE) swf4alloc(sizeof( struct yy_buffer_state ) );
- if ( ! b )
- YY_FATAL_ERROR( "out of dynamic memory in swf4_scan_buffer()" );
-
- b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
- b->yy_buf_pos = b->yy_ch_buf = base;
- b->yy_is_our_buffer = 0;
- b->yy_input_file = 0;
- b->yy_n_chars = b->yy_buf_size;
- b->yy_is_interactive = 0;
- b->yy_at_bol = 1;
- b->yy_fill_buffer = 0;
- b->yy_buffer_status = YY_BUFFER_NEW;
-
- swf4_switch_to_buffer(b );
-
- return b;
-}
-
-/** Setup the input buffer state to scan a string. The next call to swf4lex() will
- * scan from a @e copy of @a str.
- * @param str a NUL-terminated string to scan
- *
- * @return the newly allocated buffer state object.
- * @note If you want to scan bytes that may contain NUL values, then use
- * swf4_scan_bytes() instead.
- */
-YY_BUFFER_STATE swf4_scan_string (yyconst char * yystr )
-{
-
- return swf4_scan_bytes(yystr,strlen(yystr) );
-}
-
-/** Setup the input buffer state to scan the given bytes. The next call to swf4lex() will
- * scan from a @e copy of @a bytes.
- * @param bytes the byte buffer to scan
- * @param len the number of bytes in the buffer pointed to by @a bytes.
- *
- * @return the newly allocated buffer state object.
- */
-YY_BUFFER_STATE swf4_scan_bytes (yyconst char * yybytes, int _yybytes_len )
-{
- YY_BUFFER_STATE b;
- char *buf;
- yy_size_t n;
- int i;
-
- /* Get memory for full buffer, including space for trailing EOB's. */
- n = _yybytes_len + 2;
- buf = (char *) swf4alloc(n );
- if ( ! buf )
- YY_FATAL_ERROR( "out of dynamic memory in swf4_scan_bytes()" );
-
- for ( i = 0; i < _yybytes_len; ++i )
- buf[i] = yybytes[i];
-
- buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
-
- b = swf4_scan_buffer(buf,n );
- if ( ! b )
- YY_FATAL_ERROR( "bad buffer in swf4_scan_bytes()" );
-
- /* It's okay to grow etc. this buffer, and we should throw it
- * away when we're done.
- */
- b->yy_is_our_buffer = 1;
-
- return b;
-}
-
-#ifndef YY_EXIT_FAILURE
-#define YY_EXIT_FAILURE 2
-#endif
-
-static void yy_fatal_error (yyconst char* msg )
-{
- (void) fprintf( stderr, "%s\n", msg );
- exit( YY_EXIT_FAILURE );
-}
-
-/* Redefine yyless() so it works in section 3 code. */
-
-#undef yyless
-#define yyless(n) \
- do \
- { \
- /* Undo effects of setting up swf4text. */ \
- int yyless_macro_arg = (n); \
- YY_LESS_LINENO(yyless_macro_arg);\
- swf4text[swf4leng] = (yy_hold_char); \
- (yy_c_buf_p) = swf4text + yyless_macro_arg; \
- (yy_hold_char) = *(yy_c_buf_p); \
- *(yy_c_buf_p) = '\0'; \
- swf4leng = yyless_macro_arg; \
- } \
- while ( 0 )
-
-/* Accessor methods (get/set functions) to struct members. */
-
-/** Get the current line number.
- *
- */
-int swf4get_lineno (void)
-{
-
- return swf4lineno;
-}
-
-/** Get the input stream.
- *
- */
-FILE *swf4get_in (void)
-{
- return swf4in;
-}
-
-/** Get the output stream.
- *
- */
-FILE *swf4get_out (void)
-{
- return swf4out;
-}
-
-/** Get the length of the current token.
- *
- */
-int swf4get_leng (void)
-{
- return swf4leng;
-}
-
-/** Get the current token.
- *
- */
-
-char *swf4get_text (void)
-{
- return swf4text;
-}
-
-/** Set the current line number.
- * @param line_number
- *
- */
-void swf4set_lineno (int line_number )
-{
-
- swf4lineno = line_number;
-}
-
-/** Set the input stream. This does not discard the current
- * input buffer.
- * @param in_str A readable stream.
- *
- * @see swf4_switch_to_buffer
- */
-void swf4set_in (FILE * in_str )
-{
- swf4in = in_str ;
-}
-
-void swf4set_out (FILE * out_str )
-{
- swf4out = out_str ;
-}
-
-int swf4get_debug (void)
-{
- return swf4_flex_debug;
-}
-
-void swf4set_debug (int bdebug )
-{
- swf4_flex_debug = bdebug ;
-}
-
-static int yy_init_globals (void)
-{
- /* Initialization is the same as for the non-reentrant scanner.
- * This function is called from swf4lex_destroy(), so don't allocate here.
- */
-
- (yy_buffer_stack) = 0;
- (yy_buffer_stack_top) = 0;
- (yy_buffer_stack_max) = 0;
- (yy_c_buf_p) = (char *) 0;
- (yy_init) = 0;
- (yy_start) = 0;
-
-/* Defined in main.c */
-#ifdef YY_STDINIT
- swf4in = stdin;
- swf4out = stdout;
-#else
- swf4in = (FILE *) 0;
- swf4out = (FILE *) 0;
-#endif
-
- /* For future reference: Set errno on error, since we are called by
- * swf4lex_init()
- */
- return 0;
-}
-
-/* swf4lex_destroy is for both reentrant and non-reentrant scanners. */
-int swf4lex_destroy (void)
-{
-
- /* Pop the buffer stack, destroying each element. */
- while(YY_CURRENT_BUFFER){
- swf4_delete_buffer(YY_CURRENT_BUFFER );
- YY_CURRENT_BUFFER_LVALUE = NULL;
- swf4pop_buffer_state();
- }
-
- /* Destroy the stack itself. */
- swf4free((yy_buffer_stack) );
- (yy_buffer_stack) = NULL;
-
- /* Reset the globals. This is important in a non-reentrant scanner so the next time
- * swf4lex() is called, initialization will occur. */
- yy_init_globals( );
-
- return 0;
-}
-
-/*
- * Internal utility routines.
- */
-
-#ifndef yytext_ptr
-static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
-{
- register int i;
- for ( i = 0; i < n; ++i )
- s1[i] = s2[i];
-}
-#endif
-
-#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen (yyconst char * s )
-{
- register int n;
- for ( n = 0; s[n]; ++n )
- ;
-
- return n;
-}
-#endif
-
-void *swf4alloc (yy_size_t size )
-{
- return (void *) malloc( size );
-}
-
-void *swf4realloc (void * ptr, yy_size_t size )
-{
- /* The cast to (char *) in the following accommodates both
- * implementations that use char* generic pointers, and those
- * that use void* generic pointers. It works with the latter
- * because both ANSI C and C++ allow castless assignment from
- * any pointer type to void*, and deal with argument conversions
- * as though doing an assignment.
- */
- return (void *) realloc( (char *) ptr, size );
-}
-
-void swf4free (void * ptr )
-{
- free( (char *) ptr ); /* see swf4realloc() for (char *) cast */
-}
-
-#define YYTABLES_NAME "yytables"
-
-#line 239 "swf4compiler.flex"
-
-
-static int getinput() {
-#ifdef __cplusplus
- return yyinput();
-#else
- return input();
-#endif
-}
-
-int swf4wrap()
-{
- return 1;
-}
-
-static void countline()
-{
- if(sLineNumber != 0)
- msgline[column] = 0;
-
- ++sLineNumber;
- column = 0;
- msgline = msgbufs[sLineNumber & 1];
-}
-
-static int LineNumber(void)
-{
- return (sLineNumber + 1);
-}
-
-static int ColumnNumber(void)
-{
- return column;
-}
-
-static char *LineText(void)
-{
- msgline[column] = 0;
- return msgline;
-}
-
-static void comment(void)
-{
- // Handle block comments
-
- int c, c1;
-
-loop:
- // We have the start of a comment so look skip everything up to the
- // end of the comment character
- while ((c = getinput()) != '*' && c != EOF)
- {
- if(column < 1023)
- msgline[column] = c;
-
- ++column;
-
- // keep the line number in synch
- if (c == '\n')
- {
- // start the output (matches the algorithim in the lexx above)
- countline();
- }
-
- if (swf4debug) putchar(c);
- }
-
- // is this the end of comment character
- if ((c1 = getinput()) != '/' && c != EOF)
- {
- // false start as this was no end of comment
- do_unput4(c1);
- goto loop;
- }
-
- // write out the start of the end of comment
- if (c != EOF)
- if (swf4debug) putchar(c);
-
- // write out the end of the end of comment
- if (c1 != EOF)
- if (swf4debug) putchar(c1);
-}
-
-static void comment1(void)
-{
- // Handle comment of type 1 (ie '//')
-
- int c;
-
- // this is a line comment
- while ((c = getinput()) != '\n' && c != EOF)
- {
- if (swf4debug) putchar(c);
-
- if(column < 1023)
- msgline[column] = c;
-
- ++column;
- };
-
- // keep the line number in synch
- if (c == '\n')
- {
- if (swf4debug) putchar(c);
-
- countline();
- }
-}
-
-static void count(void)
-{
- int n;
-
- // Count the characters to maintain the current column position
- if (swf4text[0] == '\n')
- {
- if (swf4debug) printf("\n");
- }
- else
- {
- if (swf4debug) printf("%s", swf4text);
-
- for(n=0; n<swf4leng; ++n, ++column)
- {
- if(column < 1023)
- msgline[column] = swf4text[n];
- }
-
- //-- keep writing the stuff to standard output
- //column += swf4leng;
- }
-}
-
-static void printprog()
-{
- if(sLineNumber)
- SWF_warn("\n%s", msgbufs[(sLineNumber-1)&1]);
-
- if(column < 1023)
- msgline[column] = 0;
-
- SWF_warn("\n%s", msgline);
-}
-
-static void warning(char *msg)
-{
- // print a warning message
- printprog();
- SWF_warn("\n%*s", ColumnNumber(), "^");
- SWF_warn("\nLine %4.4d: Reason: '%s' \n", LineNumber(), msg);
-}
-
-void swf4error(char *msg)
-{
- // report a error
- if(strlen(swf4text))
- {
- SWF_error("\n%s\n%*s\nLine %i: Reason: '%s'\n",
- LineText(), ColumnNumber(), "^", LineNumber(), msg);
- }
- else
- {
- SWF_error("\nLine %d: Reason: 'Unexpected EOF found while looking for input.'\n", LineNumber());
- }
-}
-
+++ /dev/null
-
-#line 3 "lex.swf5.c"
-
-#define YY_INT_ALIGNED short int
-
-/* A lexical scanner generated by flex */
-
-#define FLEX_SCANNER
-#define YY_FLEX_MAJOR_VERSION 2
-#define YY_FLEX_MINOR_VERSION 5
-#define YY_FLEX_SUBMINOR_VERSION 33
-#if YY_FLEX_SUBMINOR_VERSION > 0
-#define FLEX_BETA
-#endif
-
-/* First, we deal with platform-specific or compiler-specific issues. */
-
-/* begin standard C headers. */
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <stdlib.h>
-
-/* end standard C headers. */
-
-/* flex integer type definitions */
-
-#ifndef FLEXINT_H
-#define FLEXINT_H
-
-/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
-
-#if __STDC_VERSION__ >= 199901L
-
-/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
- * if you want the limit (max/min) macros for int types.
- */
-#ifndef __STDC_LIMIT_MACROS
-#define __STDC_LIMIT_MACROS 1
-#endif
-
-#include <inttypes.h>
-typedef int8_t flex_int8_t;
-typedef uint8_t flex_uint8_t;
-typedef int16_t flex_int16_t;
-typedef uint16_t flex_uint16_t;
-typedef int32_t flex_int32_t;
-typedef uint32_t flex_uint32_t;
-#else
-typedef signed char flex_int8_t;
-typedef short int flex_int16_t;
-typedef int flex_int32_t;
-typedef unsigned char flex_uint8_t;
-typedef unsigned short int flex_uint16_t;
-typedef unsigned int flex_uint32_t;
-#endif /* ! C99 */
-
-/* Limits of integral types. */
-#ifndef INT8_MIN
-#define INT8_MIN (-128)
-#endif
-#ifndef INT16_MIN
-#define INT16_MIN (-32767-1)
-#endif
-#ifndef INT32_MIN
-#define INT32_MIN (-2147483647-1)
-#endif
-#ifndef INT8_MAX
-#define INT8_MAX (127)
-#endif
-#ifndef INT16_MAX
-#define INT16_MAX (32767)
-#endif
-#ifndef INT32_MAX
-#define INT32_MAX (2147483647)
-#endif
-#ifndef UINT8_MAX
-#define UINT8_MAX (255U)
-#endif
-#ifndef UINT16_MAX
-#define UINT16_MAX (65535U)
-#endif
-#ifndef UINT32_MAX
-#define UINT32_MAX (4294967295U)
-#endif
-
-#endif /* ! FLEXINT_H */
-
-#ifdef __cplusplus
-
-/* The "const" storage-class-modifier is valid. */
-#define YY_USE_CONST
-
-#else /* ! __cplusplus */
-
-#if __STDC__
-
-#define YY_USE_CONST
-
-#endif /* __STDC__ */
-#endif /* ! __cplusplus */
-
-#ifdef YY_USE_CONST
-#define yyconst const
-#else
-#define yyconst
-#endif
-
-/* Returned upon end-of-file. */
-#define YY_NULL 0
-
-/* Promotes a possibly negative, possibly signed char to an unsigned
- * integer for use as an array index. If the signed char is negative,
- * we want to instead treat it as an 8-bit unsigned char, hence the
- * double cast.
- */
-#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
-
-/* Enter a start condition. This macro really ought to take a parameter,
- * but we do it the disgusting crufty way forced on us by the ()-less
- * definition of BEGIN.
- */
-#define BEGIN (yy_start) = 1 + 2 *
-
-/* Translate the current start state into a value that can be later handed
- * to BEGIN to return to the state. The YYSTATE alias is for lex
- * compatibility.
- */
-#define YY_START (((yy_start) - 1) / 2)
-#define YYSTATE YY_START
-
-/* Action number for EOF rule of a given start state. */
-#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
-
-/* Special action meaning "start processing a new file". */
-#define YY_NEW_FILE swf5restart(swf5in )
-
-#define YY_END_OF_BUFFER_CHAR 0
-
-/* Size of default input buffer. */
-#ifndef YY_BUF_SIZE
-#define YY_BUF_SIZE 16384
-#endif
-
-/* The state buf must be large enough to hold one state per character in the main buffer.
- */
-#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
-
-#ifndef YY_TYPEDEF_YY_BUFFER_STATE
-#define YY_TYPEDEF_YY_BUFFER_STATE
-typedef struct yy_buffer_state *YY_BUFFER_STATE;
-#endif
-
-extern int swf5leng;
-
-extern FILE *swf5in, *swf5out;
-
-#define EOB_ACT_CONTINUE_SCAN 0
-#define EOB_ACT_END_OF_FILE 1
-#define EOB_ACT_LAST_MATCH 2
-
- #define YY_LESS_LINENO(n)
-
-/* Return all but the first "n" matched characters back to the input stream. */
-#define yyless(n) \
- do \
- { \
- /* Undo effects of setting up swf5text. */ \
- int yyless_macro_arg = (n); \
- YY_LESS_LINENO(yyless_macro_arg);\
- *yy_cp = (yy_hold_char); \
- YY_RESTORE_YY_MORE_OFFSET \
- (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
- YY_DO_BEFORE_ACTION; /* set up swf5text again */ \
- } \
- while ( 0 )
-
-#define unput(c) yyunput( c, (yytext_ptr) )
-
-/* The following is because we cannot portably get our hands on size_t
- * (without autoconf's help, which isn't available because we want
- * flex-generated scanners to compile on their own).
- */
-
-#ifndef YY_TYPEDEF_YY_SIZE_T
-#define YY_TYPEDEF_YY_SIZE_T
-typedef unsigned int yy_size_t;
-#endif
-
-#ifndef YY_STRUCT_YY_BUFFER_STATE
-#define YY_STRUCT_YY_BUFFER_STATE
-struct yy_buffer_state
- {
- FILE *yy_input_file;
-
- char *yy_ch_buf; /* input buffer */
- char *yy_buf_pos; /* current position in input buffer */
-
- /* Size of input buffer in bytes, not including room for EOB
- * characters.
- */
- yy_size_t yy_buf_size;
-
- /* Number of characters read into yy_ch_buf, not including EOB
- * characters.
- */
- int yy_n_chars;
-
- /* Whether we "own" the buffer - i.e., we know we created it,
- * and can realloc() it to grow it, and should free() it to
- * delete it.
- */
- int yy_is_our_buffer;
-
- /* Whether this is an "interactive" input source; if so, and
- * if we're using stdio for input, then we want to use getc()
- * instead of fread(), to make sure we stop fetching input after
- * each newline.
- */
- int yy_is_interactive;
-
- /* Whether we're considered to be at the beginning of a line.
- * If so, '^' rules will be active on the next match, otherwise
- * not.
- */
- int yy_at_bol;
-
- int yy_bs_lineno; /**< The line count. */
- int yy_bs_column; /**< The column count. */
-
- /* Whether to try to fill the input buffer when we reach the
- * end of it.
- */
- int yy_fill_buffer;
-
- int yy_buffer_status;
-
-#define YY_BUFFER_NEW 0
-#define YY_BUFFER_NORMAL 1
- /* When an EOF's been seen but there's still some text to process
- * then we mark the buffer as YY_EOF_PENDING, to indicate that we
- * shouldn't try reading from the input source any more. We might
- * still have a bunch of tokens to match, though, because of
- * possible backing-up.
- *
- * When we actually see the EOF, we change the status to "new"
- * (via swf5restart()), so that the user can continue scanning by
- * just pointing swf5in at a new input file.
- */
-#define YY_BUFFER_EOF_PENDING 2
-
- };
-#endif /* !YY_STRUCT_YY_BUFFER_STATE */
-
-/* Stack of input buffers. */
-static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
-static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
-static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
-
-/* We provide macros for accessing buffer states in case in the
- * future we want to put the buffer states in a more general
- * "scanner state".
- *
- * Returns the top of the stack, or NULL.
- */
-#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
- ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
- : NULL)
-
-/* Same as previous macro, but useful when we know that the buffer stack is not
- * NULL or when we need an lvalue. For internal use only.
- */
-#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
-
-/* yy_hold_char holds the character lost when swf5text is formed. */
-static char yy_hold_char;
-static int yy_n_chars; /* number of characters read into yy_ch_buf */
-int swf5leng;
-
-/* Points to current character in buffer. */
-static char *yy_c_buf_p = (char *) 0;
-static int yy_init = 0; /* whether we need to initialize */
-static int yy_start = 0; /* start state number */
-
-/* Flag which is used to allow swf5wrap()'s to do buffer switches
- * instead of setting up a fresh swf5in. A bit of a hack ...
- */
-static int yy_did_buffer_switch_on_eof;
-
-void swf5restart (FILE *input_file );
-void swf5_switch_to_buffer (YY_BUFFER_STATE new_buffer );
-YY_BUFFER_STATE swf5_create_buffer (FILE *file,int size );
-void swf5_delete_buffer (YY_BUFFER_STATE b );
-void swf5_flush_buffer (YY_BUFFER_STATE b );
-void swf5push_buffer_state (YY_BUFFER_STATE new_buffer );
-void swf5pop_buffer_state (void );
-
-static void swf5ensure_buffer_stack (void );
-static void swf5_load_buffer_state (void );
-static void swf5_init_buffer (YY_BUFFER_STATE b,FILE *file );
-
-#define YY_FLUSH_BUFFER swf5_flush_buffer(YY_CURRENT_BUFFER )
-
-YY_BUFFER_STATE swf5_scan_buffer (char *base,yy_size_t size );
-YY_BUFFER_STATE swf5_scan_string (yyconst char *yy_str );
-YY_BUFFER_STATE swf5_scan_bytes (yyconst char *bytes,int len );
-
-void *swf5alloc (yy_size_t );
-void *swf5realloc (void *,yy_size_t );
-void swf5free (void * );
-
-#define yy_new_buffer swf5_create_buffer
-
-#define yy_set_interactive(is_interactive) \
- { \
- if ( ! YY_CURRENT_BUFFER ){ \
- swf5ensure_buffer_stack (); \
- YY_CURRENT_BUFFER_LVALUE = \
- swf5_create_buffer(swf5in,YY_BUF_SIZE ); \
- } \
- YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
- }
-
-#define yy_set_bol(at_bol) \
- { \
- if ( ! YY_CURRENT_BUFFER ){\
- swf5ensure_buffer_stack (); \
- YY_CURRENT_BUFFER_LVALUE = \
- swf5_create_buffer(swf5in,YY_BUF_SIZE ); \
- } \
- YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
- }
-
-#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
-
-/* Begin user sect3 */
-
-typedef unsigned char YY_CHAR;
-
-FILE *swf5in = (FILE *) 0, *swf5out = (FILE *) 0;
-
-typedef int yy_state_type;
-
-extern int swf5lineno;
-
-int swf5lineno = 1;
-
-extern char *swf5text;
-#define yytext_ptr swf5text
-
-static yy_state_type yy_get_previous_state (void );
-static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
-static int yy_get_next_buffer (void );
-static void yy_fatal_error (yyconst char msg[] );
-
-/* Done after the current pattern has been matched and before the
- * corresponding action - sets up swf5text.
- */
-#define YY_DO_BEFORE_ACTION \
- (yytext_ptr) = yy_bp; \
- swf5leng = (size_t) (yy_cp - yy_bp); \
- (yy_hold_char) = *yy_cp; \
- *yy_cp = '\0'; \
- (yy_c_buf_p) = yy_cp;
-
-#define YY_NUM_RULES 166
-#define YY_END_OF_BUFFER 167
-/* This struct is not used in this scanner,
- but its presence is necessary. */
-struct yy_trans_info
- {
- flex_int32_t yy_verify;
- flex_int32_t yy_nxt;
- };
-static yyconst flex_int16_t yy_accept[650] =
- { 0,
- 0, 0, 0, 0, 167, 165, 119, 164, 165, 152,
- 165, 151, 146, 165, 153, 154, 149, 144, 159, 145,
- 160, 150, 3, 3, 162, 142, 140, 143, 141, 161,
- 155, 156, 148, 112, 112, 112, 112, 112, 112, 112,
- 112, 112, 112, 112, 112, 112, 112, 112, 112, 112,
- 112, 157, 147, 158, 163, 112, 112, 112, 112, 112,
- 112, 112, 112, 112, 112, 112, 112, 112, 112, 112,
- 164, 125, 0, 115, 113, 0, 126, 132, 0, 116,
- 114, 0, 128, 120, 130, 121, 131, 117, 118, 129,
- 4, 2, 3, 0, 134, 122, 124, 123, 135, 112,
-
- 112, 112, 112, 112, 112, 112, 19, 112, 112, 112,
- 112, 112, 112, 112, 112, 17, 16, 112, 112, 112,
- 112, 112, 112, 112, 0, 112, 112, 112, 112, 112,
- 112, 112, 112, 112, 112, 112, 112, 133, 127, 112,
- 112, 112, 112, 112, 112, 112, 112, 112, 112, 16,
- 112, 112, 112, 112, 112, 112, 112, 112, 63, 112,
- 112, 112, 112, 112, 112, 112, 112, 112, 4, 1,
- 137, 138, 136, 25, 112, 112, 112, 37, 112, 112,
- 112, 112, 112, 112, 112, 15, 112, 112, 112, 112,
- 35, 112, 112, 21, 112, 112, 36, 112, 112, 111,
-
- 112, 112, 112, 112, 112, 112, 112, 112, 112, 112,
- 112, 20, 112, 112, 66, 62, 112, 112, 73, 112,
- 55, 110, 112, 112, 109, 72, 112, 112, 112, 112,
- 112, 112, 112, 112, 112, 21, 91, 112, 57, 112,
- 112, 112, 112, 112, 112, 112, 112, 112, 20, 64,
- 139, 112, 112, 13, 112, 112, 112, 112, 112, 11,
- 26, 112, 112, 112, 112, 112, 112, 112, 112, 112,
- 7, 42, 112, 112, 112, 112, 112, 43, 112, 112,
- 112, 112, 5, 112, 112, 24, 112, 112, 112, 112,
- 112, 112, 112, 112, 112, 112, 112, 112, 112, 112,
-
- 112, 112, 112, 112, 112, 112, 112, 112, 108, 58,
- 112, 112, 112, 112, 112, 112, 43, 112, 112, 112,
- 56, 112, 8, 112, 112, 112, 112, 112, 112, 6,
- 112, 112, 112, 112, 112, 112, 112, 112, 112, 112,
- 112, 112, 112, 112, 112, 112, 112, 112, 34, 112,
- 18, 112, 112, 112, 112, 112, 112, 112, 112, 112,
- 112, 112, 112, 104, 112, 103, 112, 112, 112, 112,
- 112, 112, 112, 112, 112, 112, 112, 112, 112, 112,
- 112, 112, 112, 112, 112, 112, 112, 32, 112, 112,
- 22, 112, 112, 112, 38, 112, 112, 31, 112, 112,
-
- 112, 112, 29, 112, 23, 112, 112, 33, 12, 112,
- 27, 105, 112, 112, 86, 112, 70, 112, 112, 112,
- 112, 112, 112, 112, 112, 65, 112, 67, 112, 112,
- 83, 112, 112, 112, 112, 112, 112, 112, 112, 112,
- 112, 112, 33, 112, 112, 112, 112, 14, 112, 112,
- 112, 39, 112, 112, 112, 112, 112, 112, 112, 112,
- 112, 112, 112, 112, 112, 112, 112, 112, 112, 112,
- 112, 112, 112, 112, 112, 112, 112, 112, 112, 112,
- 112, 112, 112, 112, 112, 112, 112, 112, 112, 112,
- 112, 112, 112, 112, 9, 112, 10, 30, 112, 112,
-
- 112, 112, 112, 112, 112, 112, 112, 112, 112, 112,
- 112, 112, 112, 112, 112, 112, 112, 68, 112, 112,
- 101, 112, 85, 112, 112, 112, 112, 112, 112, 112,
- 112, 112, 112, 112, 99, 92, 112, 112, 84, 112,
- 46, 112, 47, 112, 50, 112, 40, 41, 112, 48,
- 112, 112, 112, 112, 112, 112, 74, 77, 112, 76,
- 112, 112, 90, 112, 71, 112, 87, 112, 78, 112,
- 48, 112, 79, 112, 98, 112, 112, 94, 82, 112,
- 28, 112, 112, 112, 45, 112, 112, 112, 112, 61,
- 112, 75, 89, 112, 112, 112, 112, 112, 112, 80,
-
- 112, 112, 112, 112, 112, 112, 112, 112, 112, 112,
- 95, 102, 69, 88, 59, 112, 96, 81, 112, 112,
- 112, 52, 112, 112, 112, 106, 107, 60, 112, 93,
- 112, 112, 49, 112, 44, 97, 112, 112, 112, 112,
- 100, 112, 112, 54, 112, 51, 112, 53, 0
- } ;
-
-static yyconst flex_int32_t yy_ec[256] =
- { 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
- 2, 2, 4, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 2, 5, 6, 1, 1, 7, 8, 9, 10,
- 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
- 21, 21, 21, 21, 21, 22, 22, 23, 24, 25,
- 26, 27, 28, 1, 34, 35, 36, 37, 38, 39,
- 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
- 50, 51, 52, 53, 54, 55, 56, 57, 58, 33,
- 29, 30, 31, 32, 33, 1, 34, 35, 36, 37,
-
- 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
- 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
- 58, 33, 59, 60, 61, 62, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1
- } ;
-
-static yyconst flex_int32_t yy_meta[63] =
- { 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 2, 2, 2,
- 2, 2, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 3, 2, 2, 2, 2, 2, 2, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 1, 1,
- 1, 1
- } ;
-
-static yyconst flex_int16_t yy_base[654] =
- { 0,
- 0, 0, 29, 0, 741, 742, 742, 742, 737, 713,
- 67, 742, 64, 76, 742, 742, 712, 67, 742, 68,
- 742, 70, 82, 89, 742, 742, 63, 711, 65, 742,
- 742, 742, 742, 0, 684, 684, 78, 75, 69, 82,
- 77, 81, 79, 80, 683, 86, 109, 95, 87, 699,
- 80, 742, 114, 742, 742, 105, 681, 112, 116, 116,
- 117, 120, 124, 121, 130, 99, 128, 139, 697, 682,
- 742, 742, 180, 182, 742, 726, 742, 742, 178, 187,
- 742, 725, 742, 742, 742, 742, 742, 742, 742, 742,
- 179, 200, 207, 0, 701, 742, 742, 742, 176, 0,
-
- 680, 687, 159, 673, 676, 168, 0, 673, 669, 686,
- 674, 667, 670, 663, 662, 0, 153, 667, 679, 158,
- 667, 674, 676, 671, 212, 661, 189, 654, 658, 670,
- 662, 663, 155, 653, 650, 658, 646, 742, 742, 661,
- 660, 61, 191, 201, 641, 646, 187, 640, 640, 202,
- 198, 213, 212, 655, 646, 195, 637, 652, 651, 142,
- 635, 633, 643, 215, 649, 225, 632, 631, 250, 0,
- 742, 742, 655, 0, 646, 634, 640, 0, 203, 643,
- 638, 630, 636, 628, 620, 0, 635, 208, 622, 616,
- 0, 628, 630, 0, 613, 620, 0, 606, 608, 255,
-
- 625, 613, 606, 606, 609, 605, 603, 615, 618, 615,
- 614, 0, 606, 609, 0, 0, 602, 603, 0, 605,
- 601, 0, 599, 610, 232, 0, 590, 590, 599, 599,
- 601, 587, 583, 582, 582, 245, 0, 246, 0, 581,
- 592, 242, 593, 580, 581, 587, 229, 579, 589, 0,
- 742, 582, 586, 0, 590, 581, 568, 568, 578, 0,
- 0, 581, 565, 575, 565, 576, 580, 560, 243, 573,
- 0, 0, 572, 562, 554, 557, 573, 554, 552, 568,
- 558, 564, 0, 553, 562, 0, 563, 219, 561, 559,
- 551, 557, 560, 258, 540, 556, 540, 543, 552, 553,
-
- 542, 544, 548, 534, 545, 545, 531, 542, 0, 0,
- 541, 540, 543, 542, 522, 521, 257, 526, 519, 520,
- 0, 520, 0, 518, 515, 520, 521, 527, 528, 0,
- 521, 516, 516, 509, 512, 517, 509, 522, 504, 503,
- 507, 514, 504, 499, 501, 497, 506, 508, 0, 506,
- 0, 503, 245, 505, 504, 490, 488, 493, 487, 486,
- 501, 494, 500, 0, 493, 0, 480, 483, 481, 492,
- 474, 475, 489, 471, 472, 477, 482, 470, 469, 256,
- 482, 467, 477, 465, 481, 460, 479, 0, 458, 458,
- 0, 476, 461, 470, 488, 472, 469, 0, 449, 452,
-
- 468, 467, 0, 454, 0, 459, 444, 0, 0, 447,
- 0, 266, 449, 442, 0, 460, 0, 458, 450, 440,
- 447, 455, 443, 434, 433, 0, 440, 0, 450, 431,
- 0, 448, 429, 445, 437, 438, 435, 438, 433, 423,
- 439, 265, 430, 435, 436, 423, 430, 0, 414, 419,
- 414, 0, 418, 425, 420, 419, 414, 413, 410, 419,
- 409, 401, 409, 414, 416, 410, 397, 411, 414, 413,
- 408, 398, 268, 403, 392, 384, 396, 387, 394, 385,
- 399, 384, 397, 400, 394, 392, 397, 390, 379, 390,
- 380, 373, 380, 386, 0, 385, 0, 0, 384, 373,
-
- 382, 385, 380, 379, 361, 362, 377, 379, 356, 358,
- 357, 361, 370, 356, 371, 347, 368, 0, 356, 351,
- 0, 359, 0, 348, 358, 346, 356, 345, 342, 341,
- 358, 339, 350, 350, 0, 0, 265, 349, 0, 336,
- 0, 341, 0, 347, 338, 349, 0, 0, 341, 0,
- 330, 336, 346, 328, 336, 340, 0, 0, 331, 0,
- 322, 337, 0, 326, 0, 338, 0, 337, 0, 332,
- 331, 323, 0, 314, 0, 326, 313, 0, 0, 316,
- 0, 309, 317, 323, 0, 318, 301, 304, 309, 0,
- 318, 0, 0, 315, 307, 306, 301, 294, 312, 329,
-
- 295, 294, 291, 299, 306, 307, 289, 289, 302, 292,
- 0, 0, 0, 0, 0, 289, 0, 0, 296, 295,
- 293, 0, 282, 288, 274, 0, 0, 0, 280, 0,
- 296, 291, 281, 285, 0, 0, 279, 279, 260, 264,
- 0, 266, 259, 0, 262, 0, 92, 0, 742, 317,
- 320, 322, 66
- } ;
-
-static yyconst flex_int16_t yy_def[654] =
- { 0,
- 649, 1, 1, 3, 649, 649, 649, 649, 649, 649,
- 650, 649, 649, 651, 649, 649, 649, 649, 649, 649,
- 649, 649, 649, 649, 649, 649, 649, 649, 649, 649,
- 649, 649, 649, 652, 652, 652, 652, 652, 652, 652,
- 652, 652, 652, 652, 652, 652, 652, 652, 652, 652,
- 652, 649, 649, 649, 649, 652, 652, 652, 652, 652,
- 652, 652, 652, 652, 652, 652, 652, 652, 652, 652,
- 649, 649, 650, 650, 649, 650, 649, 649, 651, 651,
- 649, 651, 649, 649, 649, 649, 649, 649, 649, 649,
- 649, 649, 649, 653, 649, 649, 649, 649, 649, 652,
-
- 652, 652, 652, 652, 652, 652, 652, 652, 652, 652,
- 652, 652, 652, 652, 652, 652, 652, 652, 652, 652,
- 652, 652, 652, 652, 649, 652, 652, 652, 652, 652,
- 652, 652, 652, 652, 652, 652, 652, 649, 649, 652,
- 652, 652, 652, 652, 652, 652, 652, 652, 652, 652,
- 652, 652, 652, 652, 652, 652, 652, 652, 652, 652,
- 652, 652, 652, 652, 652, 652, 652, 652, 649, 653,
- 649, 649, 649, 652, 652, 652, 652, 652, 652, 652,
- 652, 652, 652, 652, 652, 652, 652, 652, 652, 652,
- 652, 652, 652, 652, 652, 652, 652, 652, 652, 649,
-
- 652, 652, 652, 652, 652, 652, 652, 652, 652, 652,
- 652, 652, 652, 652, 652, 652, 652, 652, 652, 652,
- 652, 652, 652, 652, 652, 652, 652, 652, 652, 652,
- 652, 652, 652, 652, 652, 652, 652, 652, 652, 652,
- 652, 652, 652, 652, 652, 652, 652, 652, 652, 652,
- 649, 652, 652, 652, 652, 652, 652, 652, 652, 652,
- 652, 652, 652, 652, 652, 652, 652, 652, 652, 652,
- 652, 652, 652, 652, 652, 652, 652, 652, 652, 652,
- 652, 652, 652, 652, 652, 652, 652, 652, 652, 652,
- 652, 652, 652, 652, 652, 652, 652, 652, 652, 652,
-
- 652, 652, 652, 652, 652, 652, 652, 652, 652, 652,
- 652, 652, 652, 652, 652, 652, 652, 652, 652, 652,
- 652, 652, 652, 652, 652, 652, 652, 652, 652, 652,
- 652, 652, 652, 652, 652, 652, 652, 652, 652, 652,
- 652, 652, 652, 652, 652, 652, 652, 652, 652, 652,
- 652, 652, 652, 652, 652, 652, 652, 652, 652, 652,
- 652, 652, 652, 652, 652, 652, 652, 652, 652, 652,
- 652, 652, 652, 652, 652, 652, 652, 652, 652, 652,
- 652, 652, 652, 652, 652, 652, 652, 652, 652, 652,
- 652, 652, 652, 652, 652, 652, 652, 652, 652, 652,
-
- 652, 652, 652, 652, 652, 652, 652, 652, 652, 652,
- 652, 652, 652, 652, 652, 652, 652, 652, 652, 652,
- 652, 652, 652, 652, 652, 652, 652, 652, 652, 652,
- 652, 652, 652, 652, 652, 652, 652, 652, 652, 652,
- 652, 652, 652, 652, 652, 652, 652, 652, 652, 652,
- 652, 652, 652, 652, 652, 652, 652, 652, 652, 652,
- 652, 652, 652, 652, 652, 652, 652, 652, 652, 652,
- 652, 652, 652, 652, 652, 652, 652, 652, 652, 652,
- 652, 652, 652, 652, 652, 652, 652, 652, 652, 652,
- 652, 652, 652, 652, 652, 652, 652, 652, 652, 652,
-
- 652, 652, 652, 652, 652, 652, 652, 652, 652, 652,
- 652, 652, 652, 652, 652, 652, 652, 652, 652, 652,
- 652, 652, 652, 652, 652, 652, 652, 652, 652, 652,
- 652, 652, 652, 652, 652, 652, 652, 652, 652, 652,
- 652, 652, 652, 652, 652, 652, 652, 652, 652, 652,
- 652, 652, 652, 652, 652, 652, 652, 652, 652, 652,
- 652, 652, 652, 652, 652, 652, 652, 652, 652, 652,
- 652, 652, 652, 652, 652, 652, 652, 652, 652, 652,
- 652, 652, 652, 652, 652, 652, 652, 652, 652, 652,
- 652, 652, 652, 652, 652, 652, 652, 652, 652, 652,
-
- 652, 652, 652, 652, 652, 652, 652, 652, 652, 652,
- 652, 652, 652, 652, 652, 652, 652, 652, 652, 652,
- 652, 652, 652, 652, 652, 652, 652, 652, 652, 652,
- 652, 652, 652, 652, 652, 652, 652, 652, 652, 652,
- 652, 652, 652, 652, 652, 652, 652, 652, 0, 649,
- 649, 649, 649
- } ;
-
-static yyconst flex_int16_t yy_nxt[805] =
- { 0,
- 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 24,
- 24, 24, 25, 26, 27, 28, 29, 30, 31, 6,
- 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
- 34, 42, 34, 34, 43, 34, 44, 45, 46, 34,
- 47, 48, 49, 34, 50, 51, 34, 34, 52, 53,
- 54, 55, 56, 57, 58, 59, 60, 170, 61, 74,
- 62, 77, 75, 63, 64, 65, 66, 67, 80, 84,
- 68, 88, 86, 69, 81, 70, 89, 95, 96, 78,
- 98, 99, 85, 87, 217, 90, 76, 91, 175, 92,
-
- 92, 92, 92, 93, 91, 82, 93, 93, 93, 93,
- 93, 103, 106, 109, 114, 111, 118, 120, 104, 116,
- 136, 137, 107, 110, 115, 105, 119, 117, 108, 112,
- 123, 125, 128, 121, 132, 113, 124, 133, 94, 138,
- 648, 140, 126, 158, 134, 143, 127, 129, 130, 159,
- 131, 141, 104, 144, 149, 153, 101, 145, 116, 105,
- 109, 151, 147, 107, 115, 148, 150, 156, 154, 146,
- 110, 152, 123, 139, 155, 160, 162, 157, 124, 163,
- 80, 161, 74, 121, 74, 75, 81, 75, 209, 80,
- 239, 164, 165, 240, 166, 81, 169, 169, 169, 169,
-
- 169, 172, 173, 176, 190, 191, 180, 82, 210, 76,
- 177, 76, 181, 194, 195, 91, 82, 92, 92, 92,
- 92, 93, 91, 222, 93, 93, 93, 93, 93, 200,
- 200, 200, 200, 200, 202, 218, 219, 226, 255, 180,
- 223, 203, 177, 227, 192, 181, 193, 230, 244, 228,
- 236, 195, 229, 190, 191, 256, 231, 353, 248, 232,
- 264, 265, 245, 233, 354, 246, 207, 169, 169, 169,
- 169, 169, 200, 200, 200, 200, 200, 292, 303, 306,
- 319, 320, 304, 307, 264, 265, 293, 311, 337, 305,
- 308, 360, 312, 382, 313, 387, 314, 338, 413, 463,
-
- 438, 519, 489, 647, 646, 361, 439, 464, 345, 490,
- 645, 576, 644, 643, 642, 520, 577, 73, 73, 73,
- 79, 79, 79, 100, 100, 641, 640, 639, 638, 637,
- 636, 635, 634, 633, 632, 631, 630, 629, 628, 627,
- 626, 625, 624, 623, 622, 621, 620, 619, 618, 617,
- 616, 615, 614, 613, 612, 611, 610, 609, 608, 607,
- 606, 605, 604, 603, 602, 601, 600, 599, 598, 597,
- 596, 595, 594, 593, 592, 591, 590, 589, 588, 587,
- 586, 585, 584, 583, 582, 581, 580, 579, 578, 575,
- 574, 573, 572, 571, 570, 569, 568, 567, 566, 565,
-
- 564, 563, 562, 561, 560, 559, 558, 557, 556, 555,
- 554, 553, 552, 551, 550, 549, 548, 547, 546, 545,
- 544, 543, 542, 541, 540, 539, 538, 537, 536, 535,
- 534, 533, 532, 531, 530, 529, 528, 527, 526, 525,
- 524, 523, 522, 521, 518, 517, 516, 515, 514, 513,
- 512, 511, 510, 509, 508, 507, 506, 505, 504, 503,
- 502, 501, 500, 499, 498, 497, 496, 495, 494, 493,
- 492, 491, 488, 487, 486, 485, 484, 483, 482, 481,
- 480, 479, 478, 477, 476, 475, 474, 473, 472, 471,
- 470, 469, 468, 467, 466, 465, 462, 461, 460, 459,
-
- 458, 457, 456, 455, 454, 453, 452, 451, 450, 449,
- 448, 447, 446, 445, 444, 443, 442, 441, 440, 437,
- 436, 435, 434, 433, 432, 431, 430, 429, 428, 427,
- 426, 425, 424, 423, 422, 421, 420, 419, 418, 417,
- 416, 415, 414, 412, 411, 410, 409, 408, 407, 406,
- 405, 404, 403, 402, 401, 400, 399, 398, 397, 396,
- 395, 394, 393, 392, 391, 390, 389, 388, 387, 386,
- 385, 384, 383, 381, 380, 379, 378, 377, 376, 375,
- 374, 373, 372, 371, 370, 369, 368, 367, 366, 365,
- 364, 363, 362, 359, 358, 357, 356, 355, 352, 351,
-
- 350, 349, 348, 347, 346, 345, 344, 343, 342, 341,
- 340, 339, 336, 335, 334, 333, 332, 331, 330, 329,
- 328, 327, 326, 325, 324, 323, 322, 321, 318, 317,
- 316, 315, 310, 309, 302, 301, 300, 299, 298, 297,
- 296, 295, 294, 291, 290, 259, 289, 288, 287, 286,
- 285, 284, 283, 282, 281, 280, 279, 278, 277, 276,
- 275, 274, 273, 272, 271, 270, 269, 268, 267, 266,
- 263, 262, 261, 260, 259, 258, 257, 254, 253, 252,
- 251, 250, 249, 247, 243, 242, 241, 197, 238, 237,
- 235, 234, 225, 224, 221, 220, 216, 215, 214, 213,
-
- 212, 211, 208, 207, 206, 205, 204, 201, 199, 198,
- 197, 196, 193, 192, 189, 188, 187, 186, 185, 184,
- 183, 182, 179, 178, 175, 174, 171, 649, 649, 168,
- 167, 142, 135, 122, 102, 101, 97, 83, 72, 71,
- 649, 5, 649, 649, 649, 649, 649, 649, 649, 649,
- 649, 649, 649, 649, 649, 649, 649, 649, 649, 649,
- 649, 649, 649, 649, 649, 649, 649, 649, 649, 649,
- 649, 649, 649, 649, 649, 649, 649, 649, 649, 649,
- 649, 649, 649, 649, 649, 649, 649, 649, 649, 649,
- 649, 649, 649, 649, 649, 649, 649, 649, 649, 649,
-
- 649, 649, 649, 649
- } ;
-
-static yyconst flex_int16_t yy_chk[805] =
- { 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 3, 3, 3, 3, 3, 653, 3, 11,
- 3, 13, 11, 3, 3, 3, 3, 3, 14, 18,
- 3, 22, 20, 3, 14, 3, 22, 27, 27, 13,
- 29, 29, 18, 20, 142, 22, 11, 23, 142, 23,
-
- 23, 23, 23, 23, 24, 14, 24, 24, 24, 24,
- 24, 37, 38, 39, 41, 40, 43, 44, 37, 42,
- 51, 51, 38, 39, 41, 37, 43, 42, 38, 40,
- 46, 47, 48, 44, 49, 40, 46, 49, 23, 53,
- 647, 56, 47, 66, 49, 58, 47, 48, 48, 66,
- 48, 56, 58, 59, 61, 64, 56, 59, 62, 58,
- 60, 63, 60, 59, 61, 60, 62, 65, 64, 59,
- 60, 63, 67, 53, 64, 67, 68, 65, 67, 68,
- 79, 67, 73, 65, 74, 73, 79, 74, 133, 80,
- 160, 68, 68, 160, 68, 80, 91, 91, 91, 91,
-
- 91, 99, 99, 103, 117, 117, 106, 79, 133, 73,
- 103, 74, 106, 120, 120, 92, 80, 92, 92, 92,
- 92, 92, 93, 147, 93, 93, 93, 93, 93, 125,
- 125, 125, 125, 125, 127, 143, 144, 150, 179, 144,
- 147, 127, 143, 150, 151, 144, 152, 153, 164, 151,
- 156, 156, 152, 150, 150, 179, 153, 288, 166, 153,
- 188, 188, 164, 153, 288, 164, 166, 169, 169, 169,
- 169, 169, 200, 200, 200, 200, 200, 225, 236, 238,
- 247, 247, 236, 238, 225, 225, 225, 242, 269, 236,
- 238, 294, 242, 317, 242, 353, 242, 269, 353, 412,
-
- 380, 473, 442, 645, 643, 294, 380, 412, 317, 442,
- 642, 537, 640, 639, 638, 473, 537, 650, 650, 650,
- 651, 651, 651, 652, 652, 637, 634, 633, 632, 631,
- 629, 625, 624, 623, 621, 620, 619, 616, 610, 609,
- 608, 607, 606, 605, 604, 603, 602, 601, 600, 599,
- 598, 597, 596, 595, 594, 591, 589, 588, 587, 586,
- 584, 583, 582, 580, 577, 576, 574, 572, 571, 570,
- 568, 566, 564, 562, 561, 559, 556, 555, 554, 553,
- 552, 551, 549, 546, 545, 544, 542, 540, 538, 534,
- 533, 532, 531, 530, 529, 528, 527, 526, 525, 524,
-
- 522, 520, 519, 517, 516, 515, 514, 513, 512, 511,
- 510, 509, 508, 507, 506, 505, 504, 503, 502, 501,
- 500, 499, 496, 494, 493, 492, 491, 490, 489, 488,
- 487, 486, 485, 484, 483, 482, 481, 480, 479, 478,
- 477, 476, 475, 474, 472, 471, 470, 469, 468, 467,
- 466, 465, 464, 463, 462, 461, 460, 459, 458, 457,
- 456, 455, 454, 453, 451, 450, 449, 447, 446, 445,
- 444, 443, 441, 440, 439, 438, 437, 436, 435, 434,
- 433, 432, 430, 429, 427, 425, 424, 423, 422, 421,
- 420, 419, 418, 416, 414, 413, 410, 407, 406, 404,
-
- 402, 401, 400, 399, 397, 396, 395, 394, 393, 392,
- 390, 389, 387, 386, 385, 384, 383, 382, 381, 379,
- 378, 377, 376, 375, 374, 373, 372, 371, 370, 369,
- 368, 367, 365, 363, 362, 361, 360, 359, 358, 357,
- 356, 355, 354, 352, 350, 348, 347, 346, 345, 344,
- 343, 342, 341, 340, 339, 338, 337, 336, 335, 334,
- 333, 332, 331, 329, 328, 327, 326, 325, 324, 322,
- 320, 319, 318, 316, 315, 314, 313, 312, 311, 308,
- 307, 306, 305, 304, 303, 302, 301, 300, 299, 298,
- 297, 296, 295, 293, 292, 291, 290, 289, 287, 285,
-
- 284, 282, 281, 280, 279, 278, 277, 276, 275, 274,
- 273, 270, 268, 267, 266, 265, 264, 263, 262, 259,
- 258, 257, 256, 255, 253, 252, 249, 248, 246, 245,
- 244, 243, 241, 240, 235, 234, 233, 232, 231, 230,
- 229, 228, 227, 224, 223, 221, 220, 218, 217, 214,
- 213, 211, 210, 209, 208, 207, 206, 205, 204, 203,
- 202, 201, 199, 198, 196, 195, 193, 192, 190, 189,
- 187, 185, 184, 183, 182, 181, 180, 177, 176, 175,
- 173, 168, 167, 165, 163, 162, 161, 159, 158, 157,
- 155, 154, 149, 148, 146, 145, 141, 140, 137, 136,
-
- 135, 134, 132, 131, 130, 129, 128, 126, 124, 123,
- 122, 121, 119, 118, 115, 114, 113, 112, 111, 110,
- 109, 108, 105, 104, 102, 101, 95, 82, 76, 70,
- 69, 57, 50, 45, 36, 35, 28, 17, 10, 9,
- 5, 649, 649, 649, 649, 649, 649, 649, 649, 649,
- 649, 649, 649, 649, 649, 649, 649, 649, 649, 649,
- 649, 649, 649, 649, 649, 649, 649, 649, 649, 649,
- 649, 649, 649, 649, 649, 649, 649, 649, 649, 649,
- 649, 649, 649, 649, 649, 649, 649, 649, 649, 649,
- 649, 649, 649, 649, 649, 649, 649, 649, 649, 649,
-
- 649, 649, 649, 649
- } ;
-
-static yy_state_type yy_last_accepting_state;
-static char *yy_last_accepting_cpos;
-
-extern int swf5_flex_debug;
-int swf5_flex_debug = 0;
-
-/* The intent behind this definition is that it'll catch
- * any uses of REJECT which flex missed.
- */
-#define REJECT reject_used_but_not_detected
-#define yymore() yymore_used_but_not_detected
-#define YY_MORE_ADJ 0
-#define YY_RESTORE_YY_MORE_OFFSET
-char *swf5text;
-#line 1 "swf5compiler.flex"
-#line 2 "swf5compiler.flex"
-
-#include <math.h>
-#include <string.h>
-
-#include "compile.h"
-#include "action.h"
-#include "blocks/error.h"
-#include "swf5compiler.tab.h" /* defines token types */
-
-static int swf5debug;
-
-static const char *lexBuffer = NULL;
-static int lexBufferLen = 0;
-
-static int sLineNumber = 0;
-static char szLine[1024];
-static char msgbufs[2][1024] = { {0}, {0} }, *msgline = {0};
-static int column = 0;
-
-static void comment();
-static void comment1();
-static void count();
-static void countline();
-static void warning(char *msg);
-
-#define YY_INPUT(buf,result,max_size) result=lexBufferInput(buf, max_size)
-
-/* thanks to the prolific and brilliant Raff: */
-static int lexBufferInput(char *buf, int max_size)
-{
- int l = lexBufferLen > max_size ? max_size : lexBufferLen;
-
- if (lexBufferLen <= 0)
- return YY_NULL;
-
- memcpy(buf, lexBuffer, l);
- lexBuffer += l;
- lexBufferLen -= l;
- return l;
-}
-
- /* very inefficient method of unescaping strings */
-static void unescape(char *buf)
-{
- char *p, *p1;
-
- for (p1=buf; (p=strchr(p1, '\\')) != 0; p1 = p+1) {
- switch(p[1])
- {
- case 'b' : p[1] = '\b'; break;
- case 'f' : p[1] = '\f'; break;
- case 'n' : p[1] = '\n'; break;
- case 'r' : p[1] = '\r'; break;
- case 't' : p[1] = '\t'; break;
- case 'x' :
- case 'u' : warning("unsupported escape sequence");
- }
- strcpy(p, p+1);
- }
-}
-
-void swf5ParseInit(const char *script, int debug)
-{
- checkByteOrder();
- swf5restart(NULL);
-
- swf5debug = debug;
-
- lexBuffer = script;
- lexBufferLen = strlen(script);
- sLineNumber = 0;
- column = 0;
- msgline = msgbufs[0];
-}
-
-
-#line 82 "swf5compiler.flex"
- // forward declaration needed by the following function
-#ifndef YY_PROTO
-#ifdef YY_USE_PROTOS
-#define YY_PROTO(proto) proto
-#else
-#define YY_PROTO(proto) ()
-#endif
-#endif
- static void yyunput YY_PROTO(( int c, char *buf_ptr ));
-
- void do_unput5(const char c) { unput(c); }
-#line 936 "lex.swf5.c"
-
-#define INITIAL 0
-#define asm 1
-
-#ifndef YY_NO_UNISTD_H
-/* Special case for "unistd.h", since it is non-ANSI. We include it way
- * down here because we want the user's section 1 to have been scanned first.
- * The user has a chance to override it with an option.
- */
-#include <unistd.h>
-#endif
-
-#ifndef YY_EXTRA_TYPE
-#define YY_EXTRA_TYPE void *
-#endif
-
-static int yy_init_globals (void );
-
-/* Macros after this point can all be overridden by user definitions in
- * section 1.
- */
-
-#ifndef YY_SKIP_YYWRAP
-#ifdef __cplusplus
-extern "C" int swf5wrap (void );
-#else
-extern int swf5wrap (void );
-#endif
-#endif
-
- static void yyunput (int c,char *buf_ptr );
-
-#ifndef yytext_ptr
-static void yy_flex_strncpy (char *,yyconst char *,int );
-#endif
-
-#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen (yyconst char * );
-#endif
-
-#ifndef YY_NO_INPUT
-
-#ifdef __cplusplus
-static int yyinput (void );
-#else
-static int input (void );
-#endif
-
-#endif
-
-/* Amount of stuff to slurp up with each read. */
-#ifndef YY_READ_BUF_SIZE
-#define YY_READ_BUF_SIZE 8192
-#endif
-
-/* Copy whatever the last rule matched to the standard output. */
-#ifndef ECHO
-/* This used to be an fputs(), but since the string might contain NUL's,
- * we now use fwrite().
- */
-#define ECHO (void) fwrite( swf5text, swf5leng, 1, swf5out )
-#endif
-
-/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
- * is returned in "result".
- */
-#ifndef YY_INPUT
-#define YY_INPUT(buf,result,max_size) \
- if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
- { \
- int c = '*'; \
- size_t n; \
- for ( n = 0; n < max_size && \
- (c = getc( swf5in )) != EOF && c != '\n'; ++n ) \
- buf[n] = (char) c; \
- if ( c == '\n' ) \
- buf[n++] = (char) c; \
- if ( c == EOF && ferror( swf5in ) ) \
- YY_FATAL_ERROR( "input in flex scanner failed" ); \
- result = n; \
- } \
- else \
- { \
- errno=0; \
- while ( (result = fread(buf, 1, max_size, swf5in))==0 && ferror(swf5in)) \
- { \
- if( errno != EINTR) \
- { \
- YY_FATAL_ERROR( "input in flex scanner failed" ); \
- break; \
- } \
- errno=0; \
- clearerr(swf5in); \
- } \
- }\
-\
-
-#endif
-
-/* No semi-colon after return; correct usage is to write "yyterminate();" -
- * we don't want an extra ';' after the "return" because that will cause
- * some compilers to complain about unreachable statements.
- */
-#ifndef yyterminate
-#define yyterminate() return YY_NULL
-#endif
-
-/* Number of entries by which start-condition stack grows. */
-#ifndef YY_START_STACK_INCR
-#define YY_START_STACK_INCR 25
-#endif
-
-/* Report a fatal error. */
-#ifndef YY_FATAL_ERROR
-#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
-#endif
-
-/* end tables serialization structures and prototypes */
-
-/* Default declaration of generated scanner - a define so the user can
- * easily add parameters.
- */
-#ifndef YY_DECL
-#define YY_DECL_IS_OURS 1
-
-extern int swf5lex (void);
-
-#define YY_DECL int swf5lex (void)
-#endif /* !YY_DECL */
-
-/* Code executed at the beginning of each rule, after swf5text and swf5leng
- * have been set up.
- */
-#ifndef YY_USER_ACTION
-#define YY_USER_ACTION
-#endif
-
-/* Code executed at the end of each rule. */
-#ifndef YY_BREAK
-#define YY_BREAK break;
-#endif
-
-#define YY_RULE_SETUP \
- YY_USER_ACTION
-
-/** The main scanner function which does all the work.
- */
-YY_DECL
-{
- register yy_state_type yy_current_state;
- register char *yy_cp, *yy_bp;
- register int yy_act;
-
-#line 98 "swf5compiler.flex"
-
-
-#line 1093 "lex.swf5.c"
-
- if ( !(yy_init) )
- {
- (yy_init) = 1;
-
-#ifdef YY_USER_INIT
- YY_USER_INIT;
-#endif
-
- if ( ! (yy_start) )
- (yy_start) = 1; /* first start state */
-
- if ( ! swf5in )
- swf5in = stdin;
-
- if ( ! swf5out )
- swf5out = stdout;
-
- if ( ! YY_CURRENT_BUFFER ) {
- swf5ensure_buffer_stack ();
- YY_CURRENT_BUFFER_LVALUE =
- swf5_create_buffer(swf5in,YY_BUF_SIZE );
- }
-
- swf5_load_buffer_state( );
- }
-
- while ( 1 ) /* loops until end-of-file is reached */
- {
- yy_cp = (yy_c_buf_p);
-
- /* Support of swf5text. */
- *yy_cp = (yy_hold_char);
-
- /* yy_bp points to the position in yy_ch_buf of the start of
- * the current run.
- */
- yy_bp = yy_cp;
-
- yy_current_state = (yy_start);
-yy_match:
- do
- {
- register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
- if ( yy_accept[yy_current_state] )
- {
- (yy_last_accepting_state) = yy_current_state;
- (yy_last_accepting_cpos) = yy_cp;
- }
- while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
- {
- yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 650 )
- yy_c = yy_meta[(unsigned int) yy_c];
- }
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
- ++yy_cp;
- }
- while ( yy_base[yy_current_state] != 742 );
-
-yy_find_action:
- yy_act = yy_accept[yy_current_state];
- if ( yy_act == 0 )
- { /* have to back up */
- yy_cp = (yy_last_accepting_cpos);
- yy_current_state = (yy_last_accepting_state);
- yy_act = yy_accept[yy_current_state];
- }
-
- YY_DO_BEFORE_ACTION;
-
-do_action: /* This label is used only to access EOF actions. */
-
- switch ( yy_act )
- { /* beginning of action switch */
- case 0: /* must back up */
- /* undo the effects of YY_DO_BEFORE_ACTION */
- *yy_cp = (yy_hold_char);
- yy_cp = (yy_last_accepting_cpos);
- yy_current_state = (yy_last_accepting_state);
- goto yy_find_action;
-
-case 1:
-YY_RULE_SETUP
-#line 100 "swf5compiler.flex"
-{ count(); swf5lval.intVal = strtoul(swf5text, NULL, 0);
- return INTEGER; }
- YY_BREAK
-case 2:
-YY_RULE_SETUP
-#line 102 "swf5compiler.flex"
-{ count(); swf5lval.intVal = strtoul(swf5text, NULL, 0);
- return INTEGER; }
- YY_BREAK
-case 3:
-YY_RULE_SETUP
-#line 104 "swf5compiler.flex"
-{ count(); swf5lval.intVal = atoi(swf5text);
- return INTEGER; }
- YY_BREAK
-case 4:
-YY_RULE_SETUP
-#line 106 "swf5compiler.flex"
-{ count(); swf5lval.doubleVal = atof(swf5text);
- return DOUBLE; }
- YY_BREAK
-case 5:
-YY_RULE_SETUP
-#line 108 "swf5compiler.flex"
-{ count(); swf5lval.intVal = 1;
- return BOOLEAN; }
- YY_BREAK
-case 6:
-YY_RULE_SETUP
-#line 110 "swf5compiler.flex"
-{ count(); swf5lval.intVal = 0;
- return BOOLEAN; }
- YY_BREAK
-case 7:
-YY_RULE_SETUP
-#line 112 "swf5compiler.flex"
-{ count(); return NULLVAL; }
- YY_BREAK
-case 8:
-YY_RULE_SETUP
-#line 113 "swf5compiler.flex"
-{ count(); return BREAK; }
- YY_BREAK
-case 9:
-YY_RULE_SETUP
-#line 114 "swf5compiler.flex"
-{ count(); return CONTINUE; }
- YY_BREAK
-case 10:
-YY_RULE_SETUP
-#line 115 "swf5compiler.flex"
-{ count(); return FUNCTION; }
- YY_BREAK
-case 11:
-YY_RULE_SETUP
-#line 116 "swf5compiler.flex"
-{ count(); return ELSE; }
- YY_BREAK
-case 12:
-YY_RULE_SETUP
-#line 117 "swf5compiler.flex"
-{ count(); return SWITCH; }
- YY_BREAK
-case 13:
-YY_RULE_SETUP
-#line 118 "swf5compiler.flex"
-{ count(); return CASE; }
- YY_BREAK
-case 14:
-YY_RULE_SETUP
-#line 119 "swf5compiler.flex"
-{ count(); return DEFAULT; }
- YY_BREAK
-case 15:
-YY_RULE_SETUP
-#line 120 "swf5compiler.flex"
-{ count(); return FOR; }
- YY_BREAK
-case 16:
-YY_RULE_SETUP
-#line 121 "swf5compiler.flex"
-{ count(); return IN; }
- YY_BREAK
-case 17:
-YY_RULE_SETUP
-#line 122 "swf5compiler.flex"
-{ count(); return IF; }
- YY_BREAK
-case 18:
-YY_RULE_SETUP
-#line 123 "swf5compiler.flex"
-{ count(); return WHILE; }
- YY_BREAK
-case 19:
-YY_RULE_SETUP
-#line 124 "swf5compiler.flex"
-{ count(); return DO; }
- YY_BREAK
-case 20:
-YY_RULE_SETUP
-#line 125 "swf5compiler.flex"
-{ count(); return VAR; }
- YY_BREAK
-case 21:
-YY_RULE_SETUP
-#line 126 "swf5compiler.flex"
-{ count(); return NEW; }
- YY_BREAK
-case 22:
-YY_RULE_SETUP
-#line 127 "swf5compiler.flex"
-{ count(); return DELETE; }
- YY_BREAK
-case 23:
-YY_RULE_SETUP
-#line 128 "swf5compiler.flex"
-{ count(); return RETURN; }
- YY_BREAK
-case 24:
-YY_RULE_SETUP
-#line 129 "swf5compiler.flex"
-{ count(); return WITH; }
- YY_BREAK
-case 25:
-YY_RULE_SETUP
-#line 130 "swf5compiler.flex"
-{ count(); BEGIN(asm); return ASM; }
- YY_BREAK
-case 26:
-YY_RULE_SETUP
-#line 131 "swf5compiler.flex"
-{ count(); return EVAL; }
- YY_BREAK
-case 27:
-YY_RULE_SETUP
-#line 132 "swf5compiler.flex"
-{ count(); return TYPEOF; }
- YY_BREAK
-case 28:
-YY_RULE_SETUP
-#line 133 "swf5compiler.flex"
-{ count(); return INSTANCEOF; }
- YY_BREAK
-/* legacy functions */
-case 29:
-YY_RULE_SETUP
-#line 136 "swf5compiler.flex"
-{ count(); return RANDOM; }
- YY_BREAK
-case 30:
-YY_RULE_SETUP
-#line 137 "swf5compiler.flex"
-{ count(); return GETTIMER; }
- YY_BREAK
-case 31:
-YY_RULE_SETUP
-#line 138 "swf5compiler.flex"
-{ count(); return LENGTH; }
- YY_BREAK
-case 32:
-YY_RULE_SETUP
-#line 139 "swf5compiler.flex"
-{ count(); return CONCAT; }
- YY_BREAK
-case 33:
-YY_RULE_SETUP
-#line 140 "swf5compiler.flex"
-{ count(); return SUBSTR; }
- YY_BREAK
-case 34:
-YY_RULE_SETUP
-#line 141 "swf5compiler.flex"
-{ count(); return TRACE; }
- YY_BREAK
-case 35:
-YY_RULE_SETUP
-#line 142 "swf5compiler.flex"
-{ count(); return INT; }
- YY_BREAK
-case 36:
-YY_RULE_SETUP
-#line 143 "swf5compiler.flex"
-{ count(); return ORD; }
- YY_BREAK
-case 37:
-YY_RULE_SETUP
-#line 144 "swf5compiler.flex"
-{ count(); return CHR; }
- YY_BREAK
-case 38:
-YY_RULE_SETUP
-#line 145 "swf5compiler.flex"
-{ count(); return GETURL; }
- YY_BREAK
-case 39:
-YY_RULE_SETUP
-#line 146 "swf5compiler.flex"
-{ count(); return GETURL1; }
- YY_BREAK
-case 40:
-YY_RULE_SETUP
-#line 147 "swf5compiler.flex"
-{ count(); return NEXTFRAME; }
- YY_BREAK
-case 41:
-YY_RULE_SETUP
-#line 148 "swf5compiler.flex"
-{ count(); return PREVFRAME; }
- YY_BREAK
-case 42:
-YY_RULE_SETUP
-#line 149 "swf5compiler.flex"
-{ count(); return PLAY; }
- YY_BREAK
-case 43:
-YY_RULE_SETUP
-#line 150 "swf5compiler.flex"
-{ count(); return STOP; }
- YY_BREAK
-case 44:
-YY_RULE_SETUP
-#line 151 "swf5compiler.flex"
-{ count(); return TOGGLEQUALITY; }
- YY_BREAK
-case 45:
-YY_RULE_SETUP
-#line 152 "swf5compiler.flex"
-{ count(); return STOPSOUNDS; }
- YY_BREAK
-case 46:
-YY_RULE_SETUP
-#line 153 "swf5compiler.flex"
-{ count(); return CALLFRAME; }
- YY_BREAK
-case 47:
-YY_RULE_SETUP
-#line 154 "swf5compiler.flex"
-{ count(); return GOTOFRAME; }
- YY_BREAK
-case 48:
-YY_RULE_SETUP
-#line 155 "swf5compiler.flex"
-{ count(); return SETTARGET; }
- YY_BREAK
-case 49:
-YY_RULE_SETUP
-#line 156 "swf5compiler.flex"
-{ count(); return LOADVARIABLES; }
- YY_BREAK
-case 50:
-YY_RULE_SETUP
-#line 157 "swf5compiler.flex"
-{ count(); return LOADMOVIE; }
- YY_BREAK
-case 51:
-YY_RULE_SETUP
-#line 158 "swf5compiler.flex"
-{ count(); return LOADVARIABLESNUM; }
- YY_BREAK
-case 52:
-YY_RULE_SETUP
-#line 159 "swf5compiler.flex"
-{ count(); return LOADMOVIENUM; }
- YY_BREAK
-case 53:
-YY_RULE_SETUP
-#line 160 "swf5compiler.flex"
-{ count(); return DUPLICATEMOVIECLIP; }
- YY_BREAK
-case 54:
-YY_RULE_SETUP
-#line 161 "swf5compiler.flex"
-{ count(); return REMOVEMOVIECLIP; }
- YY_BREAK
-/* assembler ops */
-
-case 55:
-YY_RULE_SETUP
-#line 165 "swf5compiler.flex"
-{ count(); return DUP; }
- YY_BREAK
-case 56:
-YY_RULE_SETUP
-#line 166 "swf5compiler.flex"
-{ count(); return SWAP; }
- YY_BREAK
-case 57:
-YY_RULE_SETUP
-#line 167 "swf5compiler.flex"
-{ count(); return POP; }
- YY_BREAK
-case 58:
-YY_RULE_SETUP
-#line 168 "swf5compiler.flex"
-{ count(); return PUSH; }
- YY_BREAK
-case 59:
-YY_RULE_SETUP
-#line 169 "swf5compiler.flex"
-{ count(); return SETREGISTER; }
- YY_BREAK
-case 60:
-YY_RULE_SETUP
-#line 170 "swf5compiler.flex"
-{ count(); return CALLFUNCTION; }
- YY_BREAK
-case 61:
-YY_RULE_SETUP
-#line 171 "swf5compiler.flex"
-{ count(); return CALLMETHOD; }
- YY_BREAK
-case 62:
-YY_RULE_SETUP
-#line 172 "swf5compiler.flex"
-{ count(); return AND; }
- YY_BREAK
-case 63:
-YY_RULE_SETUP
-#line 173 "swf5compiler.flex"
-{ count(); return OR; }
- YY_BREAK
-case 64:
-YY_RULE_SETUP
-#line 174 "swf5compiler.flex"
-{ count(); return XOR; }
- YY_BREAK
-case 65:
-YY_RULE_SETUP
-#line 175 "swf5compiler.flex"
-{ count(); return MODULO; }
- YY_BREAK
-case 66:
-YY_RULE_SETUP
-#line 176 "swf5compiler.flex"
-{ count(); return ADD; }
- YY_BREAK
-case 67:
-YY_RULE_SETUP
-#line 177 "swf5compiler.flex"
-{ count(); return ADD; }
- YY_BREAK
-case 68:
-YY_RULE_SETUP
-#line 178 "swf5compiler.flex"
-{ count(); return LESSTHAN; }
- YY_BREAK
-case 69:
-YY_RULE_SETUP
-#line 179 "swf5compiler.flex"
-{ count(); return LESSTHAN; }
- YY_BREAK
-case 70:
-YY_RULE_SETUP
-#line 180 "swf5compiler.flex"
-{ count(); return EQUALS; }
- YY_BREAK
-case 71:
-YY_RULE_SETUP
-#line 181 "swf5compiler.flex"
-{ count(); return EQUALS; }
- YY_BREAK
-case 72:
-YY_RULE_SETUP
-#line 182 "swf5compiler.flex"
-{ count(); return INC; }
- YY_BREAK
-case 73:
-YY_RULE_SETUP
-#line 183 "swf5compiler.flex"
-{ count(); return DEC; }
- YY_BREAK
-case 74:
-YY_RULE_SETUP
-#line 184 "swf5compiler.flex"
-{ count(); return ENUMERATE; }
- YY_BREAK
-case 75:
-YY_RULE_SETUP
-#line 185 "swf5compiler.flex"
-{ count(); return INITOBJECT; }
- YY_BREAK
-case 76:
-YY_RULE_SETUP
-#line 186 "swf5compiler.flex"
-{ count(); return INITARRAY; }
- YY_BREAK
-case 77:
-YY_RULE_SETUP
-#line 187 "swf5compiler.flex"
-{ count(); return GETMEMBER; }
- YY_BREAK
-case 78:
-YY_RULE_SETUP
-#line 188 "swf5compiler.flex"
-{ count(); return SETMEMBER; }
- YY_BREAK
-case 79:
-YY_RULE_SETUP
-#line 189 "swf5compiler.flex"
-{ count(); return SHIFTLEFT; }
- YY_BREAK
-case 80:
-YY_RULE_SETUP
-#line 190 "swf5compiler.flex"
-{ count(); return SHIFTRIGHT; }
- YY_BREAK
-case 81:
-YY_RULE_SETUP
-#line 191 "swf5compiler.flex"
-{ count(); return SHIFTRIGHT2; }
- YY_BREAK
-case 82:
-YY_RULE_SETUP
-#line 192 "swf5compiler.flex"
-{ count(); return VAREQUALS; }
- YY_BREAK
-case 83:
-YY_RULE_SETUP
-#line 193 "swf5compiler.flex"
-{ count(); return OLDADD; }
- YY_BREAK
-case 84:
-YY_RULE_SETUP
-#line 194 "swf5compiler.flex"
-{ count(); return SUBTRACT; }
- YY_BREAK
-case 85:
-YY_RULE_SETUP
-#line 195 "swf5compiler.flex"
-{ count(); return MULTIPLY; }
- YY_BREAK
-case 86:
-YY_RULE_SETUP
-#line 196 "swf5compiler.flex"
-{ count(); return DIVIDE; }
- YY_BREAK
-case 87:
-YY_RULE_SETUP
-#line 197 "swf5compiler.flex"
-{ count(); return OLDEQUALS; }
- YY_BREAK
-case 88:
-YY_RULE_SETUP
-#line 198 "swf5compiler.flex"
-{ count(); return OLDLESSTHAN; }
- YY_BREAK
-case 89:
-YY_RULE_SETUP
-#line 199 "swf5compiler.flex"
-{ count(); return LOGICALAND; }
- YY_BREAK
-case 90:
-YY_RULE_SETUP
-#line 200 "swf5compiler.flex"
-{ count(); return LOGICALOR; }
- YY_BREAK
-case 91:
-YY_RULE_SETUP
-#line 201 "swf5compiler.flex"
-{ count(); return NOT; }
- YY_BREAK
-case 92:
-YY_RULE_SETUP
-#line 202 "swf5compiler.flex"
-{ count(); return STRINGEQ; }
- YY_BREAK
-case 93:
-YY_RULE_SETUP
-#line 203 "swf5compiler.flex"
-{ count(); return STRINGLENGTH; }
- YY_BREAK
-case 94:
-YY_RULE_SETUP
-#line 204 "swf5compiler.flex"
-{ count(); return SUBSTRING; }
- YY_BREAK
-case 95:
-YY_RULE_SETUP
-#line 205 "swf5compiler.flex"
-{ count(); return GETVARIABLE; }
- YY_BREAK
-case 96:
-YY_RULE_SETUP
-#line 206 "swf5compiler.flex"
-{ count(); return SETVARIABLE; }
- YY_BREAK
-case 97:
-YY_RULE_SETUP
-#line 207 "swf5compiler.flex"
-{ count(); return SETTARGETEXPRESSION; }
- YY_BREAK
-case 98:
-YY_RULE_SETUP
-#line 208 "swf5compiler.flex"
-{ count(); return STARTDRAG; }
- YY_BREAK
-case 99:
-YY_RULE_SETUP
-#line 209 "swf5compiler.flex"
-{ count(); return STOPDRAG; }
- YY_BREAK
-case 100:
-YY_RULE_SETUP
-#line 210 "swf5compiler.flex"
-{ count(); return STRINGLESSTHAN; }
- YY_BREAK
-case 101:
-YY_RULE_SETUP
-#line 211 "swf5compiler.flex"
-{ count(); return MBLENGTH; }
- YY_BREAK
-case 102:
-YY_RULE_SETUP
-#line 212 "swf5compiler.flex"
-{ count(); return MBSUBSTRING; }
- YY_BREAK
-case 103:
-YY_RULE_SETUP
-#line 213 "swf5compiler.flex"
-{ count(); return MBORD; }
- YY_BREAK
-case 104:
-YY_RULE_SETUP
-#line 214 "swf5compiler.flex"
-{ count(); return MBCHR; }
- YY_BREAK
-case 105:
-YY_RULE_SETUP
-#line 215 "swf5compiler.flex"
-{ count(); return BRANCHALWAYS; }
- YY_BREAK
-case 106:
-YY_RULE_SETUP
-#line 216 "swf5compiler.flex"
-{ count(); return BRANCHALWAYS; }
- YY_BREAK
-case 107:
-YY_RULE_SETUP
-#line 217 "swf5compiler.flex"
-{ count(); return BRANCHIFTRUE; }
- YY_BREAK
-case 108:
-YY_RULE_SETUP
-#line 218 "swf5compiler.flex"
-{ count(); return POST; }
- YY_BREAK
-case 109:
-YY_RULE_SETUP
-#line 219 "swf5compiler.flex"
-{ count(); return GET; }
- YY_BREAK
-case 110:
-YY_RULE_SETUP
-#line 220 "swf5compiler.flex"
-{ count(); return END; }
- YY_BREAK
-
-case 111:
-YY_RULE_SETUP
-#line 223 "swf5compiler.flex"
-{ count(); swf5lval.str = strdup(swf5text+2);
- return REGISTER; }
- YY_BREAK
-case 112:
-YY_RULE_SETUP
-#line 227 "swf5compiler.flex"
-{ count(); swf5lval.str = strdup(swf5text);
- return IDENTIFIER; }
- YY_BREAK
-case 113:
-/* rule 113 can match eol */
-YY_RULE_SETUP
-#line 230 "swf5compiler.flex"
-{ count(); swf5lval.str = strdup(swf5text+1);
- swf5lval.str[strlen(swf5lval.str)-1]=0;
- unescape(swf5lval.str);
- return STRING; }
- YY_BREAK
-case 114:
-/* rule 114 can match eol */
-YY_RULE_SETUP
-#line 235 "swf5compiler.flex"
-{ count(); swf5lval.str = strdup(swf5text+1);
- swf5lval.str[strlen(swf5lval.str)-1]=0;
- unescape(swf5lval.str);
- return STRING; }
- YY_BREAK
-case 115:
-/* rule 115 can match eol */
-*yy_cp = (yy_hold_char); /* undo effects of setting up swf5text */
-(yy_c_buf_p) = yy_cp -= 1;
-YY_DO_BEFORE_ACTION; /* set up swf5text again */
-YY_RULE_SETUP
-#line 240 "swf5compiler.flex"
-{ count(); swf5lval.str = strdup("");
- warning("Unterminated string!");
- return STRING; }
- YY_BREAK
-case 116:
-/* rule 116 can match eol */
-*yy_cp = (yy_hold_char); /* undo effects of setting up swf5text */
-(yy_c_buf_p) = yy_cp -= 1;
-YY_DO_BEFORE_ACTION; /* set up swf5text again */
-YY_RULE_SETUP
-#line 244 "swf5compiler.flex"
-{ count(); swf5lval.str = strdup("");
- warning("Unterminated string!");
- return STRING; }
- YY_BREAK
-case 117:
-YY_RULE_SETUP
-#line 248 "swf5compiler.flex"
-{ count(); comment(); }
- YY_BREAK
-case 118:
-YY_RULE_SETUP
-#line 249 "swf5compiler.flex"
-{ count(); comment1(); }
- YY_BREAK
-case 119:
-YY_RULE_SETUP
-#line 250 "swf5compiler.flex"
-{ count(); }
- YY_BREAK
-case 120:
-YY_RULE_SETUP
-#line 252 "swf5compiler.flex"
-{ count(); return INCR; }
- YY_BREAK
-case 121:
-YY_RULE_SETUP
-#line 253 "swf5compiler.flex"
-{ count(); return DECR; }
- YY_BREAK
-case 122:
-YY_RULE_SETUP
-#line 254 "swf5compiler.flex"
-{ count(); return LE; }
- YY_BREAK
-case 123:
-YY_RULE_SETUP
-#line 255 "swf5compiler.flex"
-{ count(); return GE; }
- YY_BREAK
-case 124:
-YY_RULE_SETUP
-#line 256 "swf5compiler.flex"
-{ count(); return EQ; }
- YY_BREAK
-case 125:
-YY_RULE_SETUP
-#line 257 "swf5compiler.flex"
-{ count(); return NE; }
- YY_BREAK
-case 126:
-YY_RULE_SETUP
-#line 258 "swf5compiler.flex"
-{ count(); return LAN; }
- YY_BREAK
-case 127:
-YY_RULE_SETUP
-#line 259 "swf5compiler.flex"
-{ count(); return LOR; }
- YY_BREAK
-case 128:
-YY_RULE_SETUP
-#line 260 "swf5compiler.flex"
-{ count(); return MEQ; }
- YY_BREAK
-case 129:
-YY_RULE_SETUP
-#line 261 "swf5compiler.flex"
-{ count(); return DEQ; }
- YY_BREAK
-case 130:
-YY_RULE_SETUP
-#line 262 "swf5compiler.flex"
-{ count(); return IEQ; }
- YY_BREAK
-case 131:
-YY_RULE_SETUP
-#line 263 "swf5compiler.flex"
-{ count(); return SEQ; }
- YY_BREAK
-case 132:
-YY_RULE_SETUP
-#line 264 "swf5compiler.flex"
-{ count(); return AEQ; }
- YY_BREAK
-case 133:
-YY_RULE_SETUP
-#line 265 "swf5compiler.flex"
-{ count(); return OEQ; }
- YY_BREAK
-case 134:
-YY_RULE_SETUP
-#line 266 "swf5compiler.flex"
-{ count(); return SHL; }
- YY_BREAK
-case 135:
-YY_RULE_SETUP
-#line 267 "swf5compiler.flex"
-{ count(); return SHR; }
- YY_BREAK
-case 136:
-YY_RULE_SETUP
-#line 268 "swf5compiler.flex"
-{ count(); return SHR2; }
- YY_BREAK
-case 137:
-YY_RULE_SETUP
-#line 269 "swf5compiler.flex"
-{ count(); return SHLEQ; }
- YY_BREAK
-case 138:
-YY_RULE_SETUP
-#line 270 "swf5compiler.flex"
-{ count(); return SHREQ; }
- YY_BREAK
-case 139:
-YY_RULE_SETUP
-#line 271 "swf5compiler.flex"
-{ count(); return SHR2EQ; }
- YY_BREAK
-case 140:
-YY_RULE_SETUP
-#line 273 "swf5compiler.flex"
-{ count(); return '<'; }
- YY_BREAK
-case 141:
-YY_RULE_SETUP
-#line 274 "swf5compiler.flex"
-{ count(); return '>'; }
- YY_BREAK
-case 142:
-YY_RULE_SETUP
-#line 275 "swf5compiler.flex"
-{ count(); return ';'; }
- YY_BREAK
-case 143:
-YY_RULE_SETUP
-#line 276 "swf5compiler.flex"
-{ count(); return '='; }
- YY_BREAK
-case 144:
-YY_RULE_SETUP
-#line 277 "swf5compiler.flex"
-{ count(); return '+'; }
- YY_BREAK
-case 145:
-YY_RULE_SETUP
-#line 278 "swf5compiler.flex"
-{ count(); return '-'; }
- YY_BREAK
-case 146:
-YY_RULE_SETUP
-#line 279 "swf5compiler.flex"
-{ count(); return '&'; }
- YY_BREAK
-case 147:
-YY_RULE_SETUP
-#line 280 "swf5compiler.flex"
-{ count(); return '|'; }
- YY_BREAK
-case 148:
-YY_RULE_SETUP
-#line 281 "swf5compiler.flex"
-{ count(); return '^'; }
- YY_BREAK
-case 149:
-YY_RULE_SETUP
-#line 282 "swf5compiler.flex"
-{ count(); return '*'; }
- YY_BREAK
-case 150:
-YY_RULE_SETUP
-#line 283 "swf5compiler.flex"
-{ count(); return '/'; }
- YY_BREAK
-case 151:
-YY_RULE_SETUP
-#line 284 "swf5compiler.flex"
-{ count(); return '%'; }
- YY_BREAK
-case 152:
-YY_RULE_SETUP
-#line 285 "swf5compiler.flex"
-{ count(); return '!'; }
- YY_BREAK
-case 153:
-YY_RULE_SETUP
-#line 286 "swf5compiler.flex"
-{ count(); return '('; }
- YY_BREAK
-case 154:
-YY_RULE_SETUP
-#line 287 "swf5compiler.flex"
-{ count(); return ')'; }
- YY_BREAK
-case 155:
-YY_RULE_SETUP
-#line 288 "swf5compiler.flex"
-{ count(); return '['; }
- YY_BREAK
-case 156:
-YY_RULE_SETUP
-#line 289 "swf5compiler.flex"
-{ count(); return ']'; }
- YY_BREAK
-case 157:
-YY_RULE_SETUP
-#line 290 "swf5compiler.flex"
-{ count(); return '{'; }
- YY_BREAK
-case 158:
-YY_RULE_SETUP
-#line 291 "swf5compiler.flex"
-{ count(); BEGIN(0); return '}'; }
- YY_BREAK
-case 159:
-YY_RULE_SETUP
-#line 292 "swf5compiler.flex"
-{ count(); return ','; }
- YY_BREAK
-case 160:
-YY_RULE_SETUP
-#line 293 "swf5compiler.flex"
-{ count(); return '.'; }
- YY_BREAK
-case 161:
-YY_RULE_SETUP
-#line 294 "swf5compiler.flex"
-{ count(); return '?'; }
- YY_BREAK
-case 162:
-YY_RULE_SETUP
-#line 295 "swf5compiler.flex"
-{ count(); return ':'; }
- YY_BREAK
-case 163:
-YY_RULE_SETUP
-#line 296 "swf5compiler.flex"
-{ count(); return '~'; }
- YY_BREAK
-case 164:
-/* rule 164 can match eol */
-YY_RULE_SETUP
-#line 298 "swf5compiler.flex"
-{ count(); strcpy(szLine, swf5text + 1);
- countline(); yyless(1); }
- YY_BREAK
-case 165:
-YY_RULE_SETUP
-#line 301 "swf5compiler.flex"
-SWF_error("Unrecognized character: %s\n", swf5text);
- YY_BREAK
-case 166:
-YY_RULE_SETUP
-#line 303 "swf5compiler.flex"
-ECHO;
- YY_BREAK
-#line 2040 "lex.swf5.c"
-case YY_STATE_EOF(INITIAL):
-case YY_STATE_EOF(asm):
- yyterminate();
-
- case YY_END_OF_BUFFER:
- {
- /* Amount of text matched not including the EOB char. */
- int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
-
- /* Undo the effects of YY_DO_BEFORE_ACTION. */
- *yy_cp = (yy_hold_char);
- YY_RESTORE_YY_MORE_OFFSET
-
- if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
- {
- /* We're scanning a new file or input source. It's
- * possible that this happened because the user
- * just pointed swf5in at a new source and called
- * swf5lex(). If so, then we have to assure
- * consistency between YY_CURRENT_BUFFER and our
- * globals. Here is the right place to do so, because
- * this is the first action (other than possibly a
- * back-up) that will match for the new input source.
- */
- (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
- YY_CURRENT_BUFFER_LVALUE->yy_input_file = swf5in;
- YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
- }
-
- /* Note that here we test for yy_c_buf_p "<=" to the position
- * of the first EOB in the buffer, since yy_c_buf_p will
- * already have been incremented past the NUL character
- * (since all states make transitions on EOB to the
- * end-of-buffer state). Contrast this with the test
- * in input().
- */
- if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
- { /* This was really a NUL. */
- yy_state_type yy_next_state;
-
- (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
-
- yy_current_state = yy_get_previous_state( );
-
- /* Okay, we're now positioned to make the NUL
- * transition. We couldn't have
- * yy_get_previous_state() go ahead and do it
- * for us because it doesn't know how to deal
- * with the possibility of jamming (and we don't
- * want to build jamming into it because then it
- * will run more slowly).
- */
-
- yy_next_state = yy_try_NUL_trans( yy_current_state );
-
- yy_bp = (yytext_ptr) + YY_MORE_ADJ;
-
- if ( yy_next_state )
- {
- /* Consume the NUL. */
- yy_cp = ++(yy_c_buf_p);
- yy_current_state = yy_next_state;
- goto yy_match;
- }
-
- else
- {
- yy_cp = (yy_c_buf_p);
- goto yy_find_action;
- }
- }
-
- else switch ( yy_get_next_buffer( ) )
- {
- case EOB_ACT_END_OF_FILE:
- {
- (yy_did_buffer_switch_on_eof) = 0;
-
- if ( swf5wrap( ) )
- {
- /* Note: because we've taken care in
- * yy_get_next_buffer() to have set up
- * swf5text, we can now set up
- * yy_c_buf_p so that if some total
- * hoser (like flex itself) wants to
- * call the scanner after we return the
- * YY_NULL, it'll still work - another
- * YY_NULL will get returned.
- */
- (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
-
- yy_act = YY_STATE_EOF(YY_START);
- goto do_action;
- }
-
- else
- {
- if ( ! (yy_did_buffer_switch_on_eof) )
- YY_NEW_FILE;
- }
- break;
- }
-
- case EOB_ACT_CONTINUE_SCAN:
- (yy_c_buf_p) =
- (yytext_ptr) + yy_amount_of_matched_text;
-
- yy_current_state = yy_get_previous_state( );
-
- yy_cp = (yy_c_buf_p);
- yy_bp = (yytext_ptr) + YY_MORE_ADJ;
- goto yy_match;
-
- case EOB_ACT_LAST_MATCH:
- (yy_c_buf_p) =
- &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
-
- yy_current_state = yy_get_previous_state( );
-
- yy_cp = (yy_c_buf_p);
- yy_bp = (yytext_ptr) + YY_MORE_ADJ;
- goto yy_find_action;
- }
- break;
- }
-
- default:
- YY_FATAL_ERROR(
- "fatal flex scanner internal error--no action found" );
- } /* end of action switch */
- } /* end of scanning one token */
-} /* end of swf5lex */
-
-/* yy_get_next_buffer - try to read in a new buffer
- *
- * Returns a code representing an action:
- * EOB_ACT_LAST_MATCH -
- * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
- * EOB_ACT_END_OF_FILE - end of file
- */
-static int yy_get_next_buffer (void)
-{
- register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
- register char *source = (yytext_ptr);
- register int number_to_move, i;
- int ret_val;
-
- if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
- YY_FATAL_ERROR(
- "fatal flex scanner internal error--end of buffer missed" );
-
- if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
- { /* Don't try to fill the buffer, so this is an EOF. */
- if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
- {
- /* We matched a single character, the EOB, so
- * treat this as a final EOF.
- */
- return EOB_ACT_END_OF_FILE;
- }
-
- else
- {
- /* We matched some text prior to the EOB, first
- * process it.
- */
- return EOB_ACT_LAST_MATCH;
- }
- }
-
- /* Try to read more data. */
-
- /* First move last chars to start of buffer. */
- number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
-
- for ( i = 0; i < number_to_move; ++i )
- *(dest++) = *(source++);
-
- if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
- /* don't do the read, it's not guaranteed to return an EOF,
- * just force an EOF
- */
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
-
- else
- {
- int num_to_read =
- YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
-
- while ( num_to_read <= 0 )
- { /* Not enough room in the buffer - grow it. */
-
- /* just a shorter name for the current buffer */
- YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
-
- int yy_c_buf_p_offset =
- (int) ((yy_c_buf_p) - b->yy_ch_buf);
-
- if ( b->yy_is_our_buffer )
- {
- int new_size = b->yy_buf_size * 2;
-
- if ( new_size <= 0 )
- b->yy_buf_size += b->yy_buf_size / 8;
- else
- b->yy_buf_size *= 2;
-
- b->yy_ch_buf = (char *)
- /* Include room in for 2 EOB chars. */
- swf5realloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
- }
- else
- /* Can't grow it, we don't own it. */
- b->yy_ch_buf = 0;
-
- if ( ! b->yy_ch_buf )
- YY_FATAL_ERROR(
- "fatal error - scanner input buffer overflow" );
-
- (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
-
- num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
- number_to_move - 1;
-
- }
-
- if ( num_to_read > YY_READ_BUF_SIZE )
- num_to_read = YY_READ_BUF_SIZE;
-
- /* Read in more data. */
- YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
- (yy_n_chars), num_to_read );
-
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
- }
-
- if ( (yy_n_chars) == 0 )
- {
- if ( number_to_move == YY_MORE_ADJ )
- {
- ret_val = EOB_ACT_END_OF_FILE;
- swf5restart(swf5in );
- }
-
- else
- {
- ret_val = EOB_ACT_LAST_MATCH;
- YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
- YY_BUFFER_EOF_PENDING;
- }
- }
-
- else
- ret_val = EOB_ACT_CONTINUE_SCAN;
-
- (yy_n_chars) += number_to_move;
- YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
- YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
-
- (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
-
- return ret_val;
-}
-
-/* yy_get_previous_state - get the state just before the EOB char was reached */
-
- static yy_state_type yy_get_previous_state (void)
-{
- register yy_state_type yy_current_state;
- register char *yy_cp;
-
- yy_current_state = (yy_start);
-
- for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
- {
- register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
- if ( yy_accept[yy_current_state] )
- {
- (yy_last_accepting_state) = yy_current_state;
- (yy_last_accepting_cpos) = yy_cp;
- }
- while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
- {
- yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 650 )
- yy_c = yy_meta[(unsigned int) yy_c];
- }
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
- }
-
- return yy_current_state;
-}
-
-/* yy_try_NUL_trans - try to make a transition on the NUL character
- *
- * synopsis
- * next_state = yy_try_NUL_trans( current_state );
- */
- static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
-{
- register int yy_is_jam;
- register char *yy_cp = (yy_c_buf_p);
-
- register YY_CHAR yy_c = 1;
- if ( yy_accept[yy_current_state] )
- {
- (yy_last_accepting_state) = yy_current_state;
- (yy_last_accepting_cpos) = yy_cp;
- }
- while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
- {
- yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 650 )
- yy_c = yy_meta[(unsigned int) yy_c];
- }
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
- yy_is_jam = (yy_current_state == 649);
-
- return yy_is_jam ? 0 : yy_current_state;
-}
-
- static void yyunput (int c, register char * yy_bp )
-{
- register char *yy_cp;
-
- yy_cp = (yy_c_buf_p);
-
- /* undo effects of setting up swf5text */
- *yy_cp = (yy_hold_char);
-
- if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
- { /* need to shift things up to make room */
- /* +2 for EOB chars. */
- register int number_to_move = (yy_n_chars) + 2;
- register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
- YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
- register char *source =
- &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
-
- while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
- *--dest = *--source;
-
- yy_cp += (int) (dest - source);
- yy_bp += (int) (dest - source);
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
- (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
-
- if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
- YY_FATAL_ERROR( "flex scanner push-back overflow" );
- }
-
- *--yy_cp = (char) c;
-
- (yytext_ptr) = yy_bp;
- (yy_hold_char) = *yy_cp;
- (yy_c_buf_p) = yy_cp;
-}
-
-#ifndef YY_NO_INPUT
-#ifdef __cplusplus
- static int yyinput (void)
-#else
- static int input (void)
-#endif
-
-{
- int c;
-
- *(yy_c_buf_p) = (yy_hold_char);
-
- if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
- {
- /* yy_c_buf_p now points to the character we want to return.
- * If this occurs *before* the EOB characters, then it's a
- * valid NUL; if not, then we've hit the end of the buffer.
- */
- if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
- /* This was really a NUL. */
- *(yy_c_buf_p) = '\0';
-
- else
- { /* need more input */
- int offset = (yy_c_buf_p) - (yytext_ptr);
- ++(yy_c_buf_p);
-
- switch ( yy_get_next_buffer( ) )
- {
- case EOB_ACT_LAST_MATCH:
- /* This happens because yy_g_n_b()
- * sees that we've accumulated a
- * token and flags that we need to
- * try matching the token before
- * proceeding. But for input(),
- * there's no matching to consider.
- * So convert the EOB_ACT_LAST_MATCH
- * to EOB_ACT_END_OF_FILE.
- */
-
- /* Reset buffer status. */
- swf5restart(swf5in );
-
- /*FALLTHROUGH*/
-
- case EOB_ACT_END_OF_FILE:
- {
- if ( swf5wrap( ) )
- return EOF;
-
- if ( ! (yy_did_buffer_switch_on_eof) )
- YY_NEW_FILE;
-#ifdef __cplusplus
- return yyinput();
-#else
- return input();
-#endif
- }
-
- case EOB_ACT_CONTINUE_SCAN:
- (yy_c_buf_p) = (yytext_ptr) + offset;
- break;
- }
- }
- }
-
- c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
- *(yy_c_buf_p) = '\0'; /* preserve swf5text */
- (yy_hold_char) = *++(yy_c_buf_p);
-
- return c;
-}
-#endif /* ifndef YY_NO_INPUT */
-
-/** Immediately switch to a different input stream.
- * @param input_file A readable stream.
- *
- * @note This function does not reset the start condition to @c INITIAL .
- */
- void swf5restart (FILE * input_file )
-{
-
- if ( ! YY_CURRENT_BUFFER ){
- swf5ensure_buffer_stack ();
- YY_CURRENT_BUFFER_LVALUE =
- swf5_create_buffer(swf5in,YY_BUF_SIZE );
- }
-
- swf5_init_buffer(YY_CURRENT_BUFFER,input_file );
- swf5_load_buffer_state( );
-}
-
-/** Switch to a different input buffer.
- * @param new_buffer The new input buffer.
- *
- */
- void swf5_switch_to_buffer (YY_BUFFER_STATE new_buffer )
-{
-
- /* TODO. We should be able to replace this entire function body
- * with
- * swf5pop_buffer_state();
- * swf5push_buffer_state(new_buffer);
- */
- swf5ensure_buffer_stack ();
- if ( YY_CURRENT_BUFFER == new_buffer )
- return;
-
- if ( YY_CURRENT_BUFFER )
- {
- /* Flush out information for old buffer. */
- *(yy_c_buf_p) = (yy_hold_char);
- YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
- }
-
- YY_CURRENT_BUFFER_LVALUE = new_buffer;
- swf5_load_buffer_state( );
-
- /* We don't actually know whether we did this switch during
- * EOF (swf5wrap()) processing, but the only time this flag
- * is looked at is after swf5wrap() is called, so it's safe
- * to go ahead and always set it.
- */
- (yy_did_buffer_switch_on_eof) = 1;
-}
-
-static void swf5_load_buffer_state (void)
-{
- (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
- (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
- swf5in = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
- (yy_hold_char) = *(yy_c_buf_p);
-}
-
-/** Allocate and initialize an input buffer state.
- * @param file A readable stream.
- * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
- *
- * @return the allocated buffer state.
- */
- YY_BUFFER_STATE swf5_create_buffer (FILE * file, int size )
-{
- YY_BUFFER_STATE b;
-
- b = (YY_BUFFER_STATE) swf5alloc(sizeof( struct yy_buffer_state ) );
- if ( ! b )
- YY_FATAL_ERROR( "out of dynamic memory in swf5_create_buffer()" );
-
- b->yy_buf_size = size;
-
- /* yy_ch_buf has to be 2 characters longer than the size given because
- * we need to put in 2 end-of-buffer characters.
- */
- b->yy_ch_buf = (char *) swf5alloc(b->yy_buf_size + 2 );
- if ( ! b->yy_ch_buf )
- YY_FATAL_ERROR( "out of dynamic memory in swf5_create_buffer()" );
-
- b->yy_is_our_buffer = 1;
-
- swf5_init_buffer(b,file );
-
- return b;
-}
-
-/** Destroy the buffer.
- * @param b a buffer created with swf5_create_buffer()
- *
- */
- void swf5_delete_buffer (YY_BUFFER_STATE b )
-{
-
- if ( ! b )
- return;
-
- if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
- YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
-
- if ( b->yy_is_our_buffer )
- swf5free((void *) b->yy_ch_buf );
-
- swf5free((void *) b );
-}
-
-#ifndef _UNISTD_H /* assume unistd.h has isatty() for us */
-#ifdef __cplusplus
-extern "C" {
-#endif
-#ifdef __THROW /* this is a gnuism */
-extern int isatty (int ) __THROW;
-#else
-extern int isatty (int );
-#endif
-#ifdef __cplusplus
-}
-#endif
-#endif
-
-/* Initializes or reinitializes a buffer.
- * This function is sometimes called more than once on the same buffer,
- * such as during a swf5restart() or at EOF.
- */
- static void swf5_init_buffer (YY_BUFFER_STATE b, FILE * file )
-
-{
- int oerrno = errno;
-
- swf5_flush_buffer(b );
-
- b->yy_input_file = file;
- b->yy_fill_buffer = 1;
-
- /* If b is the current buffer, then swf5_init_buffer was _probably_
- * called from swf5restart() or through yy_get_next_buffer.
- * In that case, we don't want to reset the lineno or column.
- */
- if (b != YY_CURRENT_BUFFER){
- b->yy_bs_lineno = 1;
- b->yy_bs_column = 0;
- }
-
- b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
-
- errno = oerrno;
-}
-
-/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
- * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
- *
- */
- void swf5_flush_buffer (YY_BUFFER_STATE b )
-{
- if ( ! b )
- return;
-
- b->yy_n_chars = 0;
-
- /* We always need two end-of-buffer characters. The first causes
- * a transition to the end-of-buffer state. The second causes
- * a jam in that state.
- */
- b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
- b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
-
- b->yy_buf_pos = &b->yy_ch_buf[0];
-
- b->yy_at_bol = 1;
- b->yy_buffer_status = YY_BUFFER_NEW;
-
- if ( b == YY_CURRENT_BUFFER )
- swf5_load_buffer_state( );
-}
-
-/** Pushes the new state onto the stack. The new state becomes
- * the current state. This function will allocate the stack
- * if necessary.
- * @param new_buffer The new state.
- *
- */
-void swf5push_buffer_state (YY_BUFFER_STATE new_buffer )
-{
- if (new_buffer == NULL)
- return;
-
- swf5ensure_buffer_stack();
-
- /* This block is copied from swf5_switch_to_buffer. */
- if ( YY_CURRENT_BUFFER )
- {
- /* Flush out information for old buffer. */
- *(yy_c_buf_p) = (yy_hold_char);
- YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
- }
-
- /* Only push if top exists. Otherwise, replace top. */
- if (YY_CURRENT_BUFFER)
- (yy_buffer_stack_top)++;
- YY_CURRENT_BUFFER_LVALUE = new_buffer;
-
- /* copied from swf5_switch_to_buffer. */
- swf5_load_buffer_state( );
- (yy_did_buffer_switch_on_eof) = 1;
-}
-
-/** Removes and deletes the top of the stack, if present.
- * The next element becomes the new top.
- *
- */
-void swf5pop_buffer_state (void)
-{
- if (!YY_CURRENT_BUFFER)
- return;
-
- swf5_delete_buffer(YY_CURRENT_BUFFER );
- YY_CURRENT_BUFFER_LVALUE = NULL;
- if ((yy_buffer_stack_top) > 0)
- --(yy_buffer_stack_top);
-
- if (YY_CURRENT_BUFFER) {
- swf5_load_buffer_state( );
- (yy_did_buffer_switch_on_eof) = 1;
- }
-}
-
-/* Allocates the stack if it does not exist.
- * Guarantees space for at least one push.
- */
-static void swf5ensure_buffer_stack (void)
-{
- int num_to_alloc;
-
- if (!(yy_buffer_stack)) {
-
- /* First allocation is just for 2 elements, since we don't know if this
- * scanner will even need a stack. We use 2 instead of 1 to avoid an
- * immediate realloc on the next call.
- */
- num_to_alloc = 1;
- (yy_buffer_stack) = (struct yy_buffer_state**)swf5alloc
- (num_to_alloc * sizeof(struct yy_buffer_state*)
- );
-
- memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
-
- (yy_buffer_stack_max) = num_to_alloc;
- (yy_buffer_stack_top) = 0;
- return;
- }
-
- if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
-
- /* Increase the buffer to prepare for a possible push. */
- int grow_size = 8 /* arbitrary grow size */;
-
- num_to_alloc = (yy_buffer_stack_max) + grow_size;
- (yy_buffer_stack) = (struct yy_buffer_state**)swf5realloc
- ((yy_buffer_stack),
- num_to_alloc * sizeof(struct yy_buffer_state*)
- );
-
- /* zero only the new slots.*/
- memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
- (yy_buffer_stack_max) = num_to_alloc;
- }
-}
-
-/** Setup the input buffer state to scan directly from a user-specified character buffer.
- * @param base the character buffer
- * @param size the size in bytes of the character buffer
- *
- * @return the newly allocated buffer state object.
- */
-YY_BUFFER_STATE swf5_scan_buffer (char * base, yy_size_t size )
-{
- YY_BUFFER_STATE b;
-
- if ( size < 2 ||
- base[size-2] != YY_END_OF_BUFFER_CHAR ||
- base[size-1] != YY_END_OF_BUFFER_CHAR )
- /* They forgot to leave room for the EOB's. */
- return 0;
-
- b = (YY_BUFFER_STATE) swf5alloc(sizeof( struct yy_buffer_state ) );
- if ( ! b )
- YY_FATAL_ERROR( "out of dynamic memory in swf5_scan_buffer()" );
-
- b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
- b->yy_buf_pos = b->yy_ch_buf = base;
- b->yy_is_our_buffer = 0;
- b->yy_input_file = 0;
- b->yy_n_chars = b->yy_buf_size;
- b->yy_is_interactive = 0;
- b->yy_at_bol = 1;
- b->yy_fill_buffer = 0;
- b->yy_buffer_status = YY_BUFFER_NEW;
-
- swf5_switch_to_buffer(b );
-
- return b;
-}
-
-/** Setup the input buffer state to scan a string. The next call to swf5lex() will
- * scan from a @e copy of @a str.
- * @param str a NUL-terminated string to scan
- *
- * @return the newly allocated buffer state object.
- * @note If you want to scan bytes that may contain NUL values, then use
- * swf5_scan_bytes() instead.
- */
-YY_BUFFER_STATE swf5_scan_string (yyconst char * yystr )
-{
-
- return swf5_scan_bytes(yystr,strlen(yystr) );
-}
-
-/** Setup the input buffer state to scan the given bytes. The next call to swf5lex() will
- * scan from a @e copy of @a bytes.
- * @param bytes the byte buffer to scan
- * @param len the number of bytes in the buffer pointed to by @a bytes.
- *
- * @return the newly allocated buffer state object.
- */
-YY_BUFFER_STATE swf5_scan_bytes (yyconst char * yybytes, int _yybytes_len )
-{
- YY_BUFFER_STATE b;
- char *buf;
- yy_size_t n;
- int i;
-
- /* Get memory for full buffer, including space for trailing EOB's. */
- n = _yybytes_len + 2;
- buf = (char *) swf5alloc(n );
- if ( ! buf )
- YY_FATAL_ERROR( "out of dynamic memory in swf5_scan_bytes()" );
-
- for ( i = 0; i < _yybytes_len; ++i )
- buf[i] = yybytes[i];
-
- buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
-
- b = swf5_scan_buffer(buf,n );
- if ( ! b )
- YY_FATAL_ERROR( "bad buffer in swf5_scan_bytes()" );
-
- /* It's okay to grow etc. this buffer, and we should throw it
- * away when we're done.
- */
- b->yy_is_our_buffer = 1;
-
- return b;
-}
-
-#ifndef YY_EXIT_FAILURE
-#define YY_EXIT_FAILURE 2
-#endif
-
-static void yy_fatal_error (yyconst char* msg )
-{
- (void) fprintf( stderr, "%s\n", msg );
- exit( YY_EXIT_FAILURE );
-}
-
-/* Redefine yyless() so it works in section 3 code. */
-
-#undef yyless
-#define yyless(n) \
- do \
- { \
- /* Undo effects of setting up swf5text. */ \
- int yyless_macro_arg = (n); \
- YY_LESS_LINENO(yyless_macro_arg);\
- swf5text[swf5leng] = (yy_hold_char); \
- (yy_c_buf_p) = swf5text + yyless_macro_arg; \
- (yy_hold_char) = *(yy_c_buf_p); \
- *(yy_c_buf_p) = '\0'; \
- swf5leng = yyless_macro_arg; \
- } \
- while ( 0 )
-
-/* Accessor methods (get/set functions) to struct members. */
-
-/** Get the current line number.
- *
- */
-int swf5get_lineno (void)
-{
-
- return swf5lineno;
-}
-
-/** Get the input stream.
- *
- */
-FILE *swf5get_in (void)
-{
- return swf5in;
-}
-
-/** Get the output stream.
- *
- */
-FILE *swf5get_out (void)
-{
- return swf5out;
-}
-
-/** Get the length of the current token.
- *
- */
-int swf5get_leng (void)
-{
- return swf5leng;
-}
-
-/** Get the current token.
- *
- */
-
-char *swf5get_text (void)
-{
- return swf5text;
-}
-
-/** Set the current line number.
- * @param line_number
- *
- */
-void swf5set_lineno (int line_number )
-{
-
- swf5lineno = line_number;
-}
-
-/** Set the input stream. This does not discard the current
- * input buffer.
- * @param in_str A readable stream.
- *
- * @see swf5_switch_to_buffer
- */
-void swf5set_in (FILE * in_str )
-{
- swf5in = in_str ;
-}
-
-void swf5set_out (FILE * out_str )
-{
- swf5out = out_str ;
-}
-
-int swf5get_debug (void)
-{
- return swf5_flex_debug;
-}
-
-void swf5set_debug (int bdebug )
-{
- swf5_flex_debug = bdebug ;
-}
-
-static int yy_init_globals (void)
-{
- /* Initialization is the same as for the non-reentrant scanner.
- * This function is called from swf5lex_destroy(), so don't allocate here.
- */
-
- (yy_buffer_stack) = 0;
- (yy_buffer_stack_top) = 0;
- (yy_buffer_stack_max) = 0;
- (yy_c_buf_p) = (char *) 0;
- (yy_init) = 0;
- (yy_start) = 0;
-
-/* Defined in main.c */
-#ifdef YY_STDINIT
- swf5in = stdin;
- swf5out = stdout;
-#else
- swf5in = (FILE *) 0;
- swf5out = (FILE *) 0;
-#endif
-
- /* For future reference: Set errno on error, since we are called by
- * swf5lex_init()
- */
- return 0;
-}
-
-/* swf5lex_destroy is for both reentrant and non-reentrant scanners. */
-int swf5lex_destroy (void)
-{
-
- /* Pop the buffer stack, destroying each element. */
- while(YY_CURRENT_BUFFER){
- swf5_delete_buffer(YY_CURRENT_BUFFER );
- YY_CURRENT_BUFFER_LVALUE = NULL;
- swf5pop_buffer_state();
- }
-
- /* Destroy the stack itself. */
- swf5free((yy_buffer_stack) );
- (yy_buffer_stack) = NULL;
-
- /* Reset the globals. This is important in a non-reentrant scanner so the next time
- * swf5lex() is called, initialization will occur. */
- yy_init_globals( );
-
- return 0;
-}
-
-/*
- * Internal utility routines.
- */
-
-#ifndef yytext_ptr
-static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
-{
- register int i;
- for ( i = 0; i < n; ++i )
- s1[i] = s2[i];
-}
-#endif
-
-#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen (yyconst char * s )
-{
- register int n;
- for ( n = 0; s[n]; ++n )
- ;
-
- return n;
-}
-#endif
-
-void *swf5alloc (yy_size_t size )
-{
- return (void *) malloc( size );
-}
-
-void *swf5realloc (void * ptr, yy_size_t size )
-{
- /* The cast to (char *) in the following accommodates both
- * implementations that use char* generic pointers, and those
- * that use void* generic pointers. It works with the latter
- * because both ANSI C and C++ allow castless assignment from
- * any pointer type to void*, and deal with argument conversions
- * as though doing an assignment.
- */
- return (void *) realloc( (char *) ptr, size );
-}
-
-void swf5free (void * ptr )
-{
- free( (char *) ptr ); /* see swf5realloc() for (char *) cast */
-}
-
-#define YYTABLES_NAME "yytables"
-
-#line 303 "swf5compiler.flex"
-
-
-static int getinput() {
-#ifdef __cplusplus
- return yyinput();
-#else
- return input();
-#endif
-}
-
-int swf5wrap()
-{
- return 1;
-}
-
-static void countline()
-{
- if(sLineNumber != 0)
- msgline[column] = 0;
-
- ++sLineNumber;
- column = 0;
- msgline = msgbufs[sLineNumber & 1];
-}
-
-static int LineNumber(void)
-{
- return (sLineNumber + 1);
-}
-
-static int ColumnNumber(void)
-{
- return column;
-}
-
-static char *LineText(void)
-{
- msgline[column] = 0;
- return msgline;
-}
-
-static void comment()
-{
- // Handle block comments
-
- int c, c1;
-
-loop:
- // We have the start of a comment so look skip everything up to the
- // end of the comment character
- while ((c = getinput()) != '*' && c != EOF)
- {
- if(column < 1023)
- msgline[column] = c;
-
- ++column;
-
- // keep the line number in synch
- if (c == '\n')
- {
- // start the output (matches the algorithim in the lexx above)
- countline();
- }
-
- if (swf5debug) putchar(c);
- }
-
- // is this the end of comment character
- if ((c1 = getinput()) != '/' && c != EOF)
- {
- // false start as this was no end of comment
- do_unput5(c1);
- goto loop;
- }
-
- // write out the start of the end of comment
- if (c != EOF)
- if (swf5debug) putchar(c);
-
- // write out the end of the end of comment
- if (c1 != EOF)
- if (swf5debug) putchar(c1);
-}
-
-static void comment1()
-{
- // Handle comment of type 1 (ie '//')
-
- int c;
-
- // this is a line comment
- while ((c = getinput()) != '\n' && c != EOF)
- {
- if (swf5debug) putchar(c);
-
- if(column < 1023)
- msgline[column] = c;
-
- ++column;
- };
-
- // keep the line number in synch
- if (c == '\n')
- {
- if (swf5debug) putchar(c);
-
- countline();
- }
-}
-
-static void count(void)
-{
- int n;
-
- // Count the characters to maintain the current column position
- if (swf5text[0] == '\n')
- {
- if (swf5debug) printf("\n");
- }
- else
- {
- if (swf5debug) printf("%s", swf5text);
-
- for(n=0; n<swf5leng; ++n, ++column)
- {
- if(column < 1023)
- msgline[column] = swf5text[n];
- }
-
- //-- keep writing the stuff to standard output
- //column += swf5leng;
- }
-}
-
-static void printprog()
-{
- if(sLineNumber)
- SWF_warn("\n%s", msgbufs[(sLineNumber-1)&1]);
-
- if(column < 1023)
- msgline[column] = 0;
-
- SWF_warn("\n%s", msgline);
-}
-
-static void warning(char *msg)
-{
- // print a warning message
- printprog();
- SWF_warn("\n%*s", ColumnNumber(), "^");
- SWF_warn("\nLine %4.4d: Reason: '%s' \n", LineNumber(), msg);
-}
-
-void swf5error(char *msg)
-{
- // report a error
- if(strlen(swf5text))
- {
- SWF_error("\n%s\n%*s\nLine %i: Reason: '%s'\n",
- LineText(), ColumnNumber(), "^", LineNumber(), msg);
- }
- else
- {
- SWF_error("\nLine %d: Reason: 'Unexpected EOF found while looking for input.'\n", LineNumber());
- }
-}
-
+++ /dev/null
-/* A Bison parser, made by GNU Bison 1.875. */
-
-/* Skeleton parser for Yacc-like parsing with Bison,
- Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
-
-/* As a special exception, when this file is copied by Bison into a
- Bison output file, you may use that output file without restriction.
- This special exception was added by the Free Software Foundation
- in version 1.24 of Bison. */
-
-/* Written by Richard Stallman by simplifying the original so called
- ``semantic'' parser. */
-
-/* All symbols defined below should begin with yy or YY, to avoid
- infringing on user name space. This should be done even for local
- variables, as they might otherwise be expanded by user macros.
- There are some unavoidable exceptions within include files to
- define necessary library symbols; they are noted "INFRINGES ON
- USER NAME SPACE" below. */
-
-/* Identify Bison output. */
-#define YYBISON 1
-
-/* Skeleton name. */
-#define YYSKELETON_NAME "yacc.c"
-
-/* Pure parsers. */
-#define YYPURE 0
-
-/* Using locations. */
-#define YYLSP_NEEDED 0
-
-/* If NAME_PREFIX is specified substitute the variables and functions
- names. */
-#define yyparse swf4parse
-#define yylex swf4lex
-#define yyerror swf4error
-#define yylval swf4lval
-#define yychar swf4char
-#define yydebug swf4debug
-#define yynerrs swf4nerrs
-
-
-/* Tokens. */
-#ifndef YYTOKENTYPE
-# define YYTOKENTYPE
- /* Put the tokens into the symbol table, so that GDB and other debuggers
- know about them. */
- enum yytokentype {
- BREAK = 258,
- FOR = 259,
- CONTINUE = 260,
- IF = 261,
- ELSE = 262,
- DO = 263,
- WHILE = 264,
- THIS = 265,
- EVAL = 266,
- TIME = 267,
- RANDOM = 268,
- LENGTH = 269,
- INT = 270,
- CONCAT = 271,
- DUPLICATECLIP = 272,
- REMOVECLIP = 273,
- TRACE = 274,
- STARTDRAG = 275,
- STOPDRAG = 276,
- ORD = 277,
- CHR = 278,
- CALLFRAME = 279,
- GETURL = 280,
- GETURL1 = 281,
- LOADMOVIE = 282,
- LOADVARIABLES = 283,
- POSTURL = 284,
- SUBSTR = 285,
- GETPROPERTY = 286,
- NEXTFRAME = 287,
- PREVFRAME = 288,
- PLAY = 289,
- STOP = 290,
- TOGGLEQUALITY = 291,
- STOPSOUNDS = 292,
- GOTOFRAME = 293,
- GOTOANDPLAY = 294,
- FRAMELOADED = 295,
- SETTARGET = 296,
- TELLTARGET = 297,
- STRING = 298,
- NUMBER = 299,
- IDENTIFIER = 300,
- PATH = 301,
- GETURL_METHOD = 302,
- EQ = 303,
- LE = 304,
- GE = 305,
- NE = 306,
- LAN = 307,
- LOR = 308,
- INC = 309,
- DEC = 310,
- IEQ = 311,
- DEQ = 312,
- MEQ = 313,
- SEQ = 314,
- STREQ = 315,
- STRNE = 316,
- STRCMP = 317,
- PARENT = 318,
- END = 319,
- UMINUS = 320,
- POSTFIX = 321,
- NEGATE = 322
- };
-#endif
-#define BREAK 258
-#define FOR 259
-#define CONTINUE 260
-#define IF 261
-#define ELSE 262
-#define DO 263
-#define WHILE 264
-#define THIS 265
-#define EVAL 266
-#define TIME 267
-#define RANDOM 268
-#define LENGTH 269
-#define INT 270
-#define CONCAT 271
-#define DUPLICATECLIP 272
-#define REMOVECLIP 273
-#define TRACE 274
-#define STARTDRAG 275
-#define STOPDRAG 276
-#define ORD 277
-#define CHR 278
-#define CALLFRAME 279
-#define GETURL 280
-#define GETURL1 281
-#define LOADMOVIE 282
-#define LOADVARIABLES 283
-#define POSTURL 284
-#define SUBSTR 285
-#define GETPROPERTY 286
-#define NEXTFRAME 287
-#define PREVFRAME 288
-#define PLAY 289
-#define STOP 290
-#define TOGGLEQUALITY 291
-#define STOPSOUNDS 292
-#define GOTOFRAME 293
-#define GOTOANDPLAY 294
-#define FRAMELOADED 295
-#define SETTARGET 296
-#define TELLTARGET 297
-#define STRING 298
-#define NUMBER 299
-#define IDENTIFIER 300
-#define PATH 301
-#define GETURL_METHOD 302
-#define EQ 303
-#define LE 304
-#define GE 305
-#define NE 306
-#define LAN 307
-#define LOR 308
-#define INC 309
-#define DEC 310
-#define IEQ 311
-#define DEQ 312
-#define MEQ 313
-#define SEQ 314
-#define STREQ 315
-#define STRNE 316
-#define STRCMP 317
-#define PARENT 318
-#define END 319
-#define UMINUS 320
-#define POSTFIX 321
-#define NEGATE 322
-
-
-
-
-/* Copy the first part of user declarations. */
-#line 5 "swf4compiler.y"
-
-
-#include <time.h>
-#include <string.h>
-#include <stdlib.h>
-#include "compile.h"
-#include "action.h"
-
-#define YYPARSE_PARAM buffer
-
-
-
-/* Enabling traces. */
-#ifndef YYDEBUG
-# define YYDEBUG 0
-#endif
-
-/* Enabling verbose error messages. */
-#ifdef YYERROR_VERBOSE
-# undef YYERROR_VERBOSE
-# define YYERROR_VERBOSE 1
-#else
-# define YYERROR_VERBOSE 0
-#endif
-
-#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
-#line 17 "swf4compiler.y"
-typedef union YYSTYPE {
- Buffer action;
- char *str;
- SWFActionFunction function;
- SWFGetUrl2Method getURLMethod;
-} YYSTYPE;
-/* Line 191 of yacc.c. */
-#line 237 "swf4compiler.tab.c"
-# define yystype YYSTYPE /* obsolescent; will be withdrawn */
-# define YYSTYPE_IS_DECLARED 1
-# define YYSTYPE_IS_TRIVIAL 1
-#endif
-
-
-
-/* Copy the second part of user declarations. */
-
-
-/* Line 214 of yacc.c. */
-#line 249 "swf4compiler.tab.c"
-
-#if ! defined (yyoverflow) || YYERROR_VERBOSE
-
-/* The parser invokes alloca or malloc; define the necessary symbols. */
-
-# if YYSTACK_USE_ALLOCA
-# define YYSTACK_ALLOC alloca
-# else
-# ifndef YYSTACK_USE_ALLOCA
-# if defined (alloca) || defined (_ALLOCA_H)
-# define YYSTACK_ALLOC alloca
-# else
-# ifdef __GNUC__
-# define YYSTACK_ALLOC __builtin_alloca
-# endif
-# endif
-# endif
-# endif
-
-# ifdef YYSTACK_ALLOC
- /* Pacify GCC's `empty if-body' warning. */
-# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
-# else
-# if defined (__STDC__) || defined (__cplusplus)
-# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
-# define YYSIZE_T size_t
-# endif
-# define YYSTACK_ALLOC malloc
-# define YYSTACK_FREE free
-# endif
-#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
-
-
-#if (! defined (yyoverflow) \
- && (! defined (__cplusplus) \
- || (YYSTYPE_IS_TRIVIAL)))
-
-/* A type that is properly aligned for any stack member. */
-union yyalloc
-{
- short yyss;
- YYSTYPE yyvs;
- };
-
-/* The size of the maximum gap between one aligned stack and the next. */
-# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
-
-/* The size of an array large to enough to hold all stacks, each with
- N elements. */
-# define YYSTACK_BYTES(N) \
- ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
- + YYSTACK_GAP_MAXIMUM)
-
-/* Copy COUNT objects from FROM to TO. The source and destination do
- not overlap. */
-# ifndef YYCOPY
-# if 1 < __GNUC__
-# define YYCOPY(To, From, Count) \
- __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
-# else
-# define YYCOPY(To, From, Count) \
- do \
- { \
- register YYSIZE_T yyi; \
- for (yyi = 0; yyi < (Count); yyi++) \
- (To)[yyi] = (From)[yyi]; \
- } \
- while (0)
-# endif
-# endif
-
-/* Relocate STACK from its old location to the new one. The
- local variables YYSIZE and YYSTACKSIZE give the old and new number of
- elements in the stack, and YYPTR gives the new location of the
- stack. Advance YYPTR to a properly aligned location for the next
- stack. */
-# define YYSTACK_RELOCATE(Stack) \
- do \
- { \
- YYSIZE_T yynewbytes; \
- YYCOPY (&yyptr->Stack, Stack, yysize); \
- Stack = &yyptr->Stack; \
- yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
- yyptr += yynewbytes / sizeof (*yyptr); \
- } \
- while (0)
-
-#endif
-
-#if defined (__STDC__) || defined (__cplusplus)
- typedef signed char yysigned_char;
-#else
- typedef short yysigned_char;
-#endif
-
-/* YYFINAL -- State number of the termination state. */
-#define YYFINAL 108
-/* YYLAST -- Last index in YYTABLE. */
-#define YYLAST 1341
-
-/* YYNTOKENS -- Number of terminals. */
-#define YYNTOKENS 86
-/* YYNNTS -- Number of nonterminals. */
-#define YYNNTS 22
-/* YYNRULES -- Number of rules. */
-#define YYNRULES 137
-/* YYNRULES -- Number of states. */
-#define YYNSTATES 369
-
-/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
-#define YYUNDEFTOK 2
-#define YYMAXUTOK 322
-
-#define YYTRANSLATE(YYX) \
- ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
-
-/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
-static const unsigned char yytranslate[] =
-{
- 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 76, 2, 2, 2, 2, 71, 2,
- 83, 84, 74, 72, 65, 73, 85, 75, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 68, 82,
- 69, 66, 70, 67, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 80, 2, 81, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
- 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
- 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
- 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
- 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
- 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
- 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
- 77, 78, 79
-};
-
-#if YYDEBUG
-/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
- YYRHS. */
-static const unsigned short yyprhs[] =
-{
- 0, 0, 3, 5, 7, 10, 12, 15, 19, 21,
- 24, 26, 28, 30, 32, 34, 38, 39, 41, 44,
- 55, 64, 74, 85, 94, 104, 112, 118, 119, 121,
- 131, 137, 144, 154, 155, 157, 160, 163, 167, 172,
- 177, 182, 187, 194, 203, 210, 217, 226, 233, 242,
- 249, 264, 273, 277, 281, 285, 289, 293, 297, 302,
- 307, 312, 317, 322, 327, 333, 339, 344, 348, 353,
- 358, 363, 368, 373, 380, 389, 396, 399, 402, 404,
- 408, 410, 413, 415, 417, 419, 423, 428, 431, 436,
- 439, 442, 445, 449, 453, 457, 461, 465, 469, 473,
- 477, 481, 485, 489, 493, 497, 501, 505, 509, 513,
- 519, 521, 525, 527, 529, 531, 533, 535, 537, 539,
- 541, 545, 547, 549, 552, 555, 560, 565, 569, 573,
- 577, 581, 585, 591, 597, 603, 609, 615
-};
-
-/* YYRHS -- A `-1'-separated list of the rules' RHS. */
-static const yysigned_char yyrhs[] =
-{
- 87, 0, -1, 88, -1, 89, -1, 88, 89, -1,
- 90, -1, 80, 81, -1, 80, 92, 81, -1, 82,
- -1, 106, 82, -1, 93, -1, 95, -1, 97, -1,
- 98, -1, 106, -1, 91, 65, 106, -1, -1, 90,
- -1, 92, 90, -1, 6, 83, 40, 83, 44, 84,
- 84, 90, 7, 90, -1, 6, 83, 40, 83, 44,
- 84, 84, 90, -1, 6, 83, 76, 40, 83, 44,
- 84, 84, 90, -1, 6, 83, 40, 83, 107, 84,
- 84, 90, 7, 90, -1, 6, 83, 40, 83, 107,
- 84, 84, 90, -1, 6, 83, 76, 40, 83, 107,
- 84, 84, 90, -1, 6, 83, 107, 84, 90, 7,
- 90, -1, 6, 83, 107, 84, 90, -1, -1, 107,
- -1, 9, 83, 76, 40, 83, 44, 84, 84, 90,
- -1, 9, 83, 107, 84, 90, -1, 8, 90, 9,
- 83, 107, 84, -1, 4, 83, 96, 82, 94, 82,
- 96, 84, 90, -1, -1, 91, -1, 5, 82, -1,
- 3, 82, -1, 21, 83, 84, -1, 24, 83, 103,
- 84, -1, 24, 83, 43, 84, -1, 18, 83, 107,
- 84, -1, 19, 83, 107, 84, -1, 25, 83, 107,
- 65, 107, 84, -1, 25, 83, 107, 65, 107, 65,
- 47, 84, -1, 26, 83, 43, 65, 43, 84, -1,
- 27, 83, 107, 65, 107, 84, -1, 27, 83, 107,
- 65, 107, 65, 47, 84, -1, 28, 83, 107, 65,
- 107, 84, -1, 28, 83, 107, 65, 107, 65, 47,
- 84, -1, 20, 83, 107, 65, 107, 84, -1, 20,
- 83, 107, 65, 107, 65, 107, 65, 107, 65, 107,
- 65, 107, 84, -1, 17, 83, 107, 65, 107, 65,
- 107, 84, -1, 32, 83, 84, -1, 33, 83, 84,
- -1, 34, 83, 84, -1, 35, 83, 84, -1, 36,
- 83, 84, -1, 37, 83, 84, -1, 38, 83, 44,
- 84, -1, 38, 83, 43, 84, -1, 38, 83, 107,
- 84, -1, 39, 83, 107, 84, -1, 41, 83, 43,
- 84, -1, 41, 83, 107, 84, -1, 42, 83, 43,
- 84, 90, -1, 42, 83, 107, 84, 90, -1, 11,
- 83, 107, 84, -1, 12, 83, 84, -1, 13, 83,
- 107, 84, -1, 14, 83, 107, 84, -1, 15, 83,
- 107, 84, -1, 22, 83, 107, 84, -1, 23, 83,
- 107, 84, -1, 16, 83, 107, 65, 107, 84, -1,
- 30, 83, 107, 65, 107, 65, 107, 84, -1, 31,
- 83, 107, 65, 43, 84, -1, 105, 54, -1, 105,
- 55, -1, 100, -1, 83, 102, 84, -1, 44, -1,
- 73, 44, -1, 43, -1, 103, -1, 104, -1, 104,
- 85, 45, -1, 54, 104, 85, 45, -1, 54, 105,
- -1, 55, 104, 85, 45, -1, 55, 105, -1, 73,
- 102, -1, 76, 102, -1, 105, 66, 102, -1, 102,
- 74, 102, -1, 102, 75, 102, -1, 102, 72, 102,
- -1, 102, 73, 102, -1, 102, 71, 102, -1, 102,
- 69, 102, -1, 102, 70, 102, -1, 102, 49, 102,
- -1, 102, 50, 102, -1, 102, 61, 102, -1, 102,
- 60, 102, -1, 102, 62, 102, -1, 102, 48, 102,
- -1, 102, 51, 102, -1, 102, 52, 102, -1, 102,
- 53, 102, -1, 102, 67, 102, 68, 102, -1, 45,
- -1, 104, 68, 45, -1, 10, -1, 85, -1, 75,
- -1, 63, -1, 45, -1, 46, -1, 103, -1, 43,
- -1, 83, 102, 84, -1, 101, -1, 99, -1, 54,
- 105, -1, 55, 105, -1, 54, 104, 85, 45, -1,
- 55, 104, 85, 45, -1, 105, 66, 102, -1, 105,
- 58, 102, -1, 105, 57, 102, -1, 105, 56, 102,
- -1, 105, 59, 102, -1, 104, 85, 45, 66, 102,
- -1, 104, 85, 45, 58, 102, -1, 104, 85, 45,
- 57, 102, -1, 104, 85, 45, 56, 102, -1, 104,
- 85, 45, 59, 102, -1, 102, -1
-};
-
-/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
-static const unsigned short yyrline[] =
-{
- 0, 144, 144, 150, 151, 156, 160, 161, 162, 163,
- 164, 165, 166, 167, 171, 172, 176, 177, 178, 185,
- 201, 217, 229, 243, 257, 267, 278, 288, 289, 313,
- 328, 340, 348, 370, 371, 375, 383, 391, 395, 402,
- 409, 413, 418, 425, 432, 441, 448, 455, 462, 470,
- 477, 489, 498, 502, 506, 510, 514, 518, 522, 529,
- 536, 542, 548, 555, 559, 573, 586, 590, 594, 598,
- 602, 606, 610, 614, 619, 625, 634, 645, 659, 661,
- 664, 669, 675, 680, 686, 691, 699, 714, 724, 739,
- 749, 754, 758, 764, 769, 774, 779, 784, 789, 794,
- 799, 805, 810, 815, 819, 823, 827, 832, 836, 840,
- 852, 854, 861, 864, 867, 870, 873, 876, 881, 886,
- 891, 895, 897, 899, 907, 915, 928, 941, 945, 952,
- 959, 966, 973, 982, 995, 1008, 1021, 1036
-};
-#endif
-
-#if YYDEBUG || YYERROR_VERBOSE
-/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
- First, the terminals, then, starting at YYNTOKENS, nonterminals. */
-static const char *const yytname[] =
-{
- "$end", "error", "$undefined", "BREAK", "FOR", "CONTINUE", "IF", "ELSE",
- "DO", "WHILE", "THIS", "EVAL", "TIME", "RANDOM", "LENGTH", "INT",
- "CONCAT", "DUPLICATECLIP", "REMOVECLIP", "TRACE", "STARTDRAG",
- "STOPDRAG", "ORD", "CHR", "CALLFRAME", "GETURL", "GETURL1", "LOADMOVIE",
- "LOADVARIABLES", "POSTURL", "SUBSTR", "GETPROPERTY", "NEXTFRAME",
- "PREVFRAME", "PLAY", "STOP", "TOGGLEQUALITY", "STOPSOUNDS", "GOTOFRAME",
- "GOTOANDPLAY", "FRAMELOADED", "SETTARGET", "TELLTARGET", "STRING",
- "NUMBER", "IDENTIFIER", "PATH", "GETURL_METHOD", "\"==\"", "\"<=\"",
- "\">=\"", "\"!=\"", "\"&&\"", "\"||\"", "\"++\"", "\"--\"", "\"+=\"",
- "\"/=\"", "\"*=\"", "\"-=\"", "\"===\"", "\"!==\"", "\"<=>\"", "\"..\"",
- "\"end\"", "','", "'='", "'?'", "':'", "'<'", "'>'", "'&'", "'+'",
- "'-'", "'*'", "'/'", "'!'", "UMINUS", "POSTFIX", "NEGATE", "'{'", "'}'",
- "';'", "'('", "')'", "'.'", "$accept", "program", "elems", "elem",
- "stmt", "assign_stmts", "statements", "if_stmt", "expr_opt",
- "iter_stmt", "assign_stmts_opt", "cont_stmt", "break_stmt",
- "void_function_call", "function_call", "pf_expr", "rhs_expr",
- "variable", "sprite", "lhs_expr", "assign_stmt", "expr", 0
-};
-#endif
-
-# ifdef YYPRINT
-/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
- token YYLEX-NUM. */
-static const unsigned short yytoknum[] =
-{
- 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
- 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
- 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
- 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
- 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
- 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
- 315, 316, 317, 318, 319, 44, 61, 63, 58, 60,
- 62, 38, 43, 45, 42, 47, 33, 320, 321, 322,
- 123, 125, 59, 40, 41, 46
-};
-# endif
-
-/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
-static const unsigned char yyr1[] =
-{
- 0, 86, 87, 88, 88, 89, 90, 90, 90, 90,
- 90, 90, 90, 90, 91, 91, 92, 92, 92, 93,
- 93, 93, 93, 93, 93, 93, 93, 94, 94, 95,
- 95, 95, 95, 96, 96, 97, 98, 99, 99, 99,
- 99, 99, 99, 99, 99, 99, 99, 99, 99, 99,
- 99, 99, 99, 99, 99, 99, 99, 99, 99, 99,
- 99, 99, 99, 99, 99, 99, 100, 100, 100, 100,
- 100, 100, 100, 100, 100, 100, 101, 101, 102, 102,
- 102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
- 102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
- 102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
- 103, 103, 104, 104, 104, 104, 104, 104, 105, 105,
- 105, 106, 106, 106, 106, 106, 106, 106, 106, 106,
- 106, 106, 106, 106, 106, 106, 106, 107
-};
-
-/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
-static const unsigned char yyr2[] =
-{
- 0, 2, 1, 1, 2, 1, 2, 3, 1, 2,
- 1, 1, 1, 1, 1, 3, 0, 1, 2, 10,
- 8, 9, 10, 8, 9, 7, 5, 0, 1, 9,
- 5, 6, 9, 0, 1, 2, 2, 3, 4, 4,
- 4, 4, 6, 8, 6, 6, 8, 6, 8, 6,
- 14, 8, 3, 3, 3, 3, 3, 3, 4, 4,
- 4, 4, 4, 4, 5, 5, 4, 3, 4, 4,
- 4, 4, 4, 6, 8, 6, 2, 2, 1, 3,
- 1, 2, 1, 1, 1, 3, 4, 2, 4, 2,
- 2, 2, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 5,
- 1, 3, 1, 1, 1, 1, 1, 1, 1, 1,
- 3, 1, 1, 2, 2, 4, 4, 3, 3, 3,
- 3, 3, 5, 5, 5, 5, 5, 1
-};
-
-/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
- STATE-NUM when YYTABLE doesn't specify something else to do. Zero
- means the default is an error. */
-static const unsigned char yydefact[] =
-{
- 0, 0, 0, 0, 0, 0, 0, 112, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 119, 110,
- 117, 0, 0, 115, 114, 0, 8, 0, 113, 0,
- 2, 3, 5, 10, 11, 12, 13, 122, 121, 118,
- 0, 0, 0, 36, 33, 35, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 123, 0, 124, 6, 17, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 82, 80, 0, 0,
- 0, 0, 0, 78, 0, 83, 84, 0, 1, 4,
- 0, 0, 76, 77, 0, 0, 0, 0, 0, 9,
- 34, 0, 14, 0, 0, 137, 0, 0, 0, 0,
- 0, 0, 0, 0, 37, 0, 0, 0, 0, 0,
- 0, 0, 52, 53, 54, 55, 56, 57, 82, 80,
- 0, 0, 82, 0, 82, 0, 0, 0, 7, 18,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 87, 0, 89, 80, 90, 91, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 120, 0, 0, 111, 0,
- 130, 129, 128, 131, 127, 0, 27, 0, 0, 0,
- 0, 0, 0, 0, 40, 41, 0, 39, 38, 0,
- 0, 0, 0, 59, 58, 60, 61, 62, 63, 0,
- 0, 125, 126, 0, 67, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 79, 105, 100, 101, 106,
- 107, 108, 103, 102, 104, 0, 98, 99, 97, 95,
- 96, 93, 94, 85, 92, 0, 0, 0, 0, 0,
- 15, 0, 28, 80, 0, 0, 26, 0, 0, 30,
- 0, 0, 0, 0, 0, 0, 64, 65, 66, 68,
- 69, 70, 0, 71, 72, 0, 0, 86, 88, 0,
- 135, 134, 133, 136, 132, 33, 0, 0, 80, 0,
- 0, 31, 0, 0, 0, 49, 0, 42, 44, 0,
- 45, 0, 47, 0, 0, 0, 109, 0, 0, 0,
- 0, 0, 25, 0, 0, 0, 0, 0, 0, 73,
- 0, 75, 0, 20, 23, 0, 0, 0, 51, 0,
- 43, 46, 48, 0, 32, 0, 0, 21, 24, 29,
- 0, 74, 19, 22, 0, 0, 0, 0, 50
-};
-
-/* YYDEFGOTO[NTERM-NUM]. */
-static const short yydefgoto[] =
-{
- -1, 39, 40, 41, 42, 120, 85, 43, 271, 44,
- 121, 45, 46, 47, 103, 48, 125, 105, 106, 107,
- 52, 126
-};
-
-/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
- STATE-NUM. */
-#define YYPACT_NINF -70
-static const short yypact[] =
-{
- 780, -69, -64, -60, -49, 780, -28, -70, -22, -14,
- -2, 3, 4, 11, 13, 17, 19, 20, 23, 25,
- 26, 29, 30, 31, 33, 47, 54, 56, -70, 16,
- -70, 32, 32, -70, -70, 614, -70, 422, -70, 72,
- 780, -70, -70, -70, -70, -70, -70, -70, -70, -70,
- -12, 65, 1, -70, 108, -70, 826, 80, 994, 422,
- 422, 422, 422, 64, 5, 422, 118, 422, 422, 81,
- 82, 86, 88, 89, 104, 1020, 422, 1076, 1102, -11,
- -70, -9, -70, -70, -70, 697, 106, 109, 117, 119,
- 120, 121, 123, 125, 127, 130, 98, -70, 32, 32,
- 1158, 422, 422, -70, 516, 135, -6, 141, -70, -70,
- 145, 169, -70, -70, 422, 422, 422, 422, 422, -70,
- 151, 137, -70, 139, 882, 613, 136, 140, 938, 142,
- 160, 143, 144, 166, -70, 148, 149, 170, 172, 174,
- 175, 178, -70, -70, -70, -70, -70, -70, -48, 150,
- 161, 162, -21, 163, -13, 164, 199, 204, -70, -70,
- 422, 167, 422, 422, 422, 422, 422, 422, 422, 422,
- -3, -70, -1, -70, -70, -70, -70, 1257, 422, 422,
- 422, 422, 422, 422, 422, 422, 422, 422, 422, 422,
- 422, 422, 422, 422, 422, -70, 205, 422, -70, 128,
- 613, 613, 613, 613, 613, 108, 422, 1184, 171, 780,
- 422, 173, 780, 422, -70, -70, 422, -70, -70, 422,
- 210, 422, 422, -70, -70, -70, -70, -70, -70, 780,
- 780, -70, -70, 176, -70, 177, 179, 180, 190, 182,
- 188, 192, 193, 214, 228, 212, -46, 124, 124, -46,
- 696, 696, -46, -46, 124, 107, 124, 124, -65, 18,
- 18, -70, -70, -70, 613, 422, 422, 422, 422, 422,
- -70, 197, -70, 191, 196, 1240, 274, 206, 244, -70,
- 224, -63, -51, 207, -45, -35, -70, -70, -70, -70,
- -70, -70, 422, -70, -70, 422, 249, -70, -70, 422,
- 613, 613, 613, 613, 613, 108, 211, 213, 215, 216,
- 780, -70, 217, 422, 422, -70, 246, -70, -70, 247,
- -70, 251, -70, 218, 231, 219, 613, 220, 780, 780,
- 222, 223, -70, 225, 229, 243, 230, 234, 235, -70,
- 422, -70, 780, 305, 308, 780, 780, 780, -70, 422,
- -70, -70, -70, 236, -70, 780, 780, -70, -70, -70,
- 256, -70, -70, -70, 422, 258, 422, 240, -70
-};
-
-/* YYPGOTO[NTERM-NUM]. */
-static const short yypgoto[] =
-{
- -70, -70, -70, 285, 53, -70, -70, -70, -70, -70,
- 21, -70, -70, -70, -70, -70, 346, 0, 6, 12,
- -53, 209
-};
-
-/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
- positive, shift that token. If negative, reduce the rule which
- number is the opposite. If zero, do what YYDEFACT says.
- If YYTABLE_NINF, syntax error. */
-#define YYTABLE_NINF -121
-static const short yytable[] =
-{
- 49, 122, 314, 179, 180, 49, 50, 191, 192, 193,
- 194, 50, 51, 53, 316, 7, 186, 51, -119, 54,
- 319, 315, 55, 188, 189, 190, 191, 192, 193, 194,
- 321, 49, 49, 317, 56, 49, 223, 79, 81, 320,
- 49, 50, 7, 80, 82, -119, 50, 51, 135, 322,
- 29, 30, 51, -119, 49, 58, 110, 110, 57, 110,
- 50, 59, 110, 227, 136, 110, 51, 110, 33, 60,
- 137, 229, 108, 111, 156, 28, 157, 29, 30, 196,
- 34, 61, 243, 119, 244, 49, 62, 63, 84, 127,
- 38, 50, 193, 194, 64, 33, 65, 51, 49, 49,
- 66, -116, 67, 68, 170, 172, 69, 34, 70, 71,
- 171, 173, 72, 73, 74, 37, 75, 38, 7, 112,
- 113, 114, 115, 116, 117, 8, 9, 10, 11, 12,
- 76, 118, 13, 14, 15, 16, 17, 77, 159, 78,
- 18, 19, 20, 21, 22, 23, 24, 25, 134, 26,
- 27, 28, 270, 29, 30, 178, 179, 180, 181, 182,
- 183, 139, 31, 32, -119, 142, 143, 184, 185, 186,
- 144, 33, 145, 146, 187, 299, 188, 189, 190, 191,
- 192, 193, 194, 34, 265, 266, 267, 268, 147, 160,
- 198, 37, 161, 38, 269, 190, 191, 192, 193, 194,
- 162, -118, 163, 164, 165, 49, 166, 197, 167, 49,
- 168, 50, 49, 169, 199, 50, 205, 51, 50, 206,
- 209, 51, 207, 210, 51, 213, 212, 214, 215, 49,
- 49, 216, 217, 218, 224, 50, 50, 219, 110, 220,
- 221, 51, 51, 222, 231, 225, 226, 228, 230, 232,
- 263, 234, 122, 283, 275, 292, 278, 295, 296, 297,
- 288, 289, 276, 290, 291, 279, 293, 129, 130, 131,
- 132, 133, 294, 298, 138, 306, 140, 141, -120, 305,
- 307, 310, 286, 287, 150, 151, 153, 155, 312, 313,
- 311, 318, 325, 336, 337, 328, 340, 329, 338, 330,
- 331, 333, 339, 341, 342, 49, 345, 346, 349, 347,
- 49, 50, 355, 348, 350, 356, 50, 51, 351, 352,
- 361, 364, 51, 366, 368, 109, 327, 0, 49, 49,
- 0, 0, 0, 0, 50, 50, 0, 0, 0, 0,
- 51, 51, 49, 0, 0, 49, 49, 49, 50, 0,
- 0, 50, 50, 50, 51, 49, 49, 51, 51, 51,
- 0, 50, 50, 332, 0, 0, 0, 51, 51, 233,
- 0, 235, 236, 237, 238, 239, 240, 241, 242, 0,
- 0, 343, 344, 104, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 354, 0, 0, 357, 358,
- 359, 0, 0, 0, 0, 0, 0, 0, 362, 363,
- 0, 0, 0, 0, 0, 272, 274, 0, 0, 277,
- 0, 0, 280, 0, 0, 281, 0, 0, 282, 0,
- 284, 285, 7, 86, 87, 88, 89, 90, 91, 0,
- 0, 0, 0, 0, 92, 93, 175, 176, 177, 0,
- 0, 0, 94, 95, 0, 0, 0, 0, 0, 0,
- 200, 201, 202, 203, 204, 96, 97, 29, 30, 0,
- 176, 0, 0, 0, 176, 0, 98, 99, 0, 0,
- 0, 0, 0, 0, 309, 33, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 100, 0, 34, 101, 0,
- 0, 323, 0, 0, 324, 102, 0, 38, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 334, 335, 246, 247, 248, 249, 250, 251,
- 252, 253, 254, 255, 256, 257, 258, 259, 260, 261,
- 262, 0, 0, 264, 0, 0, 0, 0, 0, 353,
- 0, 0, 0, 0, 0, 0, 0, 0, 360, 0,
- 0, 0, 0, 0, 178, 179, 180, 181, 182, 183,
- 0, 0, 0, 365, 0, 367, 184, 185, 186, 0,
- 0, 0, 0, 187, 0, 188, 189, 190, 191, 192,
- 193, 194, 0, 0, 0, 0, 0, 0, 0, 0,
- 195, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 300, 301, 302, 303, 304, 0, 1, 2, 3,
- 4, 0, 5, 6, 7, 0, 0, 0, 0, 0,
- 0, 8, 9, 10, 11, 12, 0, 0, 13, 14,
- 15, 16, 17, 0, 0, 326, 18, 19, 20, 21,
- 22, 23, 24, 25, 0, 26, 27, 28, 0, 29,
- 30, 178, 179, 180, 181, 182, 183, 0, 31, 32,
- 0, 0, 0, 184, 185, 186, 0, 33, 0, 0,
- 187, 0, 188, 189, 190, 191, 192, 193, 194, 34,
- 0, 0, 0, 0, 35, 83, 36, 37, 0, 38,
- 1, 2, 3, 4, 0, 5, 6, 7, 0, 0,
- 0, 0, 0, 0, 8, 9, 10, 11, 12, 0,
- 0, 13, 14, 15, 16, 17, 0, 0, 0, 18,
- 19, 20, 21, 22, 23, 24, 25, 0, 26, 27,
- 28, 0, 29, 30, 178, 179, 180, 181, 0, 0,
- 0, 31, 32, 0, 0, 0, 184, 185, 186, 0,
- 33, 0, 0, 0, 0, 188, 189, 190, 191, 192,
- 193, 194, 34, 0, 0, 0, 0, 35, 158, 36,
- 37, 0, 38, 1, 2, 3, 4, 0, 5, 6,
- 7, 0, 0, 0, 0, 0, 0, 8, 9, 10,
- 11, 12, 0, 0, 13, 14, 15, 16, 17, 0,
- 0, 0, 18, 19, 20, 21, 22, 23, 24, 25,
- 0, 26, 27, 28, 0, 29, 30, 0, 0, 0,
- 0, 0, 0, 0, 31, 32, 7, 86, 87, 88,
- 89, 90, 91, 33, 0, 0, 0, 0, 92, 93,
- 0, 0, 0, 0, 0, 34, 94, 95, 0, 0,
- 35, 0, 36, 37, 0, 38, 123, 0, 0, 96,
- 97, 29, 30, 0, 0, 0, 0, 0, 0, 0,
- 98, 99, 0, 0, 0, 0, 0, 0, 0, 33,
- 0, 0, 7, 86, 87, 88, 89, 90, 91, 100,
- 0, 34, 124, 0, 92, 93, 0, 0, 0, 102,
- 0, 38, 94, 95, 0, 0, 0, 0, 0, 0,
- 0, 0, 208, 0, 0, 96, 97, 29, 30, 0,
- 0, 0, 0, 0, 0, 0, 98, 99, 0, 0,
- 0, 0, 0, 0, 0, 33, 0, 0, 7, 86,
- 87, 88, 89, 90, 91, 100, 0, 34, 101, 0,
- 92, 93, 0, 0, 0, 102, 0, 38, 94, 95,
- 0, 0, 0, 0, 0, 0, 0, 0, 211, 0,
- 0, 96, 97, 29, 30, 0, 0, 0, 0, 0,
- 0, 0, 98, 99, 0, 0, 0, 0, 0, 0,
- 0, 33, 0, 0, 7, 86, 87, 88, 89, 90,
- 91, 100, 0, 34, 101, 0, 92, 93, 0, 0,
- 0, 102, 0, 38, 94, 95, 0, 0, 0, 0,
- 7, 86, 87, 88, 89, 90, 91, 96, 97, 29,
- 30, 0, 92, 93, 0, 0, 0, 0, 98, 99,
- 94, 95, 0, 0, 0, 0, 0, 33, 0, 0,
- 0, 0, 0, 148, 149, 29, 30, 100, 0, 34,
- 128, 0, 0, 0, 98, 99, 0, 102, 0, 38,
- 0, 0, 0, 33, 0, 0, 7, 86, 87, 88,
- 89, 90, 91, 100, 0, 34, 101, 0, 92, 93,
- 0, 0, 0, 102, 0, 38, 94, 95, 0, 0,
- 0, 0, 7, 86, 87, 88, 89, 90, 91, 152,
- 97, 29, 30, 0, 92, 93, 0, 0, 0, 0,
- 98, 99, 94, 95, 0, 0, 0, 0, 0, 33,
- 0, 0, 0, 0, 0, 154, 97, 29, 30, 100,
- 0, 34, 101, 0, 0, 0, 98, 99, 0, 102,
- 0, 38, 0, 0, 0, 33, 0, 0, 7, 86,
- 87, 88, 89, 90, 91, 100, 0, 34, 101, 0,
- 92, 93, 0, 0, 0, 102, 0, 38, 94, 95,
- 0, 0, 0, 0, 7, 86, 87, 88, 89, 90,
- 91, 96, 174, 29, 30, 0, 92, 93, 0, 0,
- 0, 0, 98, 99, 94, 95, 0, 0, 0, 0,
- 0, 33, 0, 0, 0, 0, 0, 96, 273, 29,
- 30, 100, 0, 34, 101, 0, 0, 0, 98, 99,
- 0, 102, 0, 38, 0, 0, 0, 33, 0, 0,
- 7, 86, 87, 88, 89, 90, 91, 100, 0, 34,
- 101, 0, 92, 93, 0, 0, 0, 102, 0, 38,
- 94, 95, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 96, 308, 29, 30, 0, 0, 0,
- 0, 0, 0, 0, 98, 99, 0, 0, 0, 0,
- 0, 0, 0, 33, 0, 178, 179, 180, 181, 182,
- 183, 0, 0, 100, 0, 34, 101, 184, 185, 186,
- 0, 0, 0, 102, 187, 38, 188, 189, 190, 191,
- 192, 193, 194, 0, 0, 0, 0, 0, 0, 0,
- 0, 245
-};
-
-static const short yycheck[] =
-{
- 0, 54, 65, 49, 50, 5, 0, 72, 73, 74,
- 75, 5, 0, 82, 65, 10, 62, 5, 66, 83,
- 65, 84, 82, 69, 70, 71, 72, 73, 74, 75,
- 65, 31, 32, 84, 83, 35, 84, 31, 32, 84,
- 40, 35, 10, 31, 32, 66, 40, 35, 43, 84,
- 45, 46, 40, 66, 54, 83, 68, 68, 5, 68,
- 54, 83, 68, 84, 64, 68, 54, 68, 63, 83,
- 64, 84, 0, 85, 85, 43, 85, 45, 46, 85,
- 75, 83, 85, 82, 85, 85, 83, 83, 35, 9,
- 85, 85, 74, 75, 83, 63, 83, 85, 98, 99,
- 83, 85, 83, 83, 98, 99, 83, 75, 83, 83,
- 98, 99, 83, 83, 83, 83, 83, 85, 10, 54,
- 55, 56, 57, 58, 59, 17, 18, 19, 20, 21,
- 83, 66, 24, 25, 26, 27, 28, 83, 85, 83,
- 32, 33, 34, 35, 36, 37, 38, 39, 84, 41,
- 42, 43, 205, 45, 46, 48, 49, 50, 51, 52,
- 53, 43, 54, 55, 66, 84, 84, 60, 61, 62,
- 84, 63, 84, 84, 67, 68, 69, 70, 71, 72,
- 73, 74, 75, 75, 56, 57, 58, 59, 84, 83,
- 45, 83, 83, 85, 66, 71, 72, 73, 74, 75,
- 83, 66, 83, 83, 83, 205, 83, 66, 83, 209,
- 83, 205, 212, 83, 45, 209, 65, 205, 212, 82,
- 84, 209, 83, 83, 212, 65, 84, 84, 84, 229,
- 230, 65, 84, 84, 84, 229, 230, 65, 68, 65,
- 65, 229, 230, 65, 45, 84, 84, 84, 84, 45,
- 45, 84, 305, 43, 83, 65, 83, 65, 65, 45,
- 84, 84, 209, 84, 84, 212, 84, 58, 59, 60,
- 61, 62, 84, 45, 65, 84, 67, 68, 66, 82,
- 84, 7, 229, 230, 75, 76, 77, 78, 44, 65,
- 84, 84, 43, 47, 47, 84, 65, 84, 47, 84,
- 84, 84, 84, 84, 84, 305, 84, 84, 65, 84,
- 310, 305, 7, 84, 84, 7, 310, 305, 84, 84,
- 84, 65, 310, 65, 84, 40, 305, -1, 328, 329,
- -1, -1, -1, -1, 328, 329, -1, -1, -1, -1,
- 328, 329, 342, -1, -1, 345, 346, 347, 342, -1,
- -1, 345, 346, 347, 342, 355, 356, 345, 346, 347,
- -1, 355, 356, 310, -1, -1, -1, 355, 356, 160,
- -1, 162, 163, 164, 165, 166, 167, 168, 169, -1,
- -1, 328, 329, 37, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, 342, -1, -1, 345, 346,
- 347, -1, -1, -1, -1, -1, -1, -1, 355, 356,
- -1, -1, -1, -1, -1, 206, 207, -1, -1, 210,
- -1, -1, 213, -1, -1, 216, -1, -1, 219, -1,
- 221, 222, 10, 11, 12, 13, 14, 15, 16, -1,
- -1, -1, -1, -1, 22, 23, 100, 101, 102, -1,
- -1, -1, 30, 31, -1, -1, -1, -1, -1, -1,
- 114, 115, 116, 117, 118, 43, 44, 45, 46, -1,
- 124, -1, -1, -1, 128, -1, 54, 55, -1, -1,
- -1, -1, -1, -1, 275, 63, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, 73, -1, 75, 76, -1,
- -1, 292, -1, -1, 295, 83, -1, 85, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, 313, 314, 178, 179, 180, 181, 182, 183,
- 184, 185, 186, 187, 188, 189, 190, 191, 192, 193,
- 194, -1, -1, 197, -1, -1, -1, -1, -1, 340,
- -1, -1, -1, -1, -1, -1, -1, -1, 349, -1,
- -1, -1, -1, -1, 48, 49, 50, 51, 52, 53,
- -1, -1, -1, 364, -1, 366, 60, 61, 62, -1,
- -1, -1, -1, 67, -1, 69, 70, 71, 72, 73,
- 74, 75, -1, -1, -1, -1, -1, -1, -1, -1,
- 84, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, 265, 266, 267, 268, 269, -1, 3, 4, 5,
- 6, -1, 8, 9, 10, -1, -1, -1, -1, -1,
- -1, 17, 18, 19, 20, 21, -1, -1, 24, 25,
- 26, 27, 28, -1, -1, 299, 32, 33, 34, 35,
- 36, 37, 38, 39, -1, 41, 42, 43, -1, 45,
- 46, 48, 49, 50, 51, 52, 53, -1, 54, 55,
- -1, -1, -1, 60, 61, 62, -1, 63, -1, -1,
- 67, -1, 69, 70, 71, 72, 73, 74, 75, 75,
- -1, -1, -1, -1, 80, 81, 82, 83, -1, 85,
- 3, 4, 5, 6, -1, 8, 9, 10, -1, -1,
- -1, -1, -1, -1, 17, 18, 19, 20, 21, -1,
- -1, 24, 25, 26, 27, 28, -1, -1, -1, 32,
- 33, 34, 35, 36, 37, 38, 39, -1, 41, 42,
- 43, -1, 45, 46, 48, 49, 50, 51, -1, -1,
- -1, 54, 55, -1, -1, -1, 60, 61, 62, -1,
- 63, -1, -1, -1, -1, 69, 70, 71, 72, 73,
- 74, 75, 75, -1, -1, -1, -1, 80, 81, 82,
- 83, -1, 85, 3, 4, 5, 6, -1, 8, 9,
- 10, -1, -1, -1, -1, -1, -1, 17, 18, 19,
- 20, 21, -1, -1, 24, 25, 26, 27, 28, -1,
- -1, -1, 32, 33, 34, 35, 36, 37, 38, 39,
- -1, 41, 42, 43, -1, 45, 46, -1, -1, -1,
- -1, -1, -1, -1, 54, 55, 10, 11, 12, 13,
- 14, 15, 16, 63, -1, -1, -1, -1, 22, 23,
- -1, -1, -1, -1, -1, 75, 30, 31, -1, -1,
- 80, -1, 82, 83, -1, 85, 40, -1, -1, 43,
- 44, 45, 46, -1, -1, -1, -1, -1, -1, -1,
- 54, 55, -1, -1, -1, -1, -1, -1, -1, 63,
- -1, -1, 10, 11, 12, 13, 14, 15, 16, 73,
- -1, 75, 76, -1, 22, 23, -1, -1, -1, 83,
- -1, 85, 30, 31, -1, -1, -1, -1, -1, -1,
- -1, -1, 40, -1, -1, 43, 44, 45, 46, -1,
- -1, -1, -1, -1, -1, -1, 54, 55, -1, -1,
- -1, -1, -1, -1, -1, 63, -1, -1, 10, 11,
- 12, 13, 14, 15, 16, 73, -1, 75, 76, -1,
- 22, 23, -1, -1, -1, 83, -1, 85, 30, 31,
- -1, -1, -1, -1, -1, -1, -1, -1, 40, -1,
- -1, 43, 44, 45, 46, -1, -1, -1, -1, -1,
- -1, -1, 54, 55, -1, -1, -1, -1, -1, -1,
- -1, 63, -1, -1, 10, 11, 12, 13, 14, 15,
- 16, 73, -1, 75, 76, -1, 22, 23, -1, -1,
- -1, 83, -1, 85, 30, 31, -1, -1, -1, -1,
- 10, 11, 12, 13, 14, 15, 16, 43, 44, 45,
- 46, -1, 22, 23, -1, -1, -1, -1, 54, 55,
- 30, 31, -1, -1, -1, -1, -1, 63, -1, -1,
- -1, -1, -1, 43, 44, 45, 46, 73, -1, 75,
- 76, -1, -1, -1, 54, 55, -1, 83, -1, 85,
- -1, -1, -1, 63, -1, -1, 10, 11, 12, 13,
- 14, 15, 16, 73, -1, 75, 76, -1, 22, 23,
- -1, -1, -1, 83, -1, 85, 30, 31, -1, -1,
- -1, -1, 10, 11, 12, 13, 14, 15, 16, 43,
- 44, 45, 46, -1, 22, 23, -1, -1, -1, -1,
- 54, 55, 30, 31, -1, -1, -1, -1, -1, 63,
- -1, -1, -1, -1, -1, 43, 44, 45, 46, 73,
- -1, 75, 76, -1, -1, -1, 54, 55, -1, 83,
- -1, 85, -1, -1, -1, 63, -1, -1, 10, 11,
- 12, 13, 14, 15, 16, 73, -1, 75, 76, -1,
- 22, 23, -1, -1, -1, 83, -1, 85, 30, 31,
- -1, -1, -1, -1, 10, 11, 12, 13, 14, 15,
- 16, 43, 44, 45, 46, -1, 22, 23, -1, -1,
- -1, -1, 54, 55, 30, 31, -1, -1, -1, -1,
- -1, 63, -1, -1, -1, -1, -1, 43, 44, 45,
- 46, 73, -1, 75, 76, -1, -1, -1, 54, 55,
- -1, 83, -1, 85, -1, -1, -1, 63, -1, -1,
- 10, 11, 12, 13, 14, 15, 16, 73, -1, 75,
- 76, -1, 22, 23, -1, -1, -1, 83, -1, 85,
- 30, 31, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, 43, 44, 45, 46, -1, -1, -1,
- -1, -1, -1, -1, 54, 55, -1, -1, -1, -1,
- -1, -1, -1, 63, -1, 48, 49, 50, 51, 52,
- 53, -1, -1, 73, -1, 75, 76, 60, 61, 62,
- -1, -1, -1, 83, 67, 85, 69, 70, 71, 72,
- 73, 74, 75, -1, -1, -1, -1, -1, -1, -1,
- -1, 84
-};
-
-/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
- symbol of state STATE-NUM. */
-static const unsigned char yystos[] =
-{
- 0, 3, 4, 5, 6, 8, 9, 10, 17, 18,
- 19, 20, 21, 24, 25, 26, 27, 28, 32, 33,
- 34, 35, 36, 37, 38, 39, 41, 42, 43, 45,
- 46, 54, 55, 63, 75, 80, 82, 83, 85, 87,
- 88, 89, 90, 93, 95, 97, 98, 99, 101, 103,
- 104, 105, 106, 82, 83, 82, 83, 90, 83, 83,
- 83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
- 83, 83, 83, 83, 83, 83, 83, 83, 83, 104,
- 105, 104, 105, 81, 90, 92, 11, 12, 13, 14,
- 15, 16, 22, 23, 30, 31, 43, 44, 54, 55,
- 73, 76, 83, 100, 102, 103, 104, 105, 0, 89,
- 68, 85, 54, 55, 56, 57, 58, 59, 66, 82,
- 91, 96, 106, 40, 76, 102, 107, 9, 76, 107,
- 107, 107, 107, 107, 84, 43, 103, 104, 107, 43,
- 107, 107, 84, 84, 84, 84, 84, 84, 43, 44,
- 107, 107, 43, 107, 43, 107, 85, 85, 81, 90,
- 83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
- 104, 105, 104, 105, 44, 102, 102, 102, 48, 49,
- 50, 51, 52, 53, 60, 61, 62, 67, 69, 70,
- 71, 72, 73, 74, 75, 84, 85, 66, 45, 45,
- 102, 102, 102, 102, 102, 65, 82, 83, 40, 84,
- 83, 40, 84, 65, 84, 84, 65, 84, 84, 65,
- 65, 65, 65, 84, 84, 84, 84, 84, 84, 84,
- 84, 45, 45, 107, 84, 107, 107, 107, 107, 107,
- 107, 107, 107, 85, 85, 84, 102, 102, 102, 102,
- 102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
- 102, 102, 102, 45, 102, 56, 57, 58, 59, 66,
- 106, 94, 107, 44, 107, 83, 90, 107, 83, 90,
- 107, 107, 107, 43, 107, 107, 90, 90, 84, 84,
- 84, 84, 65, 84, 84, 65, 65, 45, 45, 68,
- 102, 102, 102, 102, 102, 82, 84, 84, 44, 107,
- 7, 84, 44, 65, 65, 84, 65, 84, 84, 65,
- 84, 65, 84, 107, 107, 43, 102, 96, 84, 84,
- 84, 84, 90, 84, 107, 107, 47, 47, 47, 84,
- 65, 84, 84, 90, 90, 84, 84, 84, 84, 65,
- 84, 84, 84, 107, 90, 7, 7, 90, 90, 90,
- 107, 84, 90, 90, 65, 107, 65, 107, 84
-};
-
-#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
-# define YYSIZE_T __SIZE_TYPE__
-#endif
-#if ! defined (YYSIZE_T) && defined (size_t)
-# define YYSIZE_T size_t
-#endif
-#if ! defined (YYSIZE_T)
-# if defined (__STDC__) || defined (__cplusplus)
-# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
-# define YYSIZE_T size_t
-# endif
-#endif
-#if ! defined (YYSIZE_T)
-# define YYSIZE_T unsigned int
-#endif
-
-#define yyerrok (yyerrstatus = 0)
-#define yyclearin (yychar = YYEMPTY)
-#define YYEMPTY (-2)
-#define YYEOF 0
-
-#define YYACCEPT goto yyacceptlab
-#define YYABORT goto yyabortlab
-#define YYERROR goto yyerrlab1
-
-
-/* Like YYERROR except do call yyerror. This remains here temporarily
- to ease the transition to the new meaning of YYERROR, for GCC.
- Once GCC version 2 has supplanted version 1, this can go. */
-
-#define YYFAIL goto yyerrlab
-
-#define YYRECOVERING() (!!yyerrstatus)
-
-#define YYBACKUP(Token, Value) \
-do \
- if (yychar == YYEMPTY && yylen == 1) \
- { \
- yychar = (Token); \
- yylval = (Value); \
- yytoken = YYTRANSLATE (yychar); \
- YYPOPSTACK; \
- goto yybackup; \
- } \
- else \
- { \
- yyerror ("syntax error: cannot back up");\
- YYERROR; \
- } \
-while (0)
-
-#define YYTERROR 1
-#define YYERRCODE 256
-
-/* YYLLOC_DEFAULT -- Compute the default location (before the actions
- are run). */
-
-#ifndef YYLLOC_DEFAULT
-# define YYLLOC_DEFAULT(Current, Rhs, N) \
- Current.first_line = Rhs[1].first_line; \
- Current.first_column = Rhs[1].first_column; \
- Current.last_line = Rhs[N].last_line; \
- Current.last_column = Rhs[N].last_column;
-#endif
-
-/* YYLEX -- calling `yylex' with the right arguments. */
-
-#ifdef YYLEX_PARAM
-# define YYLEX yylex (YYLEX_PARAM)
-#else
-# define YYLEX yylex ()
-#endif
-
-/* Enable debugging if requested. */
-#if YYDEBUG
-
-# ifndef YYFPRINTF
-# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
-# define YYFPRINTF fprintf
-# endif
-
-# define YYDPRINTF(Args) \
-do { \
- if (yydebug) \
- YYFPRINTF Args; \
-} while (0)
-
-# define YYDSYMPRINT(Args) \
-do { \
- if (yydebug) \
- yysymprint Args; \
-} while (0)
-
-# define YYDSYMPRINTF(Title, Token, Value, Location) \
-do { \
- if (yydebug) \
- { \
- YYFPRINTF (stderr, "%s ", Title); \
- yysymprint (stderr, \
- Token, Value); \
- YYFPRINTF (stderr, "\n"); \
- } \
-} while (0)
-
-/*------------------------------------------------------------------.
-| yy_stack_print -- Print the state stack from its BOTTOM up to its |
-| TOP (cinluded). |
-`------------------------------------------------------------------*/
-
-#if defined (__STDC__) || defined (__cplusplus)
-static void
-yy_stack_print (short *bottom, short *top)
-#else
-static void
-yy_stack_print (bottom, top)
- short *bottom;
- short *top;
-#endif
-{
- YYFPRINTF (stderr, "Stack now");
- for (/* Nothing. */; bottom <= top; ++bottom)
- YYFPRINTF (stderr, " %d", *bottom);
- YYFPRINTF (stderr, "\n");
-}
-
-# define YY_STACK_PRINT(Bottom, Top) \
-do { \
- if (yydebug) \
- yy_stack_print ((Bottom), (Top)); \
-} while (0)
-
-
-/*------------------------------------------------.
-| Report that the YYRULE is going to be reduced. |
-`------------------------------------------------*/
-
-#if defined (__STDC__) || defined (__cplusplus)
-static void
-yy_reduce_print (int yyrule)
-#else
-static void
-yy_reduce_print (yyrule)
- int yyrule;
-#endif
-{
- int yyi;
- unsigned int yylineno = yyrline[yyrule];
- YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
- yyrule - 1, yylineno);
- /* Print the symbols being reduced, and their result. */
- for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
- YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]);
- YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]);
-}
-
-# define YY_REDUCE_PRINT(Rule) \
-do { \
- if (yydebug) \
- yy_reduce_print (Rule); \
-} while (0)
-
-/* Nonzero means print parse trace. It is left uninitialized so that
- multiple parsers can coexist. */
-int yydebug;
-#else /* !YYDEBUG */
-# define YYDPRINTF(Args)
-# define YYDSYMPRINT(Args)
-# define YYDSYMPRINTF(Title, Token, Value, Location)
-# define YY_STACK_PRINT(Bottom, Top)
-# define YY_REDUCE_PRINT(Rule)
-#endif /* !YYDEBUG */
-
-
-/* YYINITDEPTH -- initial size of the parser's stacks. */
-#ifndef YYINITDEPTH
-# define YYINITDEPTH 200
-#endif
-
-/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
- if the built-in stack extension method is used).
-
- Do not make this value too large; the results are undefined if
- SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
- evaluated with infinite-precision integer arithmetic. */
-
-#if YYMAXDEPTH == 0
-# undef YYMAXDEPTH
-#endif
-
-#ifndef YYMAXDEPTH
-# define YYMAXDEPTH 10000
-#endif
-
-\f
-
-#if YYERROR_VERBOSE
-
-# ifndef yystrlen
-# if defined (__GLIBC__) && defined (_STRING_H)
-# define yystrlen strlen
-# else
-/* Return the length of YYSTR. */
-static YYSIZE_T
-# if defined (__STDC__) || defined (__cplusplus)
-yystrlen (const char *yystr)
-# else
-yystrlen (yystr)
- const char *yystr;
-# endif
-{
- register const char *yys = yystr;
-
- while (*yys++ != '\0')
- continue;
-
- return yys - yystr - 1;
-}
-# endif
-# endif
-
-# ifndef yystpcpy
-# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
-# define yystpcpy stpcpy
-# else
-/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
- YYDEST. */
-static char *
-# if defined (__STDC__) || defined (__cplusplus)
-yystpcpy (char *yydest, const char *yysrc)
-# else
-yystpcpy (yydest, yysrc)
- char *yydest;
- const char *yysrc;
-# endif
-{
- register char *yyd = yydest;
- register const char *yys = yysrc;
-
- while ((*yyd++ = *yys++) != '\0')
- continue;
-
- return yyd - 1;
-}
-# endif
-# endif
-
-#endif /* !YYERROR_VERBOSE */
-
-\f
-
-#if YYDEBUG
-/*--------------------------------.
-| Print this symbol on YYOUTPUT. |
-`--------------------------------*/
-
-#if defined (__STDC__) || defined (__cplusplus)
-static void
-yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
-#else
-static void
-yysymprint (yyoutput, yytype, yyvaluep)
- FILE *yyoutput;
- int yytype;
- YYSTYPE *yyvaluep;
-#endif
-{
- /* Pacify ``unused variable'' warnings. */
- (void) yyvaluep;
-
- if (yytype < YYNTOKENS)
- {
- YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
-# ifdef YYPRINT
- YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
-# endif
- }
- else
- YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
-
- switch (yytype)
- {
- default:
- break;
- }
- YYFPRINTF (yyoutput, ")");
-}
-
-#endif /* ! YYDEBUG */
-/*-----------------------------------------------.
-| Release the memory associated to this symbol. |
-`-----------------------------------------------*/
-
-#if defined (__STDC__) || defined (__cplusplus)
-static void
-yydestruct (int yytype, YYSTYPE *yyvaluep)
-#else
-static void
-yydestruct (yytype, yyvaluep)
- int yytype;
- YYSTYPE *yyvaluep;
-#endif
-{
- /* Pacify ``unused variable'' warnings. */
- (void) yyvaluep;
-
- switch (yytype)
- {
-
- default:
- break;
- }
-}
-\f
-
-/* Prevent warnings from -Wmissing-prototypes. */
-
-#ifdef YYPARSE_PARAM
-# if defined (__STDC__) || defined (__cplusplus)
-int yyparse (void *YYPARSE_PARAM);
-# else
-int yyparse ();
-# endif
-#else /* ! YYPARSE_PARAM */
-#if defined (__STDC__) || defined (__cplusplus)
-int yyparse (void);
-#else
-int yyparse ();
-#endif
-#endif /* ! YYPARSE_PARAM */
-
-
-
-/* The lookahead symbol. */
-int yychar;
-
-/* The semantic value of the lookahead symbol. */
-YYSTYPE yylval;
-
-/* Number of syntax errors so far. */
-int yynerrs;
-
-
-
-/*----------.
-| yyparse. |
-`----------*/
-
-#ifdef YYPARSE_PARAM
-# if defined (__STDC__) || defined (__cplusplus)
-int yyparse (void *YYPARSE_PARAM)
-# else
-int yyparse (YYPARSE_PARAM)
- void *YYPARSE_PARAM;
-# endif
-#else /* ! YYPARSE_PARAM */
-#if defined (__STDC__) || defined (__cplusplus)
-int
-yyparse (void)
-#else
-int
-yyparse ()
-
-#endif
-#endif
-{
-
- register int yystate;
- register int yyn;
- int yyresult;
- /* Number of tokens to shift before error messages enabled. */
- int yyerrstatus;
- /* Lookahead token as an internal (translated) token number. */
- int yytoken = 0;
-
- /* Three stacks and their tools:
- `yyss': related to states,
- `yyvs': related to semantic values,
- `yyls': related to locations.
-
- Refer to the stacks thru separate pointers, to allow yyoverflow
- to reallocate them elsewhere. */
-
- /* The state stack. */
- short yyssa[YYINITDEPTH];
- short *yyss = yyssa;
- register short *yyssp;
-
- /* The semantic value stack. */
- YYSTYPE yyvsa[YYINITDEPTH];
- YYSTYPE *yyvs = yyvsa;
- register YYSTYPE *yyvsp;
-
-
-
-#define YYPOPSTACK (yyvsp--, yyssp--)
-
- YYSIZE_T yystacksize = YYINITDEPTH;
-
- /* The variables used to return semantic value and location from the
- action routines. */
- YYSTYPE yyval;
-
-
- /* When reducing, the number of symbols on the RHS of the reduced
- rule. */
- int yylen;
-
- YYDPRINTF ((stderr, "Starting parse\n"));
-
- yystate = 0;
- yyerrstatus = 0;
- yynerrs = 0;
- yychar = YYEMPTY; /* Cause a token to be read. */
-
- /* Initialize stack pointers.
- Waste one element of value and location stack
- so that they stay on the same level as the state stack.
- The wasted elements are never initialized. */
-
- yyssp = yyss;
- yyvsp = yyvs;
-
- goto yysetstate;
-
-/*------------------------------------------------------------.
-| yynewstate -- Push a new state, which is found in yystate. |
-`------------------------------------------------------------*/
- yynewstate:
- /* In all cases, when you get here, the value and location stacks
- have just been pushed. so pushing a state here evens the stacks.
- */
- yyssp++;
-
- yysetstate:
- *yyssp = yystate;
-
- if (yyss + yystacksize - 1 <= yyssp)
- {
- /* Get the current used size of the three stacks, in elements. */
- YYSIZE_T yysize = yyssp - yyss + 1;
-
-#ifdef yyoverflow
- {
- /* Give user a chance to reallocate the stack. Use copies of
- these so that the &'s don't force the real ones into
- memory. */
- YYSTYPE *yyvs1 = yyvs;
- short *yyss1 = yyss;
-
-
- /* Each stack pointer address is followed by the size of the
- data in use in that stack, in bytes. This used to be a
- conditional around just the two extra args, but that might
- be undefined if yyoverflow is a macro. */
- yyoverflow ("parser stack overflow",
- &yyss1, yysize * sizeof (*yyssp),
- &yyvs1, yysize * sizeof (*yyvsp),
-
- &yystacksize);
-
- yyss = yyss1;
- yyvs = yyvs1;
- }
-#else /* no yyoverflow */
-# ifndef YYSTACK_RELOCATE
- goto yyoverflowlab;
-# else
- /* Extend the stack our own way. */
- if (YYMAXDEPTH <= yystacksize)
- goto yyoverflowlab;
- yystacksize *= 2;
- if (YYMAXDEPTH < yystacksize)
- yystacksize = YYMAXDEPTH;
-
- {
- short *yyss1 = yyss;
- union yyalloc *yyptr =
- (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
- if (! yyptr)
- goto yyoverflowlab;
- YYSTACK_RELOCATE (yyss);
- YYSTACK_RELOCATE (yyvs);
-
-# undef YYSTACK_RELOCATE
- if (yyss1 != yyssa)
- YYSTACK_FREE (yyss1);
- }
-# endif
-#endif /* no yyoverflow */
-
- yyssp = yyss + yysize - 1;
- yyvsp = yyvs + yysize - 1;
-
-
- YYDPRINTF ((stderr, "Stack size increased to %lu\n",
- (unsigned long int) yystacksize));
-
- if (yyss + yystacksize - 1 <= yyssp)
- YYABORT;
- }
-
- YYDPRINTF ((stderr, "Entering state %d\n", yystate));
-
- goto yybackup;
-
-/*-----------.
-| yybackup. |
-`-----------*/
-yybackup:
-
-/* Do appropriate processing given the current state. */
-/* Read a lookahead token if we need one and don't already have one. */
-/* yyresume: */
-
- /* First try to decide what to do without reference to lookahead token. */
-
- yyn = yypact[yystate];
- if (yyn == YYPACT_NINF)
- goto yydefault;
-
- /* Not known => get a lookahead token if don't already have one. */
-
- /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
- if (yychar == YYEMPTY)
- {
- YYDPRINTF ((stderr, "Reading a token: "));
- yychar = YYLEX;
- }
-
- if (yychar <= YYEOF)
- {
- yychar = yytoken = YYEOF;
- YYDPRINTF ((stderr, "Now at end of input.\n"));
- }
- else
- {
- yytoken = YYTRANSLATE (yychar);
- YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc);
- }
-
- /* If the proper action on seeing token YYTOKEN is to reduce or to
- detect an error, take that action. */
- yyn += yytoken;
- if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
- goto yydefault;
- yyn = yytable[yyn];
- if (yyn <= 0)
- {
- if (yyn == 0 || yyn == YYTABLE_NINF)
- goto yyerrlab;
- yyn = -yyn;
- goto yyreduce;
- }
-
- if (yyn == YYFINAL)
- YYACCEPT;
-
- /* Shift the lookahead token. */
- YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken]));
-
- /* Discard the token being shifted unless it is eof. */
- if (yychar != YYEOF)
- yychar = YYEMPTY;
-
- *++yyvsp = yylval;
-
-
- /* Count tokens shifted since error; after three, turn off error
- status. */
- if (yyerrstatus)
- yyerrstatus--;
-
- yystate = yyn;
- goto yynewstate;
-
-
-/*-----------------------------------------------------------.
-| yydefault -- do the default action for the current state. |
-`-----------------------------------------------------------*/
-yydefault:
- yyn = yydefact[yystate];
- if (yyn == 0)
- goto yyerrlab;
- goto yyreduce;
-
-
-/*-----------------------------.
-| yyreduce -- Do a reduction. |
-`-----------------------------*/
-yyreduce:
- /* yyn is the number of a rule to reduce with. */
- yylen = yyr2[yyn];
-
- /* If YYLEN is nonzero, implement the default value of the action:
- `$$ = $1'.
-
- Otherwise, the following line sets YYVAL to garbage.
- This behavior is undocumented and Bison
- users should not rely upon it. Assigning to YYVAL
- unconditionally makes the parser a bit smaller, and it avoids a
- GCC warning that YYVAL may be used uninitialized. */
- yyval = yyvsp[1-yylen];
-
-
- YY_REDUCE_PRINT (yyn);
- switch (yyn)
- {
- case 2:
-#line 145 "swf4compiler.y"
- { *((Buffer *)buffer) = yyvsp[0].action; ;}
- break;
-
- case 4:
-#line 152 "swf4compiler.y"
- { bufferConcat(yyvsp[-1].action, yyvsp[0].action); ;}
- break;
-
- case 6:
-#line 160 "swf4compiler.y"
- { yyval.action = NULL; ;}
- break;
-
- case 7:
-#line 161 "swf4compiler.y"
- { yyval.action = yyvsp[-1].action; ;}
- break;
-
- case 8:
-#line 162 "swf4compiler.y"
- { yyval.action = NULL; ;}
- break;
-
- case 15:
-#line 172 "swf4compiler.y"
- { bufferConcat(yyvsp[-2].action, yyvsp[0].action); ;}
- break;
-
- case 16:
-#line 176 "swf4compiler.y"
- { yyval.action = NULL; ;}
- break;
-
- case 18:
-#line 179 "swf4compiler.y"
- { bufferConcat(yyvsp[-1].action, yyvsp[0].action); ;}
- break;
-
- case 19:
-#line 186 "swf4compiler.y"
- { yyval.action = newBuffer();
- bufferWriteU8(yyval.action, SWFACTION_WAITFORFRAME);
- bufferWriteS16(yyval.action, 3);
- bufferWriteS16(yyval.action, atoi(yyvsp[-5].str));
- free(yyvsp[-5].str);
- bufferWriteU8(yyval.action, 1); /* if not loaded, jump to.. */
- bufferWriteU8(yyval.action, SWFACTION_BRANCHALWAYS);
- bufferWriteS16(yyval.action, 2);
- bufferWriteS16(yyval.action, bufferLength(yyvsp[0].action)+5);
- bufferConcat(yyval.action, yyvsp[0].action); /* ..here */
- bufferWriteU8(yyval.action, SWFACTION_BRANCHALWAYS);
- bufferWriteS16(yyval.action, 2);
- bufferWriteS16(yyval.action, bufferLength(yyvsp[-2].action));
- bufferConcat(yyval.action, yyvsp[-2].action); ;}
- break;
-
- case 20:
-#line 202 "swf4compiler.y"
- { yyval.action = newBuffer();
- bufferWriteU8(yyval.action, SWFACTION_WAITFORFRAME);
- bufferWriteS16(yyval.action, 3);
- bufferWriteS16(yyval.action, atoi(yyvsp[-3].str));
- free(yyvsp[-3].str);
- bufferWriteU8(yyval.action, 1); /* if not loaded, jump to.. */
- bufferWriteU8(yyval.action, SWFACTION_BRANCHALWAYS);
- bufferWriteS16(yyval.action, 2);
- bufferWriteS16(yyval.action, 5);
- bufferWriteU8(yyval.action, SWFACTION_BRANCHALWAYS); /* ..here */
- bufferWriteS16(yyval.action, 2);
- bufferWriteS16(yyval.action, bufferLength(yyvsp[0].action)); /* ..and then out */
- bufferConcat(yyval.action, yyvsp[0].action); ;}
- break;
-
- case 21:
-#line 218 "swf4compiler.y"
- { yyval.action = newBuffer();
- bufferWriteU8(yyval.action, SWFACTION_WAITFORFRAME);
- bufferWriteS16(yyval.action, 3);
- bufferWriteS16(yyval.action, atoi(yyvsp[-3].str));
- free(yyvsp[-3].str);
- bufferWriteU8(yyval.action, 1); /* if not loaded, jump to.. */
- bufferWriteU8(yyval.action, SWFACTION_BRANCHALWAYS);
- bufferWriteS16(yyval.action, 2);
- bufferWriteS16(yyval.action, bufferLength(yyvsp[0].action));
- bufferConcat(yyval.action, yyvsp[0].action); ;}
- break;
-
- case 22:
-#line 230 "swf4compiler.y"
- { yyval.action = yyvsp[-5].action;
- bufferWriteU8(yyval.action, SWFACTION_WAITFORFRAMEEXPRESSION);
- bufferWriteS16(yyval.action, 1);
- bufferWriteU8(yyval.action, 1); /* if not loaded, jump to.. */
- bufferWriteU8(yyval.action, SWFACTION_BRANCHALWAYS);
- bufferWriteS16(yyval.action, 2);
- bufferWriteS16(yyval.action, bufferLength(yyvsp[0].action)+5);
- bufferConcat(yyval.action, yyvsp[0].action); /* ..here */
- bufferWriteU8(yyval.action, SWFACTION_BRANCHALWAYS);
- bufferWriteS16(yyval.action, 2);
- bufferWriteS16(yyval.action, bufferLength(yyvsp[-2].action));
- bufferConcat(yyval.action, yyvsp[-2].action); ;}
- break;
-
- case 23:
-#line 244 "swf4compiler.y"
- { yyval.action = yyvsp[-3].action;
- bufferWriteU8(yyval.action, SWFACTION_WAITFORFRAMEEXPRESSION);
- bufferWriteS16(yyval.action, 1);
- bufferWriteU8(yyval.action, 1); /* if not loaded, jump to.. */
- bufferWriteU8(yyval.action, SWFACTION_BRANCHALWAYS);
- bufferWriteS16(yyval.action, 2);
- bufferWriteS16(yyval.action, 5);
- bufferWriteU8(yyval.action, SWFACTION_BRANCHALWAYS); /* ..here */
- bufferWriteS16(yyval.action, 2);
- bufferWriteS16(yyval.action, bufferLength(yyvsp[0].action)); /* ..and then out */
- bufferConcat(yyval.action, yyvsp[0].action); ;}
- break;
-
- case 24:
-#line 258 "swf4compiler.y"
- { yyval.action = yyvsp[-3].action;
- bufferWriteU8(yyval.action, SWFACTION_WAITFORFRAMEEXPRESSION);
- bufferWriteS16(yyval.action, 1);
- bufferWriteU8(yyval.action, 1); /* if not loaded, jump to.. */
- bufferWriteU8(yyval.action, SWFACTION_BRANCHALWAYS);
- bufferWriteS16(yyval.action, 2);
- bufferWriteS16(yyval.action, bufferLength(yyvsp[0].action));
- bufferConcat(yyval.action, yyvsp[0].action); ;}
- break;
-
- case 25:
-#line 268 "swf4compiler.y"
- { bufferWriteU8(yyvsp[-4].action, SWFACTION_BRANCHIFTRUE);
- bufferWriteS16(yyvsp[-4].action, 2);
- bufferWriteS16(yyvsp[-4].action, bufferLength(yyvsp[0].action)+5);
- bufferConcat(yyvsp[-4].action, yyvsp[0].action);
- bufferWriteU8(yyvsp[-4].action, SWFACTION_BRANCHALWAYS);
- bufferWriteS16(yyvsp[-4].action, 2);
- bufferWriteS16(yyvsp[-4].action, bufferLength(yyvsp[-2].action));
- bufferConcat(yyvsp[-4].action, yyvsp[-2].action);
- yyval.action = yyvsp[-4].action; ;}
- break;
-
- case 26:
-#line 279 "swf4compiler.y"
- { bufferWriteU8(yyvsp[-2].action, SWFACTION_LOGICALNOT);
- bufferWriteU8(yyvsp[-2].action, SWFACTION_BRANCHIFTRUE);
- bufferWriteS16(yyvsp[-2].action, 2);
- bufferWriteS16(yyvsp[-2].action, bufferLength(yyvsp[0].action));
- bufferConcat(yyvsp[-2].action, yyvsp[0].action);
- yyval.action = yyvsp[-2].action; ;}
- break;
-
- case 27:
-#line 288 "swf4compiler.y"
- { yyval.action = NULL; ;}
- break;
-
- case 28:
-#line 289 "swf4compiler.y"
- { yyval.action = yyvsp[0].action; ;}
- break;
-
- case 29:
-#line 314 "swf4compiler.y"
- { yyval.action = newBuffer();
- bufferWriteU8(yyval.action, SWFACTION_WAITFORFRAME);
- bufferWriteS16(yyval.action, 3);
- bufferWriteS16(yyval.action, atoi(yyvsp[-3].str));
- free(yyvsp[-3].str);
- bufferWriteU8(yyval.action, 1); /* if not loaded, jump to.. */
- bufferWriteU8(yyval.action, SWFACTION_BRANCHALWAYS);
- bufferWriteS16(yyval.action, 2);
- bufferWriteS16(yyval.action, bufferLength(yyvsp[0].action)+5);
- bufferConcat(yyval.action, yyvsp[0].action); /* ..here */
- bufferWriteU8(yyval.action, SWFACTION_BRANCHALWAYS);
- bufferWriteS16(yyval.action, 2);
- bufferWriteS16(yyval.action, -(bufferLength(yyval.action)+2)); ;}
- break;
-
- case 30:
-#line 329 "swf4compiler.y"
- { yyval.action = yyvsp[-2].action;
- bufferWriteU8(yyval.action, SWFACTION_LOGICALNOT);
- bufferWriteU8(yyval.action, SWFACTION_BRANCHIFTRUE);
- bufferWriteS16(yyval.action, 2);
- bufferWriteS16(yyval.action, bufferLength(yyvsp[0].action)+5);
- bufferConcat(yyval.action, yyvsp[0].action);
- bufferWriteU8(yyval.action, SWFACTION_BRANCHALWAYS);
- bufferWriteS16(yyval.action, 2);
- bufferWriteS16(yyval.action, -(bufferLength(yyval.action)+2));
- bufferResolveJumps(yyval.action); ;}
- break;
-
- case 31:
-#line 341 "swf4compiler.y"
- { yyval.action = yyvsp[-4].action;
- bufferConcat(yyval.action, yyvsp[-1].action);
- bufferWriteU8(yyval.action, SWFACTION_BRANCHIFTRUE);
- bufferWriteS16(yyval.action, 2);
- bufferWriteS16(yyval.action, -(bufferLength(yyval.action)+2));
- bufferResolveJumps(yyval.action); ;}
- break;
-
- case 32:
-#line 349 "swf4compiler.y"
- { if (!yyvsp[-4].action)
- yyvsp[-4].action = newBuffer();
- else {
- bufferWriteU8(yyvsp[-4].action, SWFACTION_LOGICALNOT);
- bufferWriteU8(yyvsp[-4].action, SWFACTION_BRANCHIFTRUE);
- bufferWriteS16(yyvsp[-4].action, 2);
- bufferWriteS16(yyvsp[-4].action, bufferLength(yyvsp[0].action)+bufferLength(yyvsp[-2].action)+5);
- }
- bufferConcat(yyvsp[-4].action, yyvsp[0].action);
- bufferConcat(yyvsp[-4].action, yyvsp[-2].action);
- bufferWriteU8(yyvsp[-4].action, SWFACTION_BRANCHALWAYS);
- bufferWriteS16(yyvsp[-4].action, 2);
- bufferWriteS16(yyvsp[-4].action, -(bufferLength(yyvsp[-4].action)+2));
- bufferResolveJumps(yyvsp[-4].action);
- yyval.action = yyvsp[-6].action;
- if(!yyval.action) yyval.action = newBuffer();
- bufferConcat(yyval.action, yyvsp[-4].action);
- ;}
- break;
-
- case 33:
-#line 370 "swf4compiler.y"
- { yyval.action = NULL; ;}
- break;
-
- case 35:
-#line 376 "swf4compiler.y"
- { yyval.action = newBuffer();
- bufferWriteU8(yyval.action, SWFACTION_BRANCHALWAYS);
- bufferWriteS16(yyval.action, 2);
- bufferWriteS16(yyval.action, MAGIC_CONTINUE_NUMBER); ;}
- break;
-
- case 36:
-#line 384 "swf4compiler.y"
- { yyval.action = newBuffer();
- bufferWriteU8(yyval.action, SWFACTION_BRANCHALWAYS);
- bufferWriteS16(yyval.action, 2);
- bufferWriteS16(yyval.action, MAGIC_BREAK_NUMBER); ;}
- break;
-
- case 37:
-#line 392 "swf4compiler.y"
- { yyval.action = newBuffer();
- bufferWriteU8(yyval.action, SWFACTION_STOPDRAGMOVIE); ;}
- break;
-
- case 38:
-#line 396 "swf4compiler.y"
- { yyval.action = newBuffer();
- bufferWriteString(yyval.action, yyvsp[-1].str, strlen(yyvsp[-1].str)+1);
- bufferWriteU8(yyval.action, SWFACTION_CALLFRAME);
- bufferWriteS16(yyval.action, 0);
- free(yyvsp[-1].str); ;}
- break;
-
- case 39:
-#line 403 "swf4compiler.y"
- { yyval.action = newBuffer();
- bufferWriteString(yyval.action, yyvsp[-1].str, strlen(yyvsp[-1].str)+1);
- bufferWriteU8(yyval.action, SWFACTION_CALLFRAME);
- bufferWriteS16(yyval.action, 0);
- free(yyvsp[-1].str); ;}
- break;
-
- case 40:
-#line 410 "swf4compiler.y"
- { yyval.action = yyvsp[-1].action;
- bufferWriteU8(yyval.action, SWFACTION_REMOVECLIP); ;}
- break;
-
- case 41:
-#line 414 "swf4compiler.y"
- { yyval.action = yyvsp[-1].action;
- bufferWriteU8(yyval.action, SWFACTION_TRACE); ;}
- break;
-
- case 42:
-#line 419 "swf4compiler.y"
- { yyval.action = yyvsp[-3].action;
- bufferConcat(yyval.action, yyvsp[-1].action);
- bufferWriteU8(yyval.action, SWFACTION_GETURL2);
- bufferWriteS16(yyval.action, 1);
- bufferWriteU8(yyval.action, GETURL_METHOD_NOSEND); ;}
- break;
-
- case 43:
-#line 426 "swf4compiler.y"
- { yyval.action = yyvsp[-5].action;
- bufferConcat(yyval.action, yyvsp[-3].action);
- bufferWriteU8(yyval.action, SWFACTION_GETURL2);
- bufferWriteS16(yyval.action, 1);
- bufferWriteU8(yyval.action, yyvsp[-1].getURLMethod); ;}
- break;
-
- case 44:
-#line 433 "swf4compiler.y"
- { yyval.action = newBuffer();
- bufferWriteU8(yyval.action, SWFACTION_GETURL);
- bufferWriteS16(yyval.action, strlen(yyvsp[-3].str) + strlen(yyvsp[-1].str) + 2);
- bufferWriteHardString(yyval.action, (byte*)yyvsp[-3].str, strlen(yyvsp[-3].str));
- bufferWriteU8(yyval.action, 0);
- bufferWriteHardString(yyval.action, (byte*)yyvsp[-1].str, strlen(yyvsp[-1].str));
- bufferWriteU8(yyval.action, 0); ;}
- break;
-
- case 45:
-#line 442 "swf4compiler.y"
- { yyval.action = yyvsp[-3].action;
- bufferConcat(yyval.action, yyvsp[-1].action);
- bufferWriteU8(yyval.action, SWFACTION_GETURL2);
- bufferWriteS16(yyval.action, 1);
- bufferWriteU8(yyval.action, GETURL_METHOD_NOSEND | GETURL_LOADMOVIE); ;}
- break;
-
- case 46:
-#line 449 "swf4compiler.y"
- { yyval.action = yyvsp[-5].action;
- bufferConcat(yyval.action, yyvsp[-3].action);
- bufferWriteU8(yyval.action, SWFACTION_GETURL2);
- bufferWriteS16(yyval.action, 1);
- bufferWriteU8(yyval.action, yyvsp[-1].getURLMethod | GETURL_LOADMOVIE); ;}
- break;
-
- case 47:
-#line 456 "swf4compiler.y"
- { yyval.action = yyvsp[-3].action;
- bufferConcat(yyval.action, yyvsp[-1].action);
- bufferWriteU8(yyval.action, SWFACTION_GETURL2);
- bufferWriteS16(yyval.action, 1);
- bufferWriteU8(yyval.action, GETURL_METHOD_NOSEND | GETURL_LOADVARIABLES); ;}
- break;
-
- case 48:
-#line 463 "swf4compiler.y"
- { yyval.action = yyvsp[-5].action;
- bufferConcat(yyval.action, yyvsp[-3].action);
- bufferWriteU8(yyval.action, SWFACTION_GETURL2);
- bufferWriteS16(yyval.action, 1);
- bufferWriteU8(yyval.action, yyvsp[-1].getURLMethod | GETURL_LOADVARIABLES); ;}
- break;
-
- case 49:
-#line 471 "swf4compiler.y"
- { yyval.action = newBuffer();
- bufferWriteString(yyval.action, "0", 2); /* no constraint */
- bufferConcat(yyval.action, yyvsp[-1].action);
- bufferConcat(yyval.action, yyvsp[-3].action);
- bufferWriteU8(yyval.action, SWFACTION_STARTDRAGMOVIE); ;}
- break;
-
- case 50:
-#line 478 "swf4compiler.y"
- { yyval.action = newBuffer();
- bufferConcat(yyval.action, yyvsp[-7].action);
- bufferConcat(yyval.action, yyvsp[-3].action);
- bufferConcat(yyval.action, yyvsp[-5].action);
- bufferConcat(yyval.action, yyvsp[-1].action);
- bufferWriteString(yyval.action, "1", 2); /* has constraint */
- bufferConcat(yyval.action, yyvsp[-9].action);
- bufferConcat(yyval.action, yyvsp[-11].action);
- bufferWriteU8(yyval.action, SWFACTION_STARTDRAGMOVIE); ;}
- break;
-
- case 51:
-#line 490 "swf4compiler.y"
- { yyval.action = yyvsp[-5].action;
- bufferConcat(yyval.action, yyvsp[-3].action);
- bufferConcat(yyval.action, yyvsp[-1].action);
- bufferWriteWTHITProperty(yyval.action);
- bufferWriteU8(yyval.action, SWFACTION_ADD); /* see docs for explanation */
- bufferWriteU8(yyval.action, SWFACTION_DUPLICATECLIP); ;}
- break;
-
- case 52:
-#line 499 "swf4compiler.y"
- { yyval.action = newBuffer();
- bufferWriteU8(yyval.action, SWFACTION_NEXTFRAME); ;}
- break;
-
- case 53:
-#line 503 "swf4compiler.y"
- { yyval.action = newBuffer();
- bufferWriteU8(yyval.action, SWFACTION_PREVFRAME); ;}
- break;
-
- case 54:
-#line 507 "swf4compiler.y"
- { yyval.action = newBuffer();
- bufferWriteU8(yyval.action, SWFACTION_PLAY); ;}
- break;
-
- case 55:
-#line 511 "swf4compiler.y"
- { yyval.action = newBuffer();
- bufferWriteU8(yyval.action, SWFACTION_STOP); ;}
- break;
-
- case 56:
-#line 515 "swf4compiler.y"
- { yyval.action = newBuffer();
- bufferWriteU8(yyval.action, SWFACTION_TOGGLEQUALITY); ;}
- break;
-
- case 57:
-#line 519 "swf4compiler.y"
- { yyval.action = newBuffer();
- bufferWriteU8(yyval.action, SWFACTION_STOPSOUNDS); ;}
- break;
-
- case 58:
-#line 523 "swf4compiler.y"
- { yyval.action = newBuffer();
- bufferWriteU8(yyval.action, SWFACTION_GOTOFRAME);
- bufferWriteS16(yyval.action, 2);
- bufferWriteS16(yyval.action, atoi(yyvsp[-1].str));
- free(yyvsp[-1].str); ;}
- break;
-
- case 59:
-#line 530 "swf4compiler.y"
- { yyval.action = newBuffer();
- bufferWriteU8(yyval.action, SWFACTION_GOTOLABEL);
- bufferWriteS16(yyval.action, strlen(yyvsp[-1].str)+1);
- bufferWriteHardString(yyval.action, (byte*)yyvsp[-1].str, strlen(yyvsp[-1].str)+1);
- free(yyvsp[-1].str); ;}
- break;
-
- case 60:
-#line 537 "swf4compiler.y"
- { yyval.action = yyvsp[-1].action;
- bufferWriteU8(yyval.action, SWFACTION_GOTOEXPRESSION);
- bufferWriteS16(yyval.action, 1);
- bufferWriteU8(yyval.action, 0); ;}
- break;
-
- case 61:
-#line 543 "swf4compiler.y"
- { yyval.action = yyvsp[-1].action;
- bufferWriteU8(yyval.action, SWFACTION_GOTOEXPRESSION);
- bufferWriteS16(yyval.action, 1);
- bufferWriteU8(yyval.action, 1); ;}
- break;
-
- case 62:
-#line 549 "swf4compiler.y"
- { yyval.action = newBuffer();
- bufferWriteU8(yyval.action, SWFACTION_SETTARGET);
- bufferWriteS16(yyval.action, strlen(yyvsp[-1].str)+1);
- bufferWriteHardString(yyval.action, (byte*)yyvsp[-1].str, strlen(yyvsp[-1].str)+1);
- free(yyvsp[-1].str); ;}
- break;
-
- case 63:
-#line 556 "swf4compiler.y"
- { yyval.action = yyvsp[-1].action;
- bufferWriteU8(yyval.action, SWFACTION_SETTARGETEXPRESSION); ;}
- break;
-
- case 64:
-#line 560 "swf4compiler.y"
- { yyval.action = newBuffer();
- /* SetTarget(STRING) */
- bufferWriteU8(yyval.action, SWFACTION_SETTARGET);
- bufferWriteS16(yyval.action, strlen(yyvsp[-2].str)+1);
- bufferWriteHardString(yyval.action, (byte*)yyvsp[-2].str, strlen(yyvsp[-2].str)+1);
- /* stmt */
- bufferConcat(yyval.action, yyvsp[0].action);
- /* SetTarget('') */
- bufferWriteU8(yyval.action, SWFACTION_SETTARGET);
- bufferWriteS16(yyval.action, 1);
- bufferWriteU8(yyval.action, 0);
- free(yyvsp[-2].str); ;}
- break;
-
- case 65:
-#line 574 "swf4compiler.y"
- { yyval.action = yyvsp[-2].action;
- /* SetTarget(expr) */
- bufferWriteU8(yyval.action, SWFACTION_SETTARGETEXPRESSION);
- /* stmt */
- bufferConcat(yyval.action, yyvsp[0].action);
- /* SetTarget('') */
- bufferWriteU8(yyval.action, SWFACTION_SETTARGET);
- bufferWriteS16(yyval.action, 1);
- bufferWriteU8(yyval.action, 0); ;}
- break;
-
- case 66:
-#line 587 "swf4compiler.y"
- { yyval.action = yyvsp[-1].action;
- bufferWriteU8(yyval.action, SWFACTION_GETVARIABLE); ;}
- break;
-
- case 67:
-#line 591 "swf4compiler.y"
- { yyval.action = newBuffer();
- bufferWriteU8(yyval.action, SWFACTION_GETTIMER); ;}
- break;
-
- case 68:
-#line 595 "swf4compiler.y"
- { yyval.action = yyvsp[-1].action;
- bufferWriteU8(yyval.action, SWFACTION_RANDOM); ;}
- break;
-
- case 69:
-#line 599 "swf4compiler.y"
- { yyval.action = yyvsp[-1].action;
- bufferWriteU8(yyval.action, SWFACTION_STRINGLENGTH); ;}
- break;
-
- case 70:
-#line 603 "swf4compiler.y"
- { yyval.action = yyvsp[-1].action;
- bufferWriteU8(yyval.action, SWFACTION_INT); ;}
- break;
-
- case 71:
-#line 607 "swf4compiler.y"
- { yyval.action = yyvsp[-1].action;
- bufferWriteU8(yyval.action, SWFACTION_ORD); ;}
- break;
-
- case 72:
-#line 611 "swf4compiler.y"
- { yyval.action = yyvsp[-1].action;
- bufferWriteU8(yyval.action, SWFACTION_CHR); ;}
- break;
-
- case 73:
-#line 615 "swf4compiler.y"
- { yyval.action = yyvsp[-3].action;
- bufferConcat(yyval.action, yyvsp[-1].action);
- bufferWriteU8(yyval.action, SWFACTION_STRINGCONCAT); ;}
- break;
-
- case 74:
-#line 620 "swf4compiler.y"
- { yyval.action = yyvsp[-5].action;
- bufferConcat(yyval.action, yyvsp[-3].action);
- bufferConcat(yyval.action, yyvsp[-1].action);
- bufferWriteU8(yyval.action, SWFACTION_SUBSTRING); ;}
- break;
-
- case 75:
-#line 626 "swf4compiler.y"
- { yyval.action = newBuffer();
- bufferConcat(yyval.action, yyvsp[-3].action);
- bufferWriteGetProperty(yyval.action, yyvsp[-1].str);
- bufferWriteU8(yyval.action, SWFACTION_GETPROPERTY);
- free(yyvsp[-1].str); ;}
- break;
-
- case 76:
-#line 635 "swf4compiler.y"
- { yyval.action = newBuffer();
- bufferWriteBuffer(yyval.action, yyvsp[-1].action);
- bufferWriteU8(yyval.action, SWFACTION_GETVARIABLE);
- bufferWriteBuffer(yyval.action, yyvsp[-1].action);
- bufferConcat(yyval.action, yyvsp[-1].action);
- bufferWriteU8(yyval.action, SWFACTION_GETVARIABLE);
- bufferWriteString(yyval.action, "1", 2);
- bufferWriteU8(yyval.action, SWFACTION_ADD);
- bufferWriteU8(yyval.action, SWFACTION_SETVARIABLE); ;}
- break;
-
- case 77:
-#line 646 "swf4compiler.y"
- { yyval.action = newBuffer();
- bufferWriteBuffer(yyval.action, yyvsp[-1].action);
- bufferWriteU8(yyval.action, SWFACTION_GETVARIABLE);
- bufferWriteBuffer(yyval.action, yyvsp[-1].action);
- bufferConcat(yyval.action, yyvsp[-1].action);
- bufferWriteU8(yyval.action, SWFACTION_GETVARIABLE);
- bufferWriteString(yyval.action, "1", 2);
- bufferWriteU8(yyval.action, SWFACTION_SUBTRACT);
- bufferWriteU8(yyval.action, SWFACTION_SETVARIABLE); ;}
- break;
-
- case 79:
-#line 662 "swf4compiler.y"
- { yyval.action = yyvsp[-1].action; ;}
- break;
-
- case 80:
-#line 665 "swf4compiler.y"
- { yyval.action = newBuffer();
- bufferWriteString(yyval.action, yyvsp[0].str, strlen(yyvsp[0].str)+1);
- free(yyvsp[0].str); ;}
- break;
-
- case 81:
-#line 670 "swf4compiler.y"
- { yyval.action = newBuffer();
- bufferWriteString(yyval.action, "-", 2);
- bufferWriteString(yyval.action, yyvsp[0].str, strlen(yyvsp[0].str)+1);
- free(yyvsp[0].str); ;}
- break;
-
- case 82:
-#line 676 "swf4compiler.y"
- { yyval.action = newBuffer();
- bufferWriteString(yyval.action, yyvsp[0].str, strlen(yyvsp[0].str)+1);
- free(yyvsp[0].str); ;}
- break;
-
- case 83:
-#line 681 "swf4compiler.y"
- { yyval.action = newBuffer();
- bufferWriteString(yyval.action, yyvsp[0].str, strlen(yyvsp[0].str)+1);
- bufferWriteU8(yyval.action, SWFACTION_GETVARIABLE);
- free(yyvsp[0].str); ;}
- break;
-
- case 84:
-#line 687 "swf4compiler.y"
- { yyval.action = newBuffer();
- bufferWriteString(yyval.action, yyvsp[0].str, strlen(yyvsp[0].str)+1);
- free(yyvsp[0].str); ;}
- break;
-
- case 85:
-#line 692 "swf4compiler.y"
- { yyval.action = newBuffer();
- bufferWriteString(yyval.action, yyvsp[-2].str, strlen(yyvsp[-2].str)+1);
- bufferWriteGetProperty(yyval.action, yyvsp[0].str);
- bufferWriteU8(yyval.action, SWFACTION_GETPROPERTY);
- free(yyvsp[0].str);
- free(yyvsp[-2].str); ;}
- break;
-
- case 86:
-#line 700 "swf4compiler.y"
- { yyval.action = newBuffer();
- bufferWriteString(yyval.action, yyvsp[-2].str, strlen(yyvsp[-2].str)+1);
- bufferWriteGetProperty(yyval.action, yyvsp[0].str);
- bufferWriteString(yyval.action, yyvsp[-2].str, strlen(yyvsp[-2].str)+1);
- bufferWriteSetProperty(yyval.action, yyvsp[0].str);
- bufferWriteString(yyval.action, yyvsp[-2].str, strlen(yyvsp[-2].str)+1);
- bufferWriteGetProperty(yyval.action, yyvsp[0].str);
- bufferWriteString(yyval.action, "1", 2);
- bufferWriteU8(yyval.action, SWFACTION_ADD);
- bufferWriteU8(yyval.action, SWFACTION_SETPROPERTY);
- bufferWriteU8(yyval.action, SWFACTION_GETPROPERTY);
- free(yyvsp[-2].str);
- free(yyvsp[0].str); ;}
- break;
-
- case 87:
-#line 715 "swf4compiler.y"
- { yyval.action = yyvsp[0].action;
- bufferWriteU8(yyval.action, SWFACTION_DUP);
- bufferWriteU8(yyval.action, SWFACTION_DUP);
- bufferWriteU8(yyval.action, SWFACTION_GETVARIABLE);
- bufferWriteString(yyval.action, "1", 2);
- bufferWriteU8(yyval.action, SWFACTION_ADD);
- bufferWriteU8(yyval.action, SWFACTION_SETVARIABLE);
- bufferWriteU8(yyval.action, SWFACTION_GETVARIABLE); ;}
- break;
-
- case 88:
-#line 725 "swf4compiler.y"
- { yyval.action = newBuffer();
- bufferWriteString(yyval.action, yyvsp[-2].str, strlen(yyvsp[-2].str)+1);
- bufferWriteGetProperty(yyval.action, yyvsp[0].str);
- bufferWriteString(yyval.action, yyvsp[-2].str, strlen(yyvsp[-2].str)+1);
- bufferWriteSetProperty(yyval.action, yyvsp[0].str);
- bufferWriteString(yyval.action, yyvsp[-2].str, strlen(yyvsp[-2].str)+1);
- bufferWriteGetProperty(yyval.action, yyvsp[0].str);
- bufferWriteString(yyval.action, "1", 2);
- bufferWriteU8(yyval.action, SWFACTION_ADD);
- bufferWriteU8(yyval.action, SWFACTION_SETPROPERTY);
- bufferWriteU8(yyval.action, SWFACTION_GETPROPERTY);
- free(yyvsp[-2].str);
- free(yyvsp[0].str); ;}
- break;
-
- case 89:
-#line 740 "swf4compiler.y"
- { yyval.action = yyvsp[0].action;
- bufferWriteU8(yyval.action, SWFACTION_DUP);
- bufferWriteU8(yyval.action, SWFACTION_DUP);
- bufferWriteU8(yyval.action, SWFACTION_GETVARIABLE);
- bufferWriteString(yyval.action, "1", 2);
- bufferWriteU8(yyval.action, SWFACTION_SUBTRACT);
- bufferWriteU8(yyval.action, SWFACTION_SETVARIABLE);
- bufferWriteU8(yyval.action, SWFACTION_GETVARIABLE); ;}
- break;
-
- case 90:
-#line 750 "swf4compiler.y"
- { yyval.action = yyvsp[0].action;
- bufferWriteString(yyvsp[0].action, "-1", 3);
- bufferWriteU8(yyvsp[0].action, SWFACTION_MULTIPLY); ;}
- break;
-
- case 91:
-#line 755 "swf4compiler.y"
- { yyval.action = yyvsp[0].action;
- bufferWriteU8(yyvsp[0].action, SWFACTION_LOGICALNOT); ;}
- break;
-
- case 92:
-#line 759 "swf4compiler.y"
- { yyval.action = yyvsp[-2].action;
- bufferConcat(yyval.action, yyvsp[0].action);
- bufferWriteU8(yyval.action, SWFACTION_DUP);
- bufferWriteU8(yyval.action, SWFACTION_SETVARIABLE); ;}
- break;
-
- case 93:
-#line 765 "swf4compiler.y"
- { yyval.action = yyvsp[-2].action;
- bufferConcat(yyval.action, yyvsp[0].action);
- bufferWriteU8(yyval.action, SWFACTION_MULTIPLY); ;}
- break;
-
- case 94:
-#line 770 "swf4compiler.y"
- { yyval.action = yyvsp[-2].action;
- bufferConcat(yyval.action, yyvsp[0].action);
- bufferWriteU8(yyval.action, SWFACTION_DIVIDE); ;}
- break;
-
- case 95:
-#line 775 "swf4compiler.y"
- { yyval.action = yyvsp[-2].action;
- bufferConcat(yyval.action, yyvsp[0].action);
- bufferWriteU8(yyval.action, SWFACTION_ADD); ;}
- break;
-
- case 96:
-#line 780 "swf4compiler.y"
- { yyval.action = yyvsp[-2].action;
- bufferConcat(yyval.action, yyvsp[0].action);
- bufferWriteU8(yyval.action, SWFACTION_SUBTRACT); ;}
- break;
-
- case 97:
-#line 785 "swf4compiler.y"
- { yyval.action = yyvsp[-2].action;
- bufferConcat(yyval.action, yyvsp[0].action);
- bufferWriteU8(yyval.action, SWFACTION_STRINGCONCAT); ;}
- break;
-
- case 98:
-#line 790 "swf4compiler.y"
- { yyval.action = yyvsp[-2].action;
- bufferConcat(yyval.action, yyvsp[0].action);
- bufferWriteU8(yyval.action, SWFACTION_LESSTHAN); ;}
- break;
-
- case 99:
-#line 795 "swf4compiler.y"
- { yyval.action = yyvsp[0].action;
- bufferConcat(yyval.action, yyvsp[-2].action);
- bufferWriteU8(yyval.action, SWFACTION_LESSTHAN); ;}
- break;
-
- case 100:
-#line 800 "swf4compiler.y"
- { yyval.action = yyvsp[0].action;
- bufferConcat(yyval.action, yyvsp[-2].action);
- bufferWriteU8(yyval.action, SWFACTION_LESSTHAN);
- bufferWriteU8(yyval.action, SWFACTION_LOGICALNOT); ;}
- break;
-
- case 101:
-#line 806 "swf4compiler.y"
- { bufferConcat(yyvsp[-2].action, yyvsp[0].action);
- bufferWriteU8(yyvsp[-2].action, SWFACTION_LESSTHAN);
- bufferWriteU8(yyvsp[-2].action, SWFACTION_LOGICALNOT); ;}
- break;
-
- case 102:
-#line 811 "swf4compiler.y"
- { bufferConcat(yyvsp[-2].action, yyvsp[0].action);
- bufferWriteU8(yyvsp[-2].action, SWFACTION_STRINGEQ);
- bufferWriteU8(yyvsp[-2].action, SWFACTION_LOGICALNOT); ;}
- break;
-
- case 103:
-#line 816 "swf4compiler.y"
- { bufferConcat(yyvsp[-2].action, yyvsp[0].action);
- bufferWriteU8(yyvsp[-2].action, SWFACTION_STRINGEQ); ;}
- break;
-
- case 104:
-#line 820 "swf4compiler.y"
- { bufferConcat(yyvsp[-2].action, yyvsp[0].action);
- bufferWriteU8(yyvsp[-2].action, SWFACTION_STRINGCOMPARE); ;}
- break;
-
- case 105:
-#line 824 "swf4compiler.y"
- { bufferConcat(yyvsp[-2].action, yyvsp[0].action);
- bufferWriteU8(yyvsp[-2].action, SWFACTION_EQUAL); ;}
- break;
-
- case 106:
-#line 828 "swf4compiler.y"
- { bufferConcat(yyvsp[-2].action, yyvsp[0].action);
- bufferWriteU8(yyvsp[-2].action, SWFACTION_EQUAL);
- bufferWriteU8(yyvsp[-2].action, SWFACTION_LOGICALNOT); ;}
- break;
-
- case 107:
-#line 833 "swf4compiler.y"
- { bufferConcat(yyvsp[-2].action, yyvsp[0].action);
- bufferWriteU8(yyvsp[-2].action, SWFACTION_LOGICALAND); ;}
- break;
-
- case 108:
-#line 837 "swf4compiler.y"
- { bufferConcat(yyvsp[-2].action, yyvsp[0].action);
- bufferWriteU8(yyvsp[-2].action, SWFACTION_LOGICALOR); ;}
- break;
-
- case 109:
-#line 841 "swf4compiler.y"
- { bufferWriteU8(yyvsp[-4].action, SWFACTION_BRANCHIFTRUE);
- bufferWriteS16(yyvsp[-4].action, 2);
- bufferWriteS16(yyvsp[-4].action, bufferLength(yyvsp[0].action)+5);
- bufferConcat(yyvsp[-4].action, yyvsp[0].action);
- bufferWriteU8(yyvsp[-4].action, SWFACTION_BRANCHALWAYS);
- bufferWriteS16(yyvsp[-4].action, 2);
- bufferWriteS16(yyvsp[-4].action, bufferLength(yyvsp[-2].action));
- bufferConcat(yyvsp[-4].action, yyvsp[-2].action); ;}
- break;
-
- case 111:
-#line 855 "swf4compiler.y"
- { yyval.str = yyvsp[-2].str;
- yyval.str = stringConcat(yyval.str, strdup(":"));
- yyval.str = stringConcat(yyval.str, yyvsp[0].str); ;}
- break;
-
- case 112:
-#line 862 "swf4compiler.y"
- { yyval.str = strdup(""); ;}
- break;
-
- case 113:
-#line 865 "swf4compiler.y"
- { yyval.str = strdup(""); ;}
- break;
-
- case 114:
-#line 868 "swf4compiler.y"
- { yyval.str = strdup("/"); ;}
- break;
-
- case 115:
-#line 871 "swf4compiler.y"
- { yyval.str = strdup(".."); ;}
- break;
-
- case 116:
-#line 874 "swf4compiler.y"
- { yyval.str = yyvsp[0].str; ;}
- break;
-
- case 117:
-#line 877 "swf4compiler.y"
- { yyval.str = yyvsp[0].str; ;}
- break;
-
- case 118:
-#line 882 "swf4compiler.y"
- { yyval.action = newBuffer();
- bufferWriteString(yyval.action, yyvsp[0].str, strlen(yyvsp[0].str)+1);
- free(yyvsp[0].str); ;}
- break;
-
- case 119:
-#line 887 "swf4compiler.y"
- { yyval.action = newBuffer();
- bufferWriteString(yyval.action, yyvsp[0].str, strlen(yyvsp[0].str)+1);
- free(yyvsp[0].str); ;}
- break;
-
- case 120:
-#line 891 "swf4compiler.y"
- { yyval.action = yyvsp[-1].action; ;}
- break;
-
- case 123:
-#line 900 "swf4compiler.y"
- { yyval.action = yyvsp[0].action;
- bufferWriteBuffer(yyval.action, yyvsp[0].action);
- bufferWriteU8(yyval.action, SWFACTION_GETVARIABLE);
- bufferWriteString(yyval.action, "1", 2);
- bufferWriteU8(yyval.action, SWFACTION_ADD);
- bufferWriteU8(yyval.action, SWFACTION_SETVARIABLE); ;}
- break;
-
- case 124:
-#line 908 "swf4compiler.y"
- { yyval.action = yyvsp[0].action;
- bufferWriteBuffer(yyval.action, yyvsp[0].action);
- bufferWriteU8(yyval.action, SWFACTION_GETVARIABLE);
- bufferWriteString(yyval.action, "1", 2);
- bufferWriteU8(yyval.action, SWFACTION_SUBTRACT);
- bufferWriteU8(yyval.action, SWFACTION_SETVARIABLE); ;}
- break;
-
- case 125:
-#line 916 "swf4compiler.y"
- { yyval.action = newBuffer();
- bufferWriteString(yyval.action, yyvsp[-2].str, strlen(yyvsp[-2].str)+1);
- bufferWriteGetProperty(yyval.action, yyvsp[0].str);
- bufferWriteU8(yyval.action, SWFACTION_GETPROPERTY);
- bufferWriteString(yyval.action, "1", 2);
- bufferWriteU8(yyval.action, SWFACTION_ADD);
- bufferWriteString(yyval.action, yyvsp[-2].str, strlen(yyvsp[-2].str)+1);
- bufferWriteSetProperty(yyval.action, yyvsp[0].str);
- bufferWriteU8(yyval.action, SWFACTION_SETPROPERTY);
- free(yyvsp[-2].str);
- free(yyvsp[0].str); ;}
- break;
-
- case 126:
-#line 929 "swf4compiler.y"
- { yyval.action = newBuffer();
- bufferWriteString(yyval.action, yyvsp[-2].str, strlen(yyvsp[-2].str)+1);
- bufferWriteGetProperty(yyval.action, yyvsp[0].str);
- bufferWriteU8(yyval.action, SWFACTION_GETPROPERTY);
- bufferWriteString(yyval.action, "1", 2);
- bufferWriteU8(yyval.action, SWFACTION_SUBTRACT);
- bufferWriteString(yyval.action, yyvsp[-2].str, strlen(yyvsp[-2].str)+1);
- bufferWriteSetProperty(yyval.action, yyvsp[0].str);
- bufferWriteU8(yyval.action, SWFACTION_SETPROPERTY);
- free(yyvsp[-2].str);
- free(yyvsp[0].str); ;}
- break;
-
- case 127:
-#line 942 "swf4compiler.y"
- { bufferConcat(yyvsp[-2].action, yyvsp[0].action);
- bufferWriteU8(yyvsp[-2].action, SWFACTION_SETVARIABLE); ;}
- break;
-
- case 128:
-#line 946 "swf4compiler.y"
- { bufferWriteBuffer(yyvsp[-2].action, yyvsp[-2].action);
- bufferWriteU8(yyvsp[-2].action, SWFACTION_GETVARIABLE);
- bufferConcat(yyvsp[-2].action, yyvsp[0].action);
- bufferWriteU8(yyvsp[-2].action, SWFACTION_MULTIPLY);
- bufferWriteU8(yyvsp[-2].action, SWFACTION_SETVARIABLE); ;}
- break;
-
- case 129:
-#line 953 "swf4compiler.y"
- { bufferWriteBuffer(yyvsp[-2].action, yyvsp[-2].action);
- bufferWriteU8(yyvsp[-2].action, SWFACTION_GETVARIABLE);
- bufferConcat(yyvsp[-2].action, yyvsp[0].action);
- bufferWriteU8(yyvsp[-2].action, SWFACTION_DIVIDE);
- bufferWriteU8(yyvsp[-2].action, SWFACTION_SETVARIABLE); ;}
- break;
-
- case 130:
-#line 960 "swf4compiler.y"
- { bufferWriteBuffer(yyvsp[-2].action, yyvsp[-2].action);
- bufferWriteU8(yyvsp[-2].action, SWFACTION_GETVARIABLE);
- bufferConcat(yyvsp[-2].action, yyvsp[0].action);
- bufferWriteU8(yyvsp[-2].action, SWFACTION_ADD);
- bufferWriteU8(yyvsp[-2].action, SWFACTION_SETVARIABLE); ;}
- break;
-
- case 131:
-#line 967 "swf4compiler.y"
- { bufferWriteBuffer(yyvsp[-2].action, yyvsp[-2].action);
- bufferWriteU8(yyvsp[-2].action, SWFACTION_GETVARIABLE);
- bufferConcat(yyvsp[-2].action, yyvsp[0].action);
- bufferWriteU8(yyvsp[-2].action, SWFACTION_SUBTRACT);
- bufferWriteU8(yyvsp[-2].action, SWFACTION_SETVARIABLE); ;}
- break;
-
- case 132:
-#line 974 "swf4compiler.y"
- { yyval.action = newBuffer();
- bufferWriteString(yyval.action, yyvsp[-4].str, strlen(yyvsp[-4].str)+1);
- bufferWriteSetProperty(yyval.action, yyvsp[-2].str);
- bufferConcat(yyval.action,yyvsp[0].action);
- bufferWriteU8(yyval.action, SWFACTION_SETPROPERTY);
- free(yyvsp[-4].str);
- free(yyvsp[-2].str); ;}
- break;
-
- case 133:
-#line 983 "swf4compiler.y"
- { yyval.action = newBuffer();
- bufferWriteString(yyval.action, yyvsp[-4].str, strlen(yyvsp[-4].str)+1);
- bufferWriteSetProperty(yyval.action, yyvsp[-2].str);
- bufferWriteString(yyval.action, yyvsp[-4].str, strlen(yyvsp[-4].str)+1);
- bufferWriteGetProperty(yyval.action, yyvsp[-2].str);
- bufferWriteU8(yyval.action, SWFACTION_GETPROPERTY);
- bufferConcat(yyval.action, yyvsp[0].action);
- bufferWriteU8(yyval.action, SWFACTION_MULTIPLY);
- bufferWriteU8(yyval.action, SWFACTION_SETPROPERTY);
- free(yyvsp[-4].str);
- free(yyvsp[-2].str); ;}
- break;
-
- case 134:
-#line 996 "swf4compiler.y"
- { yyval.action = newBuffer();
- bufferWriteString(yyval.action, yyvsp[-4].str, strlen(yyvsp[-4].str)+1);
- bufferWriteSetProperty(yyval.action, yyvsp[-2].str);
- bufferWriteString(yyval.action, yyvsp[-4].str, strlen(yyvsp[-4].str)+1);
- bufferWriteGetProperty(yyval.action, yyvsp[-2].str);
- bufferWriteU8(yyval.action, SWFACTION_GETPROPERTY);
- bufferConcat(yyval.action, yyvsp[0].action);
- bufferWriteU8(yyval.action, SWFACTION_DIVIDE);
- bufferWriteU8(yyval.action, SWFACTION_SETPROPERTY);
- free(yyvsp[-4].str);
- free(yyvsp[-2].str); ;}
- break;
-
- case 135:
-#line 1009 "swf4compiler.y"
- { yyval.action = newBuffer();
- bufferWriteString(yyval.action, yyvsp[-4].str, strlen(yyvsp[-4].str)+1);
- bufferWriteSetProperty(yyval.action, yyvsp[-2].str);
- bufferWriteString(yyval.action, yyvsp[-4].str, strlen(yyvsp[-4].str)+1);
- bufferWriteGetProperty(yyval.action, yyvsp[-2].str);
- bufferWriteU8(yyval.action, SWFACTION_GETPROPERTY);
- bufferConcat(yyval.action, yyvsp[0].action);
- bufferWriteU8(yyval.action, SWFACTION_ADD);
- bufferWriteU8(yyval.action, SWFACTION_SETPROPERTY);
- free(yyvsp[-4].str);
- free(yyvsp[-2].str); ;}
- break;
-
- case 136:
-#line 1022 "swf4compiler.y"
- { yyval.action = newBuffer();
- bufferWriteString(yyval.action, yyvsp[-4].str, strlen(yyvsp[-4].str)+1);
- bufferWriteSetProperty(yyval.action, yyvsp[-2].str);
- bufferWriteString(yyval.action, yyvsp[-4].str, strlen(yyvsp[-4].str)+1);
- bufferWriteGetProperty(yyval.action, yyvsp[-2].str);
- bufferWriteU8(yyval.action, SWFACTION_GETPROPERTY);
- bufferConcat(yyval.action, yyvsp[0].action);
- bufferWriteU8(yyval.action, SWFACTION_SUBTRACT);
- bufferWriteU8(yyval.action, SWFACTION_SETPROPERTY);
- free(yyvsp[-4].str);
- free(yyvsp[-2].str); ;}
- break;
-
-
- }
-
-/* Line 999 of yacc.c. */
-#line 2691 "swf4compiler.tab.c"
-\f
- yyvsp -= yylen;
- yyssp -= yylen;
-
-
- YY_STACK_PRINT (yyss, yyssp);
-
- *++yyvsp = yyval;
-
-
- /* Now `shift' the result of the reduction. Determine what state
- that goes to, based on the state we popped back to and the rule
- number reduced by. */
-
- yyn = yyr1[yyn];
-
- yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
- if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
- yystate = yytable[yystate];
- else
- yystate = yydefgoto[yyn - YYNTOKENS];
-
- goto yynewstate;
-
-
-/*------------------------------------.
-| yyerrlab -- here on detecting error |
-`------------------------------------*/
-yyerrlab:
- /* If not already recovering from an error, report this error. */
- if (!yyerrstatus)
- {
- ++yynerrs;
-#if YYERROR_VERBOSE
- yyn = yypact[yystate];
-
- if (YYPACT_NINF < yyn && yyn < YYLAST)
- {
- YYSIZE_T yysize = 0;
- int yytype = YYTRANSLATE (yychar);
- char *yymsg;
- int yyx, yycount;
-
- yycount = 0;
- /* Start YYX at -YYN if negative to avoid negative indexes in
- YYCHECK. */
- for (yyx = yyn < 0 ? -yyn : 0;
- yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
- if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
- yysize += yystrlen (yytname[yyx]) + 15, yycount++;
- yysize += yystrlen ("syntax error, unexpected ") + 1;
- yysize += yystrlen (yytname[yytype]);
- yymsg = (char *) YYSTACK_ALLOC (yysize);
- if (yymsg != 0)
- {
- char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
- yyp = yystpcpy (yyp, yytname[yytype]);
-
- if (yycount < 5)
- {
- yycount = 0;
- for (yyx = yyn < 0 ? -yyn : 0;
- yyx < (int) (sizeof (yytname) / sizeof (char *));
- yyx++)
- if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
- {
- const char *yyq = ! yycount ? ", expecting " : " or ";
- yyp = yystpcpy (yyp, yyq);
- yyp = yystpcpy (yyp, yytname[yyx]);
- yycount++;
- }
- }
- yyerror (yymsg);
- YYSTACK_FREE (yymsg);
- }
- else
- yyerror ("syntax error; also virtual memory exhausted");
- }
- else
-#endif /* YYERROR_VERBOSE */
- yyerror ("syntax error");
- }
-
-
-
- if (yyerrstatus == 3)
- {
- /* If just tried and failed to reuse lookahead token after an
- error, discard it. */
-
- /* Return failure if at end of input. */
- if (yychar == YYEOF)
- {
- /* Pop the error token. */
- YYPOPSTACK;
- /* Pop the rest of the stack. */
- while (yyss < yyssp)
- {
- YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
- yydestruct (yystos[*yyssp], yyvsp);
- YYPOPSTACK;
- }
- YYABORT;
- }
-
- YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc);
- yydestruct (yytoken, &yylval);
- yychar = YYEMPTY;
-
- }
-
- /* Else will try to reuse lookahead token after shifting the error
- token. */
- goto yyerrlab1;
-
-
-/*----------------------------------------------------.
-| yyerrlab1 -- error raised explicitly by an action. |
-`----------------------------------------------------*/
-yyerrlab1:
- yyerrstatus = 3; /* Each real token shifted decrements this. */
-
- for (;;)
- {
- yyn = yypact[yystate];
- if (yyn != YYPACT_NINF)
- {
- yyn += YYTERROR;
- if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
- {
- yyn = yytable[yyn];
- if (0 < yyn)
- break;
- }
- }
-
- /* Pop the current state because it cannot handle the error token. */
- if (yyssp == yyss)
- YYABORT;
-
- YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
- yydestruct (yystos[yystate], yyvsp);
- yyvsp--;
- yystate = *--yyssp;
-
- YY_STACK_PRINT (yyss, yyssp);
- }
-
- if (yyn == YYFINAL)
- YYACCEPT;
-
- YYDPRINTF ((stderr, "Shifting error token, "));
-
- *++yyvsp = yylval;
-
-
- yystate = yyn;
- goto yynewstate;
-
-
-/*-------------------------------------.
-| yyacceptlab -- YYACCEPT comes here. |
-`-------------------------------------*/
-yyacceptlab:
- yyresult = 0;
- goto yyreturn;
-
-/*-----------------------------------.
-| yyabortlab -- YYABORT comes here. |
-`-----------------------------------*/
-yyabortlab:
- yyresult = 1;
- goto yyreturn;
-
-#ifndef yyoverflow
-/*----------------------------------------------.
-| yyoverflowlab -- parser overflow comes here. |
-`----------------------------------------------*/
-yyoverflowlab:
- yyerror ("parser stack overflow");
- yyresult = 2;
- /* Fall through. */
-#endif
-
-yyreturn:
-#ifndef yyoverflow
- if (yyss != yyssa)
- YYSTACK_FREE (yyss);
-#endif
- return yyresult;
-}
-
-
-#line 1039 "swf4compiler.y"
-
-
+++ /dev/null
-/* A Bison parser, made by GNU Bison 1.875. */
-
-/* Skeleton parser for Yacc-like parsing with Bison,
- Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
-
-/* As a special exception, when this file is copied by Bison into a
- Bison output file, you may use that output file without restriction.
- This special exception was added by the Free Software Foundation
- in version 1.24 of Bison. */
-
-/* Tokens. */
-#ifndef YYTOKENTYPE
-# define YYTOKENTYPE
- /* Put the tokens into the symbol table, so that GDB and other debuggers
- know about them. */
- enum yytokentype {
- BREAK = 258,
- FOR = 259,
- CONTINUE = 260,
- IF = 261,
- ELSE = 262,
- DO = 263,
- WHILE = 264,
- THIS = 265,
- EVAL = 266,
- TIME = 267,
- RANDOM = 268,
- LENGTH = 269,
- INT = 270,
- CONCAT = 271,
- DUPLICATECLIP = 272,
- REMOVECLIP = 273,
- TRACE = 274,
- STARTDRAG = 275,
- STOPDRAG = 276,
- ORD = 277,
- CHR = 278,
- CALLFRAME = 279,
- GETURL = 280,
- GETURL1 = 281,
- LOADMOVIE = 282,
- LOADVARIABLES = 283,
- POSTURL = 284,
- SUBSTR = 285,
- GETPROPERTY = 286,
- NEXTFRAME = 287,
- PREVFRAME = 288,
- PLAY = 289,
- STOP = 290,
- TOGGLEQUALITY = 291,
- STOPSOUNDS = 292,
- GOTOFRAME = 293,
- GOTOANDPLAY = 294,
- FRAMELOADED = 295,
- SETTARGET = 296,
- TELLTARGET = 297,
- STRING = 298,
- NUMBER = 299,
- IDENTIFIER = 300,
- PATH = 301,
- GETURL_METHOD = 302,
- EQ = 303,
- LE = 304,
- GE = 305,
- NE = 306,
- LAN = 307,
- LOR = 308,
- INC = 309,
- DEC = 310,
- IEQ = 311,
- DEQ = 312,
- MEQ = 313,
- SEQ = 314,
- STREQ = 315,
- STRNE = 316,
- STRCMP = 317,
- PARENT = 318,
- END = 319,
- UMINUS = 320,
- POSTFIX = 321,
- NEGATE = 322
- };
-#endif
-#define BREAK 258
-#define FOR 259
-#define CONTINUE 260
-#define IF 261
-#define ELSE 262
-#define DO 263
-#define WHILE 264
-#define THIS 265
-#define EVAL 266
-#define TIME 267
-#define RANDOM 268
-#define LENGTH 269
-#define INT 270
-#define CONCAT 271
-#define DUPLICATECLIP 272
-#define REMOVECLIP 273
-#define TRACE 274
-#define STARTDRAG 275
-#define STOPDRAG 276
-#define ORD 277
-#define CHR 278
-#define CALLFRAME 279
-#define GETURL 280
-#define GETURL1 281
-#define LOADMOVIE 282
-#define LOADVARIABLES 283
-#define POSTURL 284
-#define SUBSTR 285
-#define GETPROPERTY 286
-#define NEXTFRAME 287
-#define PREVFRAME 288
-#define PLAY 289
-#define STOP 290
-#define TOGGLEQUALITY 291
-#define STOPSOUNDS 292
-#define GOTOFRAME 293
-#define GOTOANDPLAY 294
-#define FRAMELOADED 295
-#define SETTARGET 296
-#define TELLTARGET 297
-#define STRING 298
-#define NUMBER 299
-#define IDENTIFIER 300
-#define PATH 301
-#define GETURL_METHOD 302
-#define EQ 303
-#define LE 304
-#define GE 305
-#define NE 306
-#define LAN 307
-#define LOR 308
-#define INC 309
-#define DEC 310
-#define IEQ 311
-#define DEQ 312
-#define MEQ 313
-#define SEQ 314
-#define STREQ 315
-#define STRNE 316
-#define STRCMP 317
-#define PARENT 318
-#define END 319
-#define UMINUS 320
-#define POSTFIX 321
-#define NEGATE 322
-
-
-
-
-#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
-#line 17 "swf4compiler.y"
-typedef union YYSTYPE {
- Buffer action;
- char *str;
- SWFActionFunction function;
- SWFGetUrl2Method getURLMethod;
-} YYSTYPE;
-/* Line 1240 of yacc.c. */
-#line 177 "swf4compiler.tab.h"
-# define yystype YYSTYPE /* obsolescent; will be withdrawn */
-# define YYSTYPE_IS_DECLARED 1
-# define YYSTYPE_IS_TRIVIAL 1
-#endif
-
-extern YYSTYPE swf4lval;
-
-
-
+++ /dev/null
-/* A Bison parser, made by GNU Bison 2.3. */
-
-/* Skeleton implementation for Bison's Yacc-like parsers in C
-
- Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
- Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA. */
-
-/* As a special exception, you may create a larger work that contains
- part or all of the Bison parser skeleton and distribute that work
- under terms of your choice, so long as that work isn't itself a
- parser generator using the skeleton or a modified version thereof
- as a parser skeleton. Alternatively, if you modify or redistribute
- the parser skeleton itself, you may (at your option) remove this
- special exception, which will cause the skeleton and the resulting
- Bison output files to be licensed under the GNU General Public
- License without this special exception.
-
- This special exception was added by the Free Software Foundation in
- version 2.2 of Bison. */
-
-/* C LALR(1) parser skeleton written by Richard Stallman, by
- simplifying the original so-called "semantic" parser. */
-
-/* All symbols defined below should begin with yy or YY, to avoid
- infringing on user name space. This should be done even for local
- variables, as they might otherwise be expanded by user macros.
- There are some unavoidable exceptions within include files to
- define necessary library symbols; they are noted "INFRINGES ON
- USER NAME SPACE" below. */
-
-/* Identify Bison output. */
-#define YYBISON 1
-
-/* Bison version. */
-#define YYBISON_VERSION "2.3"
-
-/* Skeleton name. */
-#define YYSKELETON_NAME "yacc.c"
-
-/* Pure parsers. */
-#define YYPURE 0
-
-/* Using locations. */
-#define YYLSP_NEEDED 0
-
-/* Substitute the variable and function names. */
-#define yyparse swf5parse
-#define yylex swf5lex
-#define yyerror swf5error
-#define yylval swf5lval
-#define yychar swf5char
-#define yydebug swf5debug
-#define yynerrs swf5nerrs
-
-
-/* Tokens. */
-#ifndef YYTOKENTYPE
-# define YYTOKENTYPE
- /* Put the tokens into the symbol table, so that GDB and other debuggers
- know about them. */
- enum yytokentype {
- BREAK = 258,
- CONTINUE = 259,
- FUNCTION = 260,
- ELSE = 261,
- SWITCH = 262,
- CASE = 263,
- DEFAULT = 264,
- FOR = 265,
- IN = 266,
- IF = 267,
- WHILE = 268,
- DO = 269,
- VAR = 270,
- NEW = 271,
- DELETE = 272,
- RETURN = 273,
- END = 274,
- WITH = 275,
- ASM = 276,
- EVAL = 277,
- RANDOM = 278,
- GETTIMER = 279,
- LENGTH = 280,
- CONCAT = 281,
- SUBSTR = 282,
- TRACE = 283,
- INT = 284,
- ORD = 285,
- CHR = 286,
- GETURL = 287,
- GETURL1 = 288,
- NEXTFRAME = 289,
- PREVFRAME = 290,
- PLAY = 291,
- STOP = 292,
- TOGGLEQUALITY = 293,
- STOPSOUNDS = 294,
- DUP = 295,
- SWAP = 296,
- POP = 297,
- PUSH = 298,
- SETREGISTER = 299,
- CALLFUNCTION = 300,
- CALLMETHOD = 301,
- AND = 302,
- OR = 303,
- XOR = 304,
- MODULO = 305,
- ADD = 306,
- LESSTHAN = 307,
- EQUALS = 308,
- INC = 309,
- DEC = 310,
- TYPEOF = 311,
- INSTANCEOF = 312,
- ENUMERATE = 313,
- INITOBJECT = 314,
- INITARRAY = 315,
- GETMEMBER = 316,
- SETMEMBER = 317,
- SHIFTLEFT = 318,
- SHIFTRIGHT = 319,
- SHIFTRIGHT2 = 320,
- VAREQUALS = 321,
- OLDADD = 322,
- SUBTRACT = 323,
- MULTIPLY = 324,
- DIVIDE = 325,
- OLDEQUALS = 326,
- OLDLESSTHAN = 327,
- LOGICALAND = 328,
- LOGICALOR = 329,
- NOT = 330,
- STRINGEQ = 331,
- STRINGLENGTH = 332,
- SUBSTRING = 333,
- GETVARIABLE = 334,
- SETVARIABLE = 335,
- SETTARGETEXPRESSION = 336,
- DUPLICATEMOVIECLIP = 337,
- REMOVEMOVIECLIP = 338,
- STRINGLESSTHAN = 339,
- MBLENGTH = 340,
- MBSUBSTRING = 341,
- MBORD = 342,
- MBCHR = 343,
- BRANCHALWAYS = 344,
- BRANCHIFTRUE = 345,
- GETURL2 = 346,
- POST = 347,
- GET = 348,
- LOADVARIABLES = 349,
- LOADMOVIE = 350,
- LOADVARIABLESNUM = 351,
- LOADMOVIENUM = 352,
- CALLFRAME = 353,
- STARTDRAG = 354,
- STOPDRAG = 355,
- GOTOFRAME = 356,
- SETTARGET = 357,
- NULLVAL = 358,
- INTEGER = 359,
- DOUBLE = 360,
- BOOLEAN = 361,
- REGISTER = 362,
- STRING = 363,
- IDENTIFIER = 364,
- EQ = 365,
- LE = 366,
- GE = 367,
- NE = 368,
- LAN = 369,
- LOR = 370,
- INCR = 371,
- DECR = 372,
- IEQ = 373,
- DEQ = 374,
- MEQ = 375,
- SEQ = 376,
- REQ = 377,
- AEQ = 378,
- OEQ = 379,
- SHL = 380,
- SHR = 381,
- SHR2 = 382,
- SHLEQ = 383,
- SHREQ = 384,
- SHR2EQ = 385,
- NOELSE = 386,
- UMINUS = 388,
- POSTFIX = 389
- };
-#endif
-/* Tokens. */
-#define BREAK 258
-#define CONTINUE 259
-#define FUNCTION 260
-#define ELSE 261
-#define SWITCH 262
-#define CASE 263
-#define DEFAULT 264
-#define FOR 265
-#define IN 266
-#define IF 267
-#define WHILE 268
-#define DO 269
-#define VAR 270
-#define NEW 271
-#define DELETE 272
-#define RETURN 273
-#define END 274
-#define WITH 275
-#define ASM 276
-#define EVAL 277
-#define RANDOM 278
-#define GETTIMER 279
-#define LENGTH 280
-#define CONCAT 281
-#define SUBSTR 282
-#define TRACE 283
-#define INT 284
-#define ORD 285
-#define CHR 286
-#define GETURL 287
-#define GETURL1 288
-#define NEXTFRAME 289
-#define PREVFRAME 290
-#define PLAY 291
-#define STOP 292
-#define TOGGLEQUALITY 293
-#define STOPSOUNDS 294
-#define DUP 295
-#define SWAP 296
-#define POP 297
-#define PUSH 298
-#define SETREGISTER 299
-#define CALLFUNCTION 300
-#define CALLMETHOD 301
-#define AND 302
-#define OR 303
-#define XOR 304
-#define MODULO 305
-#define ADD 306
-#define LESSTHAN 307
-#define EQUALS 308
-#define INC 309
-#define DEC 310
-#define TYPEOF 311
-#define INSTANCEOF 312
-#define ENUMERATE 313
-#define INITOBJECT 314
-#define INITARRAY 315
-#define GETMEMBER 316
-#define SETMEMBER 317
-#define SHIFTLEFT 318
-#define SHIFTRIGHT 319
-#define SHIFTRIGHT2 320
-#define VAREQUALS 321
-#define OLDADD 322
-#define SUBTRACT 323
-#define MULTIPLY 324
-#define DIVIDE 325
-#define OLDEQUALS 326
-#define OLDLESSTHAN 327
-#define LOGICALAND 328
-#define LOGICALOR 329
-#define NOT 330
-#define STRINGEQ 331
-#define STRINGLENGTH 332
-#define SUBSTRING 333
-#define GETVARIABLE 334
-#define SETVARIABLE 335
-#define SETTARGETEXPRESSION 336
-#define DUPLICATEMOVIECLIP 337
-#define REMOVEMOVIECLIP 338
-#define STRINGLESSTHAN 339
-#define MBLENGTH 340
-#define MBSUBSTRING 341
-#define MBORD 342
-#define MBCHR 343
-#define BRANCHALWAYS 344
-#define BRANCHIFTRUE 345
-#define GETURL2 346
-#define POST 347
-#define GET 348
-#define LOADVARIABLES 349
-#define LOADMOVIE 350
-#define LOADVARIABLESNUM 351
-#define LOADMOVIENUM 352
-#define CALLFRAME 353
-#define STARTDRAG 354
-#define STOPDRAG 355
-#define GOTOFRAME 356
-#define SETTARGET 357
-#define NULLVAL 358
-#define INTEGER 359
-#define DOUBLE 360
-#define BOOLEAN 361
-#define REGISTER 362
-#define STRING 363
-#define IDENTIFIER 364
-#define EQ 365
-#define LE 366
-#define GE 367
-#define NE 368
-#define LAN 369
-#define LOR 370
-#define INCR 371
-#define DECR 372
-#define IEQ 373
-#define DEQ 374
-#define MEQ 375
-#define SEQ 376
-#define REQ 377
-#define AEQ 378
-#define OEQ 379
-#define SHL 380
-#define SHR 381
-#define SHR2 382
-#define SHLEQ 383
-#define SHREQ 384
-#define SHR2EQ 385
-#define NOELSE 386
-#define UMINUS 388
-#define POSTFIX 389
-
-
-
-
-/* Copy the first part of user declarations. */
-#line 5 "swf5compiler.y"
-
-
-#include <time.h>
-#include <string.h>
-#include <stdlib.h>
-#include "compile.h"
-#include "action.h"
-#include "assembler.h"
-
-#define YYPARSE_PARAM buffer
-
-Buffer bf, bc;
-
-
-
-/* Enabling traces. */
-#ifndef YYDEBUG
-# define YYDEBUG 0
-#endif
-
-/* Enabling verbose error messages. */
-#ifdef YYERROR_VERBOSE
-# undef YYERROR_VERBOSE
-# define YYERROR_VERBOSE 1
-#else
-# define YYERROR_VERBOSE 0
-#endif
-
-/* Enabling the token table. */
-#ifndef YYTOKEN_TABLE
-# define YYTOKEN_TABLE 0
-#endif
-
-#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
-typedef union YYSTYPE
-#line 21 "swf5compiler.y"
-{
- Buffer action;
- char *str;
- SWFGetUrl2Method getURLMethod;
- int op;
- int intVal;
- int len;
- double doubleVal;
-
- struct
- {
- Buffer buffer;
- int count;
- } exprlist;
- struct switchcase switchcase;
- struct switchcases switchcases;
- struct
- {
- Buffer obj, ident, memexpr;
- } lval;
-}
-/* Line 187 of yacc.c. */
-#line 407 "swf5compiler.tab.c"
- YYSTYPE;
-# define yystype YYSTYPE /* obsolescent; will be withdrawn */
-# define YYSTYPE_IS_DECLARED 1
-# define YYSTYPE_IS_TRIVIAL 1
-#endif
-
-
-
-/* Copy the second part of user declarations. */
-
-
-/* Line 216 of yacc.c. */
-#line 420 "swf5compiler.tab.c"
-
-#ifdef short
-# undef short
-#endif
-
-#ifdef YYTYPE_UINT8
-typedef YYTYPE_UINT8 yytype_uint8;
-#else
-typedef unsigned char yytype_uint8;
-#endif
-
-#ifdef YYTYPE_INT8
-typedef YYTYPE_INT8 yytype_int8;
-#elif (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-typedef signed char yytype_int8;
-#else
-typedef short int yytype_int8;
-#endif
-
-#ifdef YYTYPE_UINT16
-typedef YYTYPE_UINT16 yytype_uint16;
-#else
-typedef unsigned short int yytype_uint16;
-#endif
-
-#ifdef YYTYPE_INT16
-typedef YYTYPE_INT16 yytype_int16;
-#else
-typedef short int yytype_int16;
-#endif
-
-#ifndef YYSIZE_T
-# ifdef __SIZE_TYPE__
-# define YYSIZE_T __SIZE_TYPE__
-# elif defined size_t
-# define YYSIZE_T size_t
-# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
-# define YYSIZE_T size_t
-# else
-# define YYSIZE_T unsigned int
-# endif
-#endif
-
-#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
-
-#ifndef YY_
-# if YYENABLE_NLS
-# if ENABLE_NLS
-# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
-# define YY_(msgid) dgettext ("bison-runtime", msgid)
-# endif
-# endif
-# ifndef YY_
-# define YY_(msgid) msgid
-# endif
-#endif
-
-/* Suppress unused-variable warnings by "using" E. */
-#if ! defined lint || defined __GNUC__
-# define YYUSE(e) ((void) (e))
-#else
-# define YYUSE(e) /* empty */
-#endif
-
-/* Identity function, used to suppress warnings about constant conditions. */
-#ifndef lint
-# define YYID(n) (n)
-#else
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-static int
-YYID (int i)
-#else
-static int
-YYID (i)
- int i;
-#endif
-{
- return i;
-}
-#endif
-
-#if ! defined yyoverflow || YYERROR_VERBOSE
-
-/* The parser invokes alloca or malloc; define the necessary symbols. */
-
-# ifdef YYSTACK_USE_ALLOCA
-# if YYSTACK_USE_ALLOCA
-# ifdef __GNUC__
-# define YYSTACK_ALLOC __builtin_alloca
-# elif defined __BUILTIN_VA_ARG_INCR
-# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
-# elif defined _AIX
-# define YYSTACK_ALLOC __alloca
-# elif defined _MSC_VER
-# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
-# define alloca _alloca
-# else
-# define YYSTACK_ALLOC alloca
-# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
-# ifndef _STDLIB_H
-# define _STDLIB_H 1
-# endif
-# endif
-# endif
-# endif
-# endif
-
-# ifdef YYSTACK_ALLOC
- /* Pacify GCC's `empty if-body' warning. */
-# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
-# ifndef YYSTACK_ALLOC_MAXIMUM
- /* The OS might guarantee only one guard page at the bottom of the stack,
- and a page size can be as small as 4096 bytes. So we cannot safely
- invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
- to allow for a few compiler-allocated temporary stack slots. */
-# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
-# endif
-# else
-# define YYSTACK_ALLOC YYMALLOC
-# define YYSTACK_FREE YYFREE
-# ifndef YYSTACK_ALLOC_MAXIMUM
-# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
-# endif
-# if (defined __cplusplus && ! defined _STDLIB_H \
- && ! ((defined YYMALLOC || defined malloc) \
- && (defined YYFREE || defined free)))
-# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
-# ifndef _STDLIB_H
-# define _STDLIB_H 1
-# endif
-# endif
-# ifndef YYMALLOC
-# define YYMALLOC malloc
-# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
-# endif
-# endif
-# ifndef YYFREE
-# define YYFREE free
-# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-void free (void *); /* INFRINGES ON USER NAME SPACE */
-# endif
-# endif
-# endif
-#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
-
-
-#if (! defined yyoverflow \
- && (! defined __cplusplus \
- || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
-
-/* A type that is properly aligned for any stack member. */
-union yyalloc
-{
- yytype_int16 yyss;
- YYSTYPE yyvs;
- };
-
-/* The size of the maximum gap between one aligned stack and the next. */
-# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
-
-/* The size of an array large to enough to hold all stacks, each with
- N elements. */
-# define YYSTACK_BYTES(N) \
- ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
- + YYSTACK_GAP_MAXIMUM)
-
-/* Copy COUNT objects from FROM to TO. The source and destination do
- not overlap. */
-# ifndef YYCOPY
-# if defined __GNUC__ && 1 < __GNUC__
-# define YYCOPY(To, From, Count) \
- __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
-# else
-# define YYCOPY(To, From, Count) \
- do \
- { \
- YYSIZE_T yyi; \
- for (yyi = 0; yyi < (Count); yyi++) \
- (To)[yyi] = (From)[yyi]; \
- } \
- while (YYID (0))
-# endif
-# endif
-
-/* Relocate STACK from its old location to the new one. The
- local variables YYSIZE and YYSTACKSIZE give the old and new number of
- elements in the stack, and YYPTR gives the new location of the
- stack. Advance YYPTR to a properly aligned location for the next
- stack. */
-# define YYSTACK_RELOCATE(Stack) \
- do \
- { \
- YYSIZE_T yynewbytes; \
- YYCOPY (&yyptr->Stack, Stack, yysize); \
- Stack = &yyptr->Stack; \
- yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
- yyptr += yynewbytes / sizeof (*yyptr); \
- } \
- while (YYID (0))
-
-#endif
-
-/* YYFINAL -- State number of the termination state. */
-#define YYFINAL 3
-/* YYLAST -- Last index in YYTABLE. */
-#define YYLAST 5253
-
-/* YYNTOKENS -- Number of terminals. */
-#define YYNTOKENS 159
-/* YYNNTS -- Number of nonterminals. */
-#define YYNNTS 57
-/* YYNRULES -- Number of rules. */
-#define YYNRULES 348
-/* YYNRULES -- Number of states. */
-#define YYNSTATES 616
-
-/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
-#define YYUNDEFTOK 2
-#define YYMAXUTOK 389
-
-#define YYTRANSLATE(YYX) \
- ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
-
-/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
-static const yytype_uint8 yytranslate[] =
-{
- 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 147, 2, 2, 2, 146, 139, 2,
- 157, 158, 144, 142, 132, 143, 151, 145, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 136, 156,
- 137, 133, 138, 135, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 152, 2, 153, 141, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 154, 140, 155, 148, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
- 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
- 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
- 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
- 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
- 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
- 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
- 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
- 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
- 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
- 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
- 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
- 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
- 125, 126, 127, 128, 129, 130, 131, 134, 149, 150
-};
-
-#if YYDEBUG
-/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
- YYRHS. */
-static const yytype_uint16 yyprhs[] =
-{
- 0, 0, 3, 4, 7, 8, 10, 13, 15, 17,
- 19, 22, 25, 27, 31, 33, 36, 38, 40, 42,
- 44, 46, 48, 50, 58, 61, 65, 67, 71, 79,
- 85, 86, 88, 90, 98, 99, 102, 109, 114, 118,
- 120, 122, 124, 126, 128, 130, 132, 134, 136, 138,
- 140, 142, 144, 146, 148, 150, 152, 154, 156, 158,
- 160, 162, 164, 166, 168, 170, 172, 174, 176, 178,
- 180, 182, 184, 186, 188, 190, 192, 194, 196, 198,
- 200, 202, 204, 206, 208, 210, 212, 214, 216, 218,
- 220, 222, 224, 226, 228, 230, 232, 234, 236, 238,
- 240, 242, 244, 246, 248, 250, 252, 254, 256, 258,
- 260, 262, 264, 266, 268, 270, 272, 274, 275, 277,
- 281, 283, 290, 292, 296, 301, 303, 305, 307, 309,
- 310, 311, 317, 324, 335, 344, 354, 355, 357, 360,
- 363, 364, 367, 370, 373, 375, 377, 382, 385, 390,
- 396, 401, 409, 417, 425, 433, 441, 446, 453, 468,
- 472, 481, 486, 493, 497, 501, 505, 509, 513, 517,
- 522, 527, 532, 537, 542, 547, 552, 556, 561, 566,
- 571, 576, 581, 588, 597, 602, 603, 605, 609, 615,
- 622, 630, 634, 636, 640, 642, 644, 646, 648, 650,
- 652, 654, 656, 658, 660, 662, 664, 666, 668, 670,
- 672, 674, 678, 683, 685, 688, 691, 694, 698, 702,
- 706, 710, 714, 718, 722, 726, 730, 734, 738, 742,
- 746, 750, 754, 758, 762, 766, 770, 776, 780, 784,
- 786, 789, 795, 799, 801, 805, 807, 809, 811, 813,
- 816, 819, 823, 826, 828, 831, 833, 835, 837, 839,
- 841, 845, 849, 851, 852, 858, 861, 863, 865, 867,
- 870, 873, 877, 881, 883, 886, 887, 892, 894, 896,
- 898, 900, 902, 904, 906, 910, 911, 915, 917, 920,
- 922, 924, 926, 928, 930, 932, 934, 936, 938, 940,
- 942, 944, 946, 948, 950, 952, 954, 956, 958, 960,
- 962, 964, 966, 968, 970, 972, 974, 976, 978, 980,
- 982, 984, 986, 988, 990, 992, 994, 996, 998, 1000,
- 1002, 1004, 1006, 1008, 1010, 1012, 1014, 1016, 1018, 1020,
- 1022, 1024, 1026, 1028, 1030, 1032, 1034, 1036, 1039
-};
-
-/* YYRHS -- A `-1'-separated list of the rules' RHS. */
-static const yytype_int16 yyrhs[] =
-{
- 160, 0, -1, -1, 161, 162, -1, -1, 163, -1,
- 162, 163, -1, 166, -1, 179, -1, 166, -1, 164,
- 166, -1, 154, 155, -1, 165, -1, 154, 164, 155,
- -1, 156, -1, 207, 156, -1, 170, -1, 185, -1,
- 187, -1, 188, -1, 173, -1, 168, -1, 167, -1,
- 20, 157, 202, 158, 154, 164, 155, -1, 18, 156,
- -1, 18, 203, 156, -1, 207, -1, 169, 132, 207,
- -1, 12, 157, 202, 158, 166, 6, 166, -1, 12,
- 157, 202, 158, 166, -1, -1, 202, -1, 7, -1,
- 172, 157, 202, 158, 154, 174, 155, -1, -1, 174,
- 175, -1, 8, 202, 136, 164, 3, 156, -1, 8,
- 202, 136, 164, -1, 9, 136, 164, -1, 109, -1,
- 16, -1, 17, -1, 23, -1, 24, -1, 25, -1,
- 26, -1, 27, -1, 28, -1, 29, -1, 30, -1,
- 31, -1, 32, -1, 33, -1, 34, -1, 35, -1,
- 36, -1, 37, -1, 38, -1, 39, -1, 40, -1,
- 41, -1, 42, -1, 43, -1, 44, -1, 45, -1,
- 46, -1, 47, -1, 48, -1, 49, -1, 50, -1,
- 51, -1, 52, -1, 53, -1, 54, -1, 55, -1,
- 56, -1, 57, -1, 58, -1, 59, -1, 60, -1,
- 61, -1, 62, -1, 63, -1, 64, -1, 65, -1,
- 66, -1, 67, -1, 68, -1, 69, -1, 70, -1,
- 71, -1, 72, -1, 73, -1, 74, -1, 75, -1,
- 76, -1, 77, -1, 78, -1, 79, -1, 80, -1,
- 81, -1, 82, -1, 83, -1, 99, -1, 100, -1,
- 84, -1, 85, -1, 86, -1, 87, -1, 88, -1,
- 89, -1, 90, -1, 91, -1, 92, -1, 93, -1,
- 94, -1, 95, -1, -1, 176, -1, 177, 132, 176,
- -1, 5, -1, 178, 176, 157, 177, 158, 166, -1,
- 176, -1, 202, 151, 176, -1, 202, 152, 202, 153,
- -1, 192, -1, 195, -1, 13, -1, 14, -1, -1,
- -1, 181, 157, 202, 158, 166, -1, 182, 166, 13,
- 157, 202, 158, -1, 10, 157, 186, 156, 171, 156,
- 186, 158, 183, 166, -1, 10, 157, 176, 11, 180,
- 158, 184, 166, -1, 10, 157, 15, 176, 11, 180,
- 158, 184, 166, -1, -1, 169, -1, 4, 156, -1,
- 3, 156, -1, -1, 132, 93, -1, 132, 92, -1,
- 132, 108, -1, 104, -1, 202, -1, 109, 157, 193,
- 158, -1, 17, 109, -1, 17, 200, 151, 109, -1,
- 17, 200, 152, 202, 153, -1, 28, 157, 203, 158,
- -1, 32, 157, 202, 132, 202, 189, 158, -1, 94,
- 157, 202, 132, 202, 189, 158, -1, 96, 157, 202,
- 132, 190, 189, 158, -1, 95, 157, 202, 132, 202,
- 189, 158, -1, 97, 157, 202, 132, 190, 189, 158,
- -1, 98, 157, 202, 158, -1, 99, 157, 202, 132,
- 202, 158, -1, 99, 157, 202, 132, 202, 132, 202,
- 132, 202, 132, 202, 132, 202, 158, -1, 100, 157,
- 158, -1, 82, 157, 202, 132, 202, 132, 202, 158,
- -1, 83, 157, 202, 158, -1, 33, 157, 108, 132,
- 108, 158, -1, 34, 157, 158, -1, 35, 157, 158,
- -1, 36, 157, 158, -1, 37, 157, 158, -1, 39,
- 157, 158, -1, 38, 157, 158, -1, 101, 157, 104,
- 158, -1, 101, 157, 108, 158, -1, 101, 157, 202,
- 158, -1, 102, 157, 108, 158, -1, 102, 157, 202,
- 158, -1, 109, 157, 193, 158, -1, 22, 157, 202,
- 158, -1, 24, 157, 158, -1, 23, 157, 202, 158,
- -1, 25, 157, 203, 158, -1, 29, 157, 202, 158,
- -1, 30, 157, 202, 158, -1, 31, 157, 202, 158,
- -1, 26, 157, 202, 132, 202, 158, -1, 78, 157,
- 202, 132, 202, 132, 202, 158, -1, 56, 157, 203,
- 158, -1, -1, 203, -1, 193, 132, 203, -1, 178,
- 157, 177, 158, 166, -1, 200, 151, 176, 157, 193,
- 158, -1, 200, 152, 202, 153, 157, 193, 158, -1,
- 176, 136, 203, -1, 196, -1, 197, 132, 196, -1,
- 118, -1, 121, -1, 120, -1, 119, -1, 122, -1,
- 123, -1, 124, -1, 134, -1, 128, -1, 129, -1,
- 130, -1, 116, -1, 117, -1, 201, -1, 192, -1,
- 195, -1, 176, -1, 200, 151, 176, -1, 200, 152,
- 202, 153, -1, 204, -1, 143, 202, -1, 148, 202,
- -1, 147, 202, -1, 202, 115, 202, -1, 202, 114,
- 202, -1, 202, 144, 202, -1, 202, 145, 202, -1,
- 202, 146, 202, -1, 202, 142, 202, -1, 202, 143,
- 202, -1, 202, 139, 202, -1, 202, 140, 202, -1,
- 202, 141, 202, -1, 202, 137, 202, -1, 202, 138,
- 202, -1, 202, 111, 202, -1, 202, 112, 202, -1,
- 202, 110, 202, -1, 202, 113, 202, -1, 202, 125,
- 202, -1, 202, 126, 202, -1, 202, 127, 202, -1,
- 202, 135, 202, 136, 202, -1, 201, 133, 203, -1,
- 202, 57, 200, -1, 202, -1, 16, 176, -1, 16,
- 176, 157, 193, 158, -1, 152, 193, 153, -1, 165,
- -1, 154, 197, 155, -1, 192, -1, 194, -1, 195,
- -1, 200, -1, 199, 201, -1, 201, 199, -1, 157,
- 202, 158, -1, 143, 104, -1, 104, -1, 143, 105,
- -1, 105, -1, 106, -1, 103, -1, 108, -1, 206,
- -1, 205, 132, 206, -1, 176, 133, 203, -1, 176,
- -1, -1, 21, 154, 208, 209, 155, -1, 15, 205,
- -1, 191, -1, 192, -1, 195, -1, 199, 201, -1,
- 201, 199, -1, 201, 133, 203, -1, 201, 198, 202,
- -1, 214, -1, 209, 214, -1, -1, 20, 211, 209,
- 19, -1, 108, -1, 104, -1, 105, -1, 106, -1,
- 103, -1, 107, -1, 212, -1, 213, 132, 212, -1,
- -1, 43, 215, 213, -1, 210, -1, 44, 107, -1,
- 45, -1, 18, -1, 46, -1, 47, -1, 48, -1,
- 49, -1, 50, -1, 51, -1, 52, -1, 53, -1,
- 54, -1, 55, -1, 56, -1, 57, -1, 58, -1,
- 17, -1, 16, -1, 60, -1, 59, -1, 61, -1,
- 62, -1, 63, -1, 64, -1, 65, -1, 15, -1,
- 66, -1, 67, -1, 68, -1, 69, -1, 70, -1,
- 71, -1, 72, -1, 73, -1, 74, -1, 75, -1,
- 76, -1, 77, -1, 78, -1, 29, -1, 40, -1,
- 41, -1, 42, -1, 79, -1, 80, -1, 81, -1,
- 26, -1, 82, -1, 83, -1, 28, -1, 84, -1,
- 23, -1, 85, -1, 30, -1, 31, -1, 24, -1,
- 86, -1, 87, -1, 88, -1, 89, 108, -1, 90,
- 108, -1
-};
-
-/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
-static const yytype_uint16 yyrline[] =
-{
- 0, 152, 152, 152, 160, 164, 165, 169, 171, 176,
- 179, 185, 189, 190, 191, 192, 193, 194, 195, 196,
- 197, 198, 199, 203, 214, 224, 236, 237, 241, 252,
- 262, 263, 267, 272, 286, 289, 297, 302, 307, 317,
- 318, 319, 320, 321, 322, 323, 324, 325, 326, 327,
- 328, 329, 330, 331, 332, 333, 334, 335, 336, 337,
- 338, 339, 340, 341, 342, 343, 344, 345, 346, 347,
- 348, 349, 350, 351, 352, 353, 354, 355, 356, 357,
- 358, 359, 360, 361, 362, 363, 364, 365, 366, 367,
- 368, 369, 370, 371, 372, 373, 374, 375, 376, 377,
- 378, 379, 380, 381, 382, 383, 384, 385, 386, 387,
- 388, 389, 390, 391, 392, 393, 394, 399, 402, 407,
- 414, 419, 433, 438, 444, 449, 451, 455, 460, 466,
- 471, 475, 488, 501, 536, 569, 603, 604, 610, 621,
- 634, 636, 638, 640, 647, 654, 662, 670, 676, 683,
- 690, 694, 701, 708, 715, 722, 729, 735, 742, 753,
- 758, 766, 770, 780, 784, 788, 792, 796, 800, 804,
- 810, 817, 823, 830, 839, 846, 850, 854, 858, 862,
- 866, 870, 874, 879, 885, 894, 897, 902, 911, 924,
- 932, 941, 948, 952, 958, 959, 960, 961, 962, 963,
- 964, 965, 966, 967, 968, 972, 973, 991, 1009, 1010,
- 1015, 1022, 1028, 1037, 1039, 1044, 1049, 1053, 1062, 1072,
- 1077, 1082, 1087, 1092, 1097, 1102, 1107, 1112, 1117, 1122,
- 1128, 1133, 1137, 1142, 1146, 1150, 1154, 1164, 1191, 1199,
- 1201, 1207, 1213, 1218, 1223, 1231, 1233, 1235, 1237, 1239,
- 1284, 1329, 1332, 1336, 1340, 1344, 1348, 1352, 1356, 1363,
- 1365, 1371, 1377, 1385, 1384, 1389, 1392, 1394, 1398, 1402,
- 1441, 1480, 1501, 1546, 1547, 1552, 1551, 1559, 1562, 1565,
- 1568, 1571, 1573, 1580, 1581, 1585, 1585, 1591, 1593, 1600,
- 1602, 1604, 1606, 1608, 1610, 1612, 1614, 1616, 1618, 1620,
- 1622, 1624, 1626, 1628, 1630, 1632, 1634, 1636, 1638, 1640,
- 1642, 1644, 1646, 1648, 1650, 1654, 1655, 1656, 1657, 1658,
- 1659, 1660, 1661, 1662, 1663, 1664, 1665, 1666, 1667, 1668,
- 1669, 1670, 1671, 1672, 1673, 1674, 1675, 1676, 1677, 1678,
- 1679, 1680, 1681, 1682, 1683, 1684, 1685, 1688, 1692
-};
-#endif
-
-#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
-/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
- First, the terminals, then, starting at YYNTOKENS, nonterminals. */
-static const char *const yytname[] =
-{
- "$end", "error", "$undefined", "BREAK", "CONTINUE", "FUNCTION", "ELSE",
- "SWITCH", "CASE", "DEFAULT", "FOR", "IN", "IF", "WHILE", "DO", "VAR",
- "NEW", "DELETE", "RETURN", "END", "WITH", "ASM", "EVAL", "RANDOM",
- "GETTIMER", "LENGTH", "CONCAT", "SUBSTR", "TRACE", "INT", "ORD", "CHR",
- "GETURL", "GETURL1", "NEXTFRAME", "PREVFRAME", "PLAY", "STOP",
- "TOGGLEQUALITY", "STOPSOUNDS", "DUP", "SWAP", "POP", "PUSH",
- "SETREGISTER", "CALLFUNCTION", "CALLMETHOD", "AND", "OR", "XOR",
- "MODULO", "ADD", "LESSTHAN", "EQUALS", "INC", "DEC", "TYPEOF",
- "INSTANCEOF", "ENUMERATE", "INITOBJECT", "INITARRAY", "GETMEMBER",
- "SETMEMBER", "SHIFTLEFT", "SHIFTRIGHT", "SHIFTRIGHT2", "VAREQUALS",
- "OLDADD", "SUBTRACT", "MULTIPLY", "DIVIDE", "OLDEQUALS", "OLDLESSTHAN",
- "LOGICALAND", "LOGICALOR", "NOT", "STRINGEQ", "STRINGLENGTH",
- "SUBSTRING", "GETVARIABLE", "SETVARIABLE", "SETTARGETEXPRESSION",
- "DUPLICATEMOVIECLIP", "REMOVEMOVIECLIP", "STRINGLESSTHAN", "MBLENGTH",
- "MBSUBSTRING", "MBORD", "MBCHR", "BRANCHALWAYS", "BRANCHIFTRUE",
- "GETURL2", "POST", "GET", "LOADVARIABLES", "LOADMOVIE",
- "LOADVARIABLESNUM", "LOADMOVIENUM", "CALLFRAME", "STARTDRAG", "STOPDRAG",
- "GOTOFRAME", "SETTARGET", "NULLVAL", "INTEGER", "DOUBLE", "BOOLEAN",
- "REGISTER", "STRING", "IDENTIFIER", "\"==\"", "\"<=\"", "\">=\"",
- "\"!=\"", "\"&&\"", "\"||\"", "\"++\"", "\"--\"", "\"+=\"", "\"/=\"",
- "\"*=\"", "\"-=\"", "\"%=\"", "\"&=\"", "\"|=\"", "\"<<\"", "\">>\"",
- "\">>>\"", "\"<<=\"", "\">>=\"", "\">>>=\"", "NOELSE", "','", "'='",
- "\"^=\"", "'?'", "':'", "'<'", "'>'", "'&'", "'|'", "'^'", "'+'", "'-'",
- "'*'", "'/'", "'%'", "'!'", "'~'", "UMINUS", "POSTFIX", "'.'", "'['",
- "']'", "'{'", "'}'", "';'", "'('", "')'", "$accept", "program", "@1",
- "code", "anycode", "stmts", "emptybraces", "stmt", "with_stmt",
- "return_stmt", "assign_stmts", "if_stmt", "expr_opt", "switch_init",
- "switch_stmt", "switch_cases", "switch_case", "identifier",
- "formals_list", "function_init", "function_decl", "obj_ref",
- "while_init", "do_init", "for_init", "for_in_init", "iter_stmt",
- "assign_stmts_opt", "cont_stmt", "break_stmt", "urlmethod", "level",
- "void_function_call", "function_call", "expr_list", "anon_function_decl",
- "method_call", "objexpr", "objexpr_list", "assignop", "incdecop",
- "lvalue_expr", "lvalue", "expr", "expr_or_obj", "primary", "init_vars",
- "init_var", "assign_stmt", "@2", "opcode_list", "with", "@3",
- "push_item", "push_list", "opcode", "@4", 0
-};
-#endif
-
-# ifdef YYPRINT
-/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
- token YYLEX-NUM. */
-static const yytype_uint16 yytoknum[] =
-{
- 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
- 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
- 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
- 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
- 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
- 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
- 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
- 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
- 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
- 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
- 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
- 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
- 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
- 385, 386, 44, 61, 387, 63, 58, 60, 62, 38,
- 124, 94, 43, 45, 42, 47, 37, 33, 126, 388,
- 389, 46, 91, 93, 123, 125, 59, 40, 41
-};
-# endif
-
-/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
-static const yytype_uint8 yyr1[] =
-{
- 0, 159, 161, 160, 160, 162, 162, 163, 163, 164,
- 164, 165, 166, 166, 166, 166, 166, 166, 166, 166,
- 166, 166, 166, 167, 168, 168, 169, 169, 170, 170,
- 171, 171, 172, 173, 174, 174, 175, 175, 175, 176,
- 176, 176, 176, 176, 176, 176, 176, 176, 176, 176,
- 176, 176, 176, 176, 176, 176, 176, 176, 176, 176,
- 176, 176, 176, 176, 176, 176, 176, 176, 176, 176,
- 176, 176, 176, 176, 176, 176, 176, 176, 176, 176,
- 176, 176, 176, 176, 176, 176, 176, 176, 176, 176,
- 176, 176, 176, 176, 176, 176, 176, 176, 176, 176,
- 176, 176, 176, 176, 176, 176, 176, 176, 176, 176,
- 176, 176, 176, 176, 176, 176, 176, 177, 177, 177,
- 178, 179, 180, 180, 180, 180, 180, 181, 182, 183,
- 184, 185, 185, 185, 185, 185, 186, 186, 187, 188,
- 189, 189, 189, 189, 190, 190, 191, 191, 191, 191,
- 191, 191, 191, 191, 191, 191, 191, 191, 191, 191,
- 191, 191, 191, 191, 191, 191, 191, 191, 191, 191,
- 191, 191, 191, 191, 192, 192, 192, 192, 192, 192,
- 192, 192, 192, 192, 192, 193, 193, 193, 194, 195,
- 195, 196, 197, 197, 198, 198, 198, 198, 198, 198,
- 198, 198, 198, 198, 198, 199, 199, 200, 200, 200,
- 201, 201, 201, 202, 202, 202, 202, 202, 202, 202,
- 202, 202, 202, 202, 202, 202, 202, 202, 202, 202,
- 202, 202, 202, 202, 202, 202, 202, 202, 202, 203,
- 203, 203, 203, 203, 203, 204, 204, 204, 204, 204,
- 204, 204, 204, 204, 204, 204, 204, 204, 204, 205,
- 205, 206, 206, 208, 207, 207, 207, 207, 207, 207,
- 207, 207, 207, 209, 209, 211, 210, 212, 212, 212,
- 212, 212, 212, 213, 213, 215, 214, 214, 214, 214,
- 214, 214, 214, 214, 214, 214, 214, 214, 214, 214,
- 214, 214, 214, 214, 214, 214, 214, 214, 214, 214,
- 214, 214, 214, 214, 214, 214, 214, 214, 214, 214,
- 214, 214, 214, 214, 214, 214, 214, 214, 214, 214,
- 214, 214, 214, 214, 214, 214, 214, 214, 214, 214,
- 214, 214, 214, 214, 214, 214, 214, 214, 214
-};
-
-/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
-static const yytype_uint8 yyr2[] =
-{
- 0, 2, 0, 2, 0, 1, 2, 1, 1, 1,
- 2, 2, 1, 3, 1, 2, 1, 1, 1, 1,
- 1, 1, 1, 7, 2, 3, 1, 3, 7, 5,
- 0, 1, 1, 7, 0, 2, 6, 4, 3, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 0, 1, 3,
- 1, 6, 1, 3, 4, 1, 1, 1, 1, 0,
- 0, 5, 6, 10, 8, 9, 0, 1, 2, 2,
- 0, 2, 2, 2, 1, 1, 4, 2, 4, 5,
- 4, 7, 7, 7, 7, 7, 4, 6, 14, 3,
- 8, 4, 6, 3, 3, 3, 3, 3, 3, 4,
- 4, 4, 4, 4, 4, 4, 3, 4, 4, 4,
- 4, 4, 6, 8, 4, 0, 1, 3, 5, 6,
- 7, 3, 1, 3, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 3, 4, 1, 2, 2, 2, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 5, 3, 3, 1,
- 2, 5, 3, 1, 3, 1, 1, 1, 1, 2,
- 2, 3, 2, 1, 2, 1, 1, 1, 1, 1,
- 3, 3, 1, 0, 5, 2, 1, 1, 1, 2,
- 2, 3, 3, 1, 2, 0, 4, 1, 1, 1,
- 1, 1, 1, 1, 3, 0, 3, 1, 2, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 2, 2
-};
-
-/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
- STATE-NUM when YYTABLE doesn't specify something else to do. Zero
- means the default is an error. */
-static const yytype_uint16 yydefact[] =
-{
- 2, 0, 0, 1, 0, 0, 120, 32, 0, 0,
- 127, 128, 0, 40, 41, 0, 0, 0, 0, 42,
- 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
- 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,
- 63, 64, 65, 66, 67, 68, 69, 70, 71, 72,
- 73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
- 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
- 93, 94, 95, 96, 97, 98, 99, 100, 101, 102,
- 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
- 115, 116, 0, 0, 0, 103, 104, 0, 0, 39,
- 205, 206, 0, 14, 3, 5, 12, 7, 22, 21,
- 16, 0, 20, 210, 0, 8, 0, 0, 17, 18,
- 19, 266, 267, 268, 0, 0, 207, 0, 139, 138,
- 136, 0, 41, 42, 43, 44, 45, 47, 48, 49,
- 50, 51, 52, 53, 54, 55, 56, 57, 58, 75,
- 97, 101, 102, 115, 116, 103, 104, 39, 262, 265,
- 259, 147, 208, 209, 0, 207, 40, 257, 253, 255,
- 256, 258, 39, 0, 0, 0, 185, 0, 24, 0,
- 243, 0, 208, 246, 209, 0, 248, 207, 239, 0,
- 213, 0, 263, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 185, 11, 0, 9, 6, 0, 0,
- 0, 0, 269, 0, 0, 194, 197, 196, 195, 198,
- 199, 200, 202, 203, 204, 0, 201, 0, 270, 15,
- 0, 137, 210, 0, 26, 0, 0, 0, 185, 0,
- 0, 240, 252, 254, 214, 216, 215, 0, 186, 0,
- 192, 0, 0, 117, 249, 0, 250, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 25, 0,
- 0, 0, 0, 176, 0, 0, 0, 0, 0, 0,
- 0, 0, 163, 164, 165, 166, 168, 167, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 159, 253,
- 258, 0, 258, 0, 0, 13, 10, 0, 117, 0,
- 0, 211, 0, 271, 272, 262, 0, 0, 30, 0,
- 261, 260, 0, 39, 0, 185, 0, 242, 0, 0,
- 244, 251, 118, 0, 237, 238, 231, 229, 230, 232,
- 218, 217, 233, 234, 235, 0, 227, 228, 224, 225,
- 226, 222, 223, 219, 220, 221, 0, 313, 305, 304,
- 290, 275, 339, 343, 334, 337, 327, 341, 342, 328,
- 329, 330, 285, 0, 289, 291, 292, 293, 294, 295,
- 296, 297, 298, 299, 300, 301, 302, 303, 307, 306,
- 308, 309, 310, 311, 312, 314, 315, 316, 317, 318,
- 319, 320, 321, 322, 323, 324, 325, 326, 331, 332,
- 333, 335, 336, 338, 340, 344, 345, 346, 0, 0,
- 0, 287, 273, 175, 177, 178, 0, 150, 179, 180,
- 181, 0, 0, 184, 0, 0, 161, 0, 0, 0,
- 0, 156, 0, 169, 170, 171, 172, 173, 146, 0,
- 0, 0, 0, 185, 212, 0, 27, 210, 0, 208,
- 209, 0, 0, 31, 29, 174, 149, 0, 187, 191,
- 193, 0, 0, 0, 0, 0, 0, 288, 347, 348,
- 264, 274, 0, 140, 0, 0, 0, 140, 140, 253,
- 140, 145, 140, 0, 34, 0, 131, 0, 0, 185,
- 0, 130, 0, 0, 136, 0, 241, 119, 188, 236,
- 0, 0, 281, 278, 279, 280, 282, 277, 283, 286,
- 182, 0, 0, 162, 0, 0, 0, 0, 0, 0,
- 0, 157, 0, 121, 132, 189, 0, 130, 0, 123,
- 0, 0, 28, 23, 276, 0, 142, 141, 143, 151,
- 0, 0, 152, 154, 153, 155, 0, 0, 0, 33,
- 35, 190, 0, 134, 124, 129, 284, 183, 160, 0,
- 0, 0, 135, 0, 0, 0, 38, 133, 0, 37,
- 0, 0, 0, 139, 0, 158
-};
-
-/* YYDEFGOTO[NTERM-NUM]. */
-static const yytype_int16 yydefgoto[] =
-{
- -1, 1, 2, 104, 105, 225, 106, 226, 108, 109,
- 251, 110, 492, 111, 112, 562, 590, 113, 363, 181,
- 115, 488, 116, 117, 603, 568, 118, 253, 119, 120,
- 552, 520, 121, 182, 267, 183, 184, 270, 271, 247,
- 185, 186, 187, 188, 268, 190, 159, 160, 127, 300,
- 450, 451, 505, 548, 549, 452, 506
-};
-
-/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
- STATE-NUM. */
-#define YYPACT_NINF -496
-static const yytype_int16 yypact[] =
-{
- 17, 30, 908, -496, -136, -123, -496, -496, -126, -105,
- -496, -496, 4178, -496, 4003, 1907, -101, -120, -88, -80,
- -75, -72, -65, -496, -62, -50, -43, -40, -38, -31,
- -30, -28, -27, -25, -24, -21, -496, -496, -496, -496,
- -496, -496, -496, -496, -496, -496, -496, -496, -496, -496,
- -496, -496, -20, -496, -496, -496, -496, -496, -496, -496,
- -496, -496, -496, -496, -496, -496, -496, -496, -496, -496,
- -496, -496, -496, -496, -18, -496, -496, -496, -17, -16,
- -496, -496, -496, -496, -496, -496, -496, -496, -496, -496,
- -15, -11, -8, -5, 5, 6, 7, 8, 9, 22,
- -496, -496, 1165, -496, 908, -496, -496, -496, -496, -496,
- -496, 23, -496, -496, 4178, -496, 24, 1627, -496, -496,
- -496, -496, -125, -97, 4091, -78, -58, -57, -496, -496,
- 3137, 2190, -496, -496, -496, -496, -496, -496, -496, -496,
- -496, -496, -496, -496, -496, -496, -496, -496, -496, -496,
- -496, -496, -496, -496, -496, -496, -496, -496, 49, -96,
- -496, -71, -496, -496, -64, -496, 4178, -496, -496, -496,
- -496, -496, 27, 2326, 2190, 2190, 2051, 3002, -496, 2190,
- -496, 37, -496, -496, -496, 4091, -78, -49, 4896, -47,
- -496, 2190, -496, 2190, 2190, -3, 2051, 2190, 2051, 2190,
- 2190, 2190, 2190, 45, 40, 42, 47, 48, 51, 52,
- 2051, 2190, 2190, 2190, 2190, 2190, 2190, 2190, 2190, 2190,
- 53, 2462, 2598, 2051, -496, 1319, -496, -496, 2190, 39,
- 2190, 143, -54, 4178, 2190, -496, -496, -496, -496, -496,
- -496, -496, -496, -496, -496, 2051, -496, 2190, -496, -496,
- 4178, 69, 174, 46, -496, 331, 2051, 4178, 2051, 4265,
- 2190, 50, -496, -496, 146, 146, 146, -103, -496, 76,
- -496, -113, 576, 4178, -54, 2051, -496, 4091, 2190, 2190,
- 2190, 2190, 2190, 2190, 2190, 2190, 2190, 2190, 2190, 2190,
- 2190, 2190, 2190, 2190, 2190, 2190, 2190, 2190, -496, 750,
- 5163, 962, 999, -496, 55, 688, 56, 2850, 3280, 3317,
- 4304, 86, -496, -496, -496, -496, -496, -496, 58, 4341,
- 4378, 3354, 4415, 4452, 4489, 4526, 3391, 4563, -496, 61,
- 62, 3428, 64, 3465, -119, -496, -496, 3502, 4178, 3539,
- 68, 70, 3761, -496, 4896, -9, 3234, 2190, 2190, 1627,
- -496, -496, -118, -121, 3798, 2051, 2051, -496, 2051, 4178,
- -496, -496, -496, -117, -496, -78, 4955, 192, 192, 4955,
- 4933, 4933, 26, 26, 26, 4600, 192, 192, 32, 32,
- 32, -33, -33, 146, 146, 146, 75, -496, -496, -496,
- -496, -496, -496, -496, -496, -496, -496, -496, -496, -496,
- -496, -496, -496, 123, -496, -496, -496, -496, -496, -496,
- -496, -496, -496, -496, -496, -496, -496, -496, -496, -496,
- -496, -496, -496, -496, -496, -496, -496, -496, -496, -496,
- -496, -496, -496, -496, -496, -496, -496, -496, -496, -496,
- -496, -496, -496, -496, -496, -496, -496, -496, 124, 125,
- 2869, -496, -496, -496, -496, -496, 2190, -496, -496, -496,
- -496, 2190, 127, -496, 2190, 2190, -496, 2190, 2190, 2734,
- 2734, -496, 2190, -496, -496, -496, -496, -496, -48, 77,
- -114, 1627, 2190, 2051, 80, 2190, -496, 82, 83, 88,
- 89, 3872, 94, 4896, 236, -496, -61, -111, -496, -496,
- -496, 4178, 1627, 2190, 1627, 5163, 84, -496, -496, -496,
- -496, -496, 3576, 4637, 96, 4674, 4711, 4637, 4637, -110,
- 112, 4896, 112, 289, -496, 1627, -496, 3613, -109, 2051,
- 97, -496, 4178, 2190, 3234, 1627, -496, -496, -496, 4896,
- 1473, 5087, -496, -496, -496, -496, -496, -496, -496, 120,
- -496, -14, 98, -496, 2190, 2190, 99, 101, 102, 103,
- 2190, -496, -4, -496, -496, -496, -107, -496, 1627, -496,
- 3835, 104, -496, -496, -496, 84, -496, -496, -496, -496,
- 3650, 3687, -496, -496, -496, -496, 4748, 2190, 128, -496,
- -496, -496, 1627, -496, -496, -496, -496, -496, -496, 2190,
- 4785, 1627, -496, 1627, 4822, 1627, 1627, -496, 2190, 1772,
- 4859, 109, 2190, -1, 3724, -496
-};
-
-/* YYPGOTO[NTERM-NUM]. */
-static const yytype_int16 yypgoto[] =
-{
- -496, -496, -496, -496, 162, -495, 28, 44, -496, -496,
- -496, -496, -496, -496, -496, -496, -496, 20, -66, 4,
- -496, -211, -496, -496, -496, -289, -496, -254, -496, -496,
- -397, -189, -496, -2, -220, -496, 14, -77, -496, -496,
- 141, 43, 91, 562, 38, -496, -496, 31, -129, -496,
- -218, -496, -496, -290, -496, -440, -496
-};
-
-/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
- positive, shift that token. If negative, reduce the rule which
- number is the opposite. If zero, do what YYDEFACT says.
- If YYTABLE_NINF, syntax error. */
-#define YYTABLE_NINF -213
-static const yytype_int16 yytable[] =
-{
- 122, 254, 485, 334, 587, 588, 114, -36, -36, 540,
- 511, -148, 162, 356, 356, 501, 123, -4, 501, 359,
- 128, 356, -144, 356, 277, 356, -208, -208, 163, 356,
- 3, 130, 158, 129, 192, -148, 257, -148, 352, 478,
- 495, 502, 360, 180, 525, 125, 107, 536, -144, 565,
- 357, 591, 131, 189, -209, -209, 191, 164, 100, 101,
- 235, 236, 237, 238, 239, 240, 241, 100, 101, 193,
- 242, 243, 244, 233, 234, 245, 246, 194, 576, 577,
- -39, -39, 195, 277, 275, 196, 258, 259, 260, 277,
- -212, -212, 197, 126, 578, 198, 529, -207, -207, 249,
- 122, 511, 122, -174, -174, 165, 606, 199, 114, 298,
- 609, 295, 296, 297, 200, 122, 123, 201, 123, 202,
- 556, 557, 162, 558, 256, 559, 203, 204, 122, 205,
- 206, 123, 207, 208, 229, 497, 209, 210, 163, 211,
- 212, 213, 214, 124, 123, 125, 215, 125, 107, 216,
- 252, 589, 217, 311, -36, 303, 340, 284, 285, 286,
- 125, 231, 218, 219, 220, 221, 222, 125, 293, 294,
- 295, 296, 297, 125, 293, 294, 295, 296, 297, 223,
- 228, 230, 256, 162, 258, 347, 261, 542, 543, 544,
- 545, 546, 547, 126, 273, 126, 338, 269, 312, 163,
- 313, 346, 348, 277, 180, 314, 315, 355, 126, 316,
- 317, 328, 358, 455, 457, 232, 463, 486, 462, 473,
- 474, 126, 476, 122, 180, 482, 180, 483, 125, 504,
- 507, 524, 508, 509, 304, 514, 306, 529, 180, 123,
- -122, 531, 535, 124, 551, 124, -125, -126, 318, 277,
- 534, 180, 575, 341, 553, 567, 579, 582, 124, 583,
- 584, 585, 595, 528, 601, 613, 227, 248, 125, 336,
- 345, 124, 480, 180, 530, 162, 274, 158, 592, 341,
- 571, 522, 500, 343, 180, 596, 180, 541, 351, 0,
- 0, 163, 0, 362, 350, 0, 0, 0, 0, 0,
- 0, 0, 0, 180, 0, 0, 0, 0, 0, 566,
- 0, 0, 0, 364, 0, 0, 126, 284, 285, 286,
- 365, 0, 0, 0, 0, 0, 0, 0, 276, 0,
- 0, 290, 291, 292, 293, 294, 295, 296, 297, 0,
- 0, 0, 0, 0, 122, 489, 277, 122, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 362, 0,
- 123, 490, 0, 123, 0, 0, 124, 487, 165, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 269,
- 0, 0, 0, 180, 180, 0, 180, 0, 277, 125,
- 0, 0, 125, 494, 498, 0, 499, 0, 0, 278,
- 279, 280, 281, 282, 283, 254, 0, 0, 0, 0,
- 0, 0, 0, 0, 284, 285, 286, 0, 0, 0,
- 0, 560, 0, 0, 287, 0, 288, 289, 290, 291,
- 292, 293, 294, 295, 296, 297, 0, 126, 0, 0,
- 126, 278, 279, 280, 281, 282, 283, 561, 0, 0,
- 0, 0, 0, 0, 0, 0, 284, 285, 286, 0,
- 0, 0, 0, 0, 0, 0, 287, 0, 288, 289,
- 290, 291, 292, 293, 294, 295, 296, 297, 0, 122,
- 0, 0, 0, 489, 0, 0, 0, 124, 0, 349,
- 124, 0, 0, 0, 0, 123, 0, 0, 0, 490,
- 122, 0, 122, 0, 0, 487, 0, 0, 0, 0,
- 0, 180, 0, 0, 0, 0, 123, 0, 123, 0,
- 0, 537, 0, 122, 125, 526, 0, 0, 0, 0,
- 0, 0, 122, 122, 0, 0, 0, 0, 122, 123,
- 0, 0, 0, 0, 0, 125, 538, 125, 123, 123,
- 0, 0, 569, 0, 123, 0, 0, 180, 0, 0,
- 0, 0, 0, 0, 0, 0, 122, 0, 125, 563,
- 0, 0, 126, 0, 0, 0, 0, 125, 125, 572,
- 0, 0, 123, 125, 336, 0, 0, 0, 0, 0,
- 122, 0, 0, 126, 0, 126, 0, 0, 0, 122,
- 0, 122, 0, 122, 122, 0, 123, 122, 0, 0,
- 0, 125, 593, 0, 0, 123, 126, 123, 0, 123,
- 123, 0, 124, 123, 0, 126, 126, 0, 0, 0,
- 0, 126, 0, 277, 0, 125, 602, 0, 0, 0,
- 0, 0, 0, 124, 125, 124, 125, 607, 125, 125,
- 336, 0, 125, 336, 0, 0, 0, 0, 0, 126,
- 0, 0, 0, 0, 0, 0, 124, 0, 0, 0,
- 0, 0, 0, 0, 0, 124, 124, 0, 0, 0,
- 0, 124, 0, 126, 0, 0, 278, 279, 280, 281,
- 282, 283, 126, 255, 126, 0, 126, 126, 0, 0,
- 126, 284, 285, 286, 0, 0, 0, 0, 0, 124,
- 0, 287, 0, 288, 289, 290, 291, 292, 293, 294,
- 295, 296, 297, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 124, 361, 264, 265, 266, 0, 0,
- 0, 272, 124, 0, 124, 277, 124, 124, 0, 0,
- 124, 0, 0, 299, 0, 301, 302, 0, 0, 305,
- 0, 307, 308, 309, 310, 0, 0, 0, 0, 0,
- 0, 0, 0, 319, 320, 321, 322, 323, 324, 325,
- 326, 327, 0, 331, 333, 0, 0, 0, 0, 0,
- 337, 0, 339, 0, 0, 0, 342, 0, 278, 279,
- 280, 281, 282, 283, 0, 0, 0, 277, 0, 344,
- 0, 0, 0, 284, 285, 286, 0, 0, 0, 0,
- 456, 0, 354, 287, 0, 288, 289, 290, 291, 292,
- 293, 294, 295, 296, 297, 0, 0, 0, 0, 0,
- 366, 367, 368, 369, 370, 371, 372, 373, 374, 375,
- 376, 377, 378, 379, 380, 381, 382, 383, 384, 385,
- 278, 279, 280, 281, 282, 283, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 284, 285, 286, 0, 0,
- 0, 0, 0, 0, 0, 287, 0, 288, 289, 290,
- 291, 292, 293, 294, 295, 296, 297, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 386, 491,
- 493, 4, 5, 6, 0, 7, 0, 0, 8, 0,
- 9, 10, 11, 12, 13, 14, 15, 0, 16, 17,
- 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
- 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
- 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
- 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
- 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,
- 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
- 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
- 88, 89, 90, 91, 92, 93, 94, 95, 96, 97,
- 98, 0, 0, 0, 0, 0, 0, 99, 512, 277,
- 0, 0, 0, 513, 100, 101, 515, 516, 0, 517,
- 518, 521, 521, 0, 523, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 527, 0, 0, 491, 0, 0,
- 0, 0, 0, 0, 0, 0, 277, 0, 0, 0,
- 0, 0, 102, 0, 103, 539, 0, 0, 0, 0,
- 0, 0, 278, 279, 280, 281, 282, 283, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 284, 285, 286,
- 0, 0, 0, 0, 0, 570, 0, 287, 0, 288,
- 289, 290, 291, 292, 293, 294, 295, 296, 297, 278,
- 279, 280, 281, 282, 283, 0, 580, 581, 0, 0,
- 453, 0, 586, 0, 284, 285, 286, 0, 0, 0,
- 0, 0, 0, 0, 287, 0, 288, 289, 290, 291,
- 292, 293, 294, 295, 296, 297, 0, 0, 0, 600,
- 0, 0, 0, 0, 0, 0, 0, 454, 0, 0,
- 0, 604, 0, 0, 0, 0, 0, 0, 4, 5,
- 610, 0, 7, 0, 614, 8, 0, 9, 10, 11,
- 12, 13, 14, 15, 0, 16, 17, 18, 19, 20,
- 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
- 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
- 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
- 51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
- 61, 62, 63, 64, 65, 66, 67, 68, 69, 70,
- 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
- 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
- 91, 92, 93, 94, 95, 96, 97, 98, 0, 0,
- 0, 0, 0, 0, 99, 0, 0, 0, 0, 0,
- 0, 100, 101, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 102,
- 224, 103, 4, 5, 0, 0, 7, 0, 0, 8,
- 0, 9, 10, 11, 12, 13, 14, 15, 0, 16,
- 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
- 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
- 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
- 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
- 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
- 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
- 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
- 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
- 97, 98, 0, 0, 0, 0, 0, 0, 99, 0,
- 0, 0, 0, 0, 0, 100, 101, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 102, 335, 103, 4, 5, 0, 0,
- 7, 0, 0, 8, 0, 9, 10, 11, 12, 13,
- 14, 15, 0, 16, 17, 18, 19, 20, 21, 22,
- 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
- 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
- 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
- 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,
- 63, 64, 65, 66, 67, 68, 69, 70, 71, 72,
- 73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
- 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
- 93, 94, 95, 96, 97, 98, 0, 0, 0, 0,
- 0, 0, 99, 0, 0, 0, 0, 0, 0, 100,
- 101, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 102, 573, 103,
- 4, 5, 0, 0, 7, 0, 0, 8, 0, 9,
- 10, 11, 12, 13, 14, 15, 0, 16, 17, 18,
- 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
- 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
- 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
- 49, 50, 51, 52, 53, 54, 55, 56, 57, 58,
- 59, 60, 61, 62, 63, 64, 65, 66, 67, 68,
- 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
- 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
- 89, 90, 91, 92, 93, 94, 95, 96, 97, 98,
- 0, 0, 0, 0, 0, 0, 99, 0, 0, 0,
- 0, 0, 0, 100, 101, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 611, 5, 0, 0, 7,
- 0, 102, 8, 103, 9, 10, 11, 12, 13, 14,
- 15, 0, 16, 17, 18, 19, 20, 21, 22, 23,
- 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
- 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
- 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
- 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
- 64, 65, 66, 67, 68, 69, 70, 71, 72, 73,
- 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
- 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
- 94, 95, 96, 97, 98, 0, 0, 0, 0, 0,
- 0, 99, 0, 0, 0, 0, 0, 0, 100, 101,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 6, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 166, 132, 0, 102, 0, 103, 18,
- 19, 20, 21, 22, 23, 137, 25, 26, 27, 141,
- 142, 143, 144, 145, 146, 147, 148, 36, 37, 38,
- 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
- 49, 50, 51, 52, 53, 54, 55, 56, 57, 58,
- 59, 60, 61, 62, 63, 64, 65, 66, 67, 68,
- 69, 70, 71, 72, 73, 74, 75, 76, 77, 151,
- 152, 80, 81, 82, 83, 84, 85, 86, 87, 88,
- 89, 153, 154, 0, 0, 0, 155, 156, 0, 0,
- 167, 168, 169, 170, 0, 171, 172, 0, 0, 0,
- 0, 0, 0, 100, 101, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 173, 0, 0, 0, 174, 175, 6, 0, 0, 176,
- 0, 177, 0, 178, 179, 0, 0, 166, 132, 0,
- 0, 0, 0, 18, 19, 20, 21, 22, 23, 137,
- 25, 26, 27, 141, 142, 143, 144, 145, 146, 147,
- 148, 36, 37, 38, 39, 40, 41, 42, 43, 44,
- 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
- 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
- 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
- 75, 76, 77, 151, 152, 80, 81, 82, 83, 84,
- 85, 86, 87, 88, 89, 153, 154, 0, 0, 0,
- 155, 156, 0, 0, 167, 168, 169, 170, 0, 171,
- 172, 0, 0, 0, 0, 0, 0, 100, 101, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 173, 6, 0, 0, 174, 175,
- 0, 0, 0, 176, 0, 177, 13, 132, 179, 0,
- 0, 0, 18, 19, 20, 21, 22, 23, 137, 25,
- 26, 27, 141, 142, 143, 144, 145, 146, 147, 148,
- 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
- 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
- 56, 57, 58, 59, 60, 61, 62, 63, 64, 65,
- 66, 67, 68, 69, 70, 71, 72, 73, 74, 75,
- 76, 77, 151, 152, 80, 81, 82, 83, 84, 85,
- 86, 87, 88, 89, 153, 154, 0, 0, 0, 155,
- 156, 0, 0, 167, 168, 169, 170, 0, 171, 172,
- 0, 0, 0, 0, 0, 0, 100, 101, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 6, 0, 173, 0, 0, 0, 174, 175, 0,
- 0, 0, 13, 132, 0, 0, 0, 179, 18, 19,
- 20, 21, 22, 23, 137, 25, 26, 27, 141, 142,
- 143, 144, 145, 146, 147, 148, 36, 37, 38, 39,
- 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
- 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
- 60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
- 70, 71, 72, 73, 74, 75, 76, 77, 151, 152,
- 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
- 153, 154, 0, 0, 0, 155, 156, 0, 0, 167,
- 262, 263, 170, 0, 171, 172, 0, 0, 0, 0,
- 0, 0, 100, 101, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 6, 0, 173,
- 0, 0, 0, 174, 175, 0, 0, 0, 13, 132,
- 0, 0, 0, 179, 18, 19, 20, 21, 22, 23,
- 137, 25, 26, 27, 141, 142, 143, 144, 145, 146,
- 147, 148, 36, 37, 38, 39, 40, 41, 42, 43,
- 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
- 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
- 64, 65, 66, 67, 68, 69, 70, 71, 72, 73,
- 74, 75, 76, 77, 151, 152, 80, 81, 82, 83,
- 84, 85, 86, 87, 88, 89, 153, 154, 0, 0,
- 0, 155, 156, 0, 0, 167, 329, 169, 170, 0,
- 330, 172, 0, 0, 0, 0, 0, 0, 100, 101,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 6, 0, 173, 0, 0, 0, 174,
- 175, 0, 0, 0, 13, 132, 0, 0, 0, 179,
- 18, 19, 20, 21, 22, 23, 137, 25, 26, 27,
- 141, 142, 143, 144, 145, 146, 147, 148, 36, 37,
- 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
- 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
- 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,
- 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
- 151, 152, 80, 81, 82, 83, 84, 85, 86, 87,
- 88, 89, 153, 154, 0, 0, 0, 155, 156, 0,
- 0, 167, 168, 169, 170, 0, 332, 172, 0, 0,
- 0, 0, 0, 0, 100, 101, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 6,
- 0, 173, 0, 0, 0, 174, 175, 0, 0, 0,
- 13, 132, 0, 0, 0, 179, 18, 19, 20, 21,
- 22, 23, 137, 25, 26, 27, 141, 142, 143, 144,
- 145, 146, 147, 148, 36, 37, 38, 39, 40, 41,
- 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
- 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
- 62, 63, 64, 65, 66, 67, 68, 69, 70, 71,
- 72, 73, 74, 75, 76, 77, 151, 152, 80, 81,
- 82, 83, 84, 85, 86, 87, 88, 89, 153, 154,
- 0, 0, 0, 155, 156, 0, 0, 167, 519, 169,
- 170, 0, 171, 172, 0, 0, 0, 0, 0, 0,
- 100, 101, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 173, 0, 0,
- 0, 174, 175, 0, 387, 388, 389, 390, 0, 391,
- 0, 179, 392, 393, 0, 394, 0, 395, 396, 397,
- 398, 0, 0, 0, 0, 0, 0, 277, 0, 399,
- 400, 401, 402, 403, 404, 405, 406, 407, 408, 409,
- 410, 411, 412, 413, 414, 415, 416, 417, 418, 419,
- 420, 421, 422, 423, 424, 425, 426, 427, 428, 429,
- 430, 431, 432, 433, 434, 435, 436, 437, 438, 439,
- 440, 441, 442, 443, 444, 445, 446, 447, 448, 449,
- 278, 279, 280, 281, 282, 283, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 284, 285, 286, 0, 0,
- 0, 0, 0, 0, 0, 287, 0, 288, 289, 290,
- 291, 292, 293, 294, 295, 296, 297, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 458, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 13, 132,
- 0, 0, 0, 0, 510, 133, 134, 135, 136, 23,
- 137, 138, 139, 140, 141, 142, 143, 144, 145, 146,
- 147, 148, 36, 37, 38, 39, 40, 41, 42, 43,
- 44, 45, 46, 47, 48, 49, 50, 51, 149, 53,
- 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
- 64, 65, 66, 67, 68, 69, 70, 71, 72, 73,
- 150, 75, 76, 77, 151, 152, 80, 81, 82, 83,
- 84, 85, 86, 87, 88, 89, 153, 154, 0, 0,
- 0, 155, 156, 0, 0, 0, 0, 0, 0, 0,
- 0, 157, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 250, 13, 14, 0, 0, 224, 17, 18,
- 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
- 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
- 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
- 49, 50, 51, 52, 53, 54, 55, 56, 57, 58,
- 59, 60, 61, 62, 63, 64, 65, 66, 67, 68,
- 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
- 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
- 89, 90, 91, 92, 93, 94, 95, 96, 97, 98,
- 0, 0, 0, 0, 0, 0, 99, 0, 0, 12,
- 13, 14, 0, 100, 101, 17, 18, 19, 20, 21,
- 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
- 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
- 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
- 62, 63, 64, 65, 66, 67, 68, 69, 70, 71,
- 72, 73, 74, 75, 76, 77, 78, 79, 80, 81,
- 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
- 92, 93, 94, 95, 96, 97, 98, 277, 0, 0,
- 0, 0, 0, 99, 0, 0, 0, 0, 0, 0,
- 100, 101, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 277, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 278, 279, 280, 281, 282, 283, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 284, 285, 286, 0, 0,
- 0, 277, 0, 0, 0, 287, 0, 288, 289, 290,
- 291, 292, 293, 294, 295, 296, 297, 278, 279, 280,
- 281, 282, 283, 0, 0, 0, 0, 0, 459, 0,
- 0, 0, 284, 285, 286, 0, 0, 0, 277, 0,
- 0, 0, 287, 0, 288, 289, 290, 291, 292, 293,
- 294, 295, 296, 297, 278, 279, 280, 281, 282, 283,
- 0, 0, 0, 0, 0, 460, 0, 0, 0, 284,
- 285, 286, 0, 0, 0, 277, 0, 0, 0, 287,
- 0, 288, 289, 290, 291, 292, 293, 294, 295, 296,
- 297, 278, 279, 280, 281, 282, 283, 0, 0, 0,
- 0, 0, 466, 0, 0, 0, 284, 285, 286, 0,
- 0, 0, 277, 0, 0, 0, 287, 0, 288, 289,
- 290, 291, 292, 293, 294, 295, 296, 297, 278, 279,
- 280, 281, 282, 283, 0, 0, 0, 0, 0, 471,
- 0, 0, 0, 284, 285, 286, 0, 0, 0, 277,
- 0, 0, 0, 287, 0, 288, 289, 290, 291, 292,
- 293, 294, 295, 296, 297, 278, 279, 280, 281, 282,
- 283, 0, 0, 0, 0, 0, 475, 0, 0, 0,
- 284, 285, 286, 0, 0, 0, 277, 0, 0, 0,
- 287, 0, 288, 289, 290, 291, 292, 293, 294, 295,
- 296, 297, 278, 279, 280, 281, 282, 283, 0, 0,
- 0, 0, 0, 477, 0, 0, 0, 284, 285, 286,
- 0, 0, 0, 277, 0, 0, 0, 287, 0, 288,
- 289, 290, 291, 292, 293, 294, 295, 296, 297, 278,
- 279, 280, 281, 282, 283, 0, 0, 0, 0, 0,
- 479, 0, 0, 0, 284, 285, 286, 0, 0, 0,
- 277, 0, 0, 0, 287, 0, 288, 289, 290, 291,
- 292, 293, 294, 295, 296, 297, 278, 279, 280, 281,
- 282, 283, 0, 0, 0, 0, 0, 481, 0, 0,
- 0, 284, 285, 286, 0, 0, 0, 277, 0, 0,
- 0, 287, 0, 288, 289, 290, 291, 292, 293, 294,
- 295, 296, 297, 278, 279, 280, 281, 282, 283, 0,
- 0, 0, 0, 0, 550, 0, 0, 0, 284, 285,
- 286, 0, 0, 0, 277, 0, 0, 0, 287, 0,
- 288, 289, 290, 291, 292, 293, 294, 295, 296, 297,
- 278, 279, 280, 281, 282, 283, 0, 0, 0, 0,
- 0, 564, 0, 0, 0, 284, 285, 286, 0, 0,
- 0, 277, 0, 0, 0, 287, 0, 288, 289, 290,
- 291, 292, 293, 294, 295, 296, 297, 278, 279, 280,
- 281, 282, 283, 0, 0, 0, 0, 0, 597, 0,
- 0, 0, 284, 285, 286, 0, 0, 0, 277, 0,
- 0, 0, 287, 0, 288, 289, 290, 291, 292, 293,
- 294, 295, 296, 297, 278, 279, 280, 281, 282, 283,
- 0, 0, 0, 0, 0, 598, 0, 0, 0, 284,
- 285, 286, 0, 0, 0, 277, 0, 0, 0, 287,
- 0, 288, 289, 290, 291, 292, 293, 294, 295, 296,
- 297, 278, 279, 280, 281, 282, 283, 0, 0, 0,
- 0, 0, 615, 0, 0, 0, 284, 285, 286, 0,
- 0, 0, 277, 0, 0, 0, 287, 0, 288, 289,
- 290, 291, 292, 293, 294, 295, 296, 297, 278, 279,
- 280, 281, 282, 283, 484, 0, 0, 0, 0, 0,
- 0, 0, 0, 284, 285, 286, 0, 0, 0, 277,
- 0, 0, 0, 287, 0, 288, 289, 290, 291, 292,
- 293, 294, 295, 296, 297, 278, 279, 280, 281, 282,
- 283, 496, 0, 0, 0, 0, 0, 0, 0, 0,
- 284, 285, 286, 0, 0, 0, 0, 0, 0, 0,
- 287, 0, 288, 289, 290, 291, 292, 293, 294, 295,
- 296, 297, 278, 279, 280, 281, 282, 283, 594, 0,
- 0, 0, 0, 0, 0, 0, 0, 284, 285, 286,
- 0, 0, 0, 0, 0, 0, 0, 287, 0, 288,
- 289, 290, 291, 292, 293, 294, 295, 296, 297, 13,
- 132, 0, 0, 532, 533, 18, 19, 20, 21, 22,
- 23, 137, 25, 26, 27, 141, 142, 143, 144, 145,
- 146, 147, 148, 36, 37, 38, 39, 40, 41, 42,
- 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
- 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,
- 63, 64, 65, 66, 67, 68, 69, 70, 71, 72,
- 73, 74, 75, 76, 77, 151, 152, 80, 81, 82,
- 83, 84, 85, 86, 87, 88, 89, 153, 154, 0,
- 0, 0, 155, 156, 0, 0, 0, 13, 132, 0,
- 0, 0, 161, 18, 19, 20, 21, 22, 23, 137,
- 25, 26, 27, 141, 142, 143, 144, 145, 146, 147,
- 148, 36, 37, 38, 39, 40, 41, 42, 43, 44,
- 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
- 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
- 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
- 75, 76, 77, 151, 152, 80, 81, 82, 83, 84,
- 85, 86, 87, 88, 89, 153, 154, 0, 0, 0,
- 155, 156, 0, 0, 13, 132, 0, 0, 0, 0,
- 172, 133, 134, 135, 136, 23, 137, 138, 139, 140,
- 141, 142, 143, 144, 145, 146, 147, 148, 36, 37,
- 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
- 48, 49, 50, 51, 149, 53, 54, 55, 56, 57,
- 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,
- 68, 69, 70, 71, 72, 73, 150, 75, 76, 77,
- 151, 152, 80, 81, 82, 83, 84, 85, 86, 87,
- 88, 89, 153, 154, 0, 0, 0, 155, 156, 0,
- 0, 13, 132, 0, 0, 0, 0, 157, 133, 134,
- 135, 136, 23, 137, 138, 139, 140, 141, 142, 143,
- 144, 145, 146, 147, 148, 36, 37, 38, 39, 40,
- 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
- 51, 149, 53, 54, 55, 56, 57, 58, 59, 60,
- 61, 62, 63, 64, 65, 66, 67, 68, 69, 70,
- 71, 72, 73, 150, 75, 76, 77, 151, 152, 80,
- 81, 82, 83, 84, 85, 86, 87, 88, 89, 153,
- 154, 277, 0, 0, 155, 156, 0, 0, 0, 0,
- 0, 0, 0, 0, 353, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 277, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 278, 279, 280, 281, 282, 283,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 284,
- 285, 286, 0, 0, 0, 277, 461, 0, 0, 287,
- 0, 288, 289, 290, 291, 292, 293, 294, 295, 296,
- 297, 278, 279, 280, 281, 282, 283, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 284, 285, 286, 0,
- 0, 0, 277, 464, 0, 0, 287, 0, 288, 289,
- 290, 291, 292, 293, 294, 295, 296, 297, 278, 279,
- 280, 281, 282, 283, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 284, 285, 286, 0, 0, 0, 277,
- 465, 0, 0, 287, 0, 288, 289, 290, 291, 292,
- 293, 294, 295, 296, 297, 278, 279, 280, 281, 282,
- 283, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 284, 285, 286, 0, 0, 0, 277, 467, 0, 0,
- 287, 0, 288, 289, 290, 291, 292, 293, 294, 295,
- 296, 297, 278, 279, 280, 281, 282, 283, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 284, 285, 286,
- 0, 0, 0, 277, 468, 0, 0, 287, 0, 288,
- 289, 290, 291, 292, 293, 294, 295, 296, 297, 278,
- 279, 280, 281, 282, 283, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 284, 285, 286, 0, 0, 0,
- 277, 469, 0, 0, 287, 0, 288, 289, 290, 291,
- 292, 293, 294, 295, 296, 297, 278, 279, 280, 281,
- 282, 283, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 284, 285, 286, 0, 0, 0, 277, 470, 0,
- 0, 287, 0, 288, 289, 290, 291, 292, 293, 294,
- 295, 296, 297, 278, 279, 280, 281, 282, 283, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 284, 285,
- 286, 0, 0, 0, 277, 472, 0, 0, 287, 0,
- 288, 289, 290, 291, 292, 293, 294, 295, 296, 297,
- 278, 279, 280, 281, 282, 283, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 284, 285, 286, 0, 0,
- 0, 277, 0, 0, 0, 287, 503, 288, 289, 290,
- 291, 292, 293, 294, 295, 296, 297, 278, 279, 280,
- 281, 282, 283, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 284, 285, 286, 0, 0, 0, 277, 551,
- 0, 0, 287, 0, 288, 289, 290, 291, 292, 293,
- 294, 295, 296, 297, 278, 279, 280, 281, 282, 283,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 284,
- 285, 286, 0, 0, 0, 277, 554, 0, 0, 287,
- 0, 288, 289, 290, 291, 292, 293, 294, 295, 296,
- 297, 278, 279, 280, 281, 282, 283, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 284, 285, 286, 0,
- 0, 0, 277, 555, 0, 0, 287, 0, 288, 289,
- 290, 291, 292, 293, 294, 295, 296, 297, 278, 279,
- 280, 281, 282, 283, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 284, 285, 286, 0, 0, 0, 277,
- 599, 0, 0, 287, 0, 288, 289, 290, 291, 292,
- 293, 294, 295, 296, 297, 278, 279, 280, 281, 282,
- 283, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 284, 285, 286, 0, 0, 0, 277, 0, 0, 0,
- 287, 605, 288, 289, 290, 291, 292, 293, 294, 295,
- 296, 297, 278, 279, 280, 281, 282, 283, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 284, 285, 286,
- 0, 0, 0, 277, 608, 0, 0, 287, 0, 288,
- 289, 290, 291, 292, 293, 294, 295, 296, 297, 278,
- 279, 280, 281, 282, 283, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 284, 285, 286, 0, 0, 0,
- 277, 612, 0, 0, 287, 0, 288, 289, 290, 291,
- 292, 293, 294, 295, 296, 297, 278, 279, 280, 281,
- 282, 283, 277, 0, 0, 0, 0, 0, 0, 0,
- 0, 284, 285, 286, 0, 0, 0, 0, 0, 0,
- 0, 287, 0, 288, 289, 290, 291, 292, 293, 294,
- 295, 296, 297, 278, 279, 280, 281, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 284, 285,
- 286, 0, 0, 0, 0, 0, 279, 280, 0, 0,
- 288, 289, 290, 291, 292, 293, 294, 295, 296, 297,
- 284, 285, 286, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 288, 289, 290, 291, 292, 293, 294, 295,
- 296, 297, 387, 388, 389, 390, 574, 391, 0, 0,
- 392, 393, 0, 394, 0, 395, 396, 397, 398, 0,
- 0, 0, 0, 0, 0, 0, 0, 399, 400, 401,
- 402, 403, 404, 405, 406, 407, 408, 409, 410, 411,
- 412, 413, 414, 415, 416, 417, 418, 419, 420, 421,
- 422, 423, 424, 425, 426, 427, 428, 429, 430, 431,
- 432, 433, 434, 435, 436, 437, 438, 439, 440, 441,
- 442, 443, 444, 445, 446, 447, 448, 449, 387, 388,
- 389, 390, 0, 391, 0, 0, 392, 393, 0, 394,
- 0, 395, 396, 397, 398, 0, 0, 0, 0, 0,
- 0, 0, 0, 399, 400, 401, 402, 403, 404, 405,
- 406, 407, 408, 409, 410, 411, 412, 413, 414, 415,
- 416, 417, 418, 419, 420, 421, 422, 423, 424, 425,
- 426, 427, 428, 429, 430, 431, 432, 433, 434, 435,
- 436, 437, 438, 439, 440, 441, 442, 443, 444, 445,
- 446, 447, 448, 449
-};
-
-static const yytype_int16 yycheck[] =
-{
- 2, 130, 11, 223, 8, 9, 2, 8, 9, 504,
- 450, 132, 14, 132, 132, 132, 2, 0, 132, 132,
- 156, 132, 132, 132, 57, 132, 151, 152, 14, 132,
- 0, 157, 12, 156, 154, 156, 132, 158, 258, 158,
- 158, 158, 155, 15, 158, 2, 2, 158, 158, 158,
- 153, 158, 157, 15, 151, 152, 157, 14, 116, 117,
- 118, 119, 120, 121, 122, 123, 124, 116, 117, 157,
- 128, 129, 130, 151, 152, 133, 134, 157, 92, 93,
- 151, 152, 157, 57, 133, 157, 157, 151, 152, 57,
- 151, 152, 157, 2, 108, 157, 157, 151, 152, 156,
- 102, 541, 104, 151, 152, 14, 601, 157, 104, 156,
- 605, 144, 145, 146, 157, 117, 102, 157, 104, 157,
- 517, 518, 124, 520, 133, 522, 157, 157, 130, 157,
- 157, 117, 157, 157, 114, 355, 157, 157, 124, 157,
- 157, 157, 157, 2, 130, 102, 157, 104, 104, 157,
- 130, 155, 157, 108, 155, 158, 13, 125, 126, 127,
- 117, 117, 157, 157, 157, 157, 157, 124, 142, 143,
- 144, 145, 146, 130, 142, 143, 144, 145, 146, 157,
- 157, 157, 133, 185, 157, 11, 166, 103, 104, 105,
- 106, 107, 108, 102, 157, 104, 157, 177, 158, 185,
- 158, 132, 156, 57, 176, 158, 158, 157, 117, 158,
- 158, 158, 136, 158, 158, 124, 158, 346, 132, 158,
- 158, 130, 158, 225, 196, 157, 198, 157, 185, 154,
- 107, 154, 108, 108, 196, 108, 198, 157, 210, 225,
- 158, 158, 6, 102, 132, 104, 158, 158, 210, 57,
- 156, 223, 132, 233, 158, 158, 158, 158, 117, 158,
- 158, 158, 158, 483, 136, 156, 104, 126, 225, 225,
- 250, 130, 338, 245, 485, 277, 185, 257, 567, 259,
- 534, 470, 359, 245, 256, 575, 258, 505, 257, -1,
- -1, 277, -1, 273, 256, -1, -1, -1, -1, -1,
- -1, -1, -1, 275, -1, -1, -1, -1, -1, 529,
- -1, -1, -1, 275, -1, -1, 225, 125, 126, 127,
- 277, -1, -1, -1, -1, -1, -1, -1, 187, -1,
- -1, 139, 140, 141, 142, 143, 144, 145, 146, -1,
- -1, -1, -1, -1, 346, 347, 57, 349, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, 338, -1,
- 346, 347, -1, 349, -1, -1, 225, 347, 277, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, 359,
- -1, -1, -1, 355, 356, -1, 358, -1, 57, 346,
- -1, -1, 349, 349, 356, -1, 358, -1, -1, 110,
- 111, 112, 113, 114, 115, 534, -1, -1, -1, -1,
- -1, -1, -1, -1, 125, 126, 127, -1, -1, -1,
- -1, 132, -1, -1, 135, -1, 137, 138, 139, 140,
- 141, 142, 143, 144, 145, 146, -1, 346, -1, -1,
- 349, 110, 111, 112, 113, 114, 115, 158, -1, -1,
- -1, -1, -1, -1, -1, -1, 125, 126, 127, -1,
- -1, -1, -1, -1, -1, -1, 135, -1, 137, 138,
- 139, 140, 141, 142, 143, 144, 145, 146, -1, 481,
- -1, -1, -1, 485, -1, -1, -1, 346, -1, 158,
- 349, -1, -1, -1, -1, 481, -1, -1, -1, 485,
- 502, -1, 504, -1, -1, 485, -1, -1, -1, -1,
- -1, 483, -1, -1, -1, -1, 502, -1, 504, -1,
- -1, 501, -1, 525, 481, 481, -1, -1, -1, -1,
- -1, -1, 534, 535, -1, -1, -1, -1, 540, 525,
- -1, -1, -1, -1, -1, 502, 502, 504, 534, 535,
- -1, -1, 532, -1, 540, -1, -1, 529, -1, -1,
- -1, -1, -1, -1, -1, -1, 568, -1, 525, 525,
- -1, -1, 481, -1, -1, -1, -1, 534, 535, 535,
- -1, -1, 568, 540, 540, -1, -1, -1, -1, -1,
- 592, -1, -1, 502, -1, 504, -1, -1, -1, 601,
- -1, 603, -1, 605, 606, -1, 592, 609, -1, -1,
- -1, 568, 568, -1, -1, 601, 525, 603, -1, 605,
- 606, -1, 481, 609, -1, 534, 535, -1, -1, -1,
- -1, 540, -1, 57, -1, 592, 592, -1, -1, -1,
- -1, -1, -1, 502, 601, 504, 603, 603, 605, 606,
- 606, -1, 609, 609, -1, -1, -1, -1, -1, 568,
- -1, -1, -1, -1, -1, -1, 525, -1, -1, -1,
- -1, -1, -1, -1, -1, 534, 535, -1, -1, -1,
- -1, 540, -1, 592, -1, -1, 110, 111, 112, 113,
- 114, 115, 601, 131, 603, -1, 605, 606, -1, -1,
- 609, 125, 126, 127, -1, -1, -1, -1, -1, 568,
- -1, 135, -1, 137, 138, 139, 140, 141, 142, 143,
- 144, 145, 146, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, 592, 158, 173, 174, 175, -1, -1,
- -1, 179, 601, -1, 603, 57, 605, 606, -1, -1,
- 609, -1, -1, 191, -1, 193, 194, -1, -1, 197,
- -1, 199, 200, 201, 202, -1, -1, -1, -1, -1,
- -1, -1, -1, 211, 212, 213, 214, 215, 216, 217,
- 218, 219, -1, 221, 222, -1, -1, -1, -1, -1,
- 228, -1, 230, -1, -1, -1, 234, -1, 110, 111,
- 112, 113, 114, 115, -1, -1, -1, 57, -1, 247,
- -1, -1, -1, 125, 126, 127, -1, -1, -1, -1,
- 132, -1, 260, 135, -1, 137, 138, 139, 140, 141,
- 142, 143, 144, 145, 146, -1, -1, -1, -1, -1,
- 278, 279, 280, 281, 282, 283, 284, 285, 286, 287,
- 288, 289, 290, 291, 292, 293, 294, 295, 296, 297,
- 110, 111, 112, 113, 114, 115, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, 125, 126, 127, -1, -1,
- -1, -1, -1, -1, -1, 135, -1, 137, 138, 139,
- 140, 141, 142, 143, 144, 145, 146, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, 158, 347,
- 348, 3, 4, 5, -1, 7, -1, -1, 10, -1,
- 12, 13, 14, 15, 16, 17, 18, -1, 20, 21,
- 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
- 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
- 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
- 62, 63, 64, 65, 66, 67, 68, 69, 70, 71,
- 72, 73, 74, 75, 76, 77, 78, 79, 80, 81,
- 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
- 92, 93, 94, 95, 96, 97, 98, 99, 100, 101,
- 102, -1, -1, -1, -1, -1, -1, 109, 456, 57,
- -1, -1, -1, 461, 116, 117, 464, 465, -1, 467,
- 468, 469, 470, -1, 472, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, 482, -1, -1, 485, -1, -1,
- -1, -1, -1, -1, -1, -1, 57, -1, -1, -1,
- -1, -1, 154, -1, 156, 503, -1, -1, -1, -1,
- -1, -1, 110, 111, 112, 113, 114, 115, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, 125, 126, 127,
- -1, -1, -1, -1, -1, 533, -1, 135, -1, 137,
- 138, 139, 140, 141, 142, 143, 144, 145, 146, 110,
- 111, 112, 113, 114, 115, -1, 554, 555, -1, -1,
- 158, -1, 560, -1, 125, 126, 127, -1, -1, -1,
- -1, -1, -1, -1, 135, -1, 137, 138, 139, 140,
- 141, 142, 143, 144, 145, 146, -1, -1, -1, 587,
- -1, -1, -1, -1, -1, -1, -1, 158, -1, -1,
- -1, 599, -1, -1, -1, -1, -1, -1, 3, 4,
- 608, -1, 7, -1, 612, 10, -1, 12, 13, 14,
- 15, 16, 17, 18, -1, 20, 21, 22, 23, 24,
- 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
- 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
- 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
- 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
- 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
- 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
- 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
- 95, 96, 97, 98, 99, 100, 101, 102, -1, -1,
- -1, -1, -1, -1, 109, -1, -1, -1, -1, -1,
- -1, 116, 117, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, 154,
- 155, 156, 3, 4, -1, -1, 7, -1, -1, 10,
- -1, 12, 13, 14, 15, 16, 17, 18, -1, 20,
- 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
- 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
- 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
- 51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
- 61, 62, 63, 64, 65, 66, 67, 68, 69, 70,
- 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
- 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
- 91, 92, 93, 94, 95, 96, 97, 98, 99, 100,
- 101, 102, -1, -1, -1, -1, -1, -1, 109, -1,
- -1, -1, -1, -1, -1, 116, 117, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, 154, 155, 156, 3, 4, -1, -1,
- 7, -1, -1, 10, -1, 12, 13, 14, 15, 16,
- 17, 18, -1, 20, 21, 22, 23, 24, 25, 26,
- 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
- 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
- 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
- 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
- 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
- 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
- 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
- 97, 98, 99, 100, 101, 102, -1, -1, -1, -1,
- -1, -1, 109, -1, -1, -1, -1, -1, -1, 116,
- 117, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, 154, 155, 156,
- 3, 4, -1, -1, 7, -1, -1, 10, -1, 12,
- 13, 14, 15, 16, 17, 18, -1, 20, 21, 22,
- 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
- 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
- 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
- 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,
- 63, 64, 65, 66, 67, 68, 69, 70, 71, 72,
- 73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
- 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
- 93, 94, 95, 96, 97, 98, 99, 100, 101, 102,
- -1, -1, -1, -1, -1, -1, 109, -1, -1, -1,
- -1, -1, -1, 116, 117, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, 3, 4, -1, -1, 7,
- -1, 154, 10, 156, 12, 13, 14, 15, 16, 17,
- 18, -1, 20, 21, 22, 23, 24, 25, 26, 27,
- 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
- 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
- 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
- 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,
- 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
- 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
- 88, 89, 90, 91, 92, 93, 94, 95, 96, 97,
- 98, 99, 100, 101, 102, -1, -1, -1, -1, -1,
- -1, 109, -1, -1, -1, -1, -1, -1, 116, 117,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, 5, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, 16, 17, -1, 154, -1, 156, 22,
- 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
- 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
- 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
- 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,
- 63, 64, 65, 66, 67, 68, 69, 70, 71, 72,
- 73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
- 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
- 93, 94, 95, -1, -1, -1, 99, 100, -1, -1,
- 103, 104, 105, 106, -1, 108, 109, -1, -1, -1,
- -1, -1, -1, 116, 117, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- 143, -1, -1, -1, 147, 148, 5, -1, -1, 152,
- -1, 154, -1, 156, 157, -1, -1, 16, 17, -1,
- -1, -1, -1, 22, 23, 24, 25, 26, 27, 28,
- 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
- 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
- 49, 50, 51, 52, 53, 54, 55, 56, 57, 58,
- 59, 60, 61, 62, 63, 64, 65, 66, 67, 68,
- 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
- 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
- 89, 90, 91, 92, 93, 94, 95, -1, -1, -1,
- 99, 100, -1, -1, 103, 104, 105, 106, -1, 108,
- 109, -1, -1, -1, -1, -1, -1, 116, 117, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, 143, 5, -1, -1, 147, 148,
- -1, -1, -1, 152, -1, 154, 16, 17, 157, -1,
- -1, -1, 22, 23, 24, 25, 26, 27, 28, 29,
- 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
- 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
- 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
- 60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
- 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
- 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
- 90, 91, 92, 93, 94, 95, -1, -1, -1, 99,
- 100, -1, -1, 103, 104, 105, 106, -1, 108, 109,
- -1, -1, -1, -1, -1, -1, 116, 117, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, 5, -1, 143, -1, -1, -1, 147, 148, -1,
- -1, -1, 16, 17, -1, -1, -1, 157, 22, 23,
- 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
- 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
- 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
- 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
- 64, 65, 66, 67, 68, 69, 70, 71, 72, 73,
- 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
- 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
- 94, 95, -1, -1, -1, 99, 100, -1, -1, 103,
- 104, 105, 106, -1, 108, 109, -1, -1, -1, -1,
- -1, -1, 116, 117, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, 5, -1, 143,
- -1, -1, -1, 147, 148, -1, -1, -1, 16, 17,
- -1, -1, -1, 157, 22, 23, 24, 25, 26, 27,
- 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
- 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
- 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
- 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,
- 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
- 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
- 88, 89, 90, 91, 92, 93, 94, 95, -1, -1,
- -1, 99, 100, -1, -1, 103, 104, 105, 106, -1,
- 108, 109, -1, -1, -1, -1, -1, -1, 116, 117,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, 5, -1, 143, -1, -1, -1, 147,
- 148, -1, -1, -1, 16, 17, -1, -1, -1, 157,
- 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
- 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
- 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
- 62, 63, 64, 65, 66, 67, 68, 69, 70, 71,
- 72, 73, 74, 75, 76, 77, 78, 79, 80, 81,
- 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
- 92, 93, 94, 95, -1, -1, -1, 99, 100, -1,
- -1, 103, 104, 105, 106, -1, 108, 109, -1, -1,
- -1, -1, -1, -1, 116, 117, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, 5,
- -1, 143, -1, -1, -1, 147, 148, -1, -1, -1,
- 16, 17, -1, -1, -1, 157, 22, 23, 24, 25,
- 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
- 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
- 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
- 56, 57, 58, 59, 60, 61, 62, 63, 64, 65,
- 66, 67, 68, 69, 70, 71, 72, 73, 74, 75,
- 76, 77, 78, 79, 80, 81, 82, 83, 84, 85,
- 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
- -1, -1, -1, 99, 100, -1, -1, 103, 104, 105,
- 106, -1, 108, 109, -1, -1, -1, -1, -1, -1,
- 116, 117, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, 143, -1, -1,
- -1, 147, 148, -1, 15, 16, 17, 18, -1, 20,
- -1, 157, 23, 24, -1, 26, -1, 28, 29, 30,
- 31, -1, -1, -1, -1, -1, -1, 57, -1, 40,
- 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
- 51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
- 61, 62, 63, 64, 65, 66, 67, 68, 69, 70,
- 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
- 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
- 110, 111, 112, 113, 114, 115, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, 125, 126, 127, -1, -1,
- -1, -1, -1, -1, -1, 135, -1, 137, 138, 139,
- 140, 141, 142, 143, 144, 145, 146, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, 158, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, 16, 17,
- -1, -1, -1, -1, 155, 23, 24, 25, 26, 27,
- 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
- 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
- 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
- 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,
- 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
- 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
- 88, 89, 90, 91, 92, 93, 94, 95, -1, -1,
- -1, 99, 100, -1, -1, -1, -1, -1, -1, -1,
- -1, 109, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, 15, 16, 17, -1, -1, 155, 21, 22,
- 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
- 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
- 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
- 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,
- 63, 64, 65, 66, 67, 68, 69, 70, 71, 72,
- 73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
- 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
- 93, 94, 95, 96, 97, 98, 99, 100, 101, 102,
- -1, -1, -1, -1, -1, -1, 109, -1, -1, 15,
- 16, 17, -1, 116, 117, 21, 22, 23, 24, 25,
- 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
- 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
- 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
- 56, 57, 58, 59, 60, 61, 62, 63, 64, 65,
- 66, 67, 68, 69, 70, 71, 72, 73, 74, 75,
- 76, 77, 78, 79, 80, 81, 82, 83, 84, 85,
- 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
- 96, 97, 98, 99, 100, 101, 102, 57, -1, -1,
- -1, -1, -1, 109, -1, -1, -1, -1, -1, -1,
- 116, 117, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, 57, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- 110, 111, 112, 113, 114, 115, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, 125, 126, 127, -1, -1,
- -1, 57, -1, -1, -1, 135, -1, 137, 138, 139,
- 140, 141, 142, 143, 144, 145, 146, 110, 111, 112,
- 113, 114, 115, -1, -1, -1, -1, -1, 158, -1,
- -1, -1, 125, 126, 127, -1, -1, -1, 57, -1,
- -1, -1, 135, -1, 137, 138, 139, 140, 141, 142,
- 143, 144, 145, 146, 110, 111, 112, 113, 114, 115,
- -1, -1, -1, -1, -1, 158, -1, -1, -1, 125,
- 126, 127, -1, -1, -1, 57, -1, -1, -1, 135,
- -1, 137, 138, 139, 140, 141, 142, 143, 144, 145,
- 146, 110, 111, 112, 113, 114, 115, -1, -1, -1,
- -1, -1, 158, -1, -1, -1, 125, 126, 127, -1,
- -1, -1, 57, -1, -1, -1, 135, -1, 137, 138,
- 139, 140, 141, 142, 143, 144, 145, 146, 110, 111,
- 112, 113, 114, 115, -1, -1, -1, -1, -1, 158,
- -1, -1, -1, 125, 126, 127, -1, -1, -1, 57,
- -1, -1, -1, 135, -1, 137, 138, 139, 140, 141,
- 142, 143, 144, 145, 146, 110, 111, 112, 113, 114,
- 115, -1, -1, -1, -1, -1, 158, -1, -1, -1,
- 125, 126, 127, -1, -1, -1, 57, -1, -1, -1,
- 135, -1, 137, 138, 139, 140, 141, 142, 143, 144,
- 145, 146, 110, 111, 112, 113, 114, 115, -1, -1,
- -1, -1, -1, 158, -1, -1, -1, 125, 126, 127,
- -1, -1, -1, 57, -1, -1, -1, 135, -1, 137,
- 138, 139, 140, 141, 142, 143, 144, 145, 146, 110,
- 111, 112, 113, 114, 115, -1, -1, -1, -1, -1,
- 158, -1, -1, -1, 125, 126, 127, -1, -1, -1,
- 57, -1, -1, -1, 135, -1, 137, 138, 139, 140,
- 141, 142, 143, 144, 145, 146, 110, 111, 112, 113,
- 114, 115, -1, -1, -1, -1, -1, 158, -1, -1,
- -1, 125, 126, 127, -1, -1, -1, 57, -1, -1,
- -1, 135, -1, 137, 138, 139, 140, 141, 142, 143,
- 144, 145, 146, 110, 111, 112, 113, 114, 115, -1,
- -1, -1, -1, -1, 158, -1, -1, -1, 125, 126,
- 127, -1, -1, -1, 57, -1, -1, -1, 135, -1,
- 137, 138, 139, 140, 141, 142, 143, 144, 145, 146,
- 110, 111, 112, 113, 114, 115, -1, -1, -1, -1,
- -1, 158, -1, -1, -1, 125, 126, 127, -1, -1,
- -1, 57, -1, -1, -1, 135, -1, 137, 138, 139,
- 140, 141, 142, 143, 144, 145, 146, 110, 111, 112,
- 113, 114, 115, -1, -1, -1, -1, -1, 158, -1,
- -1, -1, 125, 126, 127, -1, -1, -1, 57, -1,
- -1, -1, 135, -1, 137, 138, 139, 140, 141, 142,
- 143, 144, 145, 146, 110, 111, 112, 113, 114, 115,
- -1, -1, -1, -1, -1, 158, -1, -1, -1, 125,
- 126, 127, -1, -1, -1, 57, -1, -1, -1, 135,
- -1, 137, 138, 139, 140, 141, 142, 143, 144, 145,
- 146, 110, 111, 112, 113, 114, 115, -1, -1, -1,
- -1, -1, 158, -1, -1, -1, 125, 126, 127, -1,
- -1, -1, 57, -1, -1, -1, 135, -1, 137, 138,
- 139, 140, 141, 142, 143, 144, 145, 146, 110, 111,
- 112, 113, 114, 115, 153, -1, -1, -1, -1, -1,
- -1, -1, -1, 125, 126, 127, -1, -1, -1, 57,
- -1, -1, -1, 135, -1, 137, 138, 139, 140, 141,
- 142, 143, 144, 145, 146, 110, 111, 112, 113, 114,
- 115, 153, -1, -1, -1, -1, -1, -1, -1, -1,
- 125, 126, 127, -1, -1, -1, -1, -1, -1, -1,
- 135, -1, 137, 138, 139, 140, 141, 142, 143, 144,
- 145, 146, 110, 111, 112, 113, 114, 115, 153, -1,
- -1, -1, -1, -1, -1, -1, -1, 125, 126, 127,
- -1, -1, -1, -1, -1, -1, -1, 135, -1, 137,
- 138, 139, 140, 141, 142, 143, 144, 145, 146, 16,
- 17, -1, -1, 151, 152, 22, 23, 24, 25, 26,
- 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
- 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
- 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
- 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
- 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
- 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
- 87, 88, 89, 90, 91, 92, 93, 94, 95, -1,
- -1, -1, 99, 100, -1, -1, -1, 16, 17, -1,
- -1, -1, 109, 22, 23, 24, 25, 26, 27, 28,
- 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
- 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
- 49, 50, 51, 52, 53, 54, 55, 56, 57, 58,
- 59, 60, 61, 62, 63, 64, 65, 66, 67, 68,
- 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
- 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
- 89, 90, 91, 92, 93, 94, 95, -1, -1, -1,
- 99, 100, -1, -1, 16, 17, -1, -1, -1, -1,
- 109, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
- 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
- 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
- 62, 63, 64, 65, 66, 67, 68, 69, 70, 71,
- 72, 73, 74, 75, 76, 77, 78, 79, 80, 81,
- 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
- 92, 93, 94, 95, -1, -1, -1, 99, 100, -1,
- -1, 16, 17, -1, -1, -1, -1, 109, 23, 24,
- 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
- 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
- 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
- 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
- 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
- 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
- 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
- 95, 57, -1, -1, 99, 100, -1, -1, -1, -1,
- -1, -1, -1, -1, 109, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, 57, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, 110, 111, 112, 113, 114, 115,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, 125,
- 126, 127, -1, -1, -1, 57, 132, -1, -1, 135,
- -1, 137, 138, 139, 140, 141, 142, 143, 144, 145,
- 146, 110, 111, 112, 113, 114, 115, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, 125, 126, 127, -1,
- -1, -1, 57, 132, -1, -1, 135, -1, 137, 138,
- 139, 140, 141, 142, 143, 144, 145, 146, 110, 111,
- 112, 113, 114, 115, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, 125, 126, 127, -1, -1, -1, 57,
- 132, -1, -1, 135, -1, 137, 138, 139, 140, 141,
- 142, 143, 144, 145, 146, 110, 111, 112, 113, 114,
- 115, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- 125, 126, 127, -1, -1, -1, 57, 132, -1, -1,
- 135, -1, 137, 138, 139, 140, 141, 142, 143, 144,
- 145, 146, 110, 111, 112, 113, 114, 115, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, 125, 126, 127,
- -1, -1, -1, 57, 132, -1, -1, 135, -1, 137,
- 138, 139, 140, 141, 142, 143, 144, 145, 146, 110,
- 111, 112, 113, 114, 115, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, 125, 126, 127, -1, -1, -1,
- 57, 132, -1, -1, 135, -1, 137, 138, 139, 140,
- 141, 142, 143, 144, 145, 146, 110, 111, 112, 113,
- 114, 115, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, 125, 126, 127, -1, -1, -1, 57, 132, -1,
- -1, 135, -1, 137, 138, 139, 140, 141, 142, 143,
- 144, 145, 146, 110, 111, 112, 113, 114, 115, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, 125, 126,
- 127, -1, -1, -1, 57, 132, -1, -1, 135, -1,
- 137, 138, 139, 140, 141, 142, 143, 144, 145, 146,
- 110, 111, 112, 113, 114, 115, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, 125, 126, 127, -1, -1,
- -1, 57, -1, -1, -1, 135, 136, 137, 138, 139,
- 140, 141, 142, 143, 144, 145, 146, 110, 111, 112,
- 113, 114, 115, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, 125, 126, 127, -1, -1, -1, 57, 132,
- -1, -1, 135, -1, 137, 138, 139, 140, 141, 142,
- 143, 144, 145, 146, 110, 111, 112, 113, 114, 115,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, 125,
- 126, 127, -1, -1, -1, 57, 132, -1, -1, 135,
- -1, 137, 138, 139, 140, 141, 142, 143, 144, 145,
- 146, 110, 111, 112, 113, 114, 115, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, 125, 126, 127, -1,
- -1, -1, 57, 132, -1, -1, 135, -1, 137, 138,
- 139, 140, 141, 142, 143, 144, 145, 146, 110, 111,
- 112, 113, 114, 115, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, 125, 126, 127, -1, -1, -1, 57,
- 132, -1, -1, 135, -1, 137, 138, 139, 140, 141,
- 142, 143, 144, 145, 146, 110, 111, 112, 113, 114,
- 115, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- 125, 126, 127, -1, -1, -1, 57, -1, -1, -1,
- 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
- 145, 146, 110, 111, 112, 113, 114, 115, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, 125, 126, 127,
- -1, -1, -1, 57, 132, -1, -1, 135, -1, 137,
- 138, 139, 140, 141, 142, 143, 144, 145, 146, 110,
- 111, 112, 113, 114, 115, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, 125, 126, 127, -1, -1, -1,
- 57, 132, -1, -1, 135, -1, 137, 138, 139, 140,
- 141, 142, 143, 144, 145, 146, 110, 111, 112, 113,
- 114, 115, 57, -1, -1, -1, -1, -1, -1, -1,
- -1, 125, 126, 127, -1, -1, -1, -1, -1, -1,
- -1, 135, -1, 137, 138, 139, 140, 141, 142, 143,
- 144, 145, 146, 110, 111, 112, 113, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, 125, 126,
- 127, -1, -1, -1, -1, -1, 111, 112, -1, -1,
- 137, 138, 139, 140, 141, 142, 143, 144, 145, 146,
- 125, 126, 127, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, 137, 138, 139, 140, 141, 142, 143, 144,
- 145, 146, 15, 16, 17, 18, 19, 20, -1, -1,
- 23, 24, -1, 26, -1, 28, 29, 30, 31, -1,
- -1, -1, -1, -1, -1, -1, -1, 40, 41, 42,
- 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
- 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,
- 63, 64, 65, 66, 67, 68, 69, 70, 71, 72,
- 73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
- 83, 84, 85, 86, 87, 88, 89, 90, 15, 16,
- 17, 18, -1, 20, -1, -1, 23, 24, -1, 26,
- -1, 28, 29, 30, 31, -1, -1, -1, -1, -1,
- -1, -1, -1, 40, 41, 42, 43, 44, 45, 46,
- 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
- 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
- 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
- 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
- 87, 88, 89, 90
-};
-
-/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
- symbol of state STATE-NUM. */
-static const yytype_uint8 yystos[] =
-{
- 0, 160, 161, 0, 3, 4, 5, 7, 10, 12,
- 13, 14, 15, 16, 17, 18, 20, 21, 22, 23,
- 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
- 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
- 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
- 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
- 64, 65, 66, 67, 68, 69, 70, 71, 72, 73,
- 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
- 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
- 94, 95, 96, 97, 98, 99, 100, 101, 102, 109,
- 116, 117, 154, 156, 162, 163, 165, 166, 167, 168,
- 170, 172, 173, 176, 178, 179, 181, 182, 185, 187,
- 188, 191, 192, 195, 199, 200, 201, 207, 156, 156,
- 157, 157, 17, 23, 24, 25, 26, 28, 29, 30,
- 31, 32, 33, 34, 35, 36, 37, 38, 39, 56,
- 78, 82, 83, 94, 95, 99, 100, 109, 176, 205,
- 206, 109, 192, 195, 200, 201, 16, 103, 104, 105,
- 106, 108, 109, 143, 147, 148, 152, 154, 156, 157,
- 165, 178, 192, 194, 195, 199, 200, 201, 202, 203,
- 204, 157, 154, 157, 157, 157, 157, 157, 157, 157,
- 157, 157, 157, 157, 157, 157, 157, 157, 157, 157,
- 157, 157, 157, 157, 157, 157, 157, 157, 157, 157,
- 157, 157, 157, 157, 155, 164, 166, 163, 157, 176,
- 157, 166, 201, 151, 152, 118, 119, 120, 121, 122,
- 123, 124, 128, 129, 130, 133, 134, 198, 199, 156,
- 15, 169, 176, 186, 207, 202, 133, 132, 157, 151,
- 152, 176, 104, 105, 202, 202, 202, 193, 203, 176,
- 196, 197, 202, 157, 201, 133, 199, 57, 110, 111,
- 112, 113, 114, 115, 125, 126, 127, 135, 137, 138,
- 139, 140, 141, 142, 143, 144, 145, 146, 156, 202,
- 208, 202, 202, 158, 203, 202, 203, 202, 202, 202,
- 202, 108, 158, 158, 158, 158, 158, 158, 203, 202,
- 202, 202, 202, 202, 202, 202, 202, 202, 158, 104,
- 108, 202, 108, 202, 193, 155, 166, 202, 157, 202,
- 13, 176, 202, 203, 202, 176, 132, 11, 156, 158,
- 203, 206, 193, 109, 202, 157, 132, 153, 136, 132,
- 155, 158, 176, 177, 203, 200, 202, 202, 202, 202,
- 202, 202, 202, 202, 202, 202, 202, 202, 202, 202,
- 202, 202, 202, 202, 202, 202, 158, 15, 16, 17,
- 18, 20, 23, 24, 26, 28, 29, 30, 31, 40,
- 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
- 51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
- 61, 62, 63, 64, 65, 66, 67, 68, 69, 70,
- 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
- 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
- 209, 210, 214, 158, 158, 158, 132, 158, 158, 158,
- 158, 132, 132, 158, 132, 132, 158, 132, 132, 132,
- 132, 158, 132, 158, 158, 158, 158, 158, 158, 158,
- 177, 158, 157, 157, 153, 11, 207, 176, 180, 192,
- 195, 202, 171, 202, 166, 158, 153, 193, 203, 203,
- 196, 132, 158, 136, 154, 211, 215, 107, 108, 108,
- 155, 214, 202, 202, 108, 202, 202, 202, 202, 104,
- 190, 202, 190, 202, 154, 158, 166, 202, 193, 157,
- 180, 158, 151, 152, 156, 6, 158, 176, 166, 202,
- 164, 209, 103, 104, 105, 106, 107, 108, 212, 213,
- 158, 132, 189, 158, 132, 132, 189, 189, 189, 189,
- 132, 158, 174, 166, 158, 158, 193, 158, 184, 176,
- 202, 186, 166, 155, 19, 132, 92, 93, 108, 158,
- 202, 202, 158, 158, 158, 158, 202, 8, 9, 155,
- 175, 158, 184, 166, 153, 158, 212, 158, 158, 132,
- 202, 136, 166, 183, 202, 136, 164, 166, 132, 164,
- 202, 3, 132, 156, 202, 158
-};
-
-#define yyerrok (yyerrstatus = 0)
-#define yyclearin (yychar = YYEMPTY)
-#define YYEMPTY (-2)
-#define YYEOF 0
-
-#define YYACCEPT goto yyacceptlab
-#define YYABORT goto yyabortlab
-#define YYERROR goto yyerrorlab
-
-
-/* Like YYERROR except do call yyerror. This remains here temporarily
- to ease the transition to the new meaning of YYERROR, for GCC.
- Once GCC version 2 has supplanted version 1, this can go. */
-
-#define YYFAIL goto yyerrlab
-
-#define YYRECOVERING() (!!yyerrstatus)
-
-#define YYBACKUP(Token, Value) \
-do \
- if (yychar == YYEMPTY && yylen == 1) \
- { \
- yychar = (Token); \
- yylval = (Value); \
- yytoken = YYTRANSLATE (yychar); \
- YYPOPSTACK (1); \
- goto yybackup; \
- } \
- else \
- { \
- yyerror (YY_("syntax error: cannot back up")); \
- YYERROR; \
- } \
-while (YYID (0))
-
-
-#define YYTERROR 1
-#define YYERRCODE 256
-
-
-/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
- If N is 0, then set CURRENT to the empty location which ends
- the previous symbol: RHS[0] (always defined). */
-
-#define YYRHSLOC(Rhs, K) ((Rhs)[K])
-#ifndef YYLLOC_DEFAULT
-# define YYLLOC_DEFAULT(Current, Rhs, N) \
- do \
- if (YYID (N)) \
- { \
- (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
- (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
- (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
- (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
- } \
- else \
- { \
- (Current).first_line = (Current).last_line = \
- YYRHSLOC (Rhs, 0).last_line; \
- (Current).first_column = (Current).last_column = \
- YYRHSLOC (Rhs, 0).last_column; \
- } \
- while (YYID (0))
-#endif
-
-
-/* YY_LOCATION_PRINT -- Print the location on the stream.
- This macro was not mandated originally: define only if we know
- we won't break user code: when these are the locations we know. */
-
-#ifndef YY_LOCATION_PRINT
-# if YYLTYPE_IS_TRIVIAL
-# define YY_LOCATION_PRINT(File, Loc) \
- fprintf (File, "%d.%d-%d.%d", \
- (Loc).first_line, (Loc).first_column, \
- (Loc).last_line, (Loc).last_column)
-# else
-# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
-# endif
-#endif
-
-
-/* YYLEX -- calling `yylex' with the right arguments. */
-
-#ifdef YYLEX_PARAM
-# define YYLEX yylex (YYLEX_PARAM)
-#else
-# define YYLEX yylex ()
-#endif
-
-/* Enable debugging if requested. */
-#if YYDEBUG
-
-# ifndef YYFPRINTF
-# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
-# define YYFPRINTF fprintf
-# endif
-
-# define YYDPRINTF(Args) \
-do { \
- if (yydebug) \
- YYFPRINTF Args; \
-} while (YYID (0))
-
-# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
-do { \
- if (yydebug) \
- { \
- YYFPRINTF (stderr, "%s ", Title); \
- yy_symbol_print (stderr, \
- Type, Value); \
- YYFPRINTF (stderr, "\n"); \
- } \
-} while (YYID (0))
-
-
-/*--------------------------------.
-| Print this symbol on YYOUTPUT. |
-`--------------------------------*/
-
-/*ARGSUSED*/
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-static void
-yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
-#else
-static void
-yy_symbol_value_print (yyoutput, yytype, yyvaluep)
- FILE *yyoutput;
- int yytype;
- YYSTYPE const * const yyvaluep;
-#endif
-{
- if (!yyvaluep)
- return;
-# ifdef YYPRINT
- if (yytype < YYNTOKENS)
- YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
-# else
- YYUSE (yyoutput);
-# endif
- switch (yytype)
- {
- default:
- break;
- }
-}
-
-
-/*--------------------------------.
-| Print this symbol on YYOUTPUT. |
-`--------------------------------*/
-
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-static void
-yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
-#else
-static void
-yy_symbol_print (yyoutput, yytype, yyvaluep)
- FILE *yyoutput;
- int yytype;
- YYSTYPE const * const yyvaluep;
-#endif
-{
- if (yytype < YYNTOKENS)
- YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
- else
- YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
-
- yy_symbol_value_print (yyoutput, yytype, yyvaluep);
- YYFPRINTF (yyoutput, ")");
-}
-
-/*------------------------------------------------------------------.
-| yy_stack_print -- Print the state stack from its BOTTOM up to its |
-| TOP (included). |
-`------------------------------------------------------------------*/
-
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-static void
-yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
-#else
-static void
-yy_stack_print (bottom, top)
- yytype_int16 *bottom;
- yytype_int16 *top;
-#endif
-{
- YYFPRINTF (stderr, "Stack now");
- for (; bottom <= top; ++bottom)
- YYFPRINTF (stderr, " %d", *bottom);
- YYFPRINTF (stderr, "\n");
-}
-
-# define YY_STACK_PRINT(Bottom, Top) \
-do { \
- if (yydebug) \
- yy_stack_print ((Bottom), (Top)); \
-} while (YYID (0))
-
-
-/*------------------------------------------------.
-| Report that the YYRULE is going to be reduced. |
-`------------------------------------------------*/
-
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-static void
-yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
-#else
-static void
-yy_reduce_print (yyvsp, yyrule)
- YYSTYPE *yyvsp;
- int yyrule;
-#endif
-{
- int yynrhs = yyr2[yyrule];
- int yyi;
- unsigned long int yylno = yyrline[yyrule];
- YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
- yyrule - 1, yylno);
- /* The symbols being reduced. */
- for (yyi = 0; yyi < yynrhs; yyi++)
- {
- fprintf (stderr, " $%d = ", yyi + 1);
- yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
- &(yyvsp[(yyi + 1) - (yynrhs)])
- );
- fprintf (stderr, "\n");
- }
-}
-
-# define YY_REDUCE_PRINT(Rule) \
-do { \
- if (yydebug) \
- yy_reduce_print (yyvsp, Rule); \
-} while (YYID (0))
-
-/* Nonzero means print parse trace. It is left uninitialized so that
- multiple parsers can coexist. */
-int yydebug;
-#else /* !YYDEBUG */
-# define YYDPRINTF(Args)
-# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
-# define YY_STACK_PRINT(Bottom, Top)
-# define YY_REDUCE_PRINT(Rule)
-#endif /* !YYDEBUG */
-
-
-/* YYINITDEPTH -- initial size of the parser's stacks. */
-#ifndef YYINITDEPTH
-# define YYINITDEPTH 200
-#endif
-
-/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
- if the built-in stack extension method is used).
-
- Do not make this value too large; the results are undefined if
- YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
- evaluated with infinite-precision integer arithmetic. */
-
-#ifndef YYMAXDEPTH
-# define YYMAXDEPTH 10000
-#endif
-
-\f
-
-#if YYERROR_VERBOSE
-
-# ifndef yystrlen
-# if defined __GLIBC__ && defined _STRING_H
-# define yystrlen strlen
-# else
-/* Return the length of YYSTR. */
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-static YYSIZE_T
-yystrlen (const char *yystr)
-#else
-static YYSIZE_T
-yystrlen (yystr)
- const char *yystr;
-#endif
-{
- YYSIZE_T yylen;
- for (yylen = 0; yystr[yylen]; yylen++)
- continue;
- return yylen;
-}
-# endif
-# endif
-
-# ifndef yystpcpy
-# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
-# define yystpcpy stpcpy
-# else
-/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
- YYDEST. */
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-static char *
-yystpcpy (char *yydest, const char *yysrc)
-#else
-static char *
-yystpcpy (yydest, yysrc)
- char *yydest;
- const char *yysrc;
-#endif
-{
- char *yyd = yydest;
- const char *yys = yysrc;
-
- while ((*yyd++ = *yys++) != '\0')
- continue;
-
- return yyd - 1;
-}
-# endif
-# endif
-
-# ifndef yytnamerr
-/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
- quotes and backslashes, so that it's suitable for yyerror. The
- heuristic is that double-quoting is unnecessary unless the string
- contains an apostrophe, a comma, or backslash (other than
- backslash-backslash). YYSTR is taken from yytname. If YYRES is
- null, do not copy; instead, return the length of what the result
- would have been. */
-static YYSIZE_T
-yytnamerr (char *yyres, const char *yystr)
-{
- if (*yystr == '"')
- {
- YYSIZE_T yyn = 0;
- char const *yyp = yystr;
-
- for (;;)
- switch (*++yyp)
- {
- case '\'':
- case ',':
- goto do_not_strip_quotes;
-
- case '\\':
- if (*++yyp != '\\')
- goto do_not_strip_quotes;
- /* Fall through. */
- default:
- if (yyres)
- yyres[yyn] = *yyp;
- yyn++;
- break;
-
- case '"':
- if (yyres)
- yyres[yyn] = '\0';
- return yyn;
- }
- do_not_strip_quotes: ;
- }
-
- if (! yyres)
- return yystrlen (yystr);
-
- return yystpcpy (yyres, yystr) - yyres;
-}
-# endif
-
-/* Copy into YYRESULT an error message about the unexpected token
- YYCHAR while in state YYSTATE. Return the number of bytes copied,
- including the terminating null byte. If YYRESULT is null, do not
- copy anything; just return the number of bytes that would be
- copied. As a special case, return 0 if an ordinary "syntax error"
- message will do. Return YYSIZE_MAXIMUM if overflow occurs during
- size calculation. */
-static YYSIZE_T
-yysyntax_error (char *yyresult, int yystate, int yychar)
-{
- int yyn = yypact[yystate];
-
- if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
- return 0;
- else
- {
- int yytype = YYTRANSLATE (yychar);
- YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
- YYSIZE_T yysize = yysize0;
- YYSIZE_T yysize1;
- int yysize_overflow = 0;
- enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
- char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
- int yyx;
-
-# if 0
- /* This is so xgettext sees the translatable formats that are
- constructed on the fly. */
- YY_("syntax error, unexpected %s");
- YY_("syntax error, unexpected %s, expecting %s");
- YY_("syntax error, unexpected %s, expecting %s or %s");
- YY_("syntax error, unexpected %s, expecting %s or %s or %s");
- YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
-# endif
- char *yyfmt;
- char const *yyf;
- static char const yyunexpected[] = "syntax error, unexpected %s";
- static char const yyexpecting[] = ", expecting %s";
- static char const yyor[] = " or %s";
- char yyformat[sizeof yyunexpected
- + sizeof yyexpecting - 1
- + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
- * (sizeof yyor - 1))];
- char const *yyprefix = yyexpecting;
-
- /* Start YYX at -YYN if negative to avoid negative indexes in
- YYCHECK. */
- int yyxbegin = yyn < 0 ? -yyn : 0;
-
- /* Stay within bounds of both yycheck and yytname. */
- int yychecklim = YYLAST - yyn + 1;
- int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
- int yycount = 1;
-
- yyarg[0] = yytname[yytype];
- yyfmt = yystpcpy (yyformat, yyunexpected);
-
- for (yyx = yyxbegin; yyx < yyxend; ++yyx)
- if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
- {
- if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
- {
- yycount = 1;
- yysize = yysize0;
- yyformat[sizeof yyunexpected - 1] = '\0';
- break;
- }
- yyarg[yycount++] = yytname[yyx];
- yysize1 = yysize + yytnamerr (0, yytname[yyx]);
- yysize_overflow |= (yysize1 < yysize);
- yysize = yysize1;
- yyfmt = yystpcpy (yyfmt, yyprefix);
- yyprefix = yyor;
- }
-
- yyf = YY_(yyformat);
- yysize1 = yysize + yystrlen (yyf);
- yysize_overflow |= (yysize1 < yysize);
- yysize = yysize1;
-
- if (yysize_overflow)
- return YYSIZE_MAXIMUM;
-
- if (yyresult)
- {
- /* Avoid sprintf, as that infringes on the user's name space.
- Don't have undefined behavior even if the translation
- produced a string with the wrong number of "%s"s. */
- char *yyp = yyresult;
- int yyi = 0;
- while ((*yyp = *yyf) != '\0')
- {
- if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
- {
- yyp += yytnamerr (yyp, yyarg[yyi++]);
- yyf += 2;
- }
- else
- {
- yyp++;
- yyf++;
- }
- }
- }
- return yysize;
- }
-}
-#endif /* YYERROR_VERBOSE */
-\f
-
-/*-----------------------------------------------.
-| Release the memory associated to this symbol. |
-`-----------------------------------------------*/
-
-/*ARGSUSED*/
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-static void
-yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
-#else
-static void
-yydestruct (yymsg, yytype, yyvaluep)
- const char *yymsg;
- int yytype;
- YYSTYPE *yyvaluep;
-#endif
-{
- YYUSE (yyvaluep);
-
- if (!yymsg)
- yymsg = "Deleting";
- YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
-
- switch (yytype)
- {
-
- default:
- break;
- }
-}
-\f
-
-/* Prevent warnings from -Wmissing-prototypes. */
-
-#ifdef YYPARSE_PARAM
-#if defined __STDC__ || defined __cplusplus
-int yyparse (void *YYPARSE_PARAM);
-#else
-int yyparse ();
-#endif
-#else /* ! YYPARSE_PARAM */
-#if defined __STDC__ || defined __cplusplus
-int yyparse (void);
-#else
-int yyparse ();
-#endif
-#endif /* ! YYPARSE_PARAM */
-
-
-
-/* The look-ahead symbol. */
-int yychar;
-
-/* The semantic value of the look-ahead symbol. */
-YYSTYPE yylval;
-
-/* Number of syntax errors so far. */
-int yynerrs;
-
-
-
-/*----------.
-| yyparse. |
-`----------*/
-
-#ifdef YYPARSE_PARAM
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-int
-yyparse (void *YYPARSE_PARAM)
-#else
-int
-yyparse (YYPARSE_PARAM)
- void *YYPARSE_PARAM;
-#endif
-#else /* ! YYPARSE_PARAM */
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-int
-yyparse (void)
-#else
-int
-yyparse ()
-
-#endif
-#endif
-{
-
- int yystate;
- int yyn;
- int yyresult;
- /* Number of tokens to shift before error messages enabled. */
- int yyerrstatus;
- /* Look-ahead token as an internal (translated) token number. */
- int yytoken = 0;
-#if YYERROR_VERBOSE
- /* Buffer for error messages, and its allocated size. */
- char yymsgbuf[128];
- char *yymsg = yymsgbuf;
- YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
-#endif
-
- /* Three stacks and their tools:
- `yyss': related to states,
- `yyvs': related to semantic values,
- `yyls': related to locations.
-
- Refer to the stacks thru separate pointers, to allow yyoverflow
- to reallocate them elsewhere. */
-
- /* The state stack. */
- yytype_int16 yyssa[YYINITDEPTH];
- yytype_int16 *yyss = yyssa;
- yytype_int16 *yyssp;
-
- /* The semantic value stack. */
- YYSTYPE yyvsa[YYINITDEPTH];
- YYSTYPE *yyvs = yyvsa;
- YYSTYPE *yyvsp;
-
-
-
-#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
-
- YYSIZE_T yystacksize = YYINITDEPTH;
-
- /* The variables used to return semantic value and location from the
- action routines. */
- YYSTYPE yyval;
-
-
- /* The number of symbols on the RHS of the reduced rule.
- Keep to zero when no symbol should be popped. */
- int yylen = 0;
-
- YYDPRINTF ((stderr, "Starting parse\n"));
-
- yystate = 0;
- yyerrstatus = 0;
- yynerrs = 0;
- yychar = YYEMPTY; /* Cause a token to be read. */
-
- /* Initialize stack pointers.
- Waste one element of value and location stack
- so that they stay on the same level as the state stack.
- The wasted elements are never initialized. */
-
- yyssp = yyss;
- yyvsp = yyvs;
-
- goto yysetstate;
-
-/*------------------------------------------------------------.
-| yynewstate -- Push a new state, which is found in yystate. |
-`------------------------------------------------------------*/
- yynewstate:
- /* In all cases, when you get here, the value and location stacks
- have just been pushed. So pushing a state here evens the stacks. */
- yyssp++;
-
- yysetstate:
- *yyssp = yystate;
-
- if (yyss + yystacksize - 1 <= yyssp)
- {
- /* Get the current used size of the three stacks, in elements. */
- YYSIZE_T yysize = yyssp - yyss + 1;
-
-#ifdef yyoverflow
- {
- /* Give user a chance to reallocate the stack. Use copies of
- these so that the &'s don't force the real ones into
- memory. */
- YYSTYPE *yyvs1 = yyvs;
- yytype_int16 *yyss1 = yyss;
-
-
- /* Each stack pointer address is followed by the size of the
- data in use in that stack, in bytes. This used to be a
- conditional around just the two extra args, but that might
- be undefined if yyoverflow is a macro. */
- yyoverflow (YY_("memory exhausted"),
- &yyss1, yysize * sizeof (*yyssp),
- &yyvs1, yysize * sizeof (*yyvsp),
-
- &yystacksize);
-
- yyss = yyss1;
- yyvs = yyvs1;
- }
-#else /* no yyoverflow */
-# ifndef YYSTACK_RELOCATE
- goto yyexhaustedlab;
-# else
- /* Extend the stack our own way. */
- if (YYMAXDEPTH <= yystacksize)
- goto yyexhaustedlab;
- yystacksize *= 2;
- if (YYMAXDEPTH < yystacksize)
- yystacksize = YYMAXDEPTH;
-
- {
- yytype_int16 *yyss1 = yyss;
- union yyalloc *yyptr =
- (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
- if (! yyptr)
- goto yyexhaustedlab;
- YYSTACK_RELOCATE (yyss);
- YYSTACK_RELOCATE (yyvs);
-
-# undef YYSTACK_RELOCATE
- if (yyss1 != yyssa)
- YYSTACK_FREE (yyss1);
- }
-# endif
-#endif /* no yyoverflow */
-
- yyssp = yyss + yysize - 1;
- yyvsp = yyvs + yysize - 1;
-
-
- YYDPRINTF ((stderr, "Stack size increased to %lu\n",
- (unsigned long int) yystacksize));
-
- if (yyss + yystacksize - 1 <= yyssp)
- YYABORT;
- }
-
- YYDPRINTF ((stderr, "Entering state %d\n", yystate));
-
- goto yybackup;
-
-/*-----------.
-| yybackup. |
-`-----------*/
-yybackup:
-
- /* Do appropriate processing given the current state. Read a
- look-ahead token if we need one and don't already have one. */
-
- /* First try to decide what to do without reference to look-ahead token. */
- yyn = yypact[yystate];
- if (yyn == YYPACT_NINF)
- goto yydefault;
-
- /* Not known => get a look-ahead token if don't already have one. */
-
- /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
- if (yychar == YYEMPTY)
- {
- YYDPRINTF ((stderr, "Reading a token: "));
- yychar = YYLEX;
- }
-
- if (yychar <= YYEOF)
- {
- yychar = yytoken = YYEOF;
- YYDPRINTF ((stderr, "Now at end of input.\n"));
- }
- else
- {
- yytoken = YYTRANSLATE (yychar);
- YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
- }
-
- /* If the proper action on seeing token YYTOKEN is to reduce or to
- detect an error, take that action. */
- yyn += yytoken;
- if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
- goto yydefault;
- yyn = yytable[yyn];
- if (yyn <= 0)
- {
- if (yyn == 0 || yyn == YYTABLE_NINF)
- goto yyerrlab;
- yyn = -yyn;
- goto yyreduce;
- }
-
- if (yyn == YYFINAL)
- YYACCEPT;
-
- /* Count tokens shifted since error; after three, turn off error
- status. */
- if (yyerrstatus)
- yyerrstatus--;
-
- /* Shift the look-ahead token. */
- YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
-
- /* Discard the shifted token unless it is eof. */
- if (yychar != YYEOF)
- yychar = YYEMPTY;
-
- yystate = yyn;
- *++yyvsp = yylval;
-
- goto yynewstate;
-
-
-/*-----------------------------------------------------------.
-| yydefault -- do the default action for the current state. |
-`-----------------------------------------------------------*/
-yydefault:
- yyn = yydefact[yystate];
- if (yyn == 0)
- goto yyerrlab;
- goto yyreduce;
-
-
-/*-----------------------------.
-| yyreduce -- Do a reduction. |
-`-----------------------------*/
-yyreduce:
- /* yyn is the number of a rule to reduce with. */
- yylen = yyr2[yyn];
-
- /* If YYLEN is nonzero, implement the default value of the action:
- `$$ = $1'.
-
- Otherwise, the following line sets YYVAL to garbage.
- This behavior is undocumented and Bison
- users should not rely upon it. Assigning to YYVAL
- unconditionally makes the parser a bit smaller, and it avoids a
- GCC warning that YYVAL may be used uninitialized. */
- yyval = yyvsp[1-yylen];
-
-
- YY_REDUCE_PRINT (yyn);
- switch (yyn)
- {
- case 2:
-#line 152 "swf5compiler.y"
- { bf = newBuffer();
- bc = newBuffer();
- ;}
- break;
-
- case 3:
-#line 155 "swf5compiler.y"
- { Buffer b = newBuffer();
- bufferWriteConstants(b);
- bufferConcat(b, bf);
- bufferConcat(b, bc);
- *((Buffer *)buffer) = b; ;}
- break;
-
- case 4:
-#line 160 "swf5compiler.y"
- { Buffer b = newBuffer(); *((Buffer *)buffer) = b; ;}
- break;
-
- case 7:
-#line 170 "swf5compiler.y"
- { bufferConcat(bc, (yyvsp[(1) - (1)].action)); ;}
- break;
-
- case 8:
-#line 172 "swf5compiler.y"
- { bufferConcat(bf, (yyvsp[(1) - (1)].action)); ;}
- break;
-
- case 9:
-#line 177 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(1) - (1)].action); ;}
- break;
-
- case 10:
-#line 180 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(1) - (2)].action);
- bufferConcat((yyval.action), (yyvsp[(2) - (2)].action)); ;}
- break;
-
- case 11:
-#line 185 "swf5compiler.y"
- { ;}
- break;
-
- case 12:
-#line 189 "swf5compiler.y"
- { (yyval.action) = NULL; ;}
- break;
-
- case 13:
-#line 190 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(2) - (3)].action); ;}
- break;
-
- case 14:
-#line 191 "swf5compiler.y"
- { (yyval.action) = NULL; ;}
- break;
-
- case 15:
-#line 192 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(1) - (2)].action); ;}
- break;
-
- case 23:
-#line 204 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(3) - (7)].action);
- bufferWriteOp((yyval.action), SWFACTION_WITH);
- bufferWriteS16((yyval.action), 2);
- bufferWriteS16((yyval.action), bufferLength((yyvsp[(6) - (7)].action)));
- bufferConcat((yyval.action), (yyvsp[(6) - (7)].action)); ;}
- break;
-
- case 24:
-#line 215 "swf5compiler.y"
- { int tmp = chkctx(CTX_FUNCTION);
- if(tmp < 0)
- swf5error("return outside function");
- (yyval.action) = newBuffer();
- while(--tmp >= 0)
- bufferWriteOp((yyval.action), SWFACTION_POP);
- bufferWriteNull((yyval.action));
- bufferWriteOp((yyval.action), SWFACTION_RETURN); ;}
- break;
-
- case 25:
-#line 225 "swf5compiler.y"
- { int tmp = chkctx(CTX_FUNCTION);
- if(tmp < 0)
- swf5error("return outside function");
- (yyval.action) = newBuffer();
- while(--tmp >= 0)
- bufferWriteOp((yyval.action), SWFACTION_POP);
- bufferConcat((yyval.action), (yyvsp[(2) - (3)].action));
- bufferWriteOp((yyval.action), SWFACTION_RETURN); ;}
- break;
-
- case 27:
-#line 237 "swf5compiler.y"
- { bufferConcat((yyvsp[(1) - (3)].action), (yyvsp[(3) - (3)].action)); ;}
- break;
-
- case 28:
-#line 242 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(3) - (7)].action);
- bufferWriteOp((yyval.action), SWFACTION_BRANCHIFTRUE);
- bufferWriteS16((yyval.action), 2);
- bufferWriteS16((yyval.action), bufferLength((yyvsp[(7) - (7)].action))+5);
- bufferConcat((yyval.action), (yyvsp[(7) - (7)].action));
- bufferWriteOp((yyval.action), SWFACTION_BRANCHALWAYS);
- bufferWriteS16((yyval.action), 2);
- bufferWriteS16((yyval.action), bufferLength((yyvsp[(5) - (7)].action)));
- bufferConcat((yyval.action), (yyvsp[(5) - (7)].action)); ;}
- break;
-
- case 29:
-#line 253 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(3) - (5)].action);
- bufferWriteOp((yyval.action), SWFACTION_LOGICALNOT);
- bufferWriteOp((yyval.action), SWFACTION_BRANCHIFTRUE);
- bufferWriteS16((yyval.action), 2);
- bufferWriteS16((yyval.action), bufferLength((yyvsp[(5) - (5)].action)));
- bufferConcat((yyval.action), (yyvsp[(5) - (5)].action)); ;}
- break;
-
- case 30:
-#line 262 "swf5compiler.y"
- { (yyval.action) = NULL; ;}
- break;
-
- case 31:
-#line 263 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(1) - (1)].action); ;}
- break;
-
- case 32:
-#line 268 "swf5compiler.y"
- { addctx(CTX_SWITCH); ;}
- break;
-
- case 33:
-#line 274 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(3) - (7)].action);
- bufferResolveSwitch((yyval.action), &(yyvsp[(6) - (7)].switchcases));
- bufferResolveJumps((yyval.action));
- bufferWriteOp((yyval.action), SWFACTION_POP);
- delctx(CTX_SWITCH);
- /* FIXME: continue in switch continues surrounding loop, if any */
- ;}
- break;
-
- case 34:
-#line 286 "swf5compiler.y"
- { (yyval.switchcases).count = 0;
- (yyval.switchcases).list = 0; ;}
- break;
-
- case 35:
-#line 290 "swf5compiler.y"
- { (yyval.switchcases) = (yyvsp[(1) - (2)].switchcases);
- (yyval.switchcases).list = (struct switchcase*) realloc((yyval.switchcases).list, ((yyval.switchcases).count+1) * sizeof(struct switchcase));
- (yyval.switchcases).list[(yyval.switchcases).count] = (yyvsp[(2) - (2)].switchcase);
- (yyval.switchcases).count++; ;}
- break;
-
- case 36:
-#line 298 "swf5compiler.y"
- { (yyval.switchcase).cond = (yyvsp[(2) - (6)].action);
- (yyval.switchcase).action = (yyvsp[(4) - (6)].action);
- (yyval.switchcase).isbreak = 1; ;}
- break;
-
- case 37:
-#line 303 "swf5compiler.y"
- { (yyval.switchcase).cond = (yyvsp[(2) - (4)].action);
- (yyval.switchcase).action = (yyvsp[(4) - (4)].action);
- (yyval.switchcase).isbreak = 0; ;}
- break;
-
- case 38:
-#line 308 "swf5compiler.y"
- { (yyval.switchcase).cond = NULL;
- (yyval.switchcase).action = (yyvsp[(3) - (3)].action);
- (yyval.switchcase).isbreak = 0; ;}
- break;
-
- case 40:
-#line 318 "swf5compiler.y"
- { (yyval.str) = strdup("new"); ;}
- break;
-
- case 41:
-#line 319 "swf5compiler.y"
- { (yyval.str) = strdup("delete"); ;}
- break;
-
- case 42:
-#line 320 "swf5compiler.y"
- { (yyval.str) = strdup("random"); ;}
- break;
-
- case 43:
-#line 321 "swf5compiler.y"
- { (yyval.str) = strdup("getTimer"); ;}
- break;
-
- case 44:
-#line 322 "swf5compiler.y"
- { (yyval.str) = strdup("length"); ;}
- break;
-
- case 45:
-#line 323 "swf5compiler.y"
- { (yyval.str) = strdup("concat"); ;}
- break;
-
- case 46:
-#line 324 "swf5compiler.y"
- { (yyval.str) = strdup("substr"); ;}
- break;
-
- case 47:
-#line 325 "swf5compiler.y"
- { (yyval.str) = strdup("trace"); ;}
- break;
-
- case 48:
-#line 326 "swf5compiler.y"
- { (yyval.str) = strdup("int"); ;}
- break;
-
- case 49:
-#line 327 "swf5compiler.y"
- { (yyval.str) = strdup("ord"); ;}
- break;
-
- case 50:
-#line 328 "swf5compiler.y"
- { (yyval.str) = strdup("chr"); ;}
- break;
-
- case 51:
-#line 329 "swf5compiler.y"
- { (yyval.str) = strdup("getURL"); ;}
- break;
-
- case 52:
-#line 330 "swf5compiler.y"
- { (yyval.str) = strdup("getURL1"); ;}
- break;
-
- case 53:
-#line 331 "swf5compiler.y"
- { (yyval.str) = strdup("nextFrame"); ;}
- break;
-
- case 54:
-#line 332 "swf5compiler.y"
- { (yyval.str) = strdup("prevFrame"); ;}
- break;
-
- case 55:
-#line 333 "swf5compiler.y"
- { (yyval.str) = strdup("play"); ;}
- break;
-
- case 56:
-#line 334 "swf5compiler.y"
- { (yyval.str) = strdup("stop"); ;}
- break;
-
- case 57:
-#line 335 "swf5compiler.y"
- { (yyval.str) = strdup("toggleQuality"); ;}
- break;
-
- case 58:
-#line 336 "swf5compiler.y"
- { (yyval.str) = strdup("stopSounds"); ;}
- break;
-
- case 59:
-#line 337 "swf5compiler.y"
- { (yyval.str) = strdup("dup"); ;}
- break;
-
- case 60:
-#line 338 "swf5compiler.y"
- { (yyval.str) = strdup("swap"); ;}
- break;
-
- case 61:
-#line 339 "swf5compiler.y"
- { (yyval.str) = strdup("pop"); ;}
- break;
-
- case 62:
-#line 340 "swf5compiler.y"
- { (yyval.str) = strdup("push"); ;}
- break;
-
- case 63:
-#line 341 "swf5compiler.y"
- { (yyval.str) = strdup("setRegister"); ;}
- break;
-
- case 64:
-#line 342 "swf5compiler.y"
- { (yyval.str) = strdup("callFunction"); ;}
- break;
-
- case 65:
-#line 343 "swf5compiler.y"
- { (yyval.str) = strdup("callMethod"); ;}
- break;
-
- case 66:
-#line 344 "swf5compiler.y"
- { (yyval.str) = strdup("and"); ;}
- break;
-
- case 67:
-#line 345 "swf5compiler.y"
- { (yyval.str) = strdup("or"); ;}
- break;
-
- case 68:
-#line 346 "swf5compiler.y"
- { (yyval.str) = strdup("xor"); ;}
- break;
-
- case 69:
-#line 347 "swf5compiler.y"
- { (yyval.str) = strdup("modulo"); ;}
- break;
-
- case 70:
-#line 348 "swf5compiler.y"
- { (yyval.str) = strdup("add"); ;}
- break;
-
- case 71:
-#line 349 "swf5compiler.y"
- { (yyval.str) = strdup("lessThan"); ;}
- break;
-
- case 72:
-#line 350 "swf5compiler.y"
- { (yyval.str) = strdup("equals"); ;}
- break;
-
- case 73:
-#line 351 "swf5compiler.y"
- { (yyval.str) = strdup("inc"); ;}
- break;
-
- case 74:
-#line 352 "swf5compiler.y"
- { (yyval.str) = strdup("dec"); ;}
- break;
-
- case 75:
-#line 353 "swf5compiler.y"
- { (yyval.str) = strdup("typeof"); ;}
- break;
-
- case 76:
-#line 354 "swf5compiler.y"
- { (yyval.str) = strdup("instanceof"); ;}
- break;
-
- case 77:
-#line 355 "swf5compiler.y"
- { (yyval.str) = strdup("enumerate"); ;}
- break;
-
- case 78:
-#line 356 "swf5compiler.y"
- { (yyval.str) = strdup("initobject"); ;}
- break;
-
- case 79:
-#line 357 "swf5compiler.y"
- { (yyval.str) = strdup("initarray"); ;}
- break;
-
- case 80:
-#line 358 "swf5compiler.y"
- { (yyval.str) = strdup("getmember"); ;}
- break;
-
- case 81:
-#line 359 "swf5compiler.y"
- { (yyval.str) = strdup("setmember"); ;}
- break;
-
- case 82:
-#line 360 "swf5compiler.y"
- { (yyval.str) = strdup("shiftleft"); ;}
- break;
-
- case 83:
-#line 361 "swf5compiler.y"
- { (yyval.str) = strdup("shiftright"); ;}
- break;
-
- case 84:
-#line 362 "swf5compiler.y"
- { (yyval.str) = strdup("shiftright2"); ;}
- break;
-
- case 85:
-#line 363 "swf5compiler.y"
- { (yyval.str) = strdup("varequals"); ;}
- break;
-
- case 86:
-#line 364 "swf5compiler.y"
- { (yyval.str) = strdup("oldAdd"); ;}
- break;
-
- case 87:
-#line 365 "swf5compiler.y"
- { (yyval.str) = strdup("subtract"); ;}
- break;
-
- case 88:
-#line 366 "swf5compiler.y"
- { (yyval.str) = strdup("multiply"); ;}
- break;
-
- case 89:
-#line 367 "swf5compiler.y"
- { (yyval.str) = strdup("divide"); ;}
- break;
-
- case 90:
-#line 368 "swf5compiler.y"
- { (yyval.str) = strdup("oldequals"); ;}
- break;
-
- case 91:
-#line 369 "swf5compiler.y"
- { (yyval.str) = strdup("oldlessthan"); ;}
- break;
-
- case 92:
-#line 370 "swf5compiler.y"
- { (yyval.str) = strdup("logicaland"); ;}
- break;
-
- case 93:
-#line 371 "swf5compiler.y"
- { (yyval.str) = strdup("logicalor"); ;}
- break;
-
- case 94:
-#line 372 "swf5compiler.y"
- { (yyval.str) = strdup("not"); ;}
- break;
-
- case 95:
-#line 373 "swf5compiler.y"
- { (yyval.str) = strdup("stringeq"); ;}
- break;
-
- case 96:
-#line 374 "swf5compiler.y"
- { (yyval.str) = strdup("stringlength"); ;}
- break;
-
- case 97:
-#line 375 "swf5compiler.y"
- { (yyval.str) = strdup("substring"); ;}
- break;
-
- case 98:
-#line 376 "swf5compiler.y"
- { (yyval.str) = strdup("getvariable"); ;}
- break;
-
- case 99:
-#line 377 "swf5compiler.y"
- { (yyval.str) = strdup("setvariable"); ;}
- break;
-
- case 100:
-#line 378 "swf5compiler.y"
- { (yyval.str) = strdup("settargetexpression"); ;}
- break;
-
- case 101:
-#line 379 "swf5compiler.y"
- { (yyval.str) = strdup("duplicatemovieclip"); ;}
- break;
-
- case 102:
-#line 380 "swf5compiler.y"
- { (yyval.str) = strdup("removemovieclip"); ;}
- break;
-
- case 103:
-#line 381 "swf5compiler.y"
- { (yyval.str) = strdup("startdrag"); ;}
- break;
-
- case 104:
-#line 382 "swf5compiler.y"
- { (yyval.str) = strdup("stopdrag"); ;}
- break;
-
- case 105:
-#line 383 "swf5compiler.y"
- { (yyval.str) = strdup("stringlessthan"); ;}
- break;
-
- case 106:
-#line 384 "swf5compiler.y"
- { (yyval.str) = strdup("mblength"); ;}
- break;
-
- case 107:
-#line 385 "swf5compiler.y"
- { (yyval.str) = strdup("mbsubstring"); ;}
- break;
-
- case 108:
-#line 386 "swf5compiler.y"
- { (yyval.str) = strdup("mbord"); ;}
- break;
-
- case 109:
-#line 387 "swf5compiler.y"
- { (yyval.str) = strdup("mbchr"); ;}
- break;
-
- case 110:
-#line 388 "swf5compiler.y"
- { (yyval.str) = strdup("branchalways"); ;}
- break;
-
- case 111:
-#line 389 "swf5compiler.y"
- { (yyval.str) = strdup("branchiftrue"); ;}
- break;
-
- case 112:
-#line 390 "swf5compiler.y"
- { (yyval.str) = strdup("getURL2"); ;}
- break;
-
- case 113:
-#line 391 "swf5compiler.y"
- { (yyval.str) = strdup("post"); ;}
- break;
-
- case 114:
-#line 392 "swf5compiler.y"
- { (yyval.str) = strdup("get"); ;}
- break;
-
- case 115:
-#line 393 "swf5compiler.y"
- { (yyval.str) = strdup("loadvariables"); ;}
- break;
-
- case 116:
-#line 394 "swf5compiler.y"
- { (yyval.str) = strdup("loadMovie"); ;}
- break;
-
- case 117:
-#line 399 "swf5compiler.y"
- { (yyval.exprlist).buffer = newBuffer();
- (yyval.exprlist).count = 0; ;}
- break;
-
- case 118:
-#line 403 "swf5compiler.y"
- { (yyval.exprlist).buffer = newBuffer();
- bufferWriteHardString((yyval.exprlist).buffer, (byte*)(yyvsp[(1) - (1)].str), strlen((yyvsp[(1) - (1)].str))+1);
- (yyval.exprlist).count = 1; ;}
- break;
-
- case 119:
-#line 408 "swf5compiler.y"
- { (yyval.exprlist) = (yyvsp[(1) - (3)].exprlist);
- bufferWriteHardString((yyval.exprlist).buffer, (byte*)(yyvsp[(3) - (3)].str), strlen((yyvsp[(3) - (3)].str))+1);
- ++(yyval.exprlist).count; ;}
- break;
-
- case 120:
-#line 415 "swf5compiler.y"
- { addctx(CTX_FUNCTION); ;}
- break;
-
- case 121:
-#line 420 "swf5compiler.y"
- { (yyval.action) = newBuffer();
- bufferWriteOp((yyval.action), SWFACTION_DEFINEFUNCTION);
- bufferWriteS16((yyval.action), strlen((yyvsp[(2) - (6)].str)) +
- bufferLength((yyvsp[(4) - (6)].exprlist).buffer) + 5);
- bufferWriteHardString((yyval.action), (byte*) (yyvsp[(2) - (6)].str), strlen((yyvsp[(2) - (6)].str))+1);
- bufferWriteS16((yyval.action), (yyvsp[(4) - (6)].exprlist).count);
- bufferConcat((yyval.action), (yyvsp[(4) - (6)].exprlist).buffer);
- bufferWriteS16((yyval.action), bufferLength((yyvsp[(6) - (6)].action)));
- bufferConcat((yyval.action), (yyvsp[(6) - (6)].action));
- delctx(CTX_FUNCTION); ;}
- break;
-
- case 122:
-#line 434 "swf5compiler.y"
- { (yyval.action) = newBuffer();
- bufferWriteString((yyval.action), (yyvsp[(1) - (1)].str), strlen((yyvsp[(1) - (1)].str))+1);
- free((yyvsp[(1) - (1)].str)); ;}
- break;
-
- case 123:
-#line 439 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(1) - (3)].action);
- bufferWriteString((yyval.action), (yyvsp[(3) - (3)].str), strlen((yyvsp[(3) - (3)].str))+1);
- bufferWriteOp((yyval.action), SWFACTION_GETMEMBER);
- free((yyvsp[(3) - (3)].str)); ;}
- break;
-
- case 124:
-#line 445 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(1) - (4)].action);
- bufferConcat((yyval.action), (yyvsp[(3) - (4)].action));
- bufferWriteOp((yyval.action), SWFACTION_GETMEMBER); ;}
- break;
-
- case 127:
-#line 456 "swf5compiler.y"
- { addctx(CTX_LOOP); ;}
- break;
-
- case 128:
-#line 461 "swf5compiler.y"
- { addctx(CTX_LOOP); ;}
- break;
-
- case 129:
-#line 466 "swf5compiler.y"
- { addctx(CTX_LOOP); ;}
- break;
-
- case 130:
-#line 471 "swf5compiler.y"
- { addctx(CTX_FOR_IN); ;}
- break;
-
- case 131:
-#line 476 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(3) - (5)].action);
- bufferWriteOp((yyval.action), SWFACTION_LOGICALNOT);
- bufferWriteOp((yyval.action), SWFACTION_BRANCHIFTRUE);
- bufferWriteS16((yyval.action), 2);
- bufferWriteS16((yyval.action), bufferLength((yyvsp[(5) - (5)].action))+5);
- bufferConcat((yyval.action), (yyvsp[(5) - (5)].action));
- bufferWriteOp((yyval.action), SWFACTION_BRANCHALWAYS);
- bufferWriteS16((yyval.action), 2);
- bufferWriteS16((yyval.action), -(bufferLength((yyval.action))+2));
- bufferResolveJumps((yyval.action));
- delctx(CTX_LOOP); ;}
- break;
-
- case 132:
-#line 489 "swf5compiler.y"
- { if((yyvsp[(2) - (6)].action))
- { (yyval.action) = (yyvsp[(2) - (6)].action);
- bufferConcat((yyval.action), (yyvsp[(5) - (6)].action));
- }
- else
- (yyval.action) = (yyvsp[(5) - (6)].action);
- bufferWriteOp((yyval.action), SWFACTION_BRANCHIFTRUE);
- bufferWriteS16((yyval.action), 2);
- bufferWriteS16((yyval.action), -(bufferLength((yyval.action))+2));
- bufferResolveJumps((yyval.action));
- delctx(CTX_LOOP); ;}
- break;
-
- case 133:
-#line 502 "swf5compiler.y"
- {
- if((yyvsp[(3) - (10)].action))
- (yyval.action) = (yyvsp[(3) - (10)].action);
- else
- (yyval.action) = newBuffer();
-
- if((yyvsp[(7) - (10)].action))
- {
- bufferWriteOp((yyval.action), SWFACTION_BRANCHALWAYS);
- bufferWriteS16((yyval.action), 2);
- bufferWriteS16((yyval.action), bufferLength((yyvsp[(7) - (10)].action)));
- }
- else
- (yyvsp[(7) - (10)].action) = newBuffer();
-
- if((yyvsp[(5) - (10)].action))
- {
- bufferConcat((yyvsp[(7) - (10)].action), (yyvsp[(5) - (10)].action));
- bufferWriteOp((yyvsp[(7) - (10)].action), SWFACTION_LOGICALNOT);
- bufferWriteOp((yyvsp[(7) - (10)].action), SWFACTION_BRANCHIFTRUE);
- bufferWriteS16((yyvsp[(7) - (10)].action), 2);
- bufferWriteS16((yyvsp[(7) - (10)].action), bufferLength((yyvsp[(10) - (10)].action))+5);
- }
-
- bufferConcat((yyvsp[(7) - (10)].action), (yyvsp[(10) - (10)].action));
- bufferWriteOp((yyvsp[(7) - (10)].action), SWFACTION_BRANCHALWAYS);
- bufferWriteS16((yyvsp[(7) - (10)].action), 2);
- bufferWriteS16((yyvsp[(7) - (10)].action), -(bufferLength((yyvsp[(7) - (10)].action))+2));
- bufferResolveJumps((yyvsp[(7) - (10)].action));
-
- bufferConcat((yyval.action), (yyvsp[(7) - (10)].action));
- delctx(CTX_LOOP);
- ;}
- break;
-
- case 134:
-#line 537 "swf5compiler.y"
- { Buffer b2, b3;
- int tmp;
-
- (yyval.action) = (yyvsp[(5) - (8)].action);
- bufferWriteOp((yyval.action), SWFACTION_ENUMERATE);
-
- b2 = newBuffer();
- bufferWriteSetRegister(b2, 0);
- bufferWriteOp(b2, SWFACTION_PUSHDATA);
- bufferWriteS16(b2, 1);
- bufferWriteU8(b2, 2);
- bufferWriteOp(b2, SWFACTION_NEWEQUALS);
- bufferWriteOp(b2, SWFACTION_BRANCHIFTRUE);
- bufferWriteS16(b2, 2);
-
- b3 = newBuffer();
-/* basically a lvalue could be used here rather than an ident !!! */
-/* probably by using reg1 for the test rather than reg0 */
- bufferWriteString(b3, (yyvsp[(3) - (8)].str), strlen((yyvsp[(3) - (8)].str))+1);
- bufferWriteRegister(b3, 0);
- bufferWriteOp(b3, SWFACTION_SETVARIABLE);
- bufferConcat(b3, (yyvsp[(8) - (8)].action));
- bufferWriteS16(b2, bufferLength(b3) + 5);
- tmp = bufferLength(b2) + bufferLength(b3) + 5;
- bufferConcat((yyval.action), b2);
- bufferWriteOp(b3, SWFACTION_BRANCHALWAYS);
- bufferWriteS16(b3, 2);
- bufferWriteS16(b3, -tmp);
- bufferResolveJumps(b3);
- bufferConcat((yyval.action), b3);
- delctx(CTX_FOR_IN); ;}
- break;
-
- case 135:
-#line 570 "swf5compiler.y"
- { Buffer b2, b3;
- int tmp;
-
- (yyval.action) = (yyvsp[(6) - (9)].action);
- bufferWriteOp((yyval.action), SWFACTION_ENUMERATE);
-
- b2 = newBuffer();
- bufferWriteSetRegister(b2, 0);
- bufferWriteOp(b2, SWFACTION_PUSHDATA);
- bufferWriteS16(b2, 1);
- bufferWriteU8(b2, 2);
- bufferWriteOp(b2, SWFACTION_NEWEQUALS);
- bufferWriteOp(b2, SWFACTION_BRANCHIFTRUE);
- bufferWriteS16(b2, 2);
- // add size later
-
- b3 = newBuffer();
- bufferWriteString(b3, (yyvsp[(4) - (9)].str), strlen((yyvsp[(4) - (9)].str))+1);
- bufferWriteRegister(b3, 0);
- bufferWriteOp(b3, SWFACTION_VAREQUALS);
- bufferConcat(b3, (yyvsp[(9) - (9)].action));
- bufferWriteS16(b2, bufferLength(b3) + 5);
- tmp = bufferLength(b2) + bufferLength(b3) + 5;
- bufferConcat((yyval.action), b2);
- bufferWriteOp(b3, SWFACTION_BRANCHALWAYS);
- bufferWriteS16(b3, 2);
- bufferWriteS16(b3, -tmp);
- bufferResolveJumps(b3);
- bufferConcat((yyval.action), b3);
- delctx(CTX_FOR_IN); ;}
- break;
-
- case 136:
-#line 603 "swf5compiler.y"
- { (yyval.action) = NULL; ;}
- break;
-
- case 138:
-#line 611 "swf5compiler.y"
- { if(chkctx(CTX_CONTINUE) < 0)
- swf5error("continue outside loop");
- (yyval.action) = newBuffer();
- bufferWriteOp((yyval.action), SWFACTION_BRANCHALWAYS);
- bufferWriteS16((yyval.action), 2);
- bufferWriteS16((yyval.action), MAGIC_CONTINUE_NUMBER); ;}
- break;
-
- case 139:
-#line 622 "swf5compiler.y"
- { int tmp = chkctx(CTX_BREAK);
- if(tmp < 0)
- swf5error("break outside switch / loop");
- (yyval.action) = newBuffer();
- if(tmp) /* break out of a for .. in */
- bufferWriteOp((yyval.action), SWFACTION_POP);
- bufferWriteOp((yyval.action), SWFACTION_BRANCHALWAYS);
- bufferWriteS16((yyval.action), 2);
- bufferWriteS16((yyval.action), MAGIC_BREAK_NUMBER); ;}
- break;
-
- case 140:
-#line 634 "swf5compiler.y"
- { (yyval.getURLMethod) = GETURL_METHOD_NOSEND; ;}
- break;
-
- case 141:
-#line 636 "swf5compiler.y"
- { (yyval.getURLMethod) = GETURL_METHOD_GET; ;}
- break;
-
- case 142:
-#line 638 "swf5compiler.y"
- { (yyval.getURLMethod) = GETURL_METHOD_POST; ;}
- break;
-
- case 143:
-#line 640 "swf5compiler.y"
- { if(strcmp((yyvsp[(2) - (2)].str), "GET") == 0)
- (yyval.getURLMethod) = GETURL_METHOD_GET;
- else if(strcmp((yyvsp[(2) - (2)].str), "POST") == 0)
- (yyval.getURLMethod) = GETURL_METHOD_POST; ;}
- break;
-
- case 144:
-#line 648 "swf5compiler.y"
- { char *lvlstring = (char*) malloc(12*sizeof(char));
- sprintf(lvlstring, "_level%d", (yyvsp[(1) - (1)].intVal));
- (yyval.action) = newBuffer();
- bufferWriteString((yyval.action), lvlstring, strlen(lvlstring)+1);
- free(lvlstring); ;}
- break;
-
- case 145:
-#line 655 "swf5compiler.y"
- { (yyval.action) = newBuffer();
- bufferWriteString((yyval.action), "_level", 7);
- bufferConcat((yyval.action), (yyvsp[(1) - (1)].action));
- bufferWriteOp((yyval.action), SWFACTION_STRINGCONCAT); ;}
- break;
-
- case 146:
-#line 663 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(3) - (4)].exprlist).buffer;
- bufferWriteInt((yyval.action), (yyvsp[(3) - (4)].exprlist).count);
- bufferWriteString((yyval.action), (yyvsp[(1) - (4)].str), strlen((yyvsp[(1) - (4)].str))+1);
- bufferWriteOp((yyval.action), SWFACTION_CALLFUNCTION);
- bufferWriteOp((yyval.action), SWFACTION_POP);
- free((yyvsp[(1) - (4)].str)); ;}
- break;
-
- case 147:
-#line 671 "swf5compiler.y"
- { (yyval.action) = newBuffer();
- bufferWriteString((yyval.action), (yyvsp[(2) - (2)].str), strlen((yyvsp[(2) - (2)].str))+1);
- free((yyvsp[(2) - (2)].str));
- bufferWriteOp((yyval.action), SWFACTION_DELETE); ;}
- break;
-
- case 148:
-#line 677 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(2) - (4)].action);
- // bufferWriteOp($$, SWFACTION_GETVARIABLE);
- bufferWriteString((yyval.action), (yyvsp[(4) - (4)].str), strlen((yyvsp[(4) - (4)].str))+1);
- free((yyvsp[(4) - (4)].str));
- bufferWriteOp((yyval.action), SWFACTION_DELETEVAR); ;}
- break;
-
- case 149:
-#line 684 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(2) - (5)].action);
- // bufferWriteOp($$, SWFACTION_GETVARIABLE);
- bufferConcat((yyval.action), (yyvsp[(4) - (5)].action));
- // bufferWriteOp($$, SWFACTION_GETVARIABLE);
- bufferWriteOp((yyval.action), SWFACTION_DELETEVAR); ;}
- break;
-
- case 150:
-#line 691 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(3) - (4)].action);
- bufferWriteOp((yyval.action), SWFACTION_TRACE); ;}
- break;
-
- case 151:
-#line 695 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(3) - (7)].action);
- bufferConcat((yyval.action), (yyvsp[(5) - (7)].action));
- bufferWriteOp((yyval.action), SWFACTION_GETURL2);
- bufferWriteS16((yyval.action), 1);
- bufferWriteU8((yyval.action), (yyvsp[(6) - (7)].getURLMethod)); ;}
- break;
-
- case 152:
-#line 702 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(3) - (7)].action);
- bufferConcat((yyval.action), (yyvsp[(5) - (7)].action));
- bufferWriteOp((yyval.action), SWFACTION_GETURL2);
- bufferWriteS16((yyval.action), 1);
- bufferWriteU8((yyval.action), 0xc0+(yyvsp[(6) - (7)].getURLMethod)); ;}
- break;
-
- case 153:
-#line 709 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(3) - (7)].action);
- bufferConcat((yyval.action), (yyvsp[(5) - (7)].action));
- bufferWriteOp((yyval.action), SWFACTION_GETURL2);
- bufferWriteS16((yyval.action), 1);
- bufferWriteU8((yyval.action), 0x80+(yyvsp[(6) - (7)].getURLMethod)); ;}
- break;
-
- case 154:
-#line 716 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(3) - (7)].action);
- bufferConcat((yyval.action), (yyvsp[(5) - (7)].action));
- bufferWriteOp((yyval.action), SWFACTION_GETURL2);
- bufferWriteS16((yyval.action), 1);
- bufferWriteU8((yyval.action), 0x40+(yyvsp[(6) - (7)].getURLMethod)); ;}
- break;
-
- case 155:
-#line 723 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(3) - (7)].action);
- bufferConcat((yyval.action), (yyvsp[(5) - (7)].action));
- bufferWriteOp((yyval.action), SWFACTION_GETURL2);
- bufferWriteS16((yyval.action), 1);
- bufferWriteU8((yyval.action), (yyvsp[(6) - (7)].getURLMethod)); ;}
- break;
-
- case 156:
-#line 730 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(3) - (4)].action);
- bufferWriteOp((yyval.action), SWFACTION_CALLFRAME);
- bufferWriteS16((yyval.action), 0); ;}
- break;
-
- case 157:
-#line 736 "swf5compiler.y"
- { (yyval.action) = newBuffer();
- bufferWriteString((yyval.action), "0", 2); /* no constraint */
- bufferConcat((yyval.action), (yyvsp[(5) - (6)].action));
- bufferConcat((yyval.action), (yyvsp[(3) - (6)].action));
- bufferWriteOp((yyval.action), SWFACTION_STARTDRAGMOVIE); ;}
- break;
-
- case 158:
-#line 743 "swf5compiler.y"
- { (yyval.action) = newBuffer();
- bufferConcat((yyval.action), (yyvsp[(7) - (14)].action));
- bufferConcat((yyval.action), (yyvsp[(11) - (14)].action));
- bufferConcat((yyval.action), (yyvsp[(9) - (14)].action));
- bufferConcat((yyval.action), (yyvsp[(13) - (14)].action));
- bufferWriteString((yyval.action), "1", 2); /* has constraint */
- bufferConcat((yyval.action), (yyvsp[(5) - (14)].action));
- bufferConcat((yyval.action), (yyvsp[(3) - (14)].action));
- bufferWriteOp((yyval.action), SWFACTION_STARTDRAGMOVIE); ;}
- break;
-
- case 159:
-#line 754 "swf5compiler.y"
- { (yyval.action) = newBuffer();
- bufferWriteOp((yyval.action), SWFACTION_STOPDRAGMOVIE); ;}
- break;
-
- case 160:
-#line 759 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(3) - (8)].action);
- bufferConcat((yyval.action), (yyvsp[(5) - (8)].action));
- bufferConcat((yyval.action), (yyvsp[(7) - (8)].action));
- bufferWriteInt((yyval.action), 16384); /* magic number */
- bufferWriteOp((yyval.action), SWFACTION_ADD);
- bufferWriteOp((yyval.action), SWFACTION_DUPLICATECLIP); ;}
- break;
-
- case 161:
-#line 767 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(3) - (4)].action);
- bufferWriteOp((yyval.action), SWFACTION_REMOVECLIP); ;}
- break;
-
- case 162:
-#line 771 "swf5compiler.y"
- { (yyval.action) = newBuffer();
- bufferWriteOp((yyval.action), SWFACTION_GETURL);
- bufferWriteS16((yyval.action), strlen((yyvsp[(3) - (6)].str)) + strlen((yyvsp[(5) - (6)].str)) + 2);
- bufferWriteHardString((yyval.action), (byte*)(yyvsp[(3) - (6)].str), strlen((yyvsp[(3) - (6)].str)));
- bufferWriteU8((yyval.action), 0);
- bufferWriteHardString((yyval.action), (byte*)(yyvsp[(5) - (6)].str), strlen((yyvsp[(5) - (6)].str)));
- bufferWriteU8((yyval.action), 0); ;}
- break;
-
- case 163:
-#line 781 "swf5compiler.y"
- { (yyval.action) = newBuffer();
- bufferWriteOp((yyval.action), SWFACTION_NEXTFRAME); ;}
- break;
-
- case 164:
-#line 785 "swf5compiler.y"
- { (yyval.action) = newBuffer();
- bufferWriteOp((yyval.action), SWFACTION_PREVFRAME); ;}
- break;
-
- case 165:
-#line 789 "swf5compiler.y"
- { (yyval.action) = newBuffer();
- bufferWriteOp((yyval.action), SWFACTION_PLAY); ;}
- break;
-
- case 166:
-#line 793 "swf5compiler.y"
- { (yyval.action) = newBuffer();
- bufferWriteOp((yyval.action), SWFACTION_STOP); ;}
- break;
-
- case 167:
-#line 797 "swf5compiler.y"
- { (yyval.action) = newBuffer();
- bufferWriteOp((yyval.action), SWFACTION_STOPSOUNDS); ;}
- break;
-
- case 168:
-#line 801 "swf5compiler.y"
- { (yyval.action) = newBuffer();
- bufferWriteOp((yyval.action), SWFACTION_TOGGLEQUALITY); ;}
- break;
-
- case 169:
-#line 805 "swf5compiler.y"
- { (yyval.action) = newBuffer();
- bufferWriteOp((yyval.action), SWFACTION_GOTOFRAME);
- bufferWriteS16((yyval.action), 2);
- bufferWriteS16((yyval.action), (yyvsp[(3) - (4)].intVal)); ;}
- break;
-
- case 170:
-#line 811 "swf5compiler.y"
- { (yyval.action) = newBuffer();
- bufferWriteOp((yyval.action), SWFACTION_GOTOLABEL);
- bufferWriteS16((yyval.action), strlen((yyvsp[(3) - (4)].str))+1);
- bufferWriteHardString((yyval.action), (byte*)(yyvsp[(3) - (4)].str), strlen((yyvsp[(3) - (4)].str))+1);
- free((yyvsp[(3) - (4)].str)); ;}
- break;
-
- case 171:
-#line 818 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(3) - (4)].action);
- bufferWriteOp((yyval.action), SWFACTION_GOTOEXPRESSION);
- bufferWriteS16((yyval.action), 1);
- bufferWriteU8((yyval.action), 0); ;}
- break;
-
- case 172:
-#line 824 "swf5compiler.y"
- { (yyval.action) = newBuffer();
- bufferWriteOp((yyval.action), SWFACTION_SETTARGET);
- bufferWriteS16((yyval.action), strlen((yyvsp[(3) - (4)].str))+1);
- bufferWriteHardString((yyval.action), (byte*)(yyvsp[(3) - (4)].str), strlen((yyvsp[(3) - (4)].str))+1);
- free((yyvsp[(3) - (4)].str)); ;}
- break;
-
- case 173:
-#line 831 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(3) - (4)].action);
- bufferWriteOp((yyval.action), SWFACTION_SETTARGETEXPRESSION); ;}
- break;
-
- case 174:
-#line 840 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(3) - (4)].exprlist).buffer;
- bufferWriteInt((yyval.action), (yyvsp[(3) - (4)].exprlist).count);
- bufferWriteString((yyval.action), (yyvsp[(1) - (4)].str), strlen((yyvsp[(1) - (4)].str))+1);
- bufferWriteOp((yyval.action), SWFACTION_CALLFUNCTION);
- free((yyvsp[(1) - (4)].str)); ;}
- break;
-
- case 175:
-#line 847 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(3) - (4)].action);
- bufferWriteOp((yyval.action), SWFACTION_GETVARIABLE); ;}
- break;
-
- case 176:
-#line 851 "swf5compiler.y"
- { (yyval.action) = newBuffer();
- bufferWriteOp((yyval.action), SWFACTION_GETTIMER); ;}
- break;
-
- case 177:
-#line 855 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(3) - (4)].action);
- bufferWriteOp((yyval.action), SWFACTION_RANDOM); ;}
- break;
-
- case 178:
-#line 859 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(3) - (4)].action);
- bufferWriteOp((yyval.action), SWFACTION_STRINGLENGTH); ;}
- break;
-
- case 179:
-#line 863 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(3) - (4)].action);
- bufferWriteOp((yyval.action), SWFACTION_INT); ;}
- break;
-
- case 180:
-#line 867 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(3) - (4)].action);
- bufferWriteOp((yyval.action), SWFACTION_ORD); ;}
- break;
-
- case 181:
-#line 871 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(3) - (4)].action);
- bufferWriteOp((yyval.action), SWFACTION_CHR); ;}
- break;
-
- case 182:
-#line 875 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(3) - (6)].action);
- bufferConcat((yyval.action), (yyvsp[(5) - (6)].action));
- bufferWriteOp((yyval.action), SWFACTION_STRINGCONCAT); ;}
- break;
-
- case 183:
-#line 880 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(3) - (8)].action);
- bufferConcat((yyval.action), (yyvsp[(5) - (8)].action));
- bufferConcat((yyval.action), (yyvsp[(7) - (8)].action));
- bufferWriteOp((yyval.action), SWFACTION_SUBSTRING); ;}
- break;
-
- case 184:
-#line 886 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(3) - (4)].action);
- bufferWriteOp((yyval.action), SWFACTION_TYPEOF); ;}
- break;
-
- case 185:
-#line 894 "swf5compiler.y"
- { (yyval.exprlist).buffer = newBuffer();
- (yyval.exprlist).count = 0; ;}
- break;
-
- case 186:
-#line 898 "swf5compiler.y"
- { (yyval.exprlist).buffer = (yyvsp[(1) - (1)].action);
- (yyval.exprlist).count = 1; ;}
- break;
-
- case 187:
-#line 903 "swf5compiler.y"
- { Buffer tmp = newBuffer();
- bufferConcat(tmp, (yyvsp[(3) - (3)].action));
- bufferConcat(tmp, (yyval.exprlist).buffer);
- (yyval.exprlist).buffer = tmp;
- ++(yyval.exprlist).count; ;}
- break;
-
- case 188:
-#line 912 "swf5compiler.y"
- { (yyval.action) = newBuffer();
- bufferWriteOp((yyval.action), SWFACTION_DEFINEFUNCTION);
- bufferWriteS16((yyval.action), bufferLength((yyvsp[(3) - (5)].exprlist).buffer) + 5);
- bufferWriteU8((yyval.action), 0); /* empty function name */
- bufferWriteS16((yyval.action), (yyvsp[(3) - (5)].exprlist).count);
- bufferConcat((yyval.action), (yyvsp[(3) - (5)].exprlist).buffer);
- bufferWriteS16((yyval.action), bufferLength((yyvsp[(5) - (5)].action)));
- bufferConcat((yyval.action), (yyvsp[(5) - (5)].action));
- delctx(CTX_FUNCTION); ;}
- break;
-
- case 189:
-#line 925 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(5) - (6)].exprlist).buffer;
- bufferWriteInt((yyval.action), (yyvsp[(5) - (6)].exprlist).count);
- bufferConcat((yyval.action), (yyvsp[(1) - (6)].action));
- bufferWriteString((yyval.action), (yyvsp[(3) - (6)].str), strlen((yyvsp[(3) - (6)].str))+1);
- bufferWriteOp((yyval.action), SWFACTION_CALLMETHOD);
- free((yyvsp[(3) - (6)].str)); ;}
- break;
-
- case 190:
-#line 933 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(6) - (7)].exprlist).buffer;
- bufferWriteInt((yyval.action), (yyvsp[(6) - (7)].exprlist).count);
- bufferConcat((yyval.action), (yyvsp[(1) - (7)].action));
- bufferConcat((yyval.action), (yyvsp[(3) - (7)].action));
- bufferWriteOp((yyval.action), SWFACTION_CALLMETHOD); ;}
- break;
-
- case 191:
-#line 942 "swf5compiler.y"
- { (yyval.action) = newBuffer();
- bufferWriteString((yyval.action), (yyvsp[(1) - (3)].str), strlen((yyvsp[(1) - (3)].str))+1);
- bufferConcat((yyval.action), (yyvsp[(3) - (3)].action)); ;}
- break;
-
- case 192:
-#line 949 "swf5compiler.y"
- { (yyval.exprlist).buffer = (yyvsp[(1) - (1)].action);
- (yyval.exprlist).count = 1; ;}
- break;
-
- case 193:
-#line 953 "swf5compiler.y"
- { bufferConcat((yyval.exprlist).buffer, (yyvsp[(3) - (3)].action));
- ++(yyval.exprlist).count; ;}
- break;
-
- case 194:
-#line 958 "swf5compiler.y"
- { (yyval.op) = SWFACTION_NEWADD; ;}
- break;
-
- case 195:
-#line 959 "swf5compiler.y"
- { (yyval.op) = SWFACTION_SUBTRACT; ;}
- break;
-
- case 196:
-#line 960 "swf5compiler.y"
- { (yyval.op) = SWFACTION_MULTIPLY; ;}
- break;
-
- case 197:
-#line 961 "swf5compiler.y"
- { (yyval.op) = SWFACTION_DIVIDE; ;}
- break;
-
- case 198:
-#line 962 "swf5compiler.y"
- { (yyval.op) = SWFACTION_MODULO; ;}
- break;
-
- case 199:
-#line 963 "swf5compiler.y"
- { (yyval.op) = SWFACTION_BITWISEAND; ;}
- break;
-
- case 200:
-#line 964 "swf5compiler.y"
- { (yyval.op) = SWFACTION_BITWISEOR; ;}
- break;
-
- case 201:
-#line 965 "swf5compiler.y"
- { (yyval.op) = SWFACTION_BITWISEXOR; ;}
- break;
-
- case 202:
-#line 966 "swf5compiler.y"
- { (yyval.op) = SWFACTION_SHIFTLEFT; ;}
- break;
-
- case 203:
-#line 967 "swf5compiler.y"
- { (yyval.op) = SWFACTION_SHIFTRIGHT; ;}
- break;
-
- case 204:
-#line 968 "swf5compiler.y"
- { (yyval.op) = SWFACTION_SHIFTRIGHT2; ;}
- break;
-
- case 205:
-#line 972 "swf5compiler.y"
- { (yyval.op) = SWFACTION_INCREMENT; ;}
- break;
-
- case 206:
-#line 973 "swf5compiler.y"
- { (yyval.op) = SWFACTION_DECREMENT; ;}
- break;
-
- case 207:
-#line 992 "swf5compiler.y"
- { if((yyvsp[(1) - (1)].lval).obj)
- {
- (yyval.action) = (yyvsp[(1) - (1)].lval).obj;
-
- if((yyvsp[(1) - (1)].lval).ident)
- bufferConcat((yyval.action), (yyvsp[(1) - (1)].lval).ident);
- else
- bufferConcat((yyval.action), (yyvsp[(1) - (1)].lval).memexpr);
-
- bufferWriteOp((yyval.action), SWFACTION_GETMEMBER);
- }
- else
- {
- (yyval.action) = (yyvsp[(1) - (1)].lval).ident;
- bufferWriteOp((yyval.action), SWFACTION_GETVARIABLE);
- }
- ;}
- break;
-
- case 210:
-#line 1016 "swf5compiler.y"
- { (yyval.lval).ident = newBuffer();
- bufferWriteString((yyval.lval).ident, (yyvsp[(1) - (1)].str), strlen((yyvsp[(1) - (1)].str))+1);
- free((yyvsp[(1) - (1)].str));
- (yyval.lval).obj = 0;
- (yyval.lval).memexpr = 0; ;}
- break;
-
- case 211:
-#line 1023 "swf5compiler.y"
- { (yyval.lval).obj = (yyvsp[(1) - (3)].action);
- (yyval.lval).ident = newBuffer();
- bufferWriteString((yyval.lval).ident, (yyvsp[(3) - (3)].str), strlen((yyvsp[(3) - (3)].str))+1);
- (yyval.lval).memexpr = 0; ;}
- break;
-
- case 212:
-#line 1029 "swf5compiler.y"
- { (yyval.lval).obj = (yyvsp[(1) - (4)].action);
- (yyval.lval).memexpr = (yyvsp[(3) - (4)].action);
- (yyval.lval).ident = 0; ;}
- break;
-
- case 214:
-#line 1040 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(2) - (2)].action);
- bufferWriteInt((yyvsp[(2) - (2)].action), -1);
- bufferWriteOp((yyvsp[(2) - (2)].action), SWFACTION_MULTIPLY); ;}
- break;
-
- case 215:
-#line 1045 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(2) - (2)].action);
- bufferWriteInt((yyvsp[(2) - (2)].action), 0xffffffff);
- bufferWriteOp((yyvsp[(2) - (2)].action), SWFACTION_BITWISEXOR); ;}
- break;
-
- case 216:
-#line 1050 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(2) - (2)].action);
- bufferWriteOp((yyvsp[(2) - (2)].action), SWFACTION_LOGICALNOT); ;}
- break;
-
- case 217:
-#line 1054 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(1) - (3)].action);
- bufferWriteOp((yyval.action), SWFACTION_DUP);
- bufferWriteOp((yyval.action), SWFACTION_BRANCHIFTRUE);
- bufferWriteS16((yyval.action), 2);
- bufferWriteS16((yyval.action), bufferLength((yyvsp[(3) - (3)].action))+1);
- bufferWriteOp((yyval.action), SWFACTION_POP);
- bufferConcat((yyval.action), (yyvsp[(3) - (3)].action)); ;}
- break;
-
- case 218:
-#line 1063 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(1) - (3)].action);
- bufferWriteOp((yyval.action), SWFACTION_DUP);
- bufferWriteOp((yyval.action), SWFACTION_LOGICALNOT);
- bufferWriteOp((yyval.action), SWFACTION_BRANCHIFTRUE);
- bufferWriteS16((yyval.action), 2);
- bufferWriteS16((yyval.action), bufferLength((yyvsp[(3) - (3)].action))+1);
- bufferWriteOp((yyval.action), SWFACTION_POP);
- bufferConcat((yyval.action), (yyvsp[(3) - (3)].action)); ;}
- break;
-
- case 219:
-#line 1073 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(1) - (3)].action);
- bufferConcat((yyval.action), (yyvsp[(3) - (3)].action));
- bufferWriteOp((yyval.action), SWFACTION_MULTIPLY); ;}
- break;
-
- case 220:
-#line 1078 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(1) - (3)].action);
- bufferConcat((yyval.action), (yyvsp[(3) - (3)].action));
- bufferWriteOp((yyval.action), SWFACTION_DIVIDE); ;}
- break;
-
- case 221:
-#line 1083 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(1) - (3)].action);
- bufferConcat((yyval.action), (yyvsp[(3) - (3)].action));
- bufferWriteOp((yyval.action), SWFACTION_MODULO); ;}
- break;
-
- case 222:
-#line 1088 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(1) - (3)].action);
- bufferConcat((yyval.action), (yyvsp[(3) - (3)].action));
- bufferWriteOp((yyval.action), SWFACTION_NEWADD); ;}
- break;
-
- case 223:
-#line 1093 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(1) - (3)].action);
- bufferConcat((yyval.action), (yyvsp[(3) - (3)].action));
- bufferWriteOp((yyval.action), SWFACTION_SUBTRACT); ;}
- break;
-
- case 224:
-#line 1098 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(1) - (3)].action);
- bufferConcat((yyval.action), (yyvsp[(3) - (3)].action));
- bufferWriteOp((yyval.action), SWFACTION_BITWISEAND); ;}
- break;
-
- case 225:
-#line 1103 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(1) - (3)].action);
- bufferConcat((yyval.action), (yyvsp[(3) - (3)].action));
- bufferWriteOp((yyval.action), SWFACTION_BITWISEOR); ;}
- break;
-
- case 226:
-#line 1108 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(1) - (3)].action);
- bufferConcat((yyval.action), (yyvsp[(3) - (3)].action));
- bufferWriteOp((yyval.action), SWFACTION_BITWISEXOR); ;}
- break;
-
- case 227:
-#line 1113 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(1) - (3)].action);
- bufferConcat((yyval.action), (yyvsp[(3) - (3)].action));
- bufferWriteOp((yyval.action), SWFACTION_NEWLESSTHAN); ;}
- break;
-
- case 228:
-#line 1118 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(3) - (3)].action);
- bufferConcat((yyval.action), (yyvsp[(1) - (3)].action));
- bufferWriteOp((yyval.action), SWFACTION_NEWLESSTHAN); ;}
- break;
-
- case 229:
-#line 1123 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(3) - (3)].action);
- bufferConcat((yyval.action), (yyvsp[(1) - (3)].action));
- bufferWriteOp((yyval.action), SWFACTION_NEWLESSTHAN);
- bufferWriteOp((yyval.action), SWFACTION_LOGICALNOT); ;}
- break;
-
- case 230:
-#line 1129 "swf5compiler.y"
- { bufferConcat((yyvsp[(1) - (3)].action), (yyvsp[(3) - (3)].action));
- bufferWriteOp((yyvsp[(1) - (3)].action), SWFACTION_NEWLESSTHAN);
- bufferWriteOp((yyvsp[(1) - (3)].action), SWFACTION_LOGICALNOT); ;}
- break;
-
- case 231:
-#line 1134 "swf5compiler.y"
- { bufferConcat((yyvsp[(1) - (3)].action), (yyvsp[(3) - (3)].action));
- bufferWriteOp((yyvsp[(1) - (3)].action), SWFACTION_NEWEQUALS); ;}
- break;
-
- case 232:
-#line 1138 "swf5compiler.y"
- { bufferConcat((yyvsp[(1) - (3)].action), (yyvsp[(3) - (3)].action));
- bufferWriteOp((yyvsp[(1) - (3)].action), SWFACTION_NEWEQUALS);
- bufferWriteOp((yyvsp[(1) - (3)].action), SWFACTION_LOGICALNOT); ;}
- break;
-
- case 233:
-#line 1143 "swf5compiler.y"
- { bufferConcat((yyvsp[(1) - (3)].action), (yyvsp[(3) - (3)].action));
- bufferWriteOp((yyvsp[(1) - (3)].action), SWFACTION_SHIFTLEFT); ;}
- break;
-
- case 234:
-#line 1147 "swf5compiler.y"
- { bufferConcat((yyvsp[(1) - (3)].action), (yyvsp[(3) - (3)].action));
- bufferWriteOp((yyvsp[(1) - (3)].action), SWFACTION_SHIFTRIGHT); ;}
- break;
-
- case 235:
-#line 1151 "swf5compiler.y"
- { bufferConcat((yyvsp[(1) - (3)].action), (yyvsp[(3) - (3)].action));
- bufferWriteOp((yyvsp[(1) - (3)].action), SWFACTION_SHIFTRIGHT2); ;}
- break;
-
- case 236:
-#line 1155 "swf5compiler.y"
- { bufferWriteOp((yyvsp[(1) - (5)].action), SWFACTION_BRANCHIFTRUE);
- bufferWriteS16((yyvsp[(1) - (5)].action), 2);
- bufferWriteS16((yyvsp[(1) - (5)].action), bufferLength((yyvsp[(5) - (5)].action))+5);
- bufferConcat((yyvsp[(1) - (5)].action), (yyvsp[(5) - (5)].action));
- bufferWriteOp((yyvsp[(1) - (5)].action), SWFACTION_BRANCHALWAYS);
- bufferWriteS16((yyvsp[(1) - (5)].action), 2);
- bufferWriteS16((yyvsp[(1) - (5)].action), bufferLength((yyvsp[(3) - (5)].action)));
- bufferConcat((yyvsp[(1) - (5)].action), (yyvsp[(3) - (5)].action)); ;}
- break;
-
- case 237:
-#line 1165 "swf5compiler.y"
- { if((yyvsp[(1) - (3)].lval).obj) /* obj[memexpr] or obj.ident */
- {
- (yyval.action) = (yyvsp[(1) - (3)].lval).obj;
-
- if((yyvsp[(1) - (3)].lval).ident)
- bufferConcat((yyval.action), (yyvsp[(1) - (3)].lval).ident);
- else
- bufferConcat((yyval.action), (yyvsp[(1) - (3)].lval).memexpr);
-
- bufferConcat((yyval.action), (yyvsp[(3) - (3)].action));
- bufferWriteSetRegister((yyval.action), 0);
- bufferWriteOp((yyval.action), SWFACTION_SETMEMBER);
- bufferWriteRegister((yyval.action), 0);
- }
- else /* just ident */
- {
- (yyval.action) = (yyvsp[(3) - (3)].action);
- bufferWriteOp((yyval.action), SWFACTION_DUP);
- bufferConcat((yyval.action), (yyvsp[(1) - (3)].lval).ident);
- bufferWriteOp((yyval.action), SWFACTION_SWAP);
- bufferWriteOp((yyval.action), SWFACTION_SETVARIABLE);
- }
-/* tricky case missing here: lvalue ASSIGN expr */
-/* like in x = y += z; */
- ;}
- break;
-
- case 238:
-#line 1192 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(1) - (3)].action);
- bufferConcat((yyval.action), (yyvsp[(3) - (3)].action));
- bufferWriteOp((yyval.action), SWFACTION_INSTANCEOF); ;}
- break;
-
- case 240:
-#line 1202 "swf5compiler.y"
- { (yyval.action) = newBuffer();
- bufferWriteInt((yyval.action), 0);
- bufferWriteString((yyval.action), (yyvsp[(2) - (2)].str), strlen((yyvsp[(2) - (2)].str))+1);
- bufferWriteOp((yyval.action), SWFACTION_NEW); ;}
- break;
-
- case 241:
-#line 1208 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(4) - (5)].exprlist).buffer;
- bufferWriteInt((yyval.action), (yyvsp[(4) - (5)].exprlist).count);
- bufferWriteString((yyval.action), (yyvsp[(2) - (5)].str), strlen((yyvsp[(2) - (5)].str))+1);
- bufferWriteOp((yyval.action), SWFACTION_NEW); ;}
- break;
-
- case 242:
-#line 1214 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(2) - (3)].exprlist).buffer;
- bufferWriteInt((yyval.action), (yyvsp[(2) - (3)].exprlist).count);
- bufferWriteOp((yyval.action), SWFACTION_INITARRAY); ;}
- break;
-
- case 243:
-#line 1219 "swf5compiler.y"
- { (yyval.action) = newBuffer();
- bufferWriteInt((yyval.action), 0);
- bufferWriteOp((yyval.action), SWFACTION_INITOBJECT); ;}
- break;
-
- case 244:
-#line 1224 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(2) - (3)].exprlist).buffer;
- bufferWriteInt((yyval.action), (yyvsp[(2) - (3)].exprlist).count);
- bufferWriteOp((yyval.action), SWFACTION_INITOBJECT); ;}
- break;
-
- case 249:
-#line 1240 "swf5compiler.y"
- { if((yyvsp[(2) - (2)].lval).obj)
- {
- if((yyvsp[(2) - (2)].lval).ident) // expr . identifier
- {
- (yyval.action) = (yyvsp[(2) - (2)].lval).obj;
- bufferWriteOp((yyval.action), SWFACTION_DUP); /* a, a */
- bufferWriteBuffer((yyval.action), (yyvsp[(2) - (2)].lval).ident); /* a, a, i */
- bufferWriteOp((yyval.action), SWFACTION_SWAP); /* a, i, a */
- bufferConcat((yyval.action), (yyvsp[(2) - (2)].lval).ident); /* a, i, a, i */
- bufferWriteOp((yyval.action), SWFACTION_GETMEMBER);
- bufferWriteOp((yyval.action), (yyvsp[(1) - (2)].op));
- bufferWriteSetRegister((yyval.action), 0);
- bufferWriteOp((yyval.action), SWFACTION_SETMEMBER); /* a.i = a.i+1 */
- bufferWriteRegister((yyval.action), 0); /* a.i+1 */
- }
- else // expr [ expr ]
- {
- (yyval.action) = (yyvsp[(2) - (2)].lval).memexpr; /* i */
- bufferConcat((yyval.action), (yyvsp[(2) - (2)].lval).obj); /* i, a */
- bufferWriteSetRegister((yyval.action), 0); /* ($2.memexpr can use reg0) */
- bufferWriteOp((yyval.action), SWFACTION_SWAP); /* a, i */
- bufferWriteOp((yyval.action), SWFACTION_DUP); /* a, i, i */
- bufferWriteRegister((yyval.action), 0); /* a, i, i, a */
- bufferWriteOp((yyval.action), SWFACTION_SWAP); /* a, i, a, i */
- bufferWriteOp((yyval.action), SWFACTION_GETMEMBER); /* a, i, a[i] */
- bufferWriteOp((yyval.action), (yyvsp[(1) - (2)].op)); /* a, i, a[i]+1 */
- bufferWriteSetRegister((yyval.action), 0);
- bufferWriteOp((yyval.action), SWFACTION_SETMEMBER); /* a[i] = a[i]+1 */
- bufferWriteRegister((yyval.action), 0); /* a[i]+1 */
- }
- }
- else // identifier
- {
- (yyval.action) = newBuffer();
- bufferWriteBuffer((yyval.action), (yyvsp[(2) - (2)].lval).ident);
- bufferWriteOp((yyval.action), SWFACTION_GETVARIABLE);
- bufferWriteOp((yyval.action), (yyvsp[(1) - (2)].op));
- bufferWriteOp((yyval.action), SWFACTION_DUP);
- bufferConcat((yyval.action), (yyvsp[(2) - (2)].lval).ident);
- bufferWriteOp((yyval.action), SWFACTION_SWAP);
- bufferWriteOp((yyval.action), SWFACTION_SETVARIABLE);
- }
- ;}
- break;
-
- case 250:
-#line 1285 "swf5compiler.y"
- { if((yyvsp[(1) - (2)].lval).obj)
- {
- if((yyvsp[(1) - (2)].lval).ident)
- {
- (yyval.action) = (yyvsp[(1) - (2)].lval).obj; /* a */
- bufferWriteOp((yyval.action), SWFACTION_DUP); /* a, a */
- bufferWriteBuffer((yyval.action), (yyvsp[(1) - (2)].lval).ident); /* a, a, i */
- bufferWriteOp((yyval.action), SWFACTION_GETMEMBER); /* a, a.i */
- bufferWriteSetRegister((yyval.action), 0);
- bufferWriteOp((yyval.action), SWFACTION_SWAP); /* a.i, a */
- bufferConcat((yyval.action), (yyvsp[(1) - (2)].lval).ident); /* a.i, a, i */
- bufferWriteRegister((yyval.action), 0); /* a.i, a, i, a.i */
- bufferWriteOp((yyval.action), (yyvsp[(2) - (2)].op)); /* a.i, a, i, a.i+1 */
- bufferWriteOp((yyval.action), SWFACTION_SETMEMBER);
- }
- else
- {
- (yyval.action) = (yyvsp[(1) - (2)].lval).memexpr;
- bufferConcat((yyval.action), (yyvsp[(1) - (2)].lval).obj); /* i, a */
- bufferWriteSetRegister((yyval.action), 0);
- bufferWriteOp((yyval.action), SWFACTION_SWAP); /* a, i */
- bufferWriteOp((yyval.action), SWFACTION_DUP); /* a, i, i */
- bufferWriteRegister((yyval.action), 0); /* a, i, i, a */
- bufferWriteOp((yyval.action), SWFACTION_SWAP); /* a, i, a, i */
- bufferWriteOp((yyval.action), SWFACTION_GETMEMBER); /* a, i, a[i] */
- bufferWriteSetRegister((yyval.action), 0);
- bufferWriteOp((yyval.action), (yyvsp[(2) - (2)].op)); /* a, i, a[i]+1 */
- bufferWriteOp((yyval.action), SWFACTION_SETMEMBER);
- bufferWriteRegister((yyval.action), 0); /* a[i] */
- }
- }
- else
- {
- (yyval.action) = newBuffer();
- bufferWriteBuffer((yyval.action), (yyvsp[(1) - (2)].lval).ident);
- bufferWriteOp((yyval.action), SWFACTION_GETVARIABLE);
- bufferWriteOp((yyval.action), SWFACTION_DUP);
- bufferWriteOp((yyval.action), (yyvsp[(2) - (2)].op));
- bufferConcat((yyval.action), (yyvsp[(1) - (2)].lval).ident);
- bufferWriteOp((yyval.action), SWFACTION_SWAP);
- bufferWriteOp((yyval.action), SWFACTION_SETVARIABLE);
- }
- ;}
- break;
-
- case 251:
-#line 1330 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(2) - (3)].action); ;}
- break;
-
- case 252:
-#line 1333 "swf5compiler.y"
- { (yyval.action) = newBuffer();
- bufferWriteInt((yyval.action), -(yyvsp[(2) - (2)].intVal)); ;}
- break;
-
- case 253:
-#line 1337 "swf5compiler.y"
- { (yyval.action) = newBuffer();
- bufferWriteInt((yyval.action), (yyvsp[(1) - (1)].intVal)); ;}
- break;
-
- case 254:
-#line 1341 "swf5compiler.y"
- { (yyval.action) = newBuffer();
- bufferWriteDouble((yyval.action), -(yyvsp[(2) - (2)].doubleVal)); ;}
- break;
-
- case 255:
-#line 1345 "swf5compiler.y"
- { (yyval.action) = newBuffer();
- bufferWriteDouble((yyval.action), (yyvsp[(1) - (1)].doubleVal)); ;}
- break;
-
- case 256:
-#line 1349 "swf5compiler.y"
- { (yyval.action) = newBuffer();
- bufferWriteBoolean((yyval.action), (yyvsp[(1) - (1)].intVal)); ;}
- break;
-
- case 257:
-#line 1353 "swf5compiler.y"
- { (yyval.action) = newBuffer();
- bufferWriteNull((yyval.action)); ;}
- break;
-
- case 258:
-#line 1357 "swf5compiler.y"
- { (yyval.action) = newBuffer();
- bufferWriteString((yyval.action), (yyvsp[(1) - (1)].str), strlen((yyvsp[(1) - (1)].str))+1);
- free((yyvsp[(1) - (1)].str)); ;}
- break;
-
- case 260:
-#line 1366 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(1) - (3)].action);
- bufferConcat((yyval.action), (yyvsp[(3) - (3)].action)); ;}
- break;
-
- case 261:
-#line 1372 "swf5compiler.y"
- { (yyval.action) = newBuffer();
- bufferWriteString((yyval.action), (yyvsp[(1) - (3)].str), strlen((yyvsp[(1) - (3)].str))+1);
- bufferConcat((yyval.action), (yyvsp[(3) - (3)].action));
- bufferWriteOp((yyval.action), SWFACTION_VAREQUALS); ;}
- break;
-
- case 262:
-#line 1378 "swf5compiler.y"
- { (yyval.action) = newBuffer();
- bufferWriteString((yyval.action), (yyvsp[(1) - (1)].str), strlen((yyvsp[(1) - (1)].str))+1);
- bufferWriteOp((yyval.action), SWFACTION_VAR); ;}
- break;
-
- case 263:
-#line 1385 "swf5compiler.y"
- { asmBuffer = newBuffer(); ;}
- break;
-
- case 264:
-#line 1387 "swf5compiler.y"
- { (yyval.action) = asmBuffer; ;}
- break;
-
- case 265:
-#line 1390 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(2) - (2)].action); ;}
- break;
-
- case 267:
-#line 1395 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(1) - (1)].action);
- bufferWriteOp((yyval.action), SWFACTION_POP); ;}
- break;
-
- case 268:
-#line 1399 "swf5compiler.y"
- { (yyval.action) = (yyvsp[(1) - (1)].action);
- bufferWriteOp((yyval.action), SWFACTION_POP); ;}
- break;
-
- case 269:
-#line 1403 "swf5compiler.y"
- { if((yyvsp[(2) - (2)].lval).obj)
- {
- if((yyvsp[(2) - (2)].lval).ident)
- {
- (yyval.action) = (yyvsp[(2) - (2)].lval).obj; /* a */
- bufferWriteOp((yyval.action), SWFACTION_DUP); /* a, a */
- bufferWriteBuffer((yyval.action), (yyvsp[(2) - (2)].lval).ident); /* a, a, i */
- bufferWriteOp((yyval.action), SWFACTION_GETMEMBER); /* a, a.i */
- bufferWriteOp((yyval.action), (yyvsp[(1) - (2)].op)); /* a, a.i+1 */
- bufferConcat((yyval.action), (yyvsp[(2) - (2)].lval).ident); /* a, a.i+1, i */
- bufferWriteOp((yyval.action), SWFACTION_SWAP); /* a, i, a.i+1 */
- bufferWriteOp((yyval.action), SWFACTION_SETMEMBER); /* a.i = a.i+1 */
- }
- else
- {
- /* weird contortions so that $2.memexpr can use reg 0 */
- (yyval.action) = (yyvsp[(2) - (2)].lval).memexpr; /* i */
- bufferConcat((yyval.action), (yyvsp[(2) - (2)].lval).obj); /* i, a */
- bufferWriteSetRegister((yyval.action), 0);
- bufferWriteOp((yyval.action), SWFACTION_SWAP); /* a, i */
- bufferWriteOp((yyval.action), SWFACTION_DUP); /* a, i, i */
- bufferWriteRegister((yyval.action), 0); /* a, i, i, a */
- bufferWriteOp((yyval.action), SWFACTION_SWAP); /* a, i, a, i */
- bufferWriteOp((yyval.action), SWFACTION_GETMEMBER); /* a, i, a[i] */
- bufferWriteOp((yyval.action), (yyvsp[(1) - (2)].op)); /* a, i, a[i]+1 */
- bufferWriteOp((yyval.action), SWFACTION_SETMEMBER); /* a[i] = a[i]+1 */
- }
- }
- else
- {
- (yyval.action) = (yyvsp[(2) - (2)].lval).ident;
- bufferWriteOp((yyval.action), SWFACTION_DUP);
- bufferWriteOp((yyval.action), SWFACTION_GETVARIABLE);
- bufferWriteOp((yyval.action), (yyvsp[(1) - (2)].op));
- bufferWriteOp((yyval.action), SWFACTION_SETVARIABLE);
- }
- ;}
- break;
-
- case 270:
-#line 1442 "swf5compiler.y"
- { if((yyvsp[(1) - (2)].lval).obj)
- {
- if((yyvsp[(1) - (2)].lval).ident)
- {
- (yyval.action) = (yyvsp[(1) - (2)].lval).obj; /* a */
- bufferWriteOp((yyval.action), SWFACTION_DUP); /* a, a */
- bufferWriteBuffer((yyval.action), (yyvsp[(1) - (2)].lval).ident); /* a, a, i */
- bufferWriteOp((yyval.action), SWFACTION_GETMEMBER); /* a, a.i */
- bufferWriteOp((yyval.action), (yyvsp[(2) - (2)].op)); /* a, a.i+1 */
- bufferConcat((yyval.action), (yyvsp[(1) - (2)].lval).ident); /* a, a.i+1, i */
- bufferWriteOp((yyval.action), SWFACTION_SWAP); /* a, i, a.i+1 */
- bufferWriteOp((yyval.action), SWFACTION_SETMEMBER); /* a.i = a.i+1 */
- }
- else
- {
- /* weird contortions so that $1.memexpr can use reg 0 */
- (yyval.action) = (yyvsp[(1) - (2)].lval).memexpr; /* i */
- bufferConcat((yyval.action), (yyvsp[(1) - (2)].lval).obj); /* i, a */
- bufferWriteSetRegister((yyval.action), 0);
- bufferWriteOp((yyval.action), SWFACTION_SWAP); /* a, i */
- bufferWriteOp((yyval.action), SWFACTION_DUP); /* a, i, i */
- bufferWriteRegister((yyval.action), 0); /* a, i, i, a */
- bufferWriteOp((yyval.action), SWFACTION_SWAP); /* a, i, a, i */
- bufferWriteOp((yyval.action), SWFACTION_GETMEMBER); /* a, i, a[i] */
- bufferWriteOp((yyval.action), (yyvsp[(2) - (2)].op)); /* a, i, a[i]+1 */
- bufferWriteOp((yyval.action), SWFACTION_SETMEMBER); /* a[i] = a[i]+1 */
- }
- }
- else
- {
- (yyval.action) = (yyvsp[(1) - (2)].lval).ident;
- bufferWriteOp((yyval.action), SWFACTION_DUP);
- bufferWriteOp((yyval.action), SWFACTION_GETVARIABLE);
- bufferWriteOp((yyval.action), (yyvsp[(2) - (2)].op));
- bufferWriteOp((yyval.action), SWFACTION_SETVARIABLE);
- }
- ;}
- break;
-
- case 271:
-#line 1481 "swf5compiler.y"
- { if((yyvsp[(1) - (3)].lval).obj)
- {
- (yyval.action) = (yyvsp[(1) - (3)].lval).obj;
-
- if((yyvsp[(1) - (3)].lval).ident)
- bufferConcat((yyval.action), (yyvsp[(1) - (3)].lval).ident);
- else
- bufferConcat((yyval.action), (yyvsp[(1) - (3)].lval).memexpr);
-
- bufferConcat((yyval.action), (yyvsp[(3) - (3)].action));
- bufferWriteOp((yyval.action), SWFACTION_SETMEMBER);
- }
- else
- {
- (yyval.action) = (yyvsp[(1) - (3)].lval).ident;
- bufferConcat((yyval.action), (yyvsp[(3) - (3)].action));
- bufferWriteOp((yyval.action), SWFACTION_SETVARIABLE);
- }
- ;}
- break;
-
- case 272:
-#line 1502 "swf5compiler.y"
- { if((yyvsp[(1) - (3)].lval).obj)
- {
- if((yyvsp[(1) - (3)].lval).ident)
- {
- (yyval.action) = (yyvsp[(1) - (3)].lval).obj; /* a */
- bufferWriteOp((yyval.action), SWFACTION_DUP); /* a, a */
- bufferWriteBuffer((yyval.action), (yyvsp[(1) - (3)].lval).ident); /* a, a, i */
- bufferWriteOp((yyval.action), SWFACTION_GETMEMBER); /* a, a.i */
- bufferConcat((yyval.action), (yyvsp[(3) - (3)].action)); /* a, a.i, v */
- bufferWriteOp((yyval.action), (yyvsp[(2) - (3)].op)); /* a, a.i+v */
- bufferConcat((yyval.action), (yyvsp[(1) - (3)].lval).ident); /* a, a.i+v, i */
- bufferWriteOp((yyval.action), SWFACTION_SWAP); /* a, i, a.i+v */
- bufferWriteOp((yyval.action), SWFACTION_SETMEMBER); /* a.i = a.i+v */
- }
- else
- {
- (yyval.action) = (yyvsp[(1) - (3)].lval).memexpr; /* i */
- bufferConcat((yyval.action), (yyvsp[(1) - (3)].lval).obj); /* i, a */
- bufferWriteSetRegister((yyval.action), 0);
- bufferWriteOp((yyval.action), SWFACTION_SWAP); /* a, i */
- bufferWriteOp((yyval.action), SWFACTION_DUP); /* a, i, i */
- bufferWriteRegister((yyval.action), 0); /* a, i, i, a */
- bufferWriteOp((yyval.action), SWFACTION_SWAP); /* a, i, a, i */
- bufferWriteOp((yyval.action), SWFACTION_GETMEMBER); /* a, i, a[i] */
- bufferConcat((yyval.action), (yyvsp[(3) - (3)].action)); /* a, i, a[i], v */
- bufferWriteOp((yyval.action), (yyvsp[(2) - (3)].op)); /* a, i, a[i]+v */
- bufferWriteOp((yyval.action), SWFACTION_SETMEMBER); /* a[i] = a[i]+v */
- }
- }
- else
- {
- (yyval.action) = (yyvsp[(1) - (3)].lval).ident;
- bufferWriteOp((yyval.action), SWFACTION_DUP);
- bufferWriteOp((yyval.action), SWFACTION_GETVARIABLE);
- bufferConcat((yyval.action), (yyvsp[(3) - (3)].action));
- bufferWriteOp((yyval.action), (yyvsp[(2) - (3)].op));
- bufferWriteOp((yyval.action), SWFACTION_SETVARIABLE);
- }
- ;}
- break;
-
- case 274:
-#line 1547 "swf5compiler.y"
- { (yyval.len) = (yyvsp[(1) - (2)].len) + (yyvsp[(2) - (2)].len); ;}
- break;
-
- case 275:
-#line 1552 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer,
- SWFACTION_WITH); ;}
- break;
-
- case 276:
-#line 1554 "swf5compiler.y"
- { (yyval.len) = (yyvsp[(2) - (4)].len) + (yyvsp[(3) - (4)].len);
- bufferPatchLength(asmBuffer, (yyvsp[(3) - (4)].len)); ;}
- break;
-
- case 277:
-#line 1559 "swf5compiler.y"
- { (yyval.len) = bufferWriteConstantString(asmBuffer,(byte*) (yyvsp[(1) - (1)].str),
- strlen((yyvsp[(1) - (1)].str))+1); ;}
- break;
-
- case 278:
-#line 1562 "swf5compiler.y"
- { bufferWriteU8(asmBuffer, PUSH_INT);
- (yyval.len) = bufferWriteInt(asmBuffer, (yyvsp[(1) - (1)].intVal))+1; ;}
- break;
-
- case 279:
-#line 1565 "swf5compiler.y"
- { bufferWriteU8(asmBuffer, PUSH_DOUBLE);
- (yyval.len) = bufferWriteDouble(asmBuffer, (yyvsp[(1) - (1)].doubleVal))+1; ;}
- break;
-
- case 280:
-#line 1568 "swf5compiler.y"
- { bufferWriteU8(asmBuffer, PUSH_BOOLEAN);
- (yyval.len) = bufferWriteU8(asmBuffer, (yyvsp[(1) - (1)].intVal))+1; ;}
- break;
-
- case 281:
-#line 1571 "swf5compiler.y"
- { (yyval.len) = bufferWriteU8(asmBuffer, PUSH_NULL); ;}
- break;
-
- case 282:
-#line 1573 "swf5compiler.y"
- { bufferWriteU8(asmBuffer, PUSH_REGISTER);
- (yyval.len) = bufferWriteU8(asmBuffer,
- (char)atoi((yyvsp[(1) - (1)].str)))+1; ;}
- break;
-
- case 283:
-#line 1580 "swf5compiler.y"
- { (yyval.len) = (yyvsp[(1) - (1)].len); ;}
- break;
-
- case 284:
-#line 1581 "swf5compiler.y"
- { (yyval.len) += (yyvsp[(3) - (3)].len); ;}
- break;
-
- case 285:
-#line 1585 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer,
- SWFACTION_PUSHDATA);
- (yyval.len) += bufferWriteS16(asmBuffer, 0); ;}
- break;
-
- case 286:
-#line 1588 "swf5compiler.y"
- { (yyval.len) = (yyvsp[(2) - (3)].len) + (yyvsp[(3) - (3)].len);
- bufferPatchLength(asmBuffer, (yyvsp[(3) - (3)].len)); ;}
- break;
-
- case 288:
-#line 1594 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer,
- SWFACTION_SETREGISTER);
- (yyval.len) += bufferWriteS16(asmBuffer, 1);
- (yyval.len) += bufferWriteU8(asmBuffer,
- (char)atoi((yyvsp[(2) - (2)].str))); ;}
- break;
-
- case 289:
-#line 1600 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer,
- SWFACTION_CALLFUNCTION); ;}
- break;
-
- case 290:
-#line 1602 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer,
- SWFACTION_RETURN); ;}
- break;
-
- case 291:
-#line 1604 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer,
- SWFACTION_CALLMETHOD); ;}
- break;
-
- case 292:
-#line 1606 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer,
- SWFACTION_BITWISEAND); ;}
- break;
-
- case 293:
-#line 1608 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer,
- SWFACTION_BITWISEOR); ;}
- break;
-
- case 294:
-#line 1610 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer,
- SWFACTION_BITWISEXOR); ;}
- break;
-
- case 295:
-#line 1612 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer,
- SWFACTION_MODULO); ;}
- break;
-
- case 296:
-#line 1614 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer,
- SWFACTION_NEWADD); ;}
- break;
-
- case 297:
-#line 1616 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer,
- SWFACTION_NEWLESSTHAN); ;}
- break;
-
- case 298:
-#line 1618 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer,
- SWFACTION_NEWEQUALS); ;}
- break;
-
- case 299:
-#line 1620 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer,
- SWFACTION_INCREMENT); ;}
- break;
-
- case 300:
-#line 1622 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer,
- SWFACTION_DECREMENT); ;}
- break;
-
- case 301:
-#line 1624 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer,
- SWFACTION_TYPEOF); ;}
- break;
-
- case 302:
-#line 1626 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer,
- SWFACTION_INSTANCEOF); ;}
- break;
-
- case 303:
-#line 1628 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer,
- SWFACTION_ENUMERATE); ;}
- break;
-
- case 304:
-#line 1630 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer,
- SWFACTION_DELETE); ;}
- break;
-
- case 305:
-#line 1632 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer,
- SWFACTION_NEW); ;}
- break;
-
- case 306:
-#line 1634 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer,
- SWFACTION_INITARRAY); ;}
- break;
-
- case 307:
-#line 1636 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer,
- SWFACTION_INITOBJECT); ;}
- break;
-
- case 308:
-#line 1638 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer,
- SWFACTION_GETMEMBER); ;}
- break;
-
- case 309:
-#line 1640 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer,
- SWFACTION_SETMEMBER); ;}
- break;
-
- case 310:
-#line 1642 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer,
- SWFACTION_SHIFTLEFT); ;}
- break;
-
- case 311:
-#line 1644 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer,
- SWFACTION_SHIFTRIGHT); ;}
- break;
-
- case 312:
-#line 1646 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer,
- SWFACTION_SHIFTRIGHT2); ;}
- break;
-
- case 313:
-#line 1648 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer,
- SWFACTION_VAR); ;}
- break;
-
- case 314:
-#line 1650 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer,
- SWFACTION_VAREQUALS); ;}
- break;
-
- case 315:
-#line 1654 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer, SWFACTION_ADD); ;}
- break;
-
- case 316:
-#line 1655 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer, SWFACTION_SUBTRACT); ;}
- break;
-
- case 317:
-#line 1656 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer, SWFACTION_MULTIPLY); ;}
- break;
-
- case 318:
-#line 1657 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer, SWFACTION_DIVIDE); ;}
- break;
-
- case 319:
-#line 1658 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer, SWFACTION_EQUAL); ;}
- break;
-
- case 320:
-#line 1659 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer, SWFACTION_LESSTHAN); ;}
- break;
-
- case 321:
-#line 1660 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer, SWFACTION_LOGICALAND); ;}
- break;
-
- case 322:
-#line 1661 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer, SWFACTION_LOGICALOR); ;}
- break;
-
- case 323:
-#line 1662 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer, SWFACTION_LOGICALNOT); ;}
- break;
-
- case 324:
-#line 1663 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer, SWFACTION_STRINGEQ); ;}
- break;
-
- case 325:
-#line 1664 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer, SWFACTION_STRINGLENGTH); ;}
- break;
-
- case 326:
-#line 1665 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer, SWFACTION_SUBSTRING); ;}
- break;
-
- case 327:
-#line 1666 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer, SWFACTION_INT); ;}
- break;
-
- case 328:
-#line 1667 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer, SWFACTION_DUP); ;}
- break;
-
- case 329:
-#line 1668 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer, SWFACTION_SWAP); ;}
- break;
-
- case 330:
-#line 1669 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer, SWFACTION_POP); ;}
- break;
-
- case 331:
-#line 1670 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer, SWFACTION_GETVARIABLE); ;}
- break;
-
- case 332:
-#line 1671 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer, SWFACTION_SETVARIABLE); ;}
- break;
-
- case 333:
-#line 1672 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer, SWFACTION_SETTARGETEXPRESSION); ;}
- break;
-
- case 334:
-#line 1673 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer, SWFACTION_STRINGCONCAT); ;}
- break;
-
- case 335:
-#line 1674 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer, SWFACTION_DUPLICATECLIP); ;}
- break;
-
- case 336:
-#line 1675 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer, SWFACTION_REMOVECLIP); ;}
- break;
-
- case 337:
-#line 1676 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer, SWFACTION_TRACE); ;}
- break;
-
- case 338:
-#line 1677 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer, SWFACTION_STRINGCOMPARE); ;}
- break;
-
- case 339:
-#line 1678 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer, SWFACTION_RANDOM); ;}
- break;
-
- case 340:
-#line 1679 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer, SWFACTION_MBLENGTH); ;}
- break;
-
- case 341:
-#line 1680 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer, SWFACTION_ORD); ;}
- break;
-
- case 342:
-#line 1681 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer, SWFACTION_CHR); ;}
- break;
-
- case 343:
-#line 1682 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer, SWFACTION_GETTIMER); ;}
- break;
-
- case 344:
-#line 1683 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer, SWFACTION_MBSUBSTRING); ;}
- break;
-
- case 345:
-#line 1684 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer, SWFACTION_MBORD); ;}
- break;
-
- case 346:
-#line 1685 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer, SWFACTION_MBCHR); ;}
- break;
-
- case 347:
-#line 1688 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer, SWFACTION_BRANCHALWAYS);
- (yyval.len) += bufferWriteS16(asmBuffer, 2);
- (yyval.len) += bufferBranchTarget(asmBuffer, (yyvsp[(2) - (2)].str)); ;}
- break;
-
- case 348:
-#line 1692 "swf5compiler.y"
- { (yyval.len) = bufferWriteOp(asmBuffer, SWFACTION_BRANCHIFTRUE);
- (yyval.len) += bufferWriteS16(asmBuffer, 2);
- (yyval.len) += bufferBranchTarget(asmBuffer, (yyvsp[(2) - (2)].str)); ;}
- break;
-
-
-/* Line 1267 of yacc.c. */
-#line 5479 "swf5compiler.tab.c"
- default: break;
- }
- YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
-
- YYPOPSTACK (yylen);
- yylen = 0;
- YY_STACK_PRINT (yyss, yyssp);
-
- *++yyvsp = yyval;
-
-
- /* Now `shift' the result of the reduction. Determine what state
- that goes to, based on the state we popped back to and the rule
- number reduced by. */
-
- yyn = yyr1[yyn];
-
- yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
- if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
- yystate = yytable[yystate];
- else
- yystate = yydefgoto[yyn - YYNTOKENS];
-
- goto yynewstate;
-
-
-/*------------------------------------.
-| yyerrlab -- here on detecting error |
-`------------------------------------*/
-yyerrlab:
- /* If not already recovering from an error, report this error. */
- if (!yyerrstatus)
- {
- ++yynerrs;
-#if ! YYERROR_VERBOSE
- yyerror (YY_("syntax error"));
-#else
- {
- YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
- if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
- {
- YYSIZE_T yyalloc = 2 * yysize;
- if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
- yyalloc = YYSTACK_ALLOC_MAXIMUM;
- if (yymsg != yymsgbuf)
- YYSTACK_FREE (yymsg);
- yymsg = (char *) YYSTACK_ALLOC (yyalloc);
- if (yymsg)
- yymsg_alloc = yyalloc;
- else
- {
- yymsg = yymsgbuf;
- yymsg_alloc = sizeof yymsgbuf;
- }
- }
-
- if (0 < yysize && yysize <= yymsg_alloc)
- {
- (void) yysyntax_error (yymsg, yystate, yychar);
- yyerror (yymsg);
- }
- else
- {
- yyerror (YY_("syntax error"));
- if (yysize != 0)
- goto yyexhaustedlab;
- }
- }
-#endif
- }
-
-
-
- if (yyerrstatus == 3)
- {
- /* If just tried and failed to reuse look-ahead token after an
- error, discard it. */
-
- if (yychar <= YYEOF)
- {
- /* Return failure if at end of input. */
- if (yychar == YYEOF)
- YYABORT;
- }
- else
- {
- yydestruct ("Error: discarding",
- yytoken, &yylval);
- yychar = YYEMPTY;
- }
- }
-
- /* Else will try to reuse look-ahead token after shifting the error
- token. */
- goto yyerrlab1;
-
-
-/*---------------------------------------------------.
-| yyerrorlab -- error raised explicitly by YYERROR. |
-`---------------------------------------------------*/
-yyerrorlab:
-
- /* Pacify compilers like GCC when the user code never invokes
- YYERROR and the label yyerrorlab therefore never appears in user
- code. */
- if (/*CONSTCOND*/ 0)
- goto yyerrorlab;
-
- /* Do not reclaim the symbols of the rule which action triggered
- this YYERROR. */
- YYPOPSTACK (yylen);
- yylen = 0;
- YY_STACK_PRINT (yyss, yyssp);
- yystate = *yyssp;
- goto yyerrlab1;
-
-
-/*-------------------------------------------------------------.
-| yyerrlab1 -- common code for both syntax error and YYERROR. |
-`-------------------------------------------------------------*/
-yyerrlab1:
- yyerrstatus = 3; /* Each real token shifted decrements this. */
-
- for (;;)
- {
- yyn = yypact[yystate];
- if (yyn != YYPACT_NINF)
- {
- yyn += YYTERROR;
- if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
- {
- yyn = yytable[yyn];
- if (0 < yyn)
- break;
- }
- }
-
- /* Pop the current state because it cannot handle the error token. */
- if (yyssp == yyss)
- YYABORT;
-
-
- yydestruct ("Error: popping",
- yystos[yystate], yyvsp);
- YYPOPSTACK (1);
- yystate = *yyssp;
- YY_STACK_PRINT (yyss, yyssp);
- }
-
- if (yyn == YYFINAL)
- YYACCEPT;
-
- *++yyvsp = yylval;
-
-
- /* Shift the error token. */
- YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
-
- yystate = yyn;
- goto yynewstate;
-
-
-/*-------------------------------------.
-| yyacceptlab -- YYACCEPT comes here. |
-`-------------------------------------*/
-yyacceptlab:
- yyresult = 0;
- goto yyreturn;
-
-/*-----------------------------------.
-| yyabortlab -- YYABORT comes here. |
-`-----------------------------------*/
-yyabortlab:
- yyresult = 1;
- goto yyreturn;
-
-#ifndef yyoverflow
-/*-------------------------------------------------.
-| yyexhaustedlab -- memory exhaustion comes here. |
-`-------------------------------------------------*/
-yyexhaustedlab:
- yyerror (YY_("memory exhausted"));
- yyresult = 2;
- /* Fall through. */
-#endif
-
-yyreturn:
- if (yychar != YYEOF && yychar != YYEMPTY)
- yydestruct ("Cleanup: discarding lookahead",
- yytoken, &yylval);
- /* Do not reclaim the symbols of the rule which action triggered
- this YYABORT or YYACCEPT. */
- YYPOPSTACK (yylen);
- YY_STACK_PRINT (yyss, yyssp);
- while (yyssp != yyss)
- {
- yydestruct ("Cleanup: popping",
- yystos[*yyssp], yyvsp);
- YYPOPSTACK (1);
- }
-#ifndef yyoverflow
- if (yyss != yyssa)
- YYSTACK_FREE (yyss);
-#endif
-#if YYERROR_VERBOSE
- if (yymsg != yymsgbuf)
- YYSTACK_FREE (yymsg);
-#endif
- /* Make sure YYID is used. */
- return YYID (yyresult);
-}
-
-
-#line 1697 "swf5compiler.y"
-
-
-
+++ /dev/null
-/* A Bison parser, made by GNU Bison 2.3. */
-
-/* Skeleton interface for Bison's Yacc-like parsers in C
-
- Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
- Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA. */
-
-/* As a special exception, you may create a larger work that contains
- part or all of the Bison parser skeleton and distribute that work
- under terms of your choice, so long as that work isn't itself a
- parser generator using the skeleton or a modified version thereof
- as a parser skeleton. Alternatively, if you modify or redistribute
- the parser skeleton itself, you may (at your option) remove this
- special exception, which will cause the skeleton and the resulting
- Bison output files to be licensed under the GNU General Public
- License without this special exception.
-
- This special exception was added by the Free Software Foundation in
- version 2.2 of Bison. */
-
-/* Tokens. */
-#ifndef YYTOKENTYPE
-# define YYTOKENTYPE
- /* Put the tokens into the symbol table, so that GDB and other debuggers
- know about them. */
- enum yytokentype {
- BREAK = 258,
- CONTINUE = 259,
- FUNCTION = 260,
- ELSE = 261,
- SWITCH = 262,
- CASE = 263,
- DEFAULT = 264,
- FOR = 265,
- IN = 266,
- IF = 267,
- WHILE = 268,
- DO = 269,
- VAR = 270,
- NEW = 271,
- DELETE = 272,
- RETURN = 273,
- END = 274,
- WITH = 275,
- ASM = 276,
- EVAL = 277,
- RANDOM = 278,
- GETTIMER = 279,
- LENGTH = 280,
- CONCAT = 281,
- SUBSTR = 282,
- TRACE = 283,
- INT = 284,
- ORD = 285,
- CHR = 286,
- GETURL = 287,
- GETURL1 = 288,
- NEXTFRAME = 289,
- PREVFRAME = 290,
- PLAY = 291,
- STOP = 292,
- TOGGLEQUALITY = 293,
- STOPSOUNDS = 294,
- DUP = 295,
- SWAP = 296,
- POP = 297,
- PUSH = 298,
- SETREGISTER = 299,
- CALLFUNCTION = 300,
- CALLMETHOD = 301,
- AND = 302,
- OR = 303,
- XOR = 304,
- MODULO = 305,
- ADD = 306,
- LESSTHAN = 307,
- EQUALS = 308,
- INC = 309,
- DEC = 310,
- TYPEOF = 311,
- INSTANCEOF = 312,
- ENUMERATE = 313,
- INITOBJECT = 314,
- INITARRAY = 315,
- GETMEMBER = 316,
- SETMEMBER = 317,
- SHIFTLEFT = 318,
- SHIFTRIGHT = 319,
- SHIFTRIGHT2 = 320,
- VAREQUALS = 321,
- OLDADD = 322,
- SUBTRACT = 323,
- MULTIPLY = 324,
- DIVIDE = 325,
- OLDEQUALS = 326,
- OLDLESSTHAN = 327,
- LOGICALAND = 328,
- LOGICALOR = 329,
- NOT = 330,
- STRINGEQ = 331,
- STRINGLENGTH = 332,
- SUBSTRING = 333,
- GETVARIABLE = 334,
- SETVARIABLE = 335,
- SETTARGETEXPRESSION = 336,
- DUPLICATEMOVIECLIP = 337,
- REMOVEMOVIECLIP = 338,
- STRINGLESSTHAN = 339,
- MBLENGTH = 340,
- MBSUBSTRING = 341,
- MBORD = 342,
- MBCHR = 343,
- BRANCHALWAYS = 344,
- BRANCHIFTRUE = 345,
- GETURL2 = 346,
- POST = 347,
- GET = 348,
- LOADVARIABLES = 349,
- LOADMOVIE = 350,
- LOADVARIABLESNUM = 351,
- LOADMOVIENUM = 352,
- CALLFRAME = 353,
- STARTDRAG = 354,
- STOPDRAG = 355,
- GOTOFRAME = 356,
- SETTARGET = 357,
- NULLVAL = 358,
- INTEGER = 359,
- DOUBLE = 360,
- BOOLEAN = 361,
- REGISTER = 362,
- STRING = 363,
- IDENTIFIER = 364,
- EQ = 365,
- LE = 366,
- GE = 367,
- NE = 368,
- LAN = 369,
- LOR = 370,
- INCR = 371,
- DECR = 372,
- IEQ = 373,
- DEQ = 374,
- MEQ = 375,
- SEQ = 376,
- REQ = 377,
- AEQ = 378,
- OEQ = 379,
- SHL = 380,
- SHR = 381,
- SHR2 = 382,
- SHLEQ = 383,
- SHREQ = 384,
- SHR2EQ = 385,
- NOELSE = 386,
- UMINUS = 388,
- POSTFIX = 389
- };
-#endif
-/* Tokens. */
-#define BREAK 258
-#define CONTINUE 259
-#define FUNCTION 260
-#define ELSE 261
-#define SWITCH 262
-#define CASE 263
-#define DEFAULT 264
-#define FOR 265
-#define IN 266
-#define IF 267
-#define WHILE 268
-#define DO 269
-#define VAR 270
-#define NEW 271
-#define DELETE 272
-#define RETURN 273
-#define END 274
-#define WITH 275
-#define ASM 276
-#define EVAL 277
-#define RANDOM 278
-#define GETTIMER 279
-#define LENGTH 280
-#define CONCAT 281
-#define SUBSTR 282
-#define TRACE 283
-#define INT 284
-#define ORD 285
-#define CHR 286
-#define GETURL 287
-#define GETURL1 288
-#define NEXTFRAME 289
-#define PREVFRAME 290
-#define PLAY 291
-#define STOP 292
-#define TOGGLEQUALITY 293
-#define STOPSOUNDS 294
-#define DUP 295
-#define SWAP 296
-#define POP 297
-#define PUSH 298
-#define SETREGISTER 299
-#define CALLFUNCTION 300
-#define CALLMETHOD 301
-#define AND 302
-#define OR 303
-#define XOR 304
-#define MODULO 305
-#define ADD 306
-#define LESSTHAN 307
-#define EQUALS 308
-#define INC 309
-#define DEC 310
-#define TYPEOF 311
-#define INSTANCEOF 312
-#define ENUMERATE 313
-#define INITOBJECT 314
-#define INITARRAY 315
-#define GETMEMBER 316
-#define SETMEMBER 317
-#define SHIFTLEFT 318
-#define SHIFTRIGHT 319
-#define SHIFTRIGHT2 320
-#define VAREQUALS 321
-#define OLDADD 322
-#define SUBTRACT 323
-#define MULTIPLY 324
-#define DIVIDE 325
-#define OLDEQUALS 326
-#define OLDLESSTHAN 327
-#define LOGICALAND 328
-#define LOGICALOR 329
-#define NOT 330
-#define STRINGEQ 331
-#define STRINGLENGTH 332
-#define SUBSTRING 333
-#define GETVARIABLE 334
-#define SETVARIABLE 335
-#define SETTARGETEXPRESSION 336
-#define DUPLICATEMOVIECLIP 337
-#define REMOVEMOVIECLIP 338
-#define STRINGLESSTHAN 339
-#define MBLENGTH 340
-#define MBSUBSTRING 341
-#define MBORD 342
-#define MBCHR 343
-#define BRANCHALWAYS 344
-#define BRANCHIFTRUE 345
-#define GETURL2 346
-#define POST 347
-#define GET 348
-#define LOADVARIABLES 349
-#define LOADMOVIE 350
-#define LOADVARIABLESNUM 351
-#define LOADMOVIENUM 352
-#define CALLFRAME 353
-#define STARTDRAG 354
-#define STOPDRAG 355
-#define GOTOFRAME 356
-#define SETTARGET 357
-#define NULLVAL 358
-#define INTEGER 359
-#define DOUBLE 360
-#define BOOLEAN 361
-#define REGISTER 362
-#define STRING 363
-#define IDENTIFIER 364
-#define EQ 365
-#define LE 366
-#define GE 367
-#define NE 368
-#define LAN 369
-#define LOR 370
-#define INCR 371
-#define DECR 372
-#define IEQ 373
-#define DEQ 374
-#define MEQ 375
-#define SEQ 376
-#define REQ 377
-#define AEQ 378
-#define OEQ 379
-#define SHL 380
-#define SHR 381
-#define SHR2 382
-#define SHLEQ 383
-#define SHREQ 384
-#define SHR2EQ 385
-#define NOELSE 386
-#define UMINUS 388
-#define POSTFIX 389
-
-
-
-
-#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
-typedef union YYSTYPE
-#line 21 "swf5compiler.y"
-{
- Buffer action;
- char *str;
- SWFGetUrl2Method getURLMethod;
- int op;
- int intVal;
- int len;
- double doubleVal;
-
- struct
- {
- Buffer buffer;
- int count;
- } exprlist;
- struct switchcase switchcase;
- struct switchcases switchcases;
- struct
- {
- Buffer obj, ident, memexpr;
- } lval;
-}
-/* Line 1489 of yacc.c. */
-#line 337 "swf5compiler.tab.h"
- YYSTYPE;
-# define yystype YYSTYPE /* obsolescent; will be withdrawn */
-# define YYSTYPE_IS_DECLARED 1
-# define YYSTYPE_IS_TRIVIAL 1
-#endif
-
-extern YYSTYPE swf5lval;
-
+++ /dev/null
-/* ocr.c
-
- Part of the swftools package.
-
- Copyright (c) 2007 Matthias Kramm <kramm@quiss.org>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <unistd.h>
-#include <memory.h>
-#include "../types.h"
-#include "../mem.h"
-#include "../gfxdevice.h"
-#include "../gfxtools.h"
-#include "render.h"
-
-#include "../gocr/pnm.h"
-#include "../gocr/pgm2asc.h"
-
-typedef struct _textpage {
- char*text;
- int textpos;
- struct _textpage*next;
-} textpage_t;
-
-typedef struct _internal {
- gfxdevice_t*render;
- int pages;
-
- textpage_t*first_page;
- textpage_t*current_page;
-} internal_t;
-
-int ocr_setparameter(gfxdevice_t*dev, const char*key, const char*value)
-{
- internal_t*i = (internal_t*)dev->internal;
- return i->render->setparameter(i->render,key,value);
-}
-
-void ocr_startpage(gfxdevice_t*dev, int width, int height)
-{
- internal_t*i = (internal_t*)dev->internal;
- if(i->render) {
- fprintf(stderr, "Call endpage() before calling startpage()\n");
- return;
- }
- i->render = malloc(sizeof(gfxdevice_t));
- gfxdevice_render_init(i->render);
- i->render->startpage(i->render,width,height);
- i->pages++;
-}
-/* passthrough */
-void ocr_startclip(gfxdevice_t*dev, gfxline_t*line) { ((internal_t*)dev->internal)->render->startclip(((internal_t*)dev->internal)->render,line); }
-void ocr_endclip(gfxdevice_t*dev) { ((internal_t*)dev->internal)->render->endclip(((internal_t*)dev->internal)->render); }
-void ocr_stroke(gfxdevice_t*dev, gfxline_t*line, gfxcoord_t width, gfxcolor_t*color, gfx_capType cap_style, gfx_joinType joint_style, gfxcoord_t miterLimit) { ((internal_t*)dev->internal)->render->stroke(((internal_t*)dev->internal)->render, line, width, color, cap_style, joint_style, miterLimit); }
-void ocr_fill(gfxdevice_t*dev, gfxline_t*line, gfxcolor_t*color) { ((internal_t*)dev->internal)->render->fill(((internal_t*)dev->internal)->render, line, color); }
-void ocr_fillbitmap(gfxdevice_t*dev, gfxline_t*line, gfximage_t*img, gfxmatrix_t*matrix, gfxcxform_t*cxform) { ((internal_t*)dev->internal)->render->fillbitmap(((internal_t*)dev->internal)->render, line, img, matrix, cxform); }
-void ocr_fillgradient(gfxdevice_t*dev, gfxline_t*line, gfxgradient_t*gradient, gfxgradienttype_t type, gfxmatrix_t*matrix) { ((internal_t*)dev->internal)->render->fillgradient(((internal_t*)dev->internal)->render, line, gradient, type, matrix); }
-void ocr_addfont(gfxdevice_t*dev, gfxfont_t*font) { ((internal_t*)dev->internal)->render->addfont(((internal_t*)dev->internal)->render, font); }
-void ocr_drawchar(gfxdevice_t*dev, gfxfont_t*font, int glyphnr, gfxcolor_t*color, gfxmatrix_t*matrix) { ((internal_t*)dev->internal)->render->drawchar(((internal_t*)dev->internal)->render, font, glyphnr, color, matrix); }
-void ocr_drawlink(gfxdevice_t*dev, gfxline_t*line, const char*action) { ((internal_t*)dev->internal)->render->drawlink(((internal_t*)dev->internal)->render, line, action); }
-
-void ocr_result_write(gfxresult_t*r, int filedesc)
-{
- textpage_t*i= (textpage_t*)r->internal;
-}
-int ocr_result_save(gfxresult_t*r, const char*filename)
-{
- textpage_t*i= (textpage_t*)r->internal;
- if(!i) {
- return 0; // no pages drawn
- }
- FILE*fi = fopen(filename, "wb");
- if(!fi)
- return 0;
- while(i) {
- fwrite(i->text, i->textpos, 1, fi);
- i = i->next;
- }
- fclose(fi);
- return 1;
-}
-
-void*ocr_result_get(gfxresult_t*r, const char*name)
-{
- textpage_t*i= (textpage_t*)r->internal;
- if(!strcmp(name,"text")) {
- textpage_t*j = i;
- int len = 0;
- while(j) {
- len += i->textpos;
- j = j->next;
- }
- char*text = (char*)malloc(len);
- int pos = 0;
- j = i;
- while(j) {
- memcpy(&text[pos], i->text, i->textpos);
- pos += i->textpos;
- j = j->next;
- }
- text[pos] = 0;
- return text;
- } else if(!strncmp(name,"page",4)) {
- int pagenr = atoi(&name[4]);
- if(pagenr<0)
- pagenr=0;
- while(pagenr>0) {
- i = i->next;
- if(!i)
- return 0;
- pagenr++;
- }
- i->text[i->textpos] = 0;
- return strdup(i->text);
- }
- return 0;
-}
-void ocr_result_destroy(gfxresult_t*r)
-{
- textpage_t*i= (textpage_t*)r->internal;
- int t;
- r->internal = 0;
- while(i) {
- textpage_t*next = i->next;
- free(i->text);i->text = 0;
- free(i);
- i = next;
- }
- free(r);
-}
-
-job_t*JOB;
-
-void ocr_endpage(gfxdevice_t*dev)
-{
- internal_t*i = (internal_t*)dev->internal;
- i->render->endpage(i->render);
-
- gfxdevice_t*out = i->render;
- gfxresult_t* r = out->finish(out);
- free(i->render);i->render = 0;
-
- gfximage_t*img = (gfximage_t*)r->get(r, "page");
-
- job_t job;
- JOB = &job;
-
- job_init(&job);
- job.cfg.out_format=UTF8;
-
- job.src.fname = "<none>";
- job.src.p.p = malloc(img->width*img->height);
- job.src.p.bpp = 1;
- job.src.p.x = img->width;
- job.src.p.y = img->height;
- int size=img->width*img->height;
- int t;
- for(t=0;t<size;t++) {
- job.src.p.p[t] = (img->data[t].r+img->data[t].g+img->data[t].b)/3;
- }
-
- pgm2asc(&job);
-
- int linecounter;
- const char *line = 0;
- int len = 0;
- linecounter = 0;
- line = getTextLine(linecounter++);
- while (line) {
- len += strlen(line)+1;
- line = getTextLine(linecounter++);
- }
-
- textpage_t*page = malloc(sizeof(textpage_t));
- page->next = 0;
- page->text = malloc(len+1);
- page->textpos = 0;
- if(!i->first_page) {
- i->first_page = i->current_page = page;
- } else {
- i->current_page->next = page;
- i->current_page = page;
- }
-
- linecounter = 0;
- line = getTextLine(linecounter++);
- while (line) {
- int l = strlen(line);
- memcpy(&page->text[page->textpos], line, l);
- page->textpos += l;
- page->text[page->textpos++] = '\n';
-
- line = getTextLine(linecounter++);
- }
- page->text[page->textpos++] = 0;
-
- free_textlines();
-
- job_free(&job);JOB=0;
-
- r->destroy(r);
-}
-
-gfxresult_t* ocr_finish(gfxdevice_t*dev)
-{
- internal_t*i = (internal_t*)dev->internal;
-
- gfxresult_t*r = (gfxresult_t*)rfx_calloc(sizeof(gfxresult_t));
-
- r->internal = i->first_page;
- r->write = ocr_result_write;
- r->save = ocr_result_save;
- r->get = ocr_result_get;
- r->destroy = ocr_result_destroy;
-
- free(dev->internal); dev->internal = 0; i = 0;
-
- return r;
-}
-
-void gfxdevice_ocr_init(gfxdevice_t*dev, gfxdevice_t*out)
-{
- internal_t*i = (internal_t*)rfx_calloc(sizeof(internal_t));
- memset(dev, 0, sizeof(gfxdevice_t));
-
- dev->name = "ocr";
-
- dev->internal = i;
-
- dev->setparameter = ocr_setparameter;
- dev->startpage = ocr_startpage;
- dev->startclip = ocr_startclip;
- dev->endclip = ocr_endclip;
- dev->stroke = ocr_stroke;
- dev->fill = ocr_fill;
- dev->fillbitmap = ocr_fillbitmap;
- dev->fillgradient = ocr_fillgradient;
- dev->addfont = ocr_addfont;
- dev->drawchar = ocr_drawchar;
- dev->drawlink = ocr_drawlink;
- dev->endpage = ocr_endpage;
- dev->finish = ocr_finish;
-
- i->pages = 0;
-}
-
+++ /dev/null
-/* ocr.h
- Header file for ocr.c
-
- Part of the swftools package.
-
- Copyright (c) 2008 Matthias Kramm <kramm@quiss.org>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-#ifndef __gfxdevice_ocr_h__
-#define __gfxdevice_ocr_h__
-
-#include "../gfxdevice.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void gfxdevice_ocr_init(gfxdevice_t*dev);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //__gfxdevice_ocr_h__
+++ /dev/null
-/* polyops.c
-
- Part of the swftools package.
-
- Copyright (c) 2008 Matthias Kramm <kramm@quiss.org>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdarg.h>
-#ifndef WIN32
-#include <unistd.h>
-#endif
-#include <memory.h>
-#include <assert.h>
-#include <string.h>
-#include <math.h>
-#include "../mem.h"
-#include "../gfxdevice.h"
-#include "../gfxtools.h"
-#include "../gfxpoly.h"
-#include "../log.h"
-#include "polyops.h"
-
-typedef struct _clip {
- gfxpoly_t*poly;
- int openclips;
- struct _clip*next;
-} clip_t;
-
-typedef struct _internal {
- gfxdevice_t*out;
- clip_t*clip;
- gfxpoly_t*polyunion;
-
- int good_polygons;
- int bad_polygons;
-} internal_t;
-
-static int verbose = 0;
-
-static void dbg(char*format, ...)
-{
- if(!verbose)
- return;
- char buf[1024];
- int l;
- va_list arglist;
- va_start(arglist, format);
- vsprintf(buf, format, arglist);
- va_end(arglist);
- l = strlen(buf);
- while(l && buf[l-1]=='\n') {
- buf[l-1] = 0;
- l--;
- }
- printf("(device-polyops) %s\n", buf);
- fflush(stdout);
-}
-
-int polyops_setparameter(struct _gfxdevice*dev, const char*key, const char*value)
-{
- dbg("polyops_setparameter");
- internal_t*i = (internal_t*)dev->internal;
- if(i->out) return i->out->setparameter(i->out,key,value);
- else return 0;
-}
-
-void polyops_startpage(struct _gfxdevice*dev, int width, int height)
-{
- dbg("polyops_startpage");
- internal_t*i = (internal_t*)dev->internal;
- if(i->out) i->out->startpage(i->out,width,height);
-}
-
-void polyops_startclip(struct _gfxdevice*dev, gfxline_t*line)
-{
- dbg("polyops_startclip");
- internal_t*i = (internal_t*)dev->internal;
-
- gfxpoly_t* oldclip = i->clip?i->clip->poly:0;
- gfxpoly_t* poly = gfxpoly_fillToPoly(line);
- if(poly)
- i->good_polygons++;
- else
- i->bad_polygons++;
-
- gfxpoly_t* currentclip = 0;
- int type = 0;
-
- /* we can't rely on gfxpoly actually being able to convert
- a gfxline into a gfxpoly- for polygons which are too
- complex or just degenerate, this might fail. So handle
- all the cases where polygon conversion or intersection
- might go awry */
- if(!poly && !oldclip) {
- i->out->startclip(i->out,line);
- currentclip = 0;
- type = 1;
- } else if(!poly && oldclip) {
- gfxline_t*oldclipline = gfxpoly_to_gfxline(oldclip);
- i->out->startclip(i->out,oldclipline);
- i->out->startclip(i->out,line);
- currentclip = 0;
- type = 2;
- } else if(poly && oldclip) {
- gfxpoly_t*intersection = gfxpoly_intersect(poly, oldclip);
- if(intersection) {
- i->good_polygons++;
- // this case is what usually happens
- gfxpoly_free(poly);poly=0;
- currentclip = intersection;
- type = 0;
- } else {
- i->bad_polygons++;
- gfxline_t*oldclipline = gfxpoly_to_gfxline(oldclip);
- i->out->startclip(i->out, oldclipline);
- currentclip = poly;
- type = 1;
- }
- } else if(poly && !oldclip) {
- currentclip = poly;
- type = 0;
- }
-
- clip_t*n = i->clip;
- i->clip = (clip_t*)rfx_calloc(sizeof(clip_t));
- i->clip->next = n;
- i->clip->poly = currentclip;
- i->clip->openclips = type;
-}
-
-void polyops_endclip(struct _gfxdevice*dev)
-{
- dbg("polyops_endclip");
- internal_t*i = (internal_t*)dev->internal;
-
- if(!i->clip) {
- msg("<error> endclip without startclip (in: polyops)\n");
- return;
- }
-
- clip_t*old = i->clip;
- i->clip = i->clip->next;
- if(old->poly) {
- gfxpoly_free(old->poly);old->poly = 0;
- }
- int t;
- for(t=0;t<old->openclips;t++)
- i->out->endclip(i->out);
-
- old->next = 0;free(old);
-}
-
-static void addtounion(struct _gfxdevice*dev, gfxpoly_t*poly)
-{
- internal_t*i = (internal_t*)dev->internal;
- if(poly && i->polyunion) {
- gfxpoly_t*old = i->polyunion;
- gfxpoly_t*newpoly = gfxpoly_union(poly,i->polyunion);
- i->polyunion = newpoly;
- gfxpoly_free(old);
- }
-}
-
-static gfxline_t* handle_poly(gfxdevice_t*dev, gfxpoly_t*poly, char*ok)
-{
- internal_t*i = (internal_t*)dev->internal;
- if(i->clip && i->clip->poly) {
- gfxpoly_t*old = poly;
- if(poly) {
- poly = gfxpoly_intersect(poly, i->clip->poly);
- gfxpoly_free(old);
- }
- }
-
- if(poly)
- i->good_polygons++;
- else
- i->bad_polygons++;
-
- addtounion(dev, poly);
- gfxline_t*gfxline = 0;
- if(poly) {
- // this is the case where everything went right
- gfxline_t*line = gfxpoly_to_gfxline(poly);
- gfxpoly_free(poly);
- *ok = 1;
- return line;
- } else {
- if(i->clip && i->clip->poly) {
- /* convert current clipping from a polygon to an
- actual "startclip" written to the output */
- assert(i->clip->openclips <= 1);
- gfxline_t*clipline = gfxpoly_to_gfxline(i->clip->poly);
- i->out->startclip(i->out, clipline);
- gfxline_free(clipline);
- gfxpoly_free(i->clip->poly);i->clip->poly = 0;
- i->clip->openclips++;
- return 0;
- } else {
- return 0;
- }
- }
-}
-
-void polyops_stroke(struct _gfxdevice*dev, gfxline_t*line, gfxcoord_t width, gfxcolor_t*color, gfx_capType cap_style, gfx_joinType joint_style, gfxcoord_t miterLimit)
-{
- dbg("polyops_stroke");
- internal_t*i = (internal_t*)dev->internal;
-
- gfxpoly_t* poly = gfxpoly_strokeToPoly(line, width, cap_style, joint_style, miterLimit);
- char ok = 0;
- gfxline_t*line2 = handle_poly(dev, poly, &ok);
-
- if(ok) {
- if(i->out && line2) i->out->fill(i->out, line2, color);
- gfxline_free(line2);
- } else {
- msg("<error> ..");
- if(i->out) i->out->stroke(i->out, line, width, color, cap_style, joint_style, miterLimit);
- }
-}
-
-void polyops_fill(struct _gfxdevice*dev, gfxline_t*line, gfxcolor_t*color)
-{
- dbg("polyops_fill");
- internal_t*i = (internal_t*)dev->internal;
-
- gfxpoly_t*poly = gfxpoly_fillToPoly(line);
- char ok = 0;
- gfxline_t*line2 = handle_poly(dev, poly, &ok);
-
- if(ok) {
- if(i->out && line2) i->out->fill(i->out, line2, color);
- gfxline_free(line2);
- } else {
- if(i->out) i->out->fill(i->out, line, color);
- }
-}
-
-void polyops_fillbitmap(struct _gfxdevice*dev, gfxline_t*line, gfximage_t*img, gfxmatrix_t*matrix, gfxcxform_t*cxform)
-{
- dbg("polyops_fillbitmap");
- internal_t*i = (internal_t*)dev->internal;
-
- gfxpoly_t*poly = gfxpoly_fillToPoly(line);
- char ok = 0;
- gfxline_t*line2 = handle_poly(dev, poly, &ok);
-
- if(ok) {
- if(i->out && line2) i->out->fillbitmap(i->out, line2, img, matrix, cxform);
- gfxline_free(line2);
- } else {
- if(i->out) i->out->fillbitmap(i->out, line, img, matrix, cxform);
- }
-}
-
-void polyops_fillgradient(struct _gfxdevice*dev, gfxline_t*line, gfxgradient_t*gradient, gfxgradienttype_t type, gfxmatrix_t*matrix)
-{
- dbg("polyops_fillgradient");
- internal_t*i = (internal_t*)dev->internal;
-
- gfxpoly_t*poly = gfxpoly_fillToPoly(line);
- char ok = 0;
- gfxline_t*line2 = handle_poly(dev, poly, &ok);
-
- if(ok) {
- if(i->out && line2) i->out->fillgradient(i->out, line2, gradient, type, matrix);
- gfxline_free(line2);
- } else {
- if(i->out) i->out->fillgradient(i->out, line, gradient, type, matrix);
- }
-}
-
-void polyops_addfont(struct _gfxdevice*dev, gfxfont_t*font)
-{
- dbg("polyops_addfont");
- internal_t*i = (internal_t*)dev->internal;
- if(i->out) i->out->addfont(i->out, font);
-}
-
-void polyops_drawchar(struct _gfxdevice*dev, gfxfont_t*font, int glyphnr, gfxcolor_t*color, gfxmatrix_t*matrix)
-{
- dbg("polyops_drawchar");
- if(!font)
- return;
- internal_t*i = (internal_t*)dev->internal;
- gfxline_t*glyph = gfxline_clone(font->glyphs[glyphnr].line);
- gfxline_transform(glyph, matrix);
-
- if(i->clip && i->clip->poly) {
- gfxbbox_t bbox = gfxline_getbbox(glyph);
- gfxpoly_t*dummybox = gfxpoly_createbox(bbox.xmin,bbox.ymin,bbox.xmax,bbox.ymax);
-
- char ok=0;
- gfxline_t*gfxline = handle_poly(dev, dummybox, &ok);
- if(ok) {
- gfxbbox_t bbox2 = gfxline_getbbox(gfxline);
- double w = bbox2.xmax - bbox2.xmin;
- double h = bbox2.ymax - bbox2.ymin;
- if(w < 0.001 || h < 0.001) /* character was clipped completely */ {
- } else if(fabs((bbox.xmax - bbox.xmin) - w) > 0.05 ||
- fabs((bbox.ymax - bbox.ymin) - h) > 0.05) {
- /* notable change in character size: character was clipped
- TODO: how to deal with diagonal cuts?
- */
- polyops_fill(dev, glyph, color);
- } else {
- if(i->out) i->out->drawchar(i->out, font, glyphnr, color, matrix);
- }
- } else {
- if(i->out) i->out->drawchar(i->out, font, glyphnr, color, matrix);
- }
- } else {
- if(i->out) i->out->drawchar(i->out, font, glyphnr, color, matrix);
- }
-
- gfxline_free(glyph);
-}
-
-void polyops_drawlink(struct _gfxdevice*dev, gfxline_t*line, const char*action)
-{
- dbg("polyops_drawlink");
- internal_t*i = (internal_t*)dev->internal;
- if(i->out) i->out->drawlink(i->out, line, action);
-}
-
-void polyops_endpage(struct _gfxdevice*dev)
-{
- dbg("polyops_endpage");
- internal_t*i = (internal_t*)dev->internal;
- if(i->out) i->out->endpage(i->out);
-}
-
-gfxresult_t* polyops_finish(struct _gfxdevice*dev)
-{
- dbg("polyops_finish");
- internal_t*i = (internal_t*)dev->internal;
-
-
- if(i->polyunion) {
- gfxpoly_free(i->polyunion);i->polyunion=0;
- } else {
- if(i->bad_polygons) {
- msg("<notice> --flatten success rate: %.1f%% (%d failed polygons)", i->good_polygons*100.0 / (i->good_polygons + i->bad_polygons), i->bad_polygons);
- }
- }
- if(i->out) {
- return i->out->finish(i->out);
- } else {
- return 0;
- }
-}
-
-gfxline_t*gfxdevice_union_getunion(struct _gfxdevice*dev)
-{
- internal_t*i = (internal_t*)dev->internal;
- return gfxpoly_to_gfxline(i->polyunion);
-}
-
-void gfxdevice_removeclippings_init(gfxdevice_t*dev, gfxdevice_t*out)
-{
- dbg("gfxdevice_removeclippings_init");
- internal_t*i = (internal_t*)rfx_calloc(sizeof(internal_t));
- memset(dev, 0, sizeof(gfxdevice_t));
-
- dev->name = "removeclippings";
-
- dev->internal = i;
-
- dev->setparameter = polyops_setparameter;
- dev->startpage = polyops_startpage;
- dev->startclip = polyops_startclip;
- dev->endclip = polyops_endclip;
- dev->stroke = polyops_stroke;
- dev->fill = polyops_fill;
- dev->fillbitmap = polyops_fillbitmap;
- dev->fillgradient = polyops_fillgradient;
- dev->addfont = polyops_addfont;
- dev->drawchar = polyops_drawchar;
- dev->drawlink = polyops_drawlink;
- dev->endpage = polyops_endpage;
- dev->finish = polyops_finish;
-
- i->out = out;
- i->polyunion = 0;
-}
-
-void gfxdevice_union_init(gfxdevice_t*dev,gfxdevice_t*out)
-{
- dbg("gfxdevice_getunion_init");
- internal_t*i = (internal_t*)rfx_calloc(sizeof(internal_t));
- memset(dev, 0, sizeof(gfxdevice_t));
-
- dev->name = "union";
-
- dev->internal = i;
-
- dev->setparameter = polyops_setparameter;
- dev->startpage = polyops_startpage;
- dev->startclip = polyops_startclip;
- dev->endclip = polyops_endclip;
- dev->stroke = polyops_stroke;
- dev->fill = polyops_fill;
- dev->fillbitmap = polyops_fillbitmap;
- dev->fillgradient = polyops_fillgradient;
- dev->addfont = polyops_addfont;
- dev->drawchar = polyops_drawchar;
- dev->drawlink = polyops_drawlink;
- dev->endpage = polyops_endpage;
- dev->finish = polyops_finish;
-
- i->out = out;
- i->polyunion = gfxpoly_strokeToPoly(0, 0, gfx_capButt, gfx_joinMiter, 0);
-}
-
+++ /dev/null
-/* gfxdevice_polyops.h
- Header file for gfxdevice_polyops.c
-
- Part of the swftools package.
-
- Copyright (c) 2008 Matthias Kramm <kramm@quiss.org>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-#ifndef __gfxdevice_polyops_h__
-#define __gfxdevice_polyops_h__
-
-#include "../gfxdevice.h"
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void gfxdevice_removeclippings_init(gfxdevice_t*self, gfxdevice_t*dest);
-void gfxdevice_union_init(gfxdevice_t*self, gfxdevice_t*dest);
-gfxline_t*gfxdevice_union_getunion(struct _gfxdevice*dev);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //__gfxdevice_polyops_h__
+++ /dev/null
-/*
-This is a Optical-Character-Recognition program
-Copyright (C) 2000-2006 Joerg Schulenburg
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- see README for EMAIL address
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "gocr.h"
-#include "pnm.h"
-#include "pgm2asc.h"
-#include <string.h>
-#include <time.h>
-
-#define Blen 256
-
-// load boxes from database into boxlist (for faster access)
-// used as alternate engine, comparing chars with database
-int load_db(void) {
- FILE *f1;
- char s1[Blen+1],
- s2[Blen+1] = "./db/", /* ToDo: replace by constant! by configure */
- *s3;
- int i, j, ii, i2, line;
- struct box *box1;
- pix *pp;
-
- if( JOB->cfg.db_path ) strncpy(s2,JOB->cfg.db_path,Blen-1);
- i2=strlen(s2);
- if (JOB->cfg.verbose)
- fprintf(stderr, "# load database %s %s ... ",s2,JOB->cfg.db_path);
-
- strncpy(s2+i2,"db.lst",Blen-i2);s2[Blen]=0;
- f1 = fopen(s2, "r");
- if (!f1) {
- fprintf(stderr, " DB %s not found\n",s2);
- return 1;
- }
-
- line = 0; /* line counter for better error report */
- for (ii = 0; !feof(f1); ii++) {
-/* bbg: should write a better input routine */
- if (!fgets(s1, Blen, f1)) break; line++;
- j = strlen(s1);
- /* remove carriage return sequences from line */
- while (j > 0 && (s1[j - 1] == '\r' || s1[j - 1] == '\n'))
- s1[--j] = 0;
- if (!j) continue; /* skip empty line */
- if (s1[0]=='#') continue; /* skip comments (v0.44) */
- /* copy file name */
- for (i = 0; i < j && i+i2 < Blen && strchr(" \t,;",s1[i]) == 0; i++)
- s2[i2 + i] = s1[i];
- s2[i2+i]=0;
- /* skip spaces */
- for (; i < j && strchr(" \t",s1[i]) != 0; i++);
- /* by now: read pix, fill box, goto next ??? */
- pp = (pix *)malloc(sizeof(pix));
- if( !pp ) fprintf(stderr,"malloc error in load_db pix\n");
-
- //readpgm(s2, pp, 0 * JOB->cfg.verbose);
- fprintf(stderr, "Can't call readpgm()\n");
-
- box1 = (struct box *)malloc_box(NULL);
- if(!box1) fprintf(stderr,"malloc error in load_db box1\n");
- box1->x0 = 0;
- box1->x1 = pp->x-1; // white border 1 pixel width
- box1->y0 = 0;
- box1->y1 = pp->y-1;
- box1->x = 1;
- box1->y = 1;
- box1->dots = 0;
- box1->c = 0;
- box1->modifier = 0; /* ToDo: obsolete */
- box1->tas[0]=NULL;
- box1->tac[0]=0;
- box1->wac[0]=100; /* really 100% sure? */
- box1->num_ac=1;
- if (s1[i]=='"'){ /* parse a string */
- j=strrchr(s1+i+1,'"')-(s1+i+1); /* we only look for first and last "" */
- if (j>=1) {
- s3=(char *)malloc(j+1);
- if (!s3) fprintf (stderr, "malloc error in load_db s3\n");
- if (s3) {
- memcpy(s3,s1+i+1,j);
- s3[j]=0;
- box1->tas[0]=s3;
- // fprintf(stderr,"\nstring=%s",s3);
- }
- } else { fprintf(stderr,"load_db: string parse error L%d\n",line); }
- } else {
- box1->tac[0] = box1->c = s1[i]; /* try to interpret as ASCII */
- /* we can live without hexcode in future if we use UTF8-strings */
- s3=s1+i;
- j=strtol( s1+i, &s3, 16); /* try to read 4 to 8 digit hex unicode */
- /* if its an hexcode, ASCII interpretation is overwritten */
- if( j && i+3<=Blen && s3-s1-i>3 ) box1->tac[0] = box1->c = j;
- // fprintf(stderr,"\nhexcode=%04x=%04x %d",(int)j,(int)box1->c,s3-s1-i);
- }
- box1->num = 0;
- box1->line = -1;
- box1->m1 = 0; /* ToDo: should be given too in the database! */
- box1->m2 = 0;
- box1->m3 = 0;
- box1->m4 = 0;
- box1->p = pp;
- list_app(&JOB->tmp.dblist, box1); // append to list
-#if 0
- out_x(box1);
-#endif
- }
- fclose(f1);
- if (JOB->cfg.verbose)
- fprintf(stderr, " %d chars loaded\n", ii);
- return 0;
-}
-
-// expand database from box/boxlist name=db_$utime.pbm
-// this is added in version v0.3.3
-int store_db(struct box *box1) {
- FILE *f1;
- char s2[Blen+1] = "./db/", s3[Blen+1];
- int i2, dx, dy;
- pix b; /* temporary mini page */
-
- if( JOB->cfg.db_path ) strncpy(s2,JOB->cfg.db_path,Blen-1);
- i2=strlen(s2);
-
- /* name generation can cause problems, if called twice within a second */
- if (box1->num_ac && box1->tas[0])
- sprintf(s3,"db_%04x_%lu.pbm", (unsigned int)box1->tas[0][0],
- (unsigned long)time(NULL));
- else
- sprintf(s3,"db_%04x_%lu.pbm", (unsigned int)box1->c,
- (unsigned long)time(NULL));
- /* ToDo: the file name may be not unique */
- strncpy(s2+i2,"db.lst",Blen-i2);s2[Blen]=0;
- f1 = fopen(s2, "a");
- if (!f1) {
- fprintf(stderr, " could not access %s\n",s2);
- return 1;
- }
- strncpy(s2+i2,s3,strlen(s3)); s2[i2+strlen(s3)]=0;
- /* store image and infos about the char */
- /* ToDo: store the vector list instead of the pixelarray */
-
- if (JOB->cfg.verbose)
- fprintf(stderr, "store_db: add file %s to database\n#",s3);
- dx=box1->x1-box1->x0+1;
- dy=box1->y1-box1->y0+1;
- b.p = (unsigned char *) malloc( dx * dy );
- if( !b.p ){
- fprintf( stderr, "\nFATAL: malloc failed, skip store_db" );
- return 2;
- }
- if (copybox(box1->p, box1->x0, box1->y0, dx, dy, &b, dx * dy))
- return -1;
-
- //writepbm(s2,&b); /* What is to do on error? */
-
- free(b.p);
-
- /* store the database line */
- /* some infos about box1->m1,..,m4 should added (base line, high etc.) */
- if (box1->num_ac && box1->tas[0]) {
- fprintf(f1, "%s \"%s\"\n",s3,box1->tas[0]);
- /* ToDo: what if tas contains '"'? */
- } else {
- if( (box1->c >= '0' && box1->c <= '9')
- || (box1->c >= 'A' && box1->c <= 'Z')
- || (box1->c >= 'a' && box1->c <= 'z') )
- fprintf(f1, "%s %c\n",s3,(char)box1->c);
- else {
- if (((box1->c)>>16)>>16)
- fprintf(f1, "%s %08x\n",s3,(unsigned int)box1->c);
- else
- fprintf(f1, "%s %04x\n",s3,(unsigned int)box1->c);
- }
- }
- fclose(f1);
- return 0;
-}
-
-/* function is only for user prompt on console to identify chars
- it prints out a part of pixmap b at point x0,y0 to stderr
- using dots .,; if no pixel, and @xoO for pixels
- */
-void out_env(struct box *px ){
- int x0,y0,x1,y1,dx,dy,x,y,x2,y2,yy0,tx,ty,i,cs;
- char c1, c2; pix *b;
- cs=JOB->cfg.cs;
- yy0=px->y0;
- { /* overwrite rest of arguments */
- b=px->p;
- x0=px->x0; x1=px->x1; dx=x1-x0+1;
- y0=px->y0; y1=px->y1; dy=y1-y0+1;
- y0-=2; y1+=2;
- if (px->m4 && y0>px->m1) y0=px->m1;
- if (px->m4 && y1<px->m4) y1=px->m4;
- if (x1-x0+1<52) { x0-=10; x1+=10; } /* fragment? expand frame */
- if (x1-x0+1<52) { x0-=10; x1+=10; } /* fragment? expand frame */
- if (x1-x0+1<62) { x0-=5; x1+=5; }
- if (y1-y0+1<10) { y0-= 4; y1+= 4; } /* fragment? */
- if (x0<0) x0=0; if (x1>=b->x) x1=b->x-1;
- if (y0<0) y0=0; if (y1>=b->y) y1=b->y-1;
- dx=x1-x0+1;
- dy=y1-y0+1; yy0=y0;
- fprintf(stderr,"\n# show box + environment");
- fprintf(stderr,"\n# show box x= %4d %4d d= %3d %3d r= %d %d",
- px->x0, px->y0, px->x1 - px->x0 + 1, px->y1 - px->y0 + 1,
- px->x - px->x0, px->y - px->y0);
- if (px->num_ac){ /* output table of chars and its probabilities */
- fprintf(stderr,"\n# list box char: ");
- for(i=0;i<px->num_ac && i<NumAlt;i++)
- /* output the (xml-)string (picture position, barcodes, glyphs, ...) */
- if (px->tas[i])
- fprintf(stderr," %s(%d)", px->tas[i] ,px->wac[i]);
- else
- fprintf(stderr," %s(%d)",decode(px->tac[i],ASCII),px->wac[i]);
- }
- fprintf(stderr,"\n");
- if (px->dots && px->m2 && px->m1<y0) { yy0=px->m1; dy=px->y1-yy0+1; }
- }
- tx=dx/80+1;
- ty=dy/40+1; // step, usually 1, but greater on large maps
- fprintf(stderr,"# show pattern x= %4d %4d d= %3d %3d t= %d %d\n",
- x0,y0,dx,dy,tx,ty);
- if (dx>0)
- for(y=yy0;y<yy0+dy;y+=ty) { /* reduce the output to max 78x40 */
-
- /* image is the boxframe + environment in the original bitmap */
- for(x=x0;x<x0+dx;x+=tx){ /* by merging sub-pixels */
- c1='.';
- for(y2=y;y2<y+ty && y2<y0+dy;y2++) /* sub-pixels */
- for(x2=x;x2<x+tx && x2<x0+dx;x2++)
- { if((getpixel(b,x2,y2)<cs)) c1='#'; }
- // show pixels outside the box thinner/weaker
- if (x+tx-1 < px->x0 || x > px->x1
- || y+ty-1 < px->y0 || y > px->y1) c1=((c1=='#')?'O':',');
- fprintf(stderr,"%c", c1 );
- }
-
- c1=c2=' ';
- /* mark lines with < */
- if (px) if (y==px->m1 || y==px->m2 || y==px->m3 || y==px->m4) c1='<';
- if (y==px->y0 || y==px->y1) c2='-'; /* boxmarks */
- fprintf(stderr,"%c%c\n",c1,c2);
- }
-}
-
-
-/*
-// second variant, for database (with slightly other behaviour)
-// new variant
-// look at the environment of the pixel too (contrast etc.)
-// detailed analysis only of diff pixels!
-//
-// 100% * distance, 0 is best fit
-// = similarity of 2 chars for recognition of noisy chars
-// weigth of pixels with only one same neighbour set to 0
-// look at contours too!
- ToDo: especially on small boxes distance should only be 0 if
- characters are 100% identical!
-*/
-// #define DEBUG 2
-int distance2( pix *p1, struct box *box1,
- pix *p2, struct box *box2, int cs){
- int rc=0,x,y,v1,v2,i1,i2,rgood=0,rbad=0,
- x1,y1,x2,y2,dx,dy,dx1,dy1,dx2,dy2,tx,ty;
-#if DEBUG == 2
- if(JOB->cfg.verbose)
- fprintf(stderr," DEBUG: distance2\n");
-#endif
- x1=box1->x0;y1=box1->y0;x2=box2->x0;y2=box2->y0;
- dx1=box1->x1-box1->x0+1; dx2=box2->x1-box2->x0+1; dx=((dx1>dx2)?dx1:dx2);dx=dx1;
- dy1=box1->y1-box1->y0+1; dy2=box2->y1-box2->y0+1; dy=((dy1>dy2)?dy1:dy2);dy=dy1;
- if(abs(dx1-dx2)>1+dx/16 || abs(dy1-dy2)>1+dy/16) rbad++; // how to weight?
- // compare relations to baseline and upper line
- if(box1->m4>0 && box2->m4>0){ // used ???
- if(2*box1->y1>box1->m3+box1->m4 && 2*box2->y1<box2->m3+box2->m4) rbad+=128;
- if(2*box1->y0>box1->m1+box1->m2 && 2*box2->y0<box2->m1+box2->m2) rbad+=128;
- }
- tx=dx/16; if(dx<17)tx=1; // raster
- ty=dy/32; if(dy<33)ty=1;
- // compare pixels
- for( y=0;y<dy;y+=ty )
- for( x=0;x<dx;x+=tx ) { // try global shift too ???
- v1=((getpixel(p1,x1+x*dx1/dx,y1+y*dy1/dy)<cs)?1:0); i1=8; // better gray?
- v2=((getpixel(p2,x2+x*dx2/dx,y2+y*dy2/dy)<cs)?1:0); i2=8; // better gray?
- if(v1==v2) { rgood+=16; continue; } // all things are right!
- // what about different pixel???
- // test overlapp of surounding pixels ???
- v1=1; rbad+=4;
- v1=-1;
- for(i1=-1;i1<2;i1++)
- for(i2=-1;i2<2;i2++)if(i1!=0 || i2!=0){
- if( ((getpixel(p1,x1+x*dx1/dx+i1*(1+dx1/32),y1+y*dy1/dy+i2*(1+dy1/32))<cs)?1:0)
- !=((getpixel(p2,x2+x*dx2/dx+i1*(1+dx2/32),y2+y*dy2/dy+i2*(1+dy2/32))<cs)?1:0) ) v1++;
- }
- if(v1>0)
- rbad+=16*v1;
- }
- if(rgood+rbad) rc= 100*rbad/(rgood+rbad); else rc=99;
- /* if width/high is not correct add badness */
- rc += ( abs(dx1*dy2-dx2*dy1) * 10 ) / (dy1*dy2);
- if (rc>100) rc=100;
- if(/* rc<10 && */ JOB->cfg.verbose /* &1024 */){
-#if DEBUG == 2
- fprintf(stderr," distance2 rc=%d rgood=%d rbad=%d\n",rc,rgood,rbad);
-// out_b(NULL,p1,box1->x0,box1->y0,box1->x1-box1->x0+1,
-// box1->y1-box1->y0+1,cs);
-// out_b(NULL,p2,box2->x0,box2->y0,box2->x1-box2->x0+1,
-// box2->y1-box2->y0+1,cs);
- out_x(box1);
- out_x(box2);
-#endif
- }
- return rc;
-}
-
-wchar_t ocr_db(struct box *box1) {
- int dd = 1000, dist = 1000;
- wchar_t c = UNKNOWN;
- char buf[200];
- Box *box2, *box3;
-
- if (!list_empty(&JOB->tmp.dblist)){
- box3 = (Box *)list_get_header(&JOB->tmp.dblist);
- if(JOB->cfg.verbose)
- fprintf(stderr,"\n#DEBUG: ocr_db (%d,%d) ",box1->x0, box1->y0);
-
- for_each_data(&JOB->tmp.dblist) {
- box2 = (Box *)list_get_current(&JOB->tmp.dblist);
- /* do preselect!!! distance() slowly */
- dd = distance2( box2->p, box2, box1->p, box1, JOB->cfg.cs);
- if (dd <= dist) { /* new best fit */
- dist = dd;
- box3 = box2; /* box3 is a pointer and not copied box2 */
-
- if (dist<100 && 100-dist > JOB->cfg.certainty) {
- /* some deviation of the pattern is tolerated */
- int i, wa;
- for (i=0;i<box3->num_ac;i++) {
- wa = (100-dist)*box3->wac[i]/100; /* weight *= (100-dist) */
- if (box3->tas[i]) setas(box1,box3->tas[i],wa);
- else setac(box1,box3->tac[i],wa);
- }
- if (box3->num_ac) c=box3->tac[0]; /* 0 for strings (!UNKNOWN) */
- if (JOB->cfg.verbose)
- fprintf(stderr, " dist=%4d c= %c 0x%02x %s wc= %3d", dist,
- ((box3->c>32 && box3->c<127) ? (char) box3->c : '.'),
- (int)box3->c, ((box3->tas[0])?box3->tas[0]:""), box3->wac[0]);
- }
- if (dd<=0 && ((box3->num_ac && box3->tas[0]) || box3->c >= 128
- || !strchr ("l1|I0O", box3->c)))
- break; /* speedup if found */
- }
- } end_for_each(&JOB->tmp.dblist);
-
- }
-
- if( (JOB->cfg.mode&128) != 0 && c == UNKNOWN ) { /* prompt the user */
- /* should the output go to stderr or special pipe??? */
- int utf8_ok=0; /* trigger this flag if input is ok */
- int i, endchar; /* index */
- out_env(box1); /* old: out_x(box1); */
- fprintf(stderr,"The above pattern was not recognized.\n"
- "Enter UTF8 char or string for above pattern. Leave empty if unsure.\n"
- "Press RET at the end (ALT+RET to store into RAM only) : "
- ); /* ToDo: empty + alt-return (0x1b 0x0a) for help? ^a for skip all */
- /* UTF-8 (man 7 utf-8):
- * 7bit = 0xxxxxxx (0000-007F)
- * 11bit = 110xxxxx 10xxxxxx (0080-07FF)
- * 16bit = 1110xxxx 10xxxxxx 10xxxxxx (0800-FFFF)
- * 21bit = 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
- * 26bit = 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
- * 31bit = 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
- */
- buf[0]=0;
- /* shift/ctrl/altgr-enter acts like enter or ^j or ^m,
- * alt-enter returns 0x1b 0x0a and returns from fgets()
- * ^d (EOF) returns (nil) from fgets()
- * x+(2*)ctrl-d returns from fgets() without returning a 0x0a
- * if not UTF-input-mode, we are in trouble?
- * ^a=0x01, ^b=0x02, ^e=05, ..., ToDo: meaning of no-input or <=space
- */
- fgets(buf,200,stdin); /* including \n=0x0a */
- dd=strlen(buf);
- /* output hexcode if verbose set */
- if (JOB->cfg.verbose) {
- fprintf(stderr, "\n# fgets [%d]:", dd);
- for(i=0; i<dd; i++)
- fprintf(stderr, " %02x", (unsigned)((unsigned char)buf[i]));
- fprintf(stderr, "\n#");
- }
- /* we dont accept chars which could destroy database file */
- for (i=0; i<dd; i++) if (buf[i]<32) break;
- endchar=buf[i]; /* last char is 0x0a (ret) 0x00 (EOF) or 0x1b (alt+ret) */
- if (endchar==0x01) { i=0;JOB->cfg.mode&=~128; } /* skip all */
- buf[dd=i]=0; /* replace final 0x0a or other special codes */
- if (dd==1 && !(buf[0]&128)) { c=buf[0]; utf8_ok=1; } /* single char */
- if (dd>1 && dd<7) { /* try to decode single wide char (utf8) */
- int u0, u1; /* define UTF8-start sequences, u0=0bits u1=1bits */
- u0= 1<<(7-dd); /* compute start byte from UTF8-length */
- u1=255&~((1<<(8-dd))-1);
- for (i=1;i<dd;i++) if ((buf[i]&0xc0)!=0x80) break; /* 10xxxxxx */
- if (i==dd && (buf[0]&(u0|u1))==u1) { utf8_ok=1;
- c=buf[0]&(u0-1); /* 11..0x.. */
- for (i=1;i<dd;i++) { c<<=6; c|=buf[i]&0x3F; } /* 10xxxxxx */
- }
- }
- if (dd>0){ /* ToDo: skip space and tab too? */
- if (utf8_ok==1) { setac(box1, c, 100); } /* store single wchar */
- if (utf8_ok==0) { /* store a string of chars (UTF8-string) */
- c='_'; /* what should we do with c? probably a bad idea? */
- setas(box1, buf, 100);
- }
- /* decide between
- * 0) just help gocr to find the results and (dont remember, 0x01)
- * 1) help and remember in the same run (store to memory, 0x1b)
- * 2) expand the database (dont store ugly chars to the database!)
- */
- if (endchar!=0x01){ /* ^a before hit return */
- /* is there a reason to dont store to memory? */
- list_app(&JOB->tmp.dblist, box1); /* append to list for 1+2 */
- }
- if (endchar!=0x01 && endchar!=0x1b){
- store_db(box1); /* store to disk for 2 */
- }
- if (JOB->cfg.verbose)
- fprintf(stderr, " got char= %c 16bit= 0x%04x string= \"%s\"\n",
- ((c>32 && c<127)?(char)c:'.'), (int)c, buf);
- }
- }
-
- return c;
-}
+++ /dev/null
-/*
-This is a Optical-Character-Recognition program
-Copyright (C) 2000-2007 Joerg Schulenburg
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- check README for my email address
-*/
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h> // toupper, tolower
-#include "pgm2asc.h"
-#include "gocr.h"
-
-// ----- detect lines ---------------
-/* suggestion: Fourier transform and set line frequency where the
- amplitude has a maximum (JS: slow and not smarty enough).
-
- option: range for line numbers 1..1000 or similar
- todo: look for thickest line, and divide if thickness=2*mean_thickness
- Set these elements of the box structs:
-
- m1 <-- top of upper case letters and (bdfhkl) (can differ)
- m2 <-- top of letters (acegmnopqrsuvwxyz)
- m3 <-- baseline
- m4 <-- bottom of hanging letters (gqpy)
-
- performance can be improved by working with a temporary
- list of boxes of the special text line
-
- - Jun23,00 more robustness of m3 (test liebfrau1)
- - Feb01,02 more robustness of m4 (test s46_084.pgm)
- - Dec03,12 fix problems with footnotes
- ToDo:
- - generate lists of boxes per line (faster access)
- - use statistics
- - for each box look at it neighbours and set box-m1..m4
- - m[1..4].max .min if m4.min-m3.max<1 probability lower
- */
-int detect_lines1(pix * p, int x0, int y0, int dx, int dy)
-{
- int i, jj, j2, y, yy, my, mi, mc, i1, i2, i3, i4,
- m1, m2, m3, m4, ma1, ma2, ma3, ma4, m3pre, m4pre;
- struct box *box2, *box3; /* box3 is for verbose / debugging */
- struct tlines *lines = &JOB->res.lines;
-
- /* ToDo: optional read line-data from external source??? */
- if (lines->num == 0) { // initialize one dummy-line for pictures etc.
- lines->m4[0] = 0;
- lines->m3[0] = 0;
- lines->m2[0] = 0;
- lines->m1[0] = 0;
- lines->x0[0] = p->x; /* expand to left end during detection */
- lines->x1[0] = 0; /* expand to right end */
- lines->pitch[0] = JOB->cfg.spc; /* default word pitch */
- lines->mono[0] = 0; /* default spacing = prop */
- lines->num++;
- }
- i = lines->num;
- if (dy < 4)
- return 0; /* image is to low for latin chars */
- my = jj = 0;
- // get the mean height of all hollow chars
- // (better than mean value of everything including bg-pattern or dust?)
- for_each_data(&(JOB->res.boxlist)) {
- box2 = (struct box *)list_get_current(&(JOB->res.boxlist));
- if ( box2->c != PICTURE
- && box2->num_frames>1 && box2->num_frames<3 /* 1 or 2 holes */
- && box2->y0 >= y0 && box2->y1 <= y0 + dy
- && box2->x0 >= x0 && box2->x1 <= x0 + dx
- && box2->frame_vol[0]>0
- && box2->frame_vol[1]<0
- ) {
- jj++;
- my += box2->y1 - box2->y0 + 1;
- }
- } end_for_each(&(JOB->res.boxlist));
- if (jj==0) {
- // get the mean height of all chars
- for_each_data(&(JOB->res.boxlist)) {
- box2 = (struct box *)list_get_current(&(JOB->res.boxlist));
- if ( box2->c != PICTURE
- && box2->y1 - box2->y0 + 1 >= 4 /* 4x6 font */
- && box2->y0 >= y0 && box2->y1 <= y0 + dy
- && box2->x0 >= x0 && box2->x1 <= x0 + dx ) {
- jj++;
- my += box2->y1 - box2->y0 + 1;
- }
- } end_for_each(&(JOB->res.boxlist));
- }
- if (jj == 0)
- return 0; /* no chars detected */
-
-
- /* ToDo: a better way could be to mark good boxes (of typical high a-zA-Z0-9)
- * first and handle only marked boxes for line scan, exclude ?!,.:;etc
- * but without setect the chars itself (using good statistics)
- * see adjust_text_lines()
- */
- my /= jj; /* we only care about chars with high arround my */
- if (JOB->cfg.verbose & 16)
- fprintf(stderr,"\n# detect_lines1(%d %d %d %d) vvv&16 chars=%d my=%d\n# ",
- x0, y0, dx, dy, jj, my);
- // "my" is the average over the whole image (bad, if different fontsizes)
-
- if (my < 4)
- return 0; /* mean high is to small => error */
-
- m4pre=m3pre=y0; /* lower bond of upper line */
- // better function for scanning line around a letter ???
- // or define lines around known chars "eaTmM"
- for (j2 = y = y0; y < y0 + dy; y++) {
- // look for max. of upper and lower bound of next line
- m1 = y0 + dy;
- jj = 0;
-#if 1
- /* this is only for test runs */
- if (JOB->cfg.verbose & 16)
- fprintf(stderr,"searching new line %d\n# ",i /* lines->num */);
-#endif
-
- box3 = NULL; /* mark the most upper box starting next line */
- // find highest point of next line => store to m1-min (m1>=y)
- // only objects greater 2/3*my and smaller 3*my are allowed
- // a higher "!" at end of line can result in a to low m1
- for_each_data(&(JOB->res.boxlist)) {
- box2 = (struct box *)list_get_current(&(JOB->res.boxlist));
- if (box2->line>0 || box2->c == PICTURE) continue;
- if (lines->dx)
- yy = lines->dy * box2->x0 / (lines->dx); /* correct crooked lines */
- else yy=0;
- if ( box2->y0 >= y + yy && box2->y1 < y0 + dy // lower than y
- && box2->x0 >= x0 && box2->x1 < x0 + dx // within box ?
- && box2->c != PICTURE // no picture
- && box2->num_boxes <= 1 // ignore 2 for "!?i" 3 for "ä"
- && 3 * (box2->y1 - box2->y0) > 2 * my // not to small
- && (box2->y1 - box2->y0) < 3 * my // not to big
- && (box2->y1 - box2->y0) > 4) // minimum absolute size
- {
- if (box2->y0 < m1 + yy) {
- m1 = box2->y0 - yy; /* highest upper boundary */
- box3 = box2;
- }
- // fprintf(stderr,"\n %3d %3d %+3d %d m1= %3d",
- // box2->x0, box2->y0, box2->y1 - box2->y0 + 1, box2->num_boxes, m1);
- }
- } end_for_each(&(JOB->res.boxlist));
- if (!box3 || m1 >= y0+dy) break; /* no further line found */
- if (JOB->cfg.verbose & 16)
- fprintf(stderr," most upper box at new line xy= %4d %4d %+4d %+4d\n# ",
- box3->x0, box3->y0, box3->x1-box3->x0, box3->y1-box3->y0);
-
- // at the moment values depend from single chars, which can
- // result in bad values (ex: 4x6 /\=)
- // ToDo: 2) mean size of next line (store list of y0,y1)
- // ToDo: 3) count num0[(y0-m1)*16/my], num1[(y1-m1)*16/my]
- // ToDo: or down-top search horizontal nerarest neighbours
- lines->x0[i] = x0 + dx - 1; /* expand during operation to left end */
- lines->x1[i] = x0; /* expand to the right end of line */
- m4=m2=m1; mi=m1+my; m3=m1+2*my; jj=0;
- // find limits for upper bound, base line and ground line
- // m2-max m3-min m4-max
- for_each_data(&(JOB->res.boxlist)) {
- box2 = (struct box *)list_get_current(&(JOB->res.boxlist));
- if (box2->line>0 || box2->c == PICTURE) continue;
- if ( box2->y0 < y0 || box2->y1 >= y0 + dy
- || box2->x0 < x0 || box2->x1 >= x0 + dx ) continue; // out of image
- if (lines->dx) yy = lines->dy * box2->x0 / (lines->dx);
- else yy=0;
- /* check for ij-dots, used if chars of same high */
- if ( box2->y0 >= y + yy
- && box2->y0 >= y
- && (box2->y1 - box2->y0) < my
- && box2->y1 < m1 + yy + my/4
- && box2->y0 < mi + yy ) {
- mi = box2->y0 - yy; /* highest upper boundary i-dot */
- }
- // fprintf(stderr,"\n check %3d %3d-%3d y=%d yy=%d m1=%d", box2->x0, box2->y0, box2->y1, y, yy, m1);
- /* get m2-max m3-min m4-max */
- if ( box2->y0 >= y + yy // lower than y
- && 3 * (box2->y1 - box2->y0 + 1) > 2 * my // right size ?
- && (box2->y1 - box2->y0 + 1) < 3 * my // font mix, size = 2.6*my
- && (box2->y1 - box2->y0 + 1) > 3 // 4x6 lowercase=4
- && box2->y0 >= m1 // in m1 range?
- && box2->y0 <= m1 + yy + 9 * my / 8 // my can be to small if mixed
- // ToDo: we need a better (local?) algorithm for big headlines > 2*my
- && box2->y1 <= m1 + yy + 3 * my
- && box2->y1 >= m1 + yy + my / 2
- // lines can differ in high, my may be to small (smaller headlines)
- && box2->y0+box2->y1 <= 2*box3->y1
- )
- {
- jj++; // count chars for debugging purpose
- if (box2->y0 > m2 + yy) {
- m2 = box2->y0 - yy; /* highest upper boundary */
- if (JOB->cfg.verbose & 16)
- fprintf(stderr," set m2= %d yy= %d\n# ",m2, yy);
- }
- if (box2->y1 > m4 + yy && (my>6 || box2->y1 < m3+my)) {
- m4 = box2->y1 - yy; /* lowest lower boundary, small font lines can touch */
- }
- if ( box2->y1 < m3 + yy
- && ( ( 2*box2->y1 > m2+ m4+yy && m2>m1)
- || ( 4*box2->y1 > m1+3*m4+yy) ) ) // care for TeX: \(^1\)Footnote 2003
- /* "'!?" could cause trouble here, therefore this lines */
- /* ToDo: get_bw costs time, check pre and next */
- if( get_bw(box2->x0,box2->x1,box2->y1+1 ,box2->y1+my/2,box2->p,JOB->cfg.cs,1) == 0
- || get_bw(box2->x0,box2->x1,box2->y1+my/2,box2->y1+my/2,box2->p,JOB->cfg.cs,1) == 1
- || num_cross(box2->x0,box2->x1,(box2->y0+box2->y1)/2,(box2->y0+box2->y1)/2,box2->p,JOB->cfg.cs)>2 )
- {
- m3 = box2->y1 - yy; /* highest lower boundary */
- // printf("\n# set1 m3 m=%3d %+2d %+2d %+2d",m1,m2-m1,m3-m1,m4-m1);
- // out_x(box2);
- }
- if (box2->y0 + box2->y1 > 2*(m3 + yy)
- && box2->y1 < m4 + yy - my/4 -1
- && box2->y1 >= (m2 + m4)/2 // care for TeX: \(^1\)Footnote 2003
- && m2 > m1 ) // be sure to not use ', m2 must be ok
- {
- m3 = box2->y1 - yy; /* highest lower boundary */
- // printf("\n# set2 m3 m=%3d %+2d %+2d %+2d",m1,m2-m1,m3-m1,m4-m1);
- // out_x(box2);
- }
- if (box2->x1>lines->x1[i]) lines->x1[i] = box2->x1; /* right end */
- if (box2->x0<lines->x0[i]) lines->x0[i] = box2->x0; /* left end */
- // printf(" m=%3d %+2d %+2d %+2d yy=%3d\n",m1,m2-m1,m3-m1,m4-m1,yy);
- }
- } end_for_each(&(JOB->res.boxlist));
-
-#if 1
- /* this is only for test runs */
- if (JOB->cfg.verbose & 16)
- fprintf(stderr," step 1 y=%4d m= %4d %+3d %+3d %+3d"
- " my=%2d chars=%3d\n# ",
- y, m1, m2-m1, m3-m1, m4-m1, my, jj);
-#endif
-
- if (m3 == m1)
- break;
-#if 1 /* make averages about the line */
- // same again better estimation
- mc = (3 * m3 + m1) / 4; /* lower center ? */
- ma1 = ma2 = ma3 = ma4 = i1 = i2 = i3 = i4 = jj = 0;
- for_each_data(&(JOB->res.boxlist)) {
- box2 = (struct box *)list_get_current(&(JOB->res.boxlist));
- if (box2->line>0 || box2->c == PICTURE) continue;
- if (lines->dx) yy = lines->dy * box2->x0 / (lines->dx); else yy=0;
- if (box2->y0 >= y + yy && box2->y1 < y0 + dy // lower than y
- && box2->x0 >= x0 && box2->x1 < x0 + dx // in box ?
- && box2->c != PICTURE // no picture
- && 2 * (box2->y1 - box2->y0) > my // right size ?
- && (box2->y1 - box2->y0) < 4 * my) {
- if ( box2->y0 - yy >= m1-my/4
- && box2->y0 - yy <= m2+my/4
- && box2->y1 - yy >= m3-my/4
- && box2->y1 - yy <= m4+my/4 ) { /* its within allowed range! */
- // jj++; // not used
- if (abs(box2->y0 - yy - m1) <= abs(box2->y0 - yy - m2))
- { i1++; ma1 += box2->y0 - yy; }
- else { i2++; ma2 += box2->y0 - yy; }
- if (abs(box2->y1 - yy - m3) < abs(box2->y1 - yy - m4))
- { i3++; ma3 += box2->y1 - yy; }
- else { i4++; ma4 += box2->y1 - yy; }
- if (box2->x1>lines->x1[i]) lines->x1[i] = box2->x1; /* right end */
- if (box2->x0<lines->x0[i]) lines->x0[i] = box2->x0; /* left end */
- }
- }
- } end_for_each(&(JOB->res.boxlist));
-
- if (i1) m1 = (ma1+i1/2) / i1; /* best rounded */
- if (i2) m2 = (ma2+i2/2) / i2;
- if (i3) m3 = (ma3+i3-1) / i3; /* round up */
- if (i4) m4 = (ma4+i4-1) / i4;
- // printf("\n# .. set3 m3 m=%3d %+2d %+2d %+2d",m1,m2-m1,m3-m1,m4-m1);
-
-#endif
-
- /* expand right and left end of line */
- for_each_data(&(JOB->res.boxlist)) {
- box2 = (struct box *)list_get_current(&(JOB->res.boxlist));
- if (box2->line>0 || box2->c == PICTURE) continue;
- if (lines->dx) yy = lines->dy * box2->x0 / (lines->dx); else yy=0;
- if ( box2->y0 >= y0 && box2->y1 < y0 + dy
- && box2->x0 >= x0 && box2->x1 < x0 + dx // in box ?
- && box2->c != PICTURE // no picture
- && box2->y0 >= m1-1
- && box2->y0 <= m4
- && box2->y1 >= m1
- && box2->y1 <= m4+1 ) { /* its within line */
- if (box2->x1>lines->x1[i]) lines->x1[i] = box2->x1; /* right end */
- if (box2->x0<lines->x0[i]) lines->x0[i] = box2->x0; /* left end */
- }
- } end_for_each(&(JOB->res.boxlist));
-
-#if 1
- /* this is only for test runs */
- if (JOB->cfg.verbose & 16)
- fprintf(stderr," step 2 y=%4d m= %4d %+3d %+3d %+3d\n# ",
- y,m1,m2-m1,m3-m1,m4-m1);
-#endif
-
- if (m4 == m1) {
- if(m3+m4>2*y) y = (m4+m3)/2; /* lower end may overlap the next line */
- continue;
- }
- jj=0;
- lines->wt[i] = 100;
- if (5 * (m2 - m1 +1) < m3 - m2 || (m2 - m1) < 2) jj|=1; /* same high */
- if (5 * (m4 - m3 +1) < m3 - m2 || (m4 - m3) < 1) jj|=2; /* same base */
- if (jj&1) lines->wt[i] = 75*lines->wt[i]/100;
- if (jj&2) lines->wt[i] = 75*lines->wt[i]/100;
- if (jj>0 && JOB->cfg.verbose) {
- fprintf(stderr," trouble on line %d, wt*100= %d\n",i,lines->wt[i]);
- fprintf(stderr,"# m= %4d %+3d %+3d %+3d\n",m1,m2-m1,m3-m1,m4-m1);
- fprintf(stderr,"# i= %3d %3d %3d %3d (counts)\n",i1,i2,i3,i4);
- if (jj==3) fprintf(stderr,"# all boxes of same high!\n# ");
- if (jj==1) fprintf(stderr,"# all boxes of same upper bound!\n# ");
- if (jj==2) fprintf(stderr,"# all boxes of same lower bound!\n# ");
- }
- /* ToDo: check for dots ij,. to get the missing information */
-#if 1
- /* jj=3: ABCDEF123456 or mnmno or gqpy or lkhfdtb => we are in trouble */
- if (jj==3 && (m4-m1)>my) { jj=0; m2=m1+my/8+1; m4=m3+my/8+1; } /* ABC123 */
- /* using idots, may fail on "ABCDEFGÄÜÖ" */
- if (jj==3 && mi>0 && mi<m1 && mi>m4pre) { jj=2; m1=mi; } /* use ij dots */
- if (jj==1 && m2-(m3-m2)/4>m3pre ) { /* expect: acegmnopqrsuvwxyz */
- if (m1-m4pre<m4-m1) /* fails for 0123ABCD+Q$ */
- m1 = ( m2 + m4pre ) / 2 ;
- else
- m1 = ( m2 - (m3 - m2) / 4 );
- }
- if (jj==3)
- m2 = m1 + (m3 - m1) / 4 + 1; /* expect: 0123456789ABCDEF */
- if ( (m2 - m1) < 2)
- m2 = m1 + 2; /* font hight < 8 pixel ? */
- if (jj&2)
- m4 = m3 + (m4 - m1) / 4 + 1; /* chars have same lower base */
- if (jj>0 && JOB->cfg.verbose & 16) {
- fprintf(stderr," m= %4d %+2d %+2d %+2d my= %4d\n# ",
- m1, m2-m1, m3-m1, m4-m1, my);
- }
-#endif
-
-
- { // empty space between lines
- lines->m4[i] = m4;
- lines->m3[i] = m3;
- lines->m2[i] = m2;
- lines->m1[i] = m1;
- lines->pitch[i] = JOB->cfg.spc; /* default word pitch */
- lines->pitch[i] = 0; /* default spacing */
- if (JOB->cfg.verbose & 16)
- fprintf(stderr, " m= %4d %+3d %+3d %+3d w= %d (line=%d)\n# ",
- m1, m2 - m1, m3 - m1, m4 - m1, lines->wt[i], i);
- if (i < MAXlines && m4 - m1 > 4)
- i++;
- if (i >= MAXlines) {
- fprintf(stderr, "Warning: lines>MAXlines\n");
- break;
- }
- }
- if (m3+m4>2*y) y = (m3+m4)/2; /* lower end may overlap the next line */
- if (m3>m3pre) m3pre = m3; else m3=y0; /* set for next-line scan */
- if (m4>m4pre) m4pre = m4; else m4=y0; /* set for next-line scan */
- }
- lines->num = i;
- if (JOB->cfg.verbose)
- fprintf(stderr, " num_lines= %d", lines->num-1);
- return 0;
-}
-
-// ----- layout analyzis of dx*dy region at x0,y0 -----
-// ----- detect lines via recursive division (new version) ---------------
-// what about text in frames???
-// ToDo: change to bottom-top analyse or/and take rotation into account
-int detect_lines2(pix *p,int x0,int y0,int dx,int dy,int r){
- int i,x2,y2,x3,y3,x4,y4,x5,y5,y6,mx,my,x30,x31,y30,y31;
- struct box *box2,*box3;
- // shrink box
- if(dx<=0 || dy<=0) return 0;
- if(y0+dy< p->y/128 && y0==0) return 0; /* looks like dust */
- if(y0>p->y-p->y/128 && y0+dy==p->y) return 0; /* looks like dust */
-
- if(r>1000){ return -1;} // something is wrong
- if(JOB->cfg.verbose)fprintf(stderr,"\n# r=%2d ",r);
-
- mx=my=i=0; // mean thickness
- // remove border, shrink size
- x2=x0+dx-1; // min x
- y2=y0+dy-1; // min y
- x3=x0; // max x
- y3=y0; // max y
- for_each_data(&(JOB->res.boxlist)) {
- box3 = (struct box *)list_get_current(&(JOB->res.boxlist));
- if(box3->y0>=y0 && box3->y1<y0+dy &&
- box3->x0>=x0 && box3->x1<x0+dx)
- {
- if( box3->x1 > x3 ) x3=box3->x1; // max x
- if( box3->x0 < x2 ) x2=box3->x0; // min x
- if( box3->y1 > y3 ) y3=box3->y1; // max y
- if( box3->y0 < y2 ) y2=box3->y0; // min y
- if(box3->c!=PICTURE)
- if( box3->y1 - box3->y0 > 4 )
- {
- i++;
- mx+=box3->x1-box3->x0+1; // mean x
- my+=box3->y1-box3->y0+1; // mean y
- }
- }
- } end_for_each(&(JOB->res.boxlist));
- x0=x2; dx=x3-x2+1;
- y0=y2; dy=y3-y2+1;
-
- if(i==0 || dx<=0 || dy<=0) return 0;
- mx/=i;my/=i;
- // better look for widest h/v-gap, ToDo: vertical lines?
- if(r<8){ // max. depth
-
- // detect widest horizontal gap
- y2=y3=y4=y5=y6=0;
- x2=x3=x4=x5=y5=0;// min. 3 lines
- // position and thickness of gap, y6=num_gaps, nbox^2 ops
- for_each_data(&(JOB->res.boxlist)) { // not very efficient, sorry
- box2 = (struct box *)list_get_current(&(JOB->res.boxlist));
- if( box2->c!=PICTURE ) /* ToDo: not sure, that this is a good idea */
- if( box2->y0>=y0 && box2->y1<y0+dy
- && box2->x0>=x0 && box2->x1<x0+dx
- && box2->y1-box2->y0>my/2 ){ // no pictures & dust???
-
- y4=y0+dy-1; // nearest vert. box
- x4=x0+dx-1;
- // ToDo: rotate back box2->x1,y1 to x21,y21
- // look for nearest lowest (y4) and right (x4) neighbour
- // of every box (box2)
- for_each_data(&(JOB->res.boxlist)) {
- box3 = (struct box *)list_get_current(&(JOB->res.boxlist));
- if(box3!=box2)
- if(box3->y0>=y0 && box3->y1<y0+dy)
- if(box3->x0>=x0 && box3->x1<x0+dx)
- if(box3->c!=PICTURE) /* ToDo: not sure, that this is a good idea */
- if(box3->y1-box3->y0>my/2 ){
- // ToDo: here we need the rotation around box2
- x30=box3->x0;
- x31=box3->x1;
- y30=box3->y0;
- y31=box3->y1;
- // get min. distances to lower and to right direction
- if( y31 > box2->y1 && y30 < y4 ) y4=y30-1;
- if( x31 > box2->x1 && x30 < x4 ) x4=x30-1;
- }
- } end_for_each(&(JOB->res.boxlist));
- // set the witdht and position of largest hor./vert. gap
- // largest gap: width position
- if( y4-box2->y1 > y3 ) { y3=y4-box2->y1; y2=(y4+box2->y1)/2; }
- if( x4-box2->x1 > x3 ) { x3=x4-box2->x1; x2=(x4+box2->x1)/2; }
- }
- } end_for_each(&(JOB->res.boxlist));
- // fprintf(stderr,"\n widest y-gap= %4d %4d",y2,y3);
- // fprintf(stderr,"\n widest x-gap= %4d %4d",x2,x3);
-
- i=0; // i=1 at x, i=2 at y
- // this is the critical point
- // is this a good decision or not???
- if(x3>0 || y3>0){
- if(x3>mx && x3>2*y3 && (dy>5*x3 || (x3>10*y3 && y3>0))) i=1; else
- if(dx>5*y3 && y3>my) i=2;
- }
-
- // compare with largest box???
- for_each_data(&(JOB->res.boxlist)) { // not very efficient, sorry
- box2 = (struct box *)list_get_current(&(JOB->res.boxlist));
- if( box2->c == PICTURE )
- if( box2->y0>=y0 && box2->y1<y0+dy
- && box2->x0>=x0 && box2->x1<x0+dx )
- { // hline ???
- // largest gap: width position
- if( box2->x1-box2->x0+4 > dx && box2->y1+4<y0+dy ) { y3=1; y2=box2->y1+1; i=2; break; }
- if( box2->x1-box2->x0+4 > dx && box2->y0-4>y0 ) { y3=1; y2=box2->y0-1; i=2; break; }
- if( box2->y1-box2->y0+4 > dy && box2->x1+4<x0+dx ) { x3=1; x2=box2->x1+1; i=1; break; }
- if( box2->y1-box2->y0+4 > dy && box2->x0-4>x0 ) { x3=1; x2=box2->x0-1; i=1; break; }
- }
- } end_for_each(&(JOB->res.boxlist));
- if(JOB->cfg.verbose)fprintf(stderr," i=%d",i);
-
- if(JOB->cfg.verbose && i) fprintf(stderr," divide at %s x=%4d y=%4d dx=%4d dy=%4d",
- ((i)?( (i==1)?"x":"y" ):"?"),x2,y2,x3,y3);
- // divide horizontally if v-gap is thicker than h-gap
- // and length is larger 5*width
- if(i==1){ detect_lines2(p,x0,y0,x2-x0+1,dy,r+1);
- return detect_lines2(p,x2,y0,x0+dx-x2+1,dy,r+1); }
- // divide vertically
- if(i==2){ detect_lines2(p,x0,y0,dx,y2-y0+1,r+1);
- return detect_lines2(p,x0,y2,dx,y0+dy-y2+1,r+1);
- }
- }
-
-
- if(JOB->cfg.verbose) if(dx<5 || dy<7)fprintf(stderr," empty box");
- if(dx<5 || dy<7) return 0; // do not care about dust
- if(JOB->cfg.verbose)fprintf(stderr, " box detected at %4d %4d %4d %4d",x0,y0,dx,dy);
- if(JOB->tmp.ppo.p){
- for(i=0;i<dx;i++)put(&JOB->tmp.ppo,x0+i ,y0 ,255,16);
- for(i=0;i<dx;i++)put(&JOB->tmp.ppo,x0+i ,y0+dy-1,255,16);
- for(i=0;i<dy;i++)put(&JOB->tmp.ppo,x0 ,y0+i ,255,16);
- for(i=0;i<dy;i++)put(&JOB->tmp.ppo,x0+dx-1,y0+i ,255,16);
- // writebmp("out10.bmp",p2,JOB->cfg.verbose); // colored should be better
- }
- return detect_lines1(p,x0-0*1,y0-0*2,dx+0*2,dy+0*3);
-
-/*
- struct tlines *lines = &JOB->res.lines;
- i=lines->num; lines->num++;
- lines->m1[i]=y0; lines->m2[i]=y0+5*dy/16;
- lines->m3[i]=y0+12*dy/16; lines->m4[i]=y0+dy-1;
- lines->x0[i]=x0; lines->x1[i]=x0+dx-1;
- if(JOB->cfg.verbose)fprintf(stderr," - line= %d",lines->num);
- return 0;
- */
-}
-
-/* ToDo: herons algorithm for square root x=(x+y/x)/2 is more efficient
- * than interval subdivision (?) (germ.: Intervallschachtelung)
- * without using matlib
- * see http://www.math.vt.edu/people/brown/doc/sqrts.pdf
- */
-int my_sqrt(int x){
- int y0=0,y1=x,ym;
- for (;y0<y1-1;){
- ym=(y0+y1)/2;
- if (ym*ym<x) y0=ym; else y1=ym;
- }
- return y0;
-}
-
-/*
-** Detect rotation angle (one for whole image)
-** old: longest text-line and determining the angle of this line.
- *
- * search right nearest neighbour of each box and average vectors
- * to get the text orientation,
- * upside down decision is not made here (I dont know how to do it)
- * ToDo: set job->res.lines.{dx,dy}
- * pass 1: get mean vector to nearest char
- * pass 2: get mean vector to nearest char without outriders to pass 1
- * extimate direction as (dx,dy,num)[pass]
- * ToDo: estimate an error, boxes only work fine for zero-rotation
- * for 45 degree use vectors, not boxes to get base line
- */
-#define INorm 1024 /* integer unit 1.0 */
-int detect_rotation_angle(job_t *job){
- struct box *box2, *box3,
- *box_nn; /* nearest neighbour box */
- int x2, y2, x3, y3, dist, mindist, pass,
- rx=0, ry=0, re=0, // final result
- /* to avoid 2nd run, wie store pairs in 2 different categories */
- nn[4]={0,0,0,0}, /* num_pairs used for estimation [(pass-1)%2,pass%2] */
- dx[4]={0,0,0,0}, /* x-component of rotation vector per pass */
- dy[4]={0,0,0,0}, /* y-component of rotation vector per pass */
- er[4]={INorm/4,0,0,0}; /* mean angle deviation to pass-1 (radius^2) */
- // de; /* ToDo: absolute maximum error (dx^2+dy^2) */
- // ToDo: next pass: go to bigger distances and reduce max error
- // error is diff between passes? or diff of bottoms and top borders (?)
-
- rx=1024; ry=0; // default
- for (pass=0;pass<4;pass++) {
- for_each_data(&(job->res.boxlist)) {
- box2 = (struct box *)list_get_current(&(job->res.boxlist));
- if (box2->c==PICTURE) continue;
- /* subfunction probability of char */
- // i?
- // if (box2->x1 - box2->x0 < 3) continue; /* smallest font is 4x6 */
- if (box2->y1 - box2->y0 < 4) continue;
- /* set maximum possible distance */
- box_nn=box2; // initial box to compare with
-
- // ToDo: clustering or majority
- // the algorithm is far from being perfect, pitfalls are likely
- // but its better than the old algorithm, ToDo: database-rotated-images
- mindist = job->src.p.x * job->src.p.x + job->src.p.y * job->src.p.y;
- /* get middle point of the box */
- x2 = (box2->x0 + box2->x1)/2;
- y2 = (box2->y0 + box2->y1)/2;
- re=0;
- /* search for nearest neighbour box_nn[pass+1] of box_nn[pass] */
- for_each_data(&(job->res.boxlist)) {
- box3 = (struct box *)list_get_current(&(job->res.boxlist));
- /* try to select only potential neighbouring chars */
- /* select out all senseless combinations */
- if (box3->c==PICTURE || box3==box2) continue;
- x3 = (box3->x0 + box3->x1)/2;
- y3 = (box3->y0 + box3->y1)/2; /* get middle point of the box */
- if (x3<x2) continue; /* simplify by going right only */
- // through-away deviation of angles if > pass-1?
- // scalprod max in direction, cross prod min in direction
- // a,b (vectors): <a,b>^2/(|a|*|b|)^2 = 0(90deg)..0.5(45deg).. 1(0deg)
- // * 1024 ??
- if (pass>0) { // new variant = scalar product
- // danger of int overflow, ToDo: use int fraction
- re =(int) ((1.*(x3-x2)*dx[pass-1]+(y3-y2)*dy[pass-1])
- *(1.*(x3-x2)*dx[pass-1]+(y3-y2)*dy[pass-1])*INorm
- /(1.*((x3-x2)*(x3-x2)+(y3-y2)*(y3-y2))
- *(1.*dx[pass-1]*dx[pass-1]+dy[pass-1]*dy[pass-1])));
- if (INorm-re>er[pass-1]) continue; // hits mean deviation
- }
- /* neighbours should have same order of size (?) */
- if (3*(box3->y1-box3->y0+4) < 2*(box2->y1-box2->y0+1)) continue;
- if (2*(box3->y1-box3->y0+1) > 3*(box2->y1-box2->y0+4)) continue;
- if (2*(box3->x1-box3->x0+1) > 5*(box2->x1-box2->x0+4)) continue;
- if (5*(box3->x1-box3->x0+4) < 2*(box2->x1-box2->x0+1)) continue;
- /* should be in right range, Idea: center3 outside box2? noholes */
- if ((x3<box2->x1-1) && (x3>box2->x0+1)
- && (y3<box2->y1-1) && (y3>box2->y0+1)) continue;
- // if chars are of different size, connect careful
- if ( abs(x3-x2) > 2*(box2->x1 - box2->x0 + box3->x1 - box3 ->x0 + 2)) continue;
- if ( abs(y3-y2) > (box2->x1 - box2->x0 + box3->x1 - box3 ->x0 + 2)) continue;
- dist = (y3-y2)*(y3-y2) + (x3-x2)*(x3-x2);
- // make distances in pass-1 directions shorter or continue if not in pass-1 range?
- if (dist<9) continue; /* minimum distance^2 is 3^2 */
- if (dist<mindist) { mindist=dist; box_nn=box3;}
- // fprintf(stderr,"x y %d %d %d %d dist %d min %d\n",
- // x2,y2,x3,y3,dist,mindist);
- } end_for_each(&(job->res.boxlist));
-
- if (box_nn==box2) continue; /* has no neighbour, next box */
-
- box3=box_nn; dist=mindist;
- x3 = (box3->x0 + box3->x1)/2;
- y3 = (box3->y0 + box3->y1)/2; /* get middle point of the box */
- // dist = my_sqrt(1024*((x3-x2)*(x3-x2)+(y3-y2)*(y3-y2)));
- // compare with first box
- x2 = (box2->x0 + box2->x1)/2;
- y2 = (box2->y0 + box2->y1)/2;
- // if the high of neighbouring boxes differ, use min diff (y0,y1)
- if (pass>0 && 16*abs(dy[pass-1]) < dx[pass-1]) // dont work for strong rot.
- if (abs(box2->y1-box2->y0-box3->y1+box3->y0)>(box2->y1-box2->y0)/8) {
- // ad eh ck ...
- if (abs(box2->y1-box3->y1)<abs(y3-y2)) { y2=box2->y1; y3=box3->y1; }
- // ag ep qu ...
- if (abs(box2->y0-box3->y0)<abs(y3-y2)) { y2=box2->y0; y3=box3->y0; }
- }
- if (abs(x3-x2)<4) continue;
- dx[pass]+=(x3-x2)*1024; /* normalized before averaging */
- dy[pass]+=(y3-y2)*1024; /* 1024 is for the precision */
- nn[pass]++;
- if (pass>0) { // set error = mean deviation from pass -1
- re = INorm-(int)((1.*(x3-x2)*dx[pass-1]+(y3-y2)*dy[pass-1])
- *(1.*(x3-x2)*dx[pass-1]+(y3-y2)*dy[pass-1])*INorm
- /((1.*(x3-x2)*(x3-x2)+(y3-y2)*(y3-y2))
- *(1.*dx[pass-1]*dx[pass-1]+dy[pass-1]*dy[pass-1]))
- );
- er[pass]+=re;
- }
-#if 0
- if(JOB->cfg.verbose)
- fprintf(stderr,"# next nb (x,y,dx,dy,re) %6d %6d %5d %5d %5d pass %d\n",
- x2, y2, x3-x2, y3-y2, re, pass+1);
-#endif
- } end_for_each(&(job->res.boxlist));
- if (!nn[pass]) break;
- if (nn[pass]) {
- /* meanvalues */
- rx=dx[pass]/=nn[pass];
- ry=dy[pass]/=nn[pass];
- if (pass>0) er[pass]/=nn[pass];
- }
- if(JOB->cfg.verbose)
- fprintf(stderr,"# rotation angle (x,y,maxr,num)"
- " %6d %6d %6d %4d pass %d\n",
- rx, ry, er[pass], nn[pass], pass+1);
- }
- if (abs(ry*100)>abs(rx*50))
- fprintf(stderr,"<!-- gocr will fail, strong rotation angle detected -->\n");
- /* ToDo: normalize to 2^10 bit (square fits to 32 it) */
- JOB->res.lines.dx=rx;
- JOB->res.lines.dy=ry;
- return 0;
-}
-
-/* ----- detect lines --------------- */
-int detect_text_lines(pix * pp, int mo) {
-
- if (JOB->cfg.verbose)
- fprintf(stderr, "# detect.c detect_text_lines (vvv=16 for more info) ");
- if (mo & 4){
- if (JOB->cfg.verbose) fprintf(stderr, "# zoning\n# ... ");
- detect_lines2(pp, 0, 0, pp->x, pp->y, 0); // later replaced by better algo
- } else
- detect_lines1(pp, 0, 0, pp->x, pp->y); // old algo
-
- if(JOB->cfg.verbose) fprintf(stderr,"\n");
- return 0;
-}
-
-
-/* ----- adjust lines --------------- */
-// rotation angle? JOB->res.lines.dy, .x0 removed later
-// this is for cases, where m1..m4 is not very sure detected before
-// chars are recognized
-int adjust_text_lines(pix * pp, int mo) {
- struct box *box2;
- int *m, /* summ m1..m4, num_chars for m1..m4, min m1..m4, max. m1..m4 */
- l, i, dy, dx, diff=0, y0, y1;
-
- if ((l=JOB->res.lines.num)<2) return 0; // ???
- if (JOB->cfg.verbose)
- fprintf(stderr, "# adjust text lines ");
- m=(int *)malloc(l*16*sizeof(int));
- if (!m) { fprintf(stderr," malloc failed\n"); return 0;}
- for (i=0;i<16*l;i++) m[i]=0; /* initialize */
- dy=JOB->res.lines.dy; /* tan(alpha) of skewing */
- dx=JOB->res.lines.dx; /* old: width of image */
- // js: later skewing is replaced by one transformation of vectorized image
-
- if (dx)
- for_each_data(&(JOB->res.boxlist)) {
- box2 = (struct box *)list_get_current(&(JOB->res.boxlist));
- if (box2->line<=0) continue;
- if (box2->num_ac<1) continue;
- if (box2->wac[0]<95) continue;
- if (box2->m2==0 || box2->y1<box2->m2) continue; // char outside line
- if (box2->m3==4 || box2->y0>box2->m3) continue; // char outside line
- y0=box2->y0-((box2->x1)*dy/dx); /* corrected by page skewing */
- y1=box2->y1-((box2->x1)*dy/dx);
- if (strchr("aemnr",(char)box2->tac[0])) { // cC vV sS oO ... is unsure!
- m[box2->line*16+1]+=y0; m[box2->line*16+5]++; // num m2
- m[box2->line*16+2]+=y1; m[box2->line*16+6]++; // num m3
- if (m[box2->line*16+ 9]>y0) m[box2->line*16+ 9]=y0; /* min m2 */
- if (m[box2->line*16+13]<y0) m[box2->line*16+13]=y0; /* max m2 */
- if (m[box2->line*16+10]>y1) m[box2->line*16+10]=y1; /* min m3 */
- if (m[box2->line*16+14]<y1) m[box2->line*16+14]=y1; /* max m3 */
- }
- if (strchr("bdhklABDEFGHIKLMNRT123456789",(char)box2->tac[0])) {
- m[box2->line*16+0]+=y0; m[box2->line*16+4]++; // num m1
- m[box2->line*16+2]+=y1; m[box2->line*16+6]++; // num m3
- if (m[box2->line*16+ 8]>y0) m[box2->line*16+ 8]=y0; /* min m1 */
- if (m[box2->line*16+12]<y0) m[box2->line*16+12]=y0; /* max m1 */
- if (m[box2->line*16+10]>y1) m[box2->line*16+10]=y1; /* min m3 */
- if (m[box2->line*16+14]<y1) m[box2->line*16+14]=y1; /* max m3 */
- }
- if (strchr("gq",(char)box2->tac[0])) {
- m[box2->line*16+1]+=y0; m[box2->line*16+5]++; // num m2
- m[box2->line*16+3]+=y1; m[box2->line*16+7]++; // num m4
- if (m[box2->line*16+ 9]>y0) m[box2->line*16+ 9]=y0; /* min m2 */
- if (m[box2->line*16+13]<y0) m[box2->line*16+13]=y0; /* max m2 */
- if (m[box2->line*16+11]>y1) m[box2->line*16+11]=y1; /* min m4 */
- if (m[box2->line*16+15]<y1) m[box2->line*16+15]=y1; /* max m4 */
- }
- } end_for_each(&(JOB->res.boxlist));
-
- for (i=1;i<l;i++) {
- diff=0; // show diff per line
- if (m[i*16+4]) diff+=abs(JOB->res.lines.m1[i]-m[i*16+0]/m[i*16+4]);
- if (m[i*16+5]) diff+=abs(JOB->res.lines.m2[i]-m[i*16+1]/m[i*16+5]);
- if (m[i*16+6]) diff+=abs(JOB->res.lines.m3[i]-m[i*16+2]/m[i*16+6]);
- if (m[i*16+7]) diff+=abs(JOB->res.lines.m4[i]-m[i*16+3]/m[i*16+7]);
- /* recalculate sureness, empirically */
- if (m[i*16+4]*m[i*16+5]*m[i*16+6]*m[i*16+7] > 0)
- JOB->res.lines.wt[i]=(JOB->res.lines.wt[i]+100)/2;
- else
- JOB->res.lines.wt[i]=(JOB->res.lines.wt[i]*90)/100;
- // set mean values of sure detected bounds (rounded precisely)
- if ( m[i*16+4]) JOB->res.lines.m1[i]=(m[i*16+0]+m[i*16+4]/2)/m[i*16+4];
- if ( m[i*16+5]) JOB->res.lines.m2[i]=(m[i*16+1]+m[i*16+5]/2)/m[i*16+5];
- if ( m[i*16+6]) JOB->res.lines.m3[i]=(m[i*16+2]+m[i*16+6]/2)/m[i*16+6];
- if ( m[i*16+7]) JOB->res.lines.m4[i]=(m[i*16+3]+m[i*16+7]/2)/m[i*16+7];
- // care about very small fonts
- if (JOB->res.lines.m2[i]-JOB->res.lines.m1[i]<=1 && m[i*16+5]==0 && m[i*16+4])
- JOB->res.lines.m2[i]=JOB->res.lines.m1[i]+2;
- if (JOB->res.lines.m2[i]-JOB->res.lines.m1[i]<=1 && m[i*16+4]==0 && m[i*16+5])
- JOB->res.lines.m1[i]=JOB->res.lines.m2[i]-2;
- if (JOB->res.lines.m4[i]-JOB->res.lines.m3[i]<=1 && m[i*16+7]==0 && m[i*16+6])
- JOB->res.lines.m4[i]=JOB->res.lines.m3[i]+2;
- if (JOB->res.lines.m4[i]-JOB->res.lines.m3[i]<=1 && m[i*16+6]==0 && m[i*16+7])
- JOB->res.lines.m3[i]=JOB->res.lines.m4[i]-2;
- if ( m[i*16+7]<1 &&
- JOB->res.lines.m4[i]
- <=JOB->res.lines.m3[i]+(JOB->res.lines.m3[i]-JOB->res.lines.m2[i])/4 )
- JOB->res.lines.m4[i]=
- JOB->res.lines.m3[i]+(JOB->res.lines.m3[i]-JOB->res.lines.m2[i])/4;
- if ( m[i*16+7]<1 && m[i*16+12+2]>0 && // m4 < max.m3+..
- JOB->res.lines.m4[i] < 2*m[i*16+12+2]-JOB->res.lines.m3[i]+2 )
- JOB->res.lines.m4[i] = 2*m[i*16+12+2]-JOB->res.lines.m3[i]+2;
- if (JOB->res.lines.m4[i]<=JOB->res.lines.m3[i])
- JOB->res.lines.m4[i]= JOB->res.lines.m3[i]+1; /* 4x6 */
-
- if (JOB->cfg.verbose & 17)
- fprintf(stderr, "\n# line= %3d m= %4d %+3d %+3d %+3d "
- " n= %2d %2d %2d %2d w= %3d diff= %d",
- i, JOB->res.lines.m1[i],
- JOB->res.lines.m2[i] - JOB->res.lines.m1[i],
- JOB->res.lines.m3[i] - JOB->res.lines.m1[i],
- JOB->res.lines.m4[i] - JOB->res.lines.m1[i],
- m[i*16+4],m[i*16+5],m[i*16+6],m[i*16+7],
- JOB->res.lines.wt[i], diff);
- }
- diff=0; // count adjusted chars
-#if 1
- if (dx)
- for_each_data(&(JOB->res.boxlist)) {
- box2 = (struct box *)list_get_current(&(JOB->res.boxlist));
- if (box2->line<=0) continue;
- /* check if box was on the wrong line, ToDo: search a better line */
- if (2*box2->y0<2*JOB->res.lines.m1[box2->line]
- -JOB->res.lines.m4[box2->line]
- +JOB->res.lines.m1[box2->line]) box2->line=0;
- if (2*box2->y1>2*JOB->res.lines.m4[box2->line]
- +JOB->res.lines.m4[box2->line]
- -JOB->res.lines.m1[box2->line]) box2->line=0;
- /* do adjustments */
- if (box2->num_ac>0
- && box2->num_ac > 31 && box2->tac[0] < 127 /* islower(>256) may SIGSEGV */
- && strchr("cCoOpPsSuUvVwWxXyYzZ",(char)box2->tac[0])) { // no_wchar
- if (box2->y0-((box2->x1)*dy/dx)
- < (JOB->res.lines.m1[box2->line]+JOB->res.lines.m2[box2->line])/2
- && islower(box2->tac[0])
- ) { setac(box2,toupper((char)box2->tac[0]),(box2->wac[0]+101)/2); diff++; }
- if (box2->y0-((box2->x1)*dy/dx)
- > (JOB->res.lines.m1[box2->line]+JOB->res.lines.m2[box2->line]+1)/2
- && isupper(box2->tac[0])
- ){ setac(box2,tolower((char)box2->tac[0]),(box2->wac[0]+101)/2); diff++; }
- }
- box2->m1=JOB->res.lines.m1[box2->line]+((box2->x1)*dy/dx);
- box2->m2=JOB->res.lines.m2[box2->line]+((box2->x1)*dy/dx);
- box2->m3=JOB->res.lines.m3[box2->line]+((box2->x1)*dy/dx);
- box2->m4=JOB->res.lines.m4[box2->line]+((box2->x1)*dy/dx);
- } end_for_each(&(JOB->res.boxlist));
-#endif
-
- free(m);
- if(JOB->cfg.verbose) fprintf(stderr,"\n# changed_chars= %d\n",diff);
- return(diff);
-}
-
-/* ---- measure mean character
- * recalculate mean width and high after changes in boxlist
- * ToDo: only within a Range?
- */
-int calc_average() {
- int i = 0, x0, y0, x1, y1;
- struct box *box4;
-
- JOB->res.numC = 0;
- JOB->res.sumY = 0;
- JOB->res.sumX = 0;
- for_each_data(&(JOB->res.boxlist)) {
- box4 = (struct box *)list_get_current(&(JOB->res.boxlist));
- if( box4->c != PICTURE ){
- x0 = box4->x0; x1 = box4->x1;
- y0 = box4->y0; y1 = box4->y1;
- i++;
- if (JOB->res.avX * JOB->res.avY > 0) {
- if (x1 - x0 + 1 > 4 * JOB->res.avX
- && y1 - y0 + 1 > 4 * JOB->res.avY) continue; /* small picture */
- if (4 * (y1 - y0 + 1) < JOB->res.avY || y1 - y0 < 2)
- continue; // dots .,-_ etc.
- }
- if (x1 - x0 + 1 < 4
- && y1 - y0 + 1 < 6 ) continue; /* dots etc */
- JOB->res.sumX += x1 - x0 + 1;
- JOB->res.sumY += y1 - y0 + 1;
- JOB->res.numC++;
- }
- } end_for_each(&(JOB->res.boxlist));
- if ( JOB->res.numC ) { /* avoid div 0 */
- JOB->res.avY = (JOB->res.sumY+JOB->res.numC/2) / JOB->res.numC;
- JOB->res.avX = (JOB->res.sumX+JOB->res.numC/2) / JOB->res.numC;
- }
- if (JOB->cfg.verbose){
- fprintf(stderr, "# averages: mXmY= %d %d nC= %d n= %d\n",
- JOB->res.avX, JOB->res.avY, JOB->res.numC, i);
- }
- return 0;
-}
-
-
-/* ---- analyse boxes, find pictures and mark (do this first!!!)
- */
-int detect_pictures(job_t *job) {
- int i = 0, x0, y0, x1, y1, num_h;
- struct box *box2, *box4;
-
- if ( job->res.numC == 0 ) {
- if (job->cfg.verbose) fprintf(stderr,
- "# detect.C L%d Warning: numC=0\n", __LINE__);
- return -1;
- }
- /* ToDo: set Y to uppercase mean value? */
- job->res.avY = (job->res.sumY+job->res.numC/2) / job->res.numC;
- job->res.avX = (job->res.sumX+job->res.numC/2) / job->res.numC;
- /* ToDo: two highest volumes? crosses, on extreme volume + on border */
- if (job->cfg.verbose)
- fprintf(stderr, "# detect.C L%d pictures, frames, mXmY= %d %d ... ",
- __LINE__, job->res.avX, job->res.avY);
- for_each_data(&(job->res.boxlist)) {
- box2 = (struct box *)list_get_current(&(job->res.boxlist));
- if (box2->c == PICTURE) continue;
- x0 = box2->x0; x1 = box2->x1;
- y0 = box2->y0; y1 = box2->y1;
-
- /* pictures could be of unusual size */
- if (x1 - x0 + 1 > 4 * job->res.avX || y1 - y0 + 1 > 4 * job->res.avY) {
- /* count objects on same baseline which could be chars */
- /* else: big headlines could be misinterpreted as pictures */
- num_h=0;
- for_each_data(&(job->res.boxlist)) {
- box4 = (struct box *)list_get_current(&(job->res.boxlist));
- if (box4->c == PICTURE) continue;
- if (box4->y1-box4->y0 > 2*(y1-y0)) continue;
- if (2*(box4->y1-box4->y0) < y1-y0) continue;
- if (box4->y0 > y0 + (y1-y0+1)/2
- || box4->y0 < y0 - (y1-y0+1)/2
- || box4->y1 > y1 + (y1-y0+1)/2
- || box4->y1 < y1 - (y1-y0+1)/2) continue;
- // ToDo: continue if numcross() only 1, example: |||IIIll|||
- num_h++;
- } end_for_each(&(job->res.boxlist));
- if (num_h>4) continue;
- box2->c = PICTURE;
- i++;
- }
- /* ToDo: pictures could have low contrast=Sum((pixel(p,x,y)-160)^2) */
- } end_for_each(&(job->res.boxlist));
- // start second iteration
- if (job->cfg.verbose) {
- fprintf(stderr, " %d - boxes %d\n", i, job->res.numC-i);
- }
- calc_average();
- return 0;
-}
+++ /dev/null
-/*
-This is a Optical-Character-Recognition program
-Copyright (C) 2000-2006 Joerg Schulenburg
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- see README for email address */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <memory.h>
-#include "pgm2asc.h"
-#include "gocr.h"
-
-/* initialize job structure */
-void job_init(job_t *job) {
- /* init source */
- job->src.fname = "-";
- /* FIXME jb: init pix */
- job->src.p.p = NULL;
-
- /* init results */
- list_init( &job->res.boxlist );
- list_init( &job->res.linelist );
- job->res.avX = 5;
- job->res.avY = 8;
- job->res.sumX = 0;
- job->res.sumY = 0;
- job->res.numC = 0;
- job->res.lines.dy=0;
- job->res.lines.num=0;
-
- /* init temporaries */
- list_init( &job->tmp.dblist );
- job->tmp.n_run = 0;
- /* FIXME jb: init ppo */
- job->tmp.ppo.p = NULL;
- job->tmp.ppo.x = 0;
- job->tmp.ppo.y = 0;
-
- /* init cfg */
- job->cfg.cs = 0;
- job->cfg.spc = 0;
- job->cfg.mode = 0;
- job->cfg.dust_size = -1; /* auto detect */
- job->cfg.only_numbers = 0;
- job->cfg.verbose = 0;
- job->cfg.out_format = UTF8; /* old: ISO8859_1; */
- job->cfg.lc = "_";
- job->cfg.db_path = (char*)NULL;
- job->cfg.cfilter = (char*)NULL;
- job->cfg.certainty = 95;
-}
-
-/* free job structure */
-void job_free(job_t *job) {
-
- /* if tmp is just a copy of the pointer to the original image */
- if (job->tmp.ppo.p==job->src.p.p) job->tmp.ppo.p=NULL;
-
- /* FIMXE jb: free lists
- * list_free( &job->res.linelist );
- * list_free( &job->tmp.dblist );
- */
-
- list_and_data_free(&(job->res.boxlist), (void (*)(void *))free_box);
-
- /* FIXME jb: free pix */
- if (job->src.p.p) { free(job->src.p.p); job->src.p.p=NULL; }
-
- /* FIXME jb: free pix */
- if (job->tmp.ppo.p) { free(job->tmp.ppo.p); job->tmp.ppo.p=NULL; }
-
-}
+++ /dev/null
-/*
-This is a Optical-Character-Recognition program
-Copyright (C) 2000-2006 Joerg Schulenburg
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- see README for email address
-
- ***********************************IMPORTANT*********************************
- Notes to the developers: read the following notes before using these
- functions.
- * Be careful when using for_each_data() recursively and calling list_del.
- It may mangle with the current[] pointers, and possibly segfault or do an
- unpredictable or just undesirable behavior. We have been working on a
- solution for this problem, and solved some of the biggest problems.
- In a few words, the problem is this: when you delete a node, it may be
- the current node of a lower level loop. The current code takes care of
- access to previous/next elements of the now defunct node. So, if you do
- something like:
-
- for_each_data(l) {
- for_each_data(l) {
- list_del(l, header_data);
- free(header_data);
- } end_for_each(l);
-+ tempnode = list_cur_next(l);
- } end_for_each(l);
-
- It will work, even though the current node in the outer loop was deleted.
- However, if you replace the line marked with + with the following code:
-
- tempnode = list_next(l, list_get_current(l));
-
- it will break, since list_get_current is likely to return NULL or garbage,
- since you deleted header_data().
- Conclusion: use list_del carefully. The best way to avoid this problem is
- to not use list_del inside a big stack of loops.
- * If you have two elements with the same data, the functions will assume
- that the first one is the wanted one. Not a bug, a feature. ;-)
- * avoid calling list_prev and list_next. They are intensive and slow
- functions. Keep the result in a variable or, if you need something more,
- use list_get_element_from_data.
-
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "list.h"
-#include "progress.h"
-
-void list_init( List *l ) {
- if ( !l )
- return;
-
- l->start.next = &l->stop;
- l->stop.previous = &l->start;
- l->start.previous = l->stop.next = NULL;
- l->start.data = l->stop.data = NULL;
- l->current = NULL;
- l->level = -1;
- l->n = 0;
-}
-
-/* inserts data before data_after. If data_after == NULL, appends.
- Returns 1 on error, 0 if OK. */
-int list_ins( List *l, void *data_after, void *data) {
- Element *e, *after_element;
-
- /* test arguments */
- if ( !l || !data )
- return 1;
-
- if ( !data_after || !l->n )
- return list_app(l, data);
-
- /* get data_after element */
- if ( !(after_element = list_element_from_data(l, data_after)) )
- return 1;
-
- /* alloc a new element */
- if( !(e = (Element *)malloc(sizeof(Element))) )
- return 1;
- e->data = data;
- e->next = after_element;
- e->previous = after_element->previous;
- after_element->previous->next = e;
- after_element->previous = e;
- l->n++;
-
- return 0;
-}
-
-/* appends data to the list. Returns 1 on error, 0 if OK. */
-/* same as list_ins(l,NULL,data) ??? */
-int list_app( List *l, void *data ) {
- Element *e;
-
- if ( !l || !data )
- return 1;
- if ( !(e = (Element *)malloc(sizeof(Element))) )
- return 1;
-
- e->data = data;
- e->previous = l->stop.previous;
- e->next = l->stop.previous->next;
- l->stop.previous->next = e;
- l->stop.previous = e;
- l->n++;
- return 0;
-}
-
-/* returns element associated with data. */
-Element *list_element_from_data( List *l, void *data ) {
- Element *temp;
-
- if ( !l || !data || !l->n)
- return NULL;
-
- temp = l->start.next;
-
- while ( temp->data != data ) {
- if ( !temp || temp==&l->stop )
- return NULL;
- temp = temp->next;
- }
- return temp;
-}
-
-/* deletes (first) element with data from list. User must free data.
- Returns 0 if OK, 1 on error.
- This is the internal version, that shouldn't be called usually. Use the
- list_del() macro instead.
- */
-int list_del( List *l, void *data ) {
- Element *temp;
- int i;
-
- if (!data) return 1; /* do not delete start or stop element */
-
- /* find element associated with data */
- if ( !(temp = list_element_from_data(l, data)) )
- return 1;
-
- /* test if the deleted node is current in some nested loop, and fix it. */
- for ( i = l->level; i >= 0; i-- ) {
- if ( l->current[i] == temp ) {
- l->current[i] = temp->previous;
- }
- }
-
- temp->previous->next = temp->next;
- temp->next->previous = temp->previous;
- temp->previous = temp->next = NULL; /* mark as freed */
-/*
- fprintf(stderr,"\n# list_del=%p start=%p stop=%p",temp,&l->start,&l->stop);
-*/
-
- /* and free stuff */
- free(temp); /* element pointing to data, fixed mem-leak 0.41 */
- l->n--;
- return 0;
-}
-
-/* frees list. See also list_and_data_free() */
-void list_free( List *l ) {
- Element *temp, *temp2;
-
- if ( !l || !l->n )
- return;
-
- if ( l->current ) {
- free(l->current);
- }
- l->current = NULL;
-
- temp = l->start.next;
- while ( temp && temp!=&l->stop) {
- temp2 = temp->next;
- free(temp);
- temp = temp2;
- }
- l->start.next = &l->stop;
- l->stop.previous = &l->start;
-}
-
-/* setup a new level of for_each */
-int list_higher_level( List *l ) {
- Element **newcur;
-
- if ( !l ) return(1);
-
- /*
- Security-check: NULL pointer passed to realloc.
- ANSI allows this, but it may cause portability problems.
- */
- newcur = (Element **)realloc(l->current, (l->level+2)*sizeof(Element *));
- if (newcur) {
- l->current = newcur;
- l->level++;
- l->current[l->level] = l->start.next;
- }
- g_debug(fprintf(stderr, " level++=%d current[]=%p\n",
- l->level, l->current);)
- if ( !newcur ) {
- fprintf(stderr, " realloc failed! abort\n"); return(1);
- }
- return 0;
-}
-
-void list_lower_level( List *l ) {
- if ( !l )
- return;
-
- if (!l->level) {
- free(l->current); /* calm -lefence */
- l->current = NULL; /* could be important */
- } else {
- l->current = (Element **)realloc(l->current, l->level*sizeof(Element *));
- }
- l->level--;
- g_debug(fprintf(stderr, " level--=%d current[]=%p\n", l->level,
- l->current);)
-}
-
-/* returns the next item data */
-void *list_next( List *l, void *data ) {
- Element *temp;
-
- if ( !l || !(temp = list_element_from_data(l, data)) )
- return NULL;
- if( !temp->next ) return NULL;
- return (temp->next->data);
-}
-
-/* returns the previous item data */
-void *list_prev( List *l, void *data ) {
- Element *temp;
-
- if ( !l || !(temp = list_element_from_data(l, data)) )
- return NULL;
- if( !temp->previous ) return NULL;
- return (temp->previous->data);
-}
-
-/* Similar to qsort. Sorts list, using the (*compare) function, which is
- provided by the user. The comparison function must return an integer less
- than, equal to, or greater than zero if the first argument is considered to
- be respectively less than, equal to, or greater than the second.
- Uses the bubble sort algorithm.
- */
-void list_sort( List *l, int (*compare)(const void *, const void *) ) {
- Element *temp, *prev;
- int i, sorted;
- progress_counter_t *pc = NULL;
-
- if ( !l )
- return;
-
- /* start progress meter, sorting is slow for huge number of elements */
- /* l->n is the worst case, real time is less or equal estimated time */
- pc = open_progress(l->n,"list_sort");
-
- for (i = 0; i < l->n; i++ ) {
- sorted = 1; /* Flag for early break */
- for ( temp = l->start.next->next;
- temp != NULL && temp != &l->stop; temp = temp->next ) {
- if ( temp->previous == &l->start ) continue;
- if ( compare((const void *)temp->previous->data,
- (const void *)temp->data) > 0 ) {
-
- sorted = 0; /* rest flag */
- /* swap with the previous node */
- prev = temp->previous;
- prev->previous->next = temp;
- temp->next->previous = prev;
- temp->previous = prev->previous;
- prev->next = temp->next;
- prev->previous = temp;
- temp->next = prev;
- /* and make sure the node in the for loop is correct */
- temp = prev;
-
-#ifdef SLOWER_BUT_KEEP_BY_NOW
-/* this is a slower version, but guaranteed to work */
- void *data;
-
- data = temp->data;
- prev = temp->previous;
- list_del(l, data);
- list_ins(l, prev->data, data);
- temp = prev;
-#endif
- }
- }
- if (sorted) break;
- progress(i,pc); /* progress meter */
- }
-
- close_progress(pc);
- g_debug(fprintf(stderr, "list_sort()\n");)
-}
-
-/* calls free_data() for each data in list l,
- * before free list with list_free() */
-int list_and_data_free( List *l, void (*free_data)(void *data)) {
- void *data;
-
- if ( !l ) return 0;
- if ( !free_data ) return 1;
-
- for_each_data(l) {
- if ((data = list_get_current(l)))
- free_data(data);
- } end_for_each(l);
-
- list_free(l);
-
- g_debug(fprintf(stderr, "list_and_data_free()\n");)
-
- return 0;
-}
-
+++ /dev/null
-/*
- rule based OCR engine, partly rewritten for edges (old=pixel)
- */
-/*
-This is a Optical-Character-Recognition program
-Copyright (C) 2000-2007 Joerg Schulenburg
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- see README for email address
-
- >>> DO NOT EDIT THIS FILE IF YOU NOT REALLY KNOW WHAT YOU ARE DOING! <<<
-
- I have invested lot of time, to write this part of the program.
- This engine should recognize chars allways right or return UNKNOWN.
- If you change something, test all other example files too,
- to be sure that all things work better. (JoergS)
-
- This engine was pixelbased until 0.40 which was not successfull enough.
- Also code changes always hade side effects. The vectorisation of the code
- starts from version 0.41 with the chars XNz and seems to be much better
- to handle. Vectorization means we frame each character by a chain of
- vectors and dont care about pixels anymore. Unfortunatly I have to
- replace all the pixel codes, which is a long process. Old code will be lost.
- (JorgS)
-
-
-ToDo:
- - if box1->p and b differ, reduce probability
- - probability makes life much easier here
- - use only one box!?, may be bits have usefull infos
- - divide this file, suggestion: classify chars:
- high=ABCDEFGHIJKLMNOPQRSTUVWXYZbdfhklt, low=acegijmnopqrsuvwxyz
- or
- often_used=etianmsurwdkgo rarely_used=hvjcflpqxyz.,:
- or
- every char (large overhead)
- - two-pass version (first pass without tolerance)
- 2nd pass with tolerance (ex: one tiny more in sdata->holes)
-
- general feature extraction:
- - white holes at middle, upper, lower position (cost much time)
- - test lines and triangles insteat of rectangles
-
- char is removed, wchar_t is used (better code)
-
- making a static global variable-set x.x0,x.x1, and call test_a,
- test_b ... (faster compilation, but not reentrant!)
-
- - adding slant-angle (if detected) to distinguish between l and / ?
- - ac (alternate chars) as string add_ac(box1,"/") => box1->ac="Il/";
- for better context correction or output: "Ha[lI][lI]o!"
-
-*/
-
-#include <stdlib.h>
-#include <stdio.h>
-// #include "pgm2asc.h"
-#include "ocr0.h"
-// #include "ocr1.h"
-#include "pnm.h"
-#include "gocr.h"
-
-#define IFV if(JOB->cfg.verbose&4)
-#define MM {IFV fprintf(stderr,"\nDBG %c L%04d (%d,%d): ",(char)c_ask,__LINE__,box1->x0,box1->y0);}
-
-// the old debug mode (0.40) was only for a special char, for another char
-// code must be recompiled with C_ASK='char'
-// new debug mode (0.41) explains why char is declined or accepted as ABC...
-// the output can be filtered by external scripts
-// ToDo: we could reduce output to filter string
-#ifndef DO_DEBUG /* can be defined outside */
-#define DO_DEBUG 0 /* 0 is the default */
-#endif
-
-/* this macro is for debugging output: "if char is declined, why?" */
-#if DO_DEBUG /* 0=Work mode, 1=debugging mode */
-// Setac: output, that char is choosen with a probability
-// Break: output, why the char is not choosen
-// MSG: debugging functions for char C_ASK, mostly messages
-// DBG: definitions usefull only for debugging
-#define Setac(box1,ac,ad) { MM;IFV fprintf(stderr,"setac %d",ad);setac(box1,ac,ad); }
-#define Break { MM;IFV fprintf(stderr,"break"); break; }
-#define MSG(x) { MM;IFV x }
-#define DBG(x) x
-#else
-#define Setac(box1,ac,ad) setac(box1,ac,ad)
-#define Break break
-#define MSG(x)
-#define DBG(x)
-#endif
-
-/* extern "C"{ */
-
-// static inline int sq(int x) { return x*x; } /* square */
-
-/*
- * go from vector j1 to vector j2 and measure maximum deviation of
- * the steps from the line connecting j1 and j2
- * return the squared maximum distance
- * in units of the box size times 1024
- * ToDo: 1) better give back max-dx and max-dy ???
- * errors if j1 and j2 are in different frames or belong to
- * more then one frame?
- * 2) Better get deviation from a complete vector graphic?
- * The vectorgraphic is the ideal test char adapted to the
- * extrem vertices of the real char.
- */
-int line_deviation( struct box *box1, int j1, int j2 ) {
- int r1x, r1y, r2x, r2y, r3x, r3y, i, x, y, d, dist, maxdist=0, frame, l2;
- r1x=box1->frame_vector[j1][0];
- r1y=box1->frame_vector[j1][1];
- r2x=box1->frame_vector[j2][0];
- r2y=box1->frame_vector[j2][1];
- if (!box1->num_frames) return(-1);
- if (j1<0 || j1>box1->num_frame_vectors[box1->num_frames-1] ||
- j2<0 || j2>box1->num_frame_vectors[box1->num_frames-1]) {
- fprintf(stderr,"Error in "__FILE__" L%d: idx out of range",__LINE__);
- return(-1);
- }
- /* get the frame the endvector belongs to */
- for (i=0;i<box1->num_frames;i++)
- if (j2<box1->num_frame_vectors[i]) break;
- frame=i;
- /* frame(j1)<=frame(j2) possible */
- for (i=j1;;i++) { // do it for each vector between j1 and j2
- if (i >= box1->num_frame_vectors[frame])
- i=((frame)?box1->num_frame_vectors[frame-1]:0); /* go around */
- if (i==j2) break;
- // for (i=j1;i!=j2;i=(i+1)%box1->num_frame_vectors[0]) {~}
- r3x=box1->frame_vector[i][0];
- r3y=box1->frame_vector[i][1];
- // Language=german
- // german: Abstand Punkt von Strecke, Laenge Lotrechte
- // germ.Strecke : l1=(r1+r2)/2+d*(r2-r1)/2 for d=-1..1
- // germ.Lotrechte: l2=r3+b*[-(r2-r1).y,(r2-r1).x]
- // Schnittpunkt : l1=l2,
- // eq1x: (r1x+r2x)/2-r3x+d*(r2x-r1x)/2+b*(r2y-r1y)=0
- // eq1y: (r1y+r2y)/2-r3y+d*(r2y-r1y)/2-b*(r2x-r1x)=0
- // eq2x: b*(r2x-r1x)*(r2y-r1y)=-((r1x+r2x)/2-r3x+d*(r2x-r1x)/2)*(r2x-r1x)
- // eq2y: b*(r2x-r1x)*(r2y-r1y)= ((r1y+r2y)/2-r3y+d*(r2y-r1y)/2)*(r2y-r1y)
- // eq2y-eq2x: ... in units of 1024 (fast integer rounded correctly)
- l2=sq(r2x-r1x)+sq(r2y-r1y); // square of distance r2-r1
- if (l2==0) {
- // fprintf(stderr,"ocr0 L%d: r1==r2 r1= %d %d",__LINE__, r1x, r1y); // debugging
- d=-1024;
- } else
- d=-( ((r1x+r2x)-2*r3x)*(r2x-r1x)
- +((r1y+r2y)-2*r3y)*(r2y-r1y))*1024/l2; // ..-1024..+1024..
- if (d<=-1024) { x=r1x; y=r1y; } // starting point
- else {
- if (d>=1024) { x=r2x; y=r2y; } // end point
- else {
- x=((r1x+r2x)+1)/2+(d*(r2x-r1x))/2048;
- y=((r1y+r2y)+1)/2+(d*(r2y-r1y))/2048;
- /* we have the crossing point x,y now */
- }
- }
- dist=sq((x-r3x)*1024/(box1->x1-box1->x0+1))
- +sq((y-r3y)*1024/(box1->y1-box1->y0+1)); // 0..2*sq(1024)
- if (dist>maxdist) maxdist=dist;
- // for debugging:
- // fprintf(stderr,"\nDBG dev: %d-%d-%d dist=%5d max=%5d d=%d %d,%d-%d,%d"
- // " vector= %d %d crosspoint= %d %d ",
- // j1,i,j2,dist,maxdist,d,r1x,r1y,r2x,r2y,r3x,r3y,x,y);
- }
- return maxdist;
-}
-
-/*
- * search vectors between j1 and j2 for nearest point a to point r
- * example:
- *
- * r-> $$...$$ $ - mark vectors
- * @@$..@@ @ - black pixels
- * @@$..@@ . - white pixels
- * @@@@.$@
- * a-> @@$@$@@
- * @$.@@@@
- * @@..$@@
- * @@..$@@
- * j1 --> $$...$$ <-- j2
- *
- * ToDo: vector aa[5] = {rx,ry,x,y,d^2,idx} statt rx,ry?
- * j1 and j2 must be in the same frame
- * return aa?
- */
-int nearest_frame_vector( struct box *box1, int j1, int j2, int rx, int ry) {
- int x,y,d,i,aa[4]; /* x,y,normalized_distance^2,vector_index */
- int frame=0, x0=box1->x0, y0=box1->y0,
- x1=box1->x1, y1=box1->y1,
- dx=box1->x1-x0+1, dy=box1->y1-y0+1;
- if (!box1->num_frames) return(-1);
- if (j1<0 || j1>box1->num_frame_vectors[box1->num_frames-1] ||
- j2<0 || j2>box1->num_frame_vectors[box1->num_frames-1]) {
- fprintf(stderr,"Error in "__FILE__" L%d: idx %d-%d out of range\n",__LINE__,j1,j2);
- //out_x(box1);
- return(-1);
- }
- aa[0]=x=box1->frame_vector[j2][0]; /* x */
- aa[1]=y=box1->frame_vector[j2][1]; /* y */
- /* maximum is (distance*128)^2 if r is inside the box */
- aa[2]=d=2*sq(128)+sq((rx-(x0+x1)/2)*128/dx)+sq((ry-(y0+y1)/2)*128/dy);
- aa[3]=j2; /* vector index */
- /* get the frame the endvector belongs to */
- for (i=0;i<box1->num_frames;i++)
- if (j2<box1->num_frame_vectors[i]) break;
- frame=i;
- /* frame(j1)<=frame(j2) possible */
- for (i=j1;;i++) {
- if (i >= box1->num_frame_vectors[frame])
- i=((frame)?box1->num_frame_vectors[frame-1]:0); /* go around */
- x=box1->frame_vector[i][0]; /* take a vector */
- y=box1->frame_vector[i][1];
- /* distance to upper left end, normalized to 128 */
- d=sq((x-rx)*128/dx)+sq((y-ry)*128/dy);
- if (d<aa[2]) { aa[0]=x; aa[1]=y; aa[2]=d; aa[3]=i; }
- if (i==j2) break;
- }
- return aa[3];
-}
-
-// test for umlauts, if ret>0 and m==1 box1 is changed
-// m>0 modify box1->dots
-// m==2 modify box1->y0
-// called by pgm2asc + ocr0(?)
-int testumlaut(struct box *box1, int cs, int m, wchar_t *modifier){
- // pix p=*(box1->p);
- int r,y,x,x0,x1,y0,y1,dx,dy,m1,m2,m3,
- xl,xr,yu,yl; // left, right, upper and lower border of dots
- wchar_t mod='\0'; /* (TeX-) modifier ~"'` for compose() */
- DBG( wchar_t c_ask='"'; )
- r=0;
- x0=box1->x0; x1=box1->x1; dx=x1-x0+1;
- y0=box1->y0; y1=box1->y1; dy=y1-y0+1;
- m1=box1->m1; m2=box1->m2; m3=box1->m3;
- xl=x0; xr=x1; yu=yl=y0;
- if( dy < 5 || 4*y0 > 3*m2+m3 ) return 0; // no low chars: .,-=
- /* modifier in box included? */
- if( 2*y1 > m1+m2 ){
- /* modifier in box included? */
- for(y=y0;2*y<y0+y1;y++)if( get_bw(xl,xr,y,y,box1->p,cs,1)==0 ) break;
- if( 2*y<y0+y1 ){ /* yes => extract */
- yl=y;
- while( get_bw(xl,xr,y,y,box1->p,cs,1)==0 && 2*y<=y0+y1) y++;
- if( m&2 ) box1->y0=y; /* set new upper bond */
- }
- }
- if( yu>=yl ) { if(m) box1->dots=0; return 0; } /* nothing found */
- if( get_bw(xl-1,xl-1,yu,yl-1,box1->p,cs,1)==1 ) // neighbour overlap?
- while( get_bw(xl ,xl ,yu,yl-1,box1->p,cs,1)==1 && 2*xl<x0+x1) xl++;
- for(;xl<x1;xl++)if( get_bw(xl,xl,yu,yl,box1->p,cs,1)==1 ) break;
- for(;xr>xl;xr--)if( get_bw(xr,xr,yu,yl,box1->p,cs,1)==1 ) break;
-
- if ( yl-1>yu ) { // tall box ij"a"o"u
-#if 0
- x=box1->y0; box1->y0=m1; out_x(box1); box1->y0=x;
- fprintf(stderr,"\n#testumlaut x= %d %d m1=%d m2=%d",x0,y0,m1-y0,m2-y0);
- fprintf(stderr," yu=%d yl=%d xl=%d xr=%d",yu-y0,yl-y0,xl-x0,xr-x0);
-#define DEBUG 1
-#endif
- {
-
- x=xl;y=yu;
- if( get_bw(xl,x1+1,yu,yl-1,box1->p,cs,1)==0 ) r=0; // neighbour overlap?
- else
- if( get_bw(xl ,xl ,yu,yl-1,box1->p,cs,1)==0
- || get_bw(xl-1,xl-1,yu,yl-1,box1->p,cs,1)==0 ) // be sure there are gap to neighbours
- if( get_bw(xr ,xr ,yu,yl-1,box1->p,cs,1)==0
- || get_bw(xr+1,xr+1,yu,yl-1,box1->p,cs,1)==0 )
- { int i,j,x;
- r=1;
- // ...@@@.... RING_ABOVE // ..@@@..@@. TILDE
- // ..@...@... // @@.@@@@@..
- // ..@...@... // @.........
- // ..@..@@...
- // ...@@@....
- for (i=yu;i<yl;i++) if (get_bw(xl,xr,i,i,box1->p,cs,1)==1) break;
- for ( ;i<yl;i++) if (get_bw(xl,xr,i,i,box1->p,cs,1)==0) break;
- for (j=xl;j<xr;j++) if (get_bw(j,j,yu,i,box1->p,cs,1)==1) break;
- for ( ;j<xr;j++) if (get_bw(j,j,yu,i,box1->p,cs,1)==0) break;
- for ( x=j;x<xr;x++) if (get_bw(x,x,yu,i,box1->p,cs,1)==1) break;
- // vert. gap detected
- if( j<xr && x<xr && j<x && xr-xl>2
- && num_obj(xl,xr,yu,yl-1,box1->p,cs)>=2 // not best!!!
- && num_cross(xl,xr,yu +(yl-yu)/4,yu+ (yl-yu)/4,box1->p,cs) == 2
- && num_cross(xl,xr,yl-1-(yl-yu)/2,yl-1-(yl-yu)/2,box1->p,cs) == 2
- ){ // may be the following lines are not quite ok
- while( get_bw(xl,xr,yl,yl,box1->p,cs,1)==0 && 2*yl<y0+y1) yl++;
- r=2;
-// out_x(box1);printf(" x,y=%d,%d i=%d xl=%d xr=%d yu=%d yl=%d",x0,y0,i-x0,xl-x0,xr-x0,yu-y0,yl-y0);
- mod = DIAERESIS;
- }
- if( m&2 ) box1->y0=yl;
-/* if( m&2 ) box1->y0= ( (r==1) ? yu : yl ); */
- // out_x(box1);
- }
- if(r==0){ // divided fr != fi
- while( get_bw(x0,x1,yu,yu,box1->p,cs,1)==0 && 2*yu<y0+y1) yu++;
- if(m)box1->y0=yu;
- }
- if( r==1 ){ yl--;
-// .@@@. ..@@.
-// .@@.. .@@..
-// .@... .@@..
-//
-// if( loop(box1->p,xl,yu,xr-xl,cs,0,RI)
-// > loop(box1->p,xl,yl,xr-xl,cs,0,RI) // +dx/8
-// && loop(box1->p,xr,yu,xr-xl,cs,0,LE)
-// < loop(box1->p,xr,yl,xr-xl,cs,0,LE)) // -dx/8 ) // é Nov03
- if( loop(box1->p,xl,yu,xr-xl,cs,0,RI)
- - loop(box1->p,xr,yu,xr-xl,cs,0,LE)
- > loop(box1->p,xl,yl,xr-xl,cs,0,RI) // +dx/8
- - loop(box1->p,xr,yl,xr-xl,cs,0,LE)+1) // -dx/8 ) // é Nov03
- mod = ACUTE_ACCENT; // '
-
- if( xr-xl+1 > 3*(yl-yu+1)
- && get_bw(xl,xr,yu,yl,box1->p,cs,2)==0 )
- mod = MACRON; // "-" above
-
-// .@@@. .@@..
-// ..@@. ..@@.
-// ...@. ..@@.
-//
-// if( loop(box1->p,xl,yu,xr-xl,cs,0,RI)
-// < loop(box1->p,xl,yl,xr-xl,cs,0,RI) // -dx/8
-// && loop(box1->p,xr,yu,xr-xl,cs,0,LE)
-// > loop(box1->p,xr,yl,xr-xl,cs,0,LE) ) // +dx/8 ) à Nov03
- if( loop(box1->p,xl,yu,xr-xl,cs,0,RI)
- - loop(box1->p,xr,yu,xr-xl,cs,0,LE)
- < loop(box1->p,xl,yl,xr-xl,cs,0,RI) // -dx/8
- - loop(box1->p,xr,yl,xr-xl,cs,0,LE) -1 ) // +dx/8 ) à Nov03
- mod = GRAVE_ACCENT; // `
-
-#ifdef DEBUG
- fprintf(stderr,"\n#testumlaut x= %d %d m1=%d m2=%d",x0,y0,m1-y0,m2-y0);
- fprintf(stderr," yu=%d yl=%d xl=%d xr=%d",yu-y0,yl-y0,xl-x0,xr-x0);
-#endif
- if( (xr-xl+1) < 2*(yl-yu+1)+2
- && 2*(xr-xl+1)+2 > (yl-yu+1) ) {
- int i,i1,i2,i3,i4;
- i1=loop(box1->p,xl ,(yu+yl)/2,xr-xl+1,cs,0,RI);
- i1=loop(box1->p,xl+i1,(yu+yl)/2,xr-xl+1,cs,1,RI);
- i2=loop(box1->p,(xl+xr)/2,yu ,yl-yu+1,cs,0,DO);
- i2=loop(box1->p,(xl+xr)/2,yu+i2,yl-yu+1,cs,1,DO);
- for (i=0;i<xr-xl+1 && i<yl-yu+1;i++)
- if (getpixel(box1->p,xl+i,yu+i)< cs) break; i3=i;
- for ( ;i<xr-xl+1 && i<yl-yu+1;i++)
- if (getpixel(box1->p,xl+i,yu+i)>=cs) break; i3=i-i3;
- for (i=0;i<xr-xl+1 && i<yl-yu+1;i++)
- if (getpixel(box1->p,xr-i,yu+i)< cs) break; i4=i;
- for ( ;i<xr-xl+1 && i<yl-yu+1;i++)
- if (getpixel(box1->p,xr-i,yu+i)>=cs) break; i4=i-i4;
-#ifdef DEBUG
- fprintf(stderr,"\n#DEBUG DOT_ABOVE %d %d %d %d",i1,i2,i3,i4);
-#endif
- if ( (xr-xl<5 && yl-yu<8) /* to small */
- || (i1>=(xr-xl+1)/2+2 && i2>=(yl-yu+1)/2+2 /* symmetrical */
- && abs(i3-i4)<=i1/4+2 && abs(i1-i2)<=i1/4+2
- && abs(i3-i1)<=i1/4+4 && abs(i4-i2)<=i1/4+4)
- )
- mod = DOT_ABOVE; // "." above, ToDo: improve it!
- }
-
- if( ( loop(box1->p,xl,yu ,xr-xl,cs,0,RI)
- > loop(box1->p,xl,yl ,xr-xl,cs,0,RI)-dx/8
- || loop(box1->p,xl,yu ,xr-xl,cs,0,RI)
- > loop(box1->p,xl,yl-1,xr-xl,cs,0,RI)-dx/8 )
- && ( loop(box1->p,xr,yu ,xr-xl,cs,0,LE)
- > loop(box1->p,xr,yl ,xr-xl,cs,0,LE)-dx/8
- || loop(box1->p,xr,yu ,xr-xl,cs,0,LE)
- > loop(box1->p,xr,yl-1,xr-xl,cs,0,LE)-dx/8 )
- && num_cross(xl,xr,yu ,yu ,box1->p,cs) == 1
- && ( num_cross(xl,xr,yl ,yl ,box1->p,cs) == 2
- || num_cross(xl,xr,yl-1,yl-1,box1->p,cs) == 2 ))
- mod = CIRCUMFLEX_ACCENT; // "^"
-
- if( ( loop(box1->p,xl,yu ,xr-xl,cs,0,RI)
- < loop(box1->p,xl,yl ,xr-xl,cs,0,RI)-dx/10
- || loop(box1->p,xl,yu+1,xr-xl,cs,0,RI)
- < loop(box1->p,xl,yl ,xr-xl,cs,0,RI)-dx/10 )
- && ( loop(box1->p,xr,yu ,xr-xl,cs,0,LE)
- < loop(box1->p,xr,yl ,xr-xl,cs,0,LE)-dx/10
- || loop(box1->p,xr,yu+1,xr-xl,cs,0,LE)
- < loop(box1->p,xr,yl ,xr-xl,cs,0,LE)-dx/10 )
- && ( num_cross(xl,xr,yu ,yu ,box1->p,cs) == 2
- || num_cross(xl,xr,yu+1,yu+1,box1->p,cs) == 2 )
- && num_cross(xl,xr,yl ,yl ,box1->p,cs) == 1 )
- mod = CARON; // "v" above
-
- if( /* test for bow (new0.3.6) */
- loop(box1->p,xl,yu ,xr-xl,cs,0,RI)
- + loop(box1->p,xl,yl ,xr-xl,cs,0,RI)
- - 2*loop(box1->p,xl,(yl+yu)/2,xr-xl,cs,0,RI) > dx/16+1
- && xr-xl>10)
- if( ( loop(box1->p,xl,yu ,xr-xl,cs,0,RI)
- < loop(box1->p,xl,yl ,xr-xl,cs,0,RI)-dx/10
- || loop(box1->p,xl,yu+1,xr-xl,cs,0,RI)
- < loop(box1->p,xl,yl ,xr-xl,cs,0,RI)-dx/10 )
- && ( loop(box1->p,xr,yu ,xr-xl,cs,0,LE)
- < loop(box1->p,xr,yl ,xr-xl,cs,0,LE)-dx/10
- || loop(box1->p,xr,yu+1,xr-xl,cs,0,LE)
- < loop(box1->p,xr,yl ,xr-xl,cs,0,LE)-dx/10 )
- && ( num_cross(xl,xr,yu ,yu ,box1->p,cs) == 2
- || num_cross(xl,xr,yu+1,yu+1,box1->p,cs) == 2 )
- && num_cross(xl,xr,yl ,yl ,box1->p,cs) == 1 )
- mod = BREVE; // round "u" above
-
- if( xr-xl>3 && yl-yu>1 )
- if( loop(box1->p,xl,yu,xr-xl,cs,0,RI)
- > loop(box1->p,xl,yl,xr-xl,cs,0,RI)
- && loop(box1->p,xr,yu,xr-xl,cs,0,LE)
- < loop(box1->p,xr,yl,xr-xl,cs,0,LE)
- && num_cross(xl,xr,yu,yu,box1->p,cs) == 2
- && num_cross(xl,xr,yl,yl,box1->p,cs) == 2 )
- mod = TILDE;
-
- if( xr-xl>2 && yl-yu>2)
- if( num_cross(xl,xr,(yu+yl)/2,(yu+yl)/2,box1->p,cs) >1 )
- if( num_cross((xl+xr)/2,(xl+xr)/2,yu,yl,box1->p,cs) >1 )
- if( num_hole(xl,xr,yu,yl,box1->p,cs,NULL) == 1 )
- mod = RING_ABOVE;
-
-#ifdef DEBUG
- printf("\n#DEBUG umlaut mod=0x%04x x=%d..%d y=%d..%d r=%d %s",
- (int)mod,yu-box1->y0,yl-box1->y0,
- xl-box1->x0,xr-box1->x0,r,((mod==CARON)?"CARON":
- ((mod==ACUTE_ACCENT)?"ACUTE":
- ((mod==TILDE)?"TILDE":"?"))));
- out_x(box1);
-#endif
-
- }
- }
- if (m) box1->dots=r; // set to 0 also possible after division
- if (m) box1->modifier=mod; /* should be resetted after compose ??? */
- MSG(fprintf(stderr,"umlaut mod=%s dots=%d y0o=%d",decode(mod,ASCII),r,y0);)
- }
-// printf(" modifier=%c",mod);
- if (modifier) *modifier=mod; /* set modifier */
- return r;
-}
-
-
-static wchar_t ocr0_eE(ocr0_shared_t *sdata){
- struct box *box1=sdata->box1;
- int i,i1,i2,j,d,x,y,hchar=sdata->hchar,gchar=sdata->gchar,bad_e=0,
- x0=box1->x0,x1=box1->x1,y0=box1->y0,y1=box1->y1,cs=sdata->cs;
- int dx=x1-x0+1,dy=y1-y0+1, /* size */
- ad; /* tmp-vars */
- int (*aa)[4]=sdata->aa; /* corner-points, (x,y,dist^2,vector_idx) */
-
- // --- most frequent letter e first!!!
- // --- test e ---------------------------------------------------
- for(ad=d=100;dx>2 && dy>3;){ // min 3x4 (smallest seen is 5x6)
- DBG( wchar_t c_ask='e'; )
- if (sdata->holes.num > 2) Break; /* tolerant against a tiny hole */
- if (sdata->holes.num != 1) ad=97*ad/100;
- /* ToDo: may be a two pass version intolerant/tolerant is better */
- if( loop(box1->p,x0,y0+dy/2,x1-x0,cs,0,RI)>dx/3 ) Break; // rough test
- if( loop(box1->p,x0+dx/2,y0,y1-y0,cs,0,DO)>dy/3 ) Break;
- if( loop(box1->p,x0+dx/2,y1,y1-y0,cs,0,UP)>dy/3 ) Break;
- if( num_cross(x0,x1,y0+dy/4 ,y0+dy/4 ,box1->p,cs) > 2
- && num_cross(x0,x1,y0+dy/4+1,y0+dy/4+1,box1->p,cs) > 2 ) Break; // gt
- x=(x0+x1)/2;i= num_cross(x,x,y0,y1,box1->p,cs); // v0.40
- if (i!=3) { x=(x0+2*x1)/3;i= num_cross(x,x,y0,y1,box1->p,cs); }
- if (i!=3) { x=(x0+3*x1)/4;i= num_cross(x,x,y0,y1,box1->p,cs); }
- if (i!=3) { i= num_cross((x0+2*x1)/3,(x0+x1)/2,y0,y1,box1->p,cs); }
- i=loop(box1->p,x0,y0+dy/2,x1-x0,cs,0,RI); if( i>dx/2 ) Break;
- j=loop(box1->p,x0,y0 ,x1-x0,cs,0,RI); if( j<i ) Break;
- j=loop(box1->p,x0,y1 ,x1-x0,cs,0,RI); if( j<i ) Break;
- i=loop(box1->p,x0+dx/2,y0,y1-y0,cs,0,DO); if( i>dx/2 ) Break;
- j=loop(box1->p,x1-dx/3,y0,y1-y0,cs,0,DO); if( j<i ) i=j;
- j=loop(box1->p,x0 ,y0,y1-y0,cs,0,DO); if( j<i ) Break;
- j=loop(box1->p,x1 ,y0,y1-y0,cs,0,DO); if( j<i ) Break;
- i=loop(box1->p,x0+dx/2,y1,y1-y0,cs,0,UP); if( i>dx/2 ) Break;
- j=loop(box1->p,x0 ,y1,y1-y0,cs,0,UP); if( j<i ) Break;
- j=loop(box1->p,x1 ,y1,y1-y0,cs,0,UP); if( j<i ) Break;
- j=2*loop(box1->p,x0, (y0+y1)/2,x1-x0,cs,0,RI)
- -loop(box1->p,x0,(3*y0+y1)/4,x1-x0,cs,0,RI)
- -loop(box1->p,x0,(y0+3*y1)/4,x1-x0,cs,0,RI);
- if (dx>3 && j>=dx/4) Break; // ~g 4x6font
- for(y=1;y<dy/2;y++) if( num_cross(x0,x1,y0+y,y0+y,box1->p,cs) == 2 ) break;
- if( y==dy/2 ) Break; // v0.2.5 ~ bad_t
- for(i=0,j=x0+dx/4;j<=x1-dx/4 && i<=dx/4;j++)
- if( num_cross(j,j,y0,y1,box1->p,cs) == 3 ) i++;
- if( dx>4 && dy>5 && (i<dx/4-1 || i==0) ) Break; // ~g but 4x6-e
- // look for horizontal white line (right gap) => set x,y
- for(x=0,y=i=y0+dy/3;i<y1-dy/6;i++){
- j=loop(box1->p,x1,i,y1-y0,cs,0,LE);
- if(j>=x) { x=j;y=i; }
- }
- if (x<dx/2){ // no gap found, fat font???
- // check smallest thickness left > 2* smallest thickness right
- for(i1=dx,i=y0+dy/3;i<y1-dy/6;i++){
- j =loop(box1->p,x0 ,i,y1-y0,cs,0,RI); if (j>dx/2) break;
- j =loop(box1->p,x0+j,i,y1-y0,cs,1,RI);
- if (j<i1) i1=j; // smallest thickness on left bow
- }
- for(i2=dx,y=i=y0+dy/3;i<y1-dy/6;i++){
- j =loop(box1->p,x1 ,i,y1-y0,cs,0,LE);
- j =loop(box1->p,x1-j,i,y1-y0,cs,1,LE);
- if(j<i2) { i2=j;y=i; }
- } if (3*i2>2*i1) Break; // not accepted, if right line is not very thinn
- x =loop(box1->p,x1 ,y,y1-y0,cs,0,LE);
- x+=loop(box1->p,x1-x,y,y1-y0,cs,1,LE);
- x+=loop(box1->p,x1-x,y,y1-y0,cs,0,LE);
- if (3*i2>i1) ad=99*ad/100;
- if (2*i2>i1) ad=99*ad/100;
- bad_e=60; // used later?
- }
- if (x<dx/2) Break;
- for(i=1,j=x0+dx/6;j<x1-dx/6 && i;j++)
- if( num_cross(j,j,y0,y,box1->p,cs) > 1 ) i=0;
- if( i ) Break;
-// ..@@@@...<-
-// .@@@@@@;.
-// @@,...@@.
-// @@.....@,
-// @@@@@@@@@
-// @@.,;.@,. <- problem (y) == bad_e>50
-// @@.....@.
-// @@,...@@.
-// .@@@,@@@.
-// ..@@@@;..<-
- if (dy>11 && bad_e<50)
- if ( num_cross(x0,x1,y,y,box1->p,cs) != 1 ) Break; // except "geschwungenem e"
- if ( num_cross(x0,x1-dx/3,y ,y ,box1->p,cs) != 1
- && num_cross(x0,x1-dx/3,y+1,y+1,box1->p,cs) != 1 ) Break;
- // if( num_hole(x0, x1, y0 , y ,box1->p,cs,NULL) < 1 ){
- if( sdata->holes.num == 0 || sdata->holes.hole[0].y1 >= y-y0){
- if( sdata->hchar ) Break; // ~ \it t
- // look if thinn font (may be h-line is broken) Mai00
- for(j=0,i=x0+dx/8;i<x1-1;i++)
- if( get_bw(i,i,y0+dy/4,y,box1->p,cs,1) == 1 ) j++;
- if(j<2*dx/4) Break;
- }
- if( sdata->holes.num>0 && sdata->holes.hole[0].y0 > y-y0) Break;
- if( sdata->holes.num>1 && sdata->holes.hole[1].y0 > y-y0) Break;
- if( sdata->holes.num==1 && sdata->holes.hole[0].x0 >= dx/2) {
- ad=95*ad/100; } /* 8*10 @ (=at) is not an e */
- // look for horizontal gap
- for(x=0,y=i=y0+dy/4;i<y1-dy/4;i++){
- j=loop(box1->p,x0,i,x1-x0,cs,0,RI);
- if(j>=x) { x=j;y=i; }
- }
- if (y>y0+dy/4 && y<y1-dy/4 && x>dx/2) Break; // s
- if (x>dx/4) ad=99*ad/100;
-
- if( num_cross(x0+dx/2,x1 ,y1-dy/4,y1 ,box1->p,cs) == 0
- && num_cross(x0+dx/2,x1-1,y1-dy/4,y1 ,box1->p,cs) == 0
- && num_cross(x0+dx/2,x1 ,y1-dy/4,y1-1,box1->p,cs) == 0 ) {
- if (sdata->gchar) Break; // ~p
- ad=99*ad/100;
- }
- /* upper case is for 5x6 box */
- if( sdata->hchar // broken B ? should also work when linedetection fails
- && loop(box1->p,x1,y1-dy/3,dx,cs,0,LE)<=dx/8 ) {
- x = loop(box1->p,x0,y0+dy/2,dx,cs,0,RI);
- if( loop(box1->p,x0,y0+dy/4,dx,cs,0,RI)<=x
- && loop(box1->p,x0,y0+dy/8,dx,cs,0,RI)<=x ) Break;
- if( loop(box1->p,x0,y1-dy/4,dx,cs,0,RI)<=x
- && loop(box1->p,x0,y1-dy/8,dx,cs,0,RI)<=x ) Break;
- }
- x = loop(sdata->bp,0,dy-2 ,dx,cs,0,RI);
- if( loop(sdata->bp,0,dy-1-dy/8,dx,cs,0,RI)>x && dy>16) Break; // some Q
- if (box1->m2) {
- if (sdata->gchar) ad=99*ad/100;
- if (sdata->hchar) ad=99*ad/100;
- } else ad=99*ad/100;
-
- Setac(box1,(wchar_t)'e',ad);
- if (ad>=100) return 'e';
- break;
- }
- // --- test E ---------------------------------------------------
- for(ad=d=100;dx>2 && dy>4 ;){ // min 3x4
- // rewritten for vectors 0.43
- int i1, i2, i3, i4, i5; // line derivation + corners
- DBG( wchar_t c_ask='E'; )
- if (sdata->holes.num > 1) Break; /* tolerant against a tiny hole */
- /* half distance to the center */
- d=2*sq(128/4);
- /* now we check for the upper right end of the h */
- if (aa[3][2]>d/2) Break; /* [2] = distance, ~dj... */
- if (aa[0][2]>d/2) Break; /* upper left end */
- if (aa[1][2]>d/2) Break; /* lower left end */
- if (aa[2][2]>d/2) Break; /* lowerright end */
-/*
- E f near E
-
- OOOOOOOO OOOO
- O5 O O
- O4 O
- OOOO3 OOOOOO
- O2 O
- O O
- O1 O O
- OOOOOOOO OOOOOO
-*/
- // check the bow from below
- for (i=aa[1][3];i!=aa[2][3];i=(i+1)%box1->num_frame_vectors[0]) {
- if (y1-box1->frame_vector[ i][1]>dy/4) break; // fatal!
- } if (i!=aa[2][3]) Break; // ~AHKMNRX
- // search most left+down between bottom right and top right
- i1=nearest_frame_vector(box1, aa[2][3],aa[3][3], x0, y1);
- i5=nearest_frame_vector(box1, i1,aa[3][3], x0, y0);
- i3=nearest_frame_vector(box1, i1, i5, x1, (y0+y1)/2);
- i2=nearest_frame_vector(box1, i1, i3, x0, (2*y0+y1)/3);
- i4=nearest_frame_vector(box1, i3, i5, x0, (y0+2*y1)/3);
- i =nearest_frame_vector(box1, aa[0][3],aa[1][3], x0-dx/4, (y0+y1)/2);
- if (2*box1->frame_vector[i][0] < aa[0][0]+aa[1][0]-1-dx/16) Break;
- if (2*box1->frame_vector[i][0] < aa[0][0]+aa[1][0]) ad=99*ad/100; // f
-
- MSG(fprintf(stderr,"i1-5 %d %d %d %d %d",i1,i2,i3,i4,i5);)
- // holes right open?
- for( i=1,y=y0; y<y0+dy/4 && i; y++ ) // long black line
- if( get_bw(x0+dx/3,x1-dx/6,y,y,box1->p,cs,2) == 0 ) i=0;
- if( i ) Break;
- for( i=1,y=y1; y>y1-dy/4 && i; y-- ) // long black line
- if( get_bw(x0+dx/6,x1-dx/4,y,y,box1->p,cs,2) == 0 ) i=0;
- if( i ) Break;
- for( i=1,y=y0+dy/3; y<y1-dy/3 && i; y++ ){ // black line
- j=loop(box1->p,x0 ,y,dx,cs,0,RI);
- j=loop(box1->p,x0+j,y,dx,cs,1,RI); if( j>dx/3 ) i=0;
- } if( i ) Break;
- x=x1-dx/3; y=y0; // von oben durchbohren!
- turmite(box1->p,&x,&y,x0,x1,y0,y1,cs,DO,ST); if( y>y0+dy/4 ) Break;
- turmite(box1->p,&x,&y,x0,x1,y0,y1,cs,ST,DO); if( y>y0+dy/3 ) Break;
- turmite(box1->p,&x,&y,x0,x1,y0,y1,cs,RI,DO); if( x<=x1 || y>y0+dy/2 ) Break;
- x=x1-dx/3; y=y1; // von unten durchbohren!
- turmite(box1->p,&x,&y,x0,x1,y0,y1,cs,UP,ST); if( y<y1-dy/4 ) Break;
- turmite(box1->p,&x,&y,x0,x1,y0,y1,cs,ST,UP); if( y<y0-dy/3 ) Break;
- turmite(box1->p,&x,&y,x0,x1,y0,y1,cs,RI,UP); if( x<=x1 || y<y0+dy/2 ) Break;
- x=x1-dx/3; y=y0; // von oben durchbohren!
- turmite(box1->p,&x,&y,x0,x1,y0,y1,cs,DO,ST); if( y>y0+dy/4 ) Break;
- turmite(box1->p,&x,&y,x0,x1,y0,y1,cs,ST,DO); if( y>y0+dy/3 ) Break;
- y+=dy/15;
- turmite(box1->p,&x,&y,x0,x1,y0,y1,cs,LE,ST); if( x<x0 ) Break;
- if (dx>15 && x==x0) ad=99*ad/100; // to thin
- x+=dx/15+1;
- turmite(box1->p,&x,&y,x0,x1,y0,y1,cs,DO,ST); if( y>y1-dy/3 ) Break;
- // if( num_hole(x0, x1, y0 , y1 ,box1->p,cs,NULL) > 0 ) Break;
- if (sdata->holes.num > 0) Break;
- i=loop(box1->p,x0,y0+dy/4,dx,cs,0,RI); if(i>dx/2) Break;
- j=loop(box1->p,x0,y0+dy/2,dx,cs,0,RI); if(j<i-dx/4 || j>i+dx/8) Break; i=j;
- j=loop(box1->p,x0,y1-dy/4,dx,cs,0,RI); if(j<i-dx/4 || j>i+dx/8) Break;
- j=loop(box1->p,x1,y1-dy/4,dx,cs,0,LE);
- for( x=dx,y=y0+dy/6; y<y1-dy/9; y++ ) // left border straight
- { i=loop(box1->p,x0,y,dx,cs,0,RI);
- if (i>j/2 && ad>98) ad=99*ad/100;
- if (i>dx/4) break;
- if(i<x) x=i;
- } if( y<y1-dy/9 ) Break; // t
- if(dy>3*dx) // ~[
- if( get_bw(x0+dx/2,x0+dx/2,y0+dy/4,y1-dy/4,box1->p,cs,1) == 0 ) Break;
-
- if (box1->m2) {
- if (!hchar) ad=ad*99/100;
- if ( gchar) ad=ad*99/100;
- }
- Setac(box1,(wchar_t)'E',ad);
- if (ad>=100) return 'E';
- break;
- }
- return box1->c;
-}
-
-static wchar_t ocr0_n(ocr0_shared_t *sdata){
- struct box *box1=sdata->box1;
- int i,j,d,x,y,i1,i2,i3,handwritten=0,
- x0=box1->x0,x1=box1->x1,y0=box1->y0,y1=box1->y1,cs=sdata->cs;
- int dx=x1-x0+1,dy=y1-y0+1, /* size */
- ad; /* tmp-vars */
-
- // --- test n ---------------------------------------------------
- // glued rm is very similar to glued nn -> thickness of h-line should grow
- // may02: tested for 8x12 font
- for(ad=d=100;dx>2 && dy>3;){ // min 3x4
- DBG( wchar_t c_ask='n'; )
- if (sdata->holes.num > 1) Break; /* tolerant against a tiny hole */
- i= num_cross( 0,dx-1,dy/4,dy/4,sdata->bp,cs);
- j= num_cross( 0,dx-1,dy/2,dy/2,sdata->bp,cs);
- if( (i<2 || i>3) && j!=2 ) Break;
- if( loop(sdata->bp,dx/2,0,dy,cs,0,DO) > dy/8 && sdata->hchar ) Break; /* tt */
- y=5*dy/8; /* also for handwritten n, where first bow goes not down enough */
- if( num_cross( 0,dx/2,y ,y ,sdata->bp,cs) != 1
- && num_cross( 0,dx/2,y-1,y-1,sdata->bp,cs) != 1
- && num_cross(dx/2,dx-1,y ,y ,sdata->bp,cs) < 1 ) Break; // n rr
- // ~thick_w
- y=loop(sdata->bp,dx-1-dx/4,0,dy,cs,0,DO); if(y>dy/2) Break;
- if(y>1)if( get_bw(dx-1-dx/4,dx-1,0,y-2,sdata->bp,cs,1) == 1 ) Break;
-
- y=3*dy/4;
- if( num_cross(0, dx/2,y ,y ,sdata->bp,cs) == 1
- && num_cross(dx/2,dx-1,y ,y ,sdata->bp,cs) == 0 ) Break; // ~p
- y=dy/2;
- if( num_cross(0,dx-1,dy/2-dy/8,dy/2-dy/8,sdata->bp,cs) == 2
- && num_cross(0,dx-1,dy/2, dy/2 ,sdata->bp,cs) == 2 ) { // n rr
- /* printed n */
- x =loop(sdata->bp,0,y,dx ,cs,0,RI); if(x> dx/4) Break; // search 1st v-line
- x+=loop(sdata->bp,x,y,dx-x,cs,1,RI); if(x> dx/2) Break; i1=x; // 1st gap
- x+=loop(sdata->bp,x,y,dx-x,cs,0,RI); if(x< dx/2) Break; i2=x; // 2nd v-line
- x+=loop(sdata->bp,x,y,dx-x,cs,1,RI); if(x<3*dx/4) Break; i3=x; // 2nd gap
- i=dy/4; y=13*dy/16;
- if( num_cross(dx/2,dx-1,y,y,sdata->bp,cs)==2 ) i=3*dy/8; // \it n
- if (i<2 && i<dy/2) i++; // correct for small fonts like 8x12
- // the same game for the lower part =>l1 l2 l3 l4 ???
- for(x=i1;x<i2;x++) if( loop(sdata->bp,x, 0,dy,cs,0,DO)>=i ) break;
- if(x <i2) Break; // gap detected
- for(x=i1;x<i2;x++) if( loop(sdata->bp,x,dy-1,dy,cs,0,UP) >dy/4 ) break;
- if(x==i2) Break; // no gap detected (glued serifs ??? )
- // glued rm as nn ???
- for(y=0,x=(i1+i2)/2;x<i2;x++){
- i=loop(sdata->bp,x,0,dy,cs,0,DO);
- i=loop(sdata->bp,x,i,dy,cs,1,DO); // measure thickness
- if( i>y ) y=i; if( i<y/2 ) break;
- }
- if(x <i2) Break; // unusual property for n
- if( dy>7 )
- if( loop(sdata->bp,dx-1,dy-1-dy/8,dx,cs,0,LE)
- +loop(sdata->bp, 0,dy-1-dy/8,dx,cs,0,RI)-dx/8-1
- > loop(sdata->bp,dx-1,dy-1-dy/2,dx,cs,0,LE)
- +loop(sdata->bp, 0,dy-1-dy/2,dx,cs,0,RI) ) ad=90*ad/100; // broken o
- if( dy>7 && dx>7 )
- if( loop(sdata->bp,dx-1, dy/2,dx,cs,0,LE)==0
- && loop(sdata->bp,dx-1,dy-1-dy/8,dx,cs,0,RI)>dx/8 ) ad=98*ad/100; // broken o
- } else { /* check handwritten n */
- if( num_cross(0,dx-1,dy/2, dy/2 ,sdata->bp,cs) != 3
- && num_cross(0,dx-1,dy/2-dy/8,dy/2-dy/8,sdata->bp,cs) != 3 ) Break;
- i =loop(sdata->bp,0,dy/2-dy/8,dx,cs,0,RI); if (i>dx/4) Break;
- i+=loop(sdata->bp,i,dy/2-dy/8,dx,cs,1,RI); if (i>dx/2) Break;
- i+=loop(sdata->bp,i,dy/2-dy/8,dx,cs,0,RI);
- if( num_cross(i,i, 0,dy/2-2*dy/8,sdata->bp,cs) != 0 ) Break;
- i+=loop(sdata->bp,i,dy/2-dy/8,dx,cs,1,RI);
- if( num_cross(i,i,dy/2+1, dy-1,sdata->bp,cs) != 0 ) Break;
- handwritten=80;
- }
-
- i= loop(sdata->bp,dx-1 ,dy/2,dx,cs,0,LE); if(i>5)
- if( get_bw(dx-1-i/2,dx-1-i/2,0,dy/2,sdata->bp,cs,1) == 1 ) Break; // ~rr
- i+=loop(sdata->bp,dx-1-i,dy/2,dx,cs,1,LE);
- if( get_bw(dx-1-i ,dx-1-i ,0,dy/2,sdata->bp,cs,1) == 0 ) Break; // ~rv
-
- if( get_bw(dx/2,dx/2,dy/4,dy/4,sdata->bp,cs,1) == 0
- && get_bw(dx/2,dx-1,dy-2,dy-2,sdata->bp,cs,1) == 0
- && get_bw(dx/2,dx/2,dy/4,dy-2,sdata->bp,cs,1) == 1 ) Break; // ~P
-
- // glued ri ???
- if( box1->dots>0 && box1->m1 )
- if( get_bw((x1+x0)/2,x1,box1->m1,y0-1,box1->p,cs,1) == 1 )
- if( num_cross( 0,dx-1,0 ,0 ,sdata->bp,cs) >2
- || num_cross( 0,dx-1,1 ,1 ,sdata->bp,cs) >2 ) Break;
-
-
- i=loop(sdata->bp,dx-1, dy-1,dx,cs,0,LE); if (i>dx/2)
- i=loop(sdata->bp,dx-1, dy-2,dx,cs,0,LE);
- x=loop(sdata->bp,dx-1,dy-1-dy/4,dx,cs,0,LE);
- if (sdata->hchar && i-x>1) Break; // ß
- x=loop(sdata->bp, 0,dy-1,dx,cs,0,LE); // check for serifs
- i=loop(sdata->bp, 0,dy-2,dx,cs,0,LE); if (i<x) x=i;
- i=loop(sdata->bp, 0, 1,dx,cs,0,LE); if (i<x) x=i;
- i=loop(sdata->bp, 0, 2,dx,cs,0,LE); if (i<x) x=i;
- if (sdata->hchar && x>0) Break; // fl
-
- if (num_cross( 0,dx-1,dy/4,dy/4,sdata->bp,cs)>=3) ad=98*ad/100; // small M
- if (sdata->hchar || 2*y0<box1->m1+box1->m2) ad=96*ad/100;
- if (sdata->gchar) ad=96*ad/100; // ß fl
- if (dx<5) { // for small fonts no middle line is possible for m
- ad=99*ad/100; // 4x6 m
- if (num_cross(0,dx-1,dy/8,dy/8,sdata->bp,cs)>=2) {
- ad=97*ad/100; // ~m
- if (dy<=4) Setac(box1,'m',97); // only for 4x6 font!
- }
- }
- Setac(box1,'n',ad);
- break;
- }
- return box1->c;
-}
-
-static wchar_t ocr0_M(ocr0_shared_t *sdata){
- struct box *box1=sdata->box1;
- pix *bp=sdata->bp;
- int d,x,y,i0,i1,i2,i3,t1,hchar=sdata->hchar,gchar=sdata->gchar,
- x0=box1->x0,x1=box1->x1,y0=box1->y0,y1=box1->y1,cs=sdata->cs;
- int dx=x1-x0+1,dy=y1-y0+1, /* size */
- ad; /* tmp-vars */
-
- // ------------------ test M ---------------------------
- for(ad=d=100;dx>3 && dy>3;){ // dy<=dx nicht perfekt! besser mittleres
- // min-suchen fuer m
- DBG( wchar_t c_ask='M'; )
- if (sdata->holes.num > 1) Break; /* tolerant against a tiny hole */
- if( num_cross(0,dx-1, dy/2, dy/2,bp,cs)<3
- && num_cross(0,dx-1, dy/4, dy/4,bp,cs)<3
- && num_cross(0,dx-1,5*dy/8,5*dy/8,bp,cs)<3
- && num_cross(0,dx-1,3*dy/4,3*dy/4,bp,cs)<3
- && dx>4 ) Break;
- if( num_cross(0,dx-1, dy/4, dy/4,bp,cs)<2
- && num_cross(0,dx-1, dy/8, dy/8,bp,cs)<2 ) Break; /* fat M */
- if( num_cross(0,dx-1,3*dy/4,3*dy/4,bp,cs)<2 ) Break;
-
- x = loop(bp,dx-1 ,dy-1,dx,cs,0,LE); // ~ melted kl
- x = loop(bp,dx-1-x,dy-1,dx,cs,1,LE); if( x>dx/2 ) Break;
-
- if( loop(bp, 0,7*dy/16,dx,cs,0,RI)
- + loop(bp,dx-1,7*dy/16,dx,cs,0,LE) > dx/2 ) Break; // ~K
-
- if( dy>8 /* following lines should be extend to range check */
- && loop(bp, dx/4,dy-1, dy,cs,0,UP)<dy/4
- && loop(bp,3*dx/8,dy-1, dy,cs,0,UP)<dy/4 )
- if( loop(bp, 0,dy-1-dy/ 8,dx,cs,0,RI)
- < loop(bp, 0,dy-1-dy/16,dx,cs,0,RI)-dx/32 ) Break; // ~it_u
- if( num_cross(0,dx-1, dy/2, dy/2,bp,cs)==2
- && num_cross(0,dx-1, dy/4, dy/4,bp,cs)> 2
- && num_cross(0,dx-1,3*dy/4,3*dy/4,bp,cs)> 2 ) Break; // ~it_u
- if( num_cross(0 ,dx-1,3*dy/4,3*dy/4,bp,cs)==2
- && num_cross(dx/2,dx/2,3*dy/4, dy-1,bp,cs)> 0 ) Break; // ~it_v
-
- if( loop(bp,3*dx/4, 0,dy,cs,0,DO)
- > loop(bp,2*dx/4, 0,dy,cs,0,DO)
- && loop(bp,3*dx/4,dy-1,dy,cs,0,UP)
- < loop(bp,2*dx/4,dy-1,dy,cs,0,UP) ) Break; // ~N
- if( loop(bp,3*dx/4, dy/8,dy,cs,0,DO)
- > loop(bp,2*dx/4, dy/8,dy,cs,0,DO)
- && loop(bp,3*dx/4,dy-1-dy/8,dy,cs,0,UP)
- < loop(bp,2*dx/4,dy-1-dy/8,dy,cs,0,UP) ) Break; // ~serif_N
-
- // i0 is lower end of upper serifen (widest gap? )
- i0=0;
-
- if( num_cross(0,dx-1,dy/2,dy/2,bp,cs)!=4 ){ // Is it a N ?
- if( num_cross(0,dx-1,dy/2,dy/2,bp,cs)==3 ){
- for(y=dy/2+1;y<dy;y++){
- if( num_cross(0,dx-1,y,y,bp,cs)<3 ) break;
- }
- if( num_cross(0,dx-1,y,y,bp,cs)==2 ){
- x =loop(bp,dx-1 ,y-1,dx,cs,0,LE);
- x+=loop(bp,dx-1-x,y-1,dx,cs,1,LE);
- x+=loop(bp,dx-1-x,y-1,dx,cs,0,LE);
- if( loop(bp,dx-x,y-1,dy,cs,0,UP)>y-2 ) Break; // ~N
- }
- }
- }
- // MNWK
- for(i2=0,i1=x=dx/2;x<dx-dx/4;x++){ // lowest pixel
- y=loop(bp,x,0,dy,cs,0,DO); if(y>i2) {i2=y;i1=x;} else break; }
- i3=i2+loop(bp,i1,i2,dy-i2,cs,1,DO);
- if(i2<dy/4) {
- if (!sdata->hchar) Break; // rm
- ad=99*ad/100;
- }
- if (i2==0 && dx>8 && dy>12) Break; // glued and bad splitted serifen-MN
-
- // if( num_hole(x0, x1, y0 , y1 ,box1->p,cs,NULL) != 0 ) Break; // small A
- if (sdata->holes.num != 0) Break;
- t1=loop(bp,0 ,3*dy/4,dx,cs,0,RI);
- t1=loop(bp,t1,3*dy/4,dx,cs,1,RI); // thickness of line?
- if( 7*(t1+1)<dx )
- if( num_cross(i1,dx-1,i2-1,i2-1,bp,cs)!=2
- || num_cross(0 ,i1 ,i2-1,i2-1,bp,cs)!=2 ) Break; // too hard ???
-
- // ~u_n-pair
- if( num_cross(0,dx-1,0,0,bp,cs)!=2
- && num_cross(0,dx-1,1,1,bp,cs)!=2
- && num_cross(0,dx-1,2,2,bp,cs)!=2 ) Break;
-
- // ~nn v0.2.4a3
- if( num_cross(0,dx-1, dy/4, dy/4,bp,cs)==4
- && num_cross(0,dx-1,3*dy/4,3*dy/4,bp,cs)==4 ){
- i1 =loop(bp, 0, dy/4,dx,cs,0,RI);
- i1+=loop(bp,i1, dy/4,dx,cs,1,RI);
- i1+=loop(bp,i1, dy/4,dx,cs,0,RI);
- i2 =loop(bp, 0,3*dy/4,dx,cs,0,RI);
- i2+=loop(bp,i2,3*dy/4,dx,cs,1,RI);
- i2+=loop(bp,i2,3*dy/4,dx,cs,0,RI);
- if( i1>=i2 ) Break; // no good M
- i1+=loop(bp,i1, dy/4,dx,cs,1,RI);
- i2+=loop(bp,i2,3*dy/4,dx,cs,1,RI);
- if( i1>=i2 ) Break; // no good M
- i1+=loop(bp,i1, dy/4,dx,cs,0,RI);
- i2+=loop(bp,i2,3*dy/4,dx,cs,0,RI);
- if( i1<=i2 ) Break; // no good M
- }
- if( num_cross(0,dx-1,dy/2,dy/2,bp,cs)==2
- && num_cross(0,dx-1,dy/4,dy/4,bp,cs)==2 && !hchar ) Break; // ~ \it u
-
- if (dy<17)
- if( num_cross(0,dx-1, 0, 0,bp,cs)<2 ) ad=99*ad/100;
- if (dx>5) /* 4x6 font has only 1 cross at y=1 */
- if( num_cross(0,dx-1, 1, 1,bp,cs)<2 ) ad=96*ad/100; // kt
- if( num_cross(dx/2,dx/2, 0, dy-1,bp,cs)!=1) ad=98*ad/100; // kt
- if (dx<5 && loop(bp,dx/2,0,dy,cs,0,DO)>=3*dy/8) ad=96*ad/100; // 4x6 H
-
- if( num_cross(0,dx-1, dy/4, dy/4,bp,cs)<=2
- && num_cross(0,dx-1,3*dy/4,3*dy/4,bp,cs)<=2
- && dx>8 && dy>12 ){
- ad=98*ad/100;
- for(y=5*dy/16;y<5*dy/8;y++) // look for H-line
- if( num_cross(0,dx-1,y ,y ,bp,cs)==1 ) break;
- if( y<5*dy/8 ) ad=95*ad/100;
- if( y<5*dy/8 )
- if( num_cross(2+dx/6,dx-3-dx/6,y-2,y-2,bp,cs)==0
- || num_cross(2+dx/6,dx-3-dx/6,y-1,y-1,bp,cs)==0 ) Break; // ~H bad!
- }
-
- if( loop(bp,3*dx/8, 0,dy,cs,0,DO) >dy/2
- && loop(bp,5*dx/8,dy-1,dy,cs,0,UP) >dy/2 ) ad=95*ad/100;
-
- if(!hchar){
- ad=98*ad/100; /* not sure */
- if( loop(bp,0, dy/4,dx,cs,0,RI)
- < loop(bp,0,dy-1-dy/8,dx,cs,0,RI)-dx/16 ) Break; // ~wi glued
- }
- if( gchar ) ad=98*ad/100;
- if (ad>99 && dx<8) ad=99*ad/100; /* give 5x8 N a chance */
- Setac(box1,'M',ad);
- break;
- }
- return box1->c;
-}
-
-static wchar_t ocr0_N(ocr0_shared_t *sdata){
- struct box *box1=sdata->box1;
- int d,x,y,i1,i2,i3,hchar=sdata->hchar,gchar=sdata->gchar,
- x0=box1->x0,x1=box1->x1,y0=box1->y0,y1=box1->y1;
- int dx=x1-x0+1,dy=y1-y0+1, /* size */
- (*aa)[4]=sdata->aa, /* corner-points, (x,y,dist^2,vector_idx) */
- dbg[9],
- ad; /* tmp-vars */
-
- // --- test N ------- +hchar -gchar
- for(ad=d=100;dx>3 && dy>3;){ // 4x6font
- DBG( wchar_t c_ask='N'; )
- if (sdata->holes.num > 1) Break; /* tolerant against a tiny hole */
- if (sdata->holes.num > 0) ad=98*ad/100; /* # */
- if (dx<6) ad=99*ad/100;
- if (dx<5) ad=99*ad/100;
- /* half distance to the center */
- d=2*sq(128/4);
- /* now we check for the 4 ends of the x */
- if (aa[0][2]>d) Break;
- if (aa[1][2]>d) Break;
- if (aa[2][2]>d) Break;
- if (aa[3][2]>d) Break;
- if (aa[3][0]-aa[0][0]<dx/2) Break;
- if (aa[2][0]-aa[1][0]<dx/2) Break;
- if (aa[1][1]-aa[0][1]<dy/2) Break;
- if (aa[2][1]-aa[3][1]<dy/2) Break;
- if (aa[3][0]-aa[0][0]<4-1) Break; /* to small to hold an N */
- if (aa[2][0]-aa[1][0]<4-1) Break; /* to small */
- if (abs(aa[3][1]-aa[0][1])>(dy+2)/5) Break; /* glued tu */
- if (abs(aa[3][1]-aa[0][1])>(dy+4)/8) ad=98*ad/100; /* glued tu */
- /* left and right vertical line */
- d=line_deviation(box1, aa[0][3], aa[1][3]); if (d>2*sq(1024/4)) Break;
- ad=(100-(d-sq(1024)/2)/sq(1024)/4)*ad/100;
- d=line_deviation(box1, aa[2][3], aa[3][3]); if (d>2*sq(1024/4)) Break;
-
- /* search uppermost left ^ (between near 0,0) */
- i1=nearest_frame_vector(box1,aa[1][3],aa[2][3], x0+dx/8, y0);
- x=box1->frame_vector[i1][0];
- y=box1->frame_vector[i1][1];
- MSG( fprintf(stderr,"i1= %d (%d,%d) left ^", i1,x-x0,y-y0);)
- if (y-y0 > 5*dy/8) Break;
- if (x-x0 > 5*dx/8) Break;
- /* search uppermost right ^ ~H */
- i3=nearest_frame_vector(box1,aa[1][3],aa[2][3], x1, y0);
- MSG( fprintf(stderr,"i3= %d (%d,%d) right ^",\
- i3, box1->frame_vector[i3][0]-x0,box1->frame_vector[i3][1]-y0);)
-
- /* check if upper left and lower right point are joined directly */
- dbg[0]=d=line_deviation(box1,i1, aa[2][3]);
- /* check if lower left and lower left point are joined directly */
- dbg[1]=d=line_deviation(box1, aa[1][3],i1);
- MSG( fprintf(stderr," i1-a2 %d a1-i1 %d",dbg[0],dbg[1]); )
- if (dbg[0] > sq(1024/4)) Break;
- if (dx>4 && dbg[1] > sq(1024/4)) ad=97*ad/100; // d=0..2*sq(1024)
- if (dx>4 && dbg[1] > sq(1024/3)) Break; // d=0..2*sq(1024)
- // serif N has d=sq(1024/3)=116508
-
- /* serach lowest right v, same frame? N-tilde etc.? */
- i2=nearest_frame_vector(box1,aa[3][3],aa[0][3], x1, y1-dy/8);
- x=box1->frame_vector[i2][0];
- y=box1->frame_vector[i2][1];
- MSG( fprintf(stderr,"i2= %d (%d,%d) right v",\
- i2, box1->frame_vector[i2][0]-x0,box1->frame_vector[i2][1]-y0);)
- if (y-y0 < 3*dy/8) Break;
- if (x-x0 < 3*dx/8) Break;
- // test H
- if ( box1->frame_vector[i3][0]-box1->frame_vector[i1][0]> dx/4
- && box1->frame_vector[i3][1]-box1->frame_vector[i1][1]<=dy/8
- && y<=box1->frame_vector[i1][1]) Break;
- /* check if upper left and lower right point are joined directly */
- dbg[2]=d=line_deviation(box1,i2, aa[0][3]);
- /* check if lower right and lower right point are joined directly */
- dbg[3]=d=line_deviation(box1, aa[3][3],i2);
- MSG( fprintf(stderr," i2-a0 %d a3-i2 %d",dbg[2],dbg[3]); )
- if (dbg[2] > sq(1024/4)) Break;
- if (dbg[3] > sq(1024/4)) ad=97*ad/100; // serif N, ToDo: do it better
- if (dbg[3] > sq(1024/3)) Break;
-
- if (abs((box1->frame_vector[i1][1]-y0)
- -(y1-box1->frame_vector[i2][1]))>dy/8) ad=99*ad/100; /* ~ tu */
- if (abs(((y0+y1)/2-box1->frame_vector[i1][1])
- -(box1->frame_vector[i2][1]-(y0+y1)/2))>dy/8) ad=99*ad/100; /* ~ tu */
- if (box1->frame_vector[i2][0]
- -box1->frame_vector[i1][0]<=dx/8) Break; /* nonsignificant distance */
- if (box1->frame_vector[i2][1]
- -box1->frame_vector[i1][1]<=dy/8) ad=97*ad/100; /* too flat (ff,H) */
- if (box1->frame_vector[i2][1]
- -box1->frame_vector[i1][1]<=dy/2) ad=99*ad/100;
- MSG( \
- fprintf(stderr,"^v %d %d %d %d line deviation %d %d %d %d max %d %d",\
- box1->frame_vector[i1][0]-x0,box1->frame_vector[i1][1]-y0,\
- box1->frame_vector[i2][0]-x0,box1->frame_vector[i2][1]-y0,\
- dbg[0],dbg[1],dbg[2],dbg[3],sq(1024/4),sq(1024));)
- ad=(100-(dbg[0]-sq(1024)/2)/sq(1024)/4)*ad/100;
- ad=(100-(dbg[1]-sq(1024)/2)/sq(1024)/4)*ad/100;
- ad=(100-(dbg[2]-sq(1024)/2)/sq(1024)/4)*ad/100;
- ad=(100-(dbg[3]-sq(1024)/2)/sq(1024)/4)*ad/100;
-
- if (!hchar) ad=99*ad/100;
- if ( gchar) ad=98*ad/100; // \sc N
- Setac(box1,'N',ad);
- break;
- }
- return box1->c;
-}
-
-static wchar_t ocr0_h(ocr0_shared_t *sdata){
- struct box *box1=sdata->box1;
- pix *bp=sdata->bp;
- int i,d,x,y,hchar=sdata->hchar,gchar=sdata->gchar,
- x0=box1->x0,x1=box1->x1,y0=box1->y0,y1=box1->y1,cs=sdata->cs;
- int dx=x1-x0+1,dy=y1-y0+1, /* size */
- ad; /* tmp-vars */
- int (*aa)[4]=sdata->aa; /* corner-points, (x,y,dist^2,vector_idx) */
-
- // --- test h ---------------------------------------------------
- for(ad=d=100;dx>2 && dy>3;){ // min 3x4
- // rewritten for vectors 0.42
- int i1, i2, i3, i4, i5, i6, i7, i8; // line derivation + corners
- DBG( wchar_t c_ask='h'; )
- if (sdata->holes.num > 1) Break; /* tolerant against a tiny hole */
- /* half distance to the center */
- d=2*sq(128/4);
- /* now we check for the upper right end of the h */
- if (aa[3][2]<d/4) Break; /* [2] = distance, ~BCDEF... */
- if (aa[0][2]>d/2) Break; /* upper left end */
- if (aa[1][2]>d/2) Break; /* lower left end */
- if (aa[2][2]>d/2) Break; /* lowerright end */
-/*
- type A B=italic ???
- 18 OOO
- O O O
- O O
- O7OOO OOOO
- O4 O O O
- O O O O
- O O O O O
- 2O3 5O6 O OOO
-*/
- i1=i8=aa[0][3];
- i2=i3=aa[1][3];
- i5=i6=aa[2][3];
- // check the bow from below
- for (i4=i=i2;i!=i5;i=(i+1)%box1->num_frame_vectors[0]) {
- if (box1->frame_vector[ i][1]
- <box1->frame_vector[i4][1]) i4=i; // get next maximum
- if (box1->frame_vector[ i][1]<=y0) break; // fatal!
- }
- if (box1->frame_vector[i4][1]-y0<dy/4) Break; // ~MN
- if (y1-box1->frame_vector[i4][1]<dy/4) Break; // ~BCDEGIJLOQSUYZ
- // two steps for i7 to go around pitfalls on italic h
- i7=nearest_frame_vector(box1, i6, i8, (x0+x1)/2, (y0+y1)/2);
- i7=nearest_frame_vector(box1, i6, i7, x0, (y0+y1)/2);
- i3=nearest_frame_vector(box1, i2, i4, (x0+x1)/2, y1);
- i5=nearest_frame_vector(box1, i4, i6, (x0+x1)/2, y1);
-
- MSG(fprintf(stderr,"i1-7 %d %d %d %d %d %d %d",i1,i2,i3,i4,i5,i6,i7);)
- /* ... new part /// old obsolete part ... */
- if( get_bw(0 ,dx/2,dy/8 ,dy/8 ,bp,cs,1) != 1 ) Break;
- if( get_bw(0 ,dx/2,dy/2 ,dy/2 ,bp,cs,1) != 1 ) Break;
- if( get_bw(dx/2 ,dx-1,dy-1-dy/3,dy-1-dy/3,bp,cs,1) != 1 ) Break;
- if( get_bw(dx/2 ,dx/2,dy/5 ,dy-1-dy/3,bp,cs,1) != 1 ) Break;
- if( get_bw(dx-1-dx/3,dx-1,0 ,1 ,bp,cs,1) == 1 ) Break;
- if( get_bw(dx-1-dx/3,dx-1,1 ,dy/6 ,bp,cs,1) == 1 ) Break;
- if( dy>18 )
- if( get_bw(dx-1-dx/3,dx-1,dy/6 ,dy/5 ,bp,cs,1) == 1 ) Break;
- if( get_bw(dx-1-dx/3,dx-1,dy-1-dy/4,dy-1 ,bp,cs,1) == 0 ) Break; // s-
- for( x=x0+dx/3;x<x1-dx/3;x++)
- if( get_bw(x, x,y1-dy/4, y1, box1->p,cs,1) == 0 ) break;
- if( x>=x1-dx/3 ) Break;
- for(i=dy/4,y=y0+dy/3;y<=y1 && i;y++){
- if( num_cross(x0,x1 ,y,y, box1->p,cs) == 2 ) i--;
- } if( i ) Break;
- for(i=dy/4,y=y0;y<=y0+dy/2 && i;y++){
- if( num_cross(x0,x0+dx/2,y,y, box1->p,cs) == 1 ) i--;
- } if( i ) Break;
- // if( num_hole(x0, x1, y0 , y1 ,box1->p,cs,NULL) > 0 ) // could happen
- if (sdata->holes.num > 0)
- if (sdata->holes.hole[0].y0 > dy/3
- && sdata->holes.hole[0].y1 < dy-1-dy/3) Break;
- // if( num_hole(x0, x1, y0+dy/3 , y1-dy/3 ,box1->p,cs,NULL) != 1 ) Break; // mini
- if( loop(bp,dx-1,dy/3,dx,cs,0,LE)+dx/8
- < loop(bp,dx-1,dy/2,dx,cs,0,LE)
- && loop(bp,dx-1,dy-1-dy/8,dx,cs,0,LE)+dx/8
- < loop(bp,dx-1,dy/2,dx,cs,0,LE)) Break; // ~k Okt00
- i=loop(bp,0,dy-1-dy/4,dx,cs,0,RI);
- if (i>1 && num_cross(x0,x0,y0+dy/8+2,y0+dy/2, box1->p,cs) == 1 ){ // fi fu
- ad=(99-(1<<i))*ad/100;
- if (num_cross(x0,x0,y0,y0+dy/8+2, box1->p,cs) == 0 ) ad=97*ad/100;
- if (num_cross(x0+dx/2,x0+dx/2,y0,y0+dy/8+2, box1->p,cs) == 1 ) ad=97*ad/100;
- if (ad<1) break;
- }
- i =loop(bp,0,dy/4,dx,cs,0,RI);
- i+=loop(bp,i,dy/4,dx,cs,1,RI)+1;
- for ( ; i<dx-dx/3; i++ )
- if( loop(bp,i,0,dy,cs,0,DO)>5*dy/8 ) {
- ad=98*ad/100; // melted hi, li, but handwritten h
- MSG(fprintf(stderr,"ad=%d",ad);) }
- if( num_cross(x0,x0,y0+(dy+3)/8,y1,box1->p,cs) > 1 ) {
- ad=98*ad/100; // melted fr
- MSG(fprintf(stderr,"ad=%d",ad);) }
-
- i=loop(bp,dx-1,3*dy/4,dx,cs,0,LE); // melted "fr" for vertikal letters
- if (i>dx/4 && loop(bp,dx-1-i,dy-1,dy,cs,1,UP)>dy/2) {
- ad=94*ad/100; MSG(fprintf(stderr,"ad=%d",ad);) }
-
- i=loop(bp,dx-1,1+dy/16,dx,cs,0,LE); if (i<dx/4) {
- ad=98*ad/100;
- MSG(fprintf(stderr,"ad=%d",ad);) }
- if( num_cross(dx-i+1+dx/8,dx-i+1+dx/8,0,1+dy/16,bp,cs) > 0 ) {
- ad=95*ad/100; // melted fi
- MSG(fprintf(stderr,"ad=%d",ad);) }
- if (loop(box1->p,x1,y0+1+dy/16,dx,cs,0,LE)<dx/4) {
- ad=98*ad/100; // fi
- MSG(fprintf(stderr,"ad=%d",ad);) }
- if (loop(box1->p,x1,y0 ,dx,cs,0,LE)<dx/4
- || loop(box1->p,x1,y0+1,dx,cs,0,LE)<dx/4) {
- ad=98*ad/100; // li
- MSG(fprintf(stderr,"ad=%d",ad);) }
-
-
- if (sdata->holes.num > 0) ad=97*ad/100;
- if (box1->m2) {
- if ( gchar) ad=98*ad/100;
- if (!hchar) ad=97*ad/100;
- } else ad=99*ad/100;
- Setac(box1,'h',ad);
- break;
- }
- return box1->c;
-}
-
-static wchar_t ocr0_H(ocr0_shared_t *sdata){
- struct box *box1=sdata->box1;
- pix *bp=sdata->bp;
- int i,j,j1,d,x,y,ya,i1,i2,i3,hchar=sdata->hchar,gchar=sdata->gchar,
- x0=box1->x0,x1=box1->x1,y0=box1->y0,y1=box1->y1,cs=sdata->cs;
- int dx=x1-x0+1,dy=y1-y0+1, /* size */
- ad; /* tmp-vars */
-
- // --- test H ---------------------------------------------------
- for(ad=d=100;dx>2 && dy>3;){ // min 3x4
- DBG( wchar_t c_ask='H'; )
- if (sdata->holes.num > 1) Break; /* tolerant against a tiny hole */
- if( num_cross(0,dx-1,dy/4 ,dy/4 ,bp,cs) != 2
- && num_cross(0,dx-1,dy/4-1,dy/4-1,bp,cs) != 2 ) Break;
- if( num_cross(0,dx-1,3*dy/4 ,3*dy/4 ,bp,cs) != 2
- && num_cross(0,dx-1,3*dy/4+1,3*dy/4+1,bp,cs) != 2 ) Break;
- if( loop(bp,0 ,dy/8,dx,cs,0,RI)
- + loop(bp,dx-1,dy/8,dx,cs,0,LE)>dx/2 ) Break; // ~A
- for( j1=0,i=1,y=y0+dy/10; y<y1-dy/10 && i; y++ ) // 2 vertikal lines
- { j=loop(box1->p,x0 ,y,dx,cs,0,RI)
- +loop(box1->p,x1 ,y,dx,cs,0,LE); if( j>dx/2 ) i=0; if(j>j1)j1=j; }
- if( !i ) Break;
- for( i=1,y=dy/4; y<dy-1-dy/4 && i; y++ ) // max - min width
- { j=loop(bp,0 ,y,dx,cs,0,RI)
- +loop(bp,dx-1,y,dx,cs,0,LE); if( j1-j>dx/5 ) i=0; }
- if( !i ) Break; // ~K Jul00
- for( i=0,ya=y=y0+dy/3; y<y1-dy/3; y++ ) // horizontal line
- { j=loop(box1->p,x0 ,y,dx,cs,0,RI);
- j=loop(box1->p,x0+j,y,dx,cs,1,RI); if( j>i ) { i=j; ya=y; } }
- if( i<=dx/2 ) Break; ya-=y0;
- if( num_cross(0,dx-1,ya ,ya ,bp,cs) != 1
- && num_cross(0,dx-1,ya+1,ya+1,bp,cs) != 1 ) Break; /* Dec00 */
- for( y=ya; y<dy-dy/4; y++ ) // ~M Dec00
- if( num_cross(0,dx-1,y ,y ,bp,cs) > 2
- && num_cross(0,dx-1,y+1,y+1,bp,cs) > 2 ) break;
- if ( y<dy-dy/4 ) Break;
- for(i=1,x=x0+dx/4;x<=x1-dx/4 && i;x++){
- if( get_bw( x, x,y0 ,y0+dy/4,box1->p,cs,1) == 0 ) i=0;
- } if( i ) Break;
- for(i=1,x=x0+dx/4;x<=x1-dx/4 && i;x++){
- if( get_bw( x, x,y1-dy/4,y1 ,box1->p,cs,1) == 0 ) i=0;
- } if( i ) Break;
- for(i=1,x=x0+dx/4;x<=x1-dx/4 && i;x++){
- if( num_cross(x,x,y0+dy/8,y1-dy/8, box1->p,cs) == 1 ) i=0;
- } if( i ) Break;
- for(i=1,y=y0;y<=y0+dy/4 && i;y++){
- if( num_cross(x0,x1,y,y, box1->p,cs) == 2 ) i=0;
- } if( i ) Break;
- for(i=1,y=y1-dy/4;y<=y1 && i;y++){
- if( num_cross(x0,x1,y,y, box1->p,cs) == 2 ) i=0;
- } if( i ) Break;
- if( get_bw(x1-dx/8, x1 , y0, y0+dy/8,box1->p,cs,1) != 1 ) Break;
- if( get_bw(x0 , x0+dx/8, y1-dy/8, y1,box1->p,cs,1) != 1 ) Break;
- i1=loop(bp,dx-1, dy/4,dx,cs,0,LE); if(i1>dx/2) Break;
- i2=loop(bp,dx-1, dy/2,dx,cs,0,LE); if(i2<i1-dx/4 || i2>i1+dx/8) Break;
- i3=loop(bp,dx-1,dy-1-dy/4,dx,cs,0,LE); if(i3<i2-dx/4 || i3>i2+dx/8) Break;
- if(abs(i1+i3-2*i2)>dx/16+1) Break;
- // test for thick tall N looking like a H
- if( num_cross(x0,x1,y0,y1, box1->p,cs) < 2 ) Break; // sure N
- i1=loop(bp, 0, dy/4,dx,cs,0,RI);
- i1=loop(bp, i1, dy/4,dx,cs,1,RI);
- i2=loop(bp, 0,dy-1-dy/4,dx,cs,0,RI);
- i2=loop(bp, i2,dy-1-dy/4,dx,cs,1,RI);
- i3=loop(bp,dx-1 ,dy-1-dy/4,dx,cs,0,LE);
- i3=loop(bp,dx-1-i3,dy-1-dy/4,dx,cs,1,LE);
- i =loop(bp, 0,dy/2+1+dy/8,dx,cs,0,RI);
- i+=loop(bp, i,dy/2+1+dy/8,dx,cs,1,RI);
- i =loop(bp, i,dy/2+1+dy/8,dx,cs,0,RI);
- if (i<dx/2-1 && 5*i1>6*i2 && 5*i3>6*i2 && i1>i2 && i3>i2 ) Break;
- if( dx>8 )
- if ( loop(bp,dx-1, 3*dy/8,dx,cs,0,LE)
- -loop(bp,dx-1, dy/8,dx,cs,0,LE)>dx/4
- && loop(bp,dx-1, 3*dy/8,dx,cs,0,LE)
- -loop(bp,dx-1,dy-1-dy/8,dx,cs,0,LE)>dx/4 ) Break; // ~K
- // if( num_hole(x0,x1,y0,y1,box1->p,cs,NULL) != 0 ) Break;
- if (sdata->holes.num != 0) Break;
- if ( gchar) ad=99*ad/100;
- if (!hchar) ad=98*ad/100;
- Setac(box1,'H',ad);
- break;
- }
- return box1->c;
-}
-
-static wchar_t ocr0_k(ocr0_shared_t *sdata){
- struct box *box1=sdata->box1;
- pix *bp=sdata->bp;
- int i,j,x,y,hchar=sdata->hchar,gchar=sdata->gchar,
- x0=box1->x0,x1=box1->x1,y0=box1->y0,y1=box1->y1,cs=sdata->cs;
- int dx=x1-x0+1,dy=y1-y0+1, /* size */
- ad; /* tmp-vars */
- int (*aa)[4]=sdata->aa; /* corner-points, (x,y,dist^2,vector_idx) */
-
- // --- test k ---------------------------------------------------
- for(ad=100;dx>2 && dy>3;){ // min 3x4
- // rewritten for vectors 0.43
- int d, i1, i2, i3, i4, i5, i6, i7, i8; // line derivation + corners
- DBG( wchar_t c_ask='k'; )
- if (sdata->holes.num > 1) Break; /* tolerant against a tiny hole */
- /* half distance to the center */
- d=2*sq(128/4);
- /* now we check for the upper right end of the h */
- if (aa[3][2]<d/4) Break; /* [2] = distance, ~BCDEF... */
- if (aa[0][2]>d/2) Break; /* upper left end */
- if (aa[1][2]>d/2) Break; /* lower left end */
- if (aa[2][2]>d/2) Break; /* lowerright end */
-/*
- type A B=italic ???
- 18 OOO
- O O O
- O O6 O
- O7 OO O OO
- O4OO OO OO
- O OO O O
- O OO O O O
- 2O3 O5 O OOO
-*/
- i1=i8=aa[0][3];
- i2=i3=aa[1][3];
- i5= aa[2][3];
- // check the bow from below
- for (i4=i=i2;i!=i5;i=(i+1)%box1->num_frame_vectors[0]) {
- if (box1->frame_vector[ i][1]
- <box1->frame_vector[i4][1]) i4=i; // get next maximum
- if (box1->frame_vector[ i][1]<=y0) break; // fatal!
- }
- if (box1->frame_vector[i4][1]-y0<dy/4) Break; // ~MN
- if (y1-box1->frame_vector[i4][1]<dy/4) Break; // ~BCDEGIJLOQSUYZ
- i6=nearest_frame_vector(box1, i5, i8, x1, (2*y0+y1)/3);
- // two steps for i7 to go around pitfalls on italic h
- i7=nearest_frame_vector(box1, i6, i8, x0, y1);
- i3=nearest_frame_vector(box1, i2, i4, (x0+x1)/2, y1);
- i =nearest_frame_vector(box1, i5, i6, x0, (y0+2*y1)/3);
- if (x1-box1->frame_vector[i][0]<dy/4) Break; // h
- if (x1-box1->frame_vector[i][0]<dy/2) ad=98*ad/100;
-
- MSG(fprintf(stderr,"i1-7 %d %d %d %d %d %d %d",i1,i2,i3,i4,i5,i6,i7);)
- if( num_cross(0, dx-1,0,0,bp,cs) != 1
- && num_cross(0, dx-1,1,1,bp,cs) != 1 ) Break;
- if( num_cross(0,3*dx/4, dy/8 , dy/8 ,bp,cs) != 1
- || num_cross(0,3*dx/4,3*dy/16,3*dy/16,bp,cs) != 1 ) Break;
- if( num_cross(0,dx-1,dy-1,dy-1,bp,cs) != 2
- && num_cross(0,dx-1,dy-2,dy-2,bp,cs) != 2 ) Break;
- if( dx<8
- && num_cross(dx-1,dx-1,dy/4,dy-1,bp,cs) != 2
- && num_cross(dx-2,dx-2,dy/4,dy-1,bp,cs) != 2 ) Break;
- i1=loop(bp,0,dy/2-dy/4,dx,cs,0,RI);
- i2=loop(bp,0,dy/2 ,dx,cs,0,RI);if(i2>dx/2) Break;
- i3=loop(bp,0,dy/2+dy/4,dx,cs,0,RI);
- if(abs(i1+i3-2*i2)>dx/16+1 || i1<i3-1) Break; // v-line on left side?
- if( get_bw(x0 ,x0+dx/2,y0 ,y0+dy/4,box1->p,cs,1) != 1 ) Break;
- if( get_bw(x0+dx/2,x1, y1-dy/3,y1 ,box1->p,cs,1) != 1 ) Break;
- if( get_bw(x1-dx/4,x1, y0 ,y0+3*dy/16,box1->p,cs,1) == 1 ) Break;
- if( get_bw(x1-dx/4,x1, y0+dy/4,y1-dy/4,box1->p,cs,1) != 1 ) Break; //~1
- if( get_bw(x1-dx/4,x1, y1-dy/8,y1 ,box1->p,cs,1) != 1 ) Break;
- if (sdata->holes.num > 0)
- if (sdata->holes.hole[0].y0 > dy/4) Break;
- // if( num_hole(x0,x1,y0+dy/4,y1,box1->p,cs,NULL) != 0 ) Break;
- for(y=y0+1;y<y0+dy/2;y++) // luecke ???
- if( get_bw(x0,x1,y,y,box1->p,cs,1) == 0 ) break;
- if( y<y0+dy/2 ) Break;
- for(i=1,x=x0;x<=x0+dx/2 && i;x++)
- if(get_line(x,y0 ,x ,y1,box1->p,cs,100)>50) i=0;
- if( i ) Break; // no vertikal line!
-
- /* check for falling line in the lower left corner */
- for (j=x=0,y=5*dy/8;y<7*dy/8;y++) {
- i= loop(bp,dx-1,y,dx,cs,0,LE); if(i>x) { x=i;j=y; }
- } // x=dx/6 on fat k
- if (x + loop(bp,dx-1-x,y,dx,cs,1,LE)/2 <dx/4) Break;
- if (x + loop(bp,dx-1-x,y,dx,cs,1,LE)/2 <dx/2) ad=98*ad/100;
- x=dx-1-x; y=j;
- i =loop(bp,dx-1,dy-1,dx,cs,0,LE); if(i>dx/2)
- i =loop(bp,dx-1,dy-2,dx,cs,0,LE); if(i>dx/2) Break;
- i+=loop(bp,dx-1-i,dy-1,dx,cs,1,LE)/2;
- if( get_line(x,y,dx-1-i,dy-1,bp,cs,100)<60 ) Break;
-
- for(y=y0+dy/3;y<y1;y++) if( num_cross(x0,x1,y,y,box1->p,cs)==2 ) break;
- if( y==y1 ) Break;
- if(
- // num_hole(x0,x1 ,y0 ,y1 ,box1->p,cs,NULL)>0 // ~A happens!
- sdata->holes.num > 0 )
- if (sdata->holes.hole[0].x1>dx-1-dx/4
- || sdata->holes.hole[0].y1>dy-1-dy/4
- || sdata->holes.hole[0].y0< dy/4) Break;
- // if ( num_hole(x0,x1-dx/4,y0+dy/4,y1-dy/4,box1->p,cs,NULL)==0 ) Break;
- i=loop(bp,0,dy-1,dx,cs,0,RI);
- i=loop(bp,i,dy-1,dx,cs,1,RI); if (dx>8 && 4*i>3*dx) Break; // ~glued_tz
- i =loop(bp,0,dy/4,dx,cs,0,RI);
- if (i>dx/4
- && i+loop(bp,i,dy/4,dx,cs,1,RI)>dx/2
- && loop(bp, 0,0,dx,cs,0,RI)<=dx/4
- && loop(bp,dx-1,0,dx,cs,0,LE)>=dx/2 ) ad=90*ad/100; // divided Q
-
- if( 2*y0>(box1->m1+box1->m2) ) ad=99*ad/100;
-
- if ( gchar) ad=98*ad/100;
- if (!hchar) ad=98*ad/100;
- Setac(box1,'k',ad);
- break;
- }
- return box1->c;
-}
-
-static wchar_t ocr0_K(ocr0_shared_t *sdata){
- struct box *box1=sdata->box1;
- pix *bp=sdata->bp;
- int i,j,i1,i2,d,x,y,hchar=sdata->hchar,gchar=sdata->gchar,
- x0=box1->x0,x1=box1->x1,y0=box1->y0,y1=box1->y1,cs=sdata->cs;
- int dx=x1-x0+1,dy=y1-y0+1, /* size */
- ad,ya,xa,yb,xb,yc,xc,yd,xd,ye,xe,yf,xf; /* tmp-vars */
-
- // --- test K ---------------------------------------------------
- for(ad=d=100;dx>2 && dy>3;){ // updated 29 Mar 2000 perfect???
- DBG( wchar_t c_ask='K'; )
- if (sdata->holes.num > 1) Break; /* tolerant against a tiny hole */
- for(y=dy/8;y<dy-dy/8;y++)
- if( !get_bw(0,dx/2,y,y,bp,cs,1) ) break;
- if( y<dy-dy/8 ) Break;
- for(j=0,i=1,x=x0+dx/4;x<=x1-dx/4 && i;x++){
- y= loop(box1->p,x,y0,y1-y0,cs,0,DO); if (y>3*dy/4) { i=1;break; }
- if (dy>15 && j>dy/8){
- j =loop(box1->p,x-1,y0+y-1,x1-x0,cs,0,LE)/2;
- y+=loop(box1->p,x-j,y0+y-1,y1-y0,cs,0,DO)-1;
- }
- if(y>=dy/4) i=0; /* ok, found gap */
- } if( i ) Break;
- for(y=0,x=x0+dx/4;x<=x1-dx/4;x++){ // lower h-gap
- i=loop(box1->p,x,y1,dy,cs,0,UP);
- /* on small chars bypass possible low left serifs */
- if (i>0) { i2=loop(box1->p,x-1,y1-i-1,dy,cs,0,UP);
- if (i2>1) i+=i2-1; }
- if (i>y) { y=i; i1=x; }
- } if( y<=dy/8 ) Break; if (y<dy/4) ad=80*ad/100;
- for(i=1,x=x0+dx/3;x<=x1-dx/8 && i;x++){
- if( num_cross(x,x,y0,y1, box1->p,cs) == 2 ) i=0;
- } if( i ) Break;
- for(i=1,y=y0;y<=y0+dy/4 && i;y++){
- if( num_cross(x0,x1,y,y, box1->p,cs) == 2 ) i=0;
- } if( i ) Break;
- if( dx<10 ){
- for(i=1,y=y0+dy/3;y<=y1-dy/3 && i;y++){
- if( num_cross(x0,x1,y,y, box1->p,cs) == 1 ) i=0;
- } if( i ) Break;
- }
- for(i=1,y=y1-dy/4;y<=y1 && i;y++){
- if( num_cross(x0,x1,y,y, box1->p,cs) == 2 ) i=0;
- } if( i ) Break;
- if( get_bw(x1-dx/3,x1,y0,y0+dy/8,box1->p,cs,1) != 1 ) Break; // ~k
- if( dy>16
- && loop(bp,0, dy/4,dx,cs,0,RI)
- +loop(bp,0,3*dy/4,dx,cs,0,RI)
- <2*loop(bp,0, dy/2,dx,cs,0,RI)-2-dx/32 ) Break; // ~X
-
- i=loop(box1->p,x1,y0+ dy/4,x1-x0+1,cs,0,LE); if(i>dx/2) Break;
- j=loop(box1->p,x1,y0+ dy/2,x1-x0+1,cs,0,LE);
- x=loop(box1->p,x1,y0+3*dy/8,x1-x0+1,cs,0,LE); if(x>j) j=x;
- if(j<=i ) Break; i=j;
- j=loop(box1->p,x1,y1-dy/4,x1-x0+1,cs,0,LE); if(j>=i ) Break;
- // out_x(box1); // detailed analysis
- //
- // a d <= that are main points of K
- // | /
- // b/e
- // | \ .
- // c f
- ya= dy/4;xa=loop(bp,0,ya,dx,cs,0,RI);xa+=loop(bp,xa,ya,dx,cs,1,RI)/2;
- yc=dy-dy/4;xc=loop(bp,0,yc,dx,cs,0,RI);xc+=loop(bp,xc,yc,dx,cs,1,RI)/2;
- yb=dy/2; xb=dx-1-loop(bp,dx-1,dy/2,dx,cs,0,LE);
- for(yd=ye=yf=xe=y=i=0,xf=xd=dx;y<dy/4;y++){ // range 0..1/4
- x =loop(bp,dx-1, y,dx,cs,0,LE); if(x<xd){ xd=x;yd= y; }
- x =loop(bp,dx-1,dy-1-y,dx,cs,0,LE); if(x<xf){ xf=x;yf=dy-1-y; }
- x =loop(bp,dx-1,dy/2+y,dx,cs,0,LE); if(x>xe){ xe=x;ye=dy/2+y; }
- x =loop(bp,dx-1,dy/2-y,dx,cs,0,LE); if(x>xe){ xe=x;ye=dy/2-y; }
-#if 0 // removed v0.2.4a2
- x =loop(bp,0 ,dy/2+y,dx,cs,0,RI); // middle left border
- x+=loop(bp,x ,dy/2+y,dx,cs,1,RI); // test 2nd cross
- x+=loop(bp,x ,dy/2+y,dx,cs,0,RI); if(x<xb){ xb=x;yb=dy/2+y; }
-#endif
- x =loop(bp,0 ,dy/2-y,dx,cs,0,RI);
- x+=loop(bp,x ,dy/2-y,dx,cs,1,RI); // test 2nd cross
- x+=loop(bp,x ,dy/2-y,dx,cs,0,RI); if(x<xb){ xb=x;yb=dy/2-y; }
- x =dx-1-loop(bp,dx-1,dy/2-y,dx,cs,0,LE); if(x<xb){ xb=x;yb=dy/2-y; }
- }
- xd=dx-1-xd;xe=dx-1-xe;xf=dx-1-xf;
- xb+=loop(bp,xb,yb,dx,cs,1,RI)/4; // detect center of line
- xe-=loop(bp,xe,ye,dx,cs,1,LE)/4;
- xd-=loop(bp,xd,yd,dx,cs,1,LE)/4;
- xf-=loop(bp,xf,yf,dx,cs,1,LE)/4;
-#if 0
- MSG( \
- printf("a=%d %d b=%d %d c=%d %d d=%d %d e=%d %d f=%d %d dxdy %d %d",\
- xa,ya,xb,yb,xc,yc,xd,yd,xe,ye,xf,yf,dx,dy);\
- )
-#endif
- if( get_line2(xa,ya,xc,yc,bp,cs,100)<95 ) Break;
- if( dx>8 ){ // example szaka0103
- if( xe>5*dx/8 || xb>5*dx/8 ) Break; // ~{\it n}
- i=loop(bp,xb,yb,xb,cs,1,LE); // thick center? see font22
- if( get_line2(xb,yb,xd,yd,bp,cs,100)<95 ) // right up
- if( get_line2(xb-i/2,yb,xd,yd,bp,cs,100)<95 ) Break;
- if( get_line2(xe,ye,xf,yf,bp,cs,100)<95 ) Break; // right down
- xe+=loop(bp,xe,ye,dx,cs,1,RI); if( xe>=xf ) Break; // ~{\it n}
- } else {
- if( dy<16 && !hchar ) Break;
- if( loop(bp,0,1,dy,cs,1,DO)<=3*dx/4
- && loop(bp,1,1,dy,cs,1,DO)<=3*dx/4
- && loop(bp,2,1,dy,cs,1,DO)<=3*dx/4 ) Break; // ~x
- }
- if (loop(bp,dx-1,dy-1-dy/4,dx,cs,0,LE)<=dx/8){
- ad=99*ad/100; /* broken B ? */
- if (sdata->holes.num > 0)
- if (sdata->holes.hole[0].y1 < dy-1-dy/3) Break;
- // if( num_hole(x0,x1,y0,(y0+2*y1)/3,box1->p,cs,NULL)>0) Break; // broken B
- }
- if(box1->m3 && !hchar) ad=99*ad/100;
- if(box1->m3 && gchar) ad=99*ad/100;
- // printf(" ok xe=%d",xe);
- Setac(box1,'K',ad);
- break;
- }
- return box1->c;
-}
-
-static wchar_t ocr0_f(ocr0_shared_t *sdata){
- struct box *box1=sdata->box1;
- pix *bp=sdata->bp;
- int i,j,d,x,y,hchar=sdata->hchar,gchar=sdata->gchar,
- x0=box1->x0,x1=box1->x1,y0=box1->y0,y1=box1->y1,cs=sdata->cs;
- int dx=x1-x0+1,dy=y1-y0+1, /* size */
- (*aa)[4]=sdata->aa, /* the for line ends, (x,y,dist^2,vector_idx) */
- ab[8][4], /* special points (x,y,dist^2,vector_idx) */
- ad; /* tmp-vars */
- /* x=mindist_to_a y=0 "t"
- 0>..$$. 0>..$$ 0>..$$ end right bow a--..$$ a--.$7. y>0 "f"
- 1>.$..$ 1>.$.. 1>.$$$ start right bow .$7. .$..
- .@... .@.. 2>.@@. start upper end .@.. .@..
- 2>.$... 2>.$.. 3>$$$$ crossing bar .$.. $$$.
- 3>$@$$. 3>$@$. $@@$ $@$. .@..
- 4>.$... 4>.$.. 4>.$$. lower end .$.. .$..
- .@... .@.. .@@. .@.. .@..
- .@... .@.. .@@. .@.. .@..
- 5>.$... 5>.$.. 5>.$$. lower start .$.. .$..
- 6>..... 6>$... 6>.... optional left bow
- */
- // --- test f like t ---------------------------------------------------
- for(ad=d=100;dx>2 && dy>5;){ // sometimes no hchar!
- // rewritten for vectors 0.43
- int d, i1, i2, i3, i4, i5, i6, i7, i8, i9; // line derivation + corners
- DBG( wchar_t c_ask='f'; )
- if (sdata->holes.num > 1) Break; /* tolerant against a tiny hole */
- /* half distance to the center */
- d=2*sq(128/4);
- /* now we check for the upper right end of the h */
- if (aa[3][2]>d/2) Break; /* [2] = distance, ~BCDEF... */
- if (aa[0][2]>d ) Break; /* upper left end */
-/*
- 9
- OOO
- O 7 O8
- O6
- 1OOOO5
- O4
- O
- 2O3
- OOOOO
-*/
- i1=nearest_frame_vector(box1,aa[0][3],aa[1][3],x0-dx/2,(5*y0+3*y1)/8);
- /* we need i for 4x6 font, where left side of h-bar is near (x0,y1) */
- i =aa[1][3]; if (box1->frame_vector[i][1]<y1-dy/8)
- i =nearest_frame_vector(box1,aa[1][3],aa[2][3], x0, y1+dy/4);
- i2=nearest_frame_vector(box1, i1, i, x1, y1);
- i =nearest_frame_vector(box1,aa[1][3],aa[2][3], x1, y1+dy/4);
- i3=nearest_frame_vector(box1, i,aa[3][3], x0, y1);
- i7=nearest_frame_vector(box1, i3,aa[3][3],(x0+x1)/2, y0);
- i8=nearest_frame_vector(box1, i7,aa[0][3], x1, (3*y0+y1)/4);
- i9=nearest_frame_vector(box1,aa[3][3],aa[0][3],(x0+2*x1)/3,y0-dy/4);
- i5=nearest_frame_vector(box1, i3, i7, x1+dx/4, (5*y0+3*y1)/8);
- i4=nearest_frame_vector(box1, i3, i5, x0, (3*y0+y1)/4);
- i6=nearest_frame_vector(box1, i5, i7, x0, (y0+3*y1)/4);
-
- MSG(fprintf(stderr,"i1-9 %d %d %d %d %d %d %d %d %d",i1,i2,i3,i4,i5,i6,i7,i8,i9);)
-
- // check if vertical line is near to the left side
- if (box1->frame_vector[i2][0]-x0>dx/2) Break; // ~3
- i =nearest_frame_vector(box1, aa[0][3], i2, x1+2*dx, (y0+y1)/2);
- // MSG(fprintf(stderr,"i %d",i);)
- if (box1->frame_vector[i ][0]
- -box1->frame_vector[i9][0]>dx/8) Break; // ~3
-
- if( (box1->dots) ) Break; // Bold-face is gchar
- if (dy<=box1->m3-box1->m2+1) Break;
- for(x=0,j=y=2+(3*dy+4)/32;y<=5*dy/8;y++){ // upper cross line min=2
- i=loop(bp,0,y,dx,cs,0,RI); if( y>dy/4 && i>5*dx/8 ) break;
- i=loop(bp,i,y,dx,cs,1,RI); if( i>x ) { x=i;j=y; }
- if( y<3*dy/4 && y>dy/4
- && num_cross(0,dx-1,y ,y ,bp,cs) != 1
- && num_cross(0,dx-1,y+1,y+1,bp,cs) != 1 // against noise
- ) break;
- } if( y<=5*dy/8 ) Break; y=j;// if( y>dy/2 || y<dy/8 ) Break;
- // x is thickest width of vertical line here
- i=loop(bp,(dx+1)/2,0,dy,cs,0,DO)/2;
- if( i>dy/8
- && num_cross( 0, (dx+1)/2,i,i,bp,cs) > 0
- && num_cross((dx+1)/2,dx-1,i,i,bp,cs) > 0 ) Break; // ~Y
-
- if (loop(bp,3*dx/4, 0,dy,cs,0,DO)>dy/8
- && loop(bp,3*dx/4-1,0,dy,cs,0,DO)>dy/8) Break; // upper bow
- i=3*dy/4; if (box1->m3 && i>=box1->m3) i=box1->m3-1;
- if (num_cross(0,dx-1,i,i,bp,cs)!=1) Break;
-
- // the middle bar appear in a wide vertical range, get part below
- for (i1=dx,i2=y,j=y+1;j<dy-dy/4;j++){
- i=loop(bp,0,j,dx,cs,0,RI);
- i=loop(bp,i,j,dx,cs,1,RI); // thickness vert. line
- if (i<i1) { i1=i; i2=j; if (2*i<=x) break; }
- } i=i1; j=i2; /* i=dx, j=y below horiz-bar */
- MSG(fprintf(stderr,"j=%d i=%d y=%d x=%d",j,i,y,x);)
- // bar should have twice of the thickness of v-line
- if (x<2*i && x<dx) Break;
- if (x<i+2+dx/8) ad=97*ad/100; // fat f
-
- // check for the upper bow to the right top side
- i3=nearest_frame_vector(box1,aa[2][3],aa[3][3], x0, y0);
- MSG(fprintf(stderr,"xy= %d %d %d %d",x0,y0,\
- box1->frame_vector[i3][0]-x0,box1->frame_vector[i3][1]-y0);)
- ab[7][0]=box1->frame_vector[i3][0];
- ab[7][1]=box1->frame_vector[i3][1];
- ab[7][3]=i3;
- if (ab[7][1]-y0<=dy/16) ad=95*ad/100; // ~t
- // because of the dx,dy scaling the horiz. bar could be nearer to (x1,y0)
- // as the upper right end of the "t"
- if (aa[3][0]-x0>3*dx/4 && aa[3][1]-y0>3*dy/16) ad=99*ad/100; // ~t
-
-
- j=loop(bp,0,dy/8,dx,cs,0,RI); // if j>dx/2 we have italic f
- if ((2*x<dx && j<=dx/2) || 3*x<dx) Break; // bar should be not to small
- for(i=dy/8;i<dy;i++)
- if (loop(bp,0,i,dx,cs,0,RI)>(j+dx/4)) break;
- if (i<dy) Break; // check for v-line
-
- if( loop(bp,dx-1,dy/2,dx,cs,0,LE)<dx/2 )
- if( loop(bp,dx-1,dy/2,dx,cs,0,LE)-1
- <=loop(bp,dx-1, y ,dx,cs,0,LE) )
- if( loop(bp,dx-1, y-1,dx,cs,0,LE)
- <=loop(bp,dx-1, y ,dx,cs,0,LE) ) Break; // ~1
-
- if( loop(bp,0,dy/2,dx,cs,0,RI)-1
- >loop(bp,0, 1,dx,cs,0,RI) ) Break; // ~X
-
- i=y;j=1; // j used as flag
- if( num_cross(0,dx-1,0,0,bp,cs)==1 && hchar) //~r
- if( num_cross(0,dx-1,dy-1,dy-1,bp,cs)!=1
- && num_cross(0,dx-1,dy-2,dy-2,bp,cs)!=1 ) Break; // ~* etc.
- // check for upper bow to right
- for(y=1;j && y<i; y++) // no @@ pattern
- if( num_cross(0,dx-1,y ,y ,bp,cs) ==2 ) j=0;
- if (j==0) { ad=(ad+101)/2; }
- for(y=1;j && y<i; y++) // no @@ pattern, try to detect it
- for(x=0;j && x<dx ;x++){ // ..
- if( (getpixel(bp,x ,y )>=cs || dx<7) && getpixel(bp,x+1,y )>=cs
- && getpixel(bp,x ,y-1)< cs && getpixel(bp,x+1,y-1)< cs )
- { j=0;break; }
- } if(j) ad=98*ad/100; // not detected
-
- // if( num_hole (x0 , x1 , y0, y1,box1->p,cs,NULL) != 0 ) Break; // ~e
- if (sdata->holes.num != 0) Break; // ~e
- for(i1=i2=dx,y=7*dy/8;y<dy;y++){
- x=loop(bp,0 ,y,dx,cs,0,RI);if(x<i1)i1=x;
- x=loop(bp,dx-1,y,dx,cs,0,LE);if(x<i2)i2=x;
- }
- if(i1>i2+dx/4) Break; // ~t ~e
- if(i1>i2+1) ad=96*ad/100; // ~t ~e
- if( loop(bp,0,3*dy/4,dx,cs,0,RI)<i1-dx/4 ) Break;
- if( dx>5 && !hchar)
- if( loop(bp,dx-1,dy/2,dx,cs,0,LE)>3*dx/4 )
- if( loop(bp,dx-1,dy-1,dy,cs,0,UP)<dx/2 ) Break; // ~c
- if( dx>8 )
- if( loop(bp, 0,2*dy/3 ,dx,cs,0,RI)>2*dx/3
- || loop(bp, 0,2*dy/3-1,dx,cs,0,RI)>2*dx/3 )
- if( loop(bp,dx-1, dy/4 ,dx,cs,0,LE)>2*dx/3 ) Break; // ~5 ~S
-
- if (!hchar)
- if ( get_bw(x0+dx/8,x0+dx/8,y0+dy/4,y1-dy/16,box1->p,cs,2) == 0
- && num_cross(x1-dx/4,x1-dx/4,y0,y1,box1->p,cs)!=2
- && num_cross(x1-dx/8,x1-dx/8,y0,y1,box1->p,cs)!=2 ) Break; // ~r
-
- if (dy>15)
- if( num_cross(x0,x1,y1-dy/4,y1-dy/4,box1->p,cs)>1
- && num_cross(x0,x1,y0+dy/4,y0+dy/4,box1->p,cs)>1 ) Break; // ~H
-
- if( dx>4 )
- if( loop(bp,dx-1 ,3*dy/4,dx,cs,0,LE)-
- loop(bp,0 ,3*dy/4,dx,cs,0,RI)>dx/5+1
- && loop(bp,dx-1-dx/8,dy-1 ,dy,cs,0,UP)<dy/4 ) {
- if( loop(bp,dx-1 ,5*dy/16,dx,cs,0,LE)-
- loop(bp,0 ,5*dy/16,dx,cs,0,RI)>=dx/5+1) ad=98*ad/100; // ~E
- i=loop(bp,dx/8,0,dy,cs,0,DO);
- if (i<dy/8 || i>dy/2) {
- ad=98*ad/100; // ~E, could also be a "f" with big serifs
- MSG(fprintf(stderr,"ad=%d",ad);) }
- if (!gchar) { ad=98*ad/100;
- MSG(fprintf(stderr,"ad=%d",ad);) }
- }
- i = loop(bp,dx-1 ,3*dy/4,dx ,cs,0,LE)/2;
- if (loop(bp,dx-1-i , dy-1,dy/2,cs,0,UP)<dy/4)
- if (loop(bp,0 ,3*dy/4,dx ,cs,0,RI)<dx/4) {
- ad=98*ad/100; // ~E but serif-f
- MSG(fprintf(stderr,"ad=%d",ad);) }
-
- if( loop(bp,0,dy/4,dx ,cs,0,RI)>1
- && loop(bp,0, 0,dy/4,cs,0,DO)<dy/4 ) {
- ad=95*ad/100; // ~I
- MSG(fprintf(stderr,"ad=%d",ad);) }
-
- if (get_bw(x0+dx/16,x1-dx/16,y0,y0,box1->p,cs,2) == 0) { // white pixels?
- ad=98*ad/100; // F
- MSG(fprintf(stderr,"ad=%d",ad);) }
-
- if (!hchar) ad=ad*98/100; // d*=100;d/=128 // not 100% !
- if (box1->m4>0 && gchar && ad<99 &&
- 8*box1->y1 >= box1->m4*7+box1->m3) ad++;
- Setac(box1,'f',ad);
- break;
- }
- return box1->c;
-}
-
-static wchar_t ocr0_bB(ocr0_shared_t *sdata){
- struct box *box1=sdata->box1;
- pix *bp=sdata->bp;
- int i,j,d,x,y,i1,i2,i3,hchar=sdata->hchar,gchar=sdata->gchar,
- x0=box1->x0,x1=box1->x1,y0=box1->y0,y1=box1->y1,cs=sdata->cs;
- int dx=x1-x0+1,dy=y1-y0+1, /* size */
- ad; /* tmp-vars */
-
- // --- test B ---------------------------------------------------
- for(ad=d=100;dx>2 && dy>4;){ // min 3x4
- DBG( wchar_t c_ask='B'; )
- if (sdata->holes.num < 2) Break; /* tolerant against a tiny hole */
- for(i=1,y=y0;y<y1-dy/2 && i;y++)
- if( get_bw(x0,x0+dx/2, y , y ,box1->p,cs,1) != 1 ) i=0;
- if( !i ) Break;
- for(i=1,y=y1-dy/2;y<y1 && i;y++)
- if( get_bw(x0,x0+dx/3, y , y ,box1->p,cs,1) != 1 ) i=0;
- if( !i ) Break;
- if( get_bw(x1,x1 , y0 , y0 ,box1->p,cs,1) == 1 ) Break;
- if( num_cross(x0+dx/2, x0+dx/2,y0,y1 ,box1->p,cs) != 3 )
- if( num_cross(x1-dx/3, x1-dx/3,y0,y1 ,box1->p,cs) != 3 ) Break;
- /* --- detect center of lower hole --- */
- y = loop(box1->p,x0+dx/2,y1 ,dy,cs,0,UP); if (y>1+dy/8) Break;
- y+= loop(box1->p,x0+dx/2,y1-y,dy,cs,1,UP); if (y>dy/3) Break;
- y=y1-y-loop(box1->p,x0+dx/2,y1-y,dy,cs,0,UP)/2; if (y<y0+3*dy/8) Break;
- if (y<y0+dy/2) ad=96*ad/100;
- if( num_cross(0,dx-1,y-y0 ,y-y0 ,bp,cs) != 2 )
- if( num_cross(0,dx-1,y-y0+1,y-y0+1,bp,cs) != 2 ) Break;
- if( num_cross(0,dx-1, dy/4 , dy/4 ,bp,cs) != 2 )
- if( num_cross(0,dx-1, dy/4+1, dy/4+1,bp,cs) != 2 )
- if( num_cross(0,dx-1, dy/4-1, dy/4-1,bp,cs) != 2 ) Break;
- for( y=dy/4;y<3*dy/4;y++ ) if( num_cross(0,dx-1,y,y,bp,cs)==1 ) break;
- if( y==3*dy/4 ) Break;
-
- if( loop(box1->p,x0,y0+ y ,dx,cs,0,RI)
- > loop(box1->p,x0,y0+dy/4,dx,cs,0,RI)+dx/32 )
- if( get_bw(x0,x0,y0,y0,box1->p,cs,1) == 0 )
- if( get_bw(x0,x0,y1,y1,box1->p,cs,1) == 0 ) Break; // ~8
- i1=loop(box1->p,x0,y0+dy/4,dx,cs,0,RI);
- i2=loop(box1->p,x0,y0+dy/2,dx,cs,0,RI);
- i =loop(box1->p,x0,y0+dy/2-dy/ 8,dx,cs,0,RI); if(i>i2) i2=i;
- i =loop(box1->p,x0,y0+dy/2-dy/16,dx,cs,0,RI); if(i>i2) i2=i;
- i3=loop(box1->p,x0,y1-dy/4,dx,cs,0,RI);
- if(dy>16 && i3<i2 && i1+i3<2*i2){
- if (i3+i1<2*i2-dx/16) ad=98*ad/100; // ~8
- if (i3+i1<2*i2-dx/8 ) ad=96*ad/100;
- if( loop(box1->p,x0,y0+ 1 ,dx,cs,0,RI)
- >= loop(box1->p,x0,y0+ 3 ,dx,cs,0,RI)+dx/32 )
- if( loop(box1->p,x0,y0+ 0 ,dx,cs,0,RI)
- > loop(box1->p,x0,y0+ 3 ,dx,cs,0,RI)+dx/32 )
- if( loop(box1->p,x0,y1- 0 ,dx,cs,0,RI)
- > loop(box1->p,x0,y1- 3 ,dx,cs,0,RI)+dx/32 )
- if( loop(box1->p,x0,y1- 1 ,dx,cs,0,RI)
- > loop(box1->p,x0,y1- 3 ,dx,cs,0,RI)+dx/32 ) Break; // ~8 Aug00
- }
-
- if (sdata->holes.num != 2) Break;
- if (sdata->holes.hole[0].y0 < y-1
- && sdata->holes.hole[1].y0 < y-1 ) Break;
- if (sdata->holes.hole[0].y1 > y+1
- && sdata->holes.hole[1].y1 > y+1 ) Break;
- // if( num_hole(0,dx-1,0 ,y+1 ,bp,cs,NULL) != 1 ) Break;
- // if( num_hole(0,dx-1,y-1,dy-1,bp,cs,NULL) != 1 ) Break;
- // out_x(box1);
-
- for( x=dx,y=dy/6; y<dy-dy/8; y++ ) // left border straight
- { i=loop(box1->p,x0,y0+y,dx,cs,0,RI); if( i>x+dx/9 ) break;
- if(i<x) x=i;
- } if( y<dy-dy/8 ) Break; // ~8 bad_a
-
- for( x=dx,y=1;y<dy/4;y++ ) // right border straight
- { i=loop(bp,dx-1,dy-y,dx,cs,0,LE);
- if( i<x ) x=i; else if( i>x )break;
- } if( y<dy/4 ) Break; // ~ff (serifen?)
-
- x=loop(bp,0,dy/2 ,dx,cs,0,RI);
- i=loop(bp,0,dy/2-1,dx,cs,0,RI); if (i>x) x=i; // allow dust
- i=loop(bp,0,dy/2+1,dx,cs,0,RI); if (i>x) x=i;
- if ( loop(bp,0, dy/8,dx,cs,0,RI)
- +loop(bp,0,7*dy/8,dx,cs,0,RI) > 2*x+1 ) Break; // not konvex!
-
- if(!hchar){ // ~ fat_a
- ad=99*ad/100;
- x =loop(bp,0,dy/4,dx,cs,0,RI);
- if(loop(bp,0,dy/2,dx,cs,0,RI)>x+dx/8) ad=97*ad/100;
- }
-
- if ( (!hchar) && (dx<=10 || dy<=10) ) ad=97*ad/100; // hchar or good_quality
- if (gchar) ad=99*ad/100;
- Setac(box1,'B',ad);
- break;
- }
- // --- test b ---------------------------------------------------
- for(ad=d=100;dx>3 && dy>4;){ // min 3x4
- DBG( wchar_t c_ask='b'; )
- if (sdata->holes.num < 1) Break; /* tolerant against a tiny hole */
- for(y=y0;y<y1;y++)
- if( get_bw(x0 , x0+dx/2, y , y ,box1->p,cs,1) != 1 ) Break;
- if(y<y1-dy/32-1) Break;
- if( get_bw(x0+ dx/2, x0+dx/2, y1-dy/3, y1 ,box1->p,cs,1) != 1 ) Break;
- if( get_bw(x1- dx/2, x1 , y1-dy/3, y1-dy/3,box1->p,cs,1) != 1 ) Break;
- if( get_bw(x1- dx/3, x1 , y0 , y0+dy/5,box1->p,cs,1) == 1 ) Break;
- if( get_bw(x1-4*dx/9, x1 , y0+dy/5, y0+dy/5,box1->p,cs,1) == 1 ) Break;
- if( num_cross(x0,x1,y0+dy/4 ,y0+dy/4 ,box1->p,cs) > 1 ) // &
- if( num_cross(x0,x1,y0+dy/4-1,y0+dy/4-1,box1->p,cs) > 1 )
- if( dy<16 ||
- num_cross(x0,x1,y0+dy/5 ,y0+dy/5 ,box1->p,cs) > 1 ) Break; // fat b
- for(i=j=0,y=dy/2;y<dy-dy/8;y++)
- if( num_cross(0,dx-1,y,y,bp,cs) == 2 ) i++; else j++;
- if( i<2*j ) Break; // v024a4
- if (sdata->holes.num != 1) Break;
- if (sdata->holes.hole[0].y0 < dy/4) Break;
- if ((sdata->holes.hole[0].y1-sdata->holes.hole[0].y0+1)
- *(sdata->holes.hole[0].x1-sdata->holes.hole[0].x0+1)*16
- < dx*dy) ad=90*ad/100; // hole to small
- if( num_hole( x0, x1 , y0+dy/4, y1,box1->p,cs,NULL) != 1 ) Break;
- i=loop(bp,dx-1,dy-1 ,dx,cs,0,LE);
- j=loop(bp,dx-1,dy-1-dy/8,dx,cs,0,LE); if(j>i) Break;
- if (!hchar) ad=99*ad/100;
- if ( gchar) ad=99*ad/100;
- Setac(box1,'b',ad);
- if (ad>=100) return 'b';
- break;
- }
- return box1->c;
-}
-
-static wchar_t ocr0_dD(ocr0_shared_t *sdata){
- struct box *box1=sdata->box1;
- pix *bp=sdata->bp;
- int i,d,x,y,ya,yb,hchar=sdata->hchar,gchar=sdata->gchar,
- x0=box1->x0,x1=box1->x1,y0=box1->y0,y1=box1->y1,cs=sdata->cs;
- int dx=x1-x0+1,dy=y1-y0+1, /* size */
- ad; /* tmp-vars */
-
- // --- test D ---------------------------------------------------
- for(ad=d=100;dx>2 && dy>3;){ // min 3x4
- DBG( wchar_t c_ask='D'; )
- if (sdata->holes.num < 1) Break; /* tolerant against a tiny hole */
- if( get_bw(x0 ,x0+dx/3,y0+dy/2,y0+dy/2,box1->p,cs,1) != 1 ) Break;
- if( get_bw(x1-dx/3,x1 ,y0+dy/2,y0+dy/2,box1->p,cs,1) != 1 ) Break;
- if( get_bw(x1 ,x1 ,y0 ,y0+dy/16,box1->p,cs,1) == 1 ) Break;
- if( get_bw(x1-dx/2,x1 ,y0+dy/4,y0+dy/4 ,box1->p,cs,1) != 1 ) Break;
- if( num_cross(x0+dx/2,x0+dx/2,y0 ,y1 ,box1->p,cs) != 2 )
- if( num_cross(x1-dx/3,x1-dx/3,y0 ,y1 ,box1->p,cs) != 2 ) Break;
- if( num_cross(x0 ,x1 ,y0+dy/3,y0+dy/3,box1->p,cs) != 2 ) Break;
- if( num_cross(x0 ,x1 ,y1-dy/3,y1-dy/3,box1->p,cs) != 2 ) Break;
- if (sdata->holes.num != 1) Break;
- if (sdata->holes.hole[0].y0 > dy/3) Break;
- if (sdata->holes.hole[0].y1 < dy-1-dy/3) Break;
- // if( num_hole (x0 ,x1 ,y0 ,y1 ,box1->p,cs,NULL) != 1 ) Break;
- // test if left edge is straight
- for(x=0,y=bp->y-1-dy/8;y>=dy/5;y--){
- i=loop(bp,0,y,x1-x0,cs,0,RI);
- if( i+2+dx/16<=x ) break;
- if( i>x ) x=i;
- }
- if (y>=dy/5 ) Break;
- /* test if right edge is falling */
- for(x=dx,y=0;y<dy/3;y++){
- i=loop(bp,bp->x-1,y,x1-x0,cs,0,LE);
- if( i>x+dx/16 ) break;
- if( i<x ) x=i;
- }
- if (y<dy/3 ) Break;
- /* test if right edge is raising */
- for(x=dx,y=bp->y-1;y>2*dy/3;y--){
- i=loop(bp,bp->x-1,y,x1-x0,cs,0,LE);
- if( i>x+dx/16 ) break;
- if( i<x ) x=i;
- }
- if (y>2*dy/3 ) Break;
- if( loop(bp,dx-1,dy-1 ,dx,cs,0,LE) <=
- loop(bp,dx-1,dy-2-dy/16,dx,cs,0,LE) ) Break; // P
-
- y=loop(bp,dx/2,dy-1,dy,cs,0,UP)-1; if (dy>16) y/=2;
- if ( y>=dy/16 ) { y-=dy/16;
- if (get_bw(dx/2,dx-1,dy-1-y,dy-1-y,bp,cs,1)==1) Break; // ~A
- }
-
- ya=loop(bp, 0,dy-1,dy,cs,0,UP);
- yb=loop(bp,dx/16+1,dy-1,dy,cs,0,UP);
- if( ya<dy/2 && ya>dy/16 && ya>yb ) Break; // ~O
-
- if ( loop(bp, dx/2, 0,dy,cs,0,DO)
- -loop(bp, dx/2,dy-1,dy,cs,0,UP) > dy/8 ) ad=97*ad/100; // ~b
-
-
-
- if (loop(bp, 0, 0,dx,cs,0,RI)>=dx/2
- && loop(bp,dx-1,dy-1,dx,cs,0,LE)>=dx/2
- && loop(bp, 0,dy/2,dx,cs,0,RI)< 2 ) ad=96*ad/100; // thin O
-
- if(box1->dots) ad=ad*94/100;
- if ( gchar) ad=99*ad/100;
- if (!hchar) ad=99*ad/100;
- Setac(box1,'D',ad);
- break;
- }
- // --- test d ---------------------------------------------------
- for(d=100;dx>2 && dy>3;){ // min 3x4
- DBG( wchar_t c_ask='d'; )
- ad=100;
- if (sdata->holes.num < 1) Break; /* tolerant against a tiny hole */
- if( get_bw(x0 , x0+dx/2, y1-dy/6, y1-dy/9,box1->p,cs,1) != 1 ) Break;
- if( get_bw(x0 , x0+dx/2, y1-dy/3, y1-dy/3,box1->p,cs,1) != 1 ) Break;
- if( get_bw(x0+dx/2, x1 , y1-dy/3, y1-dy/3,box1->p,cs,1) != 1 ) Break;
- if( get_bw(x1-dx/4, x1 , y0+dy/8, y0+dy/8,box1->p,cs,1) != 1 ) Break;
- if( get_bw(x0+dx/2, x0+dx/2, y1-dy/4, y1 ,box1->p,cs,1) != 1 ) Break;
- if(dy>19)
- if( get_bw(x0 , x0+dx/3, y0 , y0+dy/5,box1->p,cs,1) == 1 ) Break;
- if( get_bw(x0 , x0+dx/3, y0 , y0+dy/6,box1->p,cs,1) == 1 ) Break;
- if( get_bw(x0 , x0+dx/4, y1-dy/8, y1 ,box1->p,cs,1) != 1 ) Break;
- if( get_bw(x0+dx/2-1,x0+dx/2,y1-dy/8, y1 ,box1->p,cs,1) != 1 ) Break; // ~"A
- if( loop(bp,bp->x-1, bp->y/4,x1-x0,cs,0,LE) >
- loop(bp,bp->x-1,3*bp->y/4,x1-x0,cs,0,LE)+1 ) Break;
- for(i=dx/8+1,x=0;x<dx && i;x++){
- if( num_cross(x ,x ,0 ,dy-1, bp,cs) == 2 ) i--;
- } if( i ) Break;
- for(i=dy/6+1,y=dy/4;y<dy && i;y++){
- if( num_cross(0 ,dx-1,y ,y , bp,cs) == 2 ) i--;
- if( num_cross(0 ,dx-1,y ,y , bp,cs) > 3 ) i++; // ~al
- } if( i ) ad=98*ad/100;
- for(i=dy/8+1,y=0;y<dy/2 && i;y++){
- if( num_cross(0 ,dx-1,y ,y , bp,cs) == 1 )
- if( num_cross(dx/2,dx-1,y ,y , bp,cs) == 1 ) i--;
- } if( i ) Break;
- if (sdata->holes.num<1) Break;
- if (sdata->holes.num>1) {
- if (dx<6) Break; ad=95*ad/100; } // glued j above 8 (4x6 sample)
- MSG(fprintf(stderr,"hole[0].y0,y1= %d %d",sdata->holes.hole[0].y0,sdata->holes.hole[0].y1););
- if ( sdata->holes.hole[0].y0 < dy/4 ) Break;
- if (dy-sdata->holes.hole[0].y1 > dy/4+1) Break; // glued et
- // if( num_hole(x0 , x1 , y0+dy/4 , y1 ,box1->p,cs,NULL) !=1 ) Break;
- if( num_cross(0 ,dx-1,dy-1-dy/4,dy-1-dy/4,bp,cs) != 2 ) { // glued al
- if (dy>15) { Break; } else ad=96*ad/100;
- }
- if (!hchar) ad=98*ad/100;
- if ( gchar) ad=99*ad/100;
- Setac(box1,'d',ad);
- break;
- }
- return box1->c;
-}
-
-static wchar_t ocr0_F(ocr0_shared_t *sdata){
- struct box *box1=sdata->box1;
- pix *bp=sdata->bp;
- int i,j,d,x,y,hchar=sdata->hchar,gchar=sdata->gchar,
- x0=box1->x0,x1=box1->x1,y0=box1->y0,y1=box1->y1,cs=sdata->cs;
- int dx=x1-x0+1,dy=y1-y0+1, /* size */
- ad; /* tmp-vars */
-
- // --- test F ---------------------------------------------------
- for(ad=d=100;dx>2 && dy>4;){ // dx>1 dy>2*dx
- DBG( wchar_t c_ask='F'; )
- if (sdata->holes.num > 1) Break; /* tolerant against a tiny hole */
- if( get_bw(x0+dx/2,x0+dx/2,y0,y0+dy/8,box1->p,cs,1) != 1 ) Break;
- if( get_bw(x0,x0+dx/4,y1-dy/4,y1-dy/4,box1->p,cs,1) != 1 ) Break;
- if( get_bw(x0,x0+dx/2,y0+dy/4,y0+dy/4,box1->p,cs,1) != 1 ) Break;
-
- for (x=0,y=0;y<dy/4;y++) {
- j=loop(bp,dx-1,dy-1-y,dx,cs,0,LE); if(j<3 || 3*j<dx) break; // ~f Jun00
- if (j>x) x=j;
- } if (y<dy/4 || x<dx/2) Break;
-
- for( i=1,y=0; y<dy/4 && i; y++ ){ // long black line
- j=loop(bp,0,y,dx,cs,0,RI);
- j=loop(bp,j,y,dx,cs,1,RI); if( j>dx/2 ) i=0; }
- if( i ) Break;
-
- x=loop(bp,0,dy-1-dy/4,dx,cs,0,RI);
- x=loop(bp,x,dy-1-dy/4,dx,cs,1,RI); // strichdicke
- for( i=1,y=dy/3; y<dy-1-dy/3 && i; y++ ) // black line
- { j=loop(bp,0,y,dx,cs,0,RI);
- j=loop(bp,j,y,dx,cs,1,RI); if( j>dx/3 && ((j>2*x && dx>8) || j>x+1)) i=0; }
- if( i ) Break;
-
- y=dy/8; if (y<1) y=1;
- for( i=1; y<dy-1-dy/2; y++ ){ // search horizontal white gap
- x =loop(bp,dx-1,y,dx,cs,0,LE); if(x<2) continue; // skip serifs
- j =loop(bp,dx-x,y,dy/4,cs,0,UP);
- x+=loop(bp,dx-x,y-j+1,dx,cs,0,LE); if (x>=dx/3) { i=0; break; }
- }
- if( i ) Break;
-
- // check for vertical line on left side
- for(i=1,y=1;y<=dy/2 && i;y++)
- if( get_bw(0,dx/2,y,y,bp,cs,1) != 1 ) i=0;
- if( !i ) Break;
-
- for(i=1,y=dy/2;y<dy && i;y++)
- if( get_bw(0,dx/3,y,y,bp,cs,1) != 1 ) i=0;
- if( !i ) Break;
-
- i=loop(bp,dx-1,dy-1,dx,cs,0,LE); // serif or E ?
- if (i<=dx/3) {
- if (loop(bp,dx-1,(dy+4)/8,dx,cs,0,LE)>dx/8 // no serif
- || loop(bp, 0, dy-3,dx,cs,0,RI)<1) break;
- ad=99*ad/100;
- }
- if( get_bw(dx-1-dx/4,dx-1,dy-1-dy/4,dy-1,bp,cs,1) == 1 ) Break; // ~E
- if( get_bw(dx-1 ,dx-1,0 ,dy/3,bp,cs,1) != 1 ) Break;
-
- if( loop(bp,0, bp->y/4,dx,cs,0,RI) <
- loop(bp,0,3*bp->y/4,dx,cs,0,RI)-1 ) Break;
- // if( num_hole(x0 , x1 , y0 , y1 ,box1->p,cs,NULL) >0 ) Break;
- if (sdata->holes.num > 0) Break;
- for(i=0,x=dx/4;x<dx-1;x++)
- if( num_cross(x,x,0,dy-2,bp,cs) == 2 ) i++;
- if ( i<1 ) Break; // 0.2.4a4
-
- if(dy<20) /* special case of small fi, not very elegant */
- if( get_bw( 1, 1,1,1,bp,cs,1) == 1
- && get_bw( 0, 0,2,2,bp,cs,1) == 1
- && get_bw(dx-2,dx-1,0,0,bp,cs,1) == 0
- && get_bw( 0, 1,0,0,bp,cs,1) == 0
- && get_bw( 0, 0,0,1,bp,cs,1) == 0 ) Break;
-
- // check for screen font f
- i= loop(bp,0,3*bp->y/4,dx,cs,0,RI)-1;
- if (i>=0 && loop(bp,dy-1,i,dy,cs,0,UP)<=3*dy/4 ) ad=ad*98/100;
-
- // check for screen font P
- i= loop(bp,bp->x-1,bp->y/4,dx,cs,0,LE);
- if (i<1) {
- j=i+loop(bp,bp->x-1-i,bp->y/4, dx ,cs,1,LE);
- j= loop(bp,bp->x-1-j,bp->y/4,3*dy/4,cs,0,DO);
- if (j<=dy/2) {
- i=loop(bp,bp->x-1,0,dx,cs,0,LE);
- ad=ad*98/100;
- if (i>dx/8) Break;
- if (i) ad=98*ad/100;
- }
- }
-
- if (!hchar) if ((box1->m2-box1->y0)*8>=dy) { // ignore bad m1..4
- if ( num_cross(2*dx/3,2*dx/3,0,dy-1,bp,cs) < 2 ) ad=90*ad/100; // ~r
- }
- if (gchar) ad=99*ad/100;
- Setac(box1,'F',ad);
- break;
- }
- return box1->c;
-}
-
-static wchar_t ocr0_uU(ocr0_shared_t *sdata){
- struct box *box1=sdata->box1;
- pix *bp=sdata->bp;
- int i,j,d,x,y,hchar=sdata->hchar,gchar=sdata->gchar,
- x0=box1->x0,x1=box1->x1,y0=box1->y0,y1=box1->y1,cs=sdata->cs;
- int dx=x1-x0+1,dy=y1-y0+1, /* size */
- ad; /* tmp-vars */
- wchar_t bc=UNKNOWN;
-
- // --- test uU ---------------------------------------------------
- // in Mitte so breit wie oben (bei V kontinuierlich schmaler)
- for(ad=d=100;dx>2 && dy>3;){ // min 3x4
- DBG( wchar_t c_ask='u'; )
- if (sdata->holes.num > 1) Break; /* tolerant against a tiny hole */
- for(y=y0+dy/4;y<y1-dy/4;y++) /* also handwritten u */
- if( num_cross(x0,x1,y,y,box1->p,cs) < 2 ) break;
- if( y<y1-dy/4 ) Break;
- if( get_bw(dx/2,dx/2,dy/2,dy-1,bp,cs,1)==0 ) Break;
- if( get_bw(dx/2,dx-1,dy/2,dy/2,bp,cs,1)==0 ) Break;
- for(i=0,x=3*dx/8;x<dx-dx/4;x++){
- y=loop(bp,x,0,dy,cs,0,DO); if(y>i)i=y; if(y<i && i>1) break;
- } if( i<dy/4 ) Break; x--;
- if( get_bw(0,x ,i-1,i-1,bp,cs,1)==0 ) Break;
- if( get_bw(x,dx-1,i-1,i-1,bp,cs,1)==0 ) Break;
-
- for(i=dy/8+2,y=dy/8;y<dy-(dy+2)/4 && i;y++){ // 12%+1 Fehler
- j=num_cross(0,dx/2-((y>dy/2)?dx/8:0),y,y,bp,cs);
- if( y<dy/2 && num_cross(dx/2,dx-1,y,y,bp,cs)>1 ) i--; // ~{\it v}
- if( y<dy/2 && (j<1 && j>2) ) { i--; ad=90*ad/100; }
- if( y>dy/2 && j!=1 ) { i--; ad=95*ad/100; }
- } if( !i ) Break;
- for(i=dy/16+1,y=dy/8;y<dy-dy/4 && i;y++){ // 12%+1 Fehler
- j=num_cross(dx-dx/2,dx-1,y,y,bp,cs);
- if( y>dy/2 && (j<1 && j>2) ) i--;
- if( y<dy/2 && j!=1 ) i--;
- } if( !i ) Break;
- for(i=1,x=x0+dx/3;x<=x1-dx/3 && i;x++){
- if( get_bw( x, x, y0, y0+dy/3,box1->p,cs,1) != 1 ) i=0;
- } if( i ) Break;
- for(i=dx/4+1,x=x0+dx/3;x<=x1-dx/3 && i;x++){
- if( get_bw( x, x,y0+dy/3,y1-dy/3,box1->p,cs,3) != 2 ) i--;
- } if( !i ) Break;
- for(i=1,x=x0+dx/3;x<=x1-dx/3 && i;x++){
- if( get_bw( x, x,y1-dy/2,y1,box1->p,cs,3) == 2 ) i=0;
- if( get_bw( x, x,y1-dy/3,y1,box1->p,cs,3) == 2 ) ad=98*ad/100;
- } if( !i ) Break;
- if( num_cross(0 ,dx/2, dy/4, dy/4,bp,cs)==2
- && num_cross(dx-dx/2,dx-1,dy-dy/4,dy-dy/4,bp,cs)==1 ) Break; // ~{\it v}
-
- i=loop(bp,0,dy-1-dy/16,dx,cs,0,RI);
- j=loop(bp,0,dy-1-dy/8 ,dx,cs,0,RI);
- if( i<j ) Break; // ~ll v0.2.4a3
- if(dy>15)
- if( loop(bp,dx-1,dy/16,dx,cs,0,LE)
- > loop(bp,dx-1,dy/8 ,dx,cs,0,LE)+1+dx/32 ) Break; // ~bad 0 (thinn)
- if( hchar && dy>7)
- if( loop(bp, 0, dy-1,dx,cs,1,RI)==dx
- && loop(bp,dx-1,3*dy/4,dx,cs,0,LE)>dx/16
- && loop(bp, 0,3*dy/4,dx,cs,0,RI)>dx/16
- && loop(bp,dx-1, dy/2,dx,cs,0,LE)>dx/16
- && loop(bp, 0, dy/2,dx,cs,0,RI)>dx/16
- ) Break; // melted ll
-
- i=loop(bp, 0,dy-2-dy/8,dx,cs,0,RI);
- j=loop(bp,dx-1,dy-2-dy/8,dx,cs,0,LE);
- if ( i>dx/4 && j>dx/4 && i+j>=dx/2) Break; // v
- if (i+j>=dx/2) ad=97*ad/100;
-
- if ( num_cross(0,dx-1,dy/2,dy/2,bp,cs)!=2 ) ad=96*ad/100; // w
- if ( loop(bp,dx/2,dy-1,dy,cs,0,UP)>0 ) ad=98*ad/100; // w
-
- if (ad==100) ad=99; // ToDo: only if lines.wt<100
- bc='u';
- if (gchar) ad=98*ad/100;
- if (hchar) bc='U';
- if (box1->dots>0) ad=99*ad/100;
- Setac(box1,bc,ad);
- break;
- }
- return box1->c;
-}
-
-static wchar_t ocr0_micro(ocr0_shared_t *sdata){
- struct box *box1=sdata->box1;
- pix *bp=sdata->bp;
- int i,j,d,x,y,i2,hchar=sdata->hchar,gchar=sdata->gchar,
- x0=box1->x0,x1=box1->x1,y0=box1->y0,y1=box1->y1,cs=sdata->cs;
- int dx=x1-x0+1,dy=y1-y0+1, /* size */
- ad; /* tmp-vars */
-
- // --- test \mu µ MICRO_SIGN --------------------------------------
- // in Mitte so breit wie oben (bei V kontinuierlich schmaler)
- if( gchar && !hchar )
- for(ad=d=100;dx>2 && dy>4;){ // min 3x4
- DBG( wchar_t c_ask='u'; )
- if (sdata->holes.num > 1) break; /* tolerant against a tiny hole */
- for(y=y0+dy/8;y<box1->m3-dy/4;y++)
- if( num_cross(x0,x1,y,y,box1->p,cs) < 2 ) break;
- if( y<box1->m3-dy/4 ) break;
- if( get_bw(dx/2,dx/2,3*dy/8,7*dy/8,bp,cs,1)==0 ) break;
- if( get_bw(dx/2,dx-1,3*dy/8,7*dy/8,bp,cs,1)==0 ) break;
- for(y=dy/2;y<dy;y++){
- x=loop(bp,dx-1,y,dx,cs,0,LE); if(8*x>5*dx) break;
- } if( y>=dy || 2*y>box1->m3+box1->m4) break; i2=y;
- for(i=0,x=2*dx/8;x<dx-1-dx/4;x++){
- y=loop(bp,x,0,dy,cs,0,DO); if(y>i)i=y; if(y<i && i>1) break;
- } if( i<dy/4 ) break; x--;
- if( get_bw(0,x ,i-1,i-1,bp,cs,1)==0 ) break;
- if( get_bw(x,dx-1,i-1,i-1,bp,cs,1)==0 ) break;
- for(i=dy/16+1,y=dy/8;y<dy-(box1->m4-box1->m3)-dy/4 && i;y++){ // 12%+1 Fehler
- j=num_cross(0,dx/2,y,y,bp,cs);
- if( y<dy/2 && num_cross(dx/2,dx-1,y,y,bp,cs)>1 ) i--; // ~{\it v}
- if( y<dy/2 && (j<1 && j>2) ) i--;
- if( y>dy/2 && j!=1 ) i--;
- } if( !i ) break;
- for(i=dy/16+1,y=dy/8;y<dy-(box1->m4-box1->m3)-dy/4 && i;y++){ // 12%+1 Fehler
- j=num_cross(dx-dx/2,dx-1,y,y,bp,cs);
- if( y>dy/2 && (j<1 && j>2) ) i--;
- if( y<dy/2 && j!=1 ) i--;
- } if( !i ) break;
- for(i=1,x=x0+dx/3;x<=x1-dx/3 && i;x++){
- if( get_bw( x, x, y0, y0+dy/4,box1->p,cs,1) != 1 ) i=0;
- } if( i ) break;
- for(i=dx/4+1,x=x0+dx/3;x<=x1-dx/3 && i;x++){
- if( get_bw( x, x,y0+dy/4,y1-dy/2,box1->p,cs,3) != 2 ) i--;
- } if( !i ) break;
- if( num_cross(0 ,dx/2, dy/4, dy/4,bp,cs)!=1 ) break;
- if( num_cross(dx-dx/2,dx-1,dy-dy/2,dy-dy/2,bp,cs)!=1 ) break;
- if( get_bw( (dx+2)/4,dx-1,dy-2-3*dy/16,dy-1,bp,cs,1) == 1 ) break;
- if( num_cross(0,dx/4,dy-1,dy-1,bp,cs)!=1 ) break;
-
- Setac(box1,MICRO_SIGN,ad);
- break;
- }
- return box1->c;
-}
-
-static wchar_t ocr0_vV(ocr0_shared_t *sdata){
- struct box *box1=sdata->box1;
- pix *bp=sdata->bp;
- int i,j,d,x,y,i1,i2,i3,hchar=sdata->hchar,gchar=sdata->gchar,
- x0=box1->x0,x1=box1->x1,y0=box1->y0,y1=box1->y1,cs=sdata->cs;
- int dx=x1-x0+1,dy=y1-y0+1, /* size */
- ad; /* tmp-vars */
- wchar_t bc=UNKNOWN;
-
- // --- test v -------------------------------------------------
- for(ad=d=100;dx>2 && dy>3;){ // min 3x4
- DBG( wchar_t c_ask='v'; )
- if (sdata->holes.num > 1) Break; /* tolerant against a tiny hole */
- x=loop(bp,dx/2,0,dx,cs,1,RI)+dx/2; // be sure in the upper gap
- y=loop(bp, x,0,(dy+1)/2,cs,0,DO)-1; // (x,y) should be in the gap
- if (x>3*dx/4 || y<dy/4) Break;
- if( get_bw(x0,x0+x,y0+y,y0+y,box1->p,cs,1) != 1 ) Break;
- if( get_bw(x0+x,x1,y0+y,y0+y,box1->p,cs,1) != 1 ) Break;
- if( get_bw(x0+x,x0+x,y1-dy/2,y1, box1->p,cs,1) != 1 ) Break;
- if( get_bw(x0+x, x0+x ,y0, y0+dy/3,box1->p,cs,1) == 1 ) // it v?
- if( get_bw(x0+x+1,x0+x+1,y0, y0+dy/3,box1->p,cs,1) == 1 ) Break;
-
- // UVW
- if(((num_cross( 0,dx/2+1,dy/ 8,dy/ 8,bp,cs)!=1)
- && (num_cross( 0,dx/2+1,dy/16,dy/16,bp,cs)!=1) // it v
- && (num_cross(dx/2+1,dx -1,dy/ 8,dy/ 8,bp,cs)!=1)) /* () added on Sep00 */
- || ((num_cross( 0,dx-1,dy-1-dy/8,dy-1-dy/8,bp,cs)> 1)
- && (num_cross( 0,dx-1,dy-1 ,dy-1 ,bp,cs)> 1)) ) Break;
- // UV
- if( get_bw(0 ,dx/8,dy-1-dy/6,dy-1,bp,cs,1)==1 ) Break;
- if( get_bw(dx-1-dx/8,dx-1,dy-1-dy/6,dy-1,bp,cs,1)==1 ) Break;
- if( loop(bp,0 ,dy/6 ,dx,cs,0,RI)
- >=loop(bp,0 ,dy-1-dy/3,dx,cs,0,RI) && dy>6 ) Break;
- if( loop(bp,0 ,dy-1-dy/3,dx,cs,0,RI)
- >loop(bp,0 ,dy-1-dy/8,dx,cs,0,RI)
- && loop(bp,dx-1,dy-1-dy/3,dx,cs,0,LE)
- >loop(bp,dx-1,dy-1-dy/8,dx,cs,0,LE) ) Break; // better OR ?
- if( loop(bp,0 ,dy-1-dy/3,dx,cs,0,RI)
- >=loop(bp,0 ,dy-1-dy/8,dx,cs,0,RI)
- && loop(bp,dx-1,dy-1-dy/3,dx,cs,0,LE)
- >=loop(bp,dx-1,dy-1-dy/8,dx,cs,0,LE) ) ad=99*ad/100; // font21
- if( loop(bp,dx-1,dy/6 ,dx,cs,0,LE)
- >=loop(bp,dx-1,dy-1-dy/3,dx,cs,0,LE) && dy>6 ) Break;
- x=loop(bp,0,dy-1,dx,cs,0,RI); // 3*x>dx changed to 2*x>dx May2001 JS
- x=loop(bp,x,dy-1,dx,cs,1,RI); if ( dx>14 && 2*x>dx ) Break; // U
- if( num_cross(0 ,dx/2, dy/4, dy/4,bp,cs)==2
- && num_cross(dx-dx/2,dx-1,dy-dy/4,dy-dy/4,bp,cs)==2 ) Break; // ~{\it u}
-
-#if 0
- // measure thickness of lower v
- i=loop(bp, 0,dy-1-dy/16,dx,cs,0,RI)
- +loop(bp,dx-1,dy-1-dy/16,dx,cs,0,LE);
- j=loop(bp, 0,dy-1-dy/4 ,dx,cs,0,RI)
- +loop(bp,dx-1,dy-1-dy/4 ,dx,cs,0,LE);
- if( box1->m1 && hchar && dy>15 && j>=i-dx/32 ) Break; // ~Y
-#endif
- /* V has serifs only on upper site! Y also on bottom, check it. Okt00 */
- i=loop(bp, 0, 0,dx,cs,0,RI);
- i=loop(bp, i, 0,dx,cs,1,RI); i1=i; // thickness
- i=loop(bp, 0, 1,dx,cs,0,RI);
- i=loop(bp, i, 1,dx,cs,1,RI); if(i>i1) i1=i; // thiggest
- i=loop(bp, 0,dy/4,dx,cs,0,RI);
- i=loop(bp, i,dy/4,dx,cs,1,RI); i2=i;
- i=loop(bp, 0,dy ,dx,cs,0,RI);
- i=loop(bp, i,dy ,dx,cs,1,RI); i3=i; // thickness
- i=loop(bp, 0,dy-1,dx,cs,0,RI);
- i=loop(bp, i,dy-1,dx,cs,1,RI); if(i>i3) i3=i; // thiggest
- if( y0 < box1->m2 )
- if( i1-i2 > dx/32+2
- && i3-i2 > dx/32+2 ) Break; // ~serif_Y
-
- if( y0 < box1->m2 ) // uppercase V ?
- if( i1-i2 < dx/32+2 ) /* no serif detected */
- if( num_cross(0,dx-1,dy-1-dy/4,dy-1-dy/4,bp,cs)==1 ){
- j=loop(bp, 0,dy-1-dy/4 ,dx,cs,0,RI);
- j=loop(bp, j,dy-1-dy/4 ,dx,cs,1,RI);
- if (j<i2+1) Break; // ~Y
- if (j<=i2+1) ad=99*ad/100; // ~Y
- }
-
- ad=99*ad/100; // be carefull (remove later)
-
- if( loop(bp,0 ,dy-1-dy/4,dx,cs,0,RI)
- >loop(bp,0 ,dy-1 ,dx,cs,0,RI) ) ad=96*ad/100;
-
- if (gchar) ad=99*ad/100;
- bc='v';
- if( hchar ) bc='V';
- Setac(box1, bc, ad);
- break;
- }
- return box1->c;
-}
-
-static wchar_t ocr0_rR(ocr0_shared_t *sdata){
- struct box *box1=sdata->box1;
- pix *bp=sdata->bp;
- int i,j,d,x,y,i1,i2,i3,hchar=sdata->hchar,gchar=sdata->gchar,
- x0=box1->x0,x1=box1->x1,y0=box1->y0,y1=box1->y1,cs=sdata->cs;
- int dx=x1-x0+1,dy=y1-y0+1, /* size */
- ad; /* tmp-vars */
-
- // --- test r -------
- for(ad=d=100;dy>3 && dx>1;){ // dy>dx, 4x6 font, dx=2 smallest prop-font
- DBG( wchar_t c_ask='r'; )
- if (sdata->holes.num > 0
- && ( sdata->holes.hole[0].y1 > dy/2 // tiny hole in upper left
- || sdata->holes.hole[0].x1 > dx/2 ) // is tolerated, ~Pp
- ) Break; /* tolerant against a tiny hole */
- if( 2*dy<box1->m3-box1->m1) Break;
-
- if( loop(bp,dx-1,dy/2,dx,cs,0,LE)<=dx/8 ) Break;
- x= loop(bp,dx-1,dy/2,dx,cs,0,LE); if (x<=dx/2) ad=99*ad/100; // ~t
- if (loop(bp,dx-1-x/2,0,dy,cs,0,DO)>dy/8) ad=99*ad/100; // ~t
- if( dx>4 )
- if( loop(bp,dx-1,dy/2,dx,cs,0,LE)<=dx/8+2 ) Break; // ~v Jun00
-
- i=dy-(dy+20)/32; // ignore dust on the ground
-
- for( y=4*dy/8; y<i; y++ ){ // center down v-line
- if( y<dy-2*dy/8 && num_cross(0,dx-1,y,y,bp,cs) !=1 ) break;
- i1= loop(bp,0 ,y,dx,cs,0,RI); if(i1>3*dx/8) break;
- i2= loop(bp,dx-1,y,dx,cs,0,LE); if(i1>i2) break;
- if( (i1+(dx-i2
- -1))/2 >= 4*dx/8 ) break; // mass middle should be left
- }
- if (y<i) Break;
-
- for( x=4*dx/8; x<dx-dx/8; x++ ){ // right upper h-line
- if( get_bw(x,x,0,(dy+2)/4,bp,cs,1) !=1 ) break; }
- if (x<dx-dx/8) Break;
-
- if( loop(bp,dx-1,dy-1-dy/4,dx,cs,0,LE)>5*dx/8 // not a C
- && get_bw(dx-1-dx/8,dx-1,dy-1-dy/4,dy-1,bp,cs,1) ==1 ) Break;
-
- if( loop(bp, 0,5*dy/8,dx,cs,0,RI)<=dx/8
- && loop(bp,dx-1,5*dy/8,dx,cs,0,LE)>=5*dy/8
- && loop(bp,dx/2, dy-1,dy,cs,0,UP)<=dy/8 ) Break; // ~c
-
- if( loop(bp, 0,3*dy/8,dx,cs,0,RI)
- > loop(bp,dx-1,3*dy/8,dx,cs,0,LE)+dx/8 ) {
- if( loop(bp, 0, dy/8,dx,cs,0,RI)<dx/8 ) Break; // ~z (broken)
- ad=98*ad/100;
- }
-
- if( loop(bp,0,dy/3,dx,cs,0,RI)>3*dx/4 ) Break; // ~i
- if( loop(bp,0,dy/4,dx,cs,0,RI)>3*dx/8 // ~I
- && get_bw(0,dx/8,0,dy/4,bp,cs,1) ==1 ) Break;
- if( num_cross(0,dx-1,dy/2, dy/2 ,bp,cs)!=1
- && num_cross(0,dx-1,dy/2+1,dy/2+1,bp,cs)!=1 ) Break; // ~n 024a3
-
- // itallic t is sometimes not high enough, look for v-like shape
- for(y=3*dy/4;y<dy-1;y++)
- if( num_cross(0,dx-1,y, y ,bp,cs)==2
- && num_cross(0,dx-1,y+1+dy/32,y+1+dy/32,bp,cs)==2 ) break; // ~t
- if(y<dy-1) Break;
- if (loop(bp,dx-1-dx/4,dy-1,dx,cs,0,UP)<dy/4) ad=98*ad/100; // ~f (serif)
- if( num_cross(dx-1,dx-1,0,3*dy/4,bp,cs)>1 ) ad=95*ad/100; // ~f
- if( num_cross(dx/2 ,dx/2 ,0,dy-1,bp,cs)>2
- && num_cross(dx/2+1,dx/2+1,0,dy-1,bp,cs)>2 ) Break; // ~f
-
- if (box1->dots) ad=98*ad/100; /* could be modified latin2-r */
- if (hchar) ad=96*ad/100;
- if (gchar) ad=97*ad/100;
- Setac(box1,'r',ad);
- break; // not 100% sure!
- }
- // --- test R ---------------------------------------------------
- for(ad=d=100;dx>2 && dy>3;){ // min 3x4
- DBG( wchar_t c_ask='R'; )
- if (sdata->holes.num > 2) Break; /* tolerant against a tiny hole */
- if( num_cross(x0,x1,y1-dy/8,y1-dy/8, box1->p,cs) < 2 ) Break; // ~P
- if (loop(bp, dx/2, dy/4,dy,cs,0,DO)>dy/2) Break; // ~C
- if (loop(bp, dx/2, 0,dy,cs,0,DO)>dy/8
- && loop(bp, dx/2,dy/16,dx,cs,0,RI)<dx/2
- && dy>=16 ) Break;
- for(i=1,y=y0+dy/8;y<=y1-dy/8 && i;y++){ // left v-line
- if( get_bw(x0 , x0+dx/2,y, y,box1->p,cs,1) != 1 ) i=0;
- } if( !i ) Break;
- for(i=1,x=x0+3*dx/8;x<=x1-dx/4 && i;x++){ // upper h-line
- if( get_bw( x, x, y0, y0+dy/4,box1->p,cs,1) != 1 ) i=0;
- } if( !i ) Break;
- for(y=0,x=x0+dx/4;x<=x1-dx/4;x++){ // lower h-gap
- i=loop(box1->p,x,y1,dy,cs,0,UP);
- /* on small chars bypass possible low left serifs */
- if (i>0) { i2=loop(box1->p,x-1,y1-i-1,dy,cs,0,UP);
- if (i2>1) i+=i2-1; }
- if (i>y) { y=i; i1=x; }
- } if( y<=dy/8 ) Break; if (y<dy/4) ad=80*ad/100;
- for(i=1,x=x0+dx/3;x<=x1-dx/8 && i;x++){ // vert crossed 2 ???
- if( num_cross(x,x,y0,y1, box1->p,cs) == 2 ) i=0;
- } if( i ) Break;
- for(i=1,y=y0;y<=y0+3*dy/8 && i;y++){ // upper 2 vert lines
- if( num_cross(x0,x1,y,y, box1->p,cs) == 2 ) i=0;
- } if( i ) Break;
- for(i=1,y=y0+dy/3;y<=y1-dy/3 && i;y++){ // midle h line
- if( num_cross(x0,x1,y,y, box1->p,cs) == 1 ) i=0;
- } if( i ) ad=95*ad/100; /* sometimes there is a small gap */
- for(i=1,y=y1-dy/4;y<=y1 && i;y++){ // lower 2 vert lies
- if( num_cross(x0,x1,y,y, box1->p,cs) == 2 ) i=0;
- } if( i ) Break;
- if( get_bw(x1-dx/3,x1,y0,y0+dy/4,box1->p,cs,1) != 1 ) Break; // pixel ru
- x=loop(bp,dx-1, dy/4,dx,cs,0,LE); if(x>dx/2) Break; i=x; // ru
- x=loop(bp,dx-1, dy/2,dx,cs,0,LE); if(x<=i ) Break; i=x; // rc
- x=loop(bp,dx-1, 5*dy/8,dx,cs,0,LE); if(x>i ) i=x;
- x=loop(bp,dx-1, 6*dy/8,dx,cs,0,LE); if(x>i ) i=x;
- x=loop(bp,dx-1,dy-1-dy/8,dx,cs,0,LE); if(x>=i ) Break; // rd
-
- i1=loop(bp,0, dy/4,dx,cs,0,RI); // straight
- i2=loop(bp,0, dy/2,dx,cs,0,RI);
- i3=loop(bp,0,dy-1-dy/4,dx,cs,0,RI); if( abs(i1+i3-2*i2)>1+dx/16 ) Break;
- if (dy>15)
- if (loop(bp,dx-1, dy/2,dx,cs,0,LE)>=loop(bp,dx-1, dy-1,dx,cs,0,LE)
- && loop(bp,dx-1,3*dy/16,dx,cs,0,LE)>=loop(bp,dx-1,dy/16,dx,cs,0,LE)+dx/8 ) Break; // ~ff
- if (dy>7)
- if (loop(bp,dx-1,dy-2 ,dx,cs,0,LE)
- >loop(bp,dx-1,dy-2-dy/8,dx,cs,0,LE)) {
- ad=98*ad/100;
- if (loop(bp,dx-1,dy-1-dy/4,dx,cs,0,LE)==0
- && loop(bp,dx-1,dy-2-dy/8,dx,cs,0,LE)>0 ) Break; // broken B ??
- }
- j=sdata->holes.num;
- if (j != 1) {
- i=num_hole (x0,x1,y0,y1-dy/3,box1->p,cs,NULL);
- // j=num_hole (x0,x1,y0,y1 ,box1->p,cs,NULL);
- if (i==0) ad=90*ad/100; /* some times there is a small gap */
- if (j>1 || j>i) Break;
- }
- if (sdata->holes.num < 1) ad=90*ad/100;
- if (sdata->holes.num==1)
- if (sdata->holes.hole[0].y1 > 3*dy/4) ad=95*ad/100; // alpha
-
- if (!hchar) ad=98*ad/100;
- if ( gchar) ad=98*ad/100;
- Setac(box1,'R',ad);
- break;
- }
- return box1->c;
-}
-
-static wchar_t ocr0_m(ocr0_shared_t *sdata){
- struct box *box1=sdata->box1;
- pix *bp=sdata->bp;
- int i,d,x,y,i1,i2,i3,i4,i5,hchar=sdata->hchar,gchar=sdata->gchar,
- handwritten=0,
- x0=box1->x0,x1=box1->x1,y0=box1->y0,y1=box1->y1,cs=sdata->cs;
- int dx=x1-x0+1,dy=y1-y0+1, /* size */
- ad; /* tmp-vars */
-
- // --- test m -------
- for(ad=d=100;dx>4 && dy>3;){
- DBG( wchar_t c_ask='m'; )
- if (sdata->holes.num > 1) Break; /* tolerant against a tiny hole */
- if (sdata->holes.num > 0) ad=96*ad/100;
- x =loop(bp,dx-1,dy/2,dx,cs,0,LE); if(3*x>dx) Break; // ~K
- y=dy/2;
- i=num_cross(0,dx-1,y ,y ,bp,cs); if (i!=3)
- i=num_cross(0,dx-1,y+1,y+1,bp,cs);
- if (i<3 && i>5) Break; // m ru rn, handwritten m
- // im or glued.mm cut to nm
- if (i>3) { ad=99*ad/100; MSG(fprintf(stderr,"ad=%d",ad);) }
- for (i=0,y=dy-1-dy/8;y>dy/2;y--) {
- i=num_cross(0,dx-1,y,y,bp,cs); if (i>2) break;
- } if (i>3) Break;
- for ( ;y>dy/2;y--) {
- i=num_cross(0,dx-1,y,y,bp,cs); if (i!=3) break;
- } if (i>5) Break; y++; i5=y;
- if (y> dy/2) handwritten=10;
- if (y>3*dy/4) handwritten=60;
- /* @@...............
- @@......,........
- @@,...@@@....@@@.
- @@,,.@@@@..@@@@@,
- @@@.@@@@@.@@@@@@,
- @@;@@@@@@@@@;,@@,
- @@@@@,.@@@@,,,@@@ <- i5
- ,@@@...;@@....@@@
- .@;...........,@@
- ...............@@
- i1 i2 i3 i4
- */
- x =loop(bp,0,y,dx ,cs,0,RI); if(x> dx/4) Break; // search 1st v-line
- x+=loop(bp,x,y,dx-x,cs,1,RI); if(x> dx/2) Break; i1=x; // first gap
- x+=loop(bp,x,y,dx-x,cs,0,RI); if(x>3*dx/4) Break; i2=x; // 2nd v-line
- x+=loop(bp,x,y,dx-x,cs,1,RI); if(x>6*dx/8) Break; i3=x; // 2nd gap
- x+=loop(bp,x,y,dx-x,cs,0,RI); if(x<5*dx/8) Break; i4=x; // 3th v-line
- if (x>=dx) Break; // missing 3th v-line, ~W
- MSG(fprintf(stderr,"y=%d x=%d %d %d %d",y,i1,i2,i3,i4);)
- if( abs((i2-i1)-(i4-i3)) > 2+((i2-i1)+(i4-i3))/4 ) Break; // same gap width? rn
- if( abs((i2-i1)-(i4-i3)) > 2+((i2-i1)+(i4-i3))/8 ) ad=98*ad/100; // same gap width? rn
- // the same game for the lower part =>l1 l2 l3 l4 ???
- i =loop(bp,0,5*dy/8,dx,cs,0,RI);
- i =loop(bp,i,5*dy/8,dx,cs,1,RI);
- x =loop(bp,0,dy-dy/32-1,dx,cs,0,RI);
- x =loop(bp,x,dy-dy/32-1,dx,cs,1,RI);
- if( x > i+1 ) i=1; else i=0; /* looks like serif m, Okt00 */
- for(y=0,x=i1;x<i2;x++) {
- i=loop(bp,x,dy-1,dy,cs,0,UP); if (i>y) y=i;
- }
- if(y<dy/4 || y<y1-y0-i5-1-dy/16) Break; // no gap detected
- for(y=0,x=i3;x<i4;x++) {
- i=loop(bp,x,dy-1,dy,cs,0,UP); if (i>y) y=i;
- }
- if(y<dy/4) Break; // no gap detected
- for(x=i1;x<i4;x++) if( loop(bp,x,0,dy,cs,0,DO)>=dy/2 ) break;
- if(x<i4 && handwritten<10) Break; // gap detected
- // glued rn as m ??? hmm seems a ballance act
- if(i2-i1>i4-i3+dx/16){
- for(y=0,x=(i1+i2)/2;x<i2;x++){
- i=loop(bp,x,0,dy,cs,0,DO);
- i=loop(bp,x,i,dy,cs,1,DO); // measure thickness
- if( i>y ) y=i; if( 2*i<y ) Break;
- }
- if(x <i2) Break; // unusual property for m (see n)
- }
- if(gchar) ad=99*ad/100;
- if(hchar) ad=99*ad/100;
-
- if( loop(bp,dx-1,dy/16,dx,cs,0,LE)<2
- && loop(bp,dx-1,dy/4 ,dx,cs,0,LE)>3 ) Break; // melted WT
-
- x=loop(bp,dx-1,dy/2,dx,cs,0,LE);
- if (x>2 && loop(bp,dx-1-x/2,0,dy,cs,0,DO)<dy/2) Break; // melt toc
- if (loop(bp,(i3+i4)/2,0,dy,cs,0,DO)>dy/2) Break; // N
-
- // {\it m}
- if( loop(bp,1, dy/4,dx,cs,0,RI)
- >loop(bp,0,7*dy/8,dx,cs,0,RI) )
- Setac(box1,'m',98*ad/100);
-
- if (handwritten<10){
- x =loop(bp,0,dy/4,dx,cs,0,RI);
- x+=loop(bp,x,dy/4,dx,cs,1,RI);
- for( ;x<i4;x++){ // x=i1 ?
- i=loop(bp,x,0,dy,cs,0,DO);
- if (i>=dy/4) ad=99*ad/100;
- if (i>(dy+2)/4) ad=95*ad/100;
- if (3*i>dy) Break;
- }
- if(x<i4) Break; // gap detected
- }
-
- if (box1->dots) ad=99*ad/100;
- Setac(box1,'m',ad);
- if (ad>=100) return 'm';
- break;
-
- }
- return box1->c;
-}
-
-static wchar_t ocr0_tT(ocr0_shared_t *sdata){
- struct box *box1=sdata->box1;
- pix *bp=sdata->bp;
- int i,i1,i2,i3,i4,j,d,x,y,yb,hchar=sdata->hchar,gchar=sdata->gchar,
- x0=box1->x0,x1=box1->x1,y0=box1->y0,y1=box1->y1,cs=sdata->cs;
- int dx=x1-x0+1,dy=y1-y0+1, /* size */
- ad; /* tmp-vars */
-
- // --- test T ---------------------------------------------------
- for(ad=d=100;dx>2 && dy>3;){ // dx>1 dy>2*dx
- DBG( wchar_t c_ask='T'; )
- if (sdata->holes.num > 1) Break; /* tolerant against a tiny hole */
- // upper horizontal line
- i1= loop (bp, dx/8,0,dy,cs,0,DO); // left side
- i2= loop (bp,dx-1-dx/8,0,dy,cs,0,DO); // right side
- i3= loop (bp, dx/8,i1,dy,cs,1,DO); // left side
- i4= loop (bp,dx-1-dx/8,i2,dy,cs,1,DO); // right side
- if (i1>dy/4 || i2>dy/4) Break;
- for (x=dx/8;x<dx-1-dx/8;x++) {
- i= loop (bp,x,0,dy,cs,0,DO);
- if (i>i1+dy/8 && i>i2+dy/8) break;
- if (i<i1-dy/8 && i<i2-dy/8) break;
- } if (x<dx-1-dx/8) Break;
- if( get_bw( 0,dx-1, dy/2, dy/2,bp,cs,1) != 1 ) Break;
- if( get_bw( 0,(dx-1)/8, dy/2,dy-1-dy/8,bp,cs,1) == 1 ) Break;
- if( get_bw( 0,3*dx/16, dy/2,dy-1-dy/4,bp,cs,1) == 1 ) Break;
- if( get_bw(dx-1-dx/4,dx-1, dy/2,dy-1-dy/4,bp,cs,1) == 1 ) Break;
- // center width
- for( y=dy/4;y<3*dy/4;y++){ // oberer Balken?
- i=dx/4+loop(bp,dx/4,y,dx,cs,0,RI); // left side of vertical line
- j= loop(bp, i,y,dx,cs,1,RI); // width of vertical line
- if (3*j>dx+1 || i+j>=dx || i+j/2<dx/2-1) break; // ~r?7
- } if (y<3*dy/4) Break; // Jan07
- // down width
- for( y=3*dy/4;y<dy;y++){
- i= loop(bp,dx/4,y,dx,cs,0,RI);
- i= loop(bp, i,y,dx,cs,1,RI);if(4*i>3*x) break; //~I
- } if( y<dy ) Break;
-
- i =dx/4+loop(bp,dx/4,dy/4,dx,cs,0,RI);if(i>3*dx/4) Break; // ~7
- i+= loop(bp,i ,dy/4,dx,cs,1,RI);if(i>3*dx/4) Break;
-
- if( num_cross(0,dx-1, dy-1, dy-1,bp,cs) != 1
- && num_cross(0,dx-1, dy-2, dy-2,bp,cs) != 1 ) Break;
- if( num_cross(0,dx-1,2*dy/3,2*dy/3,bp,cs) != 1
- && num_cross(0,dx-1,2*dy/3,2*dy/3,bp,cs) != 1 ) Break;
- if (box1->m3 && 2*y1>box1->m3+box1->m4
- && loop(bp,0, 0,dy/2,cs,0,DO)>=dy/4
- && loop(bp,0,dy-1,dy ,cs,0,UP)<=dy/2) ad=96*ad/100; // ~J
- if (gchar) ad=98*ad/100;
- if( loop(bp,0,dy-1,dx,cs,0,RI)<=dx/8) ad=99*ad/100; // ~J
- i = loop(bp,0,dy/2,dx,cs,0,RI);
- j = loop(bp,i,dy/2,dx,cs,1,RI);
- if( 2*i>=dx || 2*(dx-j-i)<i) ad=95*ad/100; // ~J
-
- Setac(box1,'T',ad);
- if (ad>=100) return 'T';
- break;
- }
- // --- test t ---------------------------------------------------
- // written t can look like a + or even with missing right side
- // smallest t found in win-screenshot (prop-font) dx=2
- for(ad=d=100;dx>1 && dy>=box1->m3-box1->m2-1;){ // sometimes no hchar!
- DBG( wchar_t c_ask='t'; )
- if (sdata->holes.num > 1) Break; /* tolerant against a tiny hole */
- if (dy<=box1->m3-box1->m2+1) ad=96*ad/100; // bad line detection?
- for(x=0,yb=j=y=dy/32+3*dy/16;y<5*dy/8;y++)if(y>0){ // upper cross line
- i=loop(bp,0,y,dx,cs,0,RI);
- i=loop(bp,i,y,dx,cs,1,RI); if( i>x ) { x=i;yb=j=y; } // hor. line
- i=num_cross(0,dx-1,y ,y ,bp,cs);
- j=num_cross(0,dx-1,y+1,y+1,bp,cs); if (i>2 && j>2) break;
- if( y<11*dy/16
- && num_cross(0,dx-1,y ,y ,bp,cs) != 1
- && ( num_cross(0,dx-1,y+dy/8,y+dy/8,bp,cs) != 1 || dy<13) // against noise
- ) break;
- } if( y<4*dy/8 ) Break;
- if (dy>12 && x>4 && x>dx/2 && yb<=(dy+4)/8)
- if ( loop(bp,dx-1-3*x/4,yb,dy,cs,1,UP)
- <=loop(bp,dx-1-1*x/4,yb,dy,cs,1,UP)+1 )
- if ( loop(bp,0 ,dy/2,dy,cs,1,UP)>dx/8 ) Break; // ~C
-
- if (x<dx/2) ad=95*ad/100; // unusual small ?
- if (x>=dx && 9*dx>=8*dy) { ad=99*ad/100; } // +
-
- i=loop(bp,dx-1,0,dx,cs,0,LE);
- for(y=0;y<dy/4;y++){
- if( num_cross(0,dx-1,y ,y ,bp,cs) == 2
- && num_cross(0,dx-1,y+1,y+1,bp,cs) == 2 ) break;
- j=loop(bp,dx-1,y,dx,cs,0,LE); if(j-i>1) break; i=j;
- }
- if( y<dy/4 ) Break; // ~f
-
- i=loop(bp,dx-1,yb,dx,cs,0,LE);
- for(y=dy/8;y<yb;y++)
- if( loop(bp,dx-1,y,dx,cs,0,LE)>i ) break;
- if( y==yb ) break;
-
- j=loop(bp,0, dy/2,dx,cs,0,RI);
- j=loop(bp,j, dy/2,dx,cs,1,RI); i=j; // thickness
- j=loop(bp,0, dy/4,dx,cs,0,RI);
- j=loop(bp,j, dy/4,dx,cs,1,RI); if (j<i) i=j; // thickness
- j=loop(bp,0,3*dy/4,dx,cs,0,RI);
- j=loop(bp,j,3*dy/4,dx,cs,1,RI); if (j<i) i=j; // thickness
- if( 2*x<3*i ) Break;
-
- if( loop(bp,dx-1,dy/2,dx,cs,0,LE)-dx/8
- <=loop(bp,dx-1, yb ,dx,cs,0,LE) )
- if( loop(bp,dx-1, yb ,dx,cs,0,LE)-dx/8
- >=loop(bp,dx-1,yb/2,dx,cs,0,LE) ) Break; // ~1 ???
-
- j=1;
- for(y=1;j && y<yb; y++) // no @@ pattern
- for(x=0;j && x<dx-2;x++){ // ..
- if( getpixel(bp,x ,y )>=cs && getpixel(bp,x+1,y )>=cs
- && getpixel(bp,x ,y-1)< cs && getpixel(bp,x+1,y-1)< cs ) { j=0;break; }
- } if(!j) Break;
-
- if( num_cross(0,dx-1,dy-2,dy-2,bp,cs) == 2
- && num_cross(0,dx-1,dy-1,dy-1,bp,cs) == 2 ) Break; // ~* (5er)
-
- if( dy>= 16
- && loop(bp, 0, 3*dy/4,dx,cs,0,RI)
- >=loop(bp, 0, dy-2,dx,cs,0,RI)
- && loop(bp,dx-1, 3*dy/4,dx,cs,0,LE)
- <=loop(bp,dx-1, dy-2,dx,cs,0,LE)
- && loop(bp,dx-1, 1,dx,cs,0,LE)+dx/16
- <loop(bp,dx-1,3*dy/16,dx,cs,0,LE)
- && ( loop(bp, 0, 1,dx,cs,0,RI)
- >loop(bp, 0,3*dy/16,dx,cs,0,RI)+dx/16
- || loop(bp,dx-1, 0,dx,cs,0,LE)==0
- || loop(bp,dx-1, 1,dx,cs,0,LE)==0) ) ad=96*ad/100; // ~f Jan02
- if(dx<8 && dy>12){ // thin f's could easily confound with t
- x=loop(bp,dx-1,3*dy/16,dx,cs,0,LE);
- if (x)
- if (loop(bp,dx-x,0,dy,cs,0,DO)<3*dy/16
- && loop(bp, 0, 3*dy/4,dx,cs,0,RI)+1
- >=loop(bp, 0, dy-2,dx,cs,0,RI)
- && loop(bp,dx-1, 3*dy/4,dx,cs,0,LE)
- <=loop(bp,dx-1, dy-2,dx,cs,0,LE) ) Break;
- }
- if (dx>7)
- if( num_cross( 0,dx-1,2*dy/3,2*dy/3,bp,cs) > 1
- && num_cross( 0,dx/2,2*dy/3,2*dy/3,bp,cs) > 0
- && num_cross(dx/2,dx-1,2*dy/3,2*dy/3,bp,cs) > 0 )
- if (sdata->holes.num > 0)
- if (sdata->holes.hole[0].y0 > dy/4) Break; // ~6
- // if ( num_hole( x0, x1, y0+dy/4, y1, box1->p,cs,NULL) > 0 ) Break; // ~6
-
- if( num_cross(0,dx-1,3*dy/4, 3*dy/4, bp,cs) >= 2
- && num_cross(0,dx-1,3*dy/4-1,3*dy/4-1,bp,cs) >= 2 ){
- ad=99*ad/100; /* italic t ? */
- if (loop(bp,dx/2 ,dy-1,dy,cs,0,UP)>dy/4) Break; // ~h
- if (loop(bp,dx/2+1,dy-1,dy,cs,0,UP)>dy/4) Break; // ~h
- }
-
- x= loop(bp,dx-1,dy/2,dx,cs,0,LE);
- i= loop(bp,dx-1,dy/8,dx,cs,0,LE);
- if (i>x && loop(bp,dx-x,0,dy,cs,0,DO)>=dy/2) ad=90*ad/100; /* ~\ */
-
- x= loop(bp,0, 0,dx,cs,0,RI);
- i= loop(bp,0, 1,dx,cs,0,RI); if (i<x) x=i;
- i= loop(bp,0,dy/4,dx,cs,0,RI);
- if (i-x>1) Break; // l
-
- // this happens quite often, do not be to strong
- if (!box1->m2) ad=99*ad/100;
- if (box1->m2) {
- if (!hchar) ad=99*ad/100; /* some times t is not long enough */
- if( y0>=box1->m2-(box1->m2-box1->m1)/4 ) ad=99*ad/100; /* to short */
- if( y0>=box1->m2 ) ad=99*ad/100; /* to short */
- }
-
- if (sdata->holes.num > 0) ad=95*ad/100;
- if (gchar) ad=99*ad/100;
- if (box1->dots) ad=90*ad/100;
- Setac(box1,'t',ad);
- break;
- }
- return box1->c;
-}
-
-static wchar_t ocr0_sS(ocr0_shared_t *sdata){
- struct box *box1=sdata->box1;
- pix *bp=sdata->bp;
- int d,x,y,i1,i2,i3,hchar=sdata->hchar,gchar=sdata->gchar,
- x0=box1->x0,x1=box1->x1,y0=box1->y0,y1=box1->y1,cs=sdata->cs;
- int dx=x1-x0+1,dy=y1-y0+1, /* size */
- ad; /* tmp-vars */
- wchar_t ac;
-
- // --- test sS near 5 ---------------------------------------------------
- for(ad=d=100;dx>2 && dy>3;){ // min 3x4 (4x6 font)
- DBG( wchar_t c_ask='s'; )
- if (sdata->holes.num > 1) Break; /* tolerant against a tiny hole */
- if( num_cross( dx/2, dx/2,0,dy-1,bp,cs)!=3
- && num_cross(5*dx/8,3*dx/8,0,dy-1,bp,cs)!=3
- && dy>4 ) Break;
- if( num_cross(0,dx-1,dy/2 ,dy/2 ,bp,cs)!=1
- && num_cross(0,dx-1,dy/2-1,dy/2-1,bp,cs)!=1 ) Break;
- // get the upper and lower hole koords
- y=dy/4;
- x =loop(bp,0,y,dx,cs,0,RI); if(x>3*dx/8) Break; /* slanted too */
- x +=loop(bp,x,y,dx,cs,1,RI); if(x>5*dx/8) Break; /* fat too */
- i1 =loop(bp,x,y,dx,cs,0,RI); i1=(i1+2*x)/2; // upper center x
- y=11*dy/16;
- x =loop(bp,dx-1 ,y,dx,cs,0,LE); if(x>dx/4) Break;
- x +=loop(bp,dx-1-x,y,dx,cs,1,LE); if(dx>5 && dy>7 && x>dx/2) Break;
- if (x>3*dx/4) Break; if(x>dx/2) { ad=98*ad/100; MSG({})}
- i2 =loop(bp,dx-1-x,y,dx,cs,0,LE); i2=dx-1-(i2+2*x)/2; // upper center x
- for( y=dy/4;y<dy/2;y++ ) // Mai00 ~3
- if( get_bw(0,i1,y,y,bp,cs,1) != 1 ) break;
- if( y<dy/2 ) Break;
- y=dy/2-loop(bp,dx-1,dy/2,dy/2,cs,1,UP);
-// if( !joined(bp,i1,dy/4,dx-1,y,cs) ){
- // break; // sometimes thick small fonts have no gap
-// }
- for(y=dy/4;y<dy/2;y++){
- x=loop(bp,dx-1,y,dx,cs,0,LE);if(x>dx/8) break;
- }
- if(y==dy/2) Break; // Mai00
-
- y=dy/2+loop(bp,0,dy/2,dy/2,cs,1,DO);
- if( !joined(bp,0,y,i2,11*dy/16,cs) ) Break;
-
- if (sdata->holes.num > 0)
- if (sdata->holes.hole[0].y0 > dy/4) Break; // ???
- // if( num_hole( x0, x1, y0+dy/4, y1, box1->p,cs,NULL) > 0 ) Break;
-
- i1=loop(bp,dx-1,dy-1,dx,cs,0,LE);
- i2=loop(bp,dx-1,dy-2,dx,cs,0,LE);
- if (i2-i1 >= dx/4) Break; // ~{ 5x7font
-
- i1=loop(bp, 0, 0,dx,cs,0,RI);
- i2=loop(bp, 0, 1,dx,cs,0,RI);
- if (i2-i1 >= dx/4) Break; // ~} 5x7font
-
- // sS5 \sl z left upper v-bow ?
-
- i1=loop(bp, 0,dy/2,dx,cs,0,RI);
- i1=loop(bp, i1,dy/2,dx,cs,1,RI);
- if (4*i1>=3*dx) ad=97*ad/100; // ~5 7-segment
-
- i1=loop(bp,0, dy/16,dx,cs,0,RI);
- i2=loop(bp,0,4*dy/16,dx,cs,0,RI);
- i3=loop(bp,0,7*dy/16,dx,cs,0,RI);
- if( 2*i2+dx/32 >= i1+i3 ){
- if( 2*i2+dx/32 > i1+i3 || dx>9 ) Break;
- // very small s?
- i1+=loop(bp,i1, dy/16,dx,cs,1,RI);
- i2+=loop(bp,i2,4*dy/16,dx,cs,1,RI);
- i3+=loop(bp,i3,7*dy/16,dx,cs,1,RI);
- if( 2*i2+dx/32 >= i1+i3 ) Break;
- }
-
- for(y=7*dy/16;y<5*dy/8;y++){
- if( num_cross( 0,dx-1,y ,y ,bp,cs)==2 )
- if( num_cross( 0,dx-1,y+1,y+1,bp,cs)==1 )
- if( num_cross( 0,dx/4,y,y,bp,cs)==1 ) break; // ~5
- } if(y<5*dy/8) Break; // v0.2.4a5
- if ( loop(bp, dx-1,dy-2-dy/32,dx,cs,0,LE)
- > loop(bp, 0, 1+dy/32,dx,cs,0,RI) + dx/4 ) Break; // ~5 Dec00
- ac='s';
- if (gchar) { ad=98*ad/100; MSG({}) }
- if( hchar ){ // S but 5 is very similar! check it
- ac='S';
- if ( loop(bp, dx-1,dy-1-dy/32,dx,cs,0,LE)
- > loop(bp, 0, 0+dy/32,dx,cs,0,RI) ) ad=99*ad/100; // ~5
- if ( loop(bp, 0,dy-1-dy/32,dx,cs,0,RI)
- > loop(bp, dx-1, 0+dy/32,dx,cs,0,LE) ) ad=99*ad/100; // ~5
- }
- Setac(box1,ac,ad);
- break;
- }
- return box1->c;
-}
-
-static wchar_t ocr0_gG(ocr0_shared_t *sdata){
- struct box *box1=sdata->box1;
- pix *bp=sdata->bp;
- int i,j,d,x,y,i1,i2,i3,hchar=sdata->hchar,gchar=sdata->gchar,
- x0=box1->x0,x1=box1->x1,y0=box1->y0,y1=box1->y1,cs=sdata->cs;
- int dx=x1-x0+1,dy=y1-y0+1, /* size */
- ad; /* tmp-vars */
-
- // --- test g ---------------------------------------------------
- /* some g's have crotchet at upper right end, so hchar can be set */
- // ~italic g
- for(ad=d=100;dx>2 && dy>4;){ // min 3x5
- DBG( wchar_t c_ask='g'; )
- if (sdata->holes.num > 3) Break; /* tolerant against a tiny hole */
- if( get_bw(x0+dx/2, x0+dx/2, y1-dy/2, y1,box1->p,cs,1) != 1 ) Break;
- if( get_bw(x1-dx/4, x1 , y1-dy/4, y1,box1->p,cs,1) != 1 ) Break; // ~p
- if( get_bw(x0+dx/2, x0+dx/2, y0, y0+dy/2,box1->p,cs,1) != 1 ) Break;
-
- if( num_cross(x0+dx/2, x0+dx/2, y0, y1, box1->p,cs) < 3 )
- if( num_cross(x1-dx/2, x1-dx/2, y0, y1, box1->p,cs) < 3 ) Break;
- if (sdata->holes.num < 1) Break;
- for (i=0;i<sdata->holes.num;i++){
- if (sdata->holes.hole[i].y1 < 5*dy/8+1) break;
- } if (i==sdata->holes.num) Break; // no upper hole found
- // if( num_hole ( x0, x1, y0, y0+5*dy/8, box1->p,cs,NULL) != 1 ) Break;
- for(y=dy/4;y<dy;y++) if( num_cross(0,dx-1,y,y,bp,cs)==2 ) break;
- if( y==dy ) Break; // ~q
- if( get_bw(0,dx/2,7*dy/8,7*dy/8,bp,cs,1) != 1 ) Break; // ~q
- y =loop(bp,dx/16,0,dy,cs,0,DO); if(y<=dy/8)
- y+=loop(bp,dx/16,y,dy,cs,1,DO); if(16*y>=15*dy) Break; // ~B
-
- if (num_cross(x1, x1, (y0+y1)/2, y1, box1->p,cs)>1) {
- ad=98*ad/100; // ~&
- if (num_cross(x1 , x1 , y0, (y0+y1)/2, box1->p,cs)<1 ) ad=96*ad/100;
- if (num_cross(x1-1, x1-1, y0, (y0+y1)/2, box1->p,cs)<1 ) ad=95*ad/100;
- }
- // looking for a gap
- for (x=0,y=dy/4;y<dy-dy/4;y++){
- i=loop(bp,dx-1,y,dy,cs,0,LE); if (i>x) x=i;
- } // in a good font x is greater dx/2
-
- if (x<dx/2) { // bad font? or %
- if( num_cross(x0,x1 ,y0+dy/4,y0+dy/4,box1->p,cs) > 2
- || num_cross(x0,x1 ,y0+dy/8,y0+dy/8,box1->p,cs) > 2) ad=90*ad/100;
- if( num_cross(x0,x1+dx/4,y1-dy/4,y1-dy/4,box1->p,cs) > 2
- || num_cross(x0,x1+dx/4,y1-dy/8,y1-dy/8,box1->p,cs) > 2) ad=90*ad/100;
- }
- if( num_cross(0,dx-1,dy/2,dy/2,bp,cs) >2 ) ad=99*ad/100; // ~/o
-
- /* test for horizontal symmetry ~8 */
- for (y=0;y<dy;y++) for (x=0;x<dx/2;x++)
- if ((getpixel(bp,x,y)<cs)!=(getpixel(bp,dx-1-x,y)<cs)) { y=dy+1; break; }
- if (y==dy) Break; /* ~8 */
-
- if (box1->m4==0) ad=98*ad/100;
- if ( hchar) ad=96*ad/100;
- if (!gchar) ad=96*ad/100;
- ad=98*ad/100;
- Setac(box1,'g',ad);
- break;
- }
- // --- test rundes G ---------------------------------------------
- for(ad=d=100;dx>3 && dy>4;){ // min 3x4
- DBG( wchar_t c_ask='G'; )
- if (sdata->holes.num > 1) Break; /* tolerant against a tiny hole */
- if( get_bw(x0 ,x0+dx/2,y0+dy/3,y0+dy/3,box1->p,cs,1) != 1 ) Break;
- if( get_bw(x0+dx/2,x1-dx/4,y0 ,y0+dy/4,box1->p,cs,1) != 1 ) Break;
- if( get_bw(x0+dx/2,x0+dx/2,y1-dy/4,y1 ,box1->p,cs,1) != 1 ) Break;
- if( get_bw(x0 ,x0+dx/2,y1-dy/3,y1-dy/3,box1->p,cs,1) != 1 ) Break; // ~S
- for( y=y0+dy/4;y<y1-dy/3;y++ )
- if( get_bw(x1-dx/2,x1,y,y,box1->p,cs,1) == 0 ) break;
- if( y==y1-dy/3 ) Break; // no gap
-
- if( num_cross(x0+dx/2 , x0+dx/2 , y0, y, box1->p,cs) != 1
- || num_cross(x0+dx/2+1, x0+dx/2+1, y0, y, box1->p,cs) != 1 ) Break; // ~e
-
- x=x0; y=y1;
- turmite(box1->p,&x,&y,x0,x1,y0,y1,cs,UP,ST); // left bow?
- if( y<y0+dy/4 ) Break; // filter W
-
- x=x1; y=y1-dy/3; // upper right offen bow
- turmite(box1->p,&x,&y,x0,x1,y0,y1,cs,LE,ST);
- if( x<x1-3*dx/8 ) Break;
- turmite(box1->p,&x,&y,x0,x1,y0,y1,cs,ST,LE);
- if( x<x0+dx/2 ){ // not sure, try again (not best)
- x=x1; y=y1-dy/4;
- turmite(box1->p,&x,&y,x0,x1,y0,y1,cs,LE,ST);
- turmite(box1->p,&x,&y,x0,x1,y0,y1,cs,ST,LE);
- if( x<x0+dx/2 ) Break;
- }
- turmite(box1->p,&x,&y,x0,x1,y0,y1,cs,RI,UP); // upper end right midle
- if( x<=x1 ) Break;
- if( y<y0+3*dy/8 ) Break;
- if( y>y1-dy/4 ) Break;
-
- x=x1-dx/3;y=y1; // follow left C-bow, filter S
- turmite(box1->p,&x,&y,x0,x1,y0+dy/4,y1,cs,LE,UP); // w=LE b=UP
- if( y>y0+dy/4+1 ) Break; /* leave box below for S or on top for CG */
- MSG(fprintf(stderr,"xy= %d %d",x-x0,y-y0);)
- /* if (y<y0) y++; else x++; */ /* enter the box again */
- turmite(box1->p,&x,&y,x0,x1,y0 ,y1,cs,RI,UP);
- MSG(fprintf(stderr,"xy= %d %d",x-x0,y-y0);)
- if( y>y0 ) Break;
- if (sdata->holes.num > 0) Break;
- // if( num_hole(x0,x1,y0,y1,box1->p,cs,NULL) > 0 ) Break;
- if( dx>4 && dy>6){ // no (<[
- for(i=1,y=0;i && y<dy/3;y++)
- if( num_cross(0,dx-1,y,y,bp,cs) == 2 ) i=0;
- if( i ) ad=98*ad/100;
- for(i=1,y=0;i && y<dy/3;y++)
- if( num_cross(0,dx-1,dy-1-y,dy-1-y,bp,cs) == 2 ) i=0;
- if( i ) Break;
- }
- for(i=1,y=dy/2;i && y<dy;y++)
- if( num_cross(0,dx-1,y,y,bp,cs) == 2 ) i=0;
- if( i ) Break;
- for(i=0,y=3*dy/4;y<dy;y++){
- x=loop(bp,0,y,dx,cs,0,RI); // Kante abfallend <=> Z
- if( x<i-dx/20 ) break;
- if( x>i ) i=x;
- } if( y<dy ) Break;
-
- // only check the middle!
- for(i=0,i1=y=dy/4;y<dy-dy/4;y++){ // look for horizontal line
- x=loop(bp,dx-1 ,y,dx/4,cs,0,LE);
- x=loop(bp,dx-1-x,y,dx/2,cs,1,LE); if(x>i){ i=x;i1=y; }
- } if( i1<=dy/4 || i1>=dy-dy/4 ) Break; // around the middle ?
- // check from above for gap and left vertical line (~S)
- x =loop(bp,0,i1,dx ,cs,0,RI);
- x+=loop(bp,x,i1,dx-x,cs,1,RI); // left vertical bow
- x+=loop(bp,x,i1,dx-x,cs,0,RI); if (x>=dx) ad=90*ad/100;
- MSG(fprintf(stderr,"h-bar y dx %d %d ad= %d",i1,i,ad);)
-
- i=1; // Mar06: adapted to 4x6 font
- for(x=dx/2;x<dx-1 && i;x++) // look for @@ (instead +1 use +delta?)
- for(y=dy/2;y<dy-1 && i;y++){ // .@
- if( getpixel(bp,x ,y )>=cs
- && getpixel(bp,x+1,y )< cs
- && getpixel(bp,x+1,y-1)< cs
- && getpixel(bp,x ,y-1)< cs ) { i=0;break; }
- }
- if(i) ad=95*ad/100; // ~C
- if(!hchar) ad=98*ad/100;
- if( gchar) ad=98*ad/100;
-
- Setac(box1,'G',ad);
- break;
- }
- // --- test \it g like 9 ----------------------------------------------
- for(ad=d=100;dx>2 && dy>4;){ // dx>1 dy>2*dx
- DBG( wchar_t c_ask='g'; )
- if (sdata->holes.num > 2) Break; /* tolerant against a tiny hole */
- if( num_cross(x0+dx/2,x0+dx/2,y0,y1,box1->p,cs) != 3 // pre select
- && num_cross(x0+dx/4,x1-dx/4,y0,y1,box1->p,cs) != 3 ) Break;
- for( x=0,i=y=y0+dy/2;y<=y1-3*dy/16;y++){ // suche kerbe
- j=loop(box1->p,x0,y,dx,cs,0,RI);
- if( j>2 && j>dx/4 && y<y1-3 && j<dx/2 ) // long bow
- j+=loop(box1->p,x0+j-2,y+1,dx,cs,0,RI)-2;
- if( j>x ) { x=j; i=y; }
- }
- if( x<4*dx/8 ) Break;
- if( num_cross(x0+dx/2,x1,i ,y1,box1->p,cs) != 1
- && num_cross(x0+dx/2,x1,i+1,y1,box1->p,cs) != 1 ) Break;
- if( num_hole(x0,x1,y0,i+1,box1->p,cs,NULL)!=1 ) Break;
- if( num_hole(x0,x1,i-1,y1,box1->p,cs,NULL)!=0 ) Break;
- if( loop(box1->p,x0,y1 ,dy,cs,0,RI)>dx/3 &&
- loop(box1->p,x0,y1-1,dy,cs,0,RI)>dx/3) Break; // no q
- for( x=0,i=y=y0+dy/3;y<=y1-dy/3;y++){ // suche kerbe
- j=loop(box1->p,x1,y,dx,cs,0,LE);
- if( j>x ) { x=j; i=y; }
- } if( x>dx/2 ) Break; // no g
- i1=loop(bp,dx-1,dy/8 ,dx,cs,0,LE); if(i1>dx/2) Break;
- i3=loop(bp,dx-1,dy-1-dy/8,dx,cs,0,LE);
- i2=loop(bp,dx-1,dy/2 ,dx,cs,0,LE); if(i1+i3<2*i2-dx/8) Break; // konvex
- i1=loop(bp,dx-1,dy/4 ,dx,cs,0,LE); if(i1>dx/2) Break;
- i3=loop(bp,dx-1,dy-1-dy/8,dx,cs,0,LE);
- for(y=dy/4;y<dy-1-dy/4;y++){
- i2=loop(bp,dx-1,y,dx,cs,0,LE);
- if(i1+i3-2*i2<-1-dx/16) break; // konvex from right ~g ~3
- } if(y<dy-1-dy/4) Break;
- x=loop(bp,dx -1,6*dy/8,dx,cs,0,LE); if(x>0){ x--; // robust
- y=loop(bp,dx-x-1, dy-1,dy,cs,0,UP);
- if(y<dy/8) Break; // ~q (serif!)
- }
- // %
- if( num_cross(x0,x1 ,y0+dy/4,y0+dy/4,box1->p,cs) > 2) ad=90*ad/100;
- if( num_cross(x0,x1+dx/4,y1-dy/4,y1-dy/4,box1->p,cs) > 2
- || num_cross(x0,x1+dx/4,y1-dy/8,y1-dy/8,box1->p,cs) > 2) ad=90*ad/100;
-
- if (box1->m4==0) ad=98*ad/100;
- if ( hchar) ad=96*ad/100;
- if (!gchar) ad=96*ad/100;
- if (ad>99) ad=99; // never be sure to have a 9
- Setac(box1,'g',ad);
- break;
- }
- return box1->c;
-}
-
-// rewritten for vector usage v0.41
-static wchar_t ocr0_xX(ocr0_shared_t *sdata){
- struct box *box1=sdata->box1;
- // pix *bp=sdata->bp; // obsolete
- int i,j,d,x,y,hchar=sdata->hchar,gchar=sdata->gchar,
- x0=box1->x0, x1=box1->x1, y0=box1->y0, y1=box1->y1; // ,cs=sdata->cs;
- int dx=x1-x0+1, dy=y1-y0+1, /* size */
- (*aa)[4]=sdata->aa, /* the for line ends, (x,y,dist^2,vector_idx) */
- ad; /* tmp-vars */
- wchar_t bc=UNKNOWN;
-
- // --- test xX ---------------------------------------------------
- // rewritten for vectors 0.41
- for(ad=d=100;dx>2 && dy>3;){ // min 3x4
- int ld, i1, i2, i3, i4; // lien derivation, 4 inner edges
- DBG( wchar_t c_ask='x'; )
- if (sdata->holes.num > 0) Break; /* # */
- /* half distance to the center */
- d=2*sq(128/4);
- /* now we check for the 4 ends of the x */
- if (aa[0][2]>d) Break;
- if (aa[1][2]>d) Break;
- if (aa[2][2]>d) Break;
- if (aa[3][2]>d) Break;
- if (aa[3][0]-aa[0][0]<dx/2) Break;
- if (aa[2][0]-aa[1][0]<dx/2) Break;
- if (aa[1][1]-aa[0][1]<dy/2) Break;
- if (aa[2][1]-aa[3][1]<dy/2) Break;
- /* searching for 4 notches between neighbouring ends */
-
- /* only left side */
- for (j=i=aa[0][3];i!=aa[1][3];i=(i+1)%box1->num_frame_vectors[0]) {
- if (box1->frame_vector[i][0]
- >=box1->frame_vector[j][0]) j=i; /* notice most right vector */
- } if (j==i) Break;
- /* calculate the distance to the center */
- x=box1->frame_vector[j][0];
- y=box1->frame_vector[j][1]; i1=j;
- if (abs(aa[0][0]+aa[1][0]+aa[2][0]+aa[3][0]-4*x)>(dx+2)) Break;
- if (abs(aa[0][1]+aa[1][1]+aa[2][1]+aa[3][1]-4*y)>(dy+2)) Break;
- if ( aa[0][0]+aa[1][0]-2*x>=0) Break;
- if ( aa[1][0] >= x ) Break;
- if ( aa[0][0] > x ) Break;
- if ( aa[0][0] >= x ) ad=99*ad/100;
- if (x-x0<dx/8) Break;
- if (x-x0<dx/4) ad=99*ad/100;
- /* check if upper left and center point are joined directly */
- ld=line_deviation(box1, aa[0][3], j);
- MSG(fprintf(stderr," 0-X %d %d dist= %d/%d",x-x0,y-y0,ld,2*sq(1024/4));)
- if (ld >2*sq(1024/4)) Break;
- /* check if lower left and center point are joined directly */
- ld=line_deviation(box1, j, aa[1][3]);
- MSG(fprintf(stderr," X-1 %d %d dist= %d/%d",x-x0,y-y0,ld,2*sq(1024/4));)
- if (ld >2*sq(1024/4)) Break;
-
- /* only lower side */
- for (j=i=aa[1][3];i!=aa[2][3];i=(i+1)%box1->num_frame_vectors[0]) {
- if (box1->frame_vector[i][1]
- <=box1->frame_vector[j][1]) j=i; /* notice most upper vector */
- } if (j==i) Break;
- /* calculate the distance to the center */
- x=box1->frame_vector[j][0];
- y=box1->frame_vector[j][1]; i2=j;
- if (abs(aa[0][0]+aa[1][0]+aa[2][0]+aa[3][0]-4*x)>(dx+2)) Break;
- if (abs(aa[0][1]+aa[1][1]+aa[2][1]+aa[3][1]-4*y)>(dy+2)) Break;
- if ( aa[1][1]+aa[2][1]-2*y<=0) Break;
- /* check if lower left and center point are joined directly */
- ld=line_deviation(box1, aa[1][3], j);
- MSG(fprintf(stderr," 1-X %d %d dist= %d/%d",x-x0,y-y0,ld,2*sq(1024/4));)
- if (ld >2*sq(1024/4)) Break;
- /* check if lower right and center point are joined directly */
- ld=line_deviation(box1, j, aa[2][3]);
- MSG(fprintf(stderr," X-2 %d %d dist= %d/%d",x-x0,y-y0,ld,2*sq(1024/4));)
- if (ld >2*sq(1024/4)) Break;
-
- /* only right side */
- for (j=i=aa[2][3];i!=aa[3][3];i=(i+1)%box1->num_frame_vectors[0]) {
- if (box1->frame_vector[i][0]
- <=box1->frame_vector[j][0]) j=i; /* notice most left vector */
- } if (j==i) Break;
- /* calculate the distance to the center */
- x=box1->frame_vector[j][0];
- y=box1->frame_vector[j][1]; i3=j;
- if (abs(aa[0][0]+aa[1][0]+aa[2][0]+aa[3][0]-4*x)>(dx+2)) Break;
- if (abs(aa[0][1]+aa[1][1]+aa[2][1]+aa[3][1]-4*y)>(dy+2)) Break;
- if ( aa[2][0]+aa[3][0]-2*x<=0) Break;
- if ( aa[3][0] <= x ) Break;
- if ( aa[2][0] < x ) Break;
- if ( aa[2][0] <= x ) ad=99*ad/100;
- if (dx-(x-x0)<dx/8) Break;
- if (dx-(x-x0)<dx/4) ad=99*ad/100;
- /* check if lower right and center point are joined directly */
- ld=line_deviation(box1, aa[2][3], j);
- MSG(fprintf(stderr," 2-X %d %d dist= %d/%d",x-x0,y-y0,ld,2*sq(1024/4));)
- if (ld >2*sq(1024/4)) Break;
- /* check if upper right and center point are joined directly */
- ld=line_deviation(box1, j, aa[3][3]);
- MSG(fprintf(stderr," X-3 %d %d dist= %d/%d",x-x0,y-y0,ld,2*sq(1024/4));)
- if (ld >2*sq(1024/4)) Break;
-
- /* only upper side */
- for (j=i=aa[3][3];i!=aa[0][3];i=(i+1)%box1->num_frame_vectors[0]) {
- if (box1->frame_vector[i][1]
- >=box1->frame_vector[j][1]) j=i; /* notice lowest vector */
- } if (j==i) Break;
- /* calculate the distance to the center */
- x=box1->frame_vector[j][0];
- y=box1->frame_vector[j][1]; i4=j;
- if (abs(aa[0][0]+aa[1][0]+aa[2][0]+aa[3][0]-4*x)>(dx+2)) Break;
- if (abs(aa[0][1]+aa[1][1]+aa[2][1]+aa[3][1]-4*y)>(dy+2)) Break;
- if ( aa[3][1]+aa[0][1]-2*y>=0) Break;
- /* check if upper left and center point are joined directly */
- ld=line_deviation(box1, aa[3][3], j);
- MSG(fprintf(stderr," 3-X %d %d dist= %d/%d",x-x0,y-y0,ld,2*sq(1024/4));)
- if (ld >2*sq(1024/4)) Break;
- /* check if lower left and center point are joined directly */
- ld=line_deviation(box1, j, aa[0][3]);
- MSG(fprintf(stderr," X-0 %d %d dist= %d/%d",x-x0,y-y0,ld,2*sq(1024/4));)
- if (ld >2*sq(1024/4)) Break;
-
- // center crossing of diagonal lines is small?
- if (box1->frame_vector[i3][0] - box1->frame_vector[i1][0] > dx/2) Break;
-
- if (gchar) ad=99*ad/100;
- bc='x'; if(hchar) bc='X';
- Setac(box1,bc,ad);
- break;
- }
- // --- test \it x ---------------------------------------------------
-#if 0
- for(ad=d=99;dx>4 && dy>4;){ // min 3x4
- DBG( wchar_t c_ask='x'; )
- if (sdata->holes.num > 1) Break; /* tolerant against a tiny hole */
- if( get_bw(x0,x0+dx/4,y0+dy/2,y0+dy/2,box1->p,cs,1) != 0 ) Break;
- if( get_bw(x1-dx/4,x1,y0+dy/2,y0+dy/2,box1->p,cs,1) != 0 ) Break;
- if( num_cross(x0+dx/4,x1-dx/4,y0+dy/2,y0+dy/2, box1->p,cs) != 1 ) Break;
- if( num_cross(x0,x1,y0+dy/4,y0+dy/4, box1->p,cs) != 3
- && num_cross(x0,x1,y0+dy/8,y0+dy/8, box1->p,cs) < 3 ) Break;
- if( num_cross(x0,x1,y1-dy/4,y1-dy/4, box1->p,cs) != 3
- && num_cross(x0,x1,y1-dy/8,y1-dy/8, box1->p,cs) < 3 ) Break;
- if( gchar ) ad=97*ad/100;
- if( hchar ) ad=96*ad/100;
- bc='x';
- Setac(box1,bc,ad);
- break;
- }
-#endif
- return box1->c;
-}
-
-static wchar_t ocr0_yY(ocr0_shared_t *sdata){
- struct box *box1=sdata->box1;
- pix *bp=sdata->bp;
- int i,j,d,x,y,hchar=sdata->hchar,gchar=sdata->gchar,
- x0=box1->x0,x1=box1->x1,y0=box1->y0,y1=box1->y1,cs=sdata->cs;
- int dx=x1-x0+1,dy=y1-y0+1, /* size */
- ad,xa,ya,xb,yb,xc,yc,xd,yd; /* tmp-vars */
- wchar_t bc=UNKNOWN;
-
- // --- test italic yY --------------------------------------------
- for(ad=d=100;dx>2 && dy>3;){ // min 3x4
- DBG( wchar_t c_ask='y'; )
- if (sdata->holes.num > 1) Break; /* tolerant against a tiny hole */
- if (sdata->holes.num > 0) ad=97*ad/100;
- if( num_cross(0,dx-1,dy/8,dy/8,bp,cs) < 2
- && num_cross(0,dx-1, 1, 1,bp,cs) < 2 ) Break;
- if( num_cross(0,dx-1,dy-1,dy-1,bp,cs) != 1
- && num_cross(0,dx-1,dy-2,dy-2,bp,cs) != 1 ) Break;
- if( num_cross(dx-1,dx-1,0,dy-1,bp,cs) != 1
- && num_cross(dx-2,dx-2,0,dy-1,bp,cs) != 1 ) Break;
- if( num_cross(dx/3,dx/3,dy/4,dy-1,bp,cs) != 2
- && num_cross(dx/2,dx/2,dy/4,dy-1,bp,cs) != 2 ) Break;
- for(yc=y=0,xc=x=dx/4;x<dx-dx/4;x++){ // search deepest point
- i=loop(bp,x,0,dy,cs,0,DO); if(i>y){ yc=y=i;xc=x; }
- } if( y>12*dy/16 || y<3*dy/8 ) Break;
- ya=dy/8; xa=xc-loop(bp,xc,ya,dx,cs,0,LE); if(xa< 0) Break;
- yb=dy/8; xb=xc+loop(bp,xc,yb,dx,cs,0,RI); if(xb>=dx) Break;
- for(y=dy/8;y<yc-dy/8;y++){
- if( num_cross(xc,dx-1,y,y,bp,cs) != 1 ) break;
- if( num_cross(0 ,xc ,y,y,bp,cs) < 1 ) break;
- } if(y<yc-dy/8) Break;
- yd=dy-1-dy/8;xd=dx-1-loop(bp,dx-1,yd,dx,cs,0,LE);
- g_debug(fprintf(stderr," debug_yY: \n"
- " /a b \n"
- " | | \n"
- " -c/ \n"
- " \e-d \n");)
- g_debug(fprintf(stderr,"a-e: %d %d %d %d %d %d %d %d",
- xa,ya,xb,yb,xc,yc,xd,yd);)
- if(xd>6*dx/8) ad=99*ad/100; // why this???
- if (loop(bp,dx-1,dy-1,dx,cs,0,LE)<1) Break;
- // printf(" abcd=%d %d %d %d %d %d %d %d -",xa,ya,xb,yb,xc,yc,xd,yd);
- if( get_line2(xb,yb,xd,yd,bp,cs,100)<95 ) Break;
- // if( get_line2(xc,yc,xd,yd,bp,cs,100)<95 ) Break;
- // printf("ok");
- bc='y';
- if(gchar && !hchar) bc='y'; else
- if(hchar && (!gchar || dy<14)) bc='Y'; else ad=98*ad/100; // SMALL-CAPS ???
- Setac(box1,bc,ad);
- break;
- }
- // --- test yY ---------------------------------------------------
- for(ad=d=100;dx>2 && dy>3;){ // min 3x4
- DBG( wchar_t c_ask='y'; )
- if (sdata->holes.num > 1) Break; /* tolerant against a tiny hole */
- if( get_bw(x0,x0,y1-dy/8,y1,box1->p,cs,1) == 1 ) {
- if( get_bw(x0,x0+4*dx/8,y0+dy/8,y0+dy/8,box1->p,cs,1) != 1 ) Break;
- } else {
- if( get_bw(x0,x0+3*dx/8,y0+dy/8,y0+dy/8,box1->p,cs,1) != 1 ) Break;
- }
- if( num_cross(0,dx-1,dy/8,dy/8,bp,cs) != 2
- && num_cross(0,dx-1, 1, 1,bp,cs) != 2 ) Break;
- if( num_cross(dx/2,dx/2,0, 1,bp,cs) != 0 ) Break;
- if( num_cross(0,dx-1,dy-1,dy-1,bp,cs) != 1
- && num_cross(0,dx-1,dy-2,dy-2,bp,cs) != 1 ) Break;
- if( num_cross(dx-1,dx-1,0,dy-1,bp,cs) != 1
- && num_cross(dx-2,dx-2,0,dy-1,bp,cs) != 1
- && num_cross(dx-dx/8-1,dx-dx/8-1,0,dy-1,bp,cs) != 1 ) Break;
- if( loop(bp,dx-1,dy-1-dy/8,dx,cs,0,LE)+dx/8+1 // Jul00
- < loop(bp, 0,dy-1-dy/8,dx,cs,0,RI) ) Break;
- for(y=0,x=dx/4;x<dx-dx/4;x++){ // search lowest point
- i=loop(bp,x,0,dy,cs,0,DO); if(i>y) y=i;
- } if( y>10*dy/16 || y<2*dy/8 ) Break;
- for(xc=xb=xa=dx,yc=yb=ya=y=0;y<dy/4;y++){
- x =loop(bp, 0 , y,dx,cs,0,RI); if(x<xa){ xa=x;ya=y; }
- x =loop(bp,dx-1 , y,dx,cs,0,LE); if(x<xb){ xb=x;yb=y; }
- }
- if(yb>dy/8) Break;
- for(i=dx,yc=y=dy/4;y<3*dy/4;y++){
- if( num_cross(0,dx-1,y,y,bp,cs) < 2 ) break;
- x =loop(bp,dx-1 ,y,dx,cs,0,LE);
- x+=loop(bp,dx-1-x,y,dx,cs,1,LE);
- j =loop(bp,dx-1-x,y,dx,cs,0,LE); if(j<=i){ i=j;yc=y;xc=dx-1-x-j/2; }
- } yc+=dy/16+1;
- yc+=loop(bp,xc,yc,i,cs,1,DO)/2;
- xa+= loop(bp,xa ,ya,dx,cs,1,RI)/2;
- xb=dx-1-loop(bp,dx-1,yb,dx,cs,1,LE)/2;
- yd=dy-1-dy/8;xd=dx-1-loop(bp,dx-1,yd,dx,cs,0,LE); if(xd>6*dx/8) Break;
- /* check for serife at lower end */
- for (i=0,x=dx-1;i<dy/4;i++) {
- j=loop(bp,dx-1,dy-1-i,dx,cs,0,LE);
- if (j>x+dx/16+1) break; /* detect serif */
- if (j<x) x=j;
- } if (i<dy/4) xd-=loop(bp,xd,yd,dx,cs,1,LE)/2;
- MSG( fprintf(stderr," debug_yY: \n"
- " a b \n"
- " \\ / \n"
- " c \n"
- " ed ");)
- MSG(fprintf(stderr,"a-e: %d %d %d %d %d %d %d %d",
- xa,ya,xb,yb,xc,yc,xd,yd);)
- // check upper left line
- if( get_line2(xa,ya,xc ,yc,bp,cs,100)<95
- && get_line2(xa,ya,xc-1,yc,bp,cs,100)<95 ) Break;
- // check upper right line
- if( get_line2(xb,yb,xc ,yc,bp,cs,100)<95
- && get_line2(xb,yb,xc-1,yc,bp,cs,100)<95 ) {
- // Times-Italic y ???
- xb+=loop(bp,xb,yb,dx/4,cs,1,RI)-1;
- yb+=loop(bp,xb,yb,dy/8,cs,1,DO)-1;
- if( get_line2(xb,yb,xc ,yc,bp,cs,100)<95 ) Break;
- }
- if( get_line2(xc,yc,xd,yd,bp,cs,100)<95 ) Break;
-
- // decission between V and Y is sometimes very difficult
- // hope that the following code is the ultimate solution
- if( yc>=5*dy/8 && !gchar)
- if( get_line2(xa,ya,xd ,yd,bp,cs,100)>95 )
- if( get_line2(xb,yb,xd ,yd,bp,cs,100)>95 )
- { if (dx>4) { Break; } else ad=ad*98/100; } // ~V
- xa=loop(bp,0,dy/8,dx,cs,0,RI);
- xb=loop(bp,0,dy/2,dx,cs,0,RI);
- xc=loop(bp,0,dy-1,dx,cs,0,RI);
- if( 2*xb< xa+xc ) ad=98*ad/100; // ~V
- if( 2*xb<=xa+xc ) ad=98*ad/100;
- if( 2*xb<=xa+xc+1 ) ad=98*ad/100;
-
- bc='y';
- if ((!gchar) && (!hchar)) ad=98*ad/100;
- if(y0<box1->m2-(box1->m2-box1->m1)/4)
- { bc='Y'; if(gchar) ad=98*ad/100; }
- // SMALL-CAPS ???
- Setac(box1,bc,ad);
- break;
- }
- return box1->c;
-}
-
-static wchar_t ocr0_zZ(ocr0_shared_t *sdata){
- struct box *box1=sdata->box1;
- int i1,i2,i3,i4,i5,dbg[9],
- d,x,y,hchar=sdata->hchar,gchar=sdata->gchar,
- x0=box1->x0,x1=box1->x1,y0=box1->y0,y1=box1->y1;
- int dx=x1-x0+1,dy=y1-y0+1, /* size */
- (*aa)[4]=sdata->aa, /* the for line ends, (x,y,dist^2,vector_idx) */
- ad; /* tmp-vars */
- wchar_t bc=UNKNOWN;
-
- // --- test zZ -------
- for(ad=d=100;dx>3 && dy>3;){ // dy>dx
- DBG( wchar_t c_ask='z'; ) /* for debugging purpose */
- if (sdata->holes.num > 1) Break; /* tolerant against a tiny hole */
- if (sdata->holes.num > 0) ad=98*ad/100; /* # */
- /* half distance to the center */
- d=2*sq(128/4);
- /* now we check for the 4 edges of the z */
- if (aa[0][2]>d) Break;
- if (aa[1][2]>d) Break;
- if (aa[2][2]>d) Break;
- if (aa[3][2]>d) Break;
- if (aa[3][0]-aa[0][0]<dx/2) Break;
- if (aa[2][0]-aa[1][0]<dx/2) Break;
- if (aa[1][1]-aa[0][1]<dy/2) Break;
- if (aa[2][1]-aa[3][1]<dy/2) Break;
- if (aa[3][0]-aa[0][0]<4-1) Break; /* to small to hold a z */
- if (aa[2][0]-aa[1][0]<4-1) Break; /* to small */
- if (aa[3][1]-y0>dy/8) ad=99*ad/100;
- if (aa[0][1]-y0>dy/8) ad=99*ad/100;
- if (2*dx<dy) ad=99*ad/100;
- MSG( \
- fprintf(stderr,"xy= %d %d aa %d %d %d %d %d %d %d %d", \
- x0,y0,aa[0][0]-x0,aa[0][1]-y0,aa[1][0]-x0,aa[1][1]-y0,\
- aa[2][0]-x0,aa[2][1]-y0,aa[3][0]-x0,aa[3][1]-y0);)
- /* upper and lower horizontal line */
- d=line_deviation(box1, aa[3][3], aa[0][3]); if (d>2*sq(1024/4)) Break;
- ad=(100-(d-sq(1024)/2)/sq(1024)/4)*ad/100;
- d=line_deviation(box1, aa[1][3], aa[2][3]); if (d>2*sq(1024/4)) Break;
-
- /* search uppermost right > */
- i1=nearest_frame_vector(box1,aa[0][3],aa[1][3], x1, y0);
- x=box1->frame_vector[i1][0];
- y=box1->frame_vector[i1][1];
- if (y-y0 > 5*dy/8) Break;
- if (x-x0 < 3*dx/8) Break;
- if (x-aa[0][0]<=dx/4) Break; // ~lI
- if (x-aa[0][0]<=dx/3) ad=98*ad/100; // ~lI
- if (x-aa[0][0]<=dx/2) ad=99*ad/100; // ~lI
- /* search most right > ~2 */
- i3=nearest_frame_vector(box1,aa[0][3],aa[1][3], x1+2*dx, (y0+y1)/2);
- MSG(fprintf(stderr,"xy= %d %d %d %d %d %d",x0,y0,x-x0,y-y0,box1->frame_vector[i3][0]-x0,box1->frame_vector[i3][1]-y0);)
- if ( box1->frame_vector[i3][1]-y0> dy/4
- && box1->frame_vector[i3][0]-x>=0) Break;
- if ( box1->frame_vector[i3][1]-y> dy/8
- && box1->frame_vector[i3][0]-x>=-dx/8) ad=98*ad/100;
- if ( box1->frame_vector[i3][1]-y> dy/8
- && box1->frame_vector[i3][0]-x>= 0) ad=97*ad/100;
- if (box1->frame_vector[i3][0]-aa[0][0]
- < aa[3][0]-box1->frame_vector[i3][0]) break; // ~lI
- if (box1->frame_vector[i3][0]-aa[0][0]
- <(aa[3][0]-box1->frame_vector[i3][0])*2) ad=98*ad/100; // ~lI
- /* better test for a bow or peaked angle */
- /* upper part of a 2, on a Z a and b should be at c
- .....$@@@@@@a...c. o1 (o1-a)=(dx+5)^2 =dx^2+10*dx+25
- ...$$@@@@@@@@@.... (o1-b)=(dx+1)^2+4^2=dx^2+ 2*dx+18
- ..$@@$@@@$@@@@@...
- ..@@@.....$$@@@@..
- ..@@.......@$@@@b.
- ..$.........$@@@@.
- .$$..........$@@@.
- .$...........@@@@.
- .............@@@@.<
- .............$@@$.
- ............$@@@..
- ............@@$...
- ............$@$...
- --- snip ----
- */
- i4=nearest_frame_vector(box1,aa[2][3],aa[0][3], x1+dx, y0);
- i5=nearest_frame_vector(box1,aa[2][3],aa[0][3], x1, y0-dx);
- d=sq(box1->frame_vector[i5][0]-box1->frame_vector[i4][0])
- +sq(box1->frame_vector[i5][1]-box1->frame_vector[i4][1]);
- if (d>2*sq(dx/8+1)) break;
-
- /* check if upper left and upper right point are joined directly */
- dbg[0]=d=line_deviation(box1, aa[0][3], i1); if (d >2*sq(1024/4)) Break;
- /* check if lower right and upper left point are joined directly */
- dbg[1]=d=line_deviation(box1, i1, aa[1][3]); if (d >2*sq(1024/4)) Break;
-
- /* search lowest left < */
- i2=nearest_frame_vector(box1,aa[2][3],aa[3][3], x0, y1);
- x=box1->frame_vector[i2][0];
- y=box1->frame_vector[i2][1];
- if (y-y0 < 3*dy/8) Break;
- if (x-x0 > 5*dx/8) Break;
- if (aa[2][0]-x<=dx/4) Break; // ~lI
- if (aa[2][0]-x<=dx/3) ad=98*ad/100; // ~lI
- if (aa[2][0]-x<=dx/2) ad=99*ad/100; // ~lI
- /* check if upper right and lower left point are joined directly */
- dbg[2]=d=line_deviation(box1,i2, aa[3][3]); if (d >2*sq(1024/4)) Break;
- /* check if lower left and lower right point are joined directly */
- dbg[3]=d=line_deviation(box1, aa[2][3],i2); if (d >2*sq(1024/4)) Break;
-
- if (box1->frame_vector[i1][0]
- -box1->frame_vector[i2][0]<=dx/8) Break; /* nonsignificant distance */
- MSG( \
- fprintf(stderr,"^v %d %d %d %d line deviation %d %d %d %d max %d %d",\
- box1->frame_vector[i1][0]-x0,box1->frame_vector[i1][1]-y0,\
- box1->frame_vector[i2][0]-x0,box1->frame_vector[i2][1]-y0,\
- dbg[0],dbg[1],dbg[2],dbg[3],2*sq(1024/4),2*sq(1024));)
- ad=(100-(dbg[0]-sq(1024)/2)/sq(1024)/4)*ad/100;
- ad=(100-(dbg[1]-sq(1024)/2)/sq(1024)/4)*ad/100;
- ad=(100-(dbg[2]-sq(1024)/2)/sq(1024)/4)*ad/100;
- ad=(100-(dbg[3]-sq(1024)/2)/sq(1024)/4)*ad/100;
-
- if ( gchar) ad=98*ad/100;
- bc='z';
- if( hchar ) bc='Z';
- Setac(box1,bc,ad);
- break;
- }
- return box1->c;
-}
-
-static wchar_t ocr0_wW(ocr0_shared_t *sdata){
- struct box *box1=sdata->box1;
- pix *bp=sdata->bp;
- int i,j,d,x,y,hchar=sdata->hchar,gchar=sdata->gchar,handwritten=0,
- x0=box1->x0,x1=box1->x1,y0=box1->y0,y1=box1->y1,cs=sdata->cs;
- int dx=x1-x0+1,dy=y1-y0+1, /* size */
- ad,ya,yb,xa,xb,xc,xd,xe,t1; /* tmp-vars */
- wchar_t ac;
-
- // ------- test w ~{\it w} ---------------
- for(ad=d=100;dx>3 && dy>3;){ // dy<=dx
- DBG( wchar_t c_ask='w'; )
- if (sdata->holes.num > 1) Break; /* tolerant against a tiny hole */
- // xa xe
- // \ xc / <=ya connected xa-xb-xc-xd-xe
- // xb xd <=yb
- // get two lowest points i3,i4,ya
- // out_x(box1);
- // ~ul ~uf
- // out_x(box1);
- for(y=dy/8;y< dy/2;y++) if( num_cross(0,dx-1,y,y,bp,cs)< 2 ) break;
- if(y<dy/2) Break;
- yb=dy-1;
- if (dx>4) { /* 4x6 is to small */
- for(y=dy-1-dy/16;y>3*dy/4;y--)
- if( num_cross(0,dx-1,y,y,bp,cs)==2 ) break;
- if(y==3*dy/4) Break;
- }
- yb=y;
- t1=loop(bp,0 ,dy/4,dx,cs,0,RI);
- t1=loop(bp,t1,dy/4,dx,cs,1,RI); // thickness of line?
- for(i=j=0 ;y> dy/4;y--) if( num_cross(0,dx-1,y,y,bp,cs)==4 ) i++;
- else if( num_cross(0,dx-1,y,y,bp,cs)>=3 ) j++;
- if(i+5<dy/4 && 7*t1<dy) Break; // only for large letters
- if(i+j==0 && (dy>6 || dx>4)) Break;
- if(i+j==0 && dx<=4){
- if (abs(loop(bp, 1,dy-1,dy,cs,0,UP)
- -loop(bp,dx-2,dy-1,dy,cs,0,UP))>dy/8+1) Break; // 4x6 N
- if ( ( loop(bp, 1, 0,dy,cs,0,DO)>=dy-2
- && loop(bp, 0,dy-1,dy,cs,0,UP)>0)
- || ( loop(bp,dx-2, 0,dy,cs,0,DO)>=dy-2
- && loop(bp,dx-1,dy-1,dy,cs,0,UP)>0)) Break; // 4x6 UV
- ad=ad*99/100; // 4x6 font
- MSG(fprintf(stderr,"ad=%d",ad);)
- }
- if( num_cross(0,dx-1, 1, 1,bp,cs)< 2
- && num_cross(0,dx-1,dy/16,dy/16,bp,cs)< 2 ) Break;
- x =loop(bp,0 ,yb,dx,cs,0,RI);
- xb=loop(bp,x ,yb,dx,cs,1,RI);xb=x+xb/2; if(xb>dx/2) Break;
- x =loop(bp,dx-1 ,yb,dx,cs,0,LE);
- xd=loop(bp,dx-1-x,yb,dx,cs,1,LE);xd=dx-1-x-xd/2;if(xd<3*dx/8) Break;
- for(y=0,xc=x=xb+1;x<xd;x++)
- if((i=loop(bp,x,dy-1,dy,cs,0,UP))>y){xc=x;y=i;}
- if(dx>4 && !y) Break;
- ya=dy-1-y; // flat
- y=loop(bp,xc,ya,dy,cs,1,UP);if(y)y--;
- if (dy>6 || dx>4) { // ~4x6 font
- if( num_cross(0 ,xc ,ya-y ,ya-y ,bp,cs)!= 2
- && num_cross(0 ,xc ,ya-y/2,ya-y/2,bp,cs)!= 2 ) Break;
- if( num_cross(xc,dx-1,ya-y ,ya-y ,bp,cs)!= 2
- && num_cross(xc,dx-1,ya-y/2,ya-y/2,bp,cs)!= 2 ) Break;
- }
- ya-=y/2;
- x =loop(bp,0 ,1 ,dx,cs,0,RI);
- xa=loop(bp,x ,1 ,dx,cs,1,RI);
- if( x+xa>xb ){ // may be, here is a small but thick letter
- // later add some proofs
- xa=x+xa/4;
- } else {
- xa=x+xa/2;
- }
- x =loop(bp,dx-1 ,1 ,dx,cs,0,LE);
- xe=loop(bp,dx-1-x,1 ,dx,cs,1,LE);xe=dx-1-x-xe/2;
- MSG( fprintf(stderr,"a-e: %d %d %d %d %d %d %d %d %d %d",
- xa,1,xb,yb,xc,ya,xd,yb,xe,1);)
- if (ya<dy/2 && xc<dx/2) ad=95*ad/100; /* ~N */
- i= loop(bp,xa ,1 ,dx,cs,1,RI);
- for (x=xa;x<xa+i;x++)
- if( get_line2(x,1,xb,yb,bp,cs,100)>94 ) break;
- if (x==xa+i) Break; // no vert. line found
- if( get_line2(xb,yb-1,xc,ya ,bp,cs,100)<95
- && get_line2(xb,yb-1,xc,ya+dy/32,bp,cs,100)<95
- && get_line2(xb,yb-1,xc,ya+dy/16,bp,cs,100)<95 ) Break;
- if( get_line2(xc, ya,xd, yb,bp,cs,100)<95
- && get_line2(xc+1,ya,xd, yb,bp,cs,100)<95 ) Break;
- if( get_line2(xd,yb,xe ,1+dy/16,bp,cs,100)<95
- && get_line2(xd,yb,dx-1 ,1+dy/8 ,bp,cs,100)<95 // round w
- && get_line2(xd,yb,xe+dx/20,1+dy/16,bp,cs,100)<95 ) Break;
- // if( num_hole(0,dx-1,0,dy-1,bp,cs,NULL) != 0 ) Break;
- // ~ur
- MSG(fprintf(stderr,"ad=%d",ad);)
- for(i=0,y=5*dy/8;y<dy;y++){
- x=loop(bp,dx-1,y,dx,cs,0,LE); if( x>i ) i=x; if( x<i-2 ) break;
- if (x<i) ad=98*ad/100;
- } if( y<dy ) Break;
- MSG(fprintf(stderr,"ad=%d",ad);)
- ac=((hchar)?'W':'w');
- if (gchar) ad=98*ad/100;
- Setac(box1,ac,ad);
- break;
- }
- // --- test ~w {\it w} ohmega? also handwritten -------
- // italic
- for(ad=d=100;dx>3 && dy>3;){ // dy<=dx 4x6font (like a H with fat bar)
- DBG( wchar_t c_ask='w'; )
- if (sdata->holes.num > 1) Break; /* tolerant against a tiny hole */
- // ~ul ~uf
- if( num_cross(0,dx-1,dy/2,dy/2,bp,cs)<2 ) Break;
- if( num_cross(0,dx-1,dy/8,dy/8,bp,cs)<2 ) handwritten=40;
- if( num_cross(0,dx-1,dy/4,dy/4,bp,cs)<2 ) handwritten=80;
- for(i=0,y=0;y<dy-1;y++)
- if( num_cross(0,dx-1,y,y,bp,cs)==3 ) i++;
- if(i<=dy/8) Break; // three legs
- // xa xe
- // \ xc / <=yb connected xa-xb-xc-xd-xe
- // xb xd
- for(y=dy/2;y<dy-1-dy/8;y++)
- if( num_cross(0,dx-1,y,y,bp,cs)==3 ) break;
- yb=y;
- x =loop(bp,0 ,yb,dx,cs,0,RI);
- x+=loop(bp,x ,yb,dx,cs,1,RI); if(x>dx/2) Break;
- xb=loop(bp,x ,yb,dx,cs,0,RI);xb=x+xb/2; if(xb>dx/2) Break;
- x =loop(bp,dx-1 ,yb,dx,cs,0,LE);
- x+=loop(bp,dx-1-x,yb,dx,cs,1,LE);
- xd=loop(bp,dx-1-x,yb,dx,cs,0,LE);xd=dx-1-x-xd/2;if(xd<3*dx/8) Break;
- if( num_cross(xb,xd,yb,yb ,bp,cs)!= 1 ) Break;
- if( num_cross(xb,xb,yb,dy-1,bp,cs)!= 1 ) Break;
- if( num_cross(xd,xd,yb,dy-1,bp,cs)!= 1 ) Break;
- if( num_cross(xb,xb, 0,yb ,bp,cs)!= 0 ) Break;
- if( num_cross(xd,xd, 0,yb ,bp,cs)!= 0 ) Break;
- // if( num_hole(0,dx-1,0,dy-1,bp,cs,NULL) != 0 ) Break;
- if (sdata->holes.num != 0) Break;
- // ~ur
- for(i=0,y=3*dy/4;y<dy;y++){
- x=loop(bp,dx-1,y,dx,cs,0,LE); if( x>i ) i=x; if( x<i-2 ) break;
- } if( y<dy ) Break; // fail for overlapping neighbouring slanted chars?
- ac=((hchar)?'W':'w');
- if (gchar) ad=98*ad/100;
- Setac(box1,ac,ad);
- Break;
- }
- return box1->c;
-}
-
-static wchar_t ocr0_aA(ocr0_shared_t *sdata){
- struct box *box1=sdata->box1;
- pix *bp=sdata->bp;
- int i,d,x,y,i1,i2,i3,i4,hchar=sdata->hchar,gchar=sdata->gchar,
- x0=box1->x0,x1=box1->x1,y0=box1->y0,y1=box1->y1,cs=sdata->cs;
- int dx=x1-x0+1,dy=y1-y0+1, /* size */
- ad,ya; /* tmp-vars */
-
- // --- test A ---------------------------------------------------
- for(ad=d=100;dx>2 && dy>3;){ // min 3x4
- DBG( wchar_t c_ask='A'; )
- if (sdata->holes.num > 2) Break; /* tolerant against a tiny hole */
- // first selection (rough sieve)
- if( get_bw(dx/2 ,dx/2 ,dy-1-dy/8,dy-1,bp,cs,1) == 1
- && get_bw(dx/2-1,dx/2-1,dy-1-dy/8,dy-1,bp,cs,1) == 1 ) Break; // ~B
- ya=0; /* upper end, not 0 for modified A etc. */
- if (box1->modifier)
- for (ya=0;ya<dy/2;ya++)
- if (num_cross(0,dx-1,ya,ya,bp,cs)==0) break;
- if (ya>=dy/2) ya=0; // already subtracted?
- if( num_cross(0,dx-1,ya+ 1 ,ya+ 1 ,bp,cs)!=1 // 600dpi
- && num_cross(0,dx-1,ya+ dy/8 ,ya+ dy/8 ,bp,cs)!=1
- && num_cross(0,dx-1,ya+ dy/16 ,ya+ dy/16 ,bp,cs)!=1
- && num_cross(0,dx-1,ya+ dy/8+1,ya+ dy/8+1,bp,cs)!=1 ) Break;
- if( num_cross(0,dx-1, 7*dy/8 , 7*dy/8 ,bp,cs)!=2
- && num_cross(0,dx-1, 7*dy/8-1, 7*dy/8-1,bp,cs)!=2 ) Break;
- if ( num_cross( 0,dx/8,ya+dy/8,ya+0,bp,cs)>0 ) Break; // ~R
- for(y=ya+dy/8;y<ya+dy/2;y++) if( num_cross(0,dx-1,y,y,bp,cs) > 1 ) break;
- if( y==ya+dy/2 ) Break; i1=y;
- if (dy>20) i1++; /* get arround some noise fat font */
-
- x =loop(bp,0,i1,dx,cs,0,RI); if(x>3*dx/4) Break;
- x+=loop(bp,x,i1,dx,cs,1,RI); if(x>3*dx/4) Break; i2=x;
- x+=loop(bp,x,i1,dx,cs,0,RI); if(x<3*dx/8) Break; i2=(x+i2)/2;
- // hole (i2,i1)
- y+=loop(bp,i2,y,dy,cs,1,DO);
- y+=loop(bp,i2,y,dy,cs,0,DO); if(y>3*dy/4) ad=ad*99/100;
- if (y>5*dy/6) { MSG(fprintf(stderr,"x,y,i1,i2= %d %d %d %d",x,y,i1,i2);) }
- if (y>5*dy/6) Break;
-
- if( sdata->holes.num != ((box1->modifier==RING_ABOVE)?2:1)
- || sdata->holes.hole[0].y1-ya >= dy-1-dy/4) Break;
- // if( num_hole ( x0, x1, y0, y1-dy/4 ,box1->p,cs,NULL) != 1 ) Break;
- // out_x(box1);
- i3=0;i4=0;
- for(x=dx/3;x<2*dx/3;x++){
- i4=num_cross(i2,x,y ,dy-1,bp,cs);if(i4<1 || i4>2)
- i4=num_cross(i2,x,y+dy/16,dy-1,bp,cs);if(i4<1 || i4>2) break;
- if(i4==1) i3=x;
- } if(i4<1 || i4>2 || i3==0){
-// ToDo: MSG(fprintf(stderr,"x,y,i4,i3= %d %d %d %d",x,y,i4,i3);)
- Break;
- }
- if( get_bw(dx-1-dx/4, dx-1, dy-1-dy/4, dy-1, bp,cs,1) != 1 ) Break;
-
- i1=loop(bp,dx-1,ya+ (dy-ya)/4,dx,cs,0,LE);
- i2=loop(bp,dx-1,ya+ (dy-ya)/2,dx,cs,0,LE);
- i3=loop(bp,dx-1,dy-1-(dy-ya)/4,dx,cs,0,LE);
- if( 2*i2-dx/8>i1+i3 ) ad=99*ad/100; /* 6*8 font */
- if( 2*i2+dx/4<i1+i3 || 2*i2-dx/4>i1+i3 ) Break;
-
- i1=loop(bp,0 ,ya+ (dy-ya)/4,dx,cs,0,RI); // linke senkr. linie
- i2=loop(bp,0 ,ya+ (dy-ya)/2,dx,cs,0,RI);
- i3=loop(bp,0 ,dy-1-(dy-ya)/4,dx,cs,0,RI);
- if( 2*i2-dx/8>i1+i3 ) ad=98*ad/100; /* 6*8 font */
- if( 2*i2+dx/4<i1+i3 || 2*i2-dx/4>i1+i3 || i1<i3) Break;
-
- // lower ends could be round on thick fonts
- for(i3=dx,y=ya+(dy-ya)/4;y<7*dy/8;y++){ // increasing width
- i1=loop(bp, 0, y,dx,cs,0,RI);
- i2=loop(bp,dx-1, y,dx,cs,0,LE);
- if(i1+i2>i3+dx/16) break; if( i1+12<i3 ) i3=i1+i2;
- } if(y<7*dy/8) Break;
- if ( loop(bp, 0,dy-1-dy/8,dx,cs,0,RI)
- -loop(bp, 0,dy/2 ,dx,cs,0,RI)>0) ad=97*ad/100; // italic-a
-
- if (!hchar) ad=99*ad/100; // italic-a
- Setac(box1,'A',ad);
- break;
- }
- // --- test a -------------------------------------------
- // with a open bow above the circle starting
- // on the right side of the circle
- for(ad=d=100;dx>2 && dy>3;){ // min 3x4
- DBG( wchar_t c_ask='a'; )
- if (sdata->holes.num > 2) Break; /* tolerant against a tiny hole */
- if( get_bw(x0 , x0+dx/2, y1-dy/3, y1-dy/3,box1->p,cs,1) != 1 ) Break;
- if( get_bw(x1-dx/3, x1 , y0+dy/3, y0+dy/3,box1->p,cs,1) != 1 ) Break;
- if( get_bw(x1-dx/3, x1 , y0+dy/4, y0+dy/4,box1->p,cs,1) != 1 ) Break;
- if( get_bw(x0+dx/2, x0+dx/2, y1-dy/3, y1, box1->p,cs,1) != 1 ) Break;
- if( get_bw(x0+dx/2, x0+dx/2, y0 , y0+dy/3,box1->p,cs,1) != 1 ) Break;
- if( get_bw(x0+dx/3, x1-dx/3, y0 , y0 ,box1->p,cs,1) != 1 ) Break;
- if( get_bw(x0+dx/4, x1-dx/2, y1 , y1 ,box1->p,cs,1) != 1 )
- if( get_bw(x0+dx/4, x1-dx/3, y1-1 , y1-1 ,box1->p,cs,1) != 1 ) Break;
- if( get_bw(x0 , x0 , y0+dy/2, y1 ,box1->p,cs,1) != 1 )
- if( get_bw(x0+dx/8, x0+dx/8, y0+dy/2, y1 ,box1->p,cs,1) != 1 ) Break;
- if( loop(bp,3*dx/8,0,dy,cs,0,DO) > 3*dy/16 ) Break; // ~d
- if( num_cross(0,dx-1,dy/4 ,dy/4 , bp,cs) >2 // ~glued am != an
- && num_cross(0,dx-1,dy/4+1,dy/4+1, bp,cs) >2 ) Break;
-
- for( x=dx/4;x<dx-dx/4;x++ ){ // ar
- i=loop(bp,x, 0,y1-y0,cs,0,DO); if (i>dy/2) break;
- i=loop(bp,x,dy-1,y1-y0,cs,0,UP); if (i>dy/2) break;
- } if( x<dx-dx/4 ) Break;
-
- for(i=dx/8+1,x=dx/4;x<=dx-1-dx/4 && i;x++){
- if( num_cross(x,x,0,bp->y-1, bp,cs) == 3 ) i--;
- } if( i ) Break;
-
- i1=loop(bp,0, dy/8,dx,cs,0,RI);
- i3=loop(bp,0,3*dy/4,dx,cs,0,RI);
- for(y=dy/8+1;y<3*dy/4;y++){
- i2=loop(bp,0,y,dx,cs,0,RI);if(2*i2>i1+i3+1) break;
- } if(y==3*dy/4) Break; // ~6
- // ~ s (small thick s), look for vertikal line piece
- for(x=3*dx/4;x<dx;x++)
- if( loop(bp,x,dy/4,dy/2,cs,1,DO)>dy/4 ) break;
- if( x==dx ) Break;
-
- if (sdata->holes.num != 1) ad=96*ad/100; else
- if (sdata->holes.num == 1)
- if( num_hole ( x0, x1, y0+dy/3, y1 ,box1->p,cs,NULL) != 1 ) Break;
- // if( num_hole ( x0, x1, y0, y1, box1->p,cs,NULL) != 1 ) Break;
- if( num_hole ( x0, x1, y0, y1-dy/3 ,box1->p,cs,NULL) != 0 ){
- i =loop(bp,0,dy/4,dx,cs,0,RI);
- i =loop(bp,i,dy/4,dx,cs,1,RI);
- if(i<dx/4+1) Break; // fat a
- i =loop(bp,0,dy/4,dx,cs,0,RI);
- i+=loop(bp,i,dy/4,dx,cs,1,RI);
- for(y=dy/4;y<dy/2;y++)
- if( num_cross(0,dx-1,y,y, bp,cs) !=2 ) break;
- x =loop(bp,0,y-1,dx,cs,0,RI);
- x+=loop(bp,x,y-1,dx,cs,1,RI);
- if(x>i) Break; // ~ 8
- }
- /* test for horizontal symmetry ~8 */
- for (y=0;y<dy;y++) for (x=0;x<dx/2;x++)
- if ((getpixel(bp,x,y)<cs)!=(getpixel(bp,dx-1-x,y)<cs)) { y=dy+1; break; }
- if (y==dy) Break; /* ~8 */
-
- if (hchar) ad=96*ad/100;
- if (gchar) ad=96*ad/100;
- Setac(box1,'a',ad);
- break;
- }
- // --- test hand written a ---------------------------------------------------
- // rarely char, without bow above the circle
- for(ad=d=100;dx>3 && dy>3;){ // min 4x4
- DBG( wchar_t c_ask='a'; )
- if (sdata->holes.num > 2) Break; /* tolerant against a tiny hole */
- if( get_bw(x0 , x0+dx/2,y0+dy/2 , y0+dy/2,box1->p,cs,1) != 1 ) Break;
- if( get_bw(x1-dx/2 , x1 ,y0+dy/2 , y0+dy/2,box1->p,cs,1) != 1 ) Break;
- if( get_bw(x0+dx/2 , x0+dx/2,y1-dy/2 , y1, box1->p,cs,1) != 1 ) Break;
- if( get_bw(x0+dx/2 , x0+dx/2,y0 , y0+dy/2,box1->p,cs,1) != 1 ) Break;
- if( get_bw(x0+dx/3 , x0+dx/3,y0 , y0+dy/2,box1->p,cs,1) != 1 ) Break;
- i = loop(bp,dx/2, 0 ,dy,cs,0,DO); if (i>dy/4) Break;
- i+= loop(bp,dx/2, i ,dy,cs,1,DO); if (i>dy/2) Break;
- i = loop(bp,dx/2, i ,dy,cs,0,DO); if (i<dy/4) Break;
- if( get_bw(x0 , x0 ,y1 , y1 ,box1->p,cs,1) == 1 ) Break;
-
- if( num_cross(x0+dx/2,x0+dx/2,y0 , y1 ,box1->p,cs) != 2 ) Break;
- if( num_cross(x0+dx/3,x1-dx/3,y0 , y0 ,box1->p,cs) != 1 ) // AND
- if( num_cross(x0+dx/3,x1-dx/3,y0+1 , y0+1 ,box1->p,cs) != 1 ) Break;
- i = loop(bp,dx/2,dy-1 ,dy,cs,0,UP); if (i>dy/3) Break;
- y = i+loop(bp,dx/2,dy-1-i,dy,cs,1,UP); if (i>dy/2) Break;
- // normal 'a' has a well separated vertical line right from the circle
- // but fat 'a' is like a 'o', only bigger on the right side
- if( num_cross(x0+dx/2-1,x1,y1 ,y1 ,box1->p,cs) < 2 /* 4x6font */
- && num_cross(x0+dx/2-1,x1,y1-i,y1-i ,box1->p,cs) < 2 /* 2 or 3 */
- && num_cross(x0+dx/2-1,x1,y1-y,y1-y ,box1->p,cs) < 2 )
- { if (loop(bp, 0,dy-1-dy/16,dx,cs,0,RI)
- <4*loop(bp,dx-1,dy-1-dy/16,dx,cs,0,LE)) { Break;}
- else ad=98*ad/100;
- }
- if( num_cross(x0,x1,y0+dy/2 , y0+dy/2,box1->p,cs) < 2
- || num_cross(x0,x1,y0+dy/3 , y0+dy/3,box1->p,cs) < 2 ) Break; // Jun00
-
- if( num_cross(x0 ,x0 ,y0+dy/3 , y1-dy/4,box1->p,cs) != 1 )
- if( num_cross(x0+1 ,x0+1 ,y0+dy/3 , y1-dy/4,box1->p,cs) != 1 ) Break;
- if (sdata->holes.num != 1)
- if( num_hole(x0,x1-2,y0 ,y1 ,box1->p,cs,NULL) != 1 )
- // if( num_hole(x0,x1 ,y0 ,y1 ,box1->p,cs,NULL) != 1 )
- Break;
- if( num_hole(x0,x1 ,y0+dy/3,y1-1 ,box1->p,cs,NULL) != 0 ) Break;
-
- if( loop(bp,0 ,0 ,x1-x0,cs,0,RI)<=
- loop(bp,0 ,2 ,x1-x0,cs,0,RI) ) Break;
-
- if( loop(bp,dx-1,dy-1,x1-x0,cs,0,LE)> dx/4
- && loop(bp,dx-1,dy-2,x1-x0,cs,0,LE)> (dx+4)/8 ) ad=97*ad/100;
-
- x=loop(bp,dx-1,dy-1-dy/4,dx,cs,0,LE);
- i=loop(bp,dx-1, dy/4,dx,cs,0,LE); if (abs(x-i)>dx/4) Break;
-
- for( x=dx/4;x<dx-dx/4;x++ ){ // ar
- i=loop(bp,x, 0,y1-y0,cs,0,DO); if (i>dy/2) break;
- i=loop(bp,x,dy-1,y1-y0,cs,0,UP); if (i>dy/2) break;
- } if( x<dx-dx/4 ) Break;
-
- if( num_cross(x0 , x1, y1, y1,box1->p,cs) == 1 )
- if( num_cross(x0 , x1, y0, y0,box1->p,cs) == 1 )
- if( loop(bp,dx-1, 0,y1-y0,cs,0,DO)> dy/4
- && loop(bp,dx-1,dy-1,y1-y0,cs,0,UP)> dy/4 ) Break; // ~o
- if( loop(bp,dx/2,dy-1,y1-y0,cs,0,UP)> dy/4 ) Break; // ~q
-
- if (hchar) ad=98*ad/100;
- if (gchar) ad=98*ad/100;
- // handwritten-a (alpha)
- Setac(box1,'a',ad);
- break;
- }
- // --- test A_A_WITH_OGONEK 0x0104 Centr.Eur.Font -------------------------
- /* not sure if we should move this to a get_CentralEuropean-function */
- for(ad=d=100;dx>2 && dy>4;){ // min 3x4
- DBG( wchar_t c_ask='A'; )
- if (sdata->holes.num > 2) break; /* tolerant against a tiny hole */
- // first selection (grobes Sieb)
- if( get_bw(dx/2,dx/2,dy-1-dy/8,dy-1,bp,cs,1) == 1 ) break; // ~B
- if( num_cross(0,dx-1, 1 , 1 ,bp,cs)!=1 // 600dpi
- && num_cross(0,dx-1, dy/8 , dy/8 ,bp,cs)!=1
- && num_cross(0,dx-1, dy/16 , dy/16 ,bp,cs)!=1
- && num_cross(0,dx-1, dy/8+1, dy/8+1,bp,cs)!=1 ) break;
- if( num_cross(0,dx-1, dy-1 , dy-1 ,bp,cs)!=1 ) break;
- if( num_cross(0,dx-1, dy/4 , dy/4 ,bp,cs)!=2
- && num_cross(0,dx-1, dy/3 , dy/3 ,bp,cs)!=2 ) break;
- if ( num_cross( 0,dx/8,dy/8, 0,bp,cs)>0 ) break; // ~R
- for(y=dy/8;y<dy/2;y++) if( num_cross(0,dx-1,y,y,bp,cs) > 1 ) break;
- if( y==dy/2 ) break; i1=y;
- if (dy>20) i1++; /* get arround some noise fat font */
-
- x =loop(bp,0,i1,dx,cs,0,RI); if(x>3*dx/4) break;
- x+=loop(bp,x,i1,dx,cs,1,RI); if(x>3*dx/4) break; i2=x;
- x+=loop(bp,x,i1,dx,cs,0,RI); if(x<3*dx/8) break; i2=(x+i2)/2;
- // hole (i2,i1)
- y+=loop(bp,i2,y,dy,cs,1,DO);
- y+=loop(bp,i2,y,dy,cs,0,DO); if(y>3*dy/4) ad=ad*99/100;
- if (y>5*dy/6) break;
-
- if( sdata->holes.num != 1 || sdata->holes.hole[0].y1 >= dy-1-dy/4) break;
- // if( num_hole ( x0, x1, y0, y1-dy/4 ,box1->p,cs,NULL) != 1 ) break;
- // out_x(box1);
- i3=0;i4=0;
- for(x=dx/3;x<2*dx/3;x++){
- i4=num_cross(i2,x,y ,dy-1,bp,cs);if(i4<1 || i4>2)
- i4=num_cross(i2,x,y+dy/16,dy-1,bp,cs);if(i4<1 || i4>2) break;
- if(i4==1) i3=x;
- } if(i4<1 || i4>2 || i3==0){
-// ToDo: g_debug_A(printf(" A: x,y,i4,i3= %d %d %d %d\n",x,y,i4,i3);)
- break;
- }
- if( get_bw(dx-1-dx/4, dx-1, dy-1-dy/4, dy-1, bp,cs,1) != 1 ) break;
- /* dy/4 changed to dy/6 because of screenfonts */
- /* there are strange fonts, one has a serif on the upper end of A */
- if ( num_cross( 0,dx/8,dy/6, 0,bp,cs)>0 ) break;
- if ( num_cross(dx-1-dx/4,dx-1, 0,dy/6,bp,cs)>0 ) break;
-
- i1=loop(bp,dx-1, dy/4,dx,cs,0,LE);
- i2=loop(bp,dx-1, dy/2,dx,cs,0,LE);
- i3=loop(bp,dx-1,dy-1-dy/4,dx,cs,0,LE);
- if( 2*i2+dx/4<i1+i3 || 2*i2-dx/8>i1+i3 ) break;
-
- i1=loop(bp,0 , dy/4,dx,cs,0,RI); // linke senkr. linie
- i2=loop(bp,0 , dy/2,dx,cs,0,RI);
- i3=loop(bp,0 ,dy-1-dy/4,dx,cs,0,RI);
- if( 2*i2+dx/4<i1+i3 || 2*i2-dx/8>i1+i3 || i1<i3) break;
-
- // lower ends could be round on thick fonts
- for(i3=dx,y=dy/4;y<6*dy/8;y++){ // increasing width
- i1=loop(bp, 0, y,dx,cs,0,RI);
- i2=loop(bp,dx-1, y,dx,cs,0,LE);
- if(i1+i2>i3+dx/16) break; if( i1+12<i3 ) i3=i1+i2;
- } if(y<6*dy/8) break;
-
- if (!hchar) ad=96*ad/100;
- if (!gchar) ad=98*ad/100;
- Setac(box1,(wchar_t)LATIN_CAPITAL_LETTER_A_WITH_OGONEK,ad);
- break;
- }
- return box1->c;
-}
-
-static wchar_t ocr0_cC(ocr0_shared_t *sdata){
- struct box *box1=sdata->box1;
- pix *bp=sdata->bp;
- int i,j,d,x,y,i1,i2,i3,i4,i5,hchar=sdata->hchar,gchar=sdata->gchar,
- x0=box1->x0,x1=box1->x1,y0=box1->y0,y1=box1->y1,cs=sdata->cs;
- int dx=x1-x0+1,dy=y1-y0+1, /* size */
- ad,t1; /* tmp-vars */
- wchar_t bc=UNKNOWN;
-
- // --- test c,C ---------------------------------------------------
- for(ad=d=100;dx>2 && dy>2;){ // min 3x4
- DBG( wchar_t c_ask='c'; )
- if (sdata->holes.num > 1) Break; /* tolerant against a tiny hole */
- if( get_bw(x0 , x0+dx/3,y0+dy/2, y0+dy/2,box1->p,cs,1) != 1 ) Break;
- if( get_bw(x0+dx/2, x0+dx/2,y1-dy/3, y1, box1->p,cs,1) != 1 ) Break;
- if( get_bw(x0+dx/2, x0+dx/2,y0 , y0+dy/3,box1->p,cs,1) != 1 ) Break;
- if( num_cross(x0,(x0+x1)/2,(y0+y1)/2,(y0+y1)/2,box1->p,cs) > 1 ) Break; // ~ocr-a-[
-
- for(y=y0+dy/4;y<y0+3*dy/4;y++)
- if( get_bw(x0+dx/2,x1,y,y,box1->p,cs,1) == 0 ) break;
- if( y==y0+3*dy/4 ) Break; i1=y; // i1: upper end of right gap
-
- // measure thickness of line!
- t1=loop(bp, 0,dy/2,dx,cs,0,RI);
- t1=loop(bp,t1,dy/2,dx,cs,1,RI);
- if (t1>dx/2) Break;
-
- for(y=i1,i2=0,x=x0+dx/2;x<x0+6*dx/8;x++){
- i=y-1+loop(box1->p,x0+dx/2,i1,dy,cs,0,DO);
- if( i>i2 ) { i2=i; }
- } if(i2<y0+5*dy/8-t1/2) Break; // i2: lowest white point above lower bow
-
- i3=y+1-loop(box1->p,x0+5*dx/8,i1,dy,cs,0,UP);
- i =y+1-loop(box1->p,x0+4*dx/8,i1,dy,cs,0,UP); if(i<i3) i3=i;
- if(i3>y0+ dy/4+t1/2) Break; // highest
-
- for(y=i1;y<y1-dy/8;y++)
- if( get_bw(x0+dx/2,x1,y,y,box1->p,cs,1) == 1 ) break;
- if( y-i1<dy/6 ) Break; i2=y-1; // lower end of right gap
- // pixelbased num_cross for streight lines could fail on small fonts
- if( num_cross(x1-dx/4,x1-dx/4,i2,y0,box1->p,cs) < 1 ) Break; // ~L
- if (loop(box1->p,x0,y0+3*dy/4,dx,cs,0,RI)>dx/16)
- if( num_cross(x0+dx/2,x1,i3 ,y1,box1->p,cs) < 1
- && num_cross(x0+dx/2,x1,y1-dy/4,y1,box1->p,cs) < 1 ) Break; // ~r
-
- i=1;
- for(x=dx/2;x<dx-1 && i;x++) // look for @@ (instead +1 use +delta?)
- for(y=dy/2;y<dy-1-dy/8 && i;y++){ // .@
- if( getpixel(bp,x ,y )>=cs
- && getpixel(bp,x+1,y )< cs
- && getpixel(bp,x+1,y-1)< cs
- && getpixel(bp,x ,y-1)< cs ) { i=0;break; }
- }
- if(!i) ad=95*ad/100; // ~G
-
- i=loop(bp,0,dy/2,dx,cs,0,RI);
- for(y=0;y<dy;y++)if( loop(bp,0,y,dx,cs,0,RI)<i-1-dx/32 ) break;
- if( y<dy ) Break; // ~r
- // out_x(box1);
- for(i5=0,i4=dx,y=dy/2;y>=dy/4;y--){
- x =loop(bp,0,y,dx,cs,0,RI);
- x+=loop(bp,x,y,dx,cs,1,RI); if(x>i5) i5=x;
- i =loop(bp,x,y,dx,cs,0,RI); if(i<i4) i4=i;
- if( i5<x-dx/32 && i>i4+dx/32 ) break; // unusual for c, more a bad e?
- } if( y>=dy/4 ) Break;
-
- if( !hchar ){ // test for e where the middle line is partly removed
- x= loop(bp,0,dy/2,dx,cs,0,RI);
- x=x +loop(bp,x,dy/2,dx,cs,1,RI);
- y=dy/2-loop(bp,x,dy/2,dy,cs,0,UP)-1;
- i=x +loop(bp,x,y,dx,cs,1,RI);
- i=i +loop(bp,i,y,dx,cs,0,RI);
- if( num_cross(x ,x ,1,dy/2,bp,cs) > 1
- || num_cross(x+1,x+1,1,dy/2,bp,cs) > 1 )
- if( num_cross(i-1,i-1,1,dy/2,bp,cs) > 1
- || num_cross(i ,i ,1,dy/2,bp,cs) > 1 ) Break; // ~bad e
- }
- if( dy>16 && dy>3*dx && hchar ){ // ~[
- x= loop(bp,0, dy/16,dx,cs,0,RI);
- x=+loop(bp,0,dy-1-dy/16,dx,cs,0,RI);
- i= loop(bp,0, dy/2 ,dx,cs,0,RI)*2;
- if( i>=x )
- if( num_cross(0,dx-1,dy/4,dy/4,bp,cs) < 2 ) Break;
-
- }
- if( get_bw(x0,x0,y0 ,y1 ,box1->p,cs,2) != 2
- && get_bw(x0,x1,y0 ,y0 ,box1->p,cs,2) != 2
- && get_bw(x0,x1,y1 ,y1 ,box1->p,cs,2) != 2
- && get_bw(x1,x1,y0+1,y1-1,box1->p,cs,1) != 1 ) Break; /* ~[ */
-
- x =loop(bp, 0,dy/2,dx,cs,0,RI);
- i =loop(bp,dx-1,dy/2,dx,cs,0,LE);
- if( (i<dx/2 || i<3) && hchar && dy>7 )
- if( loop(bp, 0,7*dy/8,dx,cs,0,RI) > x+dx/8
- && loop(bp, 0, dy/8,dx,cs,0,RI) > x+dx/8
- && loop(bp,dx-1,dy-1-dy/ 8,dx,cs,0,LE)
- > loop(bp,dx-1,dy-1-dy/16,dx,cs,0,LE)
- && loop(bp,dx-1, dy/ 8,dx,cs,0,LE)
- > loop(bp,dx-1, dy/16,dx,cs,0,LE) ) Break; // ~(
-
-// printf(" hchar=%d i1=%d i2=%d %d\n",hchar,i1-y0,i2-y0,9*dy/16);
- // ~G without characteristic crotchet
- if (hchar && dy>15 && dx>7 && i2-y0<9*dy/16 && i1-y0<=dy/4)
- if ( loop(bp,5*dx/8,i2-y0,dy,cs,0,DO) > 2*dy/8 ){
- Setac(box1,'G',90);
- Break;
- }
-
- if (hchar){
- i=1;
- for(x=dx/2;x<dx-1 && i;x++) // look for @@ (instead +1 use +delta?)
- for(y= 1;y<dy/4 && i;y++){ // .@
- if( getpixel(bp,x ,y )>=cs
- && getpixel(bp,x+1,y )< cs
- && getpixel(bp,x+1,y-1)< cs
- && getpixel(bp,x ,y-1)< cs ) { i=0;break; }
- }
- if (i) ad=98*ad/100; // ~(
- if (dy>2*dx) ad=99*ad/100;
- }
- if( loop(bp,dx-1,dy/2,dx,cs,0,LE) < 6*dx/8 ) ad=98*ad/100;
-
- i= loop(bp,dx-1,dy/16,dx,cs,0,LE);
- j= loop(bp,dx/2,0 ,dy,cs,0,DO);
- if (i>=dx/2 && j>dy/8 && j>2 && j<dy/2) Break; // t
-
- if (dy>=3*dx && dy>12) ad=99*ad/100; // (
- i= loop(bp,dx-1,dy-1,dy,cs,0,UP);
- j= loop(bp,dx/2,dy-1,dy,cs,0,UP);
- if (i==0 && j>dy/8) ad=95*ad/100; // <
- i= loop(bp,dx-1, 0,dy,cs,0,DO);
- j= loop(bp,dx/2, 0,dy,cs,0,DO);
- if (i==0 && j>dy/8) ad=95*ad/100; // <
- if (loop(bp,0,dy-1-dy/8,dx,cs,0,RI)>= 3*dx/4) ad=98*ad/100; // <
- if (loop(bp,0,dy-1-dy/8,dx,cs,0,RI)>=(dx+1)/2) ad=98*ad/100; // <
- if (loop(bp,0, dy/8,dx,cs,0,RI)>=dx/2) ad=98*ad/100; // <
-
- if (gchar) ad=98*ad/100; // could happen for 5x7 font
- bc=((hchar)?'C':'c');
- Setac(box1,bc,ad);
- break;
- }
- return box1->c;
-}
-
-static wchar_t ocr0_lL(ocr0_shared_t *sdata){
- struct box *box1=sdata->box1;
- pix *bp=sdata->bp;
- int i,j,d,x,y,i0,i1,i2,i3,i4,hchar=sdata->hchar,gchar=sdata->gchar,
- x0=box1->x0,x1=box1->x1,y0=box1->y0,y1=box1->y1,cs=sdata->cs;
- int dx=x1-x0+1,dy=y1-y0+1, /* size */
- ad; /* tmp-vars */
-
- // --- test L ---------------------------------------------------
- for(ad=d=100;dx>2 && dy>4;){ // min 3x4
- DBG( wchar_t c_ask='L'; )
- if (sdata->holes.num > 1) Break; /* tolerant against a tiny hole */
- i=loop(bp,dx-1,dy/2,dx,cs,0,LE);
- if (i<3 && dy>8) {Break;}
- if (i<dx/2) ad=98*ad/100; // ~G
-
- if (dx<8 && 3*loop(bp,dx-1,0,dy,cs,0,DO)<=dy) break; // ~G
- for( i=i1=0,y=y1-dy/4;y<=y1;y++){ // check bottom line (i1)
- j=loop(box1->p,x0 ,y,dx,cs,0,RI);
- j=loop(box1->p,x0+j,y,dx,cs,1,RI); if( j>i ){ i=j;i1=y; }
- } if( i<3*dx/4 ) Break; i1=i; // length of horizontal line
- // line thickness (i2)
- i=loop(box1->p,x0 ,y0+dy/2,dx,cs,0,RI); if( i>dx/2 ) Break;
- j=loop(box1->p,x0+i,y0+dy/2,dx,cs,1,RI); if( i+j>dx/2 ) Break; i2=j;
- if (loop(bp,dx-1, 0,dx,cs,0,LE)<dx/8
- && loop(bp,dx-1, dy/4,dx,cs,0,LE)>dx/2
- && loop(bp, 0,5*dy/8,dx,cs,0,RI)<dx/4
- && loop(bp,dx-1,3*dy/4,dx,cs,0,LE)<dx/4) Break; // ~G
- for( i=1,y=y0;y<=y1-dy/4 && i;y++){ // check vertical line
- j=loop(box1->p,x0 ,y,dx,cs,0,RI);
- if ( j>(dx+2)/4+(y1-dy/4-y)*dx/2/dy ) { i=0; break; }
- x=loop(box1->p,x0+j,y,dx,cs,1,RI);
- if( ((x>i2+1 || 4*x<3*i2) && y>y0+dy/8) || 4*x>3*i1 ) i=0;
- } if( !i ) Break;
- if( num_cross(0, dx-1-dx/8, dy-1-dy/2, dy-1-dy/2,bp,cs) != 1 ) Break;
- if( num_cross(0, dx-1 , dy/3 , dy/3,bp,cs) != 1 ) Break;
- if( num_cross(0, dx-1 , dy/8 , dy/8,bp,cs) != 1 ) Break;
- if (loop(bp,0,dy-1,dx,cs,0,RI)
- -loop(bp,0,dy-3,dx,cs,0,RI)>1+dx/16) ad=96*ad/100; // ~c
- if (loop(box1->p,x0+dx/4,y1,dy,cs,0,UP)>1+dy/16) ad=99*ad/100; // ~4
-
- if ( gchar) ad=98*ad/100;
- if (!hchar) ad=99*ad/100;
- if (5*dx<2*dy && loop(box1->p,x0,y1,dx,cs,0,RI)>dx/4) ad=99*ad/100; // ~l
- Setac(box1,'L',ad);
- break;
- }
- // --- test l ---------------------------------------------------
- // recognize a "l" is a never ending problem, because there are lots of
- // variants and the char is not very unique (under construction)
- // --- test italic l ---------------------------------------------------
- // --- test l ~italic (set flag-italic) --------------------------------
- // if unsure d should be multiplied by 80..90%
- for(ad=d=100; dy>dx && dy>5;){ // min 3x4
- DBG( wchar_t c_ask='l'; )
- if( box1->dots>0 ) Break;
- if( num_cross(0, dx-1,dy/2,dy/2,bp,cs) != 1
- || num_cross(0, dx-1,dy/4,dy/4,bp,cs) != 1 ) Break;
- // mesure thickness
- for(i1=0,i2=dx,y=dy/4;y<dy-dy/4;y++){
- j = loop(bp,0,y,dx,cs,0,RI);
- j = loop(bp,j,y,dx,cs,1,RI);
- if( j>i1 ) { i1=j; } // thickest
- if( j<i2 ) { i2=j; } // thinnest
- }
- if ( i1>2*i2 ) Break;
- if(box1->m3 && dy<=box1->m3-box1->m2) ad=94*ad/100;
- if( box1->m2-box1->m1>1 && y0>=box1->m2 ) ad=94*ad/100;
- for(i0=0,i3=0,y=0;y<dy/4;y++){
- j = loop(bp,0,y,dx,cs,0,RI);
- if( j>i3 ) { i3=j; } // widest space
- j = loop(bp,j,y,dx,cs,1,RI);
- if( j>i0 ) { i0=j;i3=0; } // thickest
- }
- if ( i0>4*i2 || 3*i3>2*dx)
- if ( loop(bp,dx-1,dy-1,dx,cs,0,LE)>3*dx/8
- || loop(bp, 0,dy-1,dx,cs,0,RI)>3*dx/8) Break; // ~7
-
- // detect serifs
- x =loop(bp,0, 0,dx,cs,0,RI);
- i3=loop(bp,x, 0,dx,cs,0,RI);
- x =loop(bp,0, 1,dx,cs,0,RI);
- x =loop(bp,x, 1,dx,cs,0,RI); if(x>i3) i3=x;
- x =loop(bp,0,dy-1,dx,cs,0,RI);
- i4=loop(bp,x,dy-1,dx,cs,0,RI);
- x =loop(bp,0,dy-2,dx,cs,0,RI);
- x =loop(bp,x,dy-2,dx,cs,0,RI); if(x>i4) i4=x;
- if( i3>i1+dx/8+1 && i4>i1+dx/8+1 ) Break; // ~I
-
- for(i=dx,j=0,y=1;y<dy/4;y++){
- x=loop(bp,dx-1,y,dx,cs,0,LE); if(x>i+1) break; i=x;
- if( num_cross(0,dx-1,y ,y ,bp,cs)==2
- && num_cross(0,dx-1,y+1+dy/32,y+1+dy/32,bp,cs)==2 ) j=1;
- } if ( y<dy/4 ) Break;
- if(j){ // if loop at the upper end, look also on bottom
- for(y=3*dy/4;y<dy;y++){
- if( num_cross(0,dx-1,y ,y ,bp,cs)==2
- && num_cross(0,dx-1,y-1-dy/32,y-1-dy/32,bp,cs)==2 ) break;
- } if ( y==dy ) Break;
- }
-
- // if( get_bw(x0,x1,y0,y1,p,cs,2) == 0 ) Break; // unsure !I|
-
- if(dx>3)
- if( get_bw(dx-1-dx/8,dx-1,0,dy/6,bp,cs,1) != 1 )
- if( get_bw(dx-1-dx/8,dx-1,0,dy/2,bp,cs,1) == 1 ) Break;
-
- if( get_bw(dx-1-dx/8,dx-1,dy/4,dy/3,bp,cs,1) != 1 ) // large I ???
- if( get_bw(0 ,dx/8,dy/4,dy/3,bp,cs,1) != 1 )
- if( get_bw(dx-1-dx/8,dx-1,0 ,dy/8,bp,cs,1) == 1 )
- if( get_bw(0 ,dx/8,0 ,dy/8,bp,cs,1) == 1 ) ad=ad*97/100;
- if( get_bw(dx-1-dx/8,dx-1,dy/2,dy-1,bp,cs,1) != 1 ) // r ???
- if( get_bw(0 ,dx/8,dy/2,dy-1,bp,cs,1) == 1 )
- if( get_bw(dx-1-dx/8,dx-1,0 ,dy/3,bp,cs,1) == 1 )
- if( get_bw(0 ,dx/8,0 ,dy/3,bp,cs,1) == 1 ) Break;
-
- for( y=1;y<12*dy/16;y++ )
- if( num_cross(0, dx-1, y , y ,bp,cs) != 1 // sure ?
- && num_cross(0, dx-1, y-1, y-1,bp,cs) != 1 ) break;
- if( y<12*dy/16 ) Break;
-
- if(dx>3){
- for( y=dy/2;y<dy-1;y++ )
- if( get_bw(dx/4,dx-1-dx/4,y,y,bp,cs,1) != 1 ) break;
- if( y<dy-1 ) Break;
- }
- // test ob rechte Kante gerade
- for(x=dx,y=bp->y-1-5*dy/16;y>=dy/5;y--){ // rechts abfallende Kante/Knick?
- i=loop(bp,bp->x-1,y,x1-x0,cs,0,LE);
- if( i-2-dx/16>=x ) break;
- if( i<x ) x=i;
- }
- if (y>=dy/5 ) Break;
-
- // test ob linke Kante gerade
- for(x=0,y=bp->y-1-dy/5;y>=dy/5;y--){ // rechts abfallende Kante/Knick?
- i=loop(bp,0,y,x1-x0,cs,0,RI);
- if( i+2+dx/16<x ) break;
- if( i>x ) x=i;
- }
- if (y>=dy/5 ) Break;
- if (box1->m4 && y1<box1->m4)
- if ( get_bw(x0,x1,y1+1,box1->m4+dy/8,box1->p,cs,1) == 1 )
- ad=ad*97/100; // unsure !l|
- i=loop(bp,dx-1,dy/16,dx,cs,0,LE);
- j=loop(bp,dx-1,dy/2 ,dx,cs,0,LE);
- if( i>3 && j>3 )
- if( get_bw(dx-1-i/2,dx-1-i/2,0,dy/2,bp,cs,1) == 1 ) Break; // ~t
-
- for(y=5*dy/8;y<dy;y++)
- if( num_cross(0,dx-1,y,y,bp,cs) == 2 ) break;
- if( y<dy ){
- i =loop(bp,0,y,dx,cs,0,RI);
- i+=loop(bp,i,y,dx,cs,1,RI);
- i+=loop(bp,i,y,dx,cs,0,RI)/2; // middle of v-gap
- if( num_cross(0,i,5*dy/8,5*dy/8,bp,cs)==0
- && num_cross(i,i,5*dy/8, y,bp,cs)==0 ) Break; // ~J
- }
- if ( dx>8
- && loop(bp, 0,3*dy/4,dx,cs,0,RI)>=dx/4
- && loop(bp, 0,7*dy/8,dx,cs,0,RI)<=dx/8
- && loop(bp,dx-1,3*dy/4,dx,cs,0,LE)<=dx/8
- && loop(bp,dx-1,7*dy/8,dx,cs,0,LE)<=dx/8 ) Break; // ~J
-
- if ( 2*i3>5*i1 ) // hmm \tt l can look very similar to 7
- if ( loop(bp,0,dy/4,dx,cs,0,RI)>dx/2
- && get_bw(0,dx/8,0,dy/4,bp,cs,1) == 1 ) Break; // ~7
-
- if ( loop(bp,dx-1,dy/2,dx,cs,0,LE)>dx/2
- && get_bw(3*dx/4,dx-1,3*dy/4,dy-1,bp,cs,1) == 1) {
- if (loop(bp,0,dy-1,dx,cs,0,RI)<dx/8) ad=99*ad/100; // ~L
- if(5*dx>2*dy) ad=99*ad/100; // ~L
- if(5*dx>3*dy) ad=99*ad/100; // ~L
- }
- if(!hchar){ // right part (bow) of h is never a l
- if( get_bw(dx/4,dx/4, 0,dy/4,bp,cs,1) == 1
- && get_bw(dx/4,dx/4,dy/2,dy-1,bp,cs,1) == 0 ) Break;
- }
- if( dx>3 && dy>3*dx )
- if( loop(bp,dx/4,dy-1 ,dy,cs,0,UP)< dy/4
- && loop(bp, 0,dy-1-dy/8,dx,cs,0,RI)>=dx/2
- && loop(bp,dx-1,dy-1-dy/8,dx,cs,0,LE)<=dx/4 ){
- ad=98*ad/100; // ~]
- if ( loop(bp,dx-1,dy/2,dx,cs,0,LE)==0 ) Break;
- }
-
- for(x=0;x<dx/2;x++)
- if( get_bw( x, x, 0,dy/4 ,bp,cs,1) == 1 ) break;
- // works only for perpenticular char
- if( get_bw( x,x+dx/16, 0,dy/16,bp,cs,1) == 0
- && get_bw( x,x+dx/16,dy/4 ,dy/2 ,bp,cs,1) == 0
- && get_bw( x,x+dx/16,dy/16,dy/4 ,bp,cs,1) == 1 ){
- for(i=dx,y=0;y<dy/4;y++){
- x=loop(bp,0,y,dx,cs,0,RI);
- if( x>i ) break;
- }
- if( x>=loop(bp,0,y+1,dx,cs,0,RI) )
- if( loop(bp,0 ,0,dy,cs,0,DO)>1 )
- if( loop(bp,0 ,0,dy,cs,0,DO)
- - loop(bp,dx/16+1,0,dy,cs,0,DO) < dx/16+1 ) Break; // ~1 Jul00,Nov00
- if( num_cross(0,dx/2,y-1,y-1,bp,cs)==2 ) Break; // ~1
- }
- if(dx<8 && dy<12){ // screen font
- i= loop(bp,0,0,dy,cs,0,DO);
- if( loop(bp,dx/2,1,dy,cs,1,DO)>=dy-2
- && loop(bp,0,dy/2,dx,cs,0,RI)>=2
- && i>1 && i<dy/2 ) Break; // ~1
- }
- if( get_bw(x1,x1,y0 ,y1 ,box1->p,cs,2) != 2
- && get_bw(x0,x1,y0 ,y0 ,box1->p,cs,2) != 2
- && get_bw(x0,x1,y1 ,y1 ,box1->p,cs,2) != 2
- && get_bw(x0,x0+dx/4,y0+1+dy/16,y1-1-dy/16,box1->p,cs,1) != 1 ) Break; /* ~] */
- i=loop(bp,dx-1,dy/2,dx,cs,0,LE);
- if( loop(bp, 0,dy/2,dx,cs,0,RI)>=dx/2
- && (i<dx/2 || i==0) ) ad=98*ad/100; // ~]
- if( get_bw(x0,x0,y0 ,y1 ,box1->p,cs,2) != 2
- && get_bw(x0,x1,y0 ,y0 ,box1->p,cs,2) != 2
- && get_bw(x0,x1,y1 ,y1 ,box1->p,cs,2) != 2
- && get_bw(x1-dx/4,x1,y0+1+dy/16,y1-1-dy/16,box1->p,cs,1) != 1 ) Break; /* ~[ */
-
- x =loop(bp, 0,dy/2,dx,cs,0,RI); // konvex/konkav? ~()
- i =loop(bp,dx-1,dy/2,dx,cs,0,LE);
- if( loop(bp, 0,7*dy/8,dx,cs,0,RI) > x+dx/8
- && loop(bp, 0, dy/8,dx,cs,0,RI) > x+dx/8
- && loop(bp,dx-1,7*dy/8,dx,cs,0,LE) < i-dx/8
- && loop(bp,dx-1, dy/8,dx,cs,0,LE) < i-dx/8 ) Break; // ~(
- if( loop(bp, 0,7*dy/8,dx,cs,0,RI) < x-dx/8
- && loop(bp, 0, dy/8,dx,cs,0,RI) < x-dx/8
- && loop(bp,dx-1,7*dy/8,dx,cs,0,LE) > i+dx/8
- && loop(bp,dx-1, dy/8,dx,cs,0,LE) > i+dx/8 ) Break; // ~)
-
- i= loop(bp, 0, 0,dy,cs,0,DO); // horizontal line?
- if(dy>=12 && i>dy/8 && i<dy/2){
- if( loop(bp,dx-1,3*dy/16,dx,cs,0,LE)-dx/8
- >loop(bp,dx-1, i,dx,cs,0,LE)
- || loop(bp,dx-1,3*dy/16,dx,cs,0,LE)-dx/8
- >loop(bp,dx-1, i+1,dx,cs,0,LE) )
- if( loop(bp,dx-1,8*dy/16,dx,cs,0,LE)-dx/8
- >loop(bp,dx-1, i,dx,cs,0,LE)
- || loop(bp,dx-1,8*dy/16,dx,cs,0,LE)-dx/8
- >loop(bp,dx-1, i+1,dx,cs,0,LE) )
- if( loop(bp, 0,3*dy/16,dx,cs,0,RI)-dx/8
- >loop(bp, 0, i,dx,cs,0,RI)
- || loop(bp, 0,3*dy/16,dx,cs,0,RI)-dx/8
- >loop(bp, 0, i+1,dx,cs,0,RI) )
- if( loop(bp, 0,8*dy/16,dx,cs,0,RI)-dx/8
- >loop(bp, 0, i,dx,cs,0,RI)
- || loop(bp, 0,8*dy/16,dx,cs,0,RI)-dx/8
- >loop(bp, 0, i+1,dx,cs,0,RI) ) Break; // ~t
- if( loop(bp, 0,i-1,dx,cs,0,RI)>1 && dx<6 ) Break; // ~t
- if( loop(bp, 0,8*dy/16,dx,cs,0,RI)>dx/8
- && loop(bp, 0, i,dx,cs,1,RI)>=dx-1
- && loop(bp,dx-1,8*dy/16,dx,cs,0,LE)>dx/8
- && loop(bp,dx-1, i-1,dx,cs,0,LE)>dx/8 ) Break; // ~t
- }
-// if( vertical_detected && dx>5 )
- if( loop(bp,0, 1,dx,cs,0,RI)>=dx/2
- && ( loop(bp,0,dy-2,dx,cs,0,RI)<=dx/8
- || loop(bp,0,dy-1,dx,cs,0,RI)<=dx/8 ) )
- if( ( loop(bp,dx-1, 0,dx,cs,0,LE)<=dx/8
- || loop(bp,dx-1, 1,dx,cs,0,LE)<=dx/8 )
- && loop(bp,dx-1,dy-2,dx,cs,0,LE)>=dx/2 ) ad=98*ad/100; // ~/
-
- if( get_bw(x0,x1,y0,y1,box1->p,cs,2) == 0 ) ad=99*ad/100;
-
- if (!hchar || loop(bp,0,dy/4,dx,cs,0,RI)>dx/2){ // ~z
- i=loop(bp,0,dy/16 ,dx,cs,0,RI);
- i=loop(bp,i,dy/16 ,dx,cs,1,RI); j=i;
- i=loop(bp,0,dy/16+1,dx,cs,0,RI);
- i=loop(bp,i,dy/16+1,dx,cs,1,RI); if (i>j) j=i;
- i=loop(bp,0,dy/16+2,dx,cs,0,RI);
- i=loop(bp,i,dy/16+2,dx,cs,1,RI); if (i>j) j=i;
- if (j*4>=dx*3) ad=98*ad/100; // ~z
- if (j*8>=dx*7) ad=96*ad/100; // ~z
- }
-
- if( get_bw(x0,x0,y1,y1,box1->p,cs,2) == 0 ) ad=99*ad/100;
- if( get_bw(x1,x1,y1,y1,box1->p,cs,2) == 0 ) ad=99*ad/100;
- if (ad==100) ad--; /* I have to fix that:
- .@@@@.<-
- @@..@@
- ....@@
- ....@@<
- ...@@.
- ..@@@.
- ..@@..
- .@@...
- @@....
- @@@@@@<-
- */
- if(!hchar) ad=ad*99/100;
- if( gchar) ad=ad*99/100;
- Setac(box1,'l',ad);
-// if( i<100 ) Break; ????
-// if( loop(bp,0, 1,dx,cs,0,RI)<=dx/8
-// && loop(bp,0,dy/2,dx,cs,0,RI)<=dx/8
-// && loop(bp,0,dy-2,dx,cs,0,RI)<=dx/8 ) vertical_detected=1;
- break;
- }
- return box1->c;
-}
-
-static wchar_t ocr0_oO(ocr0_shared_t *sdata){
- struct box *box1=sdata->box1;
- pix *bp=sdata->bp;
- int i,j,d,x,y,hchar=sdata->hchar,gchar=sdata->gchar,
- x0=box1->x0,x1=box1->x1,y0=box1->y0,y1=box1->y1,cs=sdata->cs;
- int dx=x1-x0+1,dy=y1-y0+1, /* size */
- ad; /* tmp-vars */
- wchar_t bc=UNKNOWN;
-
- // --- test o,O ---------------------------------------------------
- for(ad=d=100;dx>2 && dy>3;){ // min 3x4
- DBG( wchar_t c_ask='o'; )
- if (sdata->holes.num !=1 ) Break;
- if( get_bw(x0 , x0+dx/2,y0+dy/2 , y0+dy/2,box1->p,cs,1) != 1 ) Break;
- if( get_bw(x1-dx/2 , x1 ,y0+dy/2 , y0+dy/2,box1->p,cs,1) != 1 ) Break;
- if( get_bw(x0+dx/2 , x0+dx/2,y1-dy/2 , y1, box1->p,cs,1) != 1 ) Break;
- if( get_bw(x0+dx/2 , x0+dx/2,y0 , y0+dy/2,box1->p,cs,1) != 1 ) Break;
- if( get_bw(x0+dx/2 , x0+dx/2,y0+dy/2 , y1-dy/3,box1->p,cs,1) != 0 ) Break;
- if (sdata->holes.hole[0].y0 > dy/3
- || sdata->holes.hole[0].y1 < dy-1-dy/3) Break;
-
- if( num_cross(x0+dx/2 ,x0+dx/2 ,y0, y1 ,box1->p,cs) != 2
- && num_cross(x0+dx/2+1,x0+dx/2+1,y0, y1 ,box1->p,cs) != 2 ) Break;
- if( num_cross(x0+dx/3,x1-dx/4,y0 , y0 ,box1->p,cs) != 1 ) // AND
- if( num_cross(x0+dx/3,x1-dx/4,y0+1 , y0+1,box1->p,cs) != 1 ) Break;
- if( num_cross(x0+dx/4,x1-dx/3,y1 , y1 ,box1->p,cs) != 1 ) // against "rauschen"
- if( num_cross(x0+dx/4,x1-dx/3,y1-1 , y1-1,box1->p,cs) != 1 ) Break;
- if( num_cross(x0 ,x0 ,y0+dy/3 , y1-dy/3,box1->p,cs) != 1 )
- if( num_cross(x0+1 ,x0+1 ,y0+dy/3 , y1-dy/3,box1->p,cs) != 1 ) Break;
- if( num_cross(x1 ,x1 ,y0+dy/3 , y1-dy/3,box1->p,cs) != 1 )
- if( num_cross(x1-1 ,x1-1 ,y0+dy/3 , y1-dy/3,box1->p,cs) != 1 ) Break;
-
- if( loop(bp,0 ,0 ,x1-x0,cs,0,RI)<=
- loop(bp,0 ,2 ,x1-x0,cs,0,RI) ) Break;
-
- x=loop(bp,dx-1,dy-1-dy/3,x1-x0,cs,0,LE); // should be minimum
- for( y=dy-1-dy/3;y<dy;y++ ){
- i=loop(bp,dx-1,y,x1-x0,cs,0,LE);
- if( i<x ) break; x=i;
- }
- if( y<dy ) Break;
-
- // ~D
- if( loop(bp,0, dy/16,dx,cs,0,RI)
- + loop(bp,0,dy-1-dy/16,dx,cs,0,RI)
- <= 2*loop(bp,0, dy/2 ,dx,cs,0,RI)+dx/8 ) Break; // not konvex
- if( loop(bp,0 , 1+dy/16,dx,cs,0,RI) + dx/4
- <= loop(bp,dx-1, 1+dy/16,dx,cs,0,LE) ) Break; // Dec00
-
- if( loop(bp,dx-1, dy/16,dx,cs,0,LE)>dx/8 )
- if( loop(bp,0 , dy/16,dx,cs,0,RI)<dx/16 ) Break;
- if( loop(bp,dx-1,dy-1-dy/16,dx,cs,0,LE)>dx/8 )
- if( loop(bp,0 ,dy-1-dy/16,dx,cs,0,RI)<dx/16 ) Break;
- if( get_bw(x1-dx/32,x1,y0,y0+dy/32,box1->p,cs,1) == 0
- && get_bw(x1-dx/32,x1,y1-dy/32,y1,box1->p,cs,1) == 0
-// && ( get_bw(x0,x0+dx/32,y0,y0+dy/32,box1->p,cs,1) == 1
- && ( get_bw(0,dx/32,0,dy/32,bp,cs,1) == 1
- || get_bw(x0,x0+dx/32,y1-dy/32,y1,box1->p,cs,1) == 1 ) ) Break; // ~D
-
- // search lowest inner white point
- for(y=dy,j=x=0;x<dx;x++) {
- i =loop(bp,x,dy-1 ,y1-y0,cs,0,UP);
- i+=loop(bp,x,dy-1-i,y1-y0,cs,1,UP);
- if (i<=y) { y=i; j=x; }
- } i=y;
- // italic a
- for(y=dy-1-i;y<dy-1;y++)
- if( num_cross(j,dx-1,y,y,bp,cs) > 1 ) ad=99*ad/100; // ~a \it a
- for(y=0;y<dy-1-i;y++)
- if( num_cross(0,dx-1,y,y,bp,cs) > 2 ) ad=98*ad/100; // ~a \it a
- if (loop(bp,dx-1,dy-1,x1-x0,cs,0,LE)<dx/8) ad=98*ad/100; // \it a
- if (loop(bp,dx-1, 0,x1-x0,cs,0,LE)<dx/8) ad=98*ad/100; // \it a
- if (loop(bp,dx-1,dy-1-dy/8,x1-x0,cs,0,LE)+1+dx/16
- <loop(bp, 0,dy-1-dy/8,x1-x0,cs,0,RI))
- { ad=99*ad/100; MSG(fprintf(stderr,"ad=%d",ad);) } // \it a
- if (loop(bp,dx-1,dy-1,y1-y0,cs,0,UP)+1+(dy+3)/8
- <loop(bp, 0,dy-1,y1-y0,cs,0,UP))
- { ad=98*ad/100; MSG(fprintf(stderr,"ad=%d",ad);) } // \it a
-
- if (abs(loop(bp,dx/2, 0,dy,cs,0,DO)
- -loop(bp,dx/2,dy-1,dy,cs,0,UP))>dy/8
- || num_cross(0,dx-1, 0, 0,bp,cs) > 1
- || num_cross(0,dx-1,dy-1,dy-1,bp,cs) > 1
- ) ad=98*ad/100; // ~bq
-
- if( hchar && 2*y0<box1->m1+box1->m2 ) i=1; else i=0;
- if (gchar) ad=99*ad/100;
- bc='o';
- if( i ){ bc='O'; }
- if ( bc=='O' && ad>99) ad=99; /* we can never 100% sure, 0O */
- Setac(box1,bc,ad);
- if (bc=='O') Setac(box1,'0',ad);
- if (bc=='o') Setac(box1,'0',98*ad/100);
- break;
- }
- return box1->c;
-}
-
-static wchar_t ocr0_pP(ocr0_shared_t *sdata){
- struct box *box1=sdata->box1;
- pix *bp=sdata->bp;
- int i,j,d,x,y,i1,i2,i3,i4,hchar=sdata->hchar,gchar=sdata->gchar,
- x0=box1->x0,x1=box1->x1,y0=box1->y0,y1=box1->y1,cs=sdata->cs;
- int dx=x1-x0+1,dy=y1-y0+1, /* size */
- ad; /* tmp-vars */
- wchar_t bc=UNKNOWN;
-
- // --- test pP ---------------------------------------------------
- for(ad=d=100;dx>2 && dy>3;){ // min 3x4
- DBG( wchar_t c_ask='p'; )
- if (sdata->holes.num > 2) Break; /* tolerant against a tiny hole */
- if( get_bw(0 , dx/2,3*dy/4,3*dy/4,bp,cs,1) != 1 ) Break;
- if( get_bw(0 , dx/2, dy/2, dy/2,bp,cs,1) < 1 ) Break;
- if( get_bw(dx/4, dx-1, dy/4, dy/4,bp,cs,1) != 1 ) Break;
- i= loop(bp,dx-1,3*dy/4,dx,cs,0,LE); if (i<dx/4) Break;
- if( num_cross(x1-3*i/4,x1-3*i/4, y0, y1-3*dy/16,box1->p,cs) != 2 )
- if( num_cross(x0+dx/2 ,x0+dx/2 , y0, y1-3*dy/16,box1->p,cs) != 2 )
- if( num_cross(x0+dx/2+1,x0+dx/2+1, y0, y1-3*dy/16,box1->p,cs) != 2 ) Break;
- if( num_cross(0,dx-1,7*dy/8 ,7*dy/8 ,bp,cs) != 1 )
- if( num_cross(0,dx-1,7*dy/8-1,7*dy/8-1,bp,cs) != 1 ) Break;
- if( num_cross(0,dx-1, dy/4 , dy/4 ,bp,cs) != 2 )
- if( num_cross(0,dx-1, dy/4-1, dy/4-1,bp,cs) != 3 ) // \it p with nice kurve
- if( num_cross(0,dx-1, dy/4 , dy/4 ,bp,cs) != 2 )
- if( num_cross(0,dx-1, dy/4+1, dy/4+1,bp,cs) != 2 ) Break;
-
- i= loop(bp,0,dy/2,dx,cs,0,RI); if(i<1) i++;
- if( num_cross(i-1,dx-1, dy/4 , dy/4 ,bp,cs) != 2 )
- if( num_cross(i-1,dx-1, dy/4+1, dy/4+1,bp,cs) != 2 ) Break;
-
- i1= loop(bp, 0,3*dy/8,dx,cs,0,RI); if (i1>=dx/2) ad=90*ad/100;
- i2=i1+loop(bp,i1,3*dy/8,dx,cs,1,RI); // upper x-position of v line
- i3= loop(bp, 0,7*dy/8,dx,cs,0,RI);
- i4=i3+loop(bp,i3,7*dy/8,dx,cs,1,RI); // lower x-position of v line
- // out_x(box1);printf(" p:");
- for ( y=dy/8; y<7*dy/8; y++ ){
- x=i2+ (8*y-3*dy)*(i4-i2)/(4*dy); // right limit of line
- i= loop(bp,0,y,dx,cs,0,RI); if(i>x+dx/16) break;
- } if ( y<7*dy/8 ) Break;
- for ( x=0,j=y=dy/3; y<dy-dy/8; y++ ){ // suche unterkante (also 4x6)
- i=loop(bp,dx-1,y,dx,cs,0,LE);
- if ( i>x ) { x=i; j=y; } if(x>dx/2) break;
- } if ( x<dx/2 || x>=dx) Break;
- if( get_bw(3*dx/4,dx-1, y , dy-1,bp,cs,1) == 1 ) Break;
-
- i=num_hole (x0,x1,y0,y1-dy/5,box1->p,cs,NULL);
- // j=num_hole (x0,x1,y0,y1 ,box1->p,cs,NULL);
- j=sdata->holes.num;
-
- if (j!=1 && dx< 8) ad=96*ad/100;
- if (j!=1 && dx>=8) ad=98*ad/100;
- if (i==0 && j==0) ad=90*ad/100; /* some times there is a small gap */
- if (i>1 || j>1 || j>i) Break;
-
- // check for serif F
- i= loop(bp,bp->x-1, bp->y/4, dx ,cs,0,LE);
- i=i+loop(bp,bp->x-1-i,bp->y/4, dx ,cs,1,LE);
- j= loop(bp,bp->x-1-i,bp->y/4,3*dy/4,cs,0,DO);
- if (j>dy/2) ad=80*ad/100; // its an serif-F
-
- if( ((!hchar) && (!gchar)) || (hchar && gchar)) ad=95*ad/100;
- bc='p';
- if( hchar && ((!gchar) || dy<14)) bc='P';
- if ( hchar && gchar) ad=98*ad/100; // \ss sz
- if ((!hchar) && !gchar) ad=98*ad/100;
-
- Setac(box1,bc,ad);
- break;
- }
- return box1->c;
-}
-
-static wchar_t ocr0_qQ(ocr0_shared_t *sdata){
- struct box *box1=sdata->box1;
- pix *bp=sdata->bp;
- int i,j,d,x,y,hchar=sdata->hchar,gchar=sdata->gchar,
- x0=box1->x0,x1=box1->x1,y0=box1->y0,y1=box1->y1,cs=sdata->cs;
- int dx=x1-x0+1,dy=y1-y0+1, /* size */
- ad; /* tmp-vars */
-
- // --- test Q ---------------------------------------------------
- for(ad=d=100;dx>2 && dy>4;){ // min 3x4
- DBG( wchar_t c_ask='Q'; )
- if (sdata->holes.num > 2) Break; /* tolerant against a tiny hole */
- if( get_bw(x0 ,x0+dx/3,y0+dy/3,y0+dy/3,box1->p,cs,1) != 1 ) Break;
- if( get_bw(x1-dx/3,x1 ,y0+dy/3,y0+dy/3,box1->p,cs,1) != 1 ) Break;
- if( get_bw(x0+dx/2,x0+dx/2,y1-dy/3,y1, box1->p,cs,1) != 1 ) Break;
- if( get_bw(x0+dx/2,x0+dx/2,y0 ,y0+dy/4,box1->p,cs,1) != 1 ) Break;
- if( get_bw(x0+dx/2,x0+dx/2,y0+dy/3,y1-dy/2,box1->p,cs,1) == 1 ) Break;
- if( get_bw(x1 ,x1 ,y0 ,y0 ,box1->p,cs,1) == 1 ) Break; //alpha
- if( num_cross(x0+dx/2,x0+dx/2,y0 , y1 ,box1->p,cs) < 2 ) Break;
- if( num_cross(x0+dx/5,x1-dx/5,y0 , y0 ,box1->p,cs) != 1 ) // AND
- if( num_cross(x0+dx/5,x1-dx/5,y0+1 , y0+1 ,box1->p,cs) != 1 ) Break;
- if( num_cross(x0 ,x0 ,y0+dy/3 , y1-dy/3,box1->p,cs) != 1 )
- if( num_cross(x0+1 ,x0+1 ,y0+dy/3 , y1-dy/3,box1->p,cs) != 1 ) Break;
- if( get_bw(x1 ,x1 ,y1-dy/8 , y1 ,box1->p,cs,1) == 0 )
- if( num_cross(x1 ,x1 ,y0+dy/3 , y1-dy/3,box1->p,cs) != 1 )
- if( num_cross(x1-1 ,x1-1 ,y0+dy/3 , y1-dy/3,box1->p,cs) != 1 ) Break;
- // i=num_hole(x0,x1,y0,y1,box1->p,cs,NULL);
- i=sdata->holes.num;
- if(!i) Break;
- if( i!=1 && (i!=2 || num_hole(x0,x1,y0+dy/2,y1,box1->p,cs,NULL)!=1) ) Break;
- x=x1;y=y1;
- turmite(box1->p,&x,&y,x0,x1,y0,y1,cs,LE,ST); if( x<x1-dx/2 ) Break;
- turmite(box1->p,&x,&y,x0,x1,y0,y1,cs,ST,LE);
- if( x<x1-dx/2 ) { if (gchar) ad=98*ad/100; else ad=90*ad/100; }
- if( loop(bp,0 ,0 ,dx,cs,0,RI)
- < loop(bp,0 ,2 ,dx,cs,0,RI) ) Break;
- if( loop(bp,0 ,dy/8+2,dx,cs,0,RI)
- +loop(bp,dx-1,dy/8+2,dx,cs,0,LE) > 5*dx/8 ) Break; // ~4 Okt00
-
- x= loop(bp,dx-1,3*dy/8,dy,cs,0,LE); if( x>dx/4 ) Break;
- if( loop(bp,dx-1-x,0 ,dy,cs,0,DO)
- <= loop(bp,dx-2-x,0 ,dy,cs,0,DO) ) Break; // 4
-
- if( loop(bp,dx-1,dy-2,dx,cs,0,LE)
- <= loop(bp,dx-1,dy/2,dx,cs,0,LE) )
- if( loop(bp, 1,dy-1,dy,cs,0,UP)
- <= loop(bp,dx/2,dy-1,dy,cs,0,UP) )
- if( loop(bp, 0,dy-2,dx,cs,0,RI)>dx/2 )
- if( loop(bp, 0, 0,dx,cs,0,RI)>dx/2 ) Break; // 4
-
- if( loop(bp,dx-1,3*dy/4,dx,cs,0,LE)
- + loop(bp, 0,3*dy/4,dx,cs,0,RI)
- < loop(bp,dx-1,2*dy/4,dx,cs,0,LE)
- + loop(bp, 0,2*dy/4,dx,cs,0,RI) ) ad=94*ad/100; // 4
- if( loop(bp,0 ,3*dy/4,dx,cs,1,RI) >= dx ) ad=94*ad/100; // 4
-
-
- if( loop(bp,dx-1,dy/3,dx,cs,0,LE)> dx/4 ) Break;
- j=loop(bp,dx/2,dy-1,dy,cs,0,UP);
- if (j>1 && j>dy/8) {
- if( get_bw(0,dx/2,dy-1-j/2,dy-1-j/2,bp,cs,1) == 1 ) { // ~RA
- if (j<5) ad=95*ad/100;
- else Break;
- }
- }
-
- // italic a
- for(i=0,y=0;y<dy/2;y++)
- if( num_cross(0,dx-1,y,y,bp,cs) > 2 ) i++; if(i>dy/8) Break; // ~a \it a
- if (i>0) ad=99*ad/100;
-
- // ~o look at the lower right side for falling line
- for(j=x=0,y=dy/2;y<dy;y++){
- i=loop(bp,dx-1,y,dx,cs,0,LE);if(i>x){ x=i; }
- if (x-i>j) j=x-i;
- if( j>dx/16 ) Break; // falling line detected
- }
- if (j==0) Break; // no falling line => no Q
- if (j<=dx/16) ad=98*ad/100;
- if(y1<=box1->m3) ad=98*ad/100; // ~q no underlength! rare
- if(!hchar) ad=96*ad/100;
- Setac(box1,'Q',ad);
- break;
- }
- // --- test q ---------------------------------------------------
- for(ad=d=100;dx>2 && dy>3;){ // min 3x4
- DBG( wchar_t c_ask='q'; )
- if (sdata->holes.num > 2) Break; /* tolerant against a tiny hole */
- for ( y=y0; 2*y<=y0+y1; y++ ){ // detect ring
- if( num_cross(x0,x1, y, y,box1->p,cs) == 2 ) Break;
- } if (2*y>y0+y1) Break; /* < */
- for ( y=(y0+y1)/2; y<=y1; y++ ){ // detect vert line
- if( num_cross(x0, x1, y, y,box1->p,cs) == 1
- && num_cross(x0,x0+dx/2, y, y,box1->p,cs) == 0 ) Break;
- } if (y>y1) Break; /* O (y==y1 for 4x6font-q) */
- for ( x=0,j=y=y0+dy/3; y<=y1-dy/8; y++ ){ // detect baseline
- i=loop(box1->p,x0,y,dx,cs,0,RI);
- if ( i>x ) { x=i; j=y; }
- if ( x>dx/2 ) break;
- } if ( x<dx/2 || x>=dx) Break;
- if (y1-j+1<dy/4) ad=96*ad/100; // ~\it{a}
- if( num_cross(x0+x/2,x0+x/2, j, y1,box1->p,cs) != 0 ) ad=96*ad/100; // ~g
- if( loop(box1->p,x0+dx/16,j,dy,cs,0,UP)<1+dy/16 ){
- ad=97*ad/100;
- if (hchar || !gchar) Break; // 4
- }
- if( loop(box1->p,x0+dx/16,j-dy/32-1,dy,cs,1,RI)>=dx-dx/8
- || loop(box1->p,x0+dx/16,j-dy/16-1,dy,cs,1,RI)>=dx-dx/8 ){
- ad=96*ad/100; // 4
- }
- if( get_bw(x1-dx/3, x1, y0+dy/3, y0+dy/3,box1->p,cs,1) != 1 ) Break;
- if( get_bw(x0, x0+dx/3, y0+dy/3, y0+dy/3,box1->p,cs,1) != 1 ) Break;
- if( get_bw(x0, x0+dx/4, y1-dy/8, y1-dy/9,box1->p,cs,1) == 1 ) Break;
- if( get_bw(x0, x0+dx/4, y1-dy/5, y1-dy/9,box1->p,cs,1) == 1 ) ad=99*ad/100;
- if( num_cross(x0+dx/2,x0+dx/2, y0, j ,box1->p,cs) != 2 ) Break;
- // if( num_hole (x0 ,x1 , y0, y1 ,box1->p,cs,NULL) != 1 )
- if (sdata->holes.num != 1)
- { if (dx<16) ad=98*ad/100; else Break; }
- if( num_hole (x0 ,x1 , y0, j ,box1->p,cs,NULL) != 1 )
- { if (dx<16) ad=98*ad/100; else Break; }
- // ~\it g
- if( loop(bp,0,dy-1-dy/4,dx,cs,0,RI)>5*dx/8
- && get_bw(dx/4,dx/4,dy-1-dy/4,dy-1,bp,cs,1)==1 ) Break; // ~\it g
- // what about unsure m1-m4?
- if(!gchar){ ad=ad*99/100; } // ~4
- if( hchar){ ad=ad*99/100; } // ~49
- Setac(box1,'q',ad);
- break;
- }
- return box1->c;
-}
-
-static wchar_t ocr0_iIjJ(ocr0_shared_t *sdata){
- struct box *box1=sdata->box1;
- pix *bp=sdata->bp;
- int i,j,d,x,y,i1,i2,i3,i4,i5,hchar=sdata->hchar,gchar=sdata->gchar,
- ax,ay,bx,by,cx,cy,ex,ey,
- x0=box1->x0,x1=box1->x1,y0=box1->y0,y1=box1->y1,cs=sdata->cs;
- int dx=x1-x0+1,dy=y1-y0+1, /* size */
- ad,ya,yb,yc,yd,ye,yf,xa,xb, /* tmp-vars */
- (*aa)[4]=sdata->aa; /* the for line ends, (x,y,dist^2,vector_idx) */
-
- // --- test i ---------------------------------------------------
- // if(box1->dots==1) // what about \it neighbouring ij
- for(ad=d=100;dy>3 && dx>0;){ // min 3x4 without dot
- DBG( wchar_t c_ask='i'; )
- if (sdata->holes.num > 1) Break; /* tolerant against a tiny hole */
- // ToDo: ':' check that high of dot is smaller than the vert. line!
- /*
- * o <== ya
- * o
- *
- * ooo <== yb
- * o
- * o
- * o
- * ooo
- */
- ya=y0;
- if (box1->dots!=1) ad=98*ad/100;
- while(dy>3*dx && box1->m2){ // test for vertical i without detected dot
- i= loop(bp,dx/2,dy-1 ,dy,cs,0,UP);
- if (dy-1-i<box1->m3-2) break;
- i+=loop(bp,dx/2,dy-1-i,dy,cs,1,UP);
- // distance upper end to m2 > (m2-m1)/3
- if (3*abs(dy-1-i-box1->m2)>box1->m2-box1->m1) break;
- if( get_bw(x0,x1,y0,(box1->m1+box1->m2)/2,box1->p,cs,1) == 1 )
- if( get_bw(x0,x1,y1-i ,y1-i ,box1->p,cs,1) == 0
- || get_bw(x0,x1,y1-i-1,y1-i-1,box1->p,cs,1) == 0
- || get_bw(x0,x1,y1-i-2,y1-i-2,box1->p,cs,1) == 0 )
- {
- Setac(box1,'i',ad);
- return 'i'; /* beleave me, thats an "i"! */
- } break;
- }
-// if( box1->dots!=1 ) Break;
- if( box1->m2 && 2*y0>=box1->m2+box1->m1 ) ya=box1->m1;
-
-// out_x(box1);
- for (y=ya;2*y<ya+y1;y++) if( get_bw(x0,x1,y,y,box1->p,cs,1) == 1 ) break;
- if (2*y>=ya+y1) Break; // hmm, gap only, no dot?
- ya=y;
- if (box1->m2 && ya>box1->m2+2) Break;
- for ( ;2*y<y1+ya;y++) if( get_bw(x0,x1,y,y,box1->p,cs,1) != 1 ) break;
- if (2*y>=ya+y1) Break; // hmm no gap
- for ( ;2*y<y1+ya;y++) if( get_bw(x0,x1,y,y,box1->p,cs,1) == 1 ) break;
- yb=y;
- if (5*yb>=3*ya+2*y1) ad=99*ad/100; // large gap
- if (2*yb>= ya+ y1) ad=97*ad/100; // very large gap, ~:
- if (5*yb>=2*ya+3*y1) Break; // huge gap, ~:
- if (loop(bp,dx-1,y+(y1-ya+1)/32,dx,cs,0,LE)>dx/2) // unusual (right part of ouml)
- ad=95*ad/100;
-
- // printf(" num_cross dy/2=%d %d\n",dy/2, num_cross(0,dx-1,dy/2,dy/2,bp,cs));
- // printf(" dots=%d\n",box1->dots); out_x(box1);
- // \sl ~f. !
- for (y=y1;y>ya;y--) if( get_bw(x0,x1,y,y,box1->p,cs,1) != 1 ) break;
- if (y>(ya+3*y1)/4) Break;
- if (y>(ya+2*y1)/3) ad=96*ad/100;
-
- y=(y1-yb+1)/2+yb-y0; /* only one vertical line, italic i is more an tall S */
- if( num_cross(0,dx-1,y,y,bp,cs) != 1 ) Break;
- for(;y<=y1-y0;y++){ if( num_cross(0,dx-1,y,y,bp,cs) != 1 ) break; } yc=y;
- for(;y<=y1-y0;y++){ if( num_cross(0,dx-1,y,y,bp,cs) != 2 ) break; } yd=y;
- if( yd<3*(y1-yb+1)/4+yb-y0 ) Break;
- y=(y1-yb+1)/2+yb-y0;
- for(;y>0;y--){ if( num_cross(0,dx-1,y,y,bp,cs) != 1 ) break; } ye=y;
- for(;y>0;y--){ if( num_cross(0,dx-1,y,y,bp,cs) != 2 ) break; } yf=y;
- if( yf>(y1-yb+1)/4+yb-y0 ) Break;
- if(yd>yc+2){
- xa=loop(bp, 0,yc-1,dx,cs,0,RI);
- xb=loop(bp,dx-1,yc-1,dx,cs,0,LE);
- if(
- xb-loop(bp,dx-1,yc,dx,cs,0,LE) /* Dec00 */
- > xa-loop(bp, 0,yc,dx,cs,0,RI) ){
- y= loop(bp,dx-xb,yc-1,dy,cs,0,DO);
- if(y>0){
- i=loop(bp,dx-xb-1,yc-1+y-1,dy,cs,0,DO);
- if( i>0 ) y+=i-1;
- }
- if( yc-1+y < yd-1 ) Break;
- } else {
- y= loop(bp,11*xa/16,yc-1,dy,cs,0,DO);
- if( yc-1+y < yd-2 ) Break;
- }
- }
- if(yf<ye-2){
- x=loop(bp,0 ,ye+1,dx,cs,0,RI);
- y=loop(bp,x-1,ye+1,dy,cs,0,UP);
- i=loop(bp,x ,ye+2-y,dy,cs,0,UP);
- if( i>0 ) y+=i-1;
- if( ye+1-y > yf+1 ) Break;
- }
- if( 2*y0 <= box1->m1+box1->m2
- && loop(bp,0, 0,dx,cs,0,RI)+1
- < loop(bp,0,dx/2,dx,cs,0,RI) ) ad=97*ad/100;
-
- if( gchar ) // i is more often than j, be sure that realy correct Mai00
- if( loop(bp, 0,2*dy/4,dx,cs,0,RI)
- -loop(bp,dx-1,2*dy/4,dx,cs,0,LE)>dx/8 ) Break;
-
- // could be a broken + or similar thing?
- if( 3 * ya > box1->m1 + 2*box1->m2 ) ad=90*ad/100;
-
- if( loop(bp,dx-1,3*dy/4,dx,cs,0,LE)>dx/2
- && loop(bp,dx-1, dy-1,dx,cs,0,LE)<dx/4 ) Break; // ~d=cl
-
- // test for é
- if( dx>5 && num_cross(x0+dx/2,x0+dx/2, ya, y1 ,box1->p,cs) >= 3 )
- ad=95*ad/100;
-
- Setac(box1,'i',ad);
- break;
- }
- // --- test j ---------------------------------------------------
- // if(box1->dots==1) // what about \it neighbouring ij
- for(ad=d=100;dy>4 && dx>0;){ // min 3x4
- DBG( wchar_t c_ask='j'; )
- if (sdata->holes.num > 1) Break; /* tolerant against a tiny hole */
- ya=y0;
- if( box1->m2 && 2*y0>=box1->m2+box1->m1 ) ya=box1->m1;
-
- for(y=ya;2*y<ya+y1;y++) if( get_bw(x0,x1,y,y,box1->p,cs,1) == 1 ) break;
- if(2*y>=ya+y1) Break; // hmm only gap
- ya=y;
- if( box1->m2 && ya>box1->m2+2 ) Break;
- for( ;2*y<y1+ya;y++) if( get_bw(x0,x1,y,y,box1->p,cs,1) != 1 ) break;
- if(2*y>=ya+y1) Break; // hmm no gap
- for( ;2*y<y1+ya;y++) if( get_bw(x0,x1,y,y,box1->p,cs,1) == 1 ) break;
- if(2*y>=ya+y1) Break; // hmm very large gap
- yb=y;
- if( loop(bp,dx-1,y+(y1-ya+1)/32,dx,cs,0,LE)>dx/2 ) Break; // unusual (right part of ouml)
-
- // printf(" num_cross dy/2=%d %d\n",dy/2, num_cross(0,dx-1,dy/2,dy/2,bp,cs));
- // printf(" dots=%d\n",box1->dots); out_x(box1);
- // \sl ~f. !
- for(y=(ya+y1)/2;y<=y1;y++) if( get_bw(x0,x1,y,y,box1->p,cs,1) != 1 ) break;
- if(y<=y1) Break;
-
- y=(y1-yb+1)/2+yb-y0; /* only one vertical line, italic i is more an tall S */
- if( num_cross(0,dx-1,y,y,bp,cs) >2 ) Break;
- for(;y<=y1-y0;y++){ if( num_cross(0,dx-1,y,y,bp,cs) != 1 ) break; } yc=y;
- for(;y<=y1-y0;y++){ if( num_cross(0,dx-1,y,y,bp,cs) != 2 ) break; } yd=y;
- if( yd<3*(y1-yb+1)/4+yb-y0 ) Break;
- y=(y1-yb+1)/2+yb-y0;
- for(;y>0;y--){ if( num_cross(0,dx-1,y,y,bp,cs) != 1 ) break; } ye=y;
- for(;y>0;y--){ if( num_cross(0,dx-1,y,y,bp,cs) != 2 ) break; } yf=y;
- if( yf>(y1-yb+1)/4+yb-y0 ) Break;
- if(yd>yc+2){
- xa=loop(bp, 0,yc-1,dx,cs,0,RI);
- xb=loop(bp,dx-1,yc-1,dx,cs,0,LE);
- if(
- xb-loop(bp,dx-1,yc,dx,cs,0,LE) /* Dec00 */
- > xa-loop(bp, 0,yc,dx,cs,0,RI) ){
- y= loop(bp,dx-xb,yc-1,dy,cs,0,DO);
- if(y>0){
- i=loop(bp,dx-xb-1,yc-1+y-1,dy,cs,0,DO);
- if( i>0 ) y+=i-1;
- }
- if( yc-1+y < yd-1 ) Break;
- } else {
- y= loop(bp,11*xa/16,yc-1,dy,cs,0,DO);
- if( yc-1+y < yd-2 ) Break;
- }
- }
- if(yf<ye-2){
- x=loop(bp,0 ,ye+1,dx,cs,0,RI);
- y=loop(bp,x-1,ye+1,dy,cs,0,UP);
- i=loop(bp,x ,ye+2-y,dy,cs,0,UP);
- if( i>0 ) y+=i-1;
- if( ye+1-y > yf+1 ) Break;
- }
- if( 2*y0 <= box1->m1+box1->m2
- && loop(bp,0, 0,dx,cs,0,RI)+1
- < loop(bp,0,dx/2,dx,cs,0,RI) ) ad=97*ad/100;
- if (loop(bp,0,dy-1,dx,cs,0,RI)
- -loop(bp,0,dy-3,dx,cs,0,RI)>1+dx/16) ad=96*ad/100; // ~c
-
- if( gchar ) // i is more often than j, be sure that realy correct Mai00
- if( loop(bp, 0,2*dy/4,dx,cs,0,RI)
- -loop(bp,dx-1,2*dy/4,dx,cs,0,LE)<=dx/8 ) Break;
- // could be a broken + or similar thing?
- if( 3 * ya > box1->m1 + 2*box1->m2 ) ad=80*ad/100;
- if (!gchar) ad=96*ad/100;
- if( box1->dots!=1 ) ad=98*ad/100;
-
- Setac(box1,'j',ad);
-
- break;
- }
- // --- test I ---------------------------------------------------
- for(ad=d=100;dy>4 && dy>dx && 5*dy>4*(box1->m3-box1->m2);){ // min 3x4
- DBG( wchar_t c_ask='I'; )
- if( box1->dots==1 ) Break;
- if (sdata->holes.num > 1) Break; /* tolerant against a tiny hole */
-
- x =loop(bp,0, dy/2,dx,cs,0,RI); // konvex? divided Q
- if(loop(bp,0,7*dy/8,dx,cs,0,RI) > x+dx/8) Break;
- for( y=dy/16;y<dy-1-dy/16;y++ )
- if( num_cross(0, dx-1, y , y ,bp,cs) != 1 )
- if( num_cross(0, dx-1, y+dy/16 , y+dy/16 ,bp,cs) != 1 ) break;
- if( y<dy-1-dy/16 ) Break;
- x =loop(bp,0, dy/2,dx,cs,0,RI);
- i5=loop(bp,x, dy/2,dx,cs,1,RI); // center width
- for(y=dy/4;y<3*dy/4;y++ ){ // same width ?
- x =loop(bp,0, y,dx,cs,0,RI);
- x =loop(bp,x, y,dx,cs,1,RI); // width
- if( abs(x-i5)>1+dx/8 ) break;
- } if( y<3*dy/4 ) Break;
- // out_x(box1);
-
- // upper max width
- for(i2=i1=0,y=0;y<dy/4;y++ ){
- x =loop(bp,0, y,dx,cs,0,RI);
- x =loop(bp,x, y,dx,cs,1,RI); if(x>i1){ i1=x;i2=y; }
- }
- for(i4=i3=0,y=3*dy/4;y<dy;y++ ){
- x =loop(bp,0, y,dx,cs,0,RI);
- x =loop(bp,x, y,dx,cs,1,RI); if(x>i3){ i3=x;i4=y; }
- }
- if( abs(i3-i1)>1+dx/8 ) Break; // if i3>>i5 more sure!
- if( i1>i5 ){ // look for edges else *80%
- }
- if(i1+1<i5 && !hchar) Break; // Jun00
-
- // calculate upper and lower mass center
- x =loop(bp,0, dy/8,dx,cs,0,RI); i1=x;
- x+=loop(bp,x, dy/8,dx,cs,1,RI); i1=(i1+x-1)/2;
-
- x =loop(bp,0,dy-1-dy/8,dx,cs,0,RI); i2=x;
- x+=loop(bp,x,dy-1-dy/8,dx,cs,1,RI); i2=(i2+x-1)/2;
- x =loop(bp,0,dy-2-dy/8,dx,cs,0,RI); i=x;
- x+=loop(bp,x,dy-2-dy/8,dx,cs,1,RI); i=(i+x-1)/2; if( i>i2 ) i2=i;
-
- // printf(" get_line(%d,%d) %d\n",i1,i2,
- // get_line2(i1,dy/8,i2,dy-1-dy/8,bp,cs,100));
- if( get_line2(i1,dy/8,i2,dy-1-dy/8,bp,cs,100)<95 ) Break;
- x =(i1-i2+4)/8; i1+=x; i2-=x;
-
- // upper and lower width (what about serifs?)
- y=dy/8;
- x =loop(bp,i1, y+0,dx,cs,1,LE); i=x;
- x =loop(bp,i1, y+1,dx,cs,1,LE); if(x>i)i=x;
- x =loop(bp,i1, y+0,dx,cs,1,RI); j=x;
- x =loop(bp,i1, y+1,dx,cs,1,RI); if(x>j)j=x; if(abs(i-j)>1+dx/8)Break;
- x =loop(bp,i2,dy-y-1,dx,cs,1,LE); j=x;
- x =loop(bp,i2,dy-y-2,dx,cs,1,LE); if(x>j)j=x; if(abs(i-j)>1+dx/8)Break;
- x =loop(bp,i2,dy-y-1,dx,cs,1,RI); j=x;
- x =loop(bp,i2,dy-y-2,dx,cs,1,RI); if(x>j)j=x; if(abs(i-j)>1+dx/8)Break;
-
- if(dy>15) // v024a4
- if( loop(bp,dx-1,dy/16 ,dx,cs,0,LE)
- > loop(bp,dx-1,dy/4 ,dx,cs,0,LE)+1+dx/32 ) Break; // ~bad ) (thinn)
-
- for(i=0,y=dy/16;y<15*dy/16 && i<2;y++)
- if( num_cross(0,dx-1,y,y,bp,cs) != 1 ) i++;
- if( i>1 ) Break;
-
- if(!hchar){ // right part (bow) of h is never a l
- if( get_bw(dx/4,dx/4, 0,dy/4,bp,cs,1) == 1
- && get_bw(dx/4,dx/4,dy/2,dy-1,bp,cs,1) == 0 ) Break;
- if( loop(bp, 0,dy/4,dx,cs,0,RI)> dx/4
- && loop(bp,dx-1,dy/4,dx,cs,0,LE)<=dx/4
- && loop(bp, 1, 0,dy,cs,0,DO)<=dy/4 ) Break; // ~z
- }
-
- if( get_bw(x1,x1,y0 ,y1 ,box1->p,cs,2) != 2
- && get_bw(x0,x1,y0 ,y0 ,box1->p,cs,2) != 2
- && get_bw(x0,x1,y1 ,y1 ,box1->p,cs,2) != 2
- && get_bw(x0,x0,y0+1,y1-1,box1->p,cs,1) != 1 ) Break; /* ~] */
-
- if ( loop(bp,dx-1, dy/4,dx,cs,0,LE) > dx/2
- && loop(bp,dx-1,3*dy/4,dx,cs,0,LE) > dx/2
- && loop(bp, 0, dy/2,dx,cs,0,RI) < dx/4 ) Break; /* ~[ */
-
- x =loop(bp, 0,dy/2,dx,cs,0,RI); // konvex/konkav? ~()
- i =loop(bp,dx-1,dy/2,dx,cs,0,LE);
- if( loop(bp, 0,7*dy/8,dx,cs,0,RI) > x+dx/8
- && loop(bp, 0, dy/8,dx,cs,0,RI) > x+dx/8
- && loop(bp,dx-1,7*dy/8,dx,cs,0,LE) < i-dx/8
- && loop(bp,dx-1, dy/8,dx,cs,0,LE) < i-dx/8 ) Break; // ~(
- if( loop(bp, 0,7*dy/8,dx,cs,0,RI) < x-dx/8
- && loop(bp, 0, dy/8,dx,cs,0,RI) < x-dx/8
- && loop(bp,dx-1,7*dy/8,dx,cs,0,LE) > i+dx/8
- && loop(bp,dx-1, dy/8,dx,cs,0,LE) > i+dx/8 ) Break; // ~)
- if( loop(bp, 0, dy/8,dx,cs,0,RI)
- -(dx-loop(bp,dx-1,7*dy/8,dx,cs,0,LE)) > dx/4 ) Break; // ~/
- if( loop(bp, 0, 0,dx,cs,0,RI) > dx/2 // ToDo: check for serifs
- && loop(bp, 0, dy/8,dx,cs,0,RI) > dx/2
- && loop(bp,dx-1,dy-1 ,dx,cs,0,LE) > dx/2
- && loop(bp,dx-1,dy-1-dy/8,dx,cs,0,LE) > dx/2 ) ad=99*ad/100; // ~/
-
- if (box1->m2 && 3*y0>box1->m1+2*box1->m2)
- if( get_bw(x0+dx/8,x1-dx/8,box1->m1,(box1->m1+box1->m2)/2,box1->p,cs,1) == 1 )
- Break; // ~i
-
- if(i1+1<i5 && !hchar){ ad=65*ad/100; MSG({}) } // ~ slanted I
-
- // be sure only for serif
- i3=loop(bp,dx-1, dy/4,dx,cs,0,LE);
- i4=loop(bp, 0,dy-1-dy/4,dx,cs,0,RI);
- if (i3<2 || i4<2
- || get_bw(x1-i3/4,x1-i3/4,y0,y0+dy/4,box1->p,cs,1) != 1
- || get_bw(x0+i4/4,x0+i4/4,y1-dy/4,y1,box1->p,cs,1) != 1 )
- { ad=99*ad/100; MSG(fprintf(stderr,"ad=%d",ad);) } // ToDo: improve it
- if(!hchar){ ad=96*ad/100; MSG({}) } // ~bad_small_r
- if (box1->m4 && y1<box1->m4) { // probably lower dot?
- if ((dx>2 && get_bw(x0+1,x1-1,y1+1,box1->m4,box1->p,cs,1) == 1)
- || (dx<3 && get_bw(x0 ,x1 ,y1+1,box1->m4,box1->p,cs,1) == 1)) {
- ad=96*ad/100;
- }
- } // ~!
- // a---b
- // I
- // I
- // c---e
- // check against Z
- for(bx=0,ax=dx,ay=by=y=0;y<dy/4;y++){
- i =loop(bp,dx-1 ,y,dx,cs,0,LE); if (dx-i-1>bx) { bx=dx-1-i; by=y; }
- i+=loop(bp,dx-1-i,y,dx,cs,1,LE); if (dx-i-1<ax) { ax=dx-i; ay=y; }
- }
- for(cx=dx,ex=0,ey=cy=y=dy-1;y>dy-1-dy/4;y--){
- i =loop(bp,0,y,dx,cs,0,RI); if (i<cx) { cx=i; cy=y; }
- i+=loop(bp,i,y,dx,cs,1,RI); if (i>ex) { ex=i; ey=y; }
- }
- x=(3*ax+cx)/4; y=(3*ay+cy)/4; i= loop(bp,x,y,dx,cs,0,RI);
- x=(3*bx+ex)/4; y=(3*by+ey)/4; j= loop(bp,x,y,dx,cs,0,LE);
- if (j>0 && (2*i>3*j || 3*i<2*j )) ad=99*ad/100;
- if (j>0 && ( i>2*j || 2*i< j )) ad=97*ad/100;
- i=loop(bp,0,0,dy,cs,0,DO);
- if (i>dy/8 && i<dy/2) ad=99*ad/100; // ~1
- if (loop(bp,dx-1,0,dx,cs,0,LE)
- -loop(bp, 0,0,dx,cs,0,RI)>dx/4) ad=96*ad/100; // ~l 5x7
-
- if( get_bw(x0,x1,y0,y1,box1->p,cs,2) == 0 ) ad=99*ad/100;
- if (gchar) ad=98*ad/100; // J
- if (box1->m3 && 2*y1<=box1->m2+box1->m3) ad=96*ad/100; // '
-
- Setac(box1,'I',ad);
- break;
- }
- // --- test J --------------------------------------------------- 22Nov06
- for(ad=d=100;dy>4 && dy>=dx && dx>2;){ // min 3x4 ~Y)]d',
- // rewritten for vectors 0.42
- int ld, i1, i2, i3, i4, i5, i6, i7; // line derivation + corners
- DBG( wchar_t c_ask='J'; )
- if (sdata->holes.num > 0) Break; /* no hole */
- /* half distance to the center */
- d=2*sq(128/4);
- /* now we check for the upper right end of the J */
- if (aa[3][2]>d) Break; /* [2] = distance */
- /* searching for 4 notches between neighbouring ends */
-
-/*
- type A B
-
- 6OOOO 6O5
- 7O5 7O
- O O
- O O
- 2O 1O4 1O4
- OO 2OO
- 3 3
-*/
-
- /* Warning: aa0 can be left upper or left lower point for type B */
- /* get a point on the inner low left side of the J */
- i =nearest_frame_vector(box1,aa[3][3],aa[1][3],(x0+x1)/2,y0);
- i1=nearest_frame_vector(box1,i ,aa[1][3], x1+dx,(y0+3*y1)/4);
- /* get the most left point on the lower part of the J */
- i2=nearest_frame_vector(box1,i1,aa[3][3], x0-2*dx, y1-dy/8);
- /* get a point on the middle of the bottom of the J */
- i3=nearest_frame_vector(box1,aa[1][3],aa[2][3], (x0+x1)/2, y1);
- /* get a point on the outer low right side of the J */
- i4=nearest_frame_vector(box1,aa[1][3],aa[3][3], x1, (y0+2*y1)/3);
- /* get a point on the outer right side below top serif */
- i5=nearest_frame_vector(box1,aa[2][3],aa[3][3], (x0+2*x1)/3,y0);
- /* get a point on the left side of upper serif */
- i6=nearest_frame_vector(box1,aa[3][3],i1, x0, y0);
- /* get a point on the most right left side of upper serif */
- i7=nearest_frame_vector(box1,i6,i1, x1, y0);
- MSG(fprintf(stderr," i1-i7 %d %d %d %d %d %d %d",i1,i2,i3,i4,i5,i6,i7);)
-
- /* check the highest point on lower left area */
- i =nearest_frame_vector(box1,i1,i3,x0,y0);
- if (box1->frame_vector[i ][1]-y0<dy/4) Break; // U
- if (box1->frame_vector[i ][1]-y0<=dy/2) ad=97*ad/100; // imperfect a
- /* check the lowest point on upper left area, serife? */
- j =nearest_frame_vector(box1,i6,i7,x0,y1);
- if (box1->frame_vector[i ][1]
- -box1->frame_vector[j ][1]<=dy/4) Break; // imperfect a
- if (box1->frame_vector[i7][1]>y0+dy/4) Break; // not to low
- if (box1->frame_vector[i1][1]
- -box1->frame_vector[i7][1]<dy/2) Break;
- if (box1->frame_vector[i4][1]
- -box1->frame_vector[i5][1]<dy/2) Break;
- if (box1->frame_vector[i7][0]<x0+dx/2) Break;
- if (box1->frame_vector[i1][0]
- -box1->frame_vector[i2][0]<=dx/8) Break; // ~1
- if (box1->frame_vector[i1][0]
- -box1->frame_vector[i2][0]<=dx/4) ad=ad*99/100; // ~1
- if (box1->frame_vector[i6][1]>y0+dy/8) ad=99*ad/100; // ~1
- if (aa[0][2]==0) { // ]?
- ad=99*ad/100;
- if (aa[1][2]==0) ad=98*ad/100;
- if (aa[2][2]<=aa[3][2]) ad=97*ad/100;
- }
-
- /* check for left bow */
- for (j=i=i2;i!=i4;i=(i+1)%box1->num_frame_vectors[0]) {
- if (box1->frame_vector[ i][0] /* [0]=x */
- <box1->frame_vector[i1][0]) break; /* curve? */
- } if (i==i4) Break; // ~I
- /* check for no right bow */
- for (j=i=i2;i!=i4;i=(i+1)%box1->num_frame_vectors[0]) {
- if (box1->frame_vector[ i][0] /* [0]=x */
- >box1->frame_vector[i4][0]) break;
- } if (i!=i4) Break; // ~I
- /* check for no right bow */
- for (j=i=i5;i!=i6;i=(i+1)%box1->num_frame_vectors[0]) {
- if (box1->frame_vector[ i][1] > y0+dy/4) break;
- } if (i!=i6) Break; // ~Y
- /* check if upper left and lower left points are joined directly */
- ld=line_deviation(box1, i7, i1);
- MSG(fprintf(stderr," i7,i1 %d %d linedist= %d/%d",i7,i1,ld,2*sq(1024/4));)
- if (ld >2*sq(1024/4)) Break;
- if (5*ld >4*2*sq(1024/4)) ad=99*ad/100; // ~3
- if (6*ld >4*2*sq(1024/4)) ad=99*ad/100; // ~3
- if (7*ld >4*2*sq(1024/4)) ad=99*ad/100; // ~3
- if (8*ld >4*2*sq(1024/4)) ad=99*ad/100; // ~3
- /* check if lower right and upper right points are joined directly */
- ld=line_deviation(box1, i4, i5);
- MSG(fprintf(stderr," i4,i5 %d %d linedist= %d/%d",i4,i5,ld,2*sq(1024/4));)
- if (ld >2*sq(1024/4)) Break;
- if (5*ld >4*2*sq(1024/4)) ad=99*ad/100;
-
- // J exists as gchar and ~gchar
- if(!hchar){ ad=99*ad/100; }
- Setac(box1,'J',ad);
- break;
- }
- return box1->c;
-}
-
-static wchar_t ocr0_brackets(ocr0_shared_t *sdata){
- struct box *box1=sdata->box1;
- pix *bp=sdata->bp;
- int i,j,d,x,y,i1,i2,i3,i4,i5,i6,hchar=sdata->hchar,
- x0=box1->x0,x1=box1->x1,y0=box1->y0,y1=box1->y1,cs=sdata->cs;
- int dx=x1-x0+1,dy=y1-y0+1, /* size */
- (*aa)[4]=sdata->aa, /* corner-points, (x,y,dist^2,vector_idx) */
- ad,r1,r2; /* tmp-vars */
- wchar_t bc=UNKNOWN;
-
- // --- test > derived from xX ---------------------------------------------------
- // rewritten for vectors v0.41
- for(ad=d=100;dx>1 && dy>2;){ // min 3x2
- // 0 - indizes 0,1,i1,i2 pointing to edges of the char
- // \ .
- // \ .
- // i1,i2
- // /
- // /
- // 1
- DBG( wchar_t c_ask='>'; )
- if (sdata->holes.num > 1) Break; /* tolerant against a tiny hole */
- if (sdata->holes.num > 0 && (dx<6 || dy<6)) Break; /* # */
- /* calculate the half distance to the center */
- d=2*sq(128/4);
- /* now we check for the 2 left ends of the > */
- if (aa[0][2]>d) Break; /* upper left end */
- if (aa[1][2]>d) Break; /* lower left end */
- if (aa[1][1]-aa[0][1]<dy/2) Break;
- /* searching for 4 notches between neighbouring ends */
-
- /* run along left side from top to bottom */
- for (j=i=aa[0][3];i!=aa[1][3];i=(i+1)%box1->num_frame_vectors[0]) {
- if (box1->frame_vector[i][0]
- >=box1->frame_vector[j][0]) j=i; /* notice most right vector */
- } if (j==i || j==aa[0][3]) Break;
- /* calculate the distance to the center */
- x=box1->frame_vector[j][0];
- y=box1->frame_vector[j][1];
- if (2*x-aa[0][0]-aa[1][0]<dx) ad=99*ad/100;
- if (abs(aa[0][1]+aa[1][1]-2*y)>(dy+2)) Break;
- if ( aa[0][0]+aa[1][0]-2*x>=0) Break;
- i1=j;
- d=line_deviation(box1, aa[0][3], j) >sq(1024/4);
- /* check if upper left and center point are joined directly */
- MSG(fprintf(stderr,"x %d %d dist= %d/%d",x-x0,y-y0,d,sq(1024/4));)
- if (d >sq(1024/4)) Break; ad=ad-d*100/sq(1024);
- MSG(fprintf(stderr,"ad=%d", ad);)
- d=line_deviation(box1, j, aa[1][3]);
- /* check if lower left and center point are joined directly */
- MSG(fprintf(stderr,"x %d %d dist= %d/%d",x-x0,y-y0,d,sq(1024/4));)
- if (d >sq(1024/4)) Break; ad=ad-d*100/sq(1024);
- MSG(fprintf(stderr,"ad=%d", ad);)
-
- /* run along right side from bottom to top */
- for (j=i=aa[1][3];i!=aa[0][3];i=(i+1)%box1->num_frame_vectors[0]) {
- if (box1->frame_vector[i][0]
- >=box1->frame_vector[j][0]) j=i; /* notice most right vector */
- // MSG(fprintf(stderr,"search right: %d %d %d %d",i,j,aa[1][3],aa[0][3]);)
- } if (j==i || j==aa[1][3]) Break;
- /* calculate the distance to the center */
- x=box1->frame_vector[j][0];
- y=box1->frame_vector[j][1];
- if ( (aa[0][0]+aa[1][0]-2*x)>= 0 ) Break;
- if (abs(aa[0][1]+aa[1][1]-2*y)>(dy+2)/4) Break;
- if (aa[0][0]>=x || aa[1][0]>=x) Break;
- i2=j;
- d=line_deviation(box1, j, aa[0][3]);
- /* check if upper left and center point are directly joined directly */
- MSG(fprintf(stderr,"x %d %d dist= %d/%d",x-x0,y-y0,d,sq(1024/4));)
- if (d >sq(1024/4)) Break; ad=ad-d*100/sq(1024);
- MSG(fprintf(stderr,"ad=%d", ad);)
- d=line_deviation(box1, aa[1][3], j);
- /* check if lower left and center point are directly joined */
- MSG(fprintf(stderr,"x %d %d dist= %d/%d",x-x0,y-y0,d,sq(1024/4));)
- if (d >sq(1024/4)) Break; ad=ad-d*100/sq(1024);
- MSG(fprintf(stderr,"ad=%d", ad);)
-
- /*
- ToDo: calculate momentums or max derivations
- along lines to distinguish )]}>
- i1,i2
- */
-
- if (sdata->gchar) ad=98*ad/100;
- if (sdata->hchar) ad=99*ad/100;
- bc='>';
- Setac(box1,bc,ad);
- break;
- }
- // --- test /\\ ------------------------------------------------
-// if(bc==UNKNOWN)
-// if(!box1->dots)
- for(ad=d=100;dx>3 && dy>3;){ // min 4x4 for 4x6 font
- DBG( wchar_t c_ask='/'; )
- if (sdata->holes.num > 0) Break; /* tolerant against a tiny hole */
-#if 1
- for(i=y=0;y<dy;y++){
- if( num_cross(0,dx-1,y,y,bp,cs) != 1 ) i++;
- if( loop(bp, 0,y,dx,cs,0,RI)
- + loop(bp,dx-1,y,dx,cs,0,LE)<3*dx/8 ) break;
- }
- if( y<dy ) Break;
- if ( i>2 || (i>0 && dy<16)) Break;
-#endif
- /* get the center as exact as possible */
- i2=dx-1-loop(bp,dx-1,dy/2 ,dx,cs,0,LE) // be exact for small fonts
- +dx-1-loop(bp,dx-1,dy/2+dy%2-1,dx,cs,0,LE)
- + loop(bp, 0,dy/2 ,dx,cs,0,RI)
- + loop(bp, 0,dy/2+dy%2-1,dx,cs,0,RI);
- if (abs(i2-2*dx)>1+dx/2) Break;
- if (abs(i2-2*dx)> dx/2) ad=99*ad/100;
-
- i1=loop(bp,dx-1,dy/16,dx,cs,0,LE); // right side
- i3=loop(bp,dx-1,dy-1 ,dx,cs,0,LE);
- i4=loop(bp, 0,0 ,dx,cs,0,RI); // left side
- i6=loop(bp, 0,dy-1 ,dx,cs,0,RI);
- i=(box1->m4+box1->m3)/2-box1->m2;
- //
- // out_x(box1);printf("() %d %d %d %d %d %d %d\n",i,i1,i2,i3,i4,i5,i6);
-
- // ~lI
- for(i=i4,y=0;y<dy;y++){
- x=loop(bp,0 ,y,dx,cs,0,RI);if(abs(x-i)>dx/6+1 ) break; i=x;
- } if( y<dy ) Break;
- for(i=i1,y=0;y<dy;y++){
- x=loop(bp,dx-1,y,dx,cs,0,LE);if(abs(x-i)>dx/6+1 ) break; i=x;
- } if( y<dy ) Break;
- if(i1<=dx/8 && i6<=dx/8 && i4-(dx-i3)>dx/4 ) { Setac(box1,(bc='/'),ad);break; }
- if(i4<=dx/8 && i3<=dx/8 && i6-(dx-i1)>dx/4 ) { Setac(box1,(bc='\\'),ad);break; }
- Break;
- }
- // --- test ()<> ------------------------------------------------
-// if(bc==UNKNOWN)
-// if(!box1->dots)
- for(ad=d=100;dx>1 && dy>4;){ // min 3x4
- DBG( wchar_t c_ask='('; )
- if (sdata->holes.num > 1) {Break;}; /* tolerant against a tiny hole */
-#if 1
- for(i=y=0;y<dy;y++){
- if( num_cross(0,dx-1,y,y,bp,cs) != 1 ) i++;
- if( loop(bp, 0,y,dx,cs,0,RI)
- + loop(bp,dx-1,y,dx,cs,0,LE)<3*dx/8 ) break;
- }
- if( y<dy ) {Break;};
- if ( i>2 || (i>0 && dy<16)) {Break;};
-#endif
- /* look for the extrema => r1..r2 */
- for(i=dx,r1=r2=y=dy/2-dy/8;y<=dy/2+dy/8;y++){
- j=loop(bp, 0,y,dx,cs,0,RI); if(j==i) r2=y; if(j<i){ r2=r1=y; i=j; }
- j=loop(bp,dx-1,y,dx,cs,0,LE); if(j==i) r2=y; if(j<i){ r2=r1=y; i=j; }
- } y=(r1+r2)/2;
- i1=loop(bp,dx-1, dy/16,dx,cs,0,LE);
- i2=loop(bp,dx-1,y ,dx,cs,0,LE);
- i3=loop(bp,dx-1,dy-1-dy/16,dx,cs,0,LE);
- i4=loop(bp, 0,dy/16 ,dx,cs,0,RI);
- i5=loop(bp, 0,y ,dx,cs,0,RI);
- i6=loop(bp, 0,dy-1-dy/16,dx,cs,0,RI);
- if(dx>dy){
-// from Aug06 vector-version of greater is used
-// if(i2==0 && 3*i5>dx && i4<=dx/8 && i6<=dx/8) { Setac(box1,(bc='>'),98);{Break;}; }
- if(i5==0 && 3*i2>dx && i1<=dx/8 && i3<=dx/8) { Setac(box1,(bc='<'),98);{Break;}; }
- }
- if( dx > 2 && 9*dx>=5*dy ){ // 4x6 screen-font (3*5)
- ad=98;
- if (dx<8) ad=99*ad/100;
- if (dx<6) ad=96*ad/100;
- if( 2*dx > JOB->res.avX && 4*dx>dy ) ad=98;
-// printf(" %d %d %d %d %d %d\n",i5,i1,i3,i2,i4,i6);
- if( i5==0 && i1<=dx/8+1 && i3<=dx/8+1 && i1+i3<=dx/8+1
- && i2>=dx/2 && i4>=3*dx/4 && i6>=3*dx/4 ) {
- if (2*loop(bp, 0, y/2,dx,cs,0,RI)+1+dx/16<i4+i5) ad=95*ad/100;
- if (2*loop(bp, 0,dy-1-y/2,dx,cs,0,RI)+1+dx/16<i6+i5) ad=95*ad/100;
- Setac(box1,(bc='<'),ad);{Break;};
- }
-/* obsolete code Aug06, will be removed if new code is stable
- if( i2==0 && i4<=dx/8 && i6<=dx/8
- && i5>=dx/2 && i1>=3*dx/4 && i3>=3*dx/4 ) {
- if (2*loop(bp,dx-1, y/2,dx,cs,0,LE)+1+dx/16<i1+i2) ad=95*ad/100;
- if (2*loop(bp,dx-1,dy-1-y/2,dx,cs,0,LE)+1+dx/16<i3+i2) ad=95*ad/100;
- Setac(box1,(bc='>'),ad);{Break;};
- }
-*/
- }
-
- i1=loop(bp,dx-1,dy/16,dx,cs,0,LE);
- i2=loop(bp,dx-1,dy/2 ,dx,cs,0,LE);
- i3=loop(bp,dx-1,dy-1 ,dx,cs,0,LE);
- i4=loop(bp, 0,0 ,dx,cs,0,RI);
- i5=loop(bp, 0,dy/2,dx,cs,0,RI);
- i6=loop(bp, 0,dy-1,dx,cs,0,RI);
- i=(box1->m4+box1->m3)/2-box1->m2;
- //
- // out_x(box1);printf("() %d %d %d %d %d %d %d\n",i,i1,i2,i3,i4,i5,i6);
- if(2*i2<i1+i3 && 2*i5>i4+i6 && 2*dx<dy && dy>=i){
- Setac(box1,(bc=')'),98);break; }
- if(2*i2>i1+i3 && 2*i5<i4+i6 && 2*dx<dy && dy>=i){
- if(2*i2<=i1+i3+1 || 2*i5>=i4+i6-1) ad=98*ad/100;
- if(2*i2<=i1+i3+2 || 2*i5>=i4+i6-2) ad=98*ad/100;
- for(x=y=0;y<dy/4;y++){
- i=loop(bp,0,y,dx,cs,0,RI);if( i>x ) x=i;
- }
- for(y=0;y<(dy+2)/4;y++){
- i=loop(bp,0,y+dy/8,dx,cs,0,RI);if( i<x ) break;
- }
- if( y==(dy+2)/4 ) {Break;}; // ~l (left upper side must be convex) Jul00
- Setac(box1,(bc='('),ad); break;
- }
- Break;
- }
- // --------- test [] --------------------------------
- for(ad=d=98;dx>2 && dy>4 && dy>=2*dx;){ // (3,6) on 4x6 font
- DBG( wchar_t c_ask=']'; )
- if (sdata->holes.num > 1) { Break;} /* tolerant against a tiny hole */
- if (!hchar) ad=97*ad/100;
- for(y=0;y<dy;y++){
- if( num_cross(0,dx-1,y,y,bp,cs) != 1 ) break;
- } if (y<dy) {Break;};
- if( get_bw(x0,x1,y0 ,y0 ,box1->p,cs,2) == 2
- && get_bw(x0,x1,y0+1,y0+1,box1->p,cs,2) == 2 ) {Break;};
- if( get_bw(x0,x1,y1 ,y1 ,box1->p,cs,2) == 2
- && get_bw(x0,x1,y1-1,y1-1,box1->p,cs,2) == 2 ) {Break;};
- if( get_bw(x0 ,x0,y0 ,y1 ,box1->p,cs,2) == 0
- || get_bw(x0+1 ,x0+1,y0 ,y1 ,box1->p,cs,2) == 0 )
- if( get_bw(x0+dx/2,x1,y0+dy/4,y1-dy/4,box1->p,cs,1) == 0 )
- { Setac(box1,(bc='['),ad);break; }
- if( get_bw(x1 ,x1,y0 ,y1 ,box1->p,cs,2) == 0
- || get_bw(x1-1 ,x1-1,y0 ,y1 ,box1->p,cs,2) == 0 )
- if( get_bw(x0,x1-dx/2,y0+dy/4,y1-dy/4,box1->p,cs,1) == 0 )
- { Setac(box1,(bc=']'),ad);break; }
- break;
- }
-
-#if CODE_NOT_COMPLETED
- // --- test ] -------
- for(ad=d=100;dx>2 && dy>3;){
- DBG( wchar_t c_ask=']'; )
- if (sdata->holes.num > 1) Break; /* tolerant against a tiny hole */
- if (sdata->holes.num > 0) ad=98*ad/100; /* # */
- /* 1/8 distance to the center */
- d=2*sq(128/16);
- /* now we check for the 4 ends of the x */
- if (aa[0][2]>d) Break;
- if (aa[1][2]>d) Break;
- if (aa[2][2]>d) Break;
- if (aa[3][2]>d) Break;
- if (aa[3][0]-aa[0][0]<7*dx/8) Break;
- if (aa[2][0]-aa[1][0]<7*dx/8) Break;
- if (aa[1][1]-aa[0][1]<7*dy/8) Break;
- if (aa[2][1]-aa[3][1]<7*dy/8) Break;
- if (aa[3][0]-aa[0][0]<2) Break; /* to small */
- if (aa[2][0]-aa[1][0]<2) Break; /* to small */
- MSG( fprintf(stderr," aa %d %d %d %d %d %d %d %d d %d %d %d %d",\
- aa[0][0]-x0,aa[0][1]-y0,aa[1][0]-x0,aa[1][1]-y0,\
- aa[2][0]-x0,aa[2][1]-y0,aa[3][0]-x0,aa[3][1]-y0,\
- aa[0][2],aa[1][2],aa[2][2],aa[3][2]);)
- /* left and right vertical line */
- d=line_deviation(box1, aa[0][3], aa[1][3]); if (d>2*sq(1024/4)) Break;
- ad=(100-(d-sq(1024)/2)/sq(1024)/4)*ad/100;
- d=line_deviation(box1, aa[2][3], aa[3][3]); if (d>2*sq(1024/4)) Break;
-
- /* search uppermost left ^ */
- i1=nearest_frame_vector(box1,aa[1][3],aa[2][3], x0, y0);
- x=box1->frame_vector[i1][0];
- y=box1->frame_vector[i1][1];
- if (y-y0 > 5*dy/8) Break;
- if (x-x0 > 5*dx/8) Break;
- /* search uppermost right ^ ~H */
- i3=nearest_frame_vector(box1,aa[1][3],aa[2][3], x1, y0);
- if ( box1->frame_vector[i3][0]-x> dx/4
- && box1->frame_vector[i3][1]-y<=dy/8) Break;
-
- /* check if upper left and lower right point are joined directly */
- dbg[0]=d=line_deviation(box1,i1, aa[2][3]); if (d >2*sq(1024/4)) Break;
- /* check if lower left and lower left point are joined directly */
- dbg[1]=d=line_deviation(box1, aa[1][3],i1); if (d >2*sq(1024/4)) Break;
-
- if (!hchar) ad=99*ad/100;
- if ( gchar) ad=98*ad/100; // \sc N
- ac=(wchar_t) ']';
- Setac(box1,ac,ad);
- if (ad>=100) return ac;
- break;
- }
-#endif
- // --------- test ocr-a-[] --------------------------------
- if(bc==UNKNOWN)
- for(ad=d=98;dx>5 && dy>7 && 2*dy>3*dx;){ // only for accurate font at the moment
- DBG( wchar_t c_ask='['; )
- if (sdata->holes.num > 2) break; /* tolerant against a tiny hole */
- if (!hchar) ad=97*ad/100;
- if( num_cross(0,dx-1, 0, 0,bp,cs) != 1 ) break;
- if( num_cross(0,dx-1,dy-1,dy-1,bp,cs) != 1 ) break;
- if ( loop(bp,dx-1,dy/2,dx,cs,0,LE)
- +loop(bp, 0,dy/2,dx,cs,0,RI) <= dx/4 ) break; // O
- for(y=dy/8;y<dy-dy/8;y++){
- if( num_cross(0,dx,y,y,bp,cs) != 2 ) break;
- } if (y<dy-dy/8) break;
- if( get_bw((3*x0+5*x1)/8,x1,y0+3*dy/16,y1-3*dy/16,box1->p,cs,1) == 0)
- { Setac(box1,(bc='['),ad);break; }
- if( get_bw(x0,(5*x0+3*x1)/8,y0+3*dy/16,y1-3*dy/16,box1->p,cs,1) == 0)
- { Setac(box1,(bc=']'),ad);break; }
- break;
- }
- // --------- test {} --------------------------------
- for(ad=d=99;dx>2 && dy>5 && 2*dy>3*dx;){
- DBG( wchar_t c_ask='{'; )
- if (sdata->holes.num > 1) Break; /* tolerant against a tiny hole */
- if (!hchar) ad=97*ad/100;
- for(y=0;y<dy;y++){
- if( num_cross(0,dx-1,y,y,bp,cs) != 1 ) break;
- } if (y<dy) Break;
- for(x=0;x<dx/2;x++){
- if( num_cross(dx-1-x,dx-1-x,0,dy-1,bp,cs) != 2 ) break;
- } if (y<dx/2) Break;
- if ( num_cross(dx-1,dx-1,dy/4,dy-1-dy/4,bp,cs) != 0 ) Break;
- if ( num_cross( 0, 0,dy/4,dy-1-dy/4,bp,cs) != 1 ) Break;
- if ( loop(bp,0,dy-1,dx,cs,0,RI)>3*dx/4 ) ad=99*ad/100;
- if ( loop(bp,0, 0,dx,cs,0,RI)>3*dx/4 ) ad=99*ad/100; // <
- if ( loop(bp,0, 0,dy,cs,0,DO)<dy/2-1 ) ad=98*ad/100;
- if ( loop(bp,0,dy-1,dy,cs,0,UP)<dy/2-2 ) ad=98*ad/100; // (
- if ( loop(bp,dx-1,0,dx,cs,0,LE)
- + loop(bp,dx-1,2,dx,cs,0,LE)
- - 2*loop(bp,dx-1,1,dx,cs,0,LE) >=dx/8 ) ad=98*ad/100; // <
- if ( loop(bp,dx-2,dy-1,dy,cs,0,UP)>dy/4 ) Break; // f
- if ( get_bw(x0,x0,y0,y0+dy/4,box1->p,cs,1) == 1
- || get_bw(x0,x0,y1-dy/4,y1,box1->p,cs,1) == 1 ) Break;
- Setac(box1,(bc='{'),ad);Break;
- }
- for(ad=d=99;dx>2 && dy>5 && 2*dy>3*dx;){
- DBG( wchar_t c_ask='}'; )
- if (!hchar) ad=97*ad/100;
- for(y=0;y<dy;y++){
- if( num_cross(0,dx-1,y,y,bp,cs) != 1 ) break;
- } if (y<dy) Break;
- for(x=0;x<dx/2;x++){
- if( num_cross(x,x,0,dy-1,bp,cs) != 2 ) break;
- } if (y<dx/2) Break;
- if ( num_cross( 0, 0,dy/4,dy-1-dy/4,bp,cs) != 0 ) Break;
- if ( num_cross(dx-1,dx-1,dy/4,dy-1-dy/4,bp,cs) != 1 ) Break;
- if ( loop(bp,dx-1,dy-1,dx,cs,0,LE)>3*dx/4 ) {ad=99*ad/100;}
- if ( loop(bp,dx-1, 0,dx,cs,0,LE)>3*dx/4 ) {ad=99*ad/100;} // >
- if ( loop(bp,dx-1, 0,dy,cs,0,DO)<dy/2-1 ) {ad=98*ad/100;}
- if ( loop(bp,dx-1,dy-1,dy,cs,0,UP)<dy/2-2 ) {ad=98*ad/100;} // )
- if ( loop(bp,0,0,dx,cs,0,RI)
- + loop(bp,0,2,dx,cs,0,RI)
- - 2*loop(bp,0,1,dx,cs,0,RI) >=dx/8 ) ad=98*ad/100; // <
- if ( loop(bp,1,dy-1,dy,cs,0,UP)>dy/4 ) Break; // ???
- if ( get_bw(x1,x1,y0,y0+dy/4,box1->p,cs,1) == 1
- || get_bw(x1,x1,y1-dy/4,y1,box1->p,cs,1) == 1 ) Break;
- Setac(box1,(bc='}'),ad);Break;
- }
- return box1->c;
-}
-
-#if 0
-/* ---------- empty prototype function for copy and expand ---------- */
-static wchar_t ocr0_XXX(ocr0_shared_t *sdata){
- struct box *box1=sdata->box1;
- pix *bp=sdata->bp;
- int i,j,d,x,y,i0,i1,i2,i3,hchar=sdata->hchar,gchar=sdata->gchar,
- x0=box1->x0,x1=box1->x1,y0=box1->y0,y1=box1->y1,cs=sdata->cs;
- int dx=x1-x0+1,dy=y1-y0+1, /* size */
- ac,ad; /* tmp-vars */
-
- // --- test XXX ---------------------------------------------------
- return box1->c;
-}
-#endif
-
-
-/* ----------------------- part9 -------------------------------- */
-static wchar_t ocr0p9(ocr0_shared_t *sdata){
- struct box *box1=sdata->box1;
- pix *bp=sdata->bp;
- int i,j,d,x,y,x0=box1->x0,x1=box1->x1,y0=box1->y0,y1=box1->y1;
- int dx=x1-x0+1,dy=y1-y0+1, /* size */
- i1,i2,i3,i4; /* tmp-vars */
- int xa,xb, /* used for store significant points of char */
- dbg[9]={0,0,0,0,0,0,0,0,0}, /* debugging space */
- ya,ad,cs=sdata->cs;
- wchar_t ac,bc=UNKNOWN; // bestletter
- int hchar; // char is higher than e
- int gchar; // char has ink lower than m3
- // --- hchar --- gchar -------------------------
- hchar=0;if( 2*y0<=2*box1->m2-(box1->m2-box1->m1) ) hchar=1;
- gchar=0;if( 2*y1>=2*box1->m3+(box1->m4-box1->m3) ) gchar=1;
- // if the char is slightly moved down correction can be done
- if ( y0<box1->m2 && y1>box1->m3 && 2*y1<box1->m3+box1->m4) // moved
- if( 2*(y0-(y1-box1->m3))<=2*box1->m2-(box1->m2-box1->m1) ) hchar=1;
-
- /* reserved for the future */
- // --- test beta,\3,sz,"s ---------------------------------------------
- if(bc==UNKNOWN && hchar)
- for(ad=d=100;dx>3 && dy>6;){ // min 4x7
- DBG( wchar_t c_ask='S'; )
- if (sdata->holes.num > 2) break; /* tolerant against a tiny hole */
- /* this part is provisorium, should be changed!
- a-\
- | d
- b| /
- | \
- -c /
- */
- if( num_cross(x0 ,x1 ,y0+dy/4 ,y0+dy/4 ,box1->p,cs) != 2
- && num_cross(x0 ,x1 ,y0+dy/4+1,y0+dy/4+1,box1->p,cs) != 2 ) break;
- for(i=1+dy/16,y=y0+dy/8;y<y1-dy/4 && i>0;y++){
- if( y<y1-6*dy/16 ){ if( num_cross(x0 ,x1 ,y,y,box1->p,cs) != 2 ) i--;}
- else { if( num_cross(x0 ,x1 ,y,y,box1->p,cs) < 2 ) i--;}
- if( get_bw(x0,x0+dx/2,y,y,box1->p,cs,1) == 0 ) i--;
- if( y<y1-5*dy/16 )
- if( get_bw(x1-dx/2,x1,y,y,box1->p,cs,1) == 0 ) i--;
- } if( i<=0 ) break;
- // out_x(box1);
-
- for(y=y0+dy/3;y<y1-dy/3;y++){
- i =loop(box1->p,x1,y,dx,cs,0,LE);
- if( i>=dx/8 ) break;
- i+=loop(box1->p,x1-i,y,dx,cs,1,LE);
- if( i>=dx/2 ) break;
- } if( y>=y1-dy/3 ) break;
-
- for(y=y0+dy/5;y<y0+dy/3;y++)
- if( get_bw(x1-dx/6,x1,y,y,box1->p,cs,1) == 1 ) break;
- if( y>=y0+dy/3 ) break;
-
- for(y=y0+dy/2;y<y1;y++)
- if( get_bw(x1-dx/6,x1,y,y,box1->p,cs,1) == 1 ) break;
- if( y>=y1 ) break;
-
- for(y=y1-dy/3;y<y1-dy/8;y++){
- i=loop(box1->p,x1,y,dx,cs,0,LE);
- if( i>dx/4
- && get_bw(x1-dx/8,x1-dx/8,y,y1,box1->p,cs,1) == 1 ) break;
- } if( y<y1-dy/8 ) break; // ~Q
-
- if( box1->m3==0 || 2*y1<box1->m3+box1->m4 )
- if( loop(box1->p,x1,y1, dx,cs,0,LE)==0
- && loop(box1->p,x1,y1-dy/4,dx,cs,0,LE)>dx/8 ) break; // ~R
-
-
- for(x=x0+dx/4;x<x1-dx/4;x++)
- if( num_cross(x,x,y0,y1,box1->p,cs) == 3 ) break;
- if( x>=x1-dx/4 ) break;
-
- i=loop(bp,dx/2,dy-1,dy,cs,0,UP)+dy/64; // Jul00
- for(x=dx/5;x<dx/2;x++)
- if( loop(bp,x,dy-1,dy,cs,0,UP) > i ) break;
- if( x==dx/2 ) break;
-
- x=x0+loop(bp,0,dy/4,dx,cs,0,RI);
- for(;x<x1-dx/3;x++)
- if( get_bw(x,x,y0,y0+dy/4,box1->p,cs,1) == 0 ) break;
- if( x<x1-dx/3 ) break;
-
- if( !gchar )
- // if( num_hole( x0, x1, y0, y1,box1->p,cs,NULL) != 0 ) break;
- if (sdata->holes.num != 0) break;
-
- bc=LATIN_SMALL_LETTER_SHARP_S;
- Setac(box1,(wchar_t)bc,98);
- break;
- }
- // --- test + ------------------------------------------------
- for(ad=d=100;dx>2 && dy>2;){ // min 3x3
- DBG( wchar_t c_ask='+'; )
- if (sdata->holes.num > 1) Break; /* tolerant against a tiny hole */
- xa=(dx+1)/3-1; ya=(dy+1)/3-1;
- xb=(dx+1)/4;
- if( get_bw(x0,x0+xa,y0,y0+ya,box1->p,cs,1) == 1 ) Break;
- if( get_bw(x0,x0+xa,y1-ya,y1,box1->p,cs,1) == 1 ) Break;
- if( get_bw(x1-xb,x1,y0,y0+ya,box1->p,cs,1) == 1 ) Break;
- if( get_bw(x1-xa,x1,y1-ya,y1,box1->p,cs,1) == 1 ) Break;
- for(i=0,y=y0+ya;y<=y1-ya;y++){ // horizontal line
- if( get_bw(x0+dx/9,x1-dx/9,y,y,box1->p,cs,2) == 0 ) { i=y; break; }
- }
- if (3*dx<2*dy) ad=99*ad/100; // ~t
- if( !i ) Break;
- ac=(wchar_t) '+';
- Setac(box1,ac,ad);
- if (ad>=100) return ac;
- break;
- }
- // --- test $ ------------------------------------------------
- for(ad=d=99;dx>3 && dy>5;){ // min 3x4
- DBG( wchar_t c_ask='$'; )
- if (sdata->holes.num != 2) Break;
-
- if( get_bw(x0,x0+dx/5,y0 ,y0+dy/18,box1->p,cs,1) == 1 ) Break;
- if( get_bw(x0,x0+dx/9,y1-dy/23,y1 ,box1->p,cs,1) == 1 ) Break;
- if( get_bw(x1-dx/9,x1,y0 ,y0+dy/18,box1->p,cs,1) == 1 ) Break;
- if( get_bw(x1-dx/5,x1,y1-dy/23,y1 ,box1->p,cs,1) == 1 ) Break;
- if( get_bw(x0,x0+dx/3,y0+dy/3 ,y0+dy/2 ,box1->p,cs,1) != 1 ) Break;
- if( get_bw(x1-dx/3,x1,y1-dy/2 ,y1-dy/3 ,box1->p,cs,1) != 1 ) Break;
- i1=x0+loop(box1->p,x0,y0,dx,cs,0,RI); if( i1<x0+dx/3 || i1>x1-dx/5 ) Break;
- i2=x0+loop(box1->p,x0,y1,dx,cs,0,RI); if( i2<x0+dx/5 || i2>i1 ) Break;
- ad= get_line2(i1,y0,i2,y1,box1->p,cs,100)*ad/100;
- // check upper left and lower right half circle, $
- for (x=0,i3=y=0;y<dy/3;y++)
- if( num_cross(x0,x1,y0+dy/2-y,y0+dy/2-y,box1->p,cs) == 2 ) {
- i = loop(box1->p,x0,y0+dy/2-y,dx,cs,0,RI);
- if (i>x) { x=i; i3=y0+dy/2-y; }
- } if (x<=dx/4) Break;
- for (x=0,i4=y=0;y<dy/3;y++)
- if( num_cross(x0,x1,y0+dy/2+y,y0+dy/2+y,box1->p,cs) == 2 ) {
- i = loop(box1->p,x0,y0+dy/2+y,dx,cs,0,RI);
- if (i>x) { x=i; i4=y0+dy/2+y; }
- } if (x<=dx/4) Break;
- if (ad<95) Break;
- ac=(wchar_t) '$';
- Setac(box1,ac,ad);
- if (ad>=100) return ac;
- break;
- }
- // --- test & ------------------------------------------------
- for(ad=d=99;dx>3 && dy>4;){ /* 4x6 font */
- DBG( wchar_t c_ask='&'; )
- if (sdata->holes.num != 2) Break;
- if( get_bw(x1-dx/9,x1,y0,y0+dy/4,box1->p,cs,1) == 1 ) Break; // g
- if( loop(bp,dx/2,0,dy,cs,0,DO)>dy/2) Break;
- i1=loop(bp,0,dy/8 ,dx,cs,0,RI); if (i1>dx/2) Break;
- i =loop(bp,0,dy/4 ,dx,cs,0,RI); if (i1>dx/2) Break; if (i<i1) i1=i;
- i3=loop(bp,0,dy-dy/4 ,dx,cs,0,RI); if (i3>dx/2) Break;
- i =loop(bp,0,dy-dy/4-1,dx,cs,0,RI); if (i3>dx/2) Break; if (i<i3) i3=i;
- if (i3>i1) Break;
- for( i2=0, y=dy/4; y<=dy/2+1; y++ ){
- i =loop(bp,0,y,dx,cs,0,RI); if( i>i2 ) i2=i;
- }
- if(2*i2-i1-i3<1) Break;
- // if( num_hole(x0,x1 ,y0,y1,box1->p,cs,NULL)!=2 ) Break;
- if( num_hole(x0,x1-dx/4,y0,y1,box1->p,cs,NULL)!=2 ) Break;
- if( num_cross(dx-1,dx-1,dy/4,dy-1,bp,cs) < 1 ) Break;
- for( x=dx-1; x>=dx/2; x-- ){
- if( num_cross(x,x,dy/4,dy-1,bp,cs) > 1 ) break;
- } if( x<=3*dx/4 && x<dx-2) Break;
- if( num_cross(0,dx-1,dy-1-dy/4,dy-1-dy/4,bp,cs) > 3 ) { // glued ah
- if (dy>15) { Break; } else ad=96*ad/100;
- }
- if (!hchar) ad=98*ad/100;
- bc=(wchar_t) '&';
- Setac(box1,bc,ad);
- if (ad>=100) return bc;
- break;
- }
- // --- test \it & like \epsilon\tau ------------------------------
- if(bc==UNKNOWN)
- for(ad=d=100;dx>7 && dy>7;){
- DBG( wchar_t c_ask='&'; )
- if (sdata->holes.num > 2) break; /* tolerant against a tiny hole */
- if( num_cross(0,dx-1, dy/4, dy/4,bp,cs) != 3 ) break;
- if( num_cross(0,dx-1, dy/2, dy/2,bp,cs) != 4 ) break;
- if( num_cross(dx/2,dx-1,dy/2, dy/2,bp,cs) != 2 ) break;
- if( num_cross(0,dx-1,3*dy/4,3*dy/4,bp,cs) != 2 ) break;
- if( num_cross(0,dx-1, dy-1, dy-1,bp,cs) != 1 ) break;
- if( num_cross( 0, 0,0,dy-1,bp,cs) != 1 ) break;
- if( num_cross( dx/3, dx/3,0,dy-1,bp,cs) != 4 ) break;
- if( num_cross(13*dx/16,13*dx/16,0,dy/8,bp,cs) != 0 ) break;
- if( num_cross(4*dx/8,4*dx/8,dy-dy/4,dy-1,bp,cs) != 1 ) break;
- if( num_cross(3*dx/8,3*dx/8,dy-dy/4,dy-1,bp,cs) != 1 ) break;
- if( num_cross(5*dx/8,5*dx/8,dy-dy/4,dy-1,bp,cs) != 1 ) break;
- if( num_hole(x0 ,(x0+x1)/2,y0, y1,box1->p,cs,NULL) != 1 ) break;
- if( num_hole(x0+dx/8,x1-dx/4,y0,y1-dy/4,box1->p,cs,NULL) != 1 ) break;
- ac=(wchar_t) '&';
- Setac(box1,ac,ad);
- if (ad>=100) return ac;
- break;
- }
- // --- test ? ---------------------------------------------------
- for(ad=d=98;dx>2 && dy>5;){ // min 3x(4+2)
- DBG( wchar_t c_ask='?'; )
- if (sdata->holes.num > 1) Break; /* tolerant against a tiny hole */
- if ( num_cross(x0, x1, y0, y0, box1->p, cs) !=1 ) Break; // ~?
- if ( num_cross(x0, x1, y1, y1, box1->p, cs) > 1 ) Break; // ~?
- for(y=y0;y<y1;y++) // new y1
- if( get_bw(x0, x1, y, y,box1->p,cs,1) != 1 ) break; // lower end
- if (2*y<y0+y1) Break;
- i1=y1;
- if (y==y1 && box1->m4) { // probably lower dot not catched in box?
- if (get_bw(x0+1,x1-1,y1+1,box1->m4,box1->p,cs,1) != 1 ) Break;
- i1=box1->m4;
- for(;i1>y1;i1--) // new y1
- if( get_bw(x0, x1,i1,i1,box1->p,cs,1) == 1 ) break; // lower dot
- }
- y--; i=y-y0+1; // new dy
- for (y=0;y<dy/2;y++)
- if( num_cross(x0, x1, y0+y, y0+y, box1->p, cs) == 2 ) break;
- if (y==dy/2) Break;
- // if( num_hole( x0, x1, y0, y1, box1->p,cs,NULL) > 0 ) Break;
- if (sdata->holes.num > 0) Break;
- for(y=y0+dy/2;y<=i1;y++)
- if( get_bw(x0,x1,y,y,box1->p,cs,1) == 0 ) break;
- if( y==i1 ) Break;
- for( ;y<=i1;y++)
- if( get_bw(x0,x1,y,y,box1->p,cs,1) == 1 ) break;
- if( get_bw(x0,x1,y,y,box1->p,cs,1) != 1 ) Break;
- if( get_bw(x0+7*dx/8,x1,y,i1,box1->p,cs,1) == 1 ) Break; // broken thin 2
- bc='?';
- Setac(box1,(wchar_t)bc,98);
- return bc;
- }
- // --- test !| ---------------------------------------------------
- for(ad=d=99; dy>4 && dy>2*dx;){ // min 3x4
- DBG( wchar_t c_ask='!'; )
- if (sdata->holes.num > 1) Break; /* tolerant against a tiny hole */
- // measure thickness
- if (num_cross(x0,x1,y0 ,y0 ,box1->p,cs)!=1) Break;
- if (num_cross(x0,x1,y0+dy/2,y0+dy/2,box1->p,cs)!=1) Break;
- for(y=y0;y<y1;y++) // new y1
- if( get_bw(x0, x1, y, y,box1->p,cs,1) != 1 ) break; // lower end
- if (2*y<y0+y1) Break;
- if (y==y1 && y>box1->m3-dy/8) ad=ad*97/100; /* missing dot? */
- i1=y1;
- if (y==y1 && box1->m4) { // probably lower dot not catched in box?
- if ((dx>2 && get_bw(x0+1,x1-1,y1+1,box1->m4,box1->p,cs,1) == 1)
- || (dx<3 && get_bw(x0 ,x1 ,y1+1,box1->m4,box1->p,cs,1) == 1 )) {
- i1=box1->m4;
- for(;i1>y1;i1--) // new y1
- if( get_bw(x0, x1,i1,i1,box1->p,cs,1) == 1 ) break; // lower dot
- }
- } i2=i1;
- for( i1=0,y=y0;y<=i2;y++){
- i=num_cross(x0,x1,y,y,box1->p,cs); if(i>1) break;
- if(i==0 && i1==0) i1=y;
- } if(y<=i2 || i1==0 || i1<y0+dy/2) Break;
-
- if( loop(bp,dx-1,dy/8,dx,cs,0,LE)
- -loop(bp,dx-1, 0,dx,cs,0,LE)>dx/4+1 ) Break; // f
-
- if (!hchar) ad=96*ad/100;
- Setac(box1,(wchar_t)'!',ad);
- break;
- }
- // --- test * five egdes (jagges? beames?) what is the right english word? ----
- for(ad=d=99;dx>2 && dy>4;){
- DBG( wchar_t c_ask='*'; )
- if (sdata->holes.num > 0) Break; /* tolerant against a tiny hole */
- if( num_cross(0,dx-1, 0,dy-1,bp,cs) != 1
- && num_cross(0,dx-1, 1,dy-2,bp,cs) != 1 ) Break;
- if( num_cross(0,dx-1,dy-1,dy-1,bp,cs) != 2
- && num_cross(0,dx-1,dy-2,dy-2,bp,cs) != 2 ) Break;
- x=dx/2;y=(6*dy+8)/16; // center point 6/8=6/2^3 rounded
- /* upwarts from center */
- dbg[0]=i=get_line2(x,y,x ,0,bp,cs,100); if(i<95) Break;
- if (dx<8) /* be exact on small fonts, where get_line2 returns 100 (ToDo change) */
- if (get_bw(x,x,0,y,bp,cs,2)==2) Break;
- /* horizontal */
- dbg[1]=i=get_line2(0,y,dx-1,y,bp,cs,100); if(i<95) Break;
- if (dy<8)
- if (get_bw(0,dx-1,y ,y ,bp,cs,2)==2
- && get_bw(0,dx-1,y+1,y+1,bp,cs,2)==2) Break;
- /* down (right) */
- i=get_line2(x,y,(5*dx+4)/8,dy-1,bp,cs,100);
- j=get_line2(x,y,(6*dx+4)/8,dy-1,bp,cs,100); if(j>i) dbg[2]=i=j;
- if(i<95) Break;
- /* down (left) */
- dbg[3]=i=get_line2(x, y,(2*dx+4)/8,dy-1,bp,cs,100); if(i<95) Break; // straight up
- /* check for lower gap at bottom */
- dbg[4]=i=get_bw( x, x,dy-1-dy/8,dy-1,bp,cs,1); if(i==1) Break;
- dbg[5]=i=get_line2( dx/4,dy/4, 0,0,bp,cs,101); if(i<95) Break; // upper left gap
- dbg[6]=i=get_line2(dx-1-dx/4,dy/4,dx-1,0,bp,cs,101); if(i<95) Break; // upper right gap
- MSG(fprintf(stderr,"%d %d %d %d %d %d %d",dbg[0],dbg[1],dbg[2],dbg[3],dbg[4],dbg[5],dbg[6]);)
- Setac(box1,(wchar_t)'*',ad);
- break;
- }
- // --- test * six egdes (jagges? beames?) what is the right english word? ----
- for(ad=d=100;dx>4 && dy>4;){
- DBG( wchar_t c_ask='*'; )
- if (sdata->holes.num > 0) Break; /* tolerant against a tiny hole */
- if( num_cross(0,dx-1, dy/8, dy/8,bp,cs) != 3
- && num_cross(0,dx-1, 1+dy/8, 1+dy/8,bp,cs) != 3) Break;
- if( num_cross(0,dx-1,dy-2-dy/8,dy-2-dy/8,bp,cs) != 3) Break;
- if( num_cross(0 , 0, 0,dy-1,bp,cs) != 2) Break;
- if( num_cross(dx-1,dx-1, 0,dy-1,bp,cs) != 2) Break;
- if( num_cross(0,dx-1,dy/2,dy/2,bp,cs) != 1) Break;
- if( num_cross( 0 ,dx/8,dy/2,dy/2,bp,cs) != 0) Break;
- if( num_cross(dx-1-dx/8,dx-1,dy/2,dy/2,bp,cs) != 0) Break;
- if (dx>5) {
- dbg[0]=i=get_line2(0,dy-2-dy/8,dx-1,dy/8,bp,cs,100); if(i<95) Break; // black upwarts beam
- dbg[1]=i=get_line2(0,dy/8,dx-1,dy-2-dy/8,bp,cs,100); if(i<95) Break; // black downwards beam
- /* check vertical line */
- dbg[2]=i=get_line2(dx/2,0,dx/2, dy-1,bp,cs,100); if(i<95) Break;
- }
- MSG(fprintf(stderr,"%d %d %d %d %d %d",dbg[0],dbg[1],dbg[2],dbg[3],dbg[4],dbg[5]);)
- Setac(box1,(wchar_t)'*',98);
- break;
- }
- // --- test @ - a popular char should be detectable! added in version v0.2.4a5
- if(bc==UNKNOWN)
- for(ad=d=99;dx>5 && dy>7;){
- DBG( wchar_t c_ask='@'; )
- if (sdata->holes.num > 3) Break; /* tolerant against a tiny hole */
- if (loop(bp, 0,dy/2,dx,cs,0,RI)>dx/4) Break;
- if (loop(bp,dx-1,dy/2,dx,cs,0,LE)>dx/4) Break;
- if (loop(bp,dx/2,dy-1,dy,cs,0,UP)>dx/8) Break;
- if (loop(bp,dx/2, 0,dy,cs,0,DO)>dx/8) Break;
- /* ..@@@@..<- 8*10 example
- .@@..@@.
- @@....@@
- @@..@@@@<
- @@.@@.@@
- @@.@@.@@
- @@..@@@.
- @@......
- .@@...@@
- ..@@@@@.<- */
- x=6*dx/16;
- y=dy/2;
- i=num_cross(0,dx-1,y,y,bp,cs);
- if (i<3 || i>4) Break;
- if( i != 4 && dx>8 ) ad=98*ad/100;
-
- i=num_cross(x,x,0,dy-1,bp,cs); if (i<2) Break;
- if (i!=4) { j=num_cross(x+1,x+1,0,dy-1,bp,cs);
- if (abs(4-j)<abs(i-4)) i=j; }
- if (i!=4) { j=num_cross(x+2,x+2,0,dy-1,bp,cs);
- if (abs(4-j)<abs(i-4)) i=j; }
- if (i<3 || i>4) Break;
- if (i!=4) ad=97*ad/100;
- if( num_cross(0, x,y,y,bp,cs) != 2 ) Break;
- if( num_cross(x,dx-1,y,y,bp,cs) != 2 ) Break;
- if( num_cross(x,x,0, y,bp,cs) != 2 ) Break;
- if( num_cross(x,x,y,dy-1,bp,cs) != 2 ) Break;
- if (dx>7) {
- // if( num_hole(x0,x1,y0,y1,box1->p,cs,NULL) != 1 ) Break;
- if (sdata->holes.num != 1) Break;
- if( num_hole(x0+dx/8,x1-3*dx/16,y0+dy/8,y1-dy/8,box1->p,cs,NULL) != 1 ) Break;
- }
- Setac(box1,(wchar_t)'@',ad);
- break;
- }
- // --- test paragraph v0.2.6
- if(bc==UNKNOWN && hchar)
- for(ad=d=100;dx>4 && dy>15;){
- DBG( wchar_t c_ask='$'; )
- if (sdata->holes.num > 3) break; /* tolerant against a tiny hole */
- if( get_bw( 0,dx/2,3*dy/4,3*dy/4,bp,cs,1) == 1 ) break;
- if( get_bw(3*dx/4,dx-1,3*dy/4,3*dy/4,bp,cs,1) == 0 ) break;
- if( get_bw( 0,dx/4, dy/4, dy/4,bp,cs,1) == 0 ) break;
- if( get_bw( dx/2,dx-1, dy/4, dy/4,bp,cs,1) == 1 ) break;
- if( get_bw(dx/2,dx/2, 0, dy/4,bp,cs,1) == 0 ) break;
- if( get_bw(dx/2,dx/2,dy-1-dy/4, dy-1,bp,cs,1) == 0 ) break;
- if( num_cross(dx/2,dx/2,0,dy-1,bp,cs) != 4 ) break;
- if( num_cross(x0,x1,y0+dy/2,y0+dy/2,box1->p,cs) != 2 ) break;
- if( num_hole( x0,x1,y0+dy/4,y1-dy/4,box1->p,cs,NULL) != 1 ) break;
- Setac(box1,SECTION_SIGN,96);
- break; // paragraph=0xA7=167
- }
-
- return bc;
-}
-
-/* ----------------------- partx -------------------------------- */
-static wchar_t ocr0px(ocr0_shared_t *sdata){
- struct box *box1=sdata->box1;
- pix *bp=sdata->bp;
- int i,j,d,x,y,x0=box1->x0,x1=box1->x1,y0=box1->y0,y1=box1->y1;
- int dx=x1-x0+1,dy=y1-y0+1, /* size */
- i1,i2,i3,i4,j1,cs=sdata->cs; /* tmp-vars */
- int ya,ad; /* used for store significant points of char */
- wchar_t ac,bc=UNKNOWN; // bestletter
- int hchar; // char is higher than e
- int gchar; // char has ink lower than m3
- // --- hchar --- gchar -------------------------
- hchar=0;if( 2*y0<=2*box1->m2-(box1->m2-box1->m1) ) hchar=1;
- gchar=0;if( 2*y1>=2*box1->m3+(box1->m4-box1->m3) ) gchar=1;
- // if the char is slightly moved down correction can be done
- if ( y0<box1->m2 && y1>box1->m3 && 2*y1<box1->m3+box1->m4) // moved
- if( 2*(y0-(y1-box1->m3))<=2*box1->m2-(box1->m2-box1->m1) ) hchar=1;
-
- /* reserved for special chars, to test at the end */
- // --- test 'ff' ---------------------------------------------------
- // ToDo: better check and call test 'f' and 'f' with subboxes
- if( bc==UNKNOWN )
- for(ad=98;dx>4 && dy>6;){ // Dec00 body copied from H
- DBG( wchar_t c_ask='f'; )
- if (sdata->holes.num > 2) break; /* tolerant against a tiny hole */
- if( num_cross(0,dx-1, dy/4 , dy/4 ,bp,cs) != 2
- && num_cross(0,dx-1,3*dy/16,3*dy/16,bp,cs) != 2 ) break;
- if( num_cross(0,dx-1,3*dy/4 ,3*dy/4 ,bp,cs) != 2
- && num_cross(0,dx-1,3*dy/4+1,3*dy/4+1,bp,cs) != 2 ) break;
- if( loop(bp,0 ,dy/8,dx,cs,0,RI)
- + loop(bp,dx-1,dy/8,dx,cs,0,LE)>dx/2 ) break; // ~A
- for( j1=0,i=1,y=y0+dy/10; y<y1-dy/10 && i; y++ ) // 2 vertikal lines
- { j=loop(box1->p,x0 ,y,dx,cs,0,RI)
- +loop(box1->p,x1 ,y,dx,cs,0,LE);
- if( j>10*dx/16 ) i=0; if ( j>j1 ) j1=j; }
- if( !i ) break;
- for( x=dx/4; x<dx/2; x++ ){ // lower gap
- y=loop(bp,x ,dy-1,dy,cs,0,UP);
- if ( y > 3*dy/8 ) break;
- if ( 10*y > dy ){ /* italic */
- i=loop(bp,x ,dy-y,dx,cs,0,RI);
- if( i>1 && y+loop(bp,x+i-1,dy-y,dy,cs,0,UP)>3*dy/8 ) break;
- }
- } if( x>=dx/2 ) break;
- x=loop(box1->p,x0 ,y1-dy/8,dx,cs,0,RI)
- +loop(box1->p,x1 ,y1-dy/8,dx,cs,0,LE);
- for( i=1,y=dy/4; y<dy-1-dy/4 && i; y++ ) // max - min width
- { j=loop(bp,0 ,y,dx,cs,0,RI)
- +loop(bp,dx-1,y,dx,cs,0,LE); if( j-x>dx/5 ) i=0; }
- if( !i ) break; // ~K Jul00
- for( i=0,ya=y=y0+dy/4; y<y1-dy/3; y++ ) // horizontal line
- { j=loop(box1->p,x0 ,y,dx,cs,0,RI);
- j=loop(box1->p,x0+j,y,dx,cs,1,RI); if( j>i ) { i=j; ya=y; } }
- if( i<=dx/2 ) break; ya-=y0;
- if( num_cross(0,dx-1,ya ,ya ,bp,cs) != 1
- && num_cross(0,dx-1,ya+1,ya+1,bp,cs) != 1 ) break; /* Dec00 */
- for( y=ya; y<dy-dy/4; y++ ) // ~M Dec00
- if( num_cross(0,dx-1,y ,y ,bp,cs) > 2
- && num_cross(0,dx-1,y+1,y+1,bp,cs) > 2 ) break;
- if ( y<dy-dy/4 ) break;
- for(i=1,x=x0+dx/2;x<=x1-dx/4 && i;x++){
- if( get_bw( x, x,y0 ,y0+dy/4,box1->p,cs,1) == 0 ) i=0;
- } if( !i ) break;
- for(i=1,x=x0+dx/4;x<=x1-dx/4 && i;x++){
- if( get_bw( x, x,y1-dy/4,y1 ,box1->p,cs,1) == 0 ) i=0;
- } if( i ) break;
- for(i=1,x=x0+dx/4;x<=x1-dx/4 && i;x++){
- if( num_cross(x,x,y0+dy/8,y1-dy/8, box1->p,cs) == 1 ) i=0;
- } if( i ) break;
- for(i=1,y=y0;y<=y0+dy/4 && i;y++){
- if( num_cross(x0,x1,y,y, box1->p,cs) == 2 ) i=0;
- } if( i ) break;
- for(i=1,y=y1-dy/4;y<=y1 && i;y++){
- if( num_cross(x0,x1,y,y, box1->p,cs) == 2 ) i=0;
- } if( i ) break;
- if( num_cross(x0 ,x0+dx/8 ,y0+dy/8 ,y0 ,box1->p,cs) != 0 ) ad=96*ad/100;
- if( get_bw(x1-dx/8, x1 , y0, y0+dy/8,box1->p,cs,1) != 1 ) break;
- if( get_bw(x0 , x0+dx/8, y1-dy/8, y1,box1->p,cs,1) != 1 ) break;
- i1=loop(bp,dx-1, dy/4,dx,cs,0,LE); if(i1>dx/2) break;
- i2=loop(bp,dx-1, dy/2,dx,cs,0,LE); if(i2<i1-dx/4 || i2>i1+dx/8) break;
- i3=loop(bp,dx-1,dy-1-dy/4,dx,cs,0,LE); if(i3<i2-dx/4 || i3>i2+dx/8) break;
- if(abs(i1+i3-2*i2)>dx/16+1) break;
- if( num_hole(x0,x1,y0+dy/4,y1,box1->p,cs,NULL) != 0 ) break;
- if (!hchar) ad=96*ad/100;
- if (!gchar) ad=99*ad/100;
- ac=LATIN_SMALL_LIGATURE_FF;
- Setac(box1,ac,ad);
- break;
- }
- // --- test ae ---------------------------------------------------
- if( bc==UNKNOWN )
- for(ad=98;dx>4 && dy>6;){ // provisorium
- DBG( wchar_t c_ask=LATIN_SMALL_LETTER_AE; )
- if (sdata->holes.num > 4) Break; /* tolerant against a tiny hole */
- if( num_cross( dx/4,dx-1,3*dy/16,3*dy/16,bp,cs) != 2
- && num_cross(dx-1-dx/4,dx-1,3*dy/16,3*dy/16,bp,cs) != 1 ) Break;
- if( num_cross(0,dx-1,3*dy/ 4,3*dy/ 4,bp,cs) < 2 ) Break;
- if( num_cross(0,dx-1, 0, dy-1,bp,cs) < 3 ) Break;
- if( num_cross(dx-1,0, 0, dy-1,bp,cs) < 3 ) Break;
- if( num_cross(0,dx-1, dy/16, dy/16,bp,cs) < 2 )
- if( num_cross(0,dx-1,1+dy/16,1+dy/16,bp,cs) < 2 ) Break;
- if( num_cross(0,dx-1,dy-1-dy/16,dy-1-dy/16,bp,cs) < 2 ) Break;
- for( x=0,i2=y=dy/4; y<3*dy/4; y++ ){
- j=loop(bp,0,y,dx,cs,0,RI); if(j>x) { i2=y; x=j; }
- } if( x<dx/4 || x>3*dx/4 ) Break;
- for( x=0,i4=y=dy/4; y<3*dy/4; y++ ){
- j=loop(bp,dx-1,y,dx,cs,0,LE); if(j>x) { i4=y; x=j; }
- } if( x<dx/4 || x>3*dx/4 ) Break;
- for( x=0,i4=y=dy/8; y<3*dy/4; y++ ){
- j=loop(bp,dx-1 ,y,dx,cs,0,LE);
- j=loop(bp,dx-1-j,y,dx,cs,1,LE);
- if(j>x) { i4=y; x=j; }
- } if( x<dx/4 ) Break;
- if( num_hole(x0,x0+3*dx/4,y0+dy/4,y1,box1->p,cs,NULL) != 1 ) Break;
- if( num_hole(x0+dx/2-1,x1,y0,y1-dy/4,box1->p,cs,NULL) != 1 ) Break;
- ac=LATIN_SMALL_LETTER_AE;
- Setac(box1,ac,ad);
- if (ad>=100) return ac;
- break;
-
- }
- // --- test AE ---------------------------------------------------
- if( bc==UNKNOWN )
- for(ad=98;dx>5 && dy>6;){ // provisorium
- DBG( wchar_t c_ask=LATIN_CAPITAL_LETTER_AE; )
- if (sdata->holes.num > 2) Break; /* tolerant against a tiny hole */
- if( num_cross(0,dx-1,3*dy/16,3*dy/16,bp,cs) < 2 ) Break;
- if( num_cross(0,dx-1,3*dy/ 4,3*dy/ 4,bp,cs) < 2 ) Break;
- if( num_cross(0,dx-1, 0, dy-1,bp,cs) < 3 ) Break;
- if( num_cross(0,dx-1, dy/16, dy/16,bp,cs) != 1
- && num_cross(0,dx-1, dy/32, dy/32,bp,cs) != 1
- && num_cross(0,dx-1, 0, 0,bp,cs) != 1 ) Break;
- // check for upper horizontal line
- j=loop(bp,dx-1 ,0,dx,cs,0,LE); x=j;
- j=loop(bp,dx-1-j,0,dx,cs,1,LE);
- i=loop(bp,dx-1 ,1,dx,cs,0,LE); if (i<x) x=i;
- i=loop(bp,dx-1-i,1,dx,cs,1,LE);
- if (i>j) j=i;
- if (x>dx/8) Break;
- if (j<dx/4) Break;
- for( x=dx,i1=i3=0,i2=y=dy/4; y<3*dy/4; y++ ){
- j=loop(bp, 0,y,dx,cs,0,RI); if(j>x) break; x=j;
- j=loop(bp, j,y,dx,cs,1,RI); if(j>i1) { i1=j; i2=y; }
- j=loop(bp,dx-1 ,y,dx,cs,0,LE);
- j=loop(bp,dx-1-j,y,dx,cs,1,LE); if(j>i3) { i3=j; i4=y; }
- } if( y<3*dy/4 || i1<dx/4-1 || i3<dx/4-1) Break;
- for( i1=i3=0,y=0; y<dy/8; y++ ){
- j=loop(bp,dx-1 , y,dx,cs,0,LE);
- j=loop(bp,dx-1-j, y,dx,cs,1,LE); if(j>i1) { i1=j; }
- j=loop(bp,dx-1 ,dy-1-y,dx,cs,0,LE);
- j=loop(bp,dx-1-j,dy-1-y,dx,cs,1,LE); if(j>i3) { i3=j; }
- } if( i1<=dx/4 || i3<=dx/4 ) Break;
- for( x=dx-1-dx/8; x>dx/2; x-- ){ // look for right the E
- if( num_cross(x,x, 0,dy-1,bp,cs) == 3 )
- if( num_cross(x,x, 0,dy/4,bp,cs) == 1 )
- if( num_cross(x-1,dx-1-dx/8,3*dy/4,3*dy/4,bp,cs) == 0 )
- if( num_cross(x,x,3*dy/4,dy-1,bp,cs) == 1 ) break;
- } if (x<=dx/2) Break; // not found
- if (sdata->holes.num != 1) Break;
- if( num_hole(x0,x0+3*dx/4,y0,y1-dy/4,box1->p,cs,NULL) != 1 ) Break;
- // if( num_hole(x0, x1,y0,y1 ,box1->p,cs,NULL) != 1 ) Break;
- ac=LATIN_CAPITAL_LETTER_AE;
- Setac(box1,ac,ad);
- if (ad>=100) return ac;
- break;
-
- }
- // --- test /0 /o /O O_WITH_STROKE -----------------------------------------
- for(ad=99;dx>4 && dy>4;){ // provisorium
- DBG( wchar_t c_ask=LATIN_SMALL_LETTER_O_WITH_STROKE; )
- if (sdata->holes.num > 3) Break; /* tolerant against a tiny hole */
- if( num_cross( 0,dx-1,dy/2,dy/2,bp,cs) != 3 ) Break;
- if( num_cross(dx/2,dx/2, 0,dy-1,bp,cs) != 3 ) Break;
- if (loop(bp,dx-1,3*dy/8,dx,cs,0,RI)>dx/8) Break;
- if (loop(bp, 0,5*dy/8,dx,cs,0,RI)>dx/8) Break;
- if( num_cross( 0,dx-1, 0, 0,bp,cs) > 2 ) Break;
- if( num_cross(dx/4,dx-1, 0, 0,bp,cs) > 2 ) Break;
- if( num_cross( 0,dx-1,dy-1,dy-1,bp,cs) > 2 ) Break;
- if( num_cross( 0,3*dx/4,dy-1,dy-1,bp,cs) > 2 ) Break;
- if( num_cross( 0, 0, 0,dy-1,bp,cs) > 2 ) Break;
- if( num_cross(dx-1,dx-1, 0,dy-1,bp,cs) > 2 ) Break;
- if( num_cross( 0, 0,dy/4,dy-1,bp,cs) > 2 ) Break;
- if( num_cross(dx-1,dx-1, 0,3*dy/4,bp,cs) > 2 ) Break;
- i1 =loop(bp,dx-1 , 0,dx,cs,0,LE); if( i1>dx/8 ) Break;
- i1+=loop(bp,dx-1-i1, 0,dx,cs,1,LE); if( i1>dx/3 ) Break; i1=dx-1-i1;
- i2 =loop(bp, 0,dy-1,dx,cs,0,RI); if( i2>dx/8 ) Break;
- for(y=1;y<dy-1;y++){
- x=i1+y*(i2-i1)/dy-dx/8; if(x<0)x=0;
- j=loop(bp,x,y,dx,cs,0,RI); if( j>3*dx/16 ) break;
- } if( y<dy-1 ) Break;
- if( num_cross( 0 ,dx/4,dy/2,dy/2,bp,cs) != 1 ) Break;
- if( num_cross(dx-1-dx/4,dx-1,dy/2,dy/2,bp,cs) != 1 ) Break;
- if( num_cross(dx/4,dx-1-dx/4,dy/2,dy/2,bp,cs) != 1 ) Break;
- if (sdata->holes.num != 2) Break;
- // if( num_hole(x0,x1,y0,y1,box1->p,cs,NULL) != 2 ) Break;
-
- if ( hchar && 2*y0<box1->m1+box1->m2 )
- ac=LATIN_CAPITAL_LETTER_O_WITH_STROKE;
- else ac=LATIN_SMALL_LETTER_O_WITH_STROKE;
- Setac(box1,ac,ad);
- if (ad>=100) return ac;
- break;
-
- }
- // --- test /c /C C_WITH_STROKE CENT_SIGN --------------------------
- // here only the version with a continuously vertical line (not broken variant)
- if( bc==UNKNOWN )
- for(ad=98;dx>4 && dy>4;){ // provisorium
- DBG( wchar_t c_ask=CENT_SIGN; )
- if (sdata->holes.num > 2) Break; /* tolerant against a tiny hole */
- if( num_cross( 0,dx-1,dy/2,dy/2,bp,cs) != 2 ) Break;
- if( num_cross(0,dx-1-dx/4,dy/2,dy/2,bp,cs) != 2 ) Break;
- if( num_cross(dx/2,dx/2, 0,dy-1,bp,cs) != 3 ) Break;
- if( num_cross( 0,dx-1, 0, 0,bp,cs) > 2 ) Break;
- if( num_cross(dx/4,dx-1, 0, 0,bp,cs) > 2 ) Break;
- if( num_cross( 0,dx-1,dy-1,dy-1,bp,cs) > 2 ) Break;
- if( num_cross( 0,3*dx/4,dy-1,dy-1,bp,cs) > 2 ) Break;
- if( num_cross( 0, 0, 0,dy-1,bp,cs) > 2 ) Break;
- if( num_cross(dx-1,dx-1, 0,dy-1,bp,cs) > 3 ) Break;
- if( num_cross( 0, 0,dy/4,dy-1,bp,cs) > 2 ) Break;
- if( num_cross(dx-1,dx-1, 0,3*dy/4,bp,cs) > 3 ) Break;
- i1 =loop(bp,dx-1 , 0,dx,cs,0,LE); if( i1>dx/4 ) Break;
- i1+=loop(bp,dx-1-i1, 0,dx,cs,1,LE); if( i1>dx/4 ) Break; i1=dx-1-i1;
- i2 =loop(bp, 0,dy-1,dx,cs,0,RI); if( i2>dx/4 ) Break;
- for(y=0;y<dy;y++){
- x=i1+y*(i2-i1)/dy; if(x>dx/16+1) x-=dx/16+1;
- j=loop(bp,x,y,dx,cs,0,RI); // fprintf(stderr,"\n x=%d j=%d",x,j);
- if( j>(dx+4)/8 ) ad=96*ad/100;
- if( j>(dx+2)/4 ) break;
- } if( y<dy ) Break;
- if( num_cross( 0 ,dx/4,dy/2,dy/2,bp,cs) != 1 ) Break;
- if( num_cross(dx-1-dx/4,dx-1,dy/2,dy/2,bp,cs) != 0 ) Break;
- if( num_cross(dx/4,dx-1-dx/4,dy/2,dy/2,bp,cs) != 1 ) Break;
- // if( num_hole(x0,x1,y0,y1,box1->p,cs,NULL) != 1 ) Break;
- if (sdata->holes.num != 1) Break;
-
- ac=CENT_SIGN;
- Setac(box1,ac,ad);
- if (ad>=100) return ac;
- break;
-
- }
- // --- test EURO_CURRENCY_SIGN -----------------------------------------
- if( bc==UNKNOWN )
- for(ad=98;dx>4 && dy>6;){ // provisorium
- DBG( wchar_t c_ask='&'; )
- if (sdata->holes.num > 1) break; /* tolerant against a tiny hole */
- if( num_cross(dx/2,dx/2, 0,dy-1,bp,cs) != 4 ) break;
- if( num_cross( 0,dx-1, 0, 0,bp,cs) != 1 ) break;
- if( num_cross( 0,dx-1,dy-1,dy-1,bp,cs) != 1 ) break;
- if( num_cross( 0,dx-1,dy/2,dy/2,bp,cs) != 1 ) break;
- for(i=0,y=dy/4;y<dy-dy/4-1;y++){ // check if no gap on left side
- x=loop(bp,0,y,dx,cs,0,RI); if( x>dx/4 ) break;
- j=loop(bp,x,y,dx,cs,1,RI); if( j>i ) i=j;
- } if( y<dy-dy/4-1 || i<dx/2 ) break;
- for(y=dy/4;y<dy-dy/4-1;y++){ // check for right horizontal gap
- x=loop(bp,dx-1,y,dx,cs,0,LE); if( x>dx/2 ) break;
- } if( y>=dy-dy/4-1 ) break;
- // if( num_hole(x0,x1,y0,y1,box1->p,cs,NULL) != 0 ) break;
- if (sdata->holes.num != 0) break;
- ac=EURO_CURRENCY_SIGN;
- Setac(box1,ac,ad);
- if (ad>=100) return ac;
- break;
- }
- // --- test LETTER_C_WITH_CEDILLA ---------------------------------------------------
- if (bc==UNKNOWN)
- if (gchar)
- for(ad=98;dx>3 && dy>6;){ // provisorium
- DBG( wchar_t c_ask='c'; )
- if (sdata->holes.num > 0) break; /* no tolerant against tiny holes */
- j=loop(bp,dx-1,dy/16 ,dy,cs,0,LE);
- x=loop(bp,dx-1,dy/16+1,dy,cs,0,LE); if (x<j) j=x;
- if (3*x>dx) Break; // ~4 ocr-b
- if( num_cross(0,dx-1,3*dy/16,3*dy/16,bp,cs) > 2 ) break;
- if( num_cross(0,dx-1, 0, dy-1,bp,cs) < 2 ) break;
- if( num_cross(0,dx-1, dy/16, dy/16,bp,cs) > 2 ) break;
- for( x=dx,i2=y=dy/4; y<3*dy/4; y++ ){
- j=loop(bp,0,y,dx,cs,0,RI); if(j<x) { i2=y; x=j; }
- } if( x>0 ) break; i1=x;
- for( x=0,i4=y=dy/4; y<5*dy/8; y++ ){
- j=loop(bp,dx-1,y,dx,cs,0,LE); if(j>x) { i4=y; x=j; }
- } if( x<dx/2 ) break; i3=x;
- j =loop(bp,dx/2,0,dy,cs,0,DO);
- j+=loop(bp,dx/2,j,dy,cs,1,DO); if(j>dy/4) break;
- j =loop(bp,dx/2,j,dy,cs,0,DO); if(j<dy/2) break;
- j =loop(bp,dx-1 ,dy-1-dy/8,dx,cs,0,LE); if(j<dx/4 || 4*j>3*dx) break;
- j =loop(bp,dx-1-j/2,dy-1-dy/8,dy,cs,0,UP); if(j>dy/2) break; // ~()
- // if( num_hole(x0,x1,y0,y1,box1->p,cs,NULL) != 0 ) break;
- if (sdata->holes.num) break;
- if( hchar ) ac= LATIN_CAPITAL_LETTER_C_WITH_CEDILLA;
- else ac= LATIN_SMALL_LETTER_C_WITH_CEDILLA;
- Setac(box1,ac,ad);
- if (ad>=100) return ac;
- break;
-
- }
- // --- test # ---------------------------------------------------
- for(ad=99;dx>4 && dy>4;){ // never sure?
- DBG( wchar_t c_ask='#'; )
- if (sdata->holes.num > 2) Break; /* tolerant against a tiny hole */
- if (sdata->holes.num < 1) Break;
- if( num_cross(0,dx-1, dy/8, dy/8,bp,cs) != 2 ) Break;
- if( num_cross(0,dx-1,dy-1-dy/8,dy-1-dy/8,bp,cs) != 2 ) Break;
- if( num_cross(0,dx-1, dy/2, dy/2,bp,cs) != 2 ) Break;
- if( num_cross(0,dx/2, dy/2, dy/2,bp,cs) != 1 ) Break;
- /* fat "#" have only small ends on left and right side, we tolerate this */
- j=loop(bp, 0,dy/8,dx,cs,0,RI); if(j<1 || j<dx/16) Break; if (j<dx/8) {ad=ad*96/100;}
- j=loop(bp, 0,dy/2,dx,cs,0,RI); if(j<1 || j<dx/16 || j>=dx/2) Break; if (j<dx/8) {ad=ad*96/100;}
- j=loop(bp,dx-1,dy/2,dx,cs,0,LE); if(j<1 || j<dx/16 || j>=dx/2) Break; if (j<dx/8) {ad=ad*96/100;}
- j=loop(bp,dx-1,dy-1,dx,cs,0,LE); if(j<1 || j<dx/16) Break; if (j<dx/8) {ad=ad*96/100;}
- for( i1=i3=0,y=dy/4; y<dy/2; y++ ){
- j=loop(bp,0, y,dx,cs,0,RI); if(j>3*dx/4) { i1=0; break; }
- j=loop(bp,j, y,dx,cs,1,RI); if(j>i1) { i1=j; }
- j=loop(bp,0,dy-1-y,dx,cs,0,RI); if(j>3*dx/4) { i1=0; break; }
- j=loop(bp,j,dy-1-y,dx,cs,1,RI); if(j>i3) { i3=j; }
- }
- if (i1<dx-dx/4 || i3<dx-dx/4) Break;
- if (i1<dx-dx/8) ad=97*ad/100;
- if (i3<dx-dx/8) ad=97*ad/100;
- if (sdata->holes.num != 1) {ad=95*ad/100;}
- if( num_hole(x0+dx/8,x1-dx/8,y0+dy/8,y1-dy/8,box1->p,cs,NULL) != 1 ) Break;
- // if( num_hole(x0 ,x1 ,y0 ,y1 ,box1->p,cs,NULL) != 1 ) Break;
-
- ac=(wchar_t) '#';
- if( gchar ) {ad=99*ad/100;}
- Setac(box1,ac,ad);
- if (ad>=100) return ac;
- break;
- }
- // --- test bullet, full_box, grabbed cursor, ZapfDingBats_156
- if (bc==UNKNOWN)
- for(ad=96;dx>4 && dy>4 && 2*dx>dy;){ // provisorium
- DBG( wchar_t c_ask='#'; )
- if( get_bw(x0,x1,y0,y1,box1->p,cs,2) != 0 ) break;
- ac=BULLET;
- if (gchar && !hchar) ad=80*ad/100;
- Setac(box1,ac,ad);
- if (ad>=100) return ac;
- break;
- }
- /* --- test | (vertical line, could be a I or l) --- */
- for(ad=99;dy>4 && 2*dx<dy;){ /* v0.44 */
- DBG( wchar_t c_ask='|'; )
- /* test if everything is filled black */
- if( get_bw(x0+dx/8,x1-dx/8,y0+dy/9,y1-dy/9,box1->p,cs,2) != 0 ) break;
- /* more unsure if the borders are not exact */
- if( get_bw(x0 ,x0+dx/8,y0+dy/9,y1-dy/9,box1->p,cs,2) != 0 ) ad=99*ad/100;
- if( get_bw(x1-dx/8,x1 ,y0+dy/9,y1-dy/9,box1->p,cs,2) != 0 ) ad=99*ad/100;
- if( get_bw(x0+dx/8,x1-dx/8,y0 ,y0+dy/8,box1->p,cs,2) != 0 ) ad=99*ad/100;
- if( get_bw(x0+dx/8,x1-dx/8,y1-dy/8,y1 ,box1->p,cs,2) != 0 ) ad=99*ad/100;
- if (3*dx<dy) ad=98*ad/100;
- if (4*dx<dy) ad=99*ad/100;
- if (box1->m2 && 2*y1> box1->m2+box1->m3) Break;
- if (box1->m2 && 3*y1>2*box1->m2+box1->m3) ad=95*ad/100;
- ac='|';
- if (!hchar) ad=98*ad/100;
- Setac(box1,ac,ad);
- break;
- }
- // --- test % ---------------------------------------------------
- for(ad=100;dx>5 && dy>7;){ // provisorium
- DBG( wchar_t c_ask='%'; )
- if (sdata->holes.num > 2) break; /* tolerant against a tiny hole */
- if( num_cross(x0,x1 ,y0+dy/4,y0+dy/4,box1->p,cs) != 3
- && num_cross(x0,x1 ,y0+dy/8,y0+dy/8,box1->p,cs) != 3 ) Break;
- if( num_cross(x0,x1+dx/4,y1-dy/4,y1-dy/4,box1->p,cs) != 3
- && num_cross(x0,x1+dx/4,y1-dy/8,y1-dy/8,box1->p,cs) != 3 ) Break;
- if( num_cross(x0,x1, y0, y1,box1->p,cs) < 4
- && num_cross(x0+dx/8,x1, y0, y1,box1->p,cs) < 4
- && num_cross(x0,x1+dx/4, y0, y1,box1->p,cs) < 4
- && dx>7 && dy>15) Break;
- if( num_cross(x0,x1, y0, y1,box1->p,cs) !=5 ) ad=99*ad/100;
-
- if (dx>7 && dy>12) {
- if( num_hole(x0 ,x1 ,y0,y1-dy/4,box1->p,cs,NULL) != 1 ) Break;
- if( num_hole(x0+dx/4,x1+dx/4,y0+dy/4,y1,box1->p,cs,NULL) != 1 ) Break;
- if( num_hole(x0 ,x1+dx/4,y0,y1 ,box1->p,cs,NULL) != 2 ) Break;
- } else ad=98*ad/100;
- // use box1->p instead of b, because % is a sum of 3 objects
- if ( loop(box1->p,x0,y0 ,dx,cs,0,RI)
- <= loop(box1->p,x0,y0+dy/16+1,dx,cs,0,RI) ) ad=96*ad/100; // X
- if ( loop(box1->p,x1,y1 ,dx,cs,0,LE)
- <= loop(box1->p,x1,y1-1-dy/16,dx,cs,0,LE) ) ad=96*ad/100; // X
- for (x=0;x<dx;x++) { /* look for a vertical line and break if found */
- if ( get_bw(x0+x,x0+x,y0+dy/8,y1-dy/8,box1->p,cs,2) != 2 ) break;
- } if (x<dx) Break; // ~gluedVI
- if (gchar) ad=98*ad/100;
- ac=(wchar_t) '%';
- Setac(box1,ac,ad);
- if (ad>=100) return ac;
- break;
- }
- // --- test Omega ---------------------------------------------------
- for(ad=d=99;dx>7 && dy>7;){ // min 3x4
- DBG( wchar_t c_ask=GREEK_CAPITAL_LETTER_OMEGA; )
- if( get_bw(x0 , x0+dx/2,y0+dy/2 , y0+dy/2,box1->p,cs,1) != 1 ) Break;
- if( get_bw(x1-dx/2 , x1 ,y0+dy/2 , y0+dy/2,box1->p,cs,1) != 1 ) Break;
- if( get_bw(x0+dx/2 , x0+dx/2,y0 , y0+dy/2,box1->p,cs,1) != 1 ) Break;
- if( get_bw(x0+dx/2 , x0+dx/2,y0+dy/3 , y1-dy/3,box1->p,cs,1) != 0 ) Break;
-
- if( num_cross(x0+dx/2,x0+dx/2,y0 , y1-dy/3,box1->p,cs) != 1 ) Break;
- if( num_cross(x0+dx/3,x1-dx/3,y0 , y0 ,box1->p,cs) != 1 ) // AND
- if( num_cross(x0+dx/3,x1-dx/3,y0+1 , y0+1 ,box1->p,cs) != 1 ) Break;
- if( num_cross(x0+dx/3,x1-dx/3,y1 , y1 ,box1->p,cs) != 2 ) // against "rauschen"
- if( num_cross(x0+dx/3,x1-dx/3,y1-1 , y1-1 ,box1->p,cs) != 2 ) Break;
- if( num_cross(x0 ,x0 ,y0+dy/3 , y1-dy/3,box1->p,cs) != 1 )
- if( num_cross(x0+1 ,x0+1 ,y0+dy/3 , y1-dy/3,box1->p,cs) != 1 ) Break;
- if( num_cross(x1 ,x1 ,y0+dy/3 , y1-dy/3,box1->p,cs) != 1 )
- if( num_cross(x1-1 ,x1-1 ,y0+dy/3 , y1-dy/3,box1->p,cs) != 1 ) Break;
- if (sdata->holes.num) Break;
- // if( num_hole(x0,x1,y0,y1,box1->p,cs,NULL) != 0 ) break;
-
- if( loop(bp,0 ,0 ,x1-x0,cs,0,RI)<=
- loop(bp,0 ,2 ,x1-x0,cs,0,RI) ) Break;
- if( loop(bp,dx/2,dy-dy/4,x1-x0,cs,0,RI)>dx/4
- || loop(bp,dx/2,dy-dy/4,x1-x0,cs,0,LE)>dx/4 ) Break;
- if( loop(bp,dx/2,3*dy/8,x1-x0,cs,0,RI)<dx/4
- || loop(bp,dx/2,3*dy/8,x1-x0,cs,0,LE)<dx/4 ) Break;
-
- i=loop(bp,0,dy-1-dy/16,x1-x0,cs,0,RI); if(i>dx/8) Break;
- x=loop(bp,i,dy-1-dy/16,x1-x0,cs,1,RI); i+=x; if(i<3*dx/8 || i>dx/2) Break;
- x=loop(bp,i,dy-1-dy/16,x1-x0,cs,0,RI); i+=x; if(i<dx/2 || i>5*dx/8) Break;
- x=loop(bp,i,dy-1-dy/16,x1-x0,cs,1,RI); i+=x; if(i<7*dx/8) Break;
-
- /* look for a vertikal gap at lower end */
- for( x=dx/4;x<3*dx/4;x++ ){
- i=loop(bp,x,dy-1,y1-y0,cs,0,UP);
- if( i>3*dy/4 ) break;
- }
- if( x>=3*dx/4 ) Break;
-
- if( !hchar ) ad=60*ad/100;
- bc=GREEK_CAPITAL_LETTER_OMEGA;
- Setac(box1,bc,ad);
- break;
- }
-
- return bc;
-}
-
-// -------------------- OCR engine ;) ----------------------------
-wchar_t ocr0(struct box *box1, pix *bp, int cs){
- // pix p=*(box1->p);
- int i,j,d,x,y,x0=box1->x0,x1=box1->x1,y0=box1->y0,y1=box1->y1;
- int dx=x1-x0+1,dy=y1-y0+1, /* size */
- rx,ry,r1,r2,i1,i2,ad; /* tmp-vars */
- // ad,ac will be used in future
- wchar_t bc = UNKNOWN; // bestletter
- wchar_t um = SPACE; // modifier '"
- int hchar; // char is higher than e
- int gchar; // char has ink lower than m3
- int aa[4][4]; /* corner points, see xX, (x,y,dist^2,vector_idx) v0.41 */
- ocr0_shared_t sdata; // data used in all subfunctions
-
- sdata.box1=box1;
- sdata.bp=bp;
- sdata.cs=cs;
- // --- hchar --- gchar -------------------------
- hchar=0;if( y0 < box1->m2-(box1->m2-box1->m1)/2 ) hchar=1;
- gchar=0;if( y1 > box1->m3+(box1->m4-box1->m3)/2 ) gchar=1;
- // if the char is slightly moved down correction can be done
- if ( y0<box1->m2 && y1>box1->m3 && 2*y1<box1->m3+box1->m4) // moved
- if( 2*(y0-(y1-box1->m3))<=2*box1->m2-(box1->m2-box1->m1) ) hchar=1;
-
- sdata.hchar=hchar;
- sdata.gchar=gchar;
-
- /* search for nearest points to the 4 courners, typical for xX */
- /* this is faster as calling nearest_frame_vector 4 times */
- aa[0][0]=aa[1][0]=aa[2][0]=aa[3][0]=(x0+x1)/2; /* set to center */
- aa[0][1]=aa[1][1]=aa[2][1]=aa[3][1]=(y0+y1)/2; /* set to center */
- aa[0][2]=aa[1][2]=aa[2][2]=aa[3][2]=2*sq(128); /* distance to box edges */
- aa[0][3]=aa[1][3]=aa[2][3]=aa[3][3]=0; /* vector index */
- /* searching for 4 diagonal line ends */
- for (i=0;i<box1->num_frame_vectors[0];i++) {
- x=box1->frame_vector[i][0]; /* take a vector */
- y=box1->frame_vector[i][1];
- /* distance to upper left end, normalized to 128 */
- j=0; d=sq((x-x0)*128/dx)+sq((y-y0)*128/dy);
- // fprintf(stderr," setaa i= %2d xy= %3d %3d d=%5d aa[3]=%2d\n",i,x-x0,y-y0,d,aa[0][3]);
- if (d<aa[j][2]) { aa[j][0]=x; aa[j][1]=y; aa[j][2]=d; aa[j][3]=i; }
- /* distance to lower left end */
- j=1; d=sq((x-x0)*128/dx)+sq((y-y1)*128/dy);
- if (d<aa[j][2]) { aa[j][0]=x; aa[j][1]=y; aa[j][2]=d; aa[j][3]=i; }
- /* distance to lower right end */
- j=2; d=sq((x-x1)*128/dx)+sq((y-y1)*128/dy);
- if (d<aa[j][2]) { aa[j][0]=x; aa[j][1]=y; aa[j][2]=d; aa[j][3]=i; }
- /* distance to upper right end */
- j=3; d=sq((x-x1)*128/dx)+sq((y-y0)*128/dy);
- if (d<aa[j][2]) { aa[j][0]=x; aa[j][1]=y; aa[j][2]=d; aa[j][3]=i; }
- }
- for (i=0;i<16;i++) sdata.aa[i/4][i%4]=aa[i/4][i%4];
-
- /* extract number position and size of holes and store in a table
- * - hole coordinates are relative to box (x-x0,y-y0)
- */
- sdata.holes.num=0;
- if (box1->num_frames>0) // speedup v0.42
- num_hole(x0,x1,y0,y1,box1->p,cs,&sdata.holes); // call once
- // printf(" num_holes=%d\n",sdata.holes.num);
-
- /*
- after division of two glued chars, boundaries could be wrong,
- check this first (ToDo: only if a flag set?)
- */
- if (2*y0 < box1->m2+box1->m3)
- if (box1->m4>box1->m3 && 2*box1->y1>box1->m4+box1->m3){
- /* could be a "I" from divided "Ij" or "Ig" */
- for(y=(box1->m3+box1->m2)/2;2*y<box1->m3+box1->m4;y++)
- if( get_bw(x0,x1,y,y,box1->p,cs,1)==0 ) break;
- if(2*y<box1->m3+box1->m4)
- if( get_bw((x0+x1)/2,(x0+x1)/2,y,box1->m4,box1->p,cs,1)==0 ){
- /* be sure, ~_ */
- if (y>y0) y1=box1->y1=y;
- }
- }
-
- DBG( IFV fprintf(stderr,"\nDBG L%d (%d,%d): ",__LINE__,box1->x0,box1->y0); )
- DBG( IFV out_b(box1,sdata.bp,0,0,dx,dy,160); )
- DBG( IFV fprintf(stderr,"# aa[] %d %d %d %d %d %d %d %d (4 corners)"
- " d= %d %d %d %d",
- aa[0][0]-x0,aa[0][1]-y0,aa[1][0]-x0,aa[1][1]-y0,
- aa[2][0]-x0,aa[2][1]-y0,aa[3][0]-x0,aa[3][1]-y0,
- aa[0][2], aa[1][2], aa[2][2], aa[3][2]);)
- DBG( IFV fprintf(stderr,"\n# holes %d gchar=%d hchar=%d",sdata.holes.num, gchar, hchar);)
-
- // --- test thin lines - ---------------------------------
- for( ad=100; 2*dy<box1->m3-box1->m2 && 3*dx>=4*dy && dx>2; ){ // min 3x3 (small font)
- DBG( wchar_t c_ask='-'; )
- if( get_bw(x0+dx/8+1,x1-dx/8-1,y0+dy/8+((dy>2)?1:0),
- y1-dy/8-((dy>2)?1:0),box1->p,cs,2)==2 ) break;
- if( box1->dots ) { Setac(box1,'=',97);break; }
- if (dx<=2*dy) ad=98*ad/100;
- if (dx<=3*dy) ad=99*ad/100;
- if (!box1->m4) ad=96*ad/100;
- else {
- if (y1>=box1->m3) {
- if ( dx<2*dy) ad=98*ad/100;
- if (2*dx<3*dy) ad=98*ad/100;
- Setac(box1,'_',ad);
- break;
- }
- }
- Setac(box1,'-',ad); if (ad>=100) return '-';
- break;
- }
- // --- test thin lines = ---------------------------------
- for( ; dy>2 && dx>2; ){ // min 3x3 (small font)
- DBG( wchar_t c_ask='='; )
- for( y=y0;y<y1;y++) // remove upper empty space
- if( get_bw(x0+dx/10,x1-dx/10,y ,y ,box1->p,cs,1)==1 ) break;
- if( get_bw(x0+dx/10,x1-dx/10,y ,y ,box1->p,cs,2)==2 ) break;
- if( get_bw(x0 ,x1 ,(y+y1)/2,(y+y1)/2,box1->p,cs,1)==1 ) break;
- if( get_bw(x0+dx/10,x1-dx/10,y1 ,y1 ,box1->p,cs,2)==2 ) break;
- Setac(box1,'=',100);
- return '=';
- }
- // --- test dots : ---------------------------------
- for( ad=100; dy>2 && dy>=2*dx; ){ // max 3x3 (small font)
-
- DBG( wchar_t c_ask=':'; )
- // check the gap hight
- for( i1=dy/16;i1<dy/2;i1++)
- if( get_bw(x0+dx/8,x1-dx/8,y0+i1,y0+i1,box1->p,cs,1)==0 ) break;
- if (i1>=dy/2) break;
- for( i2=dy/16;i2<dy/2;i2++)
- if( get_bw(x0+dx/8,x1-dx/8,y1-i2,y1-i2,box1->p,cs,1)==0 ) break;
- if (i2>=dy/2) Break;
- MSG(fprintf(stderr,"gap y12 %d %d",i1,i2);)
-
- if (box1->m3 && y1>box1->m3) ad=98*ad/100; // ~;
- if (box1->m3 && 2*y0> box1->m2+box1->m1) ad=98*ad/100; // ~i
- if (gchar) ad=99*ad/100;
- ad=ad-abs(i1-i2)/dy*20;
- if (abs(i1-dx)>dy/4) Break; // round or quadratic dots?
- if (abs(i1-dx)>dy/8) ad=98*ad/100;
- if (abs(i2-dx)>dy/4) Break; // round or quadratic dots?
- if (abs(i2-dx)>dy/8) ad=98*ad/100;
- if (box1->dots!=1) ad=96*ad/100;
- Setac(box1,':',ad); // dx<=3 ad--
- if (ad>=100) return ':';
- break;
- }
- // --- test dots ; ---------------------------------
- if( 2*y0> box1->m2+box1->m1 ) // ~i
- if( 4*y1>=3*box1->m3+box1->m2 ) // ~:
- for( ad=100; dy>5 && dx>1 && dy>2*dx; ){ // max 3x3 (small font)
- DBG( wchar_t c_ask=';'; )
- // better would it be to detect round pixelcluster on top
- // check high of upper and lower dot
- for( i1=0;i1<dy/2;i1++)
- if( get_bw(x0,x1,y0+i1,y0+i1,box1->p,cs,1)==0 ) break;
- if (i1>=dy/2) break;
- for( i2=0;i2<dy/2;i2++)
- if( get_bw(x0,x1,y1-i2,y1-i2,box1->p,cs,1)==0 ) break;
- if (i2<i1) break;
-
- /* test for horizontal symmetry ~i */
- for (y=0;y<dy;y++) for (x=0;x<dx/2;x++)
- if ((getpixel(bp,x,y)<cs)!=(getpixel(bp,dx-1-x,y)<cs)) { y=dy+1; break; }
- if (y==dy) ad=96*ad/100; /* ~i */
-
- if (i2==i1 && y1<=box1->m3) ad=97*ad/100;
- if (i2-i1<dy/8) ad=99*ad/100;
- Setac(box1,';',ad); // dx<=3 ad--
- if (ad>=100) return ';';
- break;
- }
- // --- first test small dots . ---------------------------------
- if( 3*dy<box1->m4-box1->m1 && abs(dx-dy)<(dx+dy)/4+2
- && 3*y1>=(2*box1->m3+ box1->m2) // dot near baseline?
- && 5*y0>=(3*box1->m3+2*box1->m2) ){ // Jul00
- DBG( wchar_t c_ask='.'; )
- d=0; r1=60;r2=140; ad=99;
- for(x=x0;x<=x1;x++)for(y=y0;y<=y1;y++){ /* circle equation */
- rx=100*(2*x-(x0+x1))/dx; // normalize to 15bit number
- ry=100*(2*y-(y0+y1))/dy;
- if( rx*rx + ry*ry < r1*r1 ) if( getpixel(box1->p,x,y)>=cs ){ d++;x=x1+1;y=y1+1; }
- if( rx*rx + ry*ry > r2*r2 ) if( getpixel(box1->p,x,y)< cs ){ d++;x=x1+1;y=y1+1; }
- // fprintf(stderr,"\nDBG . x= %3d %3d r= %6d %6d %6d", rx, ry, rx*rx+ry*ry, r1*r1, r2*r2);
- }
- if(d==0)
- if( loop(box1->p,x0,y0,x1-x0,cs,0,RI)
- <= loop(box1->p,x0,y1,x1-x0,cs,0,RI)
- || loop(box1->p,x1,y0,x1-x0,cs,0,LE)
- >= loop(box1->p,x1,y1,x1-x0,cs,0,LE) )
- {
- bc='.'; if (box1->dots) { Setac(box1,':',ad); ad=98*ad/100; }
- Setac(box1,bc,ad);
- }
- }
- // --- first test small dots , ---------------------------------
- if( 3*dy<2*(box1->m4-box1->m1)
- && 2*y0> box1->m2+box1->m3
- && (2*dx<3*dy
- || get_bw(0,dx/2,dy/2,dy-1,bp,cs,1)==0) ){ // ocr-a-,
- DBG( wchar_t c_ask=','; )
- ad=100; bc=',';
- if (dy==1 && dx==1) ad=98*ad/100;
- if (dy==2 && dx==1) ad=99*ad/100; // this is a problem case
- if (dx>=dy) ad=99*ad/100;
- if( 2*dy >= box1->m4-box1->m1) ad=98*ad/100;
- if( loop(box1->p,x0,y0,x1-x0,cs,0,RI) /* simple line */
- > loop(box1->p,x0,y1,x1-x0,cs,0,RI)
- && loop(box1->p,x1,y0,x1-x0,cs,0,LE)
- < loop(box1->p,x1,y1,x1-x0,cs,0,LE) ) { ad=99*ad/100; }
- else { /* with upper circle */
- if( loop(box1->p,x0,(y0+y1+1)/2,x1-x0,cs,0,RI)<dx/2 ) ad=98*ad/100;
- if( loop(box1->p,x1, y1 ,x1-x0,cs,0,LE)<dx/2 ) ad=98*ad/100;
- if( loop(box1->p,x0,y1-((dy>5)?1:0),x1-x0,cs,0,LE)>(dx+1)/2 )
- if( loop(box1->p,x0, y1 ,x1-x0,cs,0,LE)>(dx+1)/2 ) ad=96*ad/100;
- }
- if(box1->dots==1) { Setac(box1,';',ad); ad=99*ad/100; }
- Setac(box1,bc,ad);
- }
- // --- first test small dots '" ---------------------------------
- if( 2*dy < box1->m4 -box1->m1+1
- && 2*y0 < box1->m2 +box1->m3
- && 3*y1 < box1->m2+2*box1->m3+2 ){
- DBG( wchar_t c_ask='\''; )
- ad=100; bc='\'';
- if (2*y1 >= box1->m2+box1->m3) { ad=96*ad/100; MSG({}) } // ~!
- if (3*y1>=2*box1->m2+box1->m3) { ad=96*ad/100; MSG({}) }
- if (get_bw(x0,x1,(box1->m2+box1->m3)/2,box1->m4,box1->p,cs,1)!=0)
- { ad=98*ad/100; MSG({}) }
- if (dx>4
- && num_cross(x0,x1,y1,y1,box1->p,cs) == 2) { // " "
- bc='"';
- // ocr-a-" has no gap!
- if ( get_bw((x0+x1)/2,(x0+x1)/2,y0,y1,box1->p,cs,1)!=0 ) ad=96*ad/100;
- } else {
- if ( num_cross(x0,x1, y0 , y0 ,box1->p,cs)!=1) ad=96*ad/100;
- if ( num_cross(x0,x1,(y0+y1)/2,(y0+y1)/2,box1->p,cs)!=1) ad=98*ad/100;
- if (dx>dy) { ad=96*ad/100; MSG({}) }
- }
- if (2*y0 > box1->m1+box1->m2) ad=99*ad/100;
- Setac(box1,bc,ad);
- if (ad>=100) return bc;
- }
- // --- TILDE ~ ---------------------------------
- if( 2*dy<box1->m4-box1->m1 && dx>=dy && dx>3 && dy>1
- && 2*y0< box1->m1+box1->m2
- && 3*y1<2*box1->m2+box1->m3 ){
- if( loop(box1->p,x0,y0,dx,cs,0,RI)
- > loop(box1->p,x0,y1,dx,cs,0,RI)
- && loop(box1->p,x1,y0,dx,cs,0,LE)
- < loop(box1->p,x1,y1,dx,cs,0,LE)
- && num_cross(x0,x1,y0,y0,box1->p,cs) == 2
- && num_cross(x0,x1,y1,y1,box1->p,cs) == 2 ) {
- DBG( wchar_t c_ask='~'; )
- bc=TILDE;
- Setac(box1,bc,99);
- }
- }
- // --- CIRCUMFLEX, hat ^ ---------------------------------
- if( 2*dy<box1->m4-box1->m1 && dx>=dy && dx>2 && dy>1
- && 2*y0< box1->m1+box1->m2
- && 3*y1<2*box1->m2+box1->m3 ){
- DBG( wchar_t c_ask='^'; )
- if( ( loop(box1->p,x0,y0 ,dx,cs,0,RI)
- > loop(box1->p,x0,y1 ,dx,cs,0,RI)-dx/8
- || loop(box1->p,x0,y0 ,dx,cs,0,RI)
- > loop(box1->p,x0,y1-1,dx,cs,0,RI)-dx/8 )
- && ( loop(box1->p,x1,y0 ,dx,cs,0,LE)
- > loop(box1->p,x1,y1 ,dx,cs,0,LE)-dx/8
- || loop(box1->p,x1,y0 ,dx,cs,0,LE)
- > loop(box1->p,x1,y1-1,dx,cs,0,LE)-dx/8 )
- && num_cross(x0,x1,y0 ,y0 ,box1->p,cs) == 1
- && ( num_cross(x0,x1,y1 ,y1 ,box1->p,cs) == 2
- || num_cross(x0,x1,y1-1,y1-1,box1->p,cs) == 2 )) {
- bc='^';
- Setac(box1,bc,99);
- }
- }
- // ------------------------------------------------------
-// if( dots==1 ){ um='\''; }
-#if 0 /* ToDo: change to vectors, call here or in whatletter */
- if (box1->dots==0) { // i-dots ??? (if dots==0 is wrong)
- y=box1->m1;
- for(;y<y0+dy/2;y++)if( get_bw(x0+dx/4,x1,y,y,box1->p,cs,1)==1) break;
- { i1=y;
- if( y<y0+dy/4 )
- for(;y<y0+dy/2;y++)if( get_bw(x0,x1,y,y,box1->p,cs,1)==0) break;
- if( y<y0+dy/2 && 5*(y-i1+1)>box1->m2-box1->m1){
- testumlaut(box1,cs,2,&um); // set modifier + new y0 ???
-
- }
- }
- }
-#else
- um = box1->modifier;
-#endif
- if ( /* um==ACUTE_ACCENT || */ um==DIAERESIS){
- for(y=y1;y>y0;y--)
- if( get_bw(x0,x1,y,y,box1->p,cs,1)==0) { y0=y; dy=y1-y0+1; break; } // scan "a "o "u
- }
-
- // --- test numbers 0..9 --- separated for faster compilation
- if( JOB->cfg.only_numbers ) return ocr0n(&sdata);
-
- // bc=ocr1(box1,bp,cs);
- if(bc!=UNKNOWN && box1->num_ac>0 && box1->wac[0]==100)
- return bc; // for fast compilable tests
-
- // ------ separated for faster compilation
- // ToDo: inser ocr0_shared_t here and split into a,b,cC,d,e,f,g9,...
-#define IF_NOT_SURE if(bc==UNKNOWN || box1->num_ac==0 || box1->wac[0]<100)
-
- IF_NOT_SURE bc=ocr0_eE(&sdata);
- IF_NOT_SURE bc=ocr0_f(&sdata);
- IF_NOT_SURE bc=ocr0_bB(&sdata);
- IF_NOT_SURE bc=ocr0_dD(&sdata);
- IF_NOT_SURE bc=ocr0_F(&sdata);
- IF_NOT_SURE bc=ocr0_uU(&sdata);
- IF_NOT_SURE bc=ocr0_micro(&sdata);
- IF_NOT_SURE bc=ocr0_vV(&sdata);
- IF_NOT_SURE bc=ocr0_rR(&sdata);
- IF_NOT_SURE bc=ocr0_m(&sdata);
- IF_NOT_SURE bc=ocr0_tT(&sdata);
- IF_NOT_SURE bc=ocr0_sS(&sdata);
- IF_NOT_SURE bc=ocr0_gG(&sdata);
- IF_NOT_SURE bc=ocr0_xX(&sdata);
- IF_NOT_SURE bc=ocr0_yY(&sdata);
- IF_NOT_SURE bc=ocr0_zZ(&sdata);
- IF_NOT_SURE bc=ocr0_wW(&sdata);
- IF_NOT_SURE bc=ocr0_aA(&sdata);
- IF_NOT_SURE bc=ocr0_cC(&sdata);
- IF_NOT_SURE bc=ocr0_lL(&sdata);
- IF_NOT_SURE bc=ocr0_oO(&sdata);
- IF_NOT_SURE bc=ocr0_pP(&sdata);
- IF_NOT_SURE bc=ocr0_qQ(&sdata);
- IF_NOT_SURE bc=ocr0_iIjJ(&sdata);
- IF_NOT_SURE bc=ocr0_n(&sdata);
- IF_NOT_SURE bc=ocr0_M(&sdata);
- IF_NOT_SURE bc=ocr0_N(&sdata);
- IF_NOT_SURE bc=ocr0_h(&sdata);
- IF_NOT_SURE bc=ocr0_H(&sdata);
- IF_NOT_SURE bc=ocr0_k(&sdata);
- IF_NOT_SURE bc=ocr0_K(&sdata);
- IF_NOT_SURE bc=ocr0n(&sdata);
- IF_NOT_SURE bc=ocr0_brackets(&sdata);
- IF_NOT_SURE bc=ocr0p9(&sdata);
- IF_NOT_SURE bc=ocr0px(&sdata);
-
-
- if(box1->num_ac==0 && bc!=UNKNOWN) fprintf(stderr,"<!--ERROR 576-->");
- if(box1->num_ac>0 && box1->wac[0]>95) box1->c=bc=box1->tac[0];
- /* will be removed later, only fix old things */
- for (i=0;i<box1->num_ac;i++) if (box1->tac[i]==bc) { bc=box1->tac[0]; }
-
- return bc;
-}
-
-
+++ /dev/null
-// test routines - faster to compile
-#include <stdlib.h>
-#include <stdio.h>
-#include "pgm2asc.h"
-#include "unicode.h"
-#include "gocr.h"
-
-// for learn_mode/analyze_mode high, with, yoffset, num of pattern_i,
-// - holes (center,radius in relative coordinates) etc. => cluster analyze
-// num_hole => min-volume, tolerance border
-// pattern: @@ @. @@
-// .@ @. ..
-// regular filter for large resolutions to make edges more smooth (on boxes)
-// extra-filter (only if not recognized?)
-// map + same color to (#==change)
-// - anti color
-// . not used
-// strongest neighbour pixels (3x3) => directions
-// second/third run with more and more tolerance!?
-
-/* FIXME jb: following is unused */
-#if 0
-struct lobj { // line-object (for fitting to near lines)
- int x0,y0; // starting point (left up)
- int x1,y1; // end point (right down)
- int mt; // minimum thickness
- int q; // quality, overlapp
-};
-
-/* FIXME jb global */
-struct lobj obj1;
-#endif
-
-// that is the first draft of feature extraction
-// detect main lines and bows
-// seems bad implemented, looking for better algorithms (ToDo: use autotrace)
-#define MAXL 10
-void ocr2(pix *b,int cs){
- int x1,y1,x2,y2,l,i,j,xa[MAXL],ya[MAXL],xb[MAXL],yb[MAXL],ll[MAXL];
- for(i=0;i<MAXL;i++)xa[i]=ya[i]=xb[i]=yb[i]=ll[i]=0;
- for(x1=0;x1<b->x;x1++) // very slowly, but simple to program
- for(y1=0;y1<b->y;y1++) // brute force
- for(x2=0;x2<b->x;x2++)
- for(y2=y1+1;y2<b->y;y2++)
- {
- if( get_line2(x1,y1,x2,y2,b,cs,100)>99 )
- { // line ???
- l=(x2-x1)*(x2-x1)+(y2-y1)*(y2-y1); // len
- for(i=0;i<MAXL;i++)
- { // remove similar lines (same middle point) IMPROVE IT !!!!!! ???
- if(
- abs(x1+x2-xa[i]-xb[i])<1+b->x/2
- && abs(y1+y2-ya[i]-yb[i])<1+b->y/2
- && abs(y1-ya[i])<1+b->y/4
- && abs(x1-xa[i])<1+b->x/4
- )
- {
- if( l>ll[i] )
- {
- for(j=i;j<MAXL-1;j++)
- { // shift table
- xa[j]=xa[j+1];ya[j]=ya[j+1];
- xb[j]=xb[j+1];yb[j]=yb[j+1];ll[j]=ll[j+1];
- }
- ll[MAXL-1]=0;
- }
- else break; // forget it if shorter
- }
- if( l>ll[i] ){ // insert if larger
- for(j=MAXL-1;j>i;j--){ // shift table
- xa[j]=xa[j-1];ya[j]=ya[j-1];
- xb[j]=xb[j-1];yb[j]=yb[j-1];ll[j]=ll[j-1];
- }
- xa[i]=x1;ya[i]=y1;xb[i]=x2;yb[i]=y2;ll[i]=l;
- break;
- }
- }
- }
- }
- for(i=0;i<MAXL;i++){
- printf(" %2d %2d %2d %2d %3d\n",xa[i],ya[i],xb[i],yb[i],ll[i]);
- }
-}
-
+++ /dev/null
-/* #include "pgm2asc.h" */
-#include "pnm.h"
-/* wchar_t ocr1(struct box *box1, pix *b, int cs); */
+++ /dev/null
-/*
-This is a Optical-Character-Recognition program
-Copyright (C) 2000-2006 Joerg Schulenburg
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- see README for EMAIL address
-*/
-
-#include <string.h>
-#include "unicode.h"
-#include "output.h"
-#include "gocr.h" /* extern job_t JOB; */
-
-/* function is only for debugging and for developing
- it prints out a part of pixmap b at point x0,y0 to stderr
- using dots .,; if no pixel, and @xoO for pixels
- modify n_run and print out what would happen on 2nd, 3th loop!
- new: output original and copied pixmap in the same figure
- */
-void out_b(struct box *px, pix *b, int x0, int y0, int dx, int dy, int cs ){
- int x,y,x2,y2,yy0,tx,ty,n1,i;
- char c1, c2;
- yy0=y0;
- if(px){ /* overwrite rest of arguments */
- if (!b) {
- b=px->p;
- x0=px->x0; dx=px->x1-px->x0+1;
- y0=px->y0; dy=px->y1-px->y0+1; yy0=y0;
- }
- if(cs==0) cs=JOB->cfg.cs;
- fprintf(stderr,"\n# list box x= %4d %4d d= %3d %3d r= %3d %3d"
- " nrun=%d p=%p", /* ToDo: r,nrun is obsolete */
- px->x0, px->y0, px->x1 - px->x0 + 1, px->y1 - px->y0 + 1,
- px->x - px->x0, px->y - px->y0, JOB->tmp.n_run, (void*)px);
- fprintf(stderr,"\n# dots=%d boxes=%d subboxes=%d c=%s mod=%s"
- " line=%d m= %d %d %d %d",
- px->dots, px->num_boxes, px->num_subboxes,
- decode(px->c,ASCII), decode(px->modifier,ASCII), px->line,
- px->m1 - px->y0, px->m2 - px->y0, px->m3 - px->y0, px->m4 - px->y0);
- if (px->num_frames) {
- int i,j,jo;
- fprintf(stderr,"\n# frames= %d (sumvects=%d)",px->num_frames,
- ((px->num_frames)?px->num_frame_vectors[px->num_frames-1]:-1));
- for (jo=j=i=0; i<px->num_frames; i++, jo=j) {
- fprintf(stderr,"\n# frame %d (%+4d,%3d,%2d) ",
- i, px->frame_vol[i], px->frame_per[i],
- px->num_frame_vectors[i]-jo);
- /* print only the first vectors of each frame */
- for (;j<px->num_frame_vectors[i] && j<MaxFrameVectors; j++)
- fprintf(stderr," #%02d %2d %2d", j,
- px->frame_vector[j][0] - px->x0,
- px->frame_vector[j][1] - px->y0);
- }
- }
- if (px->num_ac){ /* output table of chars and its probabilities */
- fprintf(stderr,"\n# list box char: ");
- for(i=0;i<px->num_ac && i<NumAlt;i++)
- /* output the (xml-)string (picture position, barcodes, glyphs, ...) */
- if (px->tas[i])
- fprintf(stderr," %s(%d)", px->tas[i] ,px->wac[i]);
- else
- fprintf(stderr," %s(%d)",decode(px->tac[i],ASCII),px->wac[i]);
- }
- fprintf(stderr,"\n");
- if (px->dots && px->m2 && px->m1<y0) { yy0=px->m1; dy=px->y1-yy0+1; }
- }
- tx=dx/80+1;
- ty=dy/40+1; /* step, usually 1, but greater on large maps */
- fprintf(stderr,"# list pattern x= %4d %4d d= %3d %3d t= %d %d\n",
- x0,y0,dx,dy,tx,ty);
- if (dx>0)
- for(y=yy0;y<yy0+dy;y+=ty) { /* reduce the output to max 78x40 */
- /* first image is the copied and modified bitmap of the box */
- if (px)
- for(x=x0;x<x0+dx;x+=tx){ /* by merging sub-pixels */
- n1=0; c1='.';
- for(y2=y;y2<y+ty && y2<y0+dy;y2++) /* sub-pixels */
- for(x2=x;x2<x+tx && x2<x0+dx;x2++)
- {
- if((getpixel(px->p,x2-x0+px->x0,
- y2-y0+px->y0)<cs)) c1='@';
- }
- if (px->num_frames) { /* mark vectors */
- int i;
- if (c1!='$' && c1!='S') /* dont mark twice */
- for (i=0;i<px->num_frame_vectors[px->num_frames-1];i++)
- if ((px->frame_vector[i][0]-px->x0)/tx==(x-x0)/tx
- && (px->frame_vector[i][1]-px->y0)/ty==(y-y0)/ty)
- { c1=((c1=='@')?'$':'S'); break; }
- }
- fprintf(stderr,"%c", c1 );
- }
-
- /* 2nd image is the boxframe in the original bitmap */
- if (dx<40) fprintf(stderr," ");
- if (dx<40) /* do it only, if we have enough place */
- for(x=x0;x<x0+dx;x+=tx){ /* by merging sub-pixels */
- c1='.';
- for(y2=y;y2<y+ty && y2<y0+dy;y2++) /* sub-pixels */
- for(x2=x;x2<x+tx && x2<x0+dx;x2++)
- { if((getpixel(b,x2,y2)<cs)) c1='@'; }
- fprintf(stderr,"%c", c1 );
- }
-
- c1=c2=' ';
- /* mark lines with < */
- if (px) if (y-y0+px->y0==px->m1 || y-y0+px->y0==px->m2
- || y-y0+px->y0==px->m3 || y-y0+px->y0==px->m4) c1='<';
- if (y==y0 || y==yy0+dy-1) c2='-'; /* boxmarks */
-
- fprintf(stderr,"%c%c\n",c1,c2);
- }
-}
-
-/* same as out_b, but for faster use, only a box as argument
- */
-void out_x(struct box *px) {
- out_b(px,NULL,0, 0, 0, 0, JOB->cfg.cs);
-}
-
-
-/* print out two boxes side by side, for debugging comparision algos */
-void out_x2(struct box *box1, struct box *box2){
- int x,y,i,tx,ty,dy;
- /*FIXME jb static*/static char *c1="OXXXXxx@.,,,,,,,";
- pix *b=&JOB->src.p;
- dy=(box1->y1-box1->y0+1);
- if(dy<box2->y1-box2->y0+1)dy=box2->y1-box2->y0+1;
- tx=(box1->x1-box1->x0)/40+1;
- ty=(box1->y1-box1->y0)/40+1; /* step, usually 1, but greater on large maps */
- if(box2)fprintf(stderr,"\n# list 2 patterns");
- for(i=0;i<dy;i+=ty) { /* reduce the output to max 78x40??? */
- fprintf(stderr,"\n"); y=box1->y0+i;
- for(x=box1->x0;x<=box1->x1;x+=tx)
- fprintf(stderr,"%c", c1[ ((getpixel(b,x,y)<JOB->cfg.cs)?0:8)+marked(b,x,y) ] );
- if(!box2) continue;
- fprintf(stderr," "); y=box2->y0+i;
- for(x=box2->x0;x<=box2->x1;x+=tx)
- fprintf(stderr,"%c", c1[ ((getpixel(b,x,y)<JOB->cfg.cs)?0:8)+marked(b,x,y) ] );
- }
-}
-
-
-/* ---- list output ---- for debugging ---
- * list all boxes where the results can be found within the c-option
- */
-int output_list(job_t *job) {
- int i = 0, j;
- struct box *box2;
- pix *pp = &job->src.p;
- char *lc = job->cfg.lc;
-
- fprintf(stderr,"\n# list shape for charlist %s",lc);
- for_each_data(&(JOB->res.boxlist)) {
- box2 = (struct box *) list_get_current(&(JOB->res.boxlist));
- for (j=0; j<box2->num_ac; j++)
- if (!lc || (box2->tac[j] && strchr(lc, box2->tac[j]))
- || (box2->tas[j] && strstr(lc, box2->tas[j]))) break;
- if (j<box2->num_ac)
- fprintf(stderr,"\n# box found in charlist");
- if (!lc || (strchr(lc, box2->c) && box2->c < 256 && box2->c)
- || (strchr(lc, '_') && box2->c==UNKNOWN) /* for compability */
- || j<box2->num_ac ){ /* also list alternative chars */
- if (!pp) pp=box2->p;
- fprintf(stderr,
- "\n# list shape %3d x=%4d %4d d= %3d %3d vf=%d ac=%d %04x %s",
- i, box2->x0, box2->y0,
- box2->x1 - box2->x0 + 1,
- box2->y1 - box2->y0 + 1,
- box2->num_frames, box2->num_ac,
- (int)box2->c, /* wchar_t -> char ???? */
- decode(box2->c,ASCII) );
- if (JOB->cfg.verbose & 4) out_x(box2);
- }
- i++;
- } end_for_each(&(JOB->res.boxlist));
- fprintf(stderr,"\n");
- return 0;
-}
-
+++ /dev/null
-/*
-This is a Optical-Character-Recognition program
-Copyright (C) 2000 Joerg Schulenburg
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- see README for EMAIL-address */
-
-#ifndef OUTPUT_H
-#define OUTPUT_H
-
-#include <stdlib.h>
-#include <stdio.h>
-#include "pnm.h"
-#include "gocr.h"
-#include "list.h"
-
-void out_b(struct box *px, pix *b, int x0, int y0, int dx, int dy, int cs );
-void out_x(struct box *px);
-void out_x2(struct box *box1,struct box *box2);
-int output_list(job_t *job);
-
-
-#endif
+++ /dev/null
-/*
-This is a Optical-Character-Recognition program
-Copyright (C) 2000-2007 Joerg Schulenburg
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- see README for EMAIL-address
-
- sometimes I have written comments in german language, sorry for that
-
- - look for ??? for preliminary code
- - space: avX=22 11-13 (empirical estimated)
- avX=16 5-7
- avX= 7 5-6
-
- ToDo: - add filter (r/s mismatch) g300c1
- - better get_line2 function (problems on high resolution)
- - write parallelizable code!
- - learnmode (optimize filter)
- - use ispell for final control or if unsure
- - better line scanning (if not even)
- - step 5: same chars differ? => expert mode
- - chars dx>dy and above 50% hor-crossing > 4 is char-group ?
- - detect color of chars and background
- - better word space calculation (look at the examples)
- (distance: left-left, middle-middle, left-right, thickness of e *0.75)
-
- GLOBAL DATA (mostly structures)
- - pix : image - one byte per pixel bits0-2=working
- - lines : rows of the text (points to pix)
- - box : list of bounding box for character
- - obj : objects (lines, splines, etc. building a character)
- */
-
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <assert.h>
-#include <string.h>
-#include <ctype.h>
-#include "../../config.h"
-#ifdef HAVE_WCHAR_H
-#include <wchar.h>
-#endif
-
-#include "list.h"
-#include "pgm2asc.h"
-// #include "pcx.h" /* needed for writebmp (removed later) */
-/* ocr1 is the test-engine - remember: this is development version */
-#include "ocr1.h"
-/* first engine */
-#include "ocr0.h"
-#include "otsu.h"
-#include "progress.h"
-
-#include "gocr.h"
-
-/* wew: will be exceeded by capitals at 1200dpi */
-#define MaxBox (100*200) // largest possible letter (buffersize)
-#define MAX(a,b) ((a) >= (b) ? (a) : (b))
-
-/* if the system does not know about wchar.h, define functions here */
-#ifndef HAVE_WCHAR_H
-/* typedef unsigned wchar_t; */
-/* Find the first occurrence of WC in WCS. */
-const wchar_t *wcschr (const wchar_t *wcs, const wchar_t wc) {
- int i; for(i=0;wcs[i];i++) if (wcs[i]==wc) return wcs+i; return NULL;
-}
-const wchar_t *wcscpy (wchar_t *dest, const wchar_t *src) {
- int i; for(i=0;src[i];i++) dest[i]=src[i]; dest[i]=0; return dest;
-}
-size_t wcslen (const wchar_t *s){
- size_t i; for(i=0;s[i];i++); return i;
-}
-#endif
-#ifndef HAVE_WCSDUP
-wchar_t * wcsdup (const wchar_t *WS) { /* its a gnu extension */
- wchar_t *copy;
- copy = (wchar_t *) malloc((wcslen(WS)+1)*sizeof(wchar_t));
- if (!copy)return NULL;
- wcscpy(copy, WS);
- return copy;
-}
-#endif
-
-// ------------------------ feature extraction -----------------
-// -------------------------------------------------------------
-// detect maximas in of line overlaps (return in %) and line coordinates
-// this is for future use
-#define HOR 1 // horizontal
-#define VER 2 // vertical
-#define RIS 3 // rising=steigend
-#define FAL 4 // falling=fallend
-
-/* exchange two variables */
-static void swap(int *a, int *b) {
- int c = *a;
- *a = *b;
- *b = c;
-}
-
-// calculate the overlapping of the line (0-1) with black points
-// by recursive bisection
-// line: y=dy/dx*x+b, implicit form: d=F(x,y)=dy*x-dx*y+b*dx=0
-// incremental y(i+1)=m*(x(i)+1)+b, F(x+1,y+1)=f(F(x,y))
-// ret & 1 => inverse pixel!
-// d=2*F(x,y) integer numbers
-int get_line(int x0, int y0, int x1, int y1, pix *p, int cs, int ret){
- int dx,dy,incrE,incrNE,d,x,y,r0,r1,ty,tx,
- *px,*py,*pdx,*pdy,*ptx,*pty,*px1;
- dx=abs(x1-x0); tx=((x1>x0)?1:-1); // tx=x-spiegelung (new)
- dy=abs(y1-y0); ty=((y1>y0)?1:-1); // ty=y-spiegelung (new)
- // rotate coordinate system if dy>dx
-/*bbg: can be faster if instead of pointers we use the variables and swaps? */
-/*js: Do not know, I am happy that the current code is working and is small */
- if(dx>dy){ pdx=&dx;pdy=&dy;px=&x;py=&y;ptx=&tx;pty=&ty;px1=&x1; }
- else { pdx=&dy;pdy=&dx;px=&y;py=&x;ptx=&ty;pty=&tx;px1=&y1; }
- if( *ptx<0 ){ swap(&x0,&x1);swap(&y0,&y1);tx=-tx;ty=-ty; }
- d=((*pdy)<<1)-(*pdx); incrE=(*pdy)<<1; incrNE=((*pdy)-(*pdx))<<1;
- x=x0; y=y0; r0=r1=0; /* dd=tolerance (store max drift) */
- while( (*px)<=(*px1) ){
- if( ((getpixel(p,x,y)<cs)?1:0)^(ret&1) ) r0++; else r1++;
- (*px)++; if( d<=0 ){ d+=incrE; } else { d+=incrNE; (*py)+=(*pty); }
- }
- return (r0*(ret&~1))/(r0+r1); // ret==100 => percentage %
-}
-
-// this function should detect whether a direct connection between points
-// exists or not, not finally implemented
-// ret & 1 => inverse pixel!
-// d=2*F(x,y) integer numbers, ideal line: ,I pixel: I@
-// ..@ @@@ .@. ...,@2@. +1..+3 floodfill around line ???
-// ..@ .@@ .@. ...,.@@@ +2..+4 <= that's not implemented yet
-// ..@ ..@ .@. ...,.@@@ +2..+4
-// @.@ @.. .@. ...,@@@. +1..+3
-// @.@ @@. .@. ...I@@@. 0..+3
-// @@@ @@@ .@. ..@1@@.. 0..+2
-// 90% 0% 100% 90% r1-r2
-// I am not satisfied with it
-int get_line2(int x0, int y0, int x1, int y1, pix *p, int cs, int ret){
- int dx,dy,incrE,incrNE,d,x,y,r0,r1,ty,tx,q,ddy,rx,ry,
- *px,*py,*pdx,*pdy,*ptx,*pty,*px1;
- dx=abs(x1-x0); tx=((x1>x0)?1:-1); // tx=x-spiegelung (new)
- dy=abs(y1-y0); ty=((y1>y0)?1:-1); // ty=y-spiegelung (new)
- // rotate coordinate system if dy>dx
- if(dx>dy){ pdx=&dx;pdy=&dy;px=&x;py=&y;ptx=&tx;pty=&ty;px1=&x1;rx=1;ry=0; }
- else { pdx=&dy;pdy=&dx;px=&y;py=&x;ptx=&ty;pty=&tx;px1=&y1;rx=0;ry=1; }
- if( *ptx<0 ){ swap(&x0,&x1);swap(&y0,&y1);tx=-tx;ty=-ty; }
- d=((*pdy)<<1)-(*pdx); incrE=(*pdy)<<1; incrNE=((*pdy)-(*pdx))<<1;
- x=x0; y=y0; r0=r1=0; ddy=3; // tolerance = bit 1 + bit 0 = left+right
- // int t=(*pdx)/16,tl,tr; // tolerance, left-,right delimiter
- while( (*px)<=(*px1) ){ // not finaly implemented
- q=((getpixel(p,x,y)<cs)?1:0)^(ret&1);
- if ( !q ){ // tolerance one pixel perpenticular to the line
- // what about 2 or more pixels tolerance???
- ddy&=(~1)|(((getpixel(p,x+ry,y+rx)<cs)?1:0)^(ret&1));
- ddy&=(~2)|(((getpixel(p,x-ry,y-rx)<cs)?1:0)^(ret&1))*2;
- } else ddy=3;
- if( ddy ) r0++; else r1++;
- (*px)++; if( d<=0 ){ d+=incrE; } else { d+=incrNE; (*py)+=(*pty); }
- }
- return (r0*(ret&~1))/(r0+r1); // ret==100 => percentage %
-}
-
-/* Look for dots in the rectangular region x0 <= x <= x1 and y0 <= y
- <= y1 in pixmap p. The two low order bits in mask indicate the color
- of dots to look for: If mask==1 then look for black dots (where a
- pixel value less than cs is considered black). If mask==2 then look
- for white dots. If mask==3 then look for both black and white dots.
- If the dots are found, the corresponding bits are set in the returned
- value. Heavily used by the engine ocr0*.cc */
-char get_bw(int x0, int x1, int y0, int y1, pix * p, int cs, int mask) {
- char rc = 0; // later with error < 2% (1 dot)
- int x, y;
-
- if (x0 < 0) x0 = 0;
- if (x1 >= p->x) x1 = p->x - 1;
- if (y0 < 0) y0 = 0;
- if (y1 >= p->y) y1 = p->y - 1;
-
- for ( y = y0; y <= y1; y++)
- for ( x = x0; x <= x1; x++) {
- rc |= ((getpixel(p, x, y) < cs) ? 1 : 2); // break if rc==3
- if ((rc & mask) == mask)
- return mask; // break loop
- }
- return (rc & mask);
-}
-
-/* more general Mar2000 (x0,x1,y0,y1 instead of x0,y0,x1,y1! (history))
- * look for black crossings throw a line from x0,y0 to x1,y1 and count them
- * follow line and count crossings ([white]-black-transitions)
- * ex: horizontal num_cross of 'm' would return 3 */
-int num_cross(int x0, int x1, int y0, int y1, pix *p, int cs) {
- int rc = 0, col = 0, k, x, y, i, d; // rc=crossings col=0=white
- int dx = x1 - x0, dy = y1 - y0;
-
- d = MAX(abs(dx), abs(dy));
- for (i = 0, x = x0, y = y0; i <= d; i++) {
- if (d) {
- x = x0 + i * dx / d;
- y = y0 + i * dy / d;
- }
- k = ((getpixel(p, x, y) < cs) ? 1 : 0); // 0=white 1=black
- if (col == 0 && k == 1)
- rc++;
- col = k;
- }
- return rc;
-}
-
-/* check if test matches pattern
- * possible pattern: "a-zA-Z0-9+\-\\" (x-y dont work for c>127)
- * ToDo: wchar_t cc + matching UTF-8 pattern for nonASCII
- */
-int my_strchr( char *pattern, wchar_t cc ) {
- char *s1;
- if (pattern==(char *)NULL) return 0;
-
- /* if (!(cc&0x80)) s1=strchr(pattern,(char)cc); else */
- s1=strstr(pattern,decode(cc, UTF8));
- switch (cc) {
- case '-':
- case '\\':
- if ((!s1) || s1-pattern<1 || *(s1-1)!='\\') return 0;
- else return 1;
- default:
- if (s1) return 1; /* cc simply matches */
- s1=pattern+1;
- while (s1) {
- if ((!s1[0]) || (!s1[1])) return 0; /* end of string */
- if (*(s1-1)!='\\' && *(s1-1)<=cc && *(s1+1)>=cc) return 1;
- s1=strchr(s1+1,'-'); /* look for next '-' */
- }
- }
- return 0;
-}
-
-/* set alternate chars and its weight, called from the engine
- if a char is recognized to (weight) percent
- can be used for filtering (only numbers etc)
- often usefull if Il1 are looking very similar
- should this function stay in box.c ???
- weight is between 0 and 100 in percent, 100 means absolutely sure
- - not final, not time critical (js)
- - replace it by a string-function setaobj(*b,"string",weight)
- and let call setac the setas function
- */
-
-int setas(struct box *b, char *as, int weight){
- int i,j;
- if (b->num_ac > NumAlt || b->num_ac<0) {
- fprintf(stderr,"\nDBG: There is something wrong with setas()!");
- b->num_ac=0;
- }
- if (as==NULL) {
- fprintf(stderr,"\nDBG: setas(NULL) makes no sense!"); return 0; }
- if (as[0]==0) {
- fprintf(stderr,"\nDBG: setas(\"\") makes no sense!"
- " x= %d %d", b->x0, b->y0);
- // out_x(b);
- return 0;
- }
-
- /* char filter (ex: only numbers) ToDo: cfilter as UTF-8 */
- if (JOB->cfg.cfilter) {
- /* do not accept chars which are not in the cfilter string */
- if ( as[0]>0 && as[1]==0 )
- if ( !my_strchr(JOB->cfg.cfilter,as[0]) ) return 0;
- }
-#if 0 /* obsolete, done in setac */
- /* not sure that this is the right place, but where else? */
- if ( as[0]>0 && as[1]==0 )
- if (b->modifier != SPACE && b->modifier != 0) {
- wchar_t newac;
- newac = compose(as[0], b->modifier);
- as = (char *)decode(newac, UTF8); /* was (const char *) */
- if (newac == as[0]) { /* nothing composed */
- fprintf(stderr, "\nDBG setas compose was useless %d %d",b->x0,b->y0);
- // out_x(b);
- }
- }
-#endif
-
- /* only the first run gets the full weight */
- weight=(100-JOB->tmp.n_run)*weight/100;
-
- /* remove same entries from table */
- for (i=0;i<b->num_ac;i++)
- if (b->tas[i])
- if (strcmp(as,b->tas[i])==0) break;
- if (b->num_ac>0 && i<b->num_ac){
- if (weight<=b->wac[i]) return 0; /* if found + less weight ignore it */
- /* to insert the new weigth on the right place, we remove it first */
- if (b->tas[i]) free(b->tas[i]);
- for (j=i;j<b->num_ac-1;j++){ /* shift lower entries */
- b->tac[j]=b->tac[j+1]; /* copy the char */
- b->tas[j]=b->tas[j+1]; /* copy the pointer to the string */
- b->wac[j]=b->wac[j+1]; /* copy the weight */
- }
- b->num_ac--; /* shrink table */
- }
- /* sorting and add it to the table */
- for (i=0;i<b->num_ac;i++) if (weight>b->wac[i]) break;
- if (b->num_ac<NumAlt-1) b->num_ac++; /* enlarge table */
- for (j=b->num_ac-1;j>i;j--){ /* shift lower entries */
- b->tac[j]=b->tac[j-1]; /* copy the char */
- b->tas[j]=b->tas[j-1]; /* copy the pointer to the string */
- b->wac[j]=b->wac[j-1]; /* copy the weight */
- }
- if (i<b->num_ac) { /* insert new entry */
- b->tac[i]=0; /* insert the char=0 ... */
- b->tas[i]=(char *)malloc(strlen(as)+1); /* ... string */
- if (b->tas[i]) memcpy(b->tas[i],as,strlen(as)+1);
- b->wac[i]=weight; /* ... and its weight */
- }
- if (i==0) b->c=b->tac[0]; /* char or 0 for string */
- return 0;
-}
-
-/* ToDo: this function will be replaced by a call of setas() later */
-int setac(struct box *b, wchar_t ac, int weight){
- int i,j;
- if ((!b) || b->num_ac > NumAlt || b->num_ac<0) {
- fprintf(stderr,"\nDBG: This is a bad call to setac()!");
- b->num_ac=0;
- }
- if (ac==0 || ac==UNKNOWN) {
- fprintf(stderr,"\nDBG: setac(0) makes no sense!");
- return 0;
- }
- /* char filter (ex: only numbers) ToDo: cfilter as UTF-8 */
- if (JOB->cfg.cfilter) {
- /* do not accept chars which are not in the cfilter string */
- /* if ( ac>255 || !strchr(JOB->cfg.cfilter,(char)ac) ) return 0; */
- if ( !my_strchr(JOB->cfg.cfilter,ac) ) return 0;
- }
- /* not sure that this is the right place, but where else? */
- if (b->modifier != SPACE && b->modifier != 0) {
- wchar_t newac;
- newac = compose(ac, b->modifier);
- if (newac == ac) { /* nothing composed */
- if(JOB->cfg.verbose & 7)
- fprintf(stderr, "\nDBG setac(%s): compose was useless @ %d %d",
- decode(ac,ASCII), b->x0, b->y0);
- }
- ac = newac;
- }
-
- /* only the first run gets the full weight */
- weight=(100-JOB->tmp.n_run)*weight/100;
-
- /* remove same entries from table */
- for (i=0;i<b->num_ac;i++) if (ac==b->tac[i]) break;
- if (b->num_ac>0 && i<b->num_ac){
- if (weight<=b->wac[i]) return 0;
- if (b->tas[i]) free(b->tas[i]);
- for (j=i;j<b->num_ac-1;j++){ /* shift lower entries */
- b->tac[j]=b->tac[j+1]; /* copy the char */
- b->tas[j]=b->tas[j+1]; /* copy the pointer to the string */
- b->wac[j]=b->wac[j+1]; /* copy the weight */
- }
- b->num_ac--; /* shrink table */
- }
- /* sorting it to the table */
- for (i=0;i<b->num_ac;i++) if (weight>b->wac[i]) break;
- if (b->num_ac<NumAlt-1) b->num_ac++; /* enlarge table */
- for (j=b->num_ac-1;j>i;j--){ /* shift lower entries */
- b->tac[j]=b->tac[j-1]; /* copy the char */
- b->tas[j]=b->tas[j-1]; /* copy the pointer to the string */
- b->wac[j]=b->wac[j-1]; /* copy the weight */
- }
- if (i<b->num_ac) { /* insert new entry */
- b->tac[i]=ac; /* insert the char ... */
- b->tas[j]=NULL; /* ... no string (?) */
- b->wac[i]=weight; /* ... and its weight */
- }
- if (i==0) b->c=ac; /* store best result to b->c (will be obsolete) */
-
- return 0;
-}
-
-/* test if ac in wac-table
- usefull for contextcorrection and box-splitting
- return 0 if not found
- return wac if found (wac>0)
- */
-int testac(struct box *b, wchar_t ac){
- int i;
- if (b->num_ac > NumAlt || b->num_ac<0) {
- fprintf(stderr,"\n#DEBUG: There is something wrong with testac()!");
- b->num_ac=0;
- }
- /* search entries in table */
- for (i=0;i<b->num_ac;i++) if (ac==b->tac[i]) return b->wac[i];
- return 0;
-}
-
-
-/* look for edges: follow a line from x0,y0 to x1,y1, record the
- * location of each transition, and return their number.
- * ex: horizontal num_cross of 'm' would return 6
- * remark: this function is not used, obsolete? ToDo: remove?
- */
-int follow_path(int x0, int x1, int y0, int y1, pix *p, int cs, path_t *path) {
- int rc = 0, prev, x, y, i, d, color; // rc=crossings col=0=white
- int dx = x1 - x0, dy = y1 - y0;
-
- d = MAX(abs(dx), abs(dy));
- prev = getpixel(p, x0, y0) < cs; // 0=white 1=black
- path->start = prev;
- for (i = 1, x = x0, y = y0; i <= d; i++) {
- if (d) {
- x = x0 + i * dx / d;
- y = y0 + i * dy / d;
- }
- color = getpixel(p, x, y) < cs; // 0=white 1=black
- if (color != prev){
- if (rc>=path->max){
- int n=path->max*2+10;
- path->x = (int *) xrealloc(path->x, n*sizeof(int));
- path->y = (int *) xrealloc(path->y, n*sizeof(int));
- path->max = n;
- }
- path->x[rc]=x;
- path->y[rc]=y;
- rc++;
- }
- prev = color;
- }
- path->num=rc;
- return rc;
-}
-
-/* ToDo: only used in follow_path, which is obsolete, remove? */
-void *xrealloc(void *ptr, size_t size){
- void *p;
- p = realloc(ptr, size);
- if (size>0 && (!p)){
- fprintf(stderr, "insufficient memory");
- exit(1);
- }
- return p;
-}
-
-/*
- * -------------------------------------------------------------
- * mark edge-points
- * - first move forward until b/w-edge
- * - more than 2 pixel?
- * - loop around
- * - if forward pixel : go up, rotate right
- * - if forward no pixel : rotate left
- * - stop if found first 2 pixel in same order
- * go_along_the_right_wall strategy is very similar and used otherwhere
- * --------------------------------------------------------------
- * turmite game: inp: start-x,y, regel r_black=UP,r_white=RIght until border
- * out: last-position
- *
- * could be used to extract more features:
- * by counting stepps, dead-end streets ,xmax,ymax,ro-,ru-,lo-,lu-edges
- *
- * use this little animal to find features, I first was happy about it
- * but now I prefer the loop() function
- */
-
-void turmite(pix *p, int *x, int *y,
- int x0, int x1, int y0, int y1, int cs, int rw, int rb) {
- int r;
- if (outbounds(p, x0, y0)) // out of pixmap
- return;
- while (*x >= x0 && *y >= y0 && *x <= x1 && *y <= y1) {
- r = ((getpixel(p, *x, *y) < cs) ? rb : rw); // select rule
- switch (r) {
- case UP: (*y)--; break;
- case DO: (*y)++; break;
- case RI: (*x)++; break;
- case LE: (*x)--; break;
- case ST: break;
- default: assert(0);
- }
- if( r==ST ) break; /* leave the while-loop */
- }
-}
-
-/* search a way from p0 to p1 without crossing pixels of type t
- * only two directions, useful to test if there is a gap 's'
- * labyrinth algorithm - do you know a faster way? */
-int joined(pix *p, int x0, int y0, int x1, int y1, int cs){
- int t,r,x,y,dx,dy,xa,ya,xb,yb;
- x=x0;y=y0;dx=1;dy=0;
- if(x1>x0){xa=x0;xb=x1;} else {xb=x0;xa=x1;}
- if(y1>y0){ya=y0;yb=y1;} else {yb=y0;ya=y1;}
- t=((getpixel(p,x,y)<cs)?1:0);
- for(;;){
- if( t==((getpixel(p,x+dy,y-dx)<cs)?1:0) // right free?
- && x+dy>=xa && x+dy<=xb && y-dx>=ya && y-dx<=yb) // wall
- { r=dy;dy=-dx;dx=r;x+=dx;y+=dy; } // rotate right and step forward
- else { r=dx;dx=-dy;dy=r; } // rotate left
- // fprintf(stderr," path xy %d-%d %d-%d %d %d %d %d\n",xa,xb,ya,yb,x,y,dx,dy);
- if( x==x1 && y==y1 ) return 1;
- if( x==x0 && y==y0 && dx==1) return 0;
- }
- // return 0; // endless loop ?
-}
-
-/* move from x,y to direction r until pixel of color col is found
- * or maximum of l steps
- * return the number of steps done */
-int loop(pix *p,int x,int y,int l,int cs,int col, DIRECTION r){
- int i=0;
- if(x>=0 && y>=0 && x<p->x && y<p->y){
- switch (r) {
- case UP:
- for( ;i<l && y>=0;i++,y--)
- if( (getpixel(p,x,y)<cs)^col )
- break;
- break;
- case DO:
- for( ;i<l && y<p->y;i++,y++)
- if( (getpixel(p,x,y)<cs)^col )
- break;
- break;
- case LE:
- for( ;i<l && x>=0;i++,x--)
- if( (getpixel(p,x,y)<cs)^col )
- break;
- break;
- case RI:
- for( ;i<l && x<p->x;i++,x++)
- if( (getpixel(p,x,y)<cs)^col )
- break;
- break;
- default:;
- }
- }
- return i;
-}
-
-/* Given a point, frames a rectangle containing all points of the same
- * color surrounding it, and mark these points.
- * ToDo: obsolate and replaced by frame_vector
- *
- * looking for better algo: go horizontally and look for upper/lower non_marked_pixel/nopixel
- * use lowest three bits for mark
- * - recursive version removed! AmigaOS has no Stack-OVL-Event
- * run around the chape using laby-robot
- * bad changes can lead to endless loop!
- * - this is not absolutely sure but mostly works well
- * diag - 0: only pi/2 direction, 1: pi/4 directions (diagonal)
- * mark - 3 bit marker, mark each valid pixel with it
- */
-int frame_nn(pix *p, int x, int y,
- int *x0, int *x1, int *y0, int *y1, // enlarge frame
- int cs, int mark,int diag){
-#if 1 /* flood-fill to detect black objects, simple and faster? */
- int rc = 0, dx, col, maxstack=0; static int overflow=0;
- int bmax=1024, blen=0, *buf; /* buffer as replacement for recursion stack */
-
- /* check bounds */
- if (outbounds(p, x, y)) return 0;
- /* check if already marked (with mark since v0.4) */
- if ((marked(p,x,y)&mark)==mark) return 0;
-
- col = ((getpixel(p, x, y) < cs) ? 0 : 1);
- buf=(int *)malloc(bmax*sizeof(int)*2);
- if (!buf) { fprintf(stderr,"malloc failed (frame_nn)\n");return 0;}
- buf[0]=x;
- buf[1]=y;
- blen=1;
-
- g_debug(fprintf(stderr,"\nframe_nn x=%4d y=%4d",x,y);)
- for ( ; blen ; ) {
- /* max stack depth is complexity of the object */
- if (blen>maxstack) maxstack=blen;
- blen--; /* reduce the stack */
- x=buf[blen*2+0];
- y=buf[blen*2+1];
- if (y < *y0) *y0 = y;
- if (y > *y1) *y1 = y;
- /* first go to leftmost pixel */
- for ( ; x>0 && (col == ((getpixel(p, x-1, y) < cs) ? 0 : 1)) ; x--);
- if ((marked(p,x,y)&mark)==mark) continue; /* already scanned */
- for (dx=-1;dx<2;dx+=2) /* look at upper and lower line, left */
- if ( diag && x<p->x && x-1>0 && y+dx >=0 && y+dx < p->y
- && col != ((getpixel(p, x , y+dx) < cs) ? 0 : 1)
- && col == ((getpixel(p, x-1, y+dx) < cs) ? 0 : 1)
- && !((marked(p,x-1,y+dx)&mark)==mark)
- ) {
- if (blen+1>=bmax) { overflow|=1; continue; }
- buf[blen*2+0]=x-1;
- buf[blen*2+1]=y+dx;
- blen++;
- }
- if (x < *x0) *x0 = x;
- /* second go right, mark and get new starting points */
- for ( ; x<p->x && (col == ((getpixel(p, x , y) < cs) ? 0 : 1)) ; x++) {
- p->p[x + y * p->x] |= (mark & 7); rc++; /* mark pixel */
- /* enlarge frame */
- if (x > *x1) *x1 = x;
- for (dx=-1;dx<2;dx+=2) /* look at upper and lower line */
- if ( col == ((getpixel(p, x , y+dx) < cs) ? 0 : 1)
- && (
- col != ((getpixel(p, x-1, y ) < cs) ? 0 : 1)
- || col != ((getpixel(p, x-1, y+dx) < cs) ? 0 : 1) )
- && !((marked(p,x,y+dx)&mark)==mark) && y+dx<p->y && y+dx>=0
- ) {
- if (blen+1>=bmax) { overflow|=1; continue; }
- buf[blen*2+0]=x;
- buf[blen*2+1]=y+dx;
- blen++;
- }
- }
- for (dx=-1;dx<2;dx+=2) /* look at upper and lower line, right */
- if ( diag && x<p->x && x-1>0 && y+dx >=0 && y+dx < p->y
- && col == ((getpixel(p, x-1, y ) < cs) ? 0 : 1)
- && col != ((getpixel(p, x , y ) < cs) ? 0 : 1)
- && col != ((getpixel(p, x-1, y+dx) < cs) ? 0 : 1)
- && col == ((getpixel(p, x , y+dx) < cs) ? 0 : 1)
- && !((marked(p,x,y+dx)&mark)==mark)
- ) {
- if (blen+1>=bmax) { overflow|=1; continue; }
- buf[blen*2+0]=x;
- buf[blen*2+1]=y+dx;
- blen++;
- }
- }
-
- /* debug, ToDo: use info maxstack and pixels for image classification */
- g_debug(fprintf(stderr," maxstack= %4d pixels= %6d",maxstack,rc);)
- if (overflow==1){
- overflow|=2;
- fprintf(stderr,"# Warning: frame_nn stack oerflow\n");
- }
- free(buf);
-#else /* old version, ToDo: improve it for tmp04/005*.pgm.gz */
- int i, j, d, dx, ox, oy, od, nx, ny, rc = 0, rot = 0, x2 = x, y2 = y, ln;
-
- static const int d0[8][2] = { { 0, -1} /* up */, {-1, -1},
- {-1, 0} /* left */, {-1, 1},
- { 0, 1} /* down */, { 1, 1},
- { 1, 0} /* right */, { 1, -1}};
-
- /* check bounds */
- if (outbounds(p, x, y))
- return 0;
- /* check if already marked */
- if ((marked(p,x,y)&mark)==mark)
- return 0;
-
- i = ((getpixel(p, x, y) < cs) ? 0 : 1);
- rc = 0;
-
- g_debug(fprintf(stderr," start frame:");)
-
- for (ln = 0; ln < 2 && rot >= 0; ln++) { // repeat if right-loop
- g_debug(fprintf(stderr," ln=%d diag=%d cs=%d x=%d y=%d - go to border\n",ln,diag,cs,x,y);)
-
- od=d=(8+4*ln-diag)&7; // start robot looks up, right is a wall
- // go to right (left) border
- if (ln==1) {
- x=x2; y=y2;
- }
- /* start on leftmost position */
- for (dx = 1 - 2*ln; x + dx < p->x && x + dx >= 0 /* bounds */ &&
- i == ((getpixel(p, x + dx, y) < cs) ? 0 : 1) /* color */;
- x += dx);
-
- g_debug(fprintf(stderr," ln=%d diag=%d cs=%d x=%d y=%d\n",ln,diag,cs,x,y);)
-
- /* robot stores start-position */
- ox = x; oy = y;
- for (rot = 0; abs(rot) <= 64; ) { /* for sure max. 8 spirals */
- /* leftmost position */
- if (ln == 0 && x < x2) {
- x2 = x; y2 = y;
- }
-
- g_debug(fprintf(stderr," x=%3d y=%3d d=%d i=%d p=%3d rc=%d\n",x,y,d,i,getpixel(p,x,y),rc);)
-
- if ( abs(d0[d][1]) ) { /* mark left (right) pixels */
- for (j = 0, dx = d0[d][1]; x + j >= 0 && x + j < p->x
- && i == ((getpixel(p, x + j, y) < cs) ? 0 : 1); j += dx) {
- if (!((marked(p, x + j, y)&mark)==mark))
- rc++;
- p->p[x + j + y * p->x] |= (mark & 7);
- }
- }
- /* look to the front of robot */
- nx = x + d0[d][0];
- ny = y + d0[d][1];
- /* if right is a wall */
- if ( outbounds(p, nx, ny) || i != ((getpixel(p,nx,ny)<cs) ? 0 : 1) ) {
- /* rotate left */
- d=(d+2-diag) & 7; rot-=2-diag;
- }
- else { /* if no wall, go, turn back and rotate left */
- x=nx; y=ny; d=(d+4+2-diag) & 7; rot+=2-diag+4;
- /* enlarge frame */
- if (x < *x0) *x0 = x;
- if (x > *x1) *x1 = x;
- if (y < *y0) *y0 = y;
- if (y > *y1) *y1 = y;
- }
- if(x==ox && y==oy && d==od) break; // round trip finished
- }
- }
- g_debug(fprintf(stderr," rot=%d\n",rot);)
-#endif
- return rc;
-}
-
-/* obsolete! replaced by vectors
- * mark neighbouring pixel of same color, return number
- * better with neighbours of same color (more general) ???
- * parameters: (&~7)-pixmap, start-point, critical_value, mark
- * recursion is removed */
-int mark_nn(pix * p, int x, int y, int cs, int r) {
- /* out of bounds or already marked? */
- if (outbounds(p, x, y) || (marked(p, x, y)&r)==r)
- return 0;
- {
- int x0, x1, y0, y1;
- x0 = x1 = x;
- y0 = y1 = y; // not used
- return frame_nn(p, x, y, &x0, &x1, &y0, &y1, cs, r, JOB->tmp.n_run & 1);
- // using same scheme
- }
-}
-
-/* ToDo: finish to replace old frame by this new one
- *
- * @...........#@@@@@@@. # = marked as already scanned black pixels
- * @........@@@@@@@@@@@# only left and right border
- * .......#@@@@@@@@@@@@@ left side on even y
- * ......@@@@@@@@#.@@@@# right side on odd y
- * .....#@@@@@......#@@@ no border is marked twice
- * ....@@@@@#......@@@#. works also for thinn lines
- * ...#@@@@........#@@@. - outer loop is stored as first
- * ..@@@@#........@@@#.. - inner loop is stored as second
- * .#@@@@........#@@@@.. 1st in an extra box (think on white chars)
- * @@@@#.......@@@@#.... 2nd merge in an extra step
- * #@@@@@....#@@@@@.....
- * @@@@@@@@@@@@@@#......
- * .#@@@@@@@@@@@@.......
- *
- * run around the chape using laby-robot
- * - used for scanning boxes, look for horizontal b/w transitions
- * with unmarked black pixels and call this routine
- * - stop if crossing a marked box in same direction (left=up, right=down)
- * box - char box, store frame_vectors and box
- * x,y - starting point
- * mark - 3 bit marker, mark each valid pixel with it
- * diag - 0: only pi/2 direction, 1: pi/4 directions (diagonal)
- * ds - start direction, 6=right of right border, 2=left of left border
- * ret - 0=ok, -1=already marked, -2=max_num_frames_exceeded
- * -7=no border in direction ds
- */
-#if 0
-#undef g_debug
-#define g_debug(x) x
-#endif
-/* grep keywords: scan_vectors frame_vector */
-int frame_vector(struct box *box1, int x, int y,
- int cs, int mark, int diag, int ds) {
- int i1, i2, i2o,
- new_x=1, /* flag for storing the vector x,y */
- steps=1, /* steps between stored vectors, speedup for big frames */
- d, /* direction */
- ox, oy, /* starting point */
- nx, ny, mx, my, /* used for simplification */
- /* ToDo: add periphery to box (german: Umfang?) */
- rc = 1, /* return code, circumference, sum vector lengths */
- rot = 0, /* memory for rotation, rot=8 means one full rotation */
- vol = 0; /* volume inside frame, negative for white inside black */
- pix *p=box1->p;
-
- /* translate the 8 directions to (x,y) pairs,
- * if only four directions are used, only every 2nd vector is accessed,
- * +1 turn left, -1 turn right
- */
- static const int d0[8][2] =
- { { 0, -1}, /* up */ {-1, -1}, /* up-le */
- {-1, 0}, /* left */ {-1, 1}, /* do-le */
- { 0, 1}, /* down */ { 1, 1}, /* do-ri */
- { 1, 0}, /* right */ { 1, -1} }; /* up-ri */
-
- /* check bounds */
- if (outbounds(p, x, y))
- return 0;
-
- /* pixel color we are looking for, 0=black, 1=white */
- d = ds;
- i1 = ((getpixel(p, x, y ) < cs) ? 0 : 1);
- i2 = ((getpixel(p, x + d0[d][0], y + d0[d][1]) < cs) ? 0 : 1);
-
- g_debug(fprintf(stderr,"\nLEV2 frame_vector @ %3d %3d d%d %2d %2d"
- " %d-%d pix=%3d mark=%d cs=%d",\
- x,y,ds,d0[ds][0],d0[ds][1],i1,i2,getpixel(p,x,y),mark,cs);)
-
- if (i1==i2){
- fprintf(stderr,"ERROR frame_vector: no border\n");
- return -7; /* no border detected */
- }
-
- /* initialize boxframe outside this function
- box1->x0=box1->x1=x;
- box1->y0=box1->y1=y;
- */
-
- /* initialize boxvector outside this function
- box1->num_frames=0
- num_frame_vectors[0]=0 ???
- and store start value
- */
- if (box1->num_frames > MaxNumFrames) return -2;
- /* index to next (x,y) */
- i2o=i2=( (box1->num_frames==0)?0:
- box1->num_frame_vectors[ box1->num_frames ] );
-#if 0 // obsolete v0.43
- box1->frame_vector[i2][0]=x;
- box1->frame_vector[i2][1]=y;
- i2++;
- box1->num_frame_vectors[ box1->num_frames ]=i2;
-#endif
- box1->num_frames++;
-
- /* robot stores start-position */
- ox = x; oy = y; /* look forward to white pixel */
-
- for (;;) { /* stop if same marked pixel touched */
-
- g_debug(fprintf(stderr,"\nLEV3: x= %3d %3d d= %d rot= %2d %3d",x,y,d,rot,i2);)
-
- /* ToDo: store max. abs(rot) ??? for better recognition */
- if (new_x) {
- g_debug(fprintf(stderr,"\nLEV2: markB xy= %3d %3d ", x, y);)
- p->p[x + y * p->x] |= (mark & 7); /* mark black pixel */
- }
-
- /* store a new vector or enlarge the predecessor */
- if (new_x && (rc%steps)==0) { /* dont store everything on big chars */
- if (i2>=MaxFrameVectors) {
- box1->num_frame_vectors[ box1->num_frames-1 ]=i2;
- reduce_vectors(box1,1); /* simplify loop */
- i2=box1->num_frame_vectors[ box1->num_frames-1 ];
- /* enlarge steps on big chars getting speedup */
- steps=(box1->y1-box1->y0+box1->x1-box1->x0)/32+1;
- }
- /* store frame-vector */
- if (i2<MaxFrameVectors) {
- box1->frame_vector[i2][0]=x;
- box1->frame_vector[i2][1]=y;
- /* test if older vector points to the same direction */
- if (i2>1) {
- /* get predecessor */
- nx=box1->frame_vector[i2-1][0]-box1->frame_vector[i2-2][0];
- ny=box1->frame_vector[i2-1][1]-box1->frame_vector[i2-2][1];
- mx=x -box1->frame_vector[i2-1][0];
- my=y -box1->frame_vector[i2-1][1];
- /* same direction? */
- if (nx*my-ny*mx==0 && nx*mx>=0 && ny*my>=0) {
- /* simplify by removing predecessor */
- i2--;
- box1->frame_vector[i2][0]=x;
- box1->frame_vector[i2][1]=y;
- } /* do not simplify */
- }
- i2++;
- box1->num_frame_vectors[ box1->num_frames-1 ]=i2;
- }
- g_debug(fprintf(stderr," stored @ %3d steps= %d", i2-1, steps);)
- }
- new_x=0; /* work for new pixel (x,y) done */
-
- /* check if round trip is finished */
- if (x==ox && y==oy && abs(rot)>=8) break;
-
- /* look to the front of robot (turtle or ant) */
- nx = x + d0[d][0];
- ny = y + d0[d][1];
-
- /* next step, if right is a wall turn the turtle left */
- if ( outbounds(p, nx, ny) || i1 != ((getpixel(p,nx,ny)<cs) ? 0 : 1) ) {
- if (y==ny && nx>=0 && nx<p->x) { /* if inbound */
- g_debug(fprintf(stderr,"\nLEV2: markW xy= %3d %3d ", nx, ny);)
- p->p[nx + ny * p->x] |= (mark & 7); /* mark white pixel */
- }
- /* rotate left 90 or 45 degrees */
- d=(d+2-diag) & 7; rot+=2-diag;
- /* calculate volume inside frame */
- switch (d+diag) {
- case 2+2: vol-=x-1; break;
- case 6+2: vol+=x; break;
- }
- }
- else { /* if no wall, go forward and turn right (90 or 45 degrees) */
- x=nx; y=ny;
- /* turn back and rotate left */
- d=(d+4+2-diag) & 7; rot+=2-diag-4;
- rc++; /* counting steps, used for speedup */
-
- /* enlarge frame */
- if (x < box1->x0) box1->x0 = x;
- if (x > box1->x1) box1->x1 = x;
- if (y < box1->y0) box1->y0 = y;
- if (y > box1->y1) box1->y1 = y;
-
- new_x=1;
- }
- }
-
- /* to distinguish inner and outer frames, store volume as +v or -v */
- box1->frame_vol[ box1->num_frames-1 ] = vol;
- box1->frame_per[ box1->num_frames-1 ] = rc-1;
-
- /* dont count and store the first vector twice */
- if (i2-i2o>1) {
- i2--; rc--; box1->num_frame_vectors[ box1->num_frames-1 ]=i2;
- }
- /* output break conditions */
- g_debug(fprintf(stderr,"\nLEV2 o= %3d %3d x= %3d %3d r=%d v=%d",ox,oy,x,y,rot,vol);)
- /* rc=1 for a single point, rc=2 for a two pixel sized point */
- g_debug(fprintf(stderr," steps= %3d vectors= %3d",rc,i2);)
- /* out_x(box1); ToDo: output only the first thousend */
- return rc; /* return number of bordering pixels = periphery? */
-}
-
-
-
-/* clear lowest 3 (marked) bits (they are used for marking) */
-void clr_bits(pix * p, int x0, int x1, int y0, int y1) {
- int x, y;
- for ( y=y0; y <= y1; y++)
- for ( x=x0; x <= x1; x++)
- p->p[x+y*p->x] &= ~7;
-}
-
-/* look for white holes surrounded by black points
- * at the moment look for white point with black in all four directions
- * - store position of hole in coordinates relativ to box!
- * ToDo: count only holes with vol>10% ???
- * ToDo: rewrite for frame vectors (faster, no malloc)
- * holes are frames rotating left hand
- * obsolete, do it with vectors
- */
-int num_hole(int x0, int x1, int y0, int y1, pix * p, int cs, holes_t *holes) {
- int num_holes = 0, x, y, hole_size;
- pix b; // temporary mini-page
- int dx = x1 - x0 + 1, dy = y1 - y0 + 1;
- unsigned char *buf; // 2nd copy of picture, for working
-
- if (holes) holes->num=0;
- if(dx<3 || dy<3) return 0;
- b.p = buf = (unsigned char *) malloc( dx * dy );
- if( !buf ){
- fprintf( stderr, "\nFATAL: malloc(%d) failed, skip num_hole", dx*dy );
- return 0;
- }
- if (copybox(p, x0, y0, dx, dy, &b, dx * dy))
- { free(b.p); return -1;}
-
- // printf(" num_hole(");
- /* --- mark white-points connected with border */
- for (x = 0; x < b.x; x++) {
- if (getpixel(&b, x, 0) >= cs)
- mark_nn(&b, x, 0, cs, AT);
- if (getpixel(&b, x, b.y - 1) >= cs)
- mark_nn(&b, x, b.y - 1, cs, AT);
- }
- for (y = 0; y < b.y; y++) {
- if (getpixel(&b, 0, y) >= cs)
- mark_nn(&b, 0, y, cs, AT);
- if (getpixel(&b, b.x - 1, y) >= cs)
- mark_nn(&b, b.x - 1, y, cs, AT);
- }
-
- //g_debug(out_b(NULL,&b,0,0,b.x,b.y,cs);)
- // --- look for unmarked white points => hole
- for (x = 0; x < b.x; x++)
- for (y = 0; y < b.y; y++)
- if (!((marked(&b, x, y)&AT)==AT)) // unmarked
- if (getpixel(&b, x, y) >= cs) { // hole found
-#if 0
- hole_size=mark_nn(&b, x, y, cs, AT); /* old version */
- if (hole_size > 1 || dx * dy <= 40)
- num_holes++;
-#else
- { /* new version, for future store of hole characteristics */
- int x0, x1, y0, y1, i, j;
- x0 = x1 = x;
- y0 = y1 = y; // not used
- hole_size=frame_nn(&b, x, y, &x0, &x1, &y0, &y1, cs, AT, JOB->tmp.n_run & 1);
- // store hole for future use, num is initialized with 0
- if (hole_size > 1 || dx * dy <= 40){
- num_holes++;
- if (holes) {
- // sort in table
- for (i=0;i<holes->num && i<MAX_HOLES;i++)
- if (holes->hole[i].size < hole_size) break;
- for (j=MAX_HOLES-2;j>=i;j--)
- holes->hole[j+1]=holes->hole[j];
- if (i<MAX_HOLES) {
- // printf(" i=%d size=%d\n",i,hole_size);
- holes->hole[i].size=hole_size;
- holes->hole[i].x=x;
- holes->hole[i].y=y;
- holes->hole[i].x0=x0;
- holes->hole[i].y0=y0;
- holes->hole[i].x1=x1;
- holes->hole[i].y1=y1;
- }
- holes->num++;
- }
- }
- }
-#endif
- }
- free(b.p);
- // printf(")=%d",num_holes);
- return num_holes;
-}
-
-/* count for black nonconnected objects --- used for i,auml,ouml,etc. */
-/* ToDo: obsolete, replaced by vectors and box.num_boxes */
-int num_obj(int x0, int x1, int y0, int y1, pix * p, int cs) {
- int x, y, rc = 0; // rc=num_obj
- unsigned char *buf; // 2nd copy of picture, for working
- pix b;
-
- if(x1<x0 || y1<y0) return 0;
- b.p = buf = (unsigned char *) malloc( (x1-x0+1) * (y1-y0+1) );
- if( !buf ){
- fprintf( stderr, "\nFATAL: malloc(%d) failed, skip num_obj",(x1-x0+1)*(y1-y0+1) );
- return 0;
- }
- if (copybox(p, x0, y0, x1 - x0 + 1, y1 - y0 + 1, &b, (x1-x0+1) * (y1-y0+1)))
- { free(b.p); return -1; }
- // --- mark black-points connected with neighbours
- for (x = 0; x < b.x; x++)
- for (y = 0; y < b.y; y++)
- if (getpixel(&b, x, y) < cs)
- if (!((marked(&b, x, y)&AT)==AT)) {
- rc++;
- mark_nn(&b, x, y, cs, AT);
- }
- free(b.p);
- return rc;
-}
-
-#if 0
-// ----------------------------------------------------------------------
-// first idea for making recognition based on probability
-// - start with a list of all possible chars
-// - call recognition_of_char(box *)
-// - remove chars from list which could clearly excluded
-// - reduce probability of chars which have wrong features
-// - font types list could also build
-// at the moment it is only an idea, I should put it to the todo list
-//
-char *list="0123456789,.\0xe4\0xf6\0xfc" // "a=228 o=246 u=252
- "abcdefghijklmnopqrstuvwxyz"
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
-int wert[100];
-int listlen=0,numrest=0;
-// initialize a new character list (for future)
-void ini_list(){ int i;
- for(i=0;list[i]!=0 && i<100;i++) wert[i]=0;
- numrest=listlen=i; }
-// exclude??? (for future) oh it was long time ago, I wrote that :/
-void exclude(char *filt){ int i,j;
- for(j=0;filt[j]!=0 && j<100;j++)
- for(i=0;list[i]!=0 && i<100;i++)
- if( filt[j]==list[i] ) { if(!wert[i])numrest--; wert[i]++; } }
-// get the result after all the work (for future)
-char getresult(){ int i;
- if( numrest==1 )
- for(i=0;list[i]!=0 && i<100;i++) if(!wert[i]) return list[i];
- return '_';
- }
-#endif
-
-// look at the environment of the pixel too (contrast etc.)
-// detailed analysis only of diff pixels!
-//
-// 100% * "distance", 0 is ideal fit
-// = similarity of two chars for recognition of garbled (verstuemmelter) chars
-// weight of pixels with only one same neighbour set to 0
-// look at contours too! v0.2.4: B==H
-// changed for v0.41, Mar06
-int distance( pix *p1, struct box *box1,
- pix *p2, struct box *box2, int cs){
- int rc=0,x,y,v1,v2,i1,i2,rgood=0,rbad=0,x1,y1,x2,y2,dx,dy,dx1,dy1,dx2,dy2;
- x1=box1->x0;y1=box1->y0;x2=box2->x0;y2=box2->y0;
- dx1=box1->x1-box1->x0+1; dx2=box2->x1-box2->x0+1; dx=((dx1>dx2)?dx1:dx2);
- dy1=box1->y1-box1->y0+1; dy2=box2->y1-box2->y0+1; dy=((dy1>dy2)?dy1:dy2);
- if(abs(dx1-dx2)>1+dx/16 || abs(dy1-dy2)>1+dy/16) return 100;
- // compare relations to baseline and upper line
- if(2*box1->y1>box1->m3+box1->m4 && 2*box2->y1<box2->m3+box2->m4) rbad+=128;
- if(2*box1->y0>box1->m1+box1->m2 && 2*box2->y0<box2->m1+box2->m2) rbad+=128;
- // compare pixels
- for( y=0;y<dy;y++ )
- for( x=0;x<dx;x++ ) { // try global shift too ???
- v1 =((getpixel(p1,x1+x ,y1+y )<cs)?1:0); i1=8; // better gray?
- v2 =((getpixel(p2,x2+x ,y2+y )<cs)?1:0); i2=8; // better gray?
- if(v1==v2) { rgood+=8; continue; } // all things are right!
- // what about different pixel???
- // test overlap of 8 surounding pixels ??? bad if two nb. are bad
- v1=-1;
- for(i1=-1;i1<2;i1++)
- for(i2=-1;i2<2;i2++)if(i1!=0 || i2!=0){
- if( ((getpixel(p1,x1+x+i1*(1+dx/32),y1+y+i2*(1+dy/32))<cs)?1:0)
- !=((getpixel(p2,x2+x+i1*(1+dx/32),y2+y+i2*(1+dy/32))<cs)?1:0) ) v1++;
- }
- if (v1>0) rbad+=16*v1;
- else rbad++;
- }
- if(rgood+rbad) rc= (100*rbad+(rgood+rbad-1))/(rgood+rbad); else rc=99;
- if(rc<10 && JOB->cfg.verbose & 7){
- fprintf(stderr,"\n# distance rc=%d good=%d bad=%d",rc,rgood,rbad);
-// out_x(box1);out_x(box2);
- }
- return rc;
-}
-
-
-
-// ============================= call OCR engine ================== ;)
-// nrun=0 from outside, nrun=1 from inside (allows modifications, oobsolete)
-wchar_t whatletter(struct box *box1, int cs, int nrun){
- wchar_t bc=UNKNOWN; // best letter
- wchar_t um=SPACE; // umlaut? '" => modifier
- pix *p=box1->p; // whole image
- int x,y,dots,xa,ya,x0,x1,y0,y1,dx,dy,i;
- pix b; // box
- struct box bbuf=*box1; // restore after modifikation!
-
- if (box1->num_ac>0 && box1->wac[0]>=JOB->cfg.certainty && bc==UNKNOWN) {
- bc=box1->tac[0];
- }
- // if (bc!=UNKNOWN) return bc;
- // if whatletter() called again, only unknown chars are processed
- // bad for splitting!
-
- // store box data, which can be modified for modified chars in 2nd run
- bbuf.x0=box1->x0; bbuf.y0=box1->y0;
- bbuf.x1=box1->x1; bbuf.y1=box1->y1;
-
- xa=box1->x; ya=box1->y;
- x0=box1->x0; y0=box1->y0;
- x1=box1->x1; y1=box1->y1;
- // int vol=(y1-y0+1)*(x1-x0+1); // volume
- // crossed l-m , divided chars
- while( get_bw(x0,x1,y0,y0,p,cs,1)!=1 && y0+1<y1) y0++;
- while( get_bw(x0,x1,y1,y1,p,cs,1)!=1 && y0+1<y1) y1--;
- dx=x1-x0+1;
- dy=y1-y0+1; // size
-
- // better to proof the white frame too!!! ????
- // --- test for german umlaut and points above, not robust enough???
- // if three chars are connected i-dots (ari) sometimes were not detected
- // - therefore after division a test could be useful
- // modify y0 only in second run!?
- // we need it here to have the right copybox
- if (um==SPACE && dy>5 && box1->num_boxes>1)
- testumlaut(box1,cs,2,&um); /* set box1->modifier + new y0 */
-
- dots=box1->dots;
- y0 =box1->y0; // dots==2 => y0 below double dots
- dy =y1-y0+1;
-
- // move upper and lower border (for divided letters)
- while( get_bw(x0,x1,y0,y0,p,cs,1)==0 && y0+1<y1) y0++;
- while( get_bw(x0,x1,y1,y1,p,cs,1)==0 && y0+1<y1) y1--;
- while( get_bw(x0,x0,y0,y1,p,cs,1)==0 && x0+1<x1) x0++;
- while( get_bw(x1,x1,y0,y1,p,cs,1)==0 && x0+1<x1) x1--;
- dx=x1-x0+1;
- dy=y1-y0+1; // size
- box1->x0=x0; box1->y0=y0; // set reduced frame
- box1->x1=x1; box1->y1=y1;
-
- // set good startpoint (probably bad from division)?
- if( xa<x0 || xa>x1 || ya<y0 || ya>y1
- || getpixel(p,xa,ya)>=cs /* || 2*ya<y0+y1 */ || dots>0 ){
- // subfunction? also called after division of two glued chars?
- for(y=y1;y>=y0;y--) // low to high (not i-dot)
- for(x=(x0+x1)/2,i=0;x>=x0 && x<=x1;i++,x+=((2*i&2)-1)*i) /* is that ok? */
- if (getpixel(p,x,y)<cs && (getpixel(p,x+1,y)<cs
- || getpixel(p,x,y+1)<cs)){ xa=x;ya=y;y=-1;break; }
- /* should box1->x,y be set? */
- }
-
- // ----- create char-only-box -------------------------------------
- // ToDo: this will be obsolete if vectors are used only
- if(dx<1 || dy<1) return bc; /* should not happen */
- b.p = (unsigned char *) malloc( dx * dy );
- if (!b.p) fprintf(stderr,"Warning: malloc failed L%d\n",__LINE__);
- if( copybox(p,x0,y0,dx,dy,&b,dx*dy) )
- { free(b.p); return bc; }
- // clr_bits(&b,0,b.x-1,0,b.y-1);
- // ------ use diagonal too (only 2nd run?)
- /* following code failes on ! and ? obsolete if vectors are used
- ToDo:
- - mark pixels neighoured to pixels outside and remove them from &b
- v0.40
- will be replaced by list of edge vectors
- - mark accents, dots and remove them from &b
- */
-#if 1 /* becomes obsolate by vector code */
- if (y0>0) // mark upper overlap
- for ( x=x0; x<=x1; x++) {
- if (getpixel(p,x,y0-1)<cs
- && getpixel(p,x,y0 )<cs && (marked(&b,x-x0,0)&1)!=1)
- mark_nn(&b,x-x0,0,cs,1);
- }
- if (x0>0) // mark left overlap
- for ( y=y0; y<=y1; y++) {
- if (getpixel(p,x0-1,y)<cs
- && getpixel(p,x0 ,y)<cs && (marked(&b,0,y-y0 )&1)!=1)
- mark_nn(&b,0,y-y0,cs,1);
- }
- if (x1<p->x-1) // mark right overlap
- for ( y=y0; y<=y1; y++) {
- if (getpixel(p,x1+1,y)<cs
- && getpixel(p,x1 ,y)<cs && (marked(&b,x1-x0,y-y0)&1)!=1)
- mark_nn(&b,x1-x0,y-y0,cs,1);
- }
- mark_nn(&b,xa-x0,ya-y0,cs,2); // not glued chars
- for(x=0;x<b.x;x++)
- for(y=0;y<b.y;y++){
- if ( (marked(&b,x,y )&3)==1 && getpixel(&b,x,y )<cs )
- b.p[x+y*b.x] = 255&~7; /* reset pixel */
- }
-#endif
-
- // if (bc == UNKNOWN) // cause split to fail
- bc=ocr0(box1,&b,cs);
-
- /* ToDo: try to change pixels near cs?? or melt? */
- if (box1->num_ac>0 && box1->wac[0]>=JOB->cfg.certainty && bc==UNKNOWN) {
- bc=box1->tac[0];
- }
-
- if (um!=0 && um!=SPACE && bc<127) { /* ToDo: is that obsolete now? */
- wchar_t newbc;
- newbc = compose(bc, um );
- if (newbc == bc) { /* nothing composed */
- if(JOB->cfg.verbose & 7)
- fprintf(stderr, "\nDBG whatletter: compose(%s) was useless (%d,%d)",
- decode(bc,ASCII), box1->x0, box1->y0);
- // if(JOB->cfg.verbose & 6) out_x(box1);
- }
- bc = newbc;
- }
- // restore modified boxes
- box1->x0=bbuf.x0; box1->y0=bbuf.y0;
- box1->x1=bbuf.x1; box1->y1=bbuf.y1;
-// if (box1->c==UNKNOWN) out_b(box1,&b,0,0,dx,dy,cs); // test
-
- free(b.p);
- return bc;
-}
-
-/*
-** creates a list of boxes/frames around objects detected
-** on the pixmap p for further work
-** returns number of boxes created.
-** - by the way: get average X, Y (avX=sumX/numC,..)
-*/
-int scan_boxes( pix *p ){
- int x, y, nx, cs, rc, ds;
- struct box *box3;
-
- if (JOB->cfg.verbose)
- fprintf(stderr,"# scanning boxes");
-
- cs = JOB->cfg.cs;
- JOB->res.sumX = JOB->res.sumY = JOB->res.numC = 0;
-
- /* clear the lowest bits of each pixel, later used as "scanned"-marker */
- clr_bits( p, 0, p->x - 1, 0, p->y - 1);
-
- for (y=0; y < p->y; y++)
- for (x=0; x < p->x; x++)
- for (ds=2; ds<7; ds+=4) { // NO - dust of size 1 is not removed !!!
- nx=x+((ds==2)?-1:+1);
- if (nx<0 || nx>=p->x) continue; /* out of image, ex: recframe */
- if ( getpixel(p, x,y)>=cs || getpixel(p,nx,y)< cs) // b/w transition?
- continue;
- if ((marked(p, x,y) & 1)&&(marked(p, nx, y) & 1))
- continue;
- /* check (and mark) only horizontal b/w transitions */
- // --- insert new box in list
- box3 = (struct box *)malloc_box(NULL);
- box3->x0=box3->x1=box3->x=x;
- box3->y0=box3->y1=box3->y=y;
- box3->num_frames=0;
- box3->dots=0;
- box3->num_boxes=1;
- box3->num_subboxes=0;
- box3->modifier='\0';
- box3->num=JOB->res.numC;
- box3->line=0; // not used here
- box3->m1=0; box3->m2=0; box3->m3=0; box3->m4=0;
- box3->p=p;
- box3->num_ac=0; // for future use
-
-/* frame, vectorize and mark only odd/even horizontal b/w transitions
- * args: box, x,y, cs, mark, diag={0,1}, ds={2,6}
- * ds - start direction, 6=right of right border, 2=left of left border
- * ret - 0=ok, -1=already marked, -2=max_num_frames_exceeded
- * -7=no border in direction ds
- * ToDo: count errors and print out for debugging
- */
- rc=frame_vector(box3, x, y, cs, 1, 1, ds);
- g_debug(fprintf(stderr,"\n# ... scan xy= %3d %3d rc= %2d", x, y, rc);)
- if (rc<0) { free_box(box3); continue; }
- if (box3->num_frames && !box3->num_frame_vectors[0])
- fprintf(stderr,"\nERROR scan_boxes: no vector in frame (%d,%d)",x,y);
-
- JOB->res.numC++;
- JOB->res.sumX += box3->x1 - box3->x0 + 1;
- JOB->res.sumY += box3->y1 - box3->y0 + 1;
-
- box3->c=(((box3->y1-box3->y0+1)
- *(box3->x1-box3->x0+1)>=MaxBox)? PICTURE : UNKNOWN);
- list_app(&(JOB->res.boxlist), box3); // append to list
- // ToDo: debug
- // if (JOB->cfg.verbose && box3->y0==29) out_x(box3);
- }
- if(JOB->res.numC){
- if (JOB->cfg.verbose)
- fprintf(stderr," nC= %3d avD= %2d %2d\n",JOB->res.numC,
- (JOB->res.sumX+JOB->res.numC/2)/JOB->res.numC,
- (JOB->res.sumY+JOB->res.numC/2)/JOB->res.numC);
- }
- return JOB->res.numC;
-}
-
-/* compare ints for sorting. Return -1, 0, or 1 according to
- whether *vr < *vs, vr == *vs, or *vr > *vs */
-int
-intcompare (const void *vr, const void *vs)
-{
- int *r=(int *)vr;
- int *s=(int *)vs;
-
- if (*r < *s) return -1;
- if (*r > *s) return 1;
- return 0;
-}
-
-/*
- * measure_pitch - detect monospaced font and measure the pitch
- * measure overall pitch for difficult lines,
- * after that measure pitch per line
- * dists arrays are limited to 1024 elements to reduce
- * cpu usage for qsort on images with extreme high number of objects
- * insert space if dist>=pitch in list_insert_spaces()
- * ToDo: ???
- * - min/max distance-matrix a-a,a-b,a-c,a-d ... etc; td,rd > ie,el,es
- * - OR measuring distance as min. pixel distance instead of box distance
- * especially useful for italic font!
- */
-void measure_pitch( job_t *job ){
- int numdists=0, spc=0, /* number of stored distances */
- pitch_p=2, pdist, pdists[1024], /* proportional distances */
- pitch_m=6, mdist, mdists[1024], /* monospaced distances */
- monospaced=0, l1;
- struct box *box2, *prev=NULL;
-
- if(job->cfg.verbose){ fprintf(stderr,"# check for word pitch"); }
- for (l1=0; l1<job->res.lines.num; l1++)
- { /* 0 means all lines */
- if(job->cfg.verbose){ fprintf(stderr,"\n# line %2d",l1); }
- numdists = 0; /* clear distance lists */
- for_each_data(&(job->res.boxlist)) {
- box2 = (struct box *)list_get_current(&(job->res.boxlist));
- if (l1>0 && box2->line!=l1) continue; /* ignore other lines */
- /* ignore dots and pictures (min. font is 4x6) */
- if (box2->y1 - box2->y0 + 1 < 4 || box2->c==PICTURE) { prev=NULL; }
- if (!prev) { prev=box2; continue; } /* we need a predecessor */
- /* use center distance for monospaced fonts */
- mdist = ((box2->x0 + box2->x1) - (prev->x0 + prev->x1) + 1)/2;
- /* use gap for proportional fonts */
- pdist = box2->x0 - prev->x1 + 1;
- /* ToDo: better take 3 instead of 2 neighbours?, smallest font 4x6 */
- /* fonts are expected to be 6 to 60 pixels high, which is about
- 4 to 50 pixels wide. We allow some extra margin. */
- if (3 < mdist && mdist < 150) { /* better mdist < 3*Xaverage ? */
- /* two options for overflow: 1) ignore, 2) store randomly */
- if (numdists<1024) { /* we do ignore here */
- mdists[numdists] = mdist;
- pdists[numdists] = pdist;
- numdists++;
- }
- }
- prev = box2;
- } end_for_each(&(job->res.boxlist));
-
- if(job->cfg.verbose){ fprintf(stderr," num_gaps= %2d",numdists); }
- if( numdists<8 ){
- if (job->cfg.verbose && l1==0) /* only for all lines */
- fprintf(stderr," (WARNING num_gaps<8)");
- }
- if (numdists>0) {
- int i,diff,ni_min,max,best_m,best_p,ni; double v;
- /* aware: takes long time for big data sets */
- /* dilute? (german: ausduennen?) */
- qsort (mdists, numdists, sizeof (int), intcompare);
- qsort (pdists, numdists, sizeof (int), intcompare);
- /* the new method, div0? */
- v = (mdists[numdists*7/10]-mdists[numdists/5])
- /(double)mdists[numdists/5];
- /* measurements showed v=.09 for Courier and .44 for Times-Roman */
- if (l1==0) monospaced = (v < .22);
- best_m= numdists/5;
- best_p=4*numdists/5;
- /* try to find better pitch for monospaced font (ok for prop) */
- for (i=numdists/5+1;i<numdists;i++) {
- if (2*mdists[i]>=3*mdists[best_m]) { best_m=i-1; break; }
- }
- /* try to find better pitch for proportional font */
- // the largest diff could be the best, if diff is always 1,
- // take the diff with the lowest weight
- for (ni=ni_min=1024,max=0,i=numdists/2+1;i<numdists-numdists/16;i++) {
- diff=pdists[i]-pdists[i-1];
- if (diff>max) {
- max=diff; best_p=i-1;
- if ((job->cfg.verbose&(32+16))==48)
- fprintf(stderr," best_p=%d maxdiff=%d\n# ...", pdists[best_p], max);
- if (max>3 && 3*pdists[i]>=4*pdists[i-1]) { break; }
- }
- if (diff) {
- if (ni<ni_min) {
- // do not try to divide one word per line
- ni_min=ni; if (max<=1 && numdists>16) best_p=i-1;
- if ((job->cfg.verbose&(32+16))==48)
- fprintf(stderr," best_p=%d ni_min=%d\n# ...", pdists[best_p], ni_min);
- }
- ni=1;
- } else ni++;
- }
- if (numdists<16 && max<=1 && ni_min>1) best_p=numdists-1; // one word
-#if 1 /* debugging */
- if ((job->cfg.verbose&(32+16))==48) {
- fprintf(stderr,"\n# ...");
- for (i=0;i<numdists;i++) fprintf(stderr," %2d",mdists[i]);
- fprintf(stderr," <- mdist[%d]\n# ...",l1);
- for (i=0;i<numdists;i++) fprintf(stderr," %2d",pdists[i]);
- fprintf(stderr," <- pdist[%d]\n# ...",l1);
- fprintf(stderr," maxdiff=%d min_samediffs=%d\n# ...",max,ni_min);
- }
-#endif
- /* we measure spaces in two different ways (mono, prop) */
- /* prop: gap between boxes, mono: distance of middle */
- if (best_p<numdists-1) pitch_p = ((pdists[best_p]+pdists[best_p+1])/2+1);
- else pitch_p = (pdists[best_p]+1 );
- pitch_m = (mdists[best_m]*4/3);
- if (numdists)
- if ( pdists[numdists-1]*2 <= pdists[0]*3
- || pdists[numdists-1] <= pdists[0]+3) {
- /* line is just a single word */
- pitch_p = pdists[numdists-1]+10;
- }
- if (l1>0 && job->cfg.spc==0) {
- job->res.lines.pitch[l1]=(monospaced?pitch_m:pitch_p);
- job->res.lines.mono[l1]=monospaced;
- }
- if (job->cfg.verbose) {
- fprintf(stderr,"\n# ..."
- " mono: v=%f (v<0.22) line=%d numdists=%d\n# ...",
- v, l1, numdists);
- fprintf(stderr," mono: min=%3d max=%3d pitch=%3d @ %2d%%\n# ...",
- mdists[0],mdists[numdists-1],pitch_m,best_m*100/numdists);
- fprintf(stderr," prop: min=%3d max=%3d pitch=%3d @ %2d%%\n# ...",
- pdists[0],pdists[numdists-1],pitch_p,best_p*100/numdists);
- fprintf(stderr," result: distance >= %d considered space\n# ...",
- job->res.lines.pitch[l1]);
- }
- } /* if (not) enough spaces */
- if (l1==0) { /* set default spaces to each line */
- int l2;
- spc = job->cfg.spc;
- if (spc==0) /* set only if not set by option */
- spc = ((monospaced)?pitch_m:pitch_p);
- for (l2=0; l2<job->res.lines.num; l2++ )
- job->res.lines.pitch[l2]=spc;
- }
- } /* each line */
- if (job->cfg.spc==0)
- job->cfg.spc = spc;
- if (job->cfg.verbose)
- fprintf(stderr," overall space width is %d %s\n",
- spc, ((monospaced)?"monospaced":"proportional"));
-
-
-}
-
-/* ---- count subboxes (white holes within black area) --------
- * new: count boxes lying inside another box (usually holes, ex: "aeobdg")
- * needed for glue_boxes, dont glue textboxes, tables and other complex
- * objects
- * ToDo: count only frames of invers spin? do we need sorted list here? -> no
- */
-int count_subboxes( pix *pp ){
- int ii=0, num_mini=0, num_same=0, cnt=0;
- struct box *box2,*box4;
- progress_counter_t *pc = NULL;
- if (JOB->cfg.verbose) { fprintf(stderr,"# count subboxes\n# ..."); }
-
- pc = open_progress(JOB->res.boxlist.n,"count_subboxes");
- for_each_data(&(JOB->res.boxlist)) {
- box2 = (struct box *)list_get_current(&(JOB->res.boxlist));
- box2->num_subboxes=0;
- progress(cnt++,pc);
- if ( (box2->x1 - box2->x0)<2
- || (box2->y1 - box2->y0)<2) continue; /* speedup for dotted bg */
- // holes inside box2 char, aoebdqg, 0.41
- for_each_data(&(JOB->res.boxlist)) {
- box4=(struct box *)list_get_current(&(JOB->res.boxlist));
- if (box4->y0 > box2->y1) break; // faster, but boxes need to be sorted
- // ToDo: better use binary tree (above/below x) to find near boxes?
- if (box4==box2) continue;
- if( box4->x0==box2->x0 && box4->x1==box2->x1
- && box4->y0==box2->y0 && box4->y1==box2->y1)
- num_same++; /* erroneous!? */
- if ( box4->x0 >= box2->x0 && box4->x1 <= box2->x1
- && box4->y0 >= box2->y0 && box4->y1 <= box2->y1
- && box4->num_subboxes==0 ) /* box4 inside box2? */
- {
- box2->num_subboxes++; ii++;
- if ((box4->x1 - box4->x0 + 1)
- *(box4->y1 - box4->y0 + 1)<17) num_mini++;
- }
- } end_for_each(&(JOB->res.boxlist));
-#if 0
- if (cnt < 1000 && JOB->cfg.verbose)
- fprintf(stderr," %4d box %4d %4d %+3d %+3d subboxes %4d\n# ...",
- cnt, box2->x0, box2->y0, box2->x1-box2->x0,
- box2->y1-box2->y0, box2->num_subboxes);
-#endif
- } end_for_each(&(JOB->res.boxlist));
- close_progress(pc);
- if (JOB->cfg.verbose)
- fprintf(stderr," %3d subboxes counted (mini=%d, same=%d) nC= %d\n",
- ii, num_mini, num_same/2 /* counted twice */, cnt);
- return 0;
-}
-
-/* ---- glue holes tochars( before step1 ) v0.42 -----------------------
- glue boxes lying inside another box (usually holes, ex: "aeobdg46890")
- Dont add dust to a char!
- lines are not detected yet
-*/
-int glue_holes_inside_chars( pix *pp ){
- int ii, cs, x0, y0, x1, y1, cnt=0,
- glued_same=0, glued_holes=0;
- struct box *box2, *box4;
- progress_counter_t *pc = NULL;
- cs=JOB->cfg.cs;
- {
- count_subboxes( pp ); /* move to pgm2asc() later */
-
- pc = open_progress(JOB->res.boxlist.n,"glue_holes_inside_chars");
- if (JOB->cfg.verbose)
- fprintf(stderr,"# glue holes to chars nC= %d\n# ...",JOB->res.numC);
- ii=0;
- for_each_data(&(JOB->res.boxlist)) {
- // get the smaller box which may be extended by bigger boxes around it
- box2 = (struct box *)list_get_current(&(JOB->res.boxlist));
- x0 = box2->x0; x1 = box2->x1;
- y0 = box2->y0; y1 = box2->y1;
-
- progress(cnt++,pc);
-
- // would it better than moving vectors to build a sub-box-tree?
-
- // do not remove chars inside pictures (car plates on photos)
- if( box2->c == PICTURE || box2->num_subboxes > 7) continue;
-
- // holes inside char, aoebdqg, 0.41
- // dont merge boxes which have subboxes by itself!
- // search boxes inside box2
- // if (x1-x0+1>2 || y1-y0+1>2) /* skip tiny boxes, bad for 4x6 */
- for_each_data(&(JOB->res.boxlist)) {
- box4=(struct box *)list_get_current(&(JOB->res.boxlist));
- if(box4!=box2 && box4->c != PICTURE )
- {
- // ToDo: dont glue, if size differs by big factors (>16?)
- if ( ( box4->x0==x0 && box4->x1==x1
- && box4->y0==y0 && box4->y1==y1 ) /* do not happen !? */
- || ( box4->x0>=x0 && box4->x1<=x1
- && box4->y0>=y0 && box4->y1<=y1
- && box4->num_subboxes==0 ) ) /* no or very small subboxes? */
- { // fkt melt(box2,box4)
- // same box, if very small but hollow char (4x5 o)
- if( box4->x0==x0 && box4->x1==x1
- && box4->y0==y0 && box4->y1==y1) glued_same++; else glued_holes++;
- // fprintf(stderr,"\n# DEBUG merge:");
- // out_x(box2); // small
- // out_x(box4); // big
- if ((JOB->cfg.verbose & 7)==7) // LEV3
- fprintf(stderr," glue hole (%4d %4d %+3d %+3d %+4d)"
- " (%4d %4d %+3d %+3d %+4d) %d\n# ...",
- x0, y0, x1-x0+1, y1-y0+1, box2->frame_vol[0],
- box4->x0, box4->y0,
- box4->x1-box4->x0+1, box4->y1-box4->y0+1,
- box4->frame_vol[0], glued_same);
- if ((box4->x1-box4->x0+1)< 8*(x1-x0+1)
- || (box4->y1-box4->y0+1)<12*(y1-y0+1)) // skip dust
- merge_boxes( box2, box4 ); // add box4 to box2
- // out_x(box2);
- x0 = box2->x0; x1 = box2->x1;
- y0 = box2->y0; y1 = box2->y1;
- JOB->res.numC--; // dont count fragments as chars
- ii++; // count removed
- list_del(&(JOB->res.boxlist), box4); // remove box4
- free_box(box4);
- // now search another hole inside box2
- }
- }
- } end_for_each(&(JOB->res.boxlist));
-
- } end_for_each(&(JOB->res.boxlist));
-
- if (JOB->cfg.verbose)
- fprintf(stderr," glued: %3d holes, %3d same, nC= %d\n",
- glued_holes, glued_same, JOB->res.numC);
- close_progress(pc);
- }
- return 0;
-}
-
-
-/* ---- glue broken chars ( before step1 ??? ) -----------------------
- use this carefully, do not destroy previous detection ~fi, broken K=k' g
- glue if boxes are near or diagonally connected
- other strategy: mark boxes for deleting and delete in extra loop at end
- faster: check only next two following boxes because list is sorted!
- ToDo: store m4 of upper line to m4_of_prev_line, and check that "-points are below
- done: glue boxes lying inside another box (usually holes, ex: "aeobdg")
- Dont add dust to a char!
- lines should be detected already (Test it for m1-m4 unknown)
- ToDo: divide in glue_idots, glue_thin_chars etc. and optimize it
-*/
-int glue_broken_chars( pix *pp ){
- int ii, y, cs, x0, y0, x1, y1, cnt=0,
- num_frags=0, glued_frags=0, glued_hor=0;
- struct box *box2, *box4;
- progress_counter_t *pc = NULL;
- cs=JOB->cfg.cs;
- {
- count_subboxes( pp ); /* move to pgm2asc() later */
-
- pc = open_progress(JOB->res.boxlist.n,"glue_broken_chars");
- if (JOB->cfg.verbose)
- fprintf(stderr,"# glue broken chars nC= %d\n# ...",JOB->res.numC);
- ii=0;
- for_each_data(&(JOB->res.boxlist)) {
- // get the box which may be extended by boxes around it
- box2 = (struct box *)list_get_current(&(JOB->res.boxlist));
- x0 = box2->x0; x1 = box2->x1;
- y0 = box2->y0; y1 = box2->y1;
-
- progress(cnt++,pc);
-
- // vertical broken (g965T umlauts etc.)
- // not: f,
-
- // would it better than moving vectors to build a sub-box-tree?
-
- // do not remove chars inside pictures (car plates on photos)
- if( box2->c == PICTURE || box2->num_subboxes > 7) continue;
-
- /* continue loop if box is below or above line */
- if( box2->m4>0 && y0>box2->m4 ) continue; /* dust outside ? */
- if( box2->m1>0 && y0<box2->m1-(box2->m3-box2->m2) ) continue;
- /* ToDo:
- * - check that y0 is greater as m3 of the char/line above
- */
-
- // check small boxes (box2) whether they belong
- // to near same size or bigger boxes (box4)
- if( 2*(y1-y0) < box2->m4 - box2->m1 // care for dots etc.
- && ( 2*y1<=(box2->m3+box2->m2) // upper fragments
- || 2*y0>=(box2->m3+box2->m2)) ) { // lower fragments
- struct box *box5=NULL, *box6=NULL; // nearest and next nearest box
- box4=NULL;
- num_frags++; /* count for debugging */
- // get the [2nd] next x-nearest box in the same line
- for_each_data(&(JOB->res.boxlist)) {
- box4=(struct box *)list_get_current(&(JOB->res.boxlist));
- if (box4 == box2 || box4->c == PICTURE) continue;
- /* 0.42 speed up for backround pixel pattern, box4 to small */
- if ( box4->x1 - box4->x0 + 1 < x1-x0+1
- && box4->y1 - box4->y0 + 1 < y1-y0+1 ) continue;
- // have in mind that line number may be wrong for dust
- if (box4->line>=0 && box2->line>=0 && box4->line==box2->line)
- {
- if (!box5) box5=box4;
- if ( abs(box4->x0 + box4->x1 - 2*box2->x0)
- <abs(box5->x0 + box5->x1 - 2*box2->x0))
- { box6=box5; box5=box4; }
- }
- } end_for_each(&(JOB->res.boxlist));
- box4=box5; // next nearest box within the same line
- if (box4) {
-#if 0 /* set this to 1 for debugging of melting bugs */
- if (JOB->cfg.verbose & 7) {
- fprintf(stderr,"\n# next two boxes are candidates for melting ");
- out_x(box2);
- out_x(box4); }
-#endif
- if( /* umlaut "a "o "u, ij; box2 is the small dot, box4 the body */
- ( y1 <= box2->m2
- && box4->y1 >= box2->m2 // dont melt dots together
- && 2* y1 < box4->y1 + box4->y0 // box2 above box4
- && box4->x1+JOB->res.avX/2>=x0
- && box4->x0-JOB->res.avX/2<=x1
- && (y1 < box4->y0 || x0 < box4->x1) // dont melt "d'"
- && 3* ( y1 - box4->y0)
- <= 2* (box4->y1 - box4->y0) // too far away? dust!
- && 8* ( x1 - x0 + 1)
- >= (box4->x1 - box4->x0 + 1) // dot must have minimum size
- && 10* ( y1 - y0 + 1)
- >= (box4->y1 - box4->y0 + 1) // dot must have minimum size
- ) || ( 0 && /* broken T */
- 3*(box2->x1 - box2->x0) > 2*JOB->res.avX
- && 4*box4->x0>3*box2->x0+box2->x1
- && 4*box4->x1<box2->x0+3*box2->x1
- )
- || /* !?; box2 is the dot, box4 the body */
- ( 2*box4->x1>=x0+x1 /* test if box4 is around box2 */
- && 2*box4->x0<=2*x1 /* +x0+1 Jan00 */
- && ( x1-x0 <= box4->x1-box4->x0+2 )
- && 2*y0>=box2->m2+box2->m3
- && 4*y1>=box2->m2+3*box2->m3
- && 4*(y1-y0)<box2->m4-box2->m1
- && (8*box4->y1 < box4->m2+7*box4->m3
- || box4->m4-box4->m1<16) /* Jan00 */
- )
- || /* =;: box2 is the upper box, box4 the lower box */
- ( 2*box4->x1>=x0+x1 /* test if box4 is around box2 */
- && 2*box4->x0<=2*x1 /* +x0+1 */
- && ( x1-x0 <= box4->x1-box4->x0+4 )
- && ( 4*x0 <= 3*box4->x1+box4->x0 )
- && (( box2->m2 && box4->m2
- && y1< box2->m3
- && 2*box4->y1 > box4->m3+box4->m2 // can be bigger than m3
- && 4*box4->y0 >= 3*box4->m2+box4->m3
- && 2*box2->y0 < box2->m3+box2->m2
- )
- || ( (!box2->m2) || (!box4->m2) )
- )
- )
- )
- { // fkt melt(box2,box4)
- if (JOB->cfg.verbose & 7)
- fprintf(stderr," glue objects (%3d %3d %+3d %+3d)"
- " (%3d %3d %+3d %+3d)\n# ...",
- x0, y0, x1-x0+1, y1-y0+1, box4->x0, box4->y0,
- box4->x1-box4->x0+1, box4->y1-box4->y0+1);
- // fprintf(stderr,"\n# DEBUG merge:"); // d=7x34 @ (109,51) ???
- // out_x(box2);
- // out_x(box4);
- merge_boxes( box2, box4 ); // add box4 to box2
- x0 = box2->x0; x1 = box2->x1;
- y0 = box2->y0; y1 = box2->y1;
- // if (JOB->cfg.verbose & 4) out_x(box2);
- // JOB->res.numC--; // dont count fragments as chars
- ii++; glued_frags++; // remove
- // output_list(JOB);
- list_del(&(JOB->res.boxlist), box4); /* ret&1: error-message ??? */
- // output_list(JOB);
- free_box(box4);
- }
- }
- }
-// continue;
-
- // horizontally broken w' K'
- if( 2*y1 < (box2->m3+box2->m2) )
- if( 2*(y1-y0) < (box2->m3+box2->m2) ) // fragment
- for_each_data(&(JOB->res.boxlist)) {
- box4=(struct box *)list_get_current(&(JOB->res.boxlist));
- if(box4!=box2 && box4->c != PICTURE )
- {
- if( box4->line>=0 && box4->line==box2->line
- && box4->x1>=x0-1 && box4->x1<x0 // do not glue 6-
- && box4->x0+3*box4->x1<4*x0)
- if( get_bw(x0 ,x0 ,y1,y1 ,pp,cs,1) == 1)
- if( get_bw(x0-2,x0-1,y1,y1+2,pp,cs,1) == 1)
- { // fkt melt(box2,box4)
- put(pp,x0,y1+1,~(128+64),0);
- merge_boxes( box2, box4 );
- x0 = box2->x0; x1 = box2->x1;
- y0 = box2->y0; y1 = box2->y1;
- JOB->res.numC--; ii++; // remove
- glued_hor++;
- list_del(&(JOB->res.boxlist), box4);
- free_box(box4);
- }
- }
- } end_for_each(&(JOB->res.boxlist));
-
- // horizontally broken n h (h=l_) v0.2.5 Jun00
- if( abs(box2->m2-y0)<=(y1-y0)/8 )
- if( abs(box2->m3-y1)<=(y1-y0)/8 )
- if( num_cross(x0, x1,(y0+ y1)/2,(y0+ y1)/2,pp,cs) == 1)
- if( num_cross(x0, x1,(y0+3*y1)/4,(y0+3*y1)/4,pp,cs) == 1)
- if( get_bw((3*x0+x1)/4,(3*x0+x1)/4,(3*y0+y1)/4,y1,pp,cs,1) == 0)
- if( get_bw(x0,(3*x0+x1)/4,(3*y0+y1)/4,(y0+3*y1)/4,pp,cs,1) == 0)
- if( get_bw(x0, x0, y0,(3*y0+y1)/4,pp,cs,1) == 1)
- for_each_data(&(JOB->res.boxlist)) {
- box4=(struct box *)list_get_current(&(JOB->res.boxlist));
- if(box4!=box2 && box4->c != PICTURE )
- {
- if( box4->line>=0 && box4->line==box2->line
- && box4->x1>x0-3 && box4->x1-2<x0
- && abs(box4->y1-box2->m3)<2)
- { // fkt melt(box2,box4)
- y=loop(pp,x0,y0,y1-y0,cs,0,DO);if(2*y>y1-y0) continue;
- put(pp,x0-1,y0+y ,~(128+64),0);
- put(pp,x0-1,y0+y+1,~(128+64),0);
- merge_boxes( box2, box4 ); // add box4 to box2
- x0 = box2->x0; x1 = box2->x1;
- y0 = box2->y0; y1 = box2->y1;
- JOB->res.numC--; ii++; // remove
- glued_hor++;
- list_del(&(JOB->res.boxlist), box4);
- free_box(box4);
- }
- }
- } end_for_each(&(JOB->res.boxlist));
- } end_for_each(&(JOB->res.boxlist));
- if (JOB->cfg.verbose)
- fprintf(stderr," glued: %3d fragments (found %3d), %3d rest, nC= %d\n",
- glued_frags, num_frags, glued_hor, JOB->res.numC);
- close_progress(pc);
- }
- return 0;
-}
-
-/*
-** this is a simple way to improve results on noisy images:
-** - find similar chars (build cluster of same chars)
-** - analyze clusters (could be used for generating unknown font-base)
-** - the quality of the result depends mainly on the distance function
-*/
- // ---- analyse boxes, compare chars, compress picture ------------
- // ToDo: - error-correction only on large chars!
-int find_same_chars( pix *pp){
- int i,k,d,cs,dist,n1,dx; struct box *box2,*box3,*box4,*box5;
- pix p=(*pp);
- cs=JOB->cfg.cs;
- {
- if(JOB->cfg.verbose)fprintf(stderr,"# packing");
- i = list_total(&(JOB->res.boxlist));
- for_each_data(&(JOB->res.boxlist)) {
- box4 = box2 = (struct box *)list_get_current(&(JOB->res.boxlist));
- dist=1000; // 100% maximum
- dx = box2->x1 - box2->x0 + 1;
-
- if(JOB->cfg.verbose)fprintf(stderr,"\r# packing %5d",i);
- if( dx>3 )
- for(box3=(struct box *)list_next(&(JOB->res.boxlist),box2);box3;
- box3=(struct box *)list_next(&(JOB->res.boxlist),box3)) {
- if(box2->num!=box3->num){
- int d=distance(&p,box2,&p,box3,cs);
- if ( d<dist ) { dist=d; box4=box3; } // best fit
- if ( d<5 ){ // good limit = 5% ???
- i--;n1=box3->num; // set all num==box2.num to box2.num
- for_each_data(&(JOB->res.boxlist)) {
- box5=(struct box *)(struct box *)list_get_current(&(JOB->res.boxlist));
- if(box5!=box2)
- if( box5->num==n1 ) box5->num=box2->num;
- } end_for_each(&(JOB->res.boxlist));
- // out_x2(box2,box5);
- // fprintf(stderr," dist=%d\n",d);
- }
- }
- }
- // nearest dist to box2 has box4
- // out_b2(box2,box4);
- // fprintf(stderr," dist=%d\n",dist);
- } end_for_each(&(JOB->res.boxlist));
- k=0;
- if(JOB->cfg.verbose)fprintf(stderr," %d different chars",i);
- for_each_data(&(JOB->res.boxlist)) {
- struct box *box3,*box4;
- int j,dist;
- box2=(struct box *)list_get_current(&(JOB->res.boxlist));
- for(box3=(struct box *)list_get_header(&(JOB->res.boxlist));
- box3!=box2 && box3!=NULL;
- box3=(struct box *)list_next(&(JOB->res.boxlist), box3))
- if(box3->num==box2->num)break;
- if(box3!=box2 && box3!=NULL)continue;
- i++;
- // count number of same chars
- dist=0;box4=box2;
-
- for(box3=box2,j=0;box3;
- box3=(struct box *)list_next(&(JOB->res.boxlist), box3)) {
- if(box3->num==box2->num){
- j++;
- d=distance(&p,box2,&p,box3,cs);
- if ( d>dist ) { dist=d; box4=box3; } // worst fit
- }
- }
- if(JOB->cfg.verbose&8){
- fprintf(stderr," no %d char %4d %5d times maxdist=%d\n",i,box2->num,j,dist);
- }
- // calculate mean-char (error-correction)
- // ToDo: calculate maxdist in group
- k+=j;
- // if(j>1)
- // out_b(box1,NULL,0,0,0,0,cs);
- if(JOB->cfg.verbose&8)
- fprintf(stderr," no %d char %4d %5d times sum=%d\n",i,box2->num,j,k);
- } end_for_each(&(JOB->res.boxlist));
- if(JOB->cfg.verbose)fprintf(stderr," ok\n");
- }
- return 0;
-}
-
-/*
-** call the first engine for all boxes and set box->c=result;
-**
-*/
-int char_recognition( pix *pp, int mo){
- int i,ii,ni,cs,x0,y0,x1,y1;
- struct box *box2;
- progress_counter_t *pc;
- wchar_t cc;
- cs=JOB->cfg.cs;
- // ---- analyse boxes, find chars ---------------------------------
- if (JOB->cfg.verbose)
- fprintf(stderr,"# char recognition");
- i=ii=ni=0;
- for_each_data(&(JOB->res.boxlist)) { /* count boxes */
- box2 = (struct box *)list_get_current(&(JOB->res.boxlist));
- /* wew: isn't this just JOB->res.numC? */
- /* js: The program is very complex. I am not sure anymore
- wether numC is the number of boxes or the number of valid
- characters.
- Because its not time consuming I count the boxes here. */
- if (box2->c==UNKNOWN) i++;
- if (box2->c==PICTURE) ii++;
- ni++;
- } end_for_each(&(JOB->res.boxlist));
- if(JOB->cfg.verbose)
- fprintf(stderr," unknown= %d picts= %d boxes= %d\n# ",i,ii,ni);
- if (!ni) return 0;
- i=ii=0;
- pc = open_progress(ni,"char_recognition");
- for_each_data(&(JOB->res.boxlist)) {
- box2 = (struct box *)list_get_current(&(JOB->res.boxlist));
- x0=box2->x0;x1=box2->x1;
- y0=box2->y0;y1=box2->y1; // box
- cc=box2->c;
- if (cc==PICTURE) continue;
-
- if ((mo&256)==0) { /* this case should be default (main engine) */
- if(cc==UNKNOWN || box2->num_ac==0 || box2->wac[0]<JOB->cfg.certainty)
- cc=whatletter(box2,cs ,0);
- }
-
- if(mo&2)
- if(cc==UNKNOWN || box2->num_ac==0 || box2->wac[0]<JOB->cfg.certainty)
- cc=ocr_db(box2);
-
-
- // box2->c=cc; bad idea (May03 removed)
- // set(box2,cc,95); ToDo: is that better?
-
- if(cc==UNKNOWN)
- i++;
- ii++;
-
- if(JOB->cfg.verbose&8) {
- fprintf(stderr,"\n# code= %04lx %c",(long)cc,(char)((cc<255)?cc:'_'));
- //out_b(box2,pp,x0,y0,x1-x0+1,y1-y0+1,cs);
- }
- progress(ii,pc); /* ii = 0..ni */
-
- } end_for_each(&(JOB->res.boxlist));
- close_progress(pc);
- if(JOB->cfg.verbose)fprintf(stderr," %d of %d chars unidentified\n",i,ii);
- return 0;
-}
-
-
-/*
-** compare unknown with known chars,
-** very similar to the find_similar_char_function but here only to
-** improve the result
-*/
-int compare_unknown_with_known_chars(pix * pp, int mo) {
- int i, cs = JOB->cfg.cs, dist, d, ad, wac, ni, ii;
- struct box *box2, *box3, *box4;
- progress_counter_t *pc=NULL;
- wchar_t bc;
- i = ii = 0; // ---- -------------------------------
- if (JOB->cfg.verbose)
- fprintf(stderr, "# try to compare unknown with known chars !(mode&8)");
- if (!(mo & 8))
- {
- ii=ni=0;
- for_each_data(&(JOB->res.boxlist)) { ni++; } end_for_each(&(JOB->res.boxlist));
- pc = open_progress(ni,"compare_chars");
- for_each_data(&(JOB->res.boxlist)) {
- box2 = (struct box *)list_get_current(&(JOB->res.boxlist)); ii++;
- if (box2->c == UNKNOWN || (box2->num_ac>0 && box2->wac[0]<97))
- if (box2->y1 - box2->y0 > 4 && box2->x1 - box2->x0 > 1) { // no dots!
- box4 = (struct box *)list_get_header(&(JOB->res.boxlist));;
- dist = 1000; /* 100% maximum */
- bc = UNKNOWN; /* best fit char */
- for_each_data(&(JOB->res.boxlist)) {
- box3 = (struct box *)list_get_current(&(JOB->res.boxlist));
- wac=((box3->num_ac>0)?box3->wac[0]:100);
- if (box3 == box2 || box3->c == UNKNOWN
- || wac<JOB->cfg.certainty) continue;
- if (box2->y1 - box2->y0 < 5 || box2->x1 - box2->x0 < 3) continue;
- d = distance(pp, box2, pp, box3, cs);
- if (d < dist) {
- dist = d; bc = box3->c; box4 = box3;
- }
- } end_for_each(&(JOB->res.boxlist));
- if (dist < 10) {
- /* sureness can be maximal of box3 */
- if (box4->num_ac>0) ad = box4->wac[0];
- else ad = 97;
- ad-=dist; if(ad<1) ad=1;
- /* ToDo: ad should depend on ad of bestfit */
- setac(box2,(wchar_t)bc,ad);
- i++;
- } // limit as option???
- // => better max distance('e','e') ???
- if (dist < 50 && (JOB->cfg.verbose & 7)) { // only for debugging
- fprintf(stderr,"\n# L%02d best fit was %04x=%c dist=%3d%% i=%d",
- box2->line, (int)bc, (char)((bc<128)?bc:'_'), dist, i);
- if(box4->num_ac>0)fprintf(stderr," w= %3d%%",box4->wac[0]);
- }
- progress(ii,pc);
- }
- } end_for_each(&(JOB->res.boxlist));
- close_progress(pc);
- }
- if (JOB->cfg.verbose)
- fprintf(stderr, " - found %d (nC=%d)\n", i, ii);
- return 0;
-}
-
-/*
-// ---- divide overlapping chars which !strchr("_,.:;",c);
-// block-splitting (two ore three glued chars)
-// division if dots>0 does not work properly! ???
-//
-// what about glued "be"?
-// what about recursive division?
-// ToDo: mark divided boxes to give the engine a chance to
-// handle wrong divisions
-*/
-int try_to_divide_boxes( pix *pp, int mo){
- struct box *box2, boxa, boxb;
- int cs=JOB->cfg.cs, ad=100,
- a2[8], ar, // certainty of each part, ar = product of all certainties
- cbest; // best certainty, skip search of certainty<cbest-1 for speed
- wchar_t ci[8], // split max. 8 chars
- s1[]={ UNKNOWN, '_', '.', ',', '\'', '!', ';', '?', ':', '-',
- '=', '(', ')', '/', '\\', '\0' }; // not accepted chars, \0-terminated!
- int x0, x1, y0, y1,
- xi[8+1]; // cutting positions
- int i, ii, n1, dy, dx;
- // pix p=(*pp); // remove!
- if (JOB->cfg.verbose)
- fprintf(stderr,"# try to divide unknown chars !(mode&16)");
- if(!(mo&16)) // put this to the caller
- for_each_data(&(JOB->res.boxlist)) {
- box2 = (struct box *)list_get_current(&(JOB->res.boxlist));
- // don't try to split simple structures (ex: 400x30 square)
- if ((!box2->num_frames)
- || box2->num_frame_vectors[ box2->num_frames-1 ]<9) continue;
- if((box2->c==UNKNOWN || (box2->num_ac && box2->wac[0]<JOB->cfg.certainty))
- && box2->x1-box2->x0>5 && box2->y1-box2->y0>4){
- x0=box2->x0; x1=box2->x1;
- y0=box2->y0; y1=box2->y1;
- ad=100;
- cbest=0;
-
- /* get minimum vertical lines */
- n1 = num_cross(x0,x1,( y1+y0)/2,( y1+y0)/2,pp,cs);
- ii = num_cross(x0,x1,(3*y1+y0)/4,(3*y1+y0)/4,pp,cs); if (ii<n1) n1=ii;
- if (box2->m2 && box2->m3 > box2->m2+2)
- for (i=box2->m2+1;i<=box2->m3-1;i++) {
- if (loop(pp,x0+1,i,x1-x0,cs,1,RI) > (x1-x0-2)) continue; // ll
- ii = num_cross(x0,x1,i,i,pp,cs); if (ii<n1) n1=ii;
- } if (n1<2) continue; // seems to make no sense to divide
- if (n1<4) ad=99*ad/100; // not to strong because m2+m3 could be wrong
- if (n1<3) ad=99*ad/100;
-
- if( 2*y1 < box2->m3+box2->m4 /* baseline char ? */
- && num_cross(x0,x1,y1-1,y1-1,pp,cs)==1 // -1 for slopes
- && num_cross((x0+2*x1)/3,(x0+3*x1)/4,y0,y1,pp,cs)<3 // not exclude tz
- && num_cross((3*x0+x1)/4,(2*x0+x1)/3,y0,y1,pp,cs)<3 // not exclude zl
- && loop(pp,x0,y1-(y1-y0)/32,x1-x0,cs,0,RI)
- +loop(pp,x1,y1-(y1-y0)/32,x1-x0,cs,0,LE) > (x1-x0+1)/2
- ) continue; /* do not try on bvdo"o etc. */
-
- // one vertical line can not be two glued chars, lc?
- if ( num_cross(x0,x1,(y1+y0)/2,(y1+y0)/2,pp,cs)<=1 ) continue;
- { // doublet = 2 letters
- // char buf[4]="\0\0\0"; // 4th byte is string end == \0
- // buf[0]=c1; // c1 is wchar_t! (0xbf00 to 0) failes
- // buf[1]=c2;
- char buf[64]=""; // end == \0
- if (JOB->cfg.verbose&2){
- fprintf(stderr, "\n#\n# divide box: %4d %4d %3d %3d\n",
- x0, y0, x1-x0+1, y1-y0+1);
- }
- // it would be better if testing is only if most right and left char
- // is has no horizontal gap (below m2) ex: be
- i=0; // num splittet chars
- xi[0]=x0; xi[1]=x0+3; xi[2]=x1;
- for ( ; ; xi[i+1]++) { // x[i] .. x[i+1], slower? but better v0.42
- /* break if x is to near to the right border */
- if (xi[i+1]>x1-3) { if (i==0) break; i--; xi[i+2]=x1; continue; }
- // ToDo: skip if not a local dy-min for speedup
- { int ymin=y1, ymax=y0, bow=0, // min max at cutting point
- max0=y0, max1=y0, // max y on left and right side
- min0=y1, min1=y1; // min y on left and right side
- for (dy=0,ii=0;ii<box2->num_frame_vectors[ 0 ];ii++) {
- int pre=ii-1, next=(ii+1)%box2->num_frame_vectors[ 0 ];
- if (pre<0) pre=box2->num_frame_vectors[ 0 ]-1;
- // check if vector is inside box to cut
- if ( box2->frame_vector[ii ][0]<=xi[i ]) continue;
- if ( box2->frame_vector[ii ][0]> xi[i+2]) continue;
- // 2nd derivation of y(x)
- if (abs(box2->frame_vector[ii ][0]-xi[i+1])<2) {
- dy= 2*box2->frame_vector[ii ][1]
- -box2->frame_vector[next][1]
- -box2->frame_vector[pre ][1];
- dx= box2->frame_vector[next][0]
- -box2->frame_vector[pre ][0];
- // rotate 180 degree if dx<0
- if (((dx>0)?dy:-dy)<-abs(dx)/2) { bow=1; }
- }
- // its not the best if we think on glued fi fo etc.
- if (( box2->frame_vector[pre ][0]<=xi[i+1]
- && box2->frame_vector[next][0]>=xi[i+1])
- || ( box2->frame_vector[pre ][0]>=xi[i+1]
- && box2->frame_vector[next][0]<=xi[i+1])) {
- if ( box2->frame_vector[ii ][1]>ymax)
- ymax= box2->frame_vector[ii ][1];
- if ( box2->frame_vector[ii ][1]<ymin)
- ymin= box2->frame_vector[ii ][1];
- }
- // min and max of left and right side
- if ( box2->frame_vector[ii ][1]>max0
- && box2->frame_vector[ii ][0]<=xi[i+1])
- max0=box2->frame_vector[ii ][1];
- if ( box2->frame_vector[ii ][1]>max1
- && box2->frame_vector[ii ][0]> xi[i+1])
- max1=box2->frame_vector[ii ][1];
- if ( box2->frame_vector[ii ][1]<min0
- && box2->frame_vector[ii ][0]<=xi[i+1])
- min0=box2->frame_vector[ii ][1];
- if ( box2->frame_vector[ii ][1]<min1
- && box2->frame_vector[ii ][0]> xi[i+1])
- min1=box2->frame_vector[ii ][1];
- }
- if(JOB->cfg.verbose&2)
- fprintf(stderr,"\n# test if to split at x%d= %2d %2d %2d"
- " bow,(max-min)[i,0,1] %d %3d %3d %3d"
- , i, xi[i]-x0, xi[i+1]-x0, xi[i+2]-x0, bow, ymax-ymin, max0-min0, max1-min1);
- /* skip if no local minimum at xi[i+1] or if its not thin enough */
- if (bow==0 || 4*(ymax-ymin)>2*(y1-y0)) continue;
- // cuttet parts should have about the same height (max-min)
- // we dont want to cut an 'n' in three parts!
- if (2*(max0-min0+1)<(y1-y0+1)) continue; // left height
- if (2*(max1-min1+1)<(y1-y0+1)) continue; // right height
- // ToDo: thickness on xi[i+1]?
- }
- // try to split successive right box if left box is recognised,
- // else shift the splitting point further to the right border
- // removing ->dots if dot only above one char !!! ??? not implemented
- if(JOB->cfg.verbose&2)
- fprintf(stderr,"\n# try to split, newbox[%d].x= %2d ... %2d "
- "dy= %d ", i, xi[i]-x0, xi[i+1]-x0, dy);
- boxa=*box2; // copy contents, ToDo: reset ac-list (in cut_box?)
- boxa.x=xi[i]; boxa.y=y0; // obsolete? mark pixel, overlap?
- boxa.x0=xi[i];boxa.x1=xi[i+1]; // new horizontal box range
- cut_box(&boxa); boxa.num_ac=0;
- // out_x(&boxa);
- // get wchar + certainty
- ci[i]=whatletter(&boxa,cs,0); a2[i]=testac(&boxa,ci[i]);
- if(JOB->cfg.verbose&2)
- fprintf(stderr,"\n# certainty %d limit= %d cbest= %d ",
- a2[i], JOB->cfg.certainty, cbest);
- if (a2[i]<JOB->cfg.certainty || a2[i]<cbest-1
- || wcschr(s1,ci[i]) ) { continue; } // dont split here
-
- for (ar=ad,ii=0;ii<=i;ii++) {
- ar=a2[ii]*ar/100; } // multiply all probabilities
- if (ar<98*JOB->cfg.certainty/100 || ar<cbest) {
- continue; } // dont go deeper, no longer string
-
- i++; if (i==8) break; // maximum splits
- if (i==4) break; // at the moment its to slow to go further
- if (i+1<8) xi[i+1]=x1; // right border of next box
- if (i+2<8) xi[i+2]=x1;
-
- if(JOB->cfg.verbose&2)
- fprintf(stderr,"\n try end split [%d]=%d [%d]=%d ",
- i, xi[i]-x0, i+1, xi[i+1]-x0);
- boxb=*box2; // try rest if it has to be split again
- boxb.x=xi[i]+1; boxb.y=y0;
- boxb.x0=xi[i]+1;boxb.x1=xi[i+1];
- cut_box(&boxb); boxb.num_ac=0;
- ci[i]=whatletter(&boxb,cs,0); a2[i]=testac(&boxb,ci[i]);
- if (a2[i]<JOB->cfg.certainty || a2[i]<cbest-1
- || wcschr(s1,ci[i]) ) { xi[i+1]=xi[i]+2; continue; } // split rest
- // now we have everything splittet
-
- if(JOB->cfg.verbose&2) {
- fprintf(stderr,"\n split at/to: ");
- for (ii=0;ii<=i;ii++)
- fprintf(stderr," %2d %s (%3d)", xi[ii+1]-x0,
- decode(ci[ii],ASCII), a2[ii]);
- fprintf(stderr,"\n");
- }
- // boxa..c changed!!! dots should be modified!!!
- // Question: cut it into boxes v0.40 or set a string v0.41?
- // new way of building a string v0.41 (can call setas multiple)
- // usefull if compare unknown with known strings (except barcode?)
- // ToDo: also create alternate variants? ex: I <-> l
- for (buf[0]=0,ar=ad,ii=0;ii<=i;ii++) {
- ar=a2[ii]*ar/100; // multiply all probabilities
- if (i>0 && ci[ii]=='n' && ci[ii-1]=='r') ar--; // m == rn
- strncat(buf,decode(ci[ii],JOB->cfg.out_format),20);
- }
-
- if (ar>cbest) cbest=ar; // best (highest) certainty found
- // reduce, but not if we cross certainty border
- if (99*ar/100 > JOB->cfg.certainty) ar=99*ar/100;
- if (JOB->cfg.verbose&2)
- fprintf(stderr,"\n split result= %s (%3d) ",buf, ar);
- setas(box2,buf,ar); // char *, does it disturb further splitting?
- buf[0]=0;
- i--; xi[i+2]=x1;
- }
- }
- }
- } end_for_each(&(JOB->res.boxlist));
- if(JOB->cfg.verbose)fprintf(stderr,", numC %d\n",JOB->res.numC);
- return 0;
-}
-
-/*
-// ---- divide vertical glued boxes (ex: g above T);
-*/
-int divide_vert_glued_boxes( pix *pp, int mo){
- struct box *box2,*box3,*box4;
- int y0,y1,y,dy,flag_found,dx;
- if(JOB->cfg.verbose)fprintf(stderr,"# divide vertical glued boxes");
- for_each_data(&(JOB->res.boxlist)) {
- box2 = (struct box *)list_get_current(&(JOB->res.boxlist));
- if (box2->c != UNKNOWN) continue; /* dont try on pictures */
- y0=box2->y0; y1=box2->y1; dy=y1-y0+1;
- dx=4*(JOB->res.avX+box2->x1-box2->x0+1); // we want to be sure to look at 4ex distance
- if ( dy>2*JOB->res.avY && dy<6*JOB->res.avY && box2->m1
- && y0<=box2->m2+2 && y0>=box2->m1-2
- && y1>=box2->m4+JOB->res.avY-2)
- { // test if lower end fits one of the other lines?
- box4=box2; flag_found=0;
- for_each_data(&(JOB->res.boxlist)) {
- box4 = (struct box *)list_get_current(&(JOB->res.boxlist));
- if (box4->c != UNKNOWN) continue; /* dont try on pictures */
- if (box4->x1<box2->x0-dx || box4->x0>box2->x1+dx) continue; // ignore far boxes
- if (box4->line==box2->line ) flag_found|=1; // near char on same line
- if (box4->line==box2->line+1) flag_found|=2; // near char on next line
- if (flag_found==3) break; // we have two vertical glued chars
- } end_for_each(&(JOB->res.boxlist));
- if (flag_found!=3) continue; // do not divide big chars or special symbols
- y=box2->m4; // lower end of the next line
- if(JOB->cfg.verbose&2){
- fprintf(stderr,"\n# divide box below y=%4d",y-y0);
- }
- // --- insert box3 before box2
- box3= (struct box *) malloc_box(box2);
- box3->y1=y;
- box2->y0=y+1; box2->line++; // m1..m4 should be corrected!
- if (box4->line == box2->line){
- box2->m1=box4->m1; box2->m2=box4->m2;
- box2->m3=box4->m3; box2->m4=box4->m4;
- }
- box3->num=JOB->res.numC;
- if (list_ins(&(JOB->res.boxlist), box2, box3)) {
- fprintf(stderr,"ERROR list_ins\n"); };
- JOB->res.numC++;
- }
- } end_for_each(&(JOB->res.boxlist));
- if(JOB->cfg.verbose)fprintf(stderr,", numC %d\n",JOB->res.numC);
- return 0;
-}
-
-
-/*
- on some systems isupper(>255) cause a segmentation fault SIGSEGV
- therefore this function
- ToDo: should be replaced (?) by wctype if available on every system
- */
-int wisupper(wchar_t cc){ return ((cc<128)?isupper(cc):0); }
-int wislower(wchar_t cc){ return ((cc<128)?islower(cc):0); }
-int wisalpha(wchar_t cc){ return ((cc<128)?isalpha(cc):0); }
-int wisdigit(wchar_t cc){ return ((cc<128)?isdigit(cc):0); }
-int wisspace(wchar_t cc){ return ((cc<128)?isspace(cc):0); }
-
-/* set box2->c to cc if cc is in the ac-list of box2, return 1 on success */
-int setc(struct box *box2, wchar_t cc){
- int ret=0, w1, w2;
- w1=((box2->num_ac) ? box2->wac[0] : 0); // weight of replaced char
- w2=testac(box2,cc);
- if (JOB->cfg.verbose)
- fprintf(stderr, "\n# change %s (%d) to %s (%d) at (%d,%d)",
- decode(box2->c,ASCII), w1, decode(cc,ASCII), w2, box2->x0, box2->y0);
- if (w2) { if (box2->c!=cc) { ret=1; setac(box2,cc,(100+w2)/2); } }
- // if(JOB->cfg.verbose & 4) out_x(box2);
- // ToDo: modify per setac (shift ac)
- return ret;
-}
-
-
-/* ---- proof difficult chars Il1 by context view ----
- context: separator, number, vowel, nonvowel, upper case ????
- could be also used to find unknown chars if the environment (nonumbers)
- can be found in other places!
- ToDo:
- - box->tac[] as set of possible chars, ac set by engine, example:
- ac="l/" (not "Il|/\" because serifs detected and slant>0)
- correction only to one of the ac-set (alternative chars)!
- - should be language-settable; Unicode compatible
- - box2->ad and wac should be changed? (not proper yet)
- * ------------- */
-int context_correction( job_t *job ) {
- // const static char
- char *l_vowel="aeiouy";
- // *l_Vowel="AEIOU",chars if the environment (nonumbers)
- char *l_nonvo = "bcdfghjklmnpqrstvwxz";
- struct box *box4, *box3, *box2, *prev, *next;
- // pix *pp = &(job->src.p);
- int nc=0, ns=0; // num corrections
-
- if (job->cfg.verbose)
- fprintf(stderr, "# context correction Il1 0O");
-
- for_each_data(&(job->res.boxlist)) {
- box2 = (struct box *)list_get_current(&(job->res.boxlist));
- if (box2->c > 0xFF) continue; // temporary UNICODE fix
- prev = (struct box *)list_get_cur_prev(&(job->res.boxlist));
- next = (struct box *)list_get_cur_next(&(job->res.boxlist));
- if( (prev) && (prev->c > 0xFF)) continue; // temporary UNICODE fix 2
- if( (next) && (next->c > 0xFF)) continue; // temporary UNICODE fix 3
- if (box2->num_ac<2) continue; // no alternatives
- if (box2->wac[0]==100 && box2->wac[1]<100) continue;
- if (box2->num_ac && box2->tas[0]) continue; // buggy space_remove 0.42
-
- /* check for Il1| which are general difficult to distinguish */
- /* bbg: not very good. Should add some tests to check if is preceded by '.',
- spelling, etc */
- /* ToDo: only correct if not 100% sure (wac[i]<100)
- and new char is in wat[] */
- if (strchr("Il1|", box2->c) && next && prev) {
-// if( strchr(" \n",prev->c) // SPC
-// && strchr(" \n",next->c) ) box2->c='I'; else // bad idea! I have ...
- if (wisalpha(next->c) && next->c!='i' &&
- ( prev->c == '\n' ||
- ( prev->c == ' ' &&
- ( box4=(struct box *)list_prev(&(job->res.boxlist), prev)) &&
- box4->c == '.' ) ) ) { nc+=setc(box2,(wchar_t)'I'); }
- else if (box2->c!='1' && strchr(l_nonvo,next->c) &&
- strchr("\" \n",prev->c)) /* lnt => Int, but 1st */
- /* do not change he'll to he'Il! */
- { nc+=setc(box2,(wchar_t)'I'); } // set box2->c to 'I' if 'I' is in the ac-list
- else if (strchr(l_vowel,next->c)) /* unusual? Ii Ie Ia Iy Iu */
- /* && strchr("KkBbFfgGpP",prev->c)) */ /* kle Kla Kli */
- { nc+=setc(box2,(wchar_t)'l'); }
- else if (wisupper(next->c)
- && !strchr("O0I123456789",next->c)
- && !strchr("O0I123456789",prev->c)) /* avoid lO => IO (10) */
- { nc+=setc(box2,(wchar_t)'I'); }
- else if (wislower(prev->c))
- { nc+=setc(box2,(wchar_t)'l'); }
- else if (wisdigit(prev->c) || wisdigit(next->c)
- || (next->c=='O' && !wisalpha(prev->c))) /* lO => 10 */
- { nc+=setc(box2,(wchar_t)'1'); }
- }
-
- /* check for O0 */
- else if (strchr("O0", box2->c) && next && prev) {
- if (wisspace(prev->c) && wisalpha(next->c)) /* initial letter */
- { nc+=setc(box2,(wchar_t)'O'); }
- else if (wisalpha(prev->c) && wisalpha(next->c)
- && wisupper(next->c)) /* word in upper case */
- { nc+=setc(box2,(wchar_t)'O'); }
- else if (wisdigit(prev->c) || wisdigit(next->c))
- { nc+=setc(box2,(wchar_t)'0'); }
- }
-
- /* check for 5S */
- else if (strchr("5S", box2->c) && next && prev) {
- if (wisspace(prev->c) && wisalpha(next->c)) /* initial letter */
- { nc+=setc(box2,(wchar_t)'S'); }
- else if (wisalpha(prev->c) && wisalpha(next->c)
- && wisupper(next->c)) /* word in upper case */
- { nc+=setc(box2,(wchar_t)'S'); }
- else if (wisdigit(prev->c) || wisdigit(next->c))
- { nc+=setc(box2,(wchar_t)'5'); }
- }
-
- /* was a space not found? xXx => x Xx ??? */
- if (wisupper(box2->c) && next && prev) {
- if (wislower(prev->c) && wislower(next->c)
- && 2 * (box2->x0 - prev->x1) > 3 * (next->x0 - box2->x1)) {
- struct box *box3 = malloc_box((struct box *) NULL);
- box3->x0 = prev->x1 + 2;
- box3->x1 = box2->x0 - 2;
- box3->y0 = box2->y0;
- box3->y1 = box2->y1;
- box3->x = box2->x0 - 1;
- box3->y = box2->y0;
- box3->dots = 0;
- box3->num_boxes = 0;
- box3->num_subboxes = 0;
- box3->c = ' ';
- box3->modifier = 0;
- setac(box3,' ',99); /* ToDo: weight depends from distance */
- box3->num = -1;
- box3->line = prev->line;
- box3->m1 = box3->m2 = box3->m3 = box3->m4 = 0;
- box3->p = &(job->src.p);
- list_ins(&(job->res.boxlist), box2, box3);
- }
- }
-
- /* a space before punctuation? but not " ./file" */
- if ( prev && next)
- if (prev->c == ' ' && strchr(" \n" , next->c)
- && strchr(".,;:!?)", box2->c))
- if (prev->x1 - prev->x0 < 2 * job->res.avX) { // carefully on tables
- box3 = prev;
- if ( !list_del(&(job->res.boxlist), box3) ) free_box(box3);
- prev = (struct box *)list_get_cur_prev(&(job->res.boxlist));
- ns++;
- }
-
- /* \'\' to \" */
- if ( prev )
- if ( (prev->c == '`' || prev->c == '\'')
- && (box2->c == '`' || box2->c == '\'') )
- if (prev->x1 - box2->x0 < job->res.avX) { // carefully on tables
- box2->c='\"';
- box3 = prev;
- list_del(&(job->res.boxlist), box3);
- free_box(box3);
- }
- } end_for_each(&(job->res.boxlist));
- if (job->cfg.verbose)
- fprintf(stderr, " num_corrected= %d removed_spaces= %d\n", nc, ns);
- return 0;
-}
-
-
-/* ---- insert spaces ----
- * depends strongly from the outcome of measure_pitch()
- * ------------------------ */
-int list_insert_spaces( pix *pp, job_t *job ) {
- int i=0, j1, j2, i1, maxline=-1, dy=0; char cc;
- struct box *box2, *box3=NULL, *box4=NULL;
-
- // measure mean line height
- for(i1=1;i1<job->res.lines.num;i1++) {
- dy+=job->res.lines.m4[i1]-job->res.lines.m1[i1]+1;
- } if (job->res.lines.num>1) dy/=(job->res.lines.num-1);
- i=0; j2=0;
- for(i1=1;i1<job->res.lines.num;i1++) {
- j1=job->res.lines.m4[i1]-job->res.lines.m1[i1]+1;
- if (j1>dy*120/100 || j1<dy*80/100) continue; // only most frequently
- j2+=j1; i++;
- } if (i>0 && j2/i>7) dy=j2/i;
- if( job->cfg.verbose&1 )
- fprintf(stderr,"# insert space between words (dy=%d) ...",dy);
- if (!dy) dy=(job->res.avY)*110/100+1;
-
- i=0;
- for_each_data(&(job->res.boxlist)) {
- box2 =(struct box *)list_get_current(&(job->res.boxlist));
- cc=0;
- if (box2->line>maxline) { // lines and chars must be sorted!
- if (maxline>=0) cc='\n'; // NL
- maxline=box2->line;
- }
- if((box3 = (struct box *)list_prev(&(job->res.boxlist), box2))){
- if (maxline && !box2->line && cc==0) cc=' ';
- if (box2->line<=maxline && cc==0) { // lines and chars must be sorted!
- int thispitch = job->res.lines.pitch[box2->line];
- int thismono = job->res.lines.mono[box2->line];
- int mdist = (box2->x1 + box2->x0 - (box3->x1 + box3->x0) + 1)/2;
- int pdist = box2->x0 - box3->x1 + 1;
- if (box2->x1 - box2->x0 < thispitch) pdist=pdist*4/3;
- /* allow extra pixels around small characters .,'!: etc */
- // fprintf(stderr,"#\n ... mono= %2d pitch= %2d mdist= %2d pdist= %2d",
- // thismono, thispitch, mdist, pdist);
- if ((thismono!=0 && mdist >= thispitch)
- || (thismono==0 && pdist >= thispitch))
- cc=' '; // insert SPACE
- }
- }
- if(cc){
- box4=(struct box *)list_prev(&(job->res.boxlist), box2);
- box3=(struct box *)malloc_box(NULL);
- box3->x0=box2->x0-2; box3->x1=box2->x0-2;
- box3->y0=box2->y0; box3->y1=box2->y1;
- if(cc!='\n' && box4)
- box3->x0=box4->x1+2;
- if(cc=='\n' || !box4)
- box3->x0=job->res.lines.x0[box2->line];
- if(cc=='\n' && box4){
- box3->y0=box4->y1; // better use lines.y1[box2->pre] ???
- box3->y1=box2->y0;
- }
- box3->x =box2->x0-1; box3->y=box2->y0;
- box3->dots=0; box3->c=cc;
- box3->num_boxes = 0;
- box3->num_subboxes = 0;
- box3->modifier='\0';
- box3->num=-1; box3->line=box2->line;
- box3->m1=box2->m1; box3->m2=box2->m2;
- box3->m3=box2->m3; box3->m4=box2->m4;
- box3->p=pp;
- setac(box3,cc,99); /* ToDo: weight depends from distance */
- list_ins(&(job->res.boxlist),box2,box3);
- if( job->cfg.verbose&1 ) {
- fprintf(stderr,"\n# insert space &%d; at x= %4d %4d box= %p",
- (int)cc, box3->x0, box3->y0, (void*)box3);
- /* out_x(box3); */
- }
- i++;
- }
- } end_for_each(&(job->res.boxlist));
- if( job->cfg.verbose&1 ) fprintf(stderr," found %d\n",i);
- return 0;
-}
-
-
-/*
- add infos where the box is positioned to the box
- this is useful for better recognition
-*/
-int add_line_info(/* List *boxlist2 */){
- // pix *pp=&JOB->src.p;
- struct tlines *lines = &JOB->res.lines;
- struct box *box2;
- int i,xx,m1,m2,m3,m4,num_line_members=0,num_rest=0;
- if( JOB->cfg.verbose&1 ) fprintf(stderr,"# add line infos to boxes ...");
- for_each_data(&(JOB->res.boxlist)) {
- box2 =(struct box *)list_get_current(&(JOB->res.boxlist));
- for(i=1;i<JOB->res.lines.num;i++) /* line 0 is a place holder */
- {
- if (lines->dx) xx=lines->dy*((box2->x1+box2->x0)/2)/lines->dx; else xx=0;
- m1=lines->m1[i]+xx;
- m2=lines->m2[i]+xx;
- m3=lines->m3[i]+xx;
- m4=lines->m4[i]+xx;
- // fprintf(stderr," test line %d m1=%d %d %d %d\n",i,m1,m2,m3,m4);
- if (m4-m1==0) continue; /* no text line (line==0) */
-#if 0
- if( box2->y1+2*JOB->res.avY >= m1
- && box2->y0-2*JOB->res.avY <= m4 ) /* not to far away */
-#endif
- /* give also a comma behind the line a chance */
- if( box2->x0 >= lines->x0[i] && box2->x1 <= lines->x1[i]+JOB->res.avX )
- if( box2->m2==0 || abs(box2->y0-box2->m2) > abs(box2->y0-m2) )
- { /* found nearest line */
- box2->m1=m1;
- box2->m2=m2;
- box2->m3=m3;
- box2->m4=m4;
- box2->line=i;
- }
- }
- if( box2->y1+2 < box2->m1
- || box2->y0 < box2->m1 - (box2->m3-box2->m1)/2
- || box2->y0-2 > box2->m4
- || box2->y1 > box2->m3 + (box2->m3-box2->m1)
- ) /* to far away */
- { /* reset */
- box2->m1=0;
- box2->m2=0;
- box2->m3=0;
- box2->m4=0;
- box2->line=0;
- num_rest++;
- } else num_line_members++;
- } end_for_each(&(JOB->res.boxlist));
- if( JOB->cfg.verbose&1 )
- fprintf(stderr," done, num_line_chars=%d rest=%d\n",
- num_line_members, num_rest);
- return 0;
-}
-
-
-/*
- * bring the boxes in right order
- * add_line_info must be executed first!
- */
-int sort_box_func (const void *a, const void *b) {
- struct box *boxa, *boxb;
-
- boxa = (struct box *)a;
- boxb = (struct box *)b;
-
- if ( ( boxb->line < boxa->line ) ||
- ( boxb->line == boxa->line && boxb->x0 < boxa->x0 ) )
- return 1;
- return -1;
-}
-
-// -------------------------------------------------------------
-// ------ use this for entry from other programs
-// include pnm.h pgm2asc.h
-// -------------------------------------------------------------
-// entry point for gocr.c or if it is used as lib
-// better name is call_ocr ???
-// jb: OLD COMMENT: not removed due to set_options_* ()
-// args after pix *pp should be removed and new functions
-// set_option_mode(int mode), set_option_spacewidth() .... etc.
-// should be used instead, before calling pgm2asc(pix *pp)
-// ! change if you can ! - used by X11 frontend
-int pgm2asc(job_t *job)
-{
- pix *pp;
- progress_counter_t *pc;
-
- assert(job);
- /* FIXME jb: remove pp */
- pp = &(job->src.p);
-
- if( job->cfg.verbose )
- fprintf(stderr, "# db_path= %s\n", job->cfg.db_path);
-
- pc = open_progress(100,"pgm2asc_main");
- progress(0,pc); /* start progress output 0% 0% */
-
- /* ----- count colors ------ create histogram -------
- - this should be used to create a upper and lower limit for cs
- - cs is the optimum gray value between cs_min and cs_max
- - also inverse scans could be detected here later */
- if (job->cfg.cs==0)
- job->cfg.cs=otsu( pp->p,pp->y,pp->x,0,0,pp->x,pp->y, job->cfg.verbose & 1 );
- /* renormalize the image and set the normalized threshold value */
- job->cfg.cs=thresholding( pp->p,pp->y,pp->x,0,0,pp->x,pp->y, job->cfg.cs );
- if( job->cfg.verbose )
- fprintf(stderr, "# thresholding new_threshold= %d\n", job->cfg.cs);
-
- progress(5,pc); /* progress is only estimated */
-
-#if 0 /* dont vast memory */
- /* FIXME jb: malloc */
- if ( job->cfg.verbose & 32 ) {
- // generate 2nd imagebuffer for debugging output
- job->tmp.ppo.p = (unsigned char *)malloc(job->src.p.y * job->src.p.x);
- // buffer
- assert(job->tmp.ppo.p);
- copybox(&job->src.p,
- 0, 0, job->src.p.x, job->src.p.y,
- &job->tmp.ppo,
- job->src.p.x * job->src.p.y);
- }
-#else
- job->tmp.ppo=job->src.p; /* temporarely, removed later */
-#endif
-
- /* load character data base */
- if ( job->cfg.mode&2 )
- load_db();
-
- /* this is first step for reorganize the PG
- ---- look for letters, put rectangular frames around letters
- letter = connected points near color F
- should be used by dust removing (faster) and line detection!
- ---- 0..cs = black letters, last change = Mai99 */
-
- progress(8,pc); /* progress is only estimated */
-
- scan_boxes( pp );
- if ( !job->res.numC ){
- fprintf( stderr,"# no boxes found - stopped\n" );
- //if(job->cfg.verbose&32) debug_img("out01",job,8);
- /***** should free stuff, etc) */
- return(1);
- }
- // if (job->cfg.verbose&32) debug_img("out00",job,4+8);
-
- progress(10,pc); /* progress is only estimated */
- // if(job->cfg.verbose&32) debug_img("out01",job,4+8);
- // output_list(job); // for debugging
- // ToDo: matrix printer preprocessing
-
- remove_dust( job ); /* from the &(job->res.boxlist)! */
-// if(job->cfg.verbose&32) debug_img("out02",job,4+8);
-// output_list(job); // for debugging
- smooth_borders( job ); /* only for big chars */
- progress(12,pc); /* progress is only estimated */
-// if(job->cfg.verbose&32) debug_img("out03",job,4+8);
-// output_list(job); // for debugging
-
- //detect_barcode( job ); /* mark barcode */
-// if(job->cfg.verbose&32) debug_img("out04",job,4+8);
-// output_list(job); // for debugging
-
- detect_pictures( job ); /* mark pictures */
-// if(job->cfg.verbose&32) debug_img("out05",job,4+8);
-// output_list(job); // for debugging
-
- remove_pictures( job ); /* do this as early as possible, before layout */
-// if(job->cfg.verbose&32) debug_img("out06",job,4+8);
-// output_list(job); // for debugging
-
- glue_holes_inside_chars( pp ); /* including count subboxes (holes) */
-
- detect_rotation_angle( job );
-
-#if 1 /* Rotate the whole picture! move boxes */
- if( job->res.lines.dy!=0 ){ // move down lowest first, move up highest first
- // in work! ??? (at end set dy=0) think on ppo!
- }
-#endif
- detect_text_lines( pp, job->cfg.mode ); /* detect and mark JOB->tmp.ppo */
-// if(job->cfg.verbose&32) debug_img("out07",job,4+8);
- progress(20,pc); /* progress is only estimated */
-
- add_line_info(/* &(job->res.boxlist) */);
- //if (job->cfg.verbose&32) debug_img("out10",job,4+8);
-
- divide_vert_glued_boxes( pp, job->cfg.mode); /* after add_line_info, before list_sort! */
-// if(job->cfg.verbose&32) debug_img("out11",job,0);
-
- remove_melted_serifs( pp ); /* make some corrections on pixmap */
- /* list_ins seems to sort in the boxes on the wrong place ??? */
-// if(job->cfg.verbose&32) debug_img("out12",job,4+8);
-
- glue_broken_chars( pp ); /* 2nd glue */
-// if(job->cfg.verbose&32) debug_img("out14",job,4+8);
-
- remove_rest_of_dust( );
-// if(job->cfg.verbose&32) debug_img("out15",job,4+8);
-
- /* better sort after dust is removed (slow for lot of pixels) */
- list_sort(&(job->res.boxlist), sort_box_func);
-
- measure_pitch( job );
-
- if(job->cfg.mode&64) find_same_chars( pp );
- progress(30,pc); /* progress is only estimated */
-// if(job->cfg.verbose&32) debug_img("out16",job,4+8);
-
- char_recognition( pp, job->cfg.mode);
- progress(60,pc); /* progress is only estimated */
-// if(job->cfg.verbose&32) debug_img("out17",job,4+8);
-
- if ( adjust_text_lines( pp, job->cfg.mode ) ) { /* correct using chars */
- /* may be, characters/pictures have changed line number */
- list_sort(&(job->res.boxlist), sort_box_func);
- // 2nd recognition call if lines are adjusted
- char_recognition( pp, job->cfg.mode);
- }
-
-#define BlownUpDrawing 1 /* german: Explosionszeichnung, temporarly */
-#if BlownUpDrawing == 1 /* german: Explosionszeichnung */
-{ /* just for debugging */
- int i,ii,ni; struct box *box2;
- i=ii=ni=0;
- for_each_data(&(JOB->res.boxlist)) { /* count boxes */
- box2 = (struct box *)list_get_current(&(JOB->res.boxlist));
- if (box2->c==UNKNOWN) i++;
- if (box2->c==PICTURE) ii++;
- ni++;
- } end_for_each(&(JOB->res.boxlist));
- if (JOB->cfg.verbose)
- fprintf(stderr,"# debug: unknown= %d picts= %d boxes= %d\n",i,ii,ni);
-}
-#endif
- // ----------- write out20.pgm ----------- mark lines + boxes
- //if (job->cfg.verbose&32) debug_img("out20",job,1+4+8);
-
- compare_unknown_with_known_chars( pp, job->cfg.mode);
- progress(70,pc); /* progress is only estimated */
-
- try_to_divide_boxes( pp, job->cfg.mode);
- progress(80,pc); /* progress is only estimated */
-
- /* --- list output ---- for debugging --- */
- //if (job->cfg.verbose&6) output_list(job);
-
- /* ---- insert spaces ---- */
- list_insert_spaces( pp , job );
-
- // ---- proof difficult chars Il1 by context view ----
- if (JOB->cfg.verbose)
- fprintf(stderr,"# context correction if !(mode&32)\n");
- if (!(job->cfg.mode&32)) context_correction( job );
-
- store_boxtree_lines( job->cfg.mode );
- progress(90,pc); /* progress is only estimated */
-
-/* 0050002.pgm.gz ca. 109 digits, only 50 recognized (only in lines?)
- * ./gocr -v 39 -m 56 -e - -m 4 -C 0-9 -f XML tmp0406/0050002.pbm.gz
- * awk 'BEGIN{num=0}/1<\/box>/{num++;}END{print num}' o
- * 15*0 24*1 18*2 19*3 15*4 6*5 6*6 6*7 4*8 8*9 sum=125digits counted boxes
- * 9*0 19*1 14*2 15*3 11*4 6*5 5*6 6*7 4*8 8*9 sum=97digits recognized
- * 1*1 1*7 not recognized (Oct04)
- * 33*SPC 76*NL = 109 spaces + 36*unknown sum=241 * 16 missed
- */
-#if BlownUpDrawing == 1 /* german: Explosionszeichnung */
-{ /* just for debugging */
- int i,ii,ni; struct box *box2; const char *testc="0123456789ABCDEFGHIJK";
- i=ii=ni=0;
- for_each_data(&(JOB->res.boxlist)) { /* count boxes */
- box2 = (struct box *)list_get_current(&(JOB->res.boxlist));
- if (box2->c==UNKNOWN) i++;
- if (box2->c==PICTURE) ii++;
- if (box2->c>' ' && box2->c<='z') ni++;
- } end_for_each(&(JOB->res.boxlist));
- if(JOB->cfg.verbose)
- fprintf(stderr,"# debug: (_)= %d picts= %d chars= %d",i,ii,ni);
- for (i=0;i<20;i++) {
- ni=0;
- for_each_data(&(JOB->res.boxlist)) { /* count boxes */
- box2 = (struct box *)list_get_current(&(JOB->res.boxlist));
- if (box2->c==testc[i]) ni++;
- } end_for_each(&(JOB->res.boxlist));
- if(JOB->cfg.verbose && ni>0)
- fprintf(stderr," (%c)=%d",testc[i],ni);
- }
- if(JOB->cfg.verbose)
- fprintf(stderr,"\n");
-}
-#endif
-
- // ---- frame-size-histogram
- // ---- (my own defined) distance between letters
- // ---- write internal picture of textsite
- // ----------- write out30.pgm -----------
- //if( job->cfg.verbose&32 ) debug_img("out30",job,2+4);
-
- progress(100,pc); /* progress is only estimated */
-
- close_progress(pc);
-
- return 0; /* what should I return? error-state? num-of-chars? */
-}
+++ /dev/null
-/*
-This is a Optical-Character-Recognition program
-Copyright (C) 2000-2006 Joerg Schulenburg
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- see README for EMAIL-address
-
-*/
-
-#ifndef PGM2ASC_H
-#define PGM2ASC_H 1
-
-#include "pnm.h"
-//#include "output.h"
-#include "list.h"
-#include "unicode.h"
-#include "gocr.h"
-
-#define pixel_at(pic, xx, yy) (pic).p[(xx)+((yy)*((pic).x))]
-#define pixel_atp(pic, xx, yy) (pic)->p[(xx)+((yy)*((pic)->x))]
-
-#ifndef HAVE_WCHAR_H
-const wchar_t *wcschr (const wchar_t *wcs, wchar_t wc);
-const wchar_t *wcscpy (wchar_t *dest, const wchar_t *src);
-size_t wcslen (const wchar_t *s);
-#endif
-#ifndef HAVE_WCSDUP
-wchar_t * wcsdup (const wchar_t *WS); /* its a gnu extension */
-#endif
-
-/* declared in pgm2asc.c */
-/* set alternate chars and its weight, called from the engine
- if a char is recognized to (weight) percent */
-int setas(struct box *b, char *as, int weight); /* string + xml */
-int setac(struct box *b, wchar_t ac, int weight); /* wchar */
-
-/* for qsort() call */
-int intcompare (const void *vr, const void *vs);
-
-/* declared in box.c */
-int box_gt(struct box *box1, struct box *box2);
-int reset_box_ac(struct box *box); /* reset and free char table */
-struct box *malloc_box( struct box *inibox ); /* alloc memory for a box */
-int free_box( struct box *box ); /* free memory of a box */
-int copybox( pix *p, int x0, int y0, int dx, int dy, pix *b, int len);
-int reduce_vectors ( struct box *box1, int mode );
-int merge_boxes( struct box *box1, struct box *box2 );
-int cut_box( struct box *box1);
-
-
-/* declared in database.c */
-int load_db(void);
-wchar_t ocr_db(struct box *box1);
-
-/* declared in detect.c */
-int detect_lines1(pix * p, int x0, int y0, int dx, int dy);
-int detect_lines2(pix *p,int x0,int y0,int dx,int dy,int r);
-int detect_rotation_angle(job_t *job);
-int detect_text_lines(pix * pp, int mo);
-int adjust_text_lines(pix * pp, int mo);
-int detect_pictures(job_t *job);
-
-/* declared in lines.c */
-void store_boxtree_lines( int mo );
- /* free memory for internal stored textlines.
- * Needs to be called _after_ having retrieved the text.
- * After freeing, no call to getTextLine is possible any
- * more
- */
-void free_textlines( void );
-
- /* get result of ocr for a given line number.
- * If the line is out of range, the function returns 0,
- * otherwise a pointer to a complete line.
- */
-const char *getTextLine( int );
-
-/* declared in remove.c */
-int remove_dust( job_t *job );
-int remove_pictures( job_t *job);
-int remove_melted_serifs( pix *pp );
-int remove_rest_of_dust();
-int smooth_borders( job_t *job );
-
-/* declared in pixel.c */
-int marked(pix * p, int x, int y);
-int pixel(pix *p, int x, int y);
-void put(pix * p, int x, int y, int ia, int io);
-
-/* start ocr on a image in job.src.p */
-int pgm2asc(job_t *job);
-
-#endif
+++ /dev/null
-/* Handle PNM-files Dez98 JS
- * 0,0 = left up
- * PAM-formats
- * PAM any P7
- * PNM-formats
- * PGM gray ASCII=P2 RAW=P5 dx dy col gray
- * PPM RGB ASCII=P3 RAW=P6 dx dy col RGB
- * PBM B/W ASCII=P1 RAW=P4 dx dy bitmap
- */
-
-#ifndef GOCR_PNM_H
-#define GOCR_PNM_H 1
-
-#include "../../config.h"
-
-struct pixmap {
- unsigned char *p; /* pointer of image buffer (pixmap) */
- int x; /* xsize */
- int y; /* ysize */
- int bpp; /* bytes per pixel: 1=gray 3=rgb */
- };
-typedef struct pixmap pix;
-
-#endif
+++ /dev/null
-/*
-This is a Optical-Character-Recognition program
-Copyright (C) 2000-2007 Joerg Schulenburg
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- see README for EMAIL-address
-*/
-
-#include <stdlib.h>
-#include <stdio.h>
-#include "pgm2asc.h"
-#include "gocr.h"
-#include "progress.h"
-
-/* measure mean thickness as an criteria for big chars */
-int mean_thickness( struct box *box2 ){
- int mt=0, i, y, dx=box2->x1-box2->x0+1, dy;
- for (y=box2->y0+1; y<box2->y1; y++) {
- i=loop(box2->p,box2->x0+0,y,dx,JOB->cfg.cs,0,RI);
- i=loop(box2->p,box2->x0+i,y,dx,JOB->cfg.cs,1,RI);
- mt+=i;
- }
- dy = box2->y1 - box2->y0 - 1;
- if (dy) mt=(mt+dy/2)/dy;
- return mt;
-}
-
-/* ---- remove dust ---------------------------------
- What is dust? I think, this is a very small pixel cluster without
- neighbours. Of course not all dust clusters can be detected correct.
- This feature should be possible to switch off via option.
- -> may be, all clusters should be stored here?
- speed is very slow, I know, but I am happy that it is working well
-*/
-int remove_dust( job_t *job ){
- /* new dust removing */
- /* FIXME jb:remove pp */
- pix *pp = &job->src.p;
- int i1,i,j,x,y,x0,x1,y0,y1,nC,sX,sY,sP, cs,vvv=job->cfg.verbose;
- struct box *box2;
-#define HISTSIZE 220 /* histogramm */
- int histo[HISTSIZE];
- cs=job->cfg.cs; sP=sX=sY=nC=0;
- /*
- * count number of black pixels within a box and store it in .dots
- * later .dots is re-used for number of objects belonging to the character
- * should be done in the flood-fill algorithm
- * volume of white pixels is estimated to big here (left/right rot)
- * ToDo: mean thickness of char lines?
- * or interval nesting (minP..maxP) to remove outriders
- */
- j=0;
- for (i1=0;i1<HISTSIZE;i1++) histo[i1]=0;
- /* mean value over every black object which is big enough */
- for_each_data(&(job->res.boxlist)) {
- box2 = (struct box *)list_get_current(&(job->res.boxlist));
- if (!box2->num_frames) continue;
- if (box2->frame_vol[0]<0) continue; /* don't count inner holes */
- j = abs(box2->frame_vol[0]);
- if ((box2->y1-box2->y0+1)>3) {
- nC++; /* only count potential chars v0.42 */
- sX+=box2->x1 - box2->x0 + 1;
- sY+=box2->y1 - box2->y0 + 1;
- sP+=j;
- }
- if (j<HISTSIZE) histo[j]++;
- } end_for_each(&(job->res.boxlist));
-
- if (job->cfg.dust_size < 0 && nC > 0) { /* auto detection */
- /* this formula is empirically, high resolution scans have bigger dust */
- /* maximum allowed dustsize (min=4*7 ca. 32)
- * does not work for background pattern!
- */
- job->cfg.dust_size = ( ( sX/nC ) * ( sY/nC ) + 16) / 32;
- if (vvv) fprintf(stderr, "# dust size detection, vol num"
- " #obj=%d maxDust=%d mpixel= %3d mxy= %2d %2d",
- nC, job->cfg.dust_size, sP/nC, sX/nC, sY/nC);
- /* we assume that for random dust applies histo[i+1]<histo[i] */
- for (i=1;i+3<HISTSIZE;i++){
- if (vvv) fprintf(stderr,"\n# dust size histogram %3d %5d",i,histo[i]);
- if (histo[i]>=nC) continue; /* v0.42 lot of pixels -> bg pattern < 3 */
- if (i>=job->cfg.dust_size) break; /* maximum = mean size / 32 */
- if (histo[i+1]==0) break; /* bad statistic */
- if ((histo[i+2]+histo[i+3])
- >=(histo[i] +histo[i+1])) break; /* no noise, but to late? */
- if ( histo[i-1] > 1024*histo[i] &&
- 2*histo[i+1] >=histo[i]) break; /* bg pattern */
- }
- if (vvv) fprintf(stderr," break");
- if (vvv) for (i1=0,j=i+1;j<HISTSIZE;j++) {
- /* compressed, output only if something is changing */
- if (j==HISTSIZE-1 || histo[j]!=histo[j-1] || histo[j]!=histo[j+1]) {
- fprintf(stderr,"\n# dust size histogram %3d %5d",j,histo[j]);
- if (++i1>20) break; /* dont do excessive output */
- }
- }
- job->cfg.dust_size=i-1;
- /* what is the statistic of random dust?
- * if we have p pixels on a x*y image we should have
- * (p/(x*y))^1 * (x*y) = p singlets
- * (p/(x*y))^2 * (x*y) = p^2/(x*y) doublets and
- * (p/(x*y))^3 * (x*y) = p^3/(x*y)^2 triplets
- */
- if (vvv) fprintf(stderr,"\n# auto dust size = %d nC= %3d .. %3d"
- " avD= %2d %2d .. %2d %2d\n",
- job->cfg.dust_size, nC, job->res.numC,
- (job->res.sumX+job->res.numC/2)/job->res.numC,
- (job->res.sumY+job->res.numC/2)/job->res.numC, sX/nC, sY/nC);
- }
- if (job->cfg.dust_size)
- { i=0;
- if(vvv){
- fprintf(stderr,"# remove dust of size %2d",job->cfg.dust_size);
- /* Warning: better use (1/(x*y))^2 as 1/((x*y)^2),
- * because (x*y)^2 may overflow */
- fprintf(stderr," histo=%d,%d(?=%d),%d(?=%d),...\n# ...",
- histo[1],histo[2],histo[1]*histo[1]/(pp->x*pp->y),
- histo[3], histo[1]*histo[1]/(pp->x*pp->y)
- *histo[1]/(pp->x*pp->y));
- }
- i = 0;
- for_each_data(&(job->res.boxlist)) {
- box2 = (struct box *)list_get_current(&(job->res.boxlist));
- x0=box2->x0;x1=box2->x1;y0=box2->y0;y1=box2->y1; /* box */
- j=abs(box2->frame_vol[0]);
- if(j<=job->cfg.dust_size) /* remove this tiny object */
- { /* here we should distinguish dust and i-dots,
- * may be we should sort out dots to a seperate dot list and
- * after line detection decide, which is dust and which not
- * dust should be removed to make recognition easier (ToDo)
- */
-#if 0
- if(get_bw((3*x0+x1)/4,(x0+3*x1)/4,y1+y1-y0+1,y1+8*(y1-y0+1),pp,cs,1))
- continue; /* this idea was to simple, see kscan003.jpg sample */
-#endif
- /* remove from average */
- job->res.numC--;
- job->res.sumX-=x1-x0+1;
- job->res.sumY-=y1-y0+1;
- /* remove pixels (should only be done with dust) */
- for(x=x0;x<=x1;x++)
- for(y=y0;y<=y1;y++){ put(pp,x,y,0,255&~7); }
- /* remove from list */
- list_del(&(job->res.boxlist),box2);
- /* free memory */
- free_box(box2);
- i++; /* count as dust particle */
- continue;
- }
- } end_for_each(&(job->res.boxlist));
- if(vvv)fprintf(stderr," %3d cluster removed, nC= %3d\n",i,job->res.numC);
- }
- /* reset dots to 0 and remove white pixels (new) */
- i=0;
- for_each_data(&(job->res.boxlist)) {
- box2 = ((struct box *)list_get_current(&(job->res.boxlist)));
- if (box2->frame_vol[0]<0) continue; /* for black areas only */
- x0=box2->x0;x1=box2->x1;y0=box2->y0;y1=box2->y1; /* box */
- if (x1-x0>16 && y1-y0>30) /* only on large enough chars */
- for(x=x0+1;x<=x1-1;x++)
- for(y=y0+1;y<=y1-1;y++){
- if( pixel_atp(pp,x ,y )>=cs
- && pixel_atp(pp,x-1,y ) <cs
- && pixel_atp(pp,x+1,y ) <cs
- && pixel_atp(pp,x ,y-1) <cs
- && pixel_atp(pp,x ,y+1) <cs ) /* remove it */
- {
- put(pp,x,y,0,0); i++; /* (x and 0) or 0 */
- }
- }
- } end_for_each(&(job->res.boxlist));
- if (vvv) fprintf(stderr,"# ... %3d white pixels removed, cs=%d nC= %3d\n",
- i,cs,job->res.numC);
- return 0;
-}
-
-/* ---- smooth big chars ---------------------------------
- * Big chars often do not have smooth borders, which let fail
- * the engine. Here we smooth the borders of big chars (>7x16).
- * Smoothing is important for b/w scans, where we often have
- * comb like pattern on a vertikal border. I also received
- * samples with lot of white pixels (sample: 04/02/25).
- * ToDo: obsolete if vector code is complete
- */
-int smooth_borders( job_t *job ){
- pix *pp = &job->src.p;
- int ii=0,x,y,x0,x1,y0,y1,dx,dy,cs,i0,i1,i2,i3,i4,n1,n2,
- cn[8],cm,vvv=job->cfg.verbose; /* dust found */
- struct box *box2;
- cs=job->cfg.cs; n1=n2=0;
- if(vvv){ fprintf(stderr,"# smooth big chars 7x16 cs=%d",cs); }
- /* filter for each big box */
- for_each_data(&(job->res.boxlist)) { n2++; /* count boxes */
- box2 = (struct box *)list_get_current(&(job->res.boxlist));
- /* do not touch small characters! but how we define small characters? */
- if (box2->x1-box2->x0+1<7 || box2->y1-box2->y0+1<16 ) continue;
- if (box2->c==PICTURE) continue;
- if (mean_thickness(box2)<3) continue;
- n1++; /* count boxes matching big-char criteria */
- x0=box2->x0; y0=box2->y0;
- x1=box2->x1; y1=box2->y1;
- dx=x1-x0+1; dy=y1-y0-1;
- /* out_x(box2);
- * dont change to much! only change if absolutely sure!
- * ....... 1 2 3
- * ex: .?##### 0 * 4
- * ....... 7 6 5
- * we should also avoid removing lines by sytematic remove
- * from left end to the right, so we concern also about distance>1
- */
- for(x=box2->x0;x<=box2->x1;x++)
- for(y=box2->y0;y<=box2->y1;y++){ /* filter out high frequencies */
- /* this is a very primitive solution, only for learning */
- cn[0]=getpixel(pp,x-1,y);
- cn[4]=getpixel(pp,x+1,y); /* horizontal */
- cn[2]=getpixel(pp,x,y-1);
- cn[6]=getpixel(pp,x,y+1); /* vertical */
- cn[1]=getpixel(pp,x-1,y-1);
- cn[3]=getpixel(pp,x+1,y-1); /* diagonal */
- cn[7]=getpixel(pp,x-1,y+1);
- cn[5]=getpixel(pp,x+1,y+1);
- cm=getpixel(pp,x,y);
- /* check for 5 other and 3 same surrounding pixels */
- for (i0=0;i0<8;i0++)
- if ((cn[i0 ]<cs)==(cm<cs)
- && (cn[(i0+7) & 7]<cs)!=(cm<cs)) break; /* first same */
- for (i1=0;i1<8;i1++)
- if ((cn[(i0+i1) & 7]<cs)!=(cm<cs)) break; /* num same */
- for (i2=0;i2<8;i2++)
- if ((cn[(i0+i1+i2) & 7]<cs)==(cm<cs)) break; /* num other */
- cn[0]=getpixel(pp,x-2,y);
- cn[4]=getpixel(pp,x+2,y); /* horizontal */
- cn[2]=getpixel(pp,x,y-2);
- cn[6]=getpixel(pp,x,y+2); /* vertical */
- cn[1]=getpixel(pp,x-2,y-2);
- cn[3]=getpixel(pp,x+2,y-2); /* diagonal */
- cn[7]=getpixel(pp,x-2,y+2);
- cn[5]=getpixel(pp,x+2,y+2);
- /* check for 5 other and 3 same surrounding pixels */
- for (i0=0;i0<8;i0++)
- if ((cn[i0 ]<cs)==(cm<cs)
- && (cn[(i0+7) & 7]<cs)!=(cm<cs)) break; /* first same */
- for (i3=0;i3<8;i3++)
- if ((cn[(i0+i3) & 7]<cs)!=(cm<cs)) break; /* num same */
- for (i4=0;i4<8;i4++)
- if ((cn[(i0+i3+i4) & 7]<cs)==(cm<cs)) break; /* num other */
- if (i1<=3 && i2>=5 && i3>=3 && i4>=3) { /* change only on borders */
- ii++; /* white : black */
- put(pp,x,y,7,((cm<cs)?(cs|32):cs/2)&~7);
-#if 0
- printf(" x y i0 i1 i2 i3 i4 cm new cs %3d %3d"
- " %3d %3d %3d %3d %3d %3d %3d %3d\n",
- x-box2->x0,y-box2->y0,i0,i1,i2,i3,i3,cm,getpixel(pp,x,y),cs);
-#endif
- }
- }
-#if 0 /* debugging */
- out_x(box2);
-#endif
- } end_for_each(&(job->res.boxlist));
- if(vvv)fprintf(stderr," ... %3d changes in %d of %d\n",ii,n1,n2);
- return 0;
-}
-
-/* test if a corner of box1 is within box2 */
-int box_nested( struct box *box1, struct box *box2){
- /* box1 in box2, +1..-1 frame for pixel-patterns */
- if ( ( ( box1->x0>=box2->x0-1 && box1->x0<=box2->x1+1 )
- || ( box1->x1>=box2->x0-1 && box1->x1<=box2->x1+1 ) )
- && ( ( box1->y0>=box2->y0-1 && box1->y0<=box2->y1+1 )
- || ( box1->y1>=box2->y0-1 && box1->y1<=box2->y1+1 ) ) )
- return 1;
- return 0;
-}
-
-/* test if box1 is within box2 */
-int box_covered( struct box *box1, struct box *box2){
- /* box1 in box2, +1..-1 frame for pixel-patterns */
- if ( ( box1->x0>=box2->x0-1 && box1->x1<=box2->x1+1 )
- && ( box1->y0>=box2->y0-1 && box1->y1<=box2->y1+1 ) )
- return 1;
- return 0;
-}
-
-/* ---- remove pictures ------------------------------------------
- * may be, not deleting or moving to another list is much better!
- * should be renamed to remove_pictures and border boxes
- */
-int remove_pictures( job_t *job){
- struct box *box4,*box2;
- int j=0, j2=0, num_del=0;
-
- if (job->cfg.verbose)
- fprintf(stderr, "# "__FILE__" L%d: remove pictures\n# ...",
- __LINE__);
-
- /* ToDo: output a list for picture handle scripts */
- j=0; j2=0;
- if(job->cfg.verbose)
- for_each_data(&(job->res.boxlist)) {
- box4 = (struct box *)list_get_current(&(job->res.boxlist));
- if (box4->c==PICTURE) j++; else j2++;
- } end_for_each(&(job->res.boxlist));
- if (job->cfg.verbose)
- fprintf(stderr," status: pictures= %d other= %d nC= %d\n# ...",
- j, j2, job->res.numC);
-
- /* remove table frames */
- if (job->res.numC > 8)
- for_each_data(&(job->res.boxlist)) {
- box2 = (struct box *)list_get_current(&(job->res.boxlist));
- if (box2->c==PICTURE
- && box2->x1-box2->x0+1>box2->p->x/2 /* big table? */
- && box2->y1-box2->y0+1>box2->p->y/2 ){ j=0;
- /* count boxes nested with the picture */
- for_each_data(&(job->res.boxlist)) {
- box4 = (struct box *)list_get_current(&(job->res.boxlist));
- if( box4 != box2 ) /* not count itself */
- if (box_nested(box4,box2)) j++; /* box4 in box2 */
- } end_for_each(&(job->res.boxlist));
- if( j>8 ){ /* remove box if more than 8 chars are within box */
- list_del(&(job->res.boxlist), box2); /* does not work proper ?! */
- free_box(box2); num_del++;
- }
- }
- } end_for_each(&(job->res.boxlist));
- if (job->cfg.verbose)
- fprintf(stderr, " deleted= %d pictures (table frames)\n# ...",
- num_del);
- num_del=0;
-
- /* remove dark-border-boxes (typical for hard copy of book site,
- * or spam random border) */
- if (job->res.numC > 1) /* dont remove the only char */
- for_each_data(&(job->res.boxlist)) {
- box2 = (struct box *)list_get_current(&(job->res.boxlist));
- if (box2->c!=PICTURE) continue; // ToDo: PICTUREs set already?
- if ( box2->x1-box2->x0+1 > box2->p->x/2
- && box2->y1-box2->y0+1 > box2->p->y/2 ) continue;
- j=0;
- if (box2->x0==0) j++;
- if (box2->y0==0) j++; /* on border? */
- if (box2->x1==box2->p->x-1) j++;
- if (box2->y1==box2->p->y-1) j++;
- if (j>2){ /* ToDo: check corner pixel */
- int cs=job->cfg.cs;
- j=0;
- if (getpixel(box2->p,box2->x0,box2->y0)<cs) j++;
- if (getpixel(box2->p,box2->x1,box2->y0)<cs) j++;
- if (getpixel(box2->p,box2->x0,box2->y1)<cs) j++;
- if (getpixel(box2->p,box2->x1,box2->y1)<cs) j++;
- if (j>2) {
- list_del(&(job->res.boxlist), box2);
- free_box(box2); num_del++;
- }
- }
- } end_for_each(&(job->res.boxlist));
- if (job->cfg.verbose)
- fprintf(stderr, " deleted= %d pictures (on border)\n# ...",
- num_del);
- num_del=0;
-
- j=0; j2=0;
- if(job->cfg.verbose)
- for_each_data(&(job->res.boxlist)) {
- box4 = (struct box *)list_get_current(&(job->res.boxlist));
- if( box4->c==PICTURE ) j++; else j2++;
- } end_for_each(&(job->res.boxlist));
- if (job->cfg.verbose)
- fprintf(stderr," status: pictures= %d other= %d nC= %d\n# ...",
- j, j2, job->res.numC);
-
- for(j=1;j;){ j=0; /* this is only because list_del does not work */
- /* can be slow on gray images */
- for_each_data(&(job->res.boxlist)) {
- box2 = (struct box *)list_get_current(&(job->res.boxlist));
- if( box2->c==PICTURE && box2->num_ac==0)
- for(j=1;j;){ /* let it grow to max before leave */
- j=0; box4=NULL;
- /* find boxes nested with the picture and remove */
- /* its for pictures build by compounds */
- for_each_data(&(job->res.boxlist)) {
- box4 = (struct box *)list_get_current(&(job->res.boxlist));
- if( box4!=box2 /* not destroy self */
- && (box4->num_ac==0) /* dont remove barcodes etc. */
- && (/* box4->c==UNKNOWN || */
- box4->c==PICTURE) ) /* dont remove valid chars */
- if(
- /* box4 in box2, +1..-1 frame for pixel-patterns */
- box_nested(box4,box2)
- /* or box2 in box4 */
- || box_nested(box2,box4) /* same? */
- )
- if ( box4->x1-box4->x0+1>2*job->res.avX
- || box4->x1-box4->x0+1<job->res.avX/2
- || box4->y1-box4->y0+1>2*job->res.avY
- || box4->y1-box4->y0+1<job->res.avY/2
- || box_covered(box4,box2) ) /* box4 completely within box2 */
- /* dont remove chars! see rotate45.fig */
- {
- /* do not remove boxes in inner loop (bug?) ToDo: check why! */
- /* instead we leave inner loop and mark box4 as valid */
- if( box4->x0<box2->x0 ) box2->x0=box4->x0;
- if( box4->x1>box2->x1 ) box2->x1=box4->x1;
- if( box4->y0<box2->y0 ) box2->y0=box4->y0;
- if( box4->y1>box2->y1 ) box2->y1=box4->y1;
- j=1; /* mark box4 as valid */
- break; /* and leave inner loop */
- }
- } end_for_each(&(job->res.boxlist));
- if (j!=0 && box4!=NULL) { /* check for valid box4 */
- /* ToDo: melt */
- list_del(&(job->res.boxlist), box4); /* does not work proper ?! */
- free_box(box4); /* break; ToDo: necessary to leave after del??? */
- num_del++;
- }
-
- }
- } end_for_each(&(job->res.boxlist));
- }
-
- if (job->cfg.verbose)
- fprintf(stderr, " deleted= %d nested pictures\n# ...", num_del);
-
- /* output a list for picture handle scripts */
- j=0; j2=0;
- if(job->cfg.verbose)
- for_each_data(&(job->res.boxlist)) {
- box4 = (struct box *)list_get_current(&(job->res.boxlist));
- if( box4->c==PICTURE ) {
- fprintf(stderr," found picture at %4d %4d size %4d %4d\n# ...",
- box4->x0, box4->y0, box4->x1-box4->x0+1, box4->y1-box4->y0+1 );
- j++;
- } else j2++;
- } end_for_each(&(job->res.boxlist));
- if (job->cfg.verbose)
- fprintf(stderr," status: pictures= %d other= %d nC= %d\n",
- j, j2, job->res.numC);
- return 0;
-}
-
-
-
- /* ---- remove melted serifs --------------------------------- v0.2.5
- >>v<<
- ##########.######## <-y0
- ################### like X VW etc.
- ...###.......###... <-y
- ...###......###....
- j1 j2 j3
- - can generate new boxes if two characters were glued
- */
-int remove_melted_serifs( pix *pp ){
- int x,y,j1,j2,j3,j4,i2,i3,i,ii,ni,cs,x0,x1,xa,xb,y0,y1,vvv=JOB->cfg.verbose;
- struct box *box2, *box3;
- progress_counter_t *pc = NULL;
-
- cs=JOB->cfg.cs; i=0; ii=0; ni=0;
- for_each_data(&(JOB->res.boxlist)) {
- ni++;
- } end_for_each(&(JOB->res.boxlist));
- pc = open_progress(ni,"remove_melted_serifs");
- ni = 0;
-
- if(vvv){ fprintf(stderr,"# searching melted serifs ..."); }
- for_each_data(&(JOB->res.boxlist)) {
- box2 = (struct box *)list_get_current(&(JOB->res.boxlist));
- if (box2->c != UNKNOWN) continue; /* dont try on pictures */
- x0=box2->x0; x1=box2->x1;
- y0=box2->y0; y1=box2->y1; /* box */
- /* upper serifs */
- for(j1=x0;j1+4<x1;){
- j1+=loop(pp,j1,y0 ,x1-x0,cs,0,RI);
- x =loop(pp,j1,y0 ,x1-x0,cs,1,RI); if(j1+x>x1+1) break;
- y =loop(pp,j1,y0+1,x1-x0,cs,1,RI); if(y>x) x=y; if(j1+x>x1+1) break;
- /* measure mean thickness of serif */
- for(j2=j3=j4=0,i2=j1;i2<j1+x;i2++){
- i3 =loop(pp,j1,y0 ,y1-y0,cs,0,DO); if(8*i3>y1-y0) break;
- i3+=loop(pp,j1,y0+i3,y1-y0,cs,1,DO); if(8*i3>y1-y0) break;
- if(8*i3<y1-y0){ j2+=i3; j3++; }
- } if(j3==0){ j1+=x; continue; }
- y = y0+(j2+j3-1)/j3+(y1-y0+1)/32;
-
- /* check if really melted serifs */
- if( loop(pp,j1,y,x1-x0,cs,0,RI)<1 ) { j1+=x; continue; }
- if(num_cross(j1 ,j1+x,y,y,pp,cs) < 2 ){ j1+=x;continue; }
- j2 = j1 + loop(pp,j1,y,x1-x0,cs,0,RI);
- j2 = j2 + loop(pp,j2,y,x1-x0,cs,1,RI);
- i3 = loop(pp,j2,y,x1-x0,cs,0,RI); if(i3<2){j1+=x;continue;}
- j2 += i3/2;
- j3 = j2 + loop(pp,j2,y ,x1-j2,cs,0,RI);
- i3 = j2 + loop(pp,j2,y+1,x1-j2,cs,0,RI); if(i3>j3)j3=i3;
- j3 = j3 + loop(pp,j3,y ,x1-j3,cs,1,RI);
- i3 = loop(pp,j3,y ,x1-j3,cs,0,RI);
- if(i3<2 || j3>=j1+x){j1+=x;continue;}
- j3 += i3/2;
-
- if(x>5)
- {
- i++; /* snip! */
- for(y=0;y<(y1-y0+1+4)/8;y++)put(pp,j2,y0+y,255,128+64); /* clear highest bit */
- if(vvv&4){
- fprintf(stderr,"\n");
- //out_x(box2);
- fprintf(stderr,"# melted serifs corrected on %d %d j1=%d j3=%d",
- j2-x0, y, j1-x0, j3-x0);
- }
- for(xb=0,xa=0;xa<(x1-x0+4)/8;xa++){ /* detect vertical gap */
- i3=y1;
- if(box2->m3>y0 && 2*y1>box2->m3+box2->m4) i3=box2->m3; /* some IJ */
- if( loop(pp,j2-xa,i3,i3-y0,cs,0,UP) > (y1-y0+1)/2
- && loop(pp,j2,(y0+y1)/2,xa+1,cs,0,LE) >=xa ){ xb=-xa; break; }
- if( loop(pp,j2+xa,i3,i3-y0,cs,0,UP) > (y1-y0+1)/2
- && loop(pp,j2,(y0+y1)/2,xa+1,cs,0,RI) >=xa ){ xb= xa; break; }
- }
- if( get_bw(j2 ,j2 ,y0,(y0+y1)/2,pp,cs,1) == 0
- && get_bw(j2+xb,j2+xb,(y0+y1)/2,i3,pp,cs,1) == 0 )
- { /* divide */
- box3=malloc_box(box2);
- box3->x1=j2-1;
- box2->x0=j2+1; x1=box2->x1;
- cut_box(box2); /* cut vectors outside the box */
- cut_box(box3);
- box3->num=JOB->res.numC;
- list_ins(&(JOB->res.boxlist),box2,box3); JOB->res.numC++; ii++; /* insert box3 before box2 */
- if(vvv&4) fprintf(stderr," => splitted");
- j1=x0=box2->x0; x=0; /* hopefully ok, UVW */
- }
- }
- j1+=x;
- }
- /* same on lower serifs -- change this later to better function
- // #### ###
- // #### v ### # <-y
- // #################### <-y1
- // j1 j2 j3
- */
- for(j1=x0;j1<x1;){
- j1+=loop(pp,j1,y1 ,x1-x0,cs,0,RI);
- x =loop(pp,j1,y1 ,x1-x0,cs,1,RI); if(j1+x>x1+1) break;
- y =loop(pp,j1,y1-1,x1-x0,cs,1,RI); if(y>x) x=y; if(j1+x>x1+1) break;
- /* measure mean thickness of serif */
- for(j2=j3=j4=0,i2=j1;i2<j1+x;i2++){
- i3 =loop(pp,j1,y1 ,y1-y0,cs,0,UP); if(8*i3>y1-y0) break;
- i3+=loop(pp,j1,y1-i3,y1-y0,cs,1,UP); if(8*i3>y1-y0) break;
- if(8*i3<y1-y0){ j2+=i3; j3++; }
- } if(j3==0){ j1+=x; continue; }
- y = y1-(j2+j3-1)/j3-(y1-y0+1)/32;
-
- /* check if really melted serifs */
- if( loop(pp,j1,y,x1-x0,cs,0,RI)<1 ) { j1+=x; continue; }
- if(num_cross(j1 ,j1+x,y,y,pp,cs) < 2 ){ j1+=x;continue; }
- j2 = j1 + loop(pp,j1,y,x1-x0,cs,0,RI);
- j2 = j2 + loop(pp,j2,y,x1-x0,cs,1,RI);
- i3 = loop(pp,j2,y,x1-x0,cs,0,RI); if(i3<2){j1+=x;continue;}
- j2 += i3/2;
- j3 = j2 + loop(pp,j2,y ,x1-j2,cs,0,RI);
- i3 = j2 + loop(pp,j2,y-1,x1-j2,cs,0,RI); if(i3>j3)j3=i3;
- j3 = j3 + loop(pp,j3,y ,x1-j3,cs,1,RI);
- i3 = loop(pp,j3,y,x1-j3,cs,0,RI);
- if(i3<2 || j3>=j1+x){j1+=x;continue;}
- j3 += i3/2;
-
- /* y =y1-(y1-y0+1+4)/8; */
- if(x>5)
- {
- i++; /* snip! */
- for(i3=0;i3<(y1-y0+1+4)/8;i3++)
- put(pp,j2,y1-i3,255,128+64); /* clear highest bit */
- if(vvv&4){
- fprintf(stderr,"\n");
- //out_x(box2);
- fprintf(stderr,"# melted serifs corrected on %d %d j1=%d j3=%d",j2-x0,y-y0,j1-x0,j3-x0);
- }
- for(xb=0,xa=0;xa<(x1-x0+4)/8;xa++){ /* detect vertical gap */
- if( loop(pp,j2-xa,y0,y1-y0,cs,0,DO) > (y1-y0+1)/2
- && loop(pp,j2,(y0+y1)/2,xa+1,cs,0,LE) >=xa ){ xb=-xa; break; }
- if( loop(pp,j2+xa,y0,y1-y0,cs,0,DO) > (y1-y0+1)/2
- && loop(pp,j2,(y0+y1)/2,xa+1,cs,0,RI) >=xa ){ xb= xa; break; }
- }
- if( get_bw(j2 ,j2 ,(y0+y1)/2,y1,pp,cs,1) == 0
- && get_bw(j2+xb,j2+xb,y0,(y0+y1)/2,pp,cs,1) == 0 )
- { /* divide */
- box3=malloc_box(box2);
- box3->x1=j2-1;
- box2->x0=j2; x1=box2->x1;
- cut_box(box2); /* cut vectors outside the box */
- cut_box(box3);
- box3->num=JOB->res.numC;
- list_ins(&(JOB->res.boxlist),box2,box3); JOB->res.numC++; ii++;
- /* box3,box2 in correct order??? */
- if(vvv&4) fprintf(stderr," => splitted");
- j1=x0=box2->x0; x=0; /* hopefully ok, NMK */
- }
- }
- j1+=x;
- }
- progress(ni++,pc);
- } end_for_each(&(JOB->res.boxlist));
- close_progress(pc);
- if(vvv)fprintf(stderr," %3d cluster corrected, %d new boxes\n",i,ii);
- return 0;
-}
-
-/* remove black borders often seen on bad scanned copies of books
- - dust around the border
- */
-int remove_rest_of_dust() {
- int i1, i2, vvv = JOB->cfg.verbose, x0, x1, y0, y1, cnt=0;
- struct box *box2, *box4;
- progress_counter_t *pc = NULL;
-
- i1 = i2 = 0; /* counter for removed boxes */
- if (vvv)
- fprintf(stderr, "# detect dust (avX,nC), ... ");
- /* remove fragments from border */
- for_each_data(&(JOB->res.boxlist)) {
- box2 = (struct box *)list_get_current(&(JOB->res.boxlist));
- if (box2->c == UNKNOWN) {
- x0 = box2->x0; x1 = box2->x1;
- y0 = box2->y0; y1 = box2->y1; /* box */
- /* box in char ??? */
- if ( 2 * JOB->res.numC * (y1 - y0 + 1) < 3 * JOB->res.sumY
- && ( y1 < box2->p->y/4 || y0 > 3*box2->p->y/4 ) /* not single line */
- && JOB->res.numC > 1 /* do not remove everything */
- && ( box2->m4 == 0 ) ) /* remove this */
- {
- JOB->res.numC--; /* ToDo: dont count tiny pixels */
- /* ToDo: res.sumX,Y must also be corrected */
- i1++;
- list_del(&(JOB->res.boxlist), box2);
- free_box(box2);
- }
- }
- } end_for_each(&(JOB->res.boxlist));
-
- pc = open_progress(JOB->res.boxlist.n,"remove_dust2");
- for_each_data(&(JOB->res.boxlist)) {
- box2 = (struct box *)list_get_current(&(JOB->res.boxlist));
- progress(cnt++,pc);
- if (box2->c == PICTURE) continue;
- x0 = box2->x0; x1 = box2->x1;
- y0 = box2->y0; y1 = box2->y1; /* box */
- /* remove tiny box2 if to far away from bigger boxes */
- /* ToDo: remove clouds of tiny pixels (count near small, compare with num bigger) */
- /* 0.42: remove far away pixel? ToDo: do it at earlier? */
- if (x1-x0+1<3 && y1-y0+1<3){
- int xn, yn, xs, ys;
- int found=0; /* nearest bigger box */
- /* search near bigger box */
- for_each_data(&(JOB->res.boxlist)) {
- box4 = (struct box *)list_get_current(&(JOB->res.boxlist));
- if (found || box4 == box2) continue;
- if (box4->x1-box4->x0+1<3 && box4->y1-box4->y0+1<3) continue;
- xs = box4->x1-box4->x0+1;
- ys = box4->y1-box4->y0+1;
- xn = abs((box4->x0+box4->x1)/2 - box2->x0);
- yn = abs((box4->y0+box4->y1)/2 - box2->y0);
- if (2*xn < 3*xs && 2*yn < 3*ys) { found=1; }
- } end_for_each(&(JOB->res.boxlist));
- if (!found) { /* found nothing, box2 to far from big boxes */
- i2++;
- list_del(&(JOB->res.boxlist), box2);
- free_box(box2);
- }
- }
- } end_for_each(&(JOB->res.boxlist));
- close_progress(pc);
- if (vvv)
- fprintf(stderr, " %3d + %3d boxes deleted, nC= %d ?\n",
- i1, i2, JOB->res.numC);
-
- return 0;
-}
+++ /dev/null
-/*
-This is a Optical-Character-Recognition program
-Copyright (C) 2000-2007 Joerg Schulenburg
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- see README for EMAIL-address
- */
-
-#include "unicode.h"
-#include <stdio.h>
-
-/* FIXME jb global */
-int warn=0; /* if 1 a message is generated if composition is not defined */
-
-/* Arguments: the character (main), and the modifier (accent, etc). See the
- function if you want to know the modifiers.
- Description: This function intends to be a small helper, to avoid having
- to write switches in functions. It's therefore mainly to accents, and
- specially for the most usual ones. It supports the basic greek
- characters too, which is actually not very helpful.
- Returns: the unicode character corresponding to the composed character.
-
- ToDo:
- - It seems to me, that tables should be more effectiv.
- So we should use tables in future? (js)
- */
-wchar_t compose(wchar_t main, wchar_t modifier) {
-/* supported by now: part of ISO8859-1, basic greek characters */
- if( main == UNKNOWN || main == PICTURE ) return main;
-#ifdef DEBUG
- if(modifier!=UNICODE_NULL && modifier!=SPACE)
- printf(" compose(%c,%d)",(char)main,(int)modifier);
-#endif
- if(main>127 && modifier!=0 && modifier!=SPACE && warn)
- fprintf(stderr,"# Warning compose %04x + %04x>127\n",
- (int)modifier,(int)main);
- switch (modifier) {
- case UNICODE_NULL:
- case SPACE:
- return (wchar_t)main;
-
- case APOSTROPHE: /* do NOT USE this. It's here for compatibility only.
- Use ACUTE_ACCENT instead. */
- fprintf( stderr, "COMPOSE: got APOSTROPHE instead of ACUTE_ACCENT");
-
- case ACUTE_ACCENT: /* acute/cedilla */
- switch (main) {
- case 'a': return LATIN_SMALL_LETTER_A_WITH_ACUTE;
- case 'A': return LATIN_CAPITAL_LETTER_A_WITH_ACUTE;
- case LATIN_SMALL_LETTER_AE: return LATIN_SMALL_LETTER_AE_WITH_ACUTE;
- case LATIN_CAPITAL_LETTER_AE: return LATIN_CAPITAL_LETTER_AE_WITH_ACUTE;
- case 'c': return LATIN_SMALL_LETTER_C_WITH_ACUTE;
- case 'C': return LATIN_CAPITAL_LETTER_C_WITH_ACUTE;
- case 'e': return LATIN_SMALL_LETTER_E_WITH_ACUTE;
- case 'E': return LATIN_CAPITAL_LETTER_E_WITH_ACUTE;
- case 'g': return LATIN_SMALL_LETTER_G_WITH_ACUTE;
- case 'G': return LATIN_CAPITAL_LETTER_G_WITH_ACUTE;
- case 'i': return LATIN_SMALL_LETTER_I_WITH_ACUTE;
- case 'I': return LATIN_CAPITAL_LETTER_I_WITH_ACUTE;
- case 'l': return LATIN_SMALL_LETTER_L_WITH_ACUTE;
- case 'L': return LATIN_CAPITAL_LETTER_L_WITH_ACUTE;
- case 'n': return LATIN_SMALL_LETTER_N_WITH_ACUTE;
- case 'N': return LATIN_CAPITAL_LETTER_N_WITH_ACUTE;
- case 'o': return LATIN_SMALL_LETTER_O_WITH_ACUTE;
- case 'O': return LATIN_CAPITAL_LETTER_O_WITH_ACUTE;
- case '0': return LATIN_CAPITAL_LETTER_O_WITH_ACUTE;
- case 'r': return LATIN_SMALL_LETTER_R_WITH_ACUTE;
- case 'R': return LATIN_CAPITAL_LETTER_R_WITH_ACUTE;
- case 's': return LATIN_SMALL_LETTER_S_WITH_ACUTE;
- case 'S': return LATIN_CAPITAL_LETTER_S_WITH_ACUTE;
- case 'u': return LATIN_SMALL_LETTER_U_WITH_ACUTE;
- case 'U': return LATIN_CAPITAL_LETTER_U_WITH_ACUTE;
- case 'y': return LATIN_SMALL_LETTER_Y_WITH_ACUTE;
- case 'Y': return LATIN_CAPITAL_LETTER_Y_WITH_ACUTE;
- case 'z': return LATIN_SMALL_LETTER_Z_WITH_ACUTE;
- case 'Z': return LATIN_CAPITAL_LETTER_Z_WITH_ACUTE;
- default:
- if(warn)fprintf( stderr, " COMPOSE: ACUTE_ACCENT+%04x not defined\n",(int)main);
- }
- break;
-
- case BREVE: /* caron (latin2) "u"-above-... (small bow) */
- switch (main) {
- /* FIXME write separate heuristics for breve */
- case 'a': return LATIN_SMALL_LETTER_A_WITH_BREVE;
- case 'A': return LATIN_CAPITAL_LETTER_A_WITH_BREVE;
- case 'e': return LATIN_SMALL_LETTER_E_WITH_BREVE;
- case 'E': return LATIN_CAPITAL_LETTER_E_WITH_BREVE;
- case 'g': return LATIN_SMALL_LETTER_G_WITH_BREVE;
- case 'G': return LATIN_CAPITAL_LETTER_G_WITH_BREVE;
- case 'i': return LATIN_SMALL_LETTER_I_WITH_BREVE;
- case 'I': return LATIN_CAPITAL_LETTER_I_WITH_BREVE;
- case 'o': return LATIN_SMALL_LETTER_O_WITH_BREVE;
- case 'O': return LATIN_CAPITAL_LETTER_O_WITH_BREVE;
- case 'u': return LATIN_SMALL_LETTER_U_WITH_BREVE;
- case 'U': return LATIN_CAPITAL_LETTER_U_WITH_BREVE;
- default:
- if(warn)fprintf( stderr, " COMPOSE: BREVE+%04x not defined\n",(int)main);
- }
- break;
-
- case CARON: /* caron (latin2) "v"-above-... */
- switch (main) {
- case 'a': return LATIN_SMALL_LETTER_A_WITH_CARON;
- case 'A': return LATIN_CAPITAL_LETTER_A_WITH_CARON;
- case 'c': return LATIN_SMALL_LETTER_C_WITH_CARON;
- case 'C': return LATIN_CAPITAL_LETTER_C_WITH_CARON;
- case 'e': return LATIN_SMALL_LETTER_E_WITH_CARON;
- case 'E': return LATIN_CAPITAL_LETTER_E_WITH_CARON;
- case 'i': return LATIN_SMALL_LETTER_I_WITH_CARON;
- case 'I': return LATIN_CAPITAL_LETTER_I_WITH_CARON;
- case 'o': return LATIN_SMALL_LETTER_O_WITH_CARON;
- case 'O': return LATIN_CAPITAL_LETTER_O_WITH_CARON;
- case '0': return LATIN_CAPITAL_LETTER_O_WITH_CARON;
- case 's': return LATIN_SMALL_LETTER_S_WITH_CARON;
- case 'S': return LATIN_CAPITAL_LETTER_S_WITH_CARON;
- case 'u': return LATIN_SMALL_LETTER_U_WITH_CARON;
- case 'U': return LATIN_CAPITAL_LETTER_U_WITH_CARON;
- case 'z': return LATIN_SMALL_LETTER_Z_WITH_CARON;
- case 'Z': return LATIN_CAPITAL_LETTER_Z_WITH_CARON;
- default:
- if(warn)fprintf( stderr, " COMPOSE: CARON+%04x not defined\n",(int)main);
- }
- break;
-
- case CEDILLA:
- switch (main) {
- case 'c': return LATIN_SMALL_LETTER_C_WITH_CEDILLA;
- case 'C': return LATIN_CAPITAL_LETTER_C_WITH_CEDILLA;
- default:
- if(warn)fprintf( stderr, " COMPOSE: CEDILLA+%04x not defined\n",(int)main);
- }
- break;
-
- case TILDE:
- switch (main) {
- case 'a': return LATIN_SMALL_LETTER_A_WITH_TILDE;
- case 'A': return LATIN_CAPITAL_LETTER_A_WITH_TILDE;
- case 'i': return LATIN_SMALL_LETTER_I_WITH_TILDE;
- case 'I': return LATIN_CAPITAL_LETTER_I_WITH_TILDE;
- case 'n': return LATIN_SMALL_LETTER_N_WITH_TILDE;
- case 'N': return LATIN_CAPITAL_LETTER_N_WITH_TILDE;
- case 'o': return LATIN_SMALL_LETTER_O_WITH_TILDE;
- case 'O': return LATIN_CAPITAL_LETTER_O_WITH_TILDE;
- case '0': return LATIN_CAPITAL_LETTER_O_WITH_TILDE;
- case 'u': return LATIN_SMALL_LETTER_U_WITH_TILDE;
- case 'U': return LATIN_CAPITAL_LETTER_U_WITH_TILDE;
- default:
- if(warn)fprintf( stderr, " COMPOSE: TILDE+%04x not defined\n",(int)main);
- }
- break;
-
- case GRAVE_ACCENT:
- switch (main) {
- case 'a': return LATIN_SMALL_LETTER_A_WITH_GRAVE;
- case 'A': return LATIN_CAPITAL_LETTER_A_WITH_GRAVE;
- case 'e': return LATIN_SMALL_LETTER_E_WITH_GRAVE;
- case 'E': return LATIN_CAPITAL_LETTER_E_WITH_GRAVE;
- case 'i': return LATIN_SMALL_LETTER_I_WITH_GRAVE;
- case 'I': return LATIN_CAPITAL_LETTER_I_WITH_GRAVE;
- case 'n': return LATIN_SMALL_LETTER_N_WITH_GRAVE;
- case 'N': return LATIN_CAPITAL_LETTER_N_WITH_GRAVE;
- case 'o': return LATIN_SMALL_LETTER_O_WITH_GRAVE;
- case 'O': return LATIN_CAPITAL_LETTER_O_WITH_GRAVE;
- case '0': return LATIN_CAPITAL_LETTER_O_WITH_GRAVE;
- case 'u': return LATIN_SMALL_LETTER_U_WITH_GRAVE;
- case 'U': return LATIN_CAPITAL_LETTER_U_WITH_GRAVE;
- default:
- if(warn)fprintf( stderr, " COMPOSE: GRAVE_ACCENT+%04x not defined\n",(int)main);
- }
- break;
-
- case QUOTATION_MARK: /* do NOT USE this. It's here for compatibility only.
- Use DIAERESIS instead. */
- fprintf( stderr, "COMPOSE: got APOSTROPHE instead of ACUTE_ACCENT");
-
- case DIAERESIS:
- switch (main) {
- case 'a': return LATIN_SMALL_LETTER_A_WITH_DIAERESIS;
- case 'A': return LATIN_CAPITAL_LETTER_A_WITH_DIAERESIS;
- case 'e': return LATIN_SMALL_LETTER_E_WITH_DIAERESIS;
- case 'E': return LATIN_CAPITAL_LETTER_E_WITH_DIAERESIS;
- case 'i': return LATIN_SMALL_LETTER_I_WITH_DIAERESIS;
- case 'I': return LATIN_CAPITAL_LETTER_I_WITH_DIAERESIS;
- case 'o': return LATIN_SMALL_LETTER_O_WITH_DIAERESIS;
- case 'O': return LATIN_CAPITAL_LETTER_O_WITH_DIAERESIS;
- case '0': return LATIN_CAPITAL_LETTER_O_WITH_DIAERESIS;
- case 'u': return LATIN_SMALL_LETTER_U_WITH_DIAERESIS;
- case 'U': return LATIN_CAPITAL_LETTER_U_WITH_DIAERESIS;
- case 'y': return LATIN_SMALL_LETTER_Y_WITH_DIAERESIS;
- case 'Y': return LATIN_CAPITAL_LETTER_Y_WITH_DIAERESIS;
- default:
- if(warn)fprintf( stderr, " COMPOSE: DIAERESIS+%04x (%c) not defined\n",(int)main,(char)main);
- }
- break;
-
- case CIRCUMFLEX_ACCENT: /* ^ */
- switch (main) {
- case 'a': return LATIN_SMALL_LETTER_A_WITH_CIRCUMFLEX;
- case 'A': return LATIN_CAPITAL_LETTER_A_WITH_CIRCUMFLEX;
- case 'c': return LATIN_SMALL_LETTER_C_WITH_CIRCUMFLEX;
- case 'C': return LATIN_CAPITAL_LETTER_C_WITH_CIRCUMFLEX;
- case 'e': return LATIN_SMALL_LETTER_E_WITH_CIRCUMFLEX;
- case 'E': return LATIN_CAPITAL_LETTER_E_WITH_CIRCUMFLEX;
- case 'g': return LATIN_SMALL_LETTER_G_WITH_CIRCUMFLEX;
- case 'G': return LATIN_CAPITAL_LETTER_G_WITH_CIRCUMFLEX;
- case 'h': return LATIN_SMALL_LETTER_H_WITH_CIRCUMFLEX;
- case 'H': return LATIN_CAPITAL_LETTER_H_WITH_CIRCUMFLEX;
- case 'i': return LATIN_SMALL_LETTER_I_WITH_CIRCUMFLEX;
- case 'I': return LATIN_CAPITAL_LETTER_I_WITH_CIRCUMFLEX;
- case 'j': return LATIN_SMALL_LETTER_J_WITH_CIRCUMFLEX;
- case 'J': return LATIN_CAPITAL_LETTER_J_WITH_CIRCUMFLEX;
- case 'o': return LATIN_SMALL_LETTER_O_WITH_CIRCUMFLEX;
- case 'O': return LATIN_CAPITAL_LETTER_O_WITH_CIRCUMFLEX;
- case '0': return LATIN_CAPITAL_LETTER_O_WITH_CIRCUMFLEX;
- case 's': return LATIN_SMALL_LETTER_S_WITH_CIRCUMFLEX;
- case 'S': return LATIN_CAPITAL_LETTER_S_WITH_CIRCUMFLEX;
- case 'u': return LATIN_SMALL_LETTER_U_WITH_CIRCUMFLEX;
- case 'U': return LATIN_CAPITAL_LETTER_U_WITH_CIRCUMFLEX;
- case 'w': return LATIN_SMALL_LETTER_W_WITH_CIRCUMFLEX;
- case 'W': return LATIN_CAPITAL_LETTER_W_WITH_CIRCUMFLEX;
- case 'y': return LATIN_SMALL_LETTER_Y_WITH_CIRCUMFLEX;
- case 'Y': return LATIN_CAPITAL_LETTER_Y_WITH_CIRCUMFLEX;
- default:
- if(warn)fprintf( stderr, " COMPOSE: CIRCUMFLEX_ACCENT+%04x not defined\n",(int)main);
- }
- break;
-
- case MACRON: /* a minus sign above the char (latin2) */
- switch (main) {
- case 'a': return LATIN_SMALL_LETTER_A_WITH_MACRON;
- case 'A': return LATIN_CAPITAL_LETTER_A_WITH_MACRON;
- case 'e': return LATIN_SMALL_LETTER_E_WITH_MACRON;
- case 'E': return LATIN_CAPITAL_LETTER_E_WITH_MACRON;
- case 'i': return LATIN_SMALL_LETTER_I_WITH_MACRON;
- case 'I': return LATIN_CAPITAL_LETTER_I_WITH_MACRON;
- case 'o': return LATIN_SMALL_LETTER_O_WITH_MACRON;
- case 'O': return LATIN_CAPITAL_LETTER_O_WITH_MACRON;
- case 'u': return LATIN_SMALL_LETTER_U_WITH_MACRON;
- case 'U': return LATIN_CAPITAL_LETTER_U_WITH_MACRON;
- case 'y': return LATIN_SMALL_LETTER_Y_WITH_MACRON;
- case 'Y': return LATIN_CAPITAL_LETTER_Y_WITH_MACRON;
- case LATIN_SMALL_LETTER_AE: return LATIN_SMALL_LETTER_AE_WITH_MACRON;
- case LATIN_CAPITAL_LETTER_AE: return LATIN_CAPITAL_LETTER_AE_WITH_MACRON;
- case '=': return IDENTICAL_TO;
- case '-': return '=';
- case ' ': return MODIFIER_LETTER_MACRON;
- default:
- if(warn)fprintf( stderr, " COMPOSE: MACRON+%04x not defined\n",(int)main);
- }
- break;
-
- case DOT_ABOVE: /* latin2 */
- switch (main) {
- case 'a': return LATIN_SMALL_LETTER_A_WITH_DOT_ABOVE;
- case 'A': return LATIN_CAPITAL_LETTER_A_WITH_DOT_ABOVE;
- case 'c': return LATIN_SMALL_LETTER_C_WITH_DOT_ABOVE;
- case 'C': return LATIN_CAPITAL_LETTER_C_WITH_DOT_ABOVE;
- case 'e': return LATIN_SMALL_LETTER_E_WITH_DOT_ABOVE;
- case 'E': return LATIN_CAPITAL_LETTER_E_WITH_DOT_ABOVE;
- case 'g': return LATIN_SMALL_LETTER_G_WITH_DOT_ABOVE;
- case 'G': return LATIN_CAPITAL_LETTER_G_WITH_DOT_ABOVE;
- case 'l': return 'i'; /* correct wrong recognition */
- case 'i': return 'i';
- case LATIN_SMALL_LETTER_DOTLESS_I: return 'i';
- case 'I': return LATIN_CAPITAL_LETTER_I_WITH_DOT_ABOVE;
- case 'j': return 'j';
- case 'o': return LATIN_SMALL_LETTER_O_WITH_DOT_ABOVE;
- case 'O': return LATIN_CAPITAL_LETTER_O_WITH_DOT_ABOVE;
- case 'z': return LATIN_SMALL_LETTER_Z_WITH_DOT_ABOVE;
- case 'Z': return LATIN_CAPITAL_LETTER_Z_WITH_DOT_ABOVE;
- case ',': return ';';
- case '.': return ':';
- default:
- if(warn)fprintf( stderr, " COMPOSE: DOT_ABOVE+%04x not defined\n",(int)main);
- }
- break;
-
- case RING_ABOVE:
- switch (main) {
- case 'a': return LATIN_SMALL_LETTER_A_WITH_RING_ABOVE;
- case 'A': return LATIN_CAPITAL_LETTER_A_WITH_RING_ABOVE;
- case 'u': return LATIN_SMALL_LETTER_U_WITH_RING_ABOVE;
- case 'U': return LATIN_CAPITAL_LETTER_U_WITH_RING_ABOVE;
- default:
- if(warn)fprintf( stderr, " COMPOSE: RING_ABOVE+%04x not defined\n",(int)main);
- }
- break;
-
- case 'e': /* e ligatures: ae, oe. */
- case 'E':
- switch (main) {
- case 'a': return LATIN_SMALL_LETTER_AE;
- case 'A': return LATIN_CAPITAL_LETTER_AE;
- case 'o': return LATIN_SMALL_LIGATURE_OE;
- case 'O': return LATIN_CAPITAL_LIGATURE_OE;
- case '0': return LATIN_CAPITAL_LIGATURE_OE;
- default:
- if(warn)fprintf( stderr, " COMPOSE: %04x+e/E not defined\n",(int)main);
- }
- break;
-
- case 'g': /* greek */
- switch (main) {
- /* missing 0x37A-0x390 */
- /* weird cases: Q -> theta (it resembles a little, doesn't it?)
- V -> psi (what can I do?) */
- case 'A': return GREEK_CAPITAL_LETTER_ALPHA;
- case 'B': return GREEK_CAPITAL_LETTER_BETA;
- case 'G': return GREEK_CAPITAL_LETTER_GAMMA;
- case 'D': return GREEK_CAPITAL_LETTER_DELTA;
- case 'E': return GREEK_CAPITAL_LETTER_EPSILON;
- case 'Z': return GREEK_CAPITAL_LETTER_ZETA;
- case 'H': return GREEK_CAPITAL_LETTER_ETA;
- case 'Q': return GREEK_CAPITAL_LETTER_THETA;
- case 'I': return GREEK_CAPITAL_LETTER_IOTA;
- case 'K': return GREEK_CAPITAL_LETTER_KAPPA;
- case 'L': return GREEK_CAPITAL_LETTER_LAMDA;
- case 'M': return GREEK_CAPITAL_LETTER_MU;
- case 'N': return GREEK_CAPITAL_LETTER_NU;
- case 'X': return GREEK_CAPITAL_LETTER_XI;
- case 'O': return GREEK_CAPITAL_LETTER_OMICRON;
- case 'P': return GREEK_CAPITAL_LETTER_PI;
- case 'R': return GREEK_CAPITAL_LETTER_RHO;
- case 'S': return GREEK_CAPITAL_LETTER_SIGMA;
- case 'T': return GREEK_CAPITAL_LETTER_TAU;
- case 'Y': return GREEK_CAPITAL_LETTER_UPSILON;
- case 'F': return GREEK_CAPITAL_LETTER_PHI;
- case 'C': return GREEK_CAPITAL_LETTER_CHI;
- case 'V': return GREEK_CAPITAL_LETTER_PSI;
- case 'W': return GREEK_CAPITAL_LETTER_OMEGA;
-/*
- case '': return GREEK_CAPITAL_LETTER_IOTA_WITH_DIALYTIKA;
- case '': return GREEK_CAPITAL_LETTER_UPSILON_WITH_DIALYTIKA;
- case '': return GREEK_SMALL_LETTER_ALPHA_WITH_TONOS;
- case '': return GREEK_SMALL_LETTER_EPSILON_WITH_TONOS;
- case '': return GREEK_SMALL_LETTER_ETA_WITH_TONOS;
- case '': return GREEK_SMALL_LETTER_IOTA_WITH_TONOS;
- case '': return GREEK_SMALL_LETTER_UPSILON_WITH_DIALYTIKA_AND_TONOS;
-*/
- case 'a': return GREEK_SMALL_LETTER_ALPHA;
- case 'b': return GREEK_SMALL_LETTER_BETA;
- case 'g': return GREEK_SMALL_LETTER_GAMMA;
- case 'd': return GREEK_SMALL_LETTER_DELTA;
- case 'e': return GREEK_SMALL_LETTER_EPSILON;
- case 'z': return GREEK_SMALL_LETTER_ZETA;
- case 'h': return GREEK_SMALL_LETTER_ETA;
- case 'q': return GREEK_SMALL_LETTER_THETA;
- case 'i': return GREEK_SMALL_LETTER_IOTA;
- case 'k': return GREEK_SMALL_LETTER_KAPPA;
- case 'l': return GREEK_SMALL_LETTER_LAMDA;
- case 'm': return GREEK_SMALL_LETTER_MU;
- case 'n': return GREEK_SMALL_LETTER_NU;
- case 'x': return GREEK_SMALL_LETTER_XI;
- case 'o': return GREEK_SMALL_LETTER_OMICRON;
- case 'p': return GREEK_SMALL_LETTER_PI;
- case 'r': return GREEK_SMALL_LETTER_RHO;
- case '&': return GREEK_SMALL_LETTER_FINAL_SIGMA;
- case 's': return GREEK_SMALL_LETTER_SIGMA;
- case 't': return GREEK_SMALL_LETTER_TAU;
- case 'y': return GREEK_SMALL_LETTER_UPSILON;
- case 'f': return GREEK_SMALL_LETTER_PHI;
- case 'c': return GREEK_SMALL_LETTER_CHI;
- case 'v': return GREEK_SMALL_LETTER_PSI;
- case 'w': return GREEK_SMALL_LETTER_OMEGA;
-/*
- case '': return GREEK_SMALL_LETTER_IOTA_WITH_DIALYTIKA;
- case '': return GREEK_SMALL_LETTER_UPSILON_WITH_DIALYTIKA;
- case '': return GREEK_SMALL_LETTER_OMICRON_WITH_TONOS;
- case '': return GREEK_SMALL_LETTER_UPSILON_WITH_TONOS;
- case '': return GREEK_SMALL_LETTER_OMEGA_WITH_TONOS;
- case '': return GREEK_BETA_SYMBOL;
- case '': return GREEK_THETA_SYMBOL;
- case '': return GREEK_UPSILON_WITH_HOOK_SYMBOL;
- case '': return GREEK_UPSILON_WITH_ACUTE_AND_HOOK_SYMBOL;
- case '': return GREEK_UPSILON_WITH_DIAERESIS_AND_HOOK_SYMBOL;
- case '': return GREEK_PHI_SYMBOL;
- case '': return GREEK_PI_SYMBOL;
-*/
- default:
- if(warn)fprintf( stderr, " COMPOSE: GREEK %04x not defined\n",(int)main);
- }
- break;
-
- default:
- fprintf( stderr, " COMPOSE: modifier %04x not defined\n",(int)modifier);
- }
- return (wchar_t)main;
-}
-
-#define UNDEFINED "~"
-
-/* Arguments: character in Unicode format, type of format to convert to.
- Returns: a string containing the Unicode character converted to the chosen
- format. This string is statically allocated and should not be freed.
- ToDo: better using tables?
- */
-const char *decode(wchar_t c, FORMAT type) {
- /* static char d; --- js: big bug (missing \0) if &d returned */
- /*FIXME jb static*/ static char bbuf[8*32]; /* space for 8 buffers, rotating */
- /*FIXME jb static*/ static char *buf=bbuf; /* used for UTF8 sequences and undefined codes */
- buf+=32; if(buf>=bbuf+8*32) buf=bbuf;
- buf[0]=buf[1]=buf[2]=0;
- switch (type) {
- case ISO8859_1:
- if ( c <= 0xFF ) { /* UNICODE == ISO8859-1 */
- buf[0] = (char)c;
- return buf;
- }
- switch (c) { /* not found in list, but perhaps we can describe it */
- /* todo: add greek. GREEK_SMALL_LETTER_ALPHA = alpha */
-
- /* general puctuation */
- case HYPHEN:
- return (const char *)"-";
- case FIGURE_DASH:
- case EN_DASH:
- return (const char *)"--";
- case EM_DASH:
- return (const char *)"---";
- case LEFT_SINGLE_QUOTATION_MARK:
- return (const char *)"`";
- case RIGHT_SINGLE_QUOTATION_MARK:
- return (const char *)"'";
- case SINGLE_LOW_9_QUOTATION_MARK:
- return (const char *)",";
- case SINGLE_HIGH_REVERSED_9_QUOTATION_MARK:
- return (const char *)UNDEFINED;
- case LEFT_DOUBLE_QUOTATION_MARK:
- return (const char *)"``";
- case RIGHT_DOUBLE_QUOTATION_MARK:
- return (const char *)"''";
- case DOUBLE_LOW_9_QUOTATION_MARK:
- return (const char *)",,";
- case DOUBLE_HIGH_REVERSED_9_QUOTATION_MARK:
- return (const char *)UNDEFINED;
- case DAGGER:
- return (const char *)"+";
- case DOUBLE_DAGGER:
- return (const char *)"*";
- case BULLET:
- return (const char *)"*";
- case TRIANGULAR_BULLET:
- return (const char *)"*";
- case HYPHENATION_POINT:
- return (const char *)"-";
- case HORIZONTAL_ELLIPSIS:
- return (const char *)"...";
- case PER_MILLE_SIGN:
- return (const char *)"%%"; /* awk! */
- case SINGLE_LEFT_POINTING_ANGLE_QUOTATION_MARK:
- return (const char *)"<";
- case SINGLE_RIGHT_POINTING_ANGLE_QUOTATION_MARK:
- return (const char *)">";
- case EURO_CURRENCY_SIGN:
- return (const char *)"EUR"; /* change it! */
-
- /* ligatures */
- case LATIN_SMALL_LIGATURE_FF:
- return (const char *)"ff";
- case LATIN_SMALL_LIGATURE_FI:
- return (const char *)"fi";
- case LATIN_SMALL_LIGATURE_FL:
- return (const char *)"fl";
- case LATIN_SMALL_LIGATURE_FFI:
- return (const char *)"ffi";
- case LATIN_SMALL_LIGATURE_FFL:
- return (const char *)"ffl";
- case LATIN_SMALL_LIGATURE_LONG_S_T:
- case LATIN_SMALL_LIGATURE_ST:
- return (const char *)"st";
-
- /* extra */
- case UNKNOWN:
- return (const char *)"_";
- case PICTURE:
- return (const char *)"_"; /* Due to Mobile OCR */
-
- default:
- /* snprintf seems to be no standard, so I use insecure sprintf */
- sprintf(buf,"\\code(%04x)",(unsigned)c);
- return buf; /* UNDEFINED; */
- }
- break;
- case TeX:
- if ( c >= SPACE && c <= TILDE ) { /* ASCII */
- switch (c) {
- case '$':
- return (const char *)"\\$";
- case '&':
- return (const char *)"\\&";
- case '%':
- return (const char *)"\\%";
- case '#':
- return (const char *)"\\#";
- case '_':
- return (const char *)"\\_";
- case '{':
- return (const char *)"\\{";
- case '}':
- return (const char *)"\\}";
- case '\\':
- return (const char *)"$\\backslash$";
- case '~':
- return (const char *)"\\~{}";
- case '^':
- return (const char *)"\\^{}";
- default:
- buf[0] = (char)c;
- return (const char *)buf;
- }
- }
- switch (c) {
- /* ISO8859_1 */
- case NO_BREAK_SPACE:
- return (const char *)"~";
- case INVERTED_EXCLAMATION_MARK:
- return (const char *)"!'";
- case CENT_SIGN:
- return (const char *)"\\textcent"; /* \usepackage{textcomp} */
- case POUND_SIGN:
- return (const char *)"\\pounds";
- case EURO_CURRENCY_SIGN:
- return (const char *)"\\euro"; /* \usepackage{eurosans} */
- case CURRENCY_SIGN:
- return (const char *)"\\textcurrency"; /* \usepackage{textcomp} */
- case YEN_SIGN:
- return (const char *)"\\textyen"; /* \usepackage{textcomp} */
- case BROKEN_BAR:
- return (const char *)"\\textbrokenbar"; /* \usepackage{textcomp} */
- case SECTION_SIGN:
- return (const char *)"\\S";
- case DIAERESIS:
- return (const char *)"\"";
- case COPYRIGHT_SIGN:
- return (const char *)"\\copyright";
- case FEMININE_ORDINAL_INDICATOR:
- return (const char *)"$^{\\underbar{a}}$";
- case LEFT_POINTING_DOUBLE_ANGLE_QUOTATION_MARK:
- return (const char *)"\\flqq{}";
- case NOT_SIGN:
- return (const char *)"$\\lnot$";
- case SOFT_HYPHEN:
- return (const char *)"\\-";
- case REGISTERED_SIGN:
- return (const char *)"\\textregistered";/* \usepackage{textcomp} */
- case MACRON:
- return (const char *)"\\textasciimacron";/* \usepackage{textcomp} */
- case DEGREE_SIGN:
- return (const char *)"$^{o}$";
- case PLUS_MINUS_SIGN:
- return (const char *)"$\\pm$";
- case SUPERSCRIPT_TWO:
- return (const char *)"$^{2}$";
- case SUPERSCRIPT_THREE:
- return (const char *)"$^{3}$";
- case ACUTE_ACCENT:
- return (const char *)"\\( \\prime \\)";
- case MICRO_SIGN:
- return (const char *)"$\\mu$";
- case PILCROW_SIGN:
- return (const char *)"\\P";
- case MIDDLE_DOT:
- return (const char *)"$\\cdot$";
- case CEDILLA:
- return (const char *)"\\,";
- case SUPERSCRIPT_ONE:
- return (const char *)"$^{1}$";
- case MASCULINE_ORDINAL_INDICATOR:
- return (const char *)"$^{\\underbar{o}}$";
- case RIGHT_POINTING_DOUBLE_ANGLE_QUOTATION_MARK:
- return (const char *)"\\frqq{}";
- case VULGAR_FRACTION_ONE_QUARTER: /* these fractions are not good*/
- return (const char *)"\\( 1\\over 4 \\)";
- case VULGAR_FRACTION_ONE_HALF:
- return (const char *)"\\( 1\\over 2 \\)";
- case VULGAR_FRACTION_THREE_QUARTERS:
- return (const char *)"\\( 3\\over 4 \\)";
- case INVERTED_QUESTION_MARK:
- return (const char *)"?'";
- case LATIN_CAPITAL_LETTER_A_WITH_GRAVE:
- return (const char *)"\\`A";
- case LATIN_CAPITAL_LETTER_A_WITH_ACUTE:
- return (const char *)"\\'A";
- case LATIN_CAPITAL_LETTER_A_WITH_CIRCUMFLEX:
- return (const char *)"\\^A";
- case LATIN_CAPITAL_LETTER_A_WITH_TILDE:
- return (const char *)"\\~A";
- case LATIN_CAPITAL_LETTER_A_WITH_DIAERESIS:
- return (const char *)"\\\"A";
- case LATIN_CAPITAL_LETTER_A_WITH_RING_ABOVE:
- return (const char *)"\\AA";
- case LATIN_CAPITAL_LETTER_AE:
- return (const char *)"\\AE";
- case LATIN_CAPITAL_LETTER_C_WITH_CARON:
- return (const char *)"\\v{C}";
- case LATIN_CAPITAL_LETTER_C_WITH_CEDILLA:
- return (const char *)"\\C";
- case LATIN_CAPITAL_LETTER_E_WITH_GRAVE:
- return (const char *)"\\`E";
- case LATIN_CAPITAL_LETTER_E_WITH_ACUTE:
- return (const char *)"\\'E";
- case LATIN_CAPITAL_LETTER_E_WITH_CARON:
- return (const char *)"\\v{E}";
- case LATIN_CAPITAL_LETTER_E_WITH_CIRCUMFLEX:
- return (const char *)"\\^E";
- case LATIN_CAPITAL_LETTER_E_WITH_DIAERESIS:
- return (const char *)"\\\"E";
- case LATIN_CAPITAL_LETTER_I_WITH_GRAVE:
- return (const char *)"\\`I";
- case LATIN_CAPITAL_LETTER_I_WITH_ACUTE:
- return (const char *)"\\'I";
- case LATIN_CAPITAL_LETTER_I_WITH_CIRCUMFLEX:
- return (const char *)"\\^I";
- case LATIN_CAPITAL_LETTER_I_WITH_DIAERESIS:
- return (const char *)"\\\"I";
- case LATIN_CAPITAL_LETTER_ETH:
- return (const char *)UNDEFINED;
- case LATIN_CAPITAL_LETTER_N_WITH_TILDE:
- return (const char *)"\\~N";
- case LATIN_CAPITAL_LETTER_O_WITH_GRAVE:
- return (const char *)"\\`O";
- case LATIN_CAPITAL_LETTER_O_WITH_ACUTE:
- return (const char *)"\\'O";
- case LATIN_CAPITAL_LETTER_O_WITH_CIRCUMFLEX:
- return (const char *)"\\^O";
- case LATIN_CAPITAL_LETTER_O_WITH_TILDE:
- return (const char *)"\\~O";
- case LATIN_CAPITAL_LETTER_O_WITH_DIAERESIS:
- return (const char *)"\\\"O";
- case MULTIPLICATION_SIGN:
- return (const char *)"$\\times$";
- case LATIN_CAPITAL_LETTER_O_WITH_STROKE:
- return (const char *)"\\O";
- case LATIN_CAPITAL_LETTER_S_WITH_CARON:
- return (const char *)"\\v{S}";
- case LATIN_CAPITAL_LETTER_U_WITH_GRAVE:
- return (const char *)"\\`U";
- case LATIN_CAPITAL_LETTER_U_WITH_ACUTE:
- return (const char *)"\\'U";
- case LATIN_CAPITAL_LETTER_U_WITH_CIRCUMFLEX:
- return (const char *)"\\^U";
- case LATIN_CAPITAL_LETTER_U_WITH_DIAERESIS:
- return (const char *)"\\\"U";
- case LATIN_CAPITAL_LETTER_Y_WITH_ACUTE:
- return (const char *)"\\'Y";
- case LATIN_CAPITAL_LETTER_Z_WITH_CARON:
- return (const char *)"\\v{Z}";
- case LATIN_CAPITAL_LETTER_THORN:
- return (const char *)UNDEFINED;
- case LATIN_SMALL_LETTER_SHARP_S:
- return (const char *)"\\ss";
- case LATIN_SMALL_LETTER_A_WITH_GRAVE:
- return (const char *)"\\`a";
- case LATIN_SMALL_LETTER_A_WITH_ACUTE:
- return (const char *)"\\'a";
- case LATIN_SMALL_LETTER_A_WITH_CIRCUMFLEX:
- return (const char *)"\\^a";
- case LATIN_SMALL_LETTER_A_WITH_TILDE:
- return (const char *)"\\~a";
- case LATIN_SMALL_LETTER_A_WITH_DIAERESIS:
- return (const char *)"\\\"a";
- case LATIN_SMALL_LETTER_A_WITH_RING_ABOVE:
- return (const char *)"\\aa";
- case LATIN_SMALL_LETTER_AE:
- return (const char *)"\\ae";
- case LATIN_SMALL_LETTER_C_WITH_CARON:
- return (const char *)"\\v{c}";
- case LATIN_SMALL_LETTER_C_WITH_CEDILLA:
- return (const char *)"\\c";
- case LATIN_SMALL_LETTER_E_WITH_GRAVE:
- return (const char *)"\\`e";
- case LATIN_SMALL_LETTER_E_WITH_ACUTE:
- return (const char *)"\\'e";
- case LATIN_SMALL_LETTER_E_WITH_CARON:
- return (const char *)"\\v{e}";
- case LATIN_SMALL_LETTER_E_WITH_CIRCUMFLEX:
- return (const char *)"\\^e";
- case LATIN_SMALL_LETTER_E_WITH_DIAERESIS:
- return (const char *)"\\\"e";
- case LATIN_SMALL_LETTER_I_WITH_GRAVE:
- return (const char *)"\\`i";
- case LATIN_SMALL_LETTER_I_WITH_ACUTE:
- return (const char *)"\\'i";
- case LATIN_SMALL_LETTER_I_WITH_CIRCUMFLEX:
- return (const char *)"\\^i";
- case LATIN_SMALL_LETTER_I_WITH_DIAERESIS:
- return (const char *)"\\\"i";
- case LATIN_SMALL_LETTER_ETH:
- return (const char *)UNDEFINED;
- case LATIN_SMALL_LETTER_N_WITH_TILDE:
- return (const char *)"\\~n";
- case LATIN_SMALL_LETTER_O_WITH_GRAVE:
- return (const char *)"\\`o";
- case LATIN_SMALL_LETTER_O_WITH_ACUTE:
- return (const char *)"\\'o";
- case LATIN_SMALL_LETTER_O_WITH_CIRCUMFLEX:
- return (const char *)"\\^o";
- case LATIN_SMALL_LETTER_O_WITH_TILDE:
- return (const char *)"\\~o";
- case LATIN_SMALL_LETTER_O_WITH_DIAERESIS:
- return (const char *)"\\\"o";
- case DIVISION_SIGN:
- return (const char *)"$\\div$";
- case LATIN_SMALL_LETTER_O_WITH_STROKE:
- return (const char *)"\\o";
- case LATIN_SMALL_LETTER_S_WITH_CARON:
- return (const char *)"\\v{s}";
- case LATIN_SMALL_LETTER_U_WITH_GRAVE:
- return (const char *)"\\`u";
- case LATIN_SMALL_LETTER_U_WITH_ACUTE:
- return (const char *)"\\'u";
- case LATIN_SMALL_LETTER_U_WITH_CIRCUMFLEX:
- return (const char *)"\\^u";
- case LATIN_SMALL_LETTER_U_WITH_DIAERESIS:
- return (const char *)"\\\"u";
- case LATIN_SMALL_LETTER_Y_WITH_ACUTE:
- return (const char *)"\\'y";
- case LATIN_SMALL_LETTER_THORN:
- return (const char *)UNDEFINED;
- case LATIN_SMALL_LETTER_Y_WITH_DIAERESIS:
- return (const char *)"\\\"y";
- case LATIN_SMALL_LETTER_Z_WITH_CARON:
- return (const char *)"\\v{z}";
-
- /* greek */
- /* some (punctuation, accents, accented capital) greek letters missing*/
- case GREEK_CAPITAL_LETTER_ALPHA:
- return (const char *)"A";
- case GREEK_CAPITAL_LETTER_BETA:
- return (const char *)"B";
- case GREEK_CAPITAL_LETTER_GAMMA:
- return (const char *)"\\( \\Gamma \\)";
- case GREEK_CAPITAL_LETTER_DELTA:
- return (const char *)"\\( \\Delta \\)";
- case GREEK_CAPITAL_LETTER_EPSILON:
- return (const char *)"E";
- case GREEK_CAPITAL_LETTER_ZETA:
- return (const char *)"Z";
- case GREEK_CAPITAL_LETTER_ETA:
- return (const char *)"H";
- case GREEK_CAPITAL_LETTER_THETA:
- return (const char *)"\\( \\Theta \\)";
- case GREEK_CAPITAL_LETTER_IOTA:
- return (const char *)"I";
- case GREEK_CAPITAL_LETTER_KAPPA:
- return (const char *)"K";
- case GREEK_CAPITAL_LETTER_LAMDA:
- return (const char *)"\\( \\Lambda \\)";
- case GREEK_CAPITAL_LETTER_MU:
- return (const char *)"M";
- case GREEK_CAPITAL_LETTER_NU:
- return (const char *)"N";
- case GREEK_CAPITAL_LETTER_XI:
- return (const char *)"\\( \\Xi \\)";
- case GREEK_CAPITAL_LETTER_OMICRON:
- return (const char *)"O";
- case GREEK_CAPITAL_LETTER_PI:
- return (const char *)"\\( \\Pi \\)";
- case GREEK_CAPITAL_LETTER_RHO:
- return (const char *)"P";
- case GREEK_CAPITAL_LETTER_SIGMA:
- return (const char *)"\\( \\Sigma \\)";
- case GREEK_CAPITAL_LETTER_TAU:
- return (const char *)"T";
- case GREEK_CAPITAL_LETTER_UPSILON:
- return (const char *)"\\( \\Upsilon \\)";
- case GREEK_CAPITAL_LETTER_PHI:
- return (const char *)"\\( \\Phi \\)";
- case GREEK_CAPITAL_LETTER_CHI:
- return (const char *)"\\( \\Chi \\)";
- case GREEK_CAPITAL_LETTER_PSI:
- return (const char *)"\\( \\Psi \\)";
- case GREEK_CAPITAL_LETTER_OMEGA:
- return (const char *)"\\( \\Omega \\)";
- case GREEK_CAPITAL_LETTER_IOTA_WITH_DIALYTIKA:
- return (const char *)UNDEFINED;
- case GREEK_CAPITAL_LETTER_UPSILON_WITH_DIALYTIKA:
- return (const char *)UNDEFINED;
- case GREEK_SMALL_LETTER_ALPHA_WITH_TONOS:
- return (const char *)UNDEFINED;
- case GREEK_SMALL_LETTER_EPSILON_WITH_TONOS:
- return (const char *)UNDEFINED;
- case GREEK_SMALL_LETTER_ETA_WITH_TONOS:
- return (const char *)UNDEFINED;
- case GREEK_SMALL_LETTER_IOTA_WITH_TONOS:
- return (const char *)UNDEFINED;
- case GREEK_SMALL_LETTER_UPSILON_WITH_DIALYTIKA_AND_TONOS:
- return (const char *)UNDEFINED;
- case GREEK_SMALL_LETTER_ALPHA:
- return (const char *)"\\( \\alpha \\)";
- case GREEK_SMALL_LETTER_BETA:
- return (const char *)"\\( \\beta \\)";
- case GREEK_SMALL_LETTER_GAMMA:
- return (const char *)"\\( \\gamma \\)";
- case GREEK_SMALL_LETTER_DELTA:
- return (const char *)"\\( \\delta \\)";
- case GREEK_SMALL_LETTER_EPSILON:
- return (const char *)"\\( \\epsilon \\)";
- case GREEK_SMALL_LETTER_ZETA:
- return (const char *)"\\( \\zeta \\)";
- case GREEK_SMALL_LETTER_ETA:
- return (const char *)"\\( \\eta \\)";
- case GREEK_SMALL_LETTER_THETA:
- return (const char *)"\\( \\theta \\)";
- case GREEK_SMALL_LETTER_IOTA:
- return (const char *)"\\( \\iota \\)";
- case GREEK_SMALL_LETTER_KAPPA:
- return (const char *)"\\( \\kappa \\)";
- case GREEK_SMALL_LETTER_LAMDA:
- return (const char *)"\\( \\lambda \\)";
- case GREEK_SMALL_LETTER_MU:
- return (const char *)"\\( \\mu \\)";
- case GREEK_SMALL_LETTER_NU:
- return (const char *)"\\( \\nu \\)";
- case GREEK_SMALL_LETTER_XI:
- return (const char *)"\\( \\xi \\)";
- case GREEK_SMALL_LETTER_OMICRON:
- return (const char *)"\\( \\omicron \\)";
- case GREEK_SMALL_LETTER_PI:
- return (const char *)"\\( \\pi \\)";
- case GREEK_SMALL_LETTER_RHO:
- return (const char *)"\\( \\rho \\)";
- case GREEK_SMALL_LETTER_FINAL_SIGMA:
- return (const char *)"\\( \\varsigma \\)";
- case GREEK_SMALL_LETTER_SIGMA:
- return (const char *)"\\( \\sigma \\)";
- case GREEK_SMALL_LETTER_TAU:
- return (const char *)"\\( \\tau \\)";
- case GREEK_SMALL_LETTER_UPSILON:
- return (const char *)"\\( \\upsilon \\)";
- case GREEK_SMALL_LETTER_PHI:
- return (const char *)"\\( \\varphi \\)";
- case GREEK_SMALL_LETTER_CHI:
- return (const char *)"\\( \\chi \\)";
- case GREEK_SMALL_LETTER_PSI:
- return (const char *)"\\( \\psi \\)";
- case GREEK_SMALL_LETTER_OMEGA:
- return (const char *)"\\( \\omega \\)";
- case GREEK_SMALL_LETTER_IOTA_WITH_DIALYTIKA:
- return (const char *)UNDEFINED;
- case GREEK_SMALL_LETTER_UPSILON_WITH_DIALYTIKA:
- return (const char *)UNDEFINED;
- case GREEK_SMALL_LETTER_OMICRON_WITH_TONOS:
- return (const char *)UNDEFINED;
- case GREEK_SMALL_LETTER_UPSILON_WITH_TONOS:
- return (const char *)UNDEFINED;
- case GREEK_SMALL_LETTER_OMEGA_WITH_TONOS:
- return (const char *)UNDEFINED;
- case GREEK_BETA_SYMBOL:
- return (const char *)UNDEFINED;
- case GREEK_THETA_SYMBOL:
- return (const char *)"\\( \\vartheta \\)";
- case GREEK_UPSILON_WITH_HOOK_SYMBOL:
- return (const char *)UNDEFINED;
- case GREEK_UPSILON_WITH_ACUTE_AND_HOOK_SYMBOL:
- return (const char *)UNDEFINED;
- case GREEK_UPSILON_WITH_DIAERESIS_AND_HOOK_SYMBOL:
- return (const char *)UNDEFINED;
- case GREEK_PHI_SYMBOL:
- return (const char *)"\\( \\phi \\)";
- case GREEK_PI_SYMBOL:
- return (const char *)"\\( \\varpi \\)";
- /* and some greek letters missing*/
-
- /* punctuation (partial) */
- case HYPHEN:
- return (const char *)"-";
- case NON_BREAKING_HYPHEN:
- return (const char *)UNDEFINED;
- case FIGURE_DASH:
- case EN_DASH:
- return (const char *)"--";
- case EM_DASH:
- return (const char *)"---";
- case HORIZONTAL_BAR:
- return (const char *)UNDEFINED;
- case LEFT_SINGLE_QUOTATION_MARK:
- return (const char *)"`";
- case RIGHT_SINGLE_QUOTATION_MARK:
- return (const char *)"'";
- case SINGLE_LOW_9_QUOTATION_MARK:
- return (const char *)"\\glq{}";
- case SINGLE_HIGH_REVERSED_9_QUOTATION_MARK:
- return (const char *)UNDEFINED;
- case LEFT_DOUBLE_QUOTATION_MARK:
- return (const char *)"``";
- case RIGHT_DOUBLE_QUOTATION_MARK:
- return (const char *)"''";
- case DOUBLE_LOW_9_QUOTATION_MARK:
- return (const char *)"\\glqq{}";
- case DOUBLE_HIGH_REVERSED_9_QUOTATION_MARK:
- return (const char *)UNDEFINED;
- case DAGGER:
- return (const char *)"\\dag";
- case DOUBLE_DAGGER:
- return (const char *)"\\ddag";
- case BULLET:
- return (const char *)"$\\bullet$";
- case TRIANGULAR_BULLET:
- return (const char *)"$\\blacktriangleright";
- case HYPHENATION_POINT:
- return (const char *)"\\-";
- case HORIZONTAL_ELLIPSIS:
- return (const char *)"\\ldots";
- case PER_MILLE_SIGN:
- return (const char *)UNDEFINED;
- case SINGLE_LEFT_POINTING_ANGLE_QUOTATION_MARK:
- return (const char *)"\\flq{}";
- case SINGLE_RIGHT_POINTING_ANGLE_QUOTATION_MARK:
- return (const char *)"\\frq{}";
- /* ligatures */
- case LATIN_SMALL_LIGATURE_FF:
- return (const char *)"ff";
- case LATIN_SMALL_LIGATURE_FI:
- return (const char *)"fi";
- case LATIN_SMALL_LIGATURE_FL:
- return (const char *)"fl";
- case LATIN_SMALL_LIGATURE_FFI:
- return (const char *)"ffi";
- case LATIN_SMALL_LIGATURE_FFL:
- return (const char *)"ffl";
- case LATIN_SMALL_LIGATURE_LONG_S_T:
- case LATIN_SMALL_LIGATURE_ST:
- return (const char *)"st";
- /* reserved */
- case 0:
- return (const char *)"";
- case UNKNOWN:
- return (const char *)"\\_";
- case PICTURE:
- return (const char *)"(PICTURE)";
- default:
- /* snprintf seems to be no standard, so I use insecure sprintf */
- sprintf(buf,"\\symbol{%u}",(unsigned)c);
- return buf; /* UNDEFINED; */
- }
- case HTML:
- if ( c >= SPACE && c <= TILDE ) { /* ASCII */
- switch (c) {
- case '&':
- return (const char *)"&";
- /* semicolon must not be coded */
- case '\'':
- return (const char *)"'";
- case '"':
- return (const char *)""";
- case '<':
- return (const char *)"<";
- case '>':
- return (const char *)">";
- }
- buf[0] = (char)c;
- return buf;
- }
- switch (c) {
- case PICTURE:
- return (const char *)"<!--PICTURE-->";
- case UNKNOWN:
- return (const char *)"_"; /* better use colored symbol? */
- case LINE_FEED:
- return (const char *)"<br />"; /* \n handled somwhere else? */
- case FORM_FEED:
- case CARRIAGE_RETURN:
- return (const char *)"<br />";
- case NO_BREAK_SPACE:
- return (const char *)"<nobr />";
- case INVERTED_EXCLAMATION_MARK:
- return (const char *)"¡";
- case CENT_SIGN:
- return (const char *)"¢";
- case POUND_SIGN:
- return (const char *)"£";
- case CURRENCY_SIGN:
- return (const char *)"¤";
- case YEN_SIGN:
- return (const char *)"¥";
- case BROKEN_BAR:
- return (const char *)"¦";
- case SECTION_SIGN:
- return (const char *)"§";
- case DIAERESIS:
- return (const char *)"¨";
- case COPYRIGHT_SIGN:
- return (const char *)"©";
- case FEMININE_ORDINAL_INDICATOR:
- return (const char *)"ªem;";
- case LEFT_POINTING_DOUBLE_ANGLE_QUOTATION_MARK:
- return (const char *)"«";
- case NOT_SIGN:
- return (const char *)"¬";
- case SOFT_HYPHEN:
- return (const char *)"­";
- case REGISTERED_SIGN:
- return (const char *)"®";
- case MACRON:
- return (const char *)"¯";
- case DEGREE_SIGN:
- return (const char *)"°";
- case PLUS_MINUS_SIGN:
- return (const char *)"±";
- case SUPERSCRIPT_TWO:
- return (const char *)"²";
- case SUPERSCRIPT_THREE:
- return (const char *)"³";
- case ACUTE_ACCENT:
- return (const char *)"´";
- case MICRO_SIGN:
- return (const char *)"µ";
- case PILCROW_SIGN:
- return (const char *)"¶";
- case MIDDLE_DOT:
- return (const char *)"·";
- case CEDILLA:
- return (const char *)"¸";
- case SUPERSCRIPT_ONE:
- return (const char *)"¹";
- case MASCULINE_ORDINAL_INDICATOR:
- return (const char *)"º";
- case RIGHT_POINTING_DOUBLE_ANGLE_QUOTATION_MARK:
- return (const char *)"»";
- case VULGAR_FRACTION_ONE_QUARTER:
- return (const char *)"¼";
- case VULGAR_FRACTION_ONE_HALF:
- return (const char *)"½";
- case VULGAR_FRACTION_THREE_QUARTERS:
- return (const char *)"¾";
- case INVERTED_QUESTION_MARK:
- return (const char *)"¿";
- case LATIN_CAPITAL_LETTER_A_WITH_GRAVE:
- return (const char *)"À";
- case LATIN_CAPITAL_LETTER_A_WITH_ACUTE:
- return (const char *)"Á";
- case LATIN_CAPITAL_LETTER_A_WITH_BREVE:
- return (const char *)"Ă";
- case LATIN_CAPITAL_LETTER_A_WITH_CIRCUMFLEX:
- return (const char *)"Â";
- case LATIN_CAPITAL_LETTER_A_WITH_TILDE:
- return (const char *)"Ã";
- case LATIN_CAPITAL_LETTER_A_WITH_DIAERESIS:
- return (const char *)"Ä";
- case LATIN_CAPITAL_LETTER_A_WITH_RING_ABOVE:
- return (const char *)"Å";
- case LATIN_CAPITAL_LETTER_AE:
- return (const char *)"Æ";
- case LATIN_CAPITAL_LETTER_C_WITH_CARON:
- return (const char *)"Č";
- case LATIN_CAPITAL_LETTER_C_WITH_CEDILLA:
- return (const char *)"Ç";
- case LATIN_CAPITAL_LETTER_E_WITH_GRAVE:
- return (const char *)"È";
- case LATIN_CAPITAL_LETTER_E_WITH_ACUTE:
- return (const char *)"É";
- case LATIN_CAPITAL_LETTER_E_WITH_CARON:
- return (const char *)"Ě";
- case LATIN_CAPITAL_LETTER_E_WITH_CIRCUMFLEX:
- return (const char *)"Ê";
- case LATIN_CAPITAL_LETTER_E_WITH_DIAERESIS:
- return (const char *)"Ë";
- case LATIN_CAPITAL_LETTER_I_WITH_GRAVE:
- return (const char *)"Ì";
- case LATIN_CAPITAL_LETTER_I_WITH_ACUTE:
- return (const char *)"Í";
- case LATIN_CAPITAL_LETTER_I_WITH_CIRCUMFLEX:
- return (const char *)"Î";
- case LATIN_CAPITAL_LETTER_I_WITH_DIAERESIS:
- return (const char *)"Ï";
- case LATIN_CAPITAL_LETTER_ETH:
- return (const char *)"Ð";
- case LATIN_CAPITAL_LETTER_N_WITH_TILDE:
- return (const char *)"Ñ";
- case LATIN_CAPITAL_LETTER_O_WITH_GRAVE:
- return (const char *)"Ò";
- case LATIN_CAPITAL_LETTER_O_WITH_ACUTE:
- return (const char *)"Ó";
- case LATIN_CAPITAL_LETTER_O_WITH_CIRCUMFLEX:
- return (const char *)"Ô";
- case LATIN_CAPITAL_LETTER_O_WITH_TILDE:
- return (const char *)"Õ";
- case LATIN_CAPITAL_LETTER_O_WITH_DIAERESIS:
- return (const char *)"Ö";
- case MULTIPLICATION_SIGN:
- return (const char *)"×";
- case LATIN_CAPITAL_LETTER_O_WITH_STROKE:
- return (const char *)"Ø";
- case LATIN_CAPITAL_LETTER_S_WITH_CARON:
- return (const char *)"Š";
- case LATIN_CAPITAL_LETTER_U_WITH_GRAVE:
- return (const char *)"Ù";
- case LATIN_CAPITAL_LETTER_U_WITH_ACUTE:
- return (const char *)"Ú";
- case LATIN_CAPITAL_LETTER_U_WITH_CIRCUMFLEX:
- return (const char *)"Û";
- case LATIN_CAPITAL_LETTER_U_WITH_DIAERESIS:
- return (const char *)"Ü";
- case LATIN_CAPITAL_LETTER_Y_WITH_ACUTE:
- return (const char *)"Ý";
- case LATIN_CAPITAL_LETTER_Z_WITH_CARON:
- return (const char *)"Ž";
- case LATIN_CAPITAL_LETTER_THORN:
- return (const char *)"Þ";
- case LATIN_SMALL_LETTER_SHARP_S:
- return (const char *)"ß";
- case LATIN_SMALL_LETTER_A_WITH_GRAVE:
- return (const char *)"à";
- case LATIN_SMALL_LETTER_A_WITH_ACUTE:
- return (const char *)"á";
- case LATIN_SMALL_LETTER_A_WITH_BREVE:
- return (const char *)"ă";
- case LATIN_SMALL_LETTER_A_WITH_CARON:
- return (const char *)"&acaron;";
- case LATIN_SMALL_LETTER_A_WITH_CIRCUMFLEX:
- return (const char *)"â";
- case LATIN_SMALL_LETTER_A_WITH_TILDE:
- return (const char *)"ã";
- case LATIN_SMALL_LETTER_A_WITH_DIAERESIS:
- return (const char *)"ä";
- case LATIN_SMALL_LETTER_A_WITH_RING_ABOVE:
- return (const char *)"å";
- case LATIN_SMALL_LETTER_AE:
- return (const char *)"æ";
- case LATIN_SMALL_LETTER_C_WITH_CARON:
- return (const char *)"č";
- case LATIN_SMALL_LETTER_C_WITH_CEDILLA:
- return (const char *)"ç";
- case LATIN_SMALL_LETTER_E_WITH_GRAVE:
- return (const char *)"è";
- case LATIN_SMALL_LETTER_E_WITH_ACUTE:
- return (const char *)"é";
- case LATIN_SMALL_LETTER_E_WITH_CARON:
- return (const char *)"ě";
- case LATIN_SMALL_LETTER_E_WITH_CIRCUMFLEX:
- return (const char *)"ê";
- case LATIN_SMALL_LETTER_E_WITH_DIAERESIS:
- return (const char *)"ë";
- case LATIN_SMALL_LETTER_I_WITH_GRAVE:
- return (const char *)"ì";
- case LATIN_SMALL_LETTER_I_WITH_ACUTE:
- return (const char *)"í";
- case LATIN_SMALL_LETTER_I_WITH_CIRCUMFLEX:
- return (const char *)"î";
- case LATIN_SMALL_LETTER_I_WITH_DIAERESIS:
- return (const char *)"ï";
- case LATIN_SMALL_LETTER_ETH:
- return (const char *)"ð";
- case LATIN_SMALL_LETTER_N_WITH_TILDE:
- return (const char *)"ñ";
- case LATIN_SMALL_LETTER_O_WITH_GRAVE:
- return (const char *)"ò";
- case LATIN_SMALL_LETTER_O_WITH_ACUTE:
- return (const char *)"ó";
- case LATIN_SMALL_LETTER_O_WITH_CIRCUMFLEX:
- return (const char *)"ô";
- case LATIN_SMALL_LETTER_O_WITH_TILDE:
- return (const char *)"õ";
- case LATIN_SMALL_LETTER_O_WITH_DIAERESIS:
- return (const char *)"ö";
- case DIVISION_SIGN:
- return (const char *)"÷";
- case LATIN_SMALL_LETTER_O_WITH_STROKE:
- return (const char *)"ø";
- case LATIN_SMALL_LETTER_S_WITH_CARON:
- return (const char *)"š";
- case LATIN_SMALL_LETTER_U_WITH_GRAVE:
- return (const char *)"ù";
- case LATIN_SMALL_LETTER_U_WITH_ACUTE:
- return (const char *)"ú";
- case LATIN_SMALL_LETTER_U_WITH_CIRCUMFLEX:
- return (const char *)"û";
- case LATIN_SMALL_LETTER_U_WITH_DIAERESIS:
- return (const char *)"ü";
- case LATIN_SMALL_LETTER_Y_WITH_ACUTE:
- return (const char *)"ý";
- case LATIN_SMALL_LETTER_THORN:
- return (const char *)"þ";
- case LATIN_SMALL_LETTER_Y_WITH_DIAERESIS:
- return (const char *)"ÿ";
- case LATIN_SMALL_LETTER_Z_WITH_CARON:
- return (const char *)"ž";
- case EURO_CURRENCY_SIGN:
- return (const char *)"€";
- case 0:
- return (const char *)"";
- default:
- sprintf(buf,"&#%u;",(unsigned)c);
- return buf; /* undefined */
- }
- /* break; unreachable code */
- case XML: /* only 5 &xxx;-ENTITIES ar defined by default */
- if ( c >= SPACE && c <= TILDE ) { /* ASCII */
- switch (c) {
- case '&':
- return (const char *)"&";
- case '\'':
- return (const char *)"'";
- case '"':
- return (const char *)""";
- case '<':
- return (const char *)"<";
- case '>':
- return (const char *)">";
- }
- buf[0] = (char)c;
- return buf;
- }
- switch (c) { /* subject of change! */
- case PICTURE:
- return (const char *)"(PICTURE)";
- case UNKNOWN:
- return (const char *)"_"; /* better use colored symbol? */
- case LINE_FEED: /* \n handled somwhere else? */
- case FORM_FEED:
- case CARRIAGE_RETURN:
- return (const char *)"<br />";
- case NO_BREAK_SPACE:
- return (const char *)"<nobr />";
- case 0:
- return (const char *)"";
- default:
- sprintf(buf,"&#x%03x;",(unsigned)c);
- return buf; /* undefined */
- }
- /* break; unreachable code */
- case SGML:
- switch (c) {
- default:
- sprintf(buf,"&#%u;",(unsigned)c);
- return buf; /* UNDEFINED */
- }
- /* break; unreachable code */
- case ASCII: /* mainly used for debugging */
- if ( c=='\n' || (c>= 0x20 && c <= 0x7F) ) {
- buf[0] = (char)c;
- return buf;
- }
- switch (c) {
- /* extra */
- case UNKNOWN:
- return (const char *)"(?)";
- case PICTURE:
- return (const char *)"(?)";
-
- default:
- /* snprintf seems to be no standard, so I use insecure sprintf */
- if ((unsigned)c>255) sprintf(buf,"(0x%04x)",(unsigned)c);
- else sprintf(buf,"(0x%02x)",(unsigned)c);
- return buf; /* UNDEFINED; */
- }
- /* break; unreachable code */
- default: /* use UTF8 as default, test with xterm -u8 */
- /* extra */
- if ( c == UNKNOWN ) return (const char *)"_";
- if ( c == PICTURE ) return (const char *)"_"; /* Due to Mobile OCR */
- if ( c <= (wchar_t)0x0000007F ) { /* UTF8 == 7bit ASCII */
- buf[0] = (char)c;
- return buf;
- }
- if ( c <= (wchar_t)0x000007FF ) { /* UTF8 == 11bit */
- buf[0] = (char)(0xc0|((c>> 6) & 0x1f)); /* 110xxxxx */
- buf[1] = (char)(0x80|( c & 0x3f)); /* 10xxxxxx */
- buf[2] = (char)0; /* terminate string */
- return buf;
- }
- /* wchar_t is 16bit for Borland-C !? Jan07 */
- if ( c <= (wchar_t)0x0000FFFF ) { /* UTF8 == 16bit */
- buf[0] = (char)(0xe0|((c>>12) & 0x0f)); /* 1110xxxx */
- buf[1] = (char)(0x80|((c>> 6) & 0x3f)); /* 10xxxxxx */
- buf[2] = (char)(0x80|( c & 0x3f)); /* 10xxxxxx */
- buf[3] = (char)0; /* terminate string */
- return buf;
- }
- if ( c <= (wchar_t)0x001FFFFF ) { /* UTF8 == 21bit */
- buf[0] = (char)(0xf0|((c>>18) & 0x07)); /* 11110xxx */
- buf[1] = (char)(0x80|((c>>12) & 0x3f)); /* 10xxxxxx */
- buf[2] = (char)(0x80|((c>> 6) & 0x3f)); /* 10xxxxxx */
- buf[3] = (char)(0x80|( c & 0x3f)); /* 10xxxxxx */
- buf[4] = (char)0; /* terminate string */
- return buf;
- }
- if ( c <= (wchar_t)0x03FFFFFF ) { /* UTF8 == 26bit */
- buf[0] = (char)(0xf8|((c>>24) & 0x03)); /* 111110xx */
- buf[1] = (char)(0x80|((c>>18) & 0x3f)); /* 10xxxxxx */
- buf[2] = (char)(0x80|((c>>12) & 0x3f)); /* 10xxxxxx */
- buf[3] = (char)(0x80|((c>> 6) & 0x3f)); /* 10xxxxxx */
- buf[4] = (char)(0x80|( c & 0x3f)); /* 10xxxxxx */
- buf[5] = (char)0; /* terminate string */
- return buf;
- }
- if ( c <= (wchar_t)0x7FFFFFFF ) { /* UTF8 == 31bit */
- buf[0] = (char)(0xfc|((c>>30) & 0x01)); /* 1111110x */
- buf[1] = (char)(0x80|((c>>24) & 0x3f)); /* 10xxxxxx */
- buf[2] = (char)(0x80|((c>>18) & 0x3f)); /* 10xxxxxx */
- buf[3] = (char)(0x80|((c>>12) & 0x3f)); /* 10xxxxxx */
- buf[4] = (char)(0x80|((c>> 6) & 0x3f)); /* 10xxxxxx */
- buf[5] = (char)(0x80|( c & 0x3f)); /* 10xxxxxx */
- buf[6] = (char)0; /* terminate string */
- return buf;
- }
- return (const char *)UNDEFINED;
- }
-}
+++ /dev/null
-/*
-This is a Optical-Character-Recognition program
-Copyright (C) 2000-2007 Joerg Schulenburg
-
- The character codes in this file are Copyright (c) 1991-1999 Unicode, Inc.
- All Rights reserved.
-
- This file is provided as-is by Unicode, Inc. (The Unicode Consortium).
- No claims are made as to fitness for any particular purpose. No
- warranties of any kind are expressed or implied. The recipient
- agrees to determine applicability of information provided. If this
- file has been provided on optical media by Unicode, Inc., the sole
- remedy for any claim will be exchange of defective media within 90
- days of receipt.
-
- Unicode, Inc. hereby grants the right to freely use the information
- supplied in this file in the creation of products supporting the
- Unicode Standard, and to make copies of this file in any form for
- internal or external distribution as long as this notice remains
- attached.
-
-For the rest of the file, the following applies:
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- see README for EMAIL-address
- */
-
-/*
- Only the codes judged necessary by the developers are present in this
- file. It conforms with MES-1. You'll find also Greek characters,
- mathematical symbols and some extra symbols.
-
- Use the following regular expression to help add new codes from the
- Unicode data files: ([\w\s]*);([\w\s]*);[^\n]*
-*/
-
-#ifndef G_UNICODE_H
-#define G_UNICODE_H
-
-#include <stddef.h>
-
-enum format {
- ISO8859_1, TeX, HTML, XML, SGML, UTF8, ASCII
-};
-typedef enum format FORMAT;
-
-/*
- * Prototypes
- */
-wchar_t compose(wchar_t main, wchar_t modifier);
-const char *decode(wchar_t c, FORMAT type);
-
-/*
- * Unicode codes
- */
-
-/* E000-F8FF are for private use. We'll reserve E000-E0FF by now. */
-/* the next line isnt proper, but was the easiest way to fix a problem */
-#ifndef UNKNOWN
-#define UNKNOWN 0xE000
-#endif
-#define PICTURE 0xE001
-#define HEADER_FILE 0xE010
-
-/* most codes 0x00-0x1F are not needed, but we provide them anyway. U0000 had
- the name changed from NULL to UNICODE_NULL to avoid conflicts. */
-#define UNICODE_NULL 0x0000
-#define START_OF_HEADING 0x0001
-#define START_OF_TEXT 0x0002
-#define END_OF_TEXT 0x0003
-#define END_OF_TRANSMISSION 0x0004
-#define ENQUIRY 0x0005
-#define ACKNOWLEDGE 0x0006
-#define BELL 0x0007
-#define BACKSPACE 0x0008
-#define HORIZONTAL_TABULATION 0x0009
-#define LINE_FEED 0x000A
-#define VERTICAL_TABULATION 0x000B
-#define FORM_FEED 0x000C
-#define CARRIAGE_RETURN 0x000D
-#define SHIFT_OUT 0x000E
-#define SHIFT_IN 0x000F
-#define DATA_LINK_ESCAPE 0x0010
-#define DEVICE_CONTROL_ONE 0x0011
-#define DEVICE_CONTROL_TWO 0x0012
-#define DEVICE_CONTROL_THREE 0x0013
-#define DEVICE_CONTROL_FOUR 0x0014
-#define NEGATIVE_ACKNOWLEDGE 0x0015
-#define SYNCHRONOUS_IDLE 0x0016
-#define END_OF_TRANSMISSION_BLOCK 0x0017
-#define CANCEL 0x0018
-#define END_OF_MEDIUM 0x0019
-#define SUBSTITUTE 0x001A
-#define ESCAPE 0x001B
-#define FILE_SEPARATOR 0x001C
-#define GROUP_SEPARATOR 0x001D
-#define RECORD_SEPARATOR 0x001E
-#define UNIT_SEPARATOR 0x001F
-
-/* ASCII */
-#define SPACE 0x0020
-#define EXCLAMATION_MARK 0x0021
-#define QUOTATION_MARK 0x0022
-#define NUMBER_SIGN 0x0023
-#define DOLLAR_SIGN 0x0024
-#define PERCENT_SIGN 0x0025
-#define AMPERSAND 0x0026
-#define APOSTROPHE 0x0027
-#define LEFT_PARENTHESIS 0x0028
-#define RIGHT_PARENTHESIS 0x0029
-#define ASTERISK 0x002A
-#define PLUS_SIGN 0x002B
-#define COMMA 0x002C
-#define HYPHEN_MINUS 0x002D
-#define FULL_STOP 0x002E
-#define SOLIDUS 0x002F
-#define DIGIT_ZERO 0x0030
-#define DIGIT_ONE 0x0031
-#define DIGIT_TWO 0x0032
-#define DIGIT_THREE 0x0033
-#define DIGIT_FOUR 0x0034
-#define DIGIT_FIVE 0x0035
-#define DIGIT_SIX 0x0036
-#define DIGIT_SEVEN 0x0037
-#define DIGIT_EIGHT 0x0038
-#define DIGIT_NINE 0x0039
-#define COLON 0x003A
-#define SEMICOLON 0x003B
-#define LESS_THAN_SIGN 0x003C
-#define EQUALS_SIGN 0x003D
-#define GREATER_THAN_SIGN 0x003E
-#define QUESTION_MARK 0x003F
-#define COMMERCIAL_AT 0x0040
-#define LATIN_CAPITAL_LETTER_A 0x0041
-#define LATIN_CAPITAL_LETTER_B 0x0042
-#define LATIN_CAPITAL_LETTER_C 0x0043
-#define LATIN_CAPITAL_LETTER_D 0x0044
-#define LATIN_CAPITAL_LETTER_E 0x0045
-#define LATIN_CAPITAL_LETTER_F 0x0046
-#define LATIN_CAPITAL_LETTER_G 0x0047
-#define LATIN_CAPITAL_LETTER_H 0x0048
-#define LATIN_CAPITAL_LETTER_I 0x0049
-#define LATIN_CAPITAL_LETTER_J 0x004A
-#define LATIN_CAPITAL_LETTER_K 0x004B
-#define LATIN_CAPITAL_LETTER_L 0x004C
-#define LATIN_CAPITAL_LETTER_M 0x004D
-#define LATIN_CAPITAL_LETTER_N 0x004E
-#define LATIN_CAPITAL_LETTER_O 0x004F
-#define LATIN_CAPITAL_LETTER_P 0x0050
-#define LATIN_CAPITAL_LETTER_Q 0x0051
-#define LATIN_CAPITAL_LETTER_R 0x0052
-#define LATIN_CAPITAL_LETTER_S 0x0053
-#define LATIN_CAPITAL_LETTER_T 0x0054
-#define LATIN_CAPITAL_LETTER_U 0x0055
-#define LATIN_CAPITAL_LETTER_V 0x0056
-#define LATIN_CAPITAL_LETTER_W 0x0057
-#define LATIN_CAPITAL_LETTER_X 0x0058
-#define LATIN_CAPITAL_LETTER_Y 0x0059
-#define LATIN_CAPITAL_LETTER_Z 0x005A
-#define LEFT_SQUARE_BRACKET 0x005B
-#define REVERSE_SOLIDUS 0x005C
-#define RIGHT_SQUARE_BRACKET 0x005D
-#define CIRCUMFLEX_ACCENT 0x005E
-#define LOW_LINE 0x005F
-#define GRAVE_ACCENT 0x0060
-#define LATIN_SMALL_LETTER_A 0x0061
-#define LATIN_SMALL_LETTER_B 0x0062
-#define LATIN_SMALL_LETTER_C 0x0063
-#define LATIN_SMALL_LETTER_D 0x0064
-#define LATIN_SMALL_LETTER_E 0x0065
-#define LATIN_SMALL_LETTER_F 0x0066
-#define LATIN_SMALL_LETTER_G 0x0067
-#define LATIN_SMALL_LETTER_H 0x0068
-#define LATIN_SMALL_LETTER_I 0x0069
-#define LATIN_SMALL_LETTER_J 0x006A
-#define LATIN_SMALL_LETTER_K 0x006B
-#define LATIN_SMALL_LETTER_L 0x006C
-#define LATIN_SMALL_LETTER_M 0x006D
-#define LATIN_SMALL_LETTER_N 0x006E
-#define LATIN_SMALL_LETTER_O 0x006F
-#define LATIN_SMALL_LETTER_P 0x0070
-#define LATIN_SMALL_LETTER_Q 0x0071
-#define LATIN_SMALL_LETTER_R 0x0072
-#define LATIN_SMALL_LETTER_S 0x0073
-#define LATIN_SMALL_LETTER_T 0x0074
-#define LATIN_SMALL_LETTER_U 0x0075
-#define LATIN_SMALL_LETTER_V 0x0076
-#define LATIN_SMALL_LETTER_W 0x0077
-#define LATIN_SMALL_LETTER_X 0x0078
-#define LATIN_SMALL_LETTER_Y 0x0079
-#define LATIN_SMALL_LETTER_Z 0x007A
-#define LEFT_CURLY_BRACKET 0x007B
-#define VERTICAL_LINE 0x007C
-#define RIGHT_CURLY_BRACKET 0x007D
-#define TILDE 0x007E
-
-/* codes 0x7F-0xBF are not needed */
-#define NO_BREAK_SPACE 0x00A0
-#define INVERTED_EXCLAMATION_MARK 0x00A1
-#define CENT_SIGN 0x00A2
-#define POUND_SIGN 0x00A3
-#define CURRENCY_SIGN 0x00A4
-#define YEN_SIGN 0x00A5
-#define BROKEN_BAR 0x00A6
-#define SECTION_SIGN 0x00A7
-#define DIAERESIS 0x00A8
-#define COPYRIGHT_SIGN 0x00A9
-#define FEMININE_ORDINAL_INDICATOR 0x00AA
-#define LEFT_POINTING_DOUBLE_ANGLE_QUOTATION_MARK 0x00AB
-#define NOT_SIGN 0x00AC
-#define SOFT_HYPHEN 0x00AD
-#define REGISTERED_SIGN 0x00AE
-#define MACRON 0x00AF
-#define DEGREE_SIGN 0x00B0
-#define PLUS_MINUS_SIGN 0x00B1
-#define SUPERSCRIPT_TWO 0x00B2
-#define SUPERSCRIPT_THREE 0x00B3
-#define ACUTE_ACCENT 0x00B4
-#define MICRO_SIGN 0x00B5
-#define PILCROW_SIGN 0x00B6
-#define MIDDLE_DOT 0x00B7
-#define CEDILLA 0x00B8
-#define SUPERSCRIPT_ONE 0x00B9
-#define MASCULINE_ORDINAL_INDICATOR 0x00BA
-#define RIGHT_POINTING_DOUBLE_ANGLE_QUOTATION_MARK 0x00BB
-#define VULGAR_FRACTION_ONE_QUARTER 0x00BC
-#define VULGAR_FRACTION_ONE_HALF 0x00BD
-#define VULGAR_FRACTION_THREE_QUARTERS 0x00BE
-#define INVERTED_QUESTION_MARK 0x00BF
-#define LATIN_CAPITAL_LETTER_A_WITH_GRAVE 0x00C0
-#define LATIN_CAPITAL_LETTER_A_WITH_ACUTE 0x00C1
-#define LATIN_CAPITAL_LETTER_A_WITH_CIRCUMFLEX 0x00C2
-#define LATIN_CAPITAL_LETTER_A_WITH_TILDE 0x00C3
-#define LATIN_CAPITAL_LETTER_A_WITH_DIAERESIS 0x00C4
-#define LATIN_CAPITAL_LETTER_A_WITH_RING_ABOVE 0x00C5
-#define LATIN_CAPITAL_LETTER_AE 0x00C6
-#define LATIN_CAPITAL_LETTER_C_WITH_CEDILLA 0x00C7
-#define LATIN_CAPITAL_LETTER_E_WITH_GRAVE 0x00C8
-#define LATIN_CAPITAL_LETTER_E_WITH_ACUTE 0x00C9
-#define LATIN_CAPITAL_LETTER_E_WITH_CIRCUMFLEX 0x00CA
-#define LATIN_CAPITAL_LETTER_E_WITH_DIAERESIS 0x00CB
-#define LATIN_CAPITAL_LETTER_I_WITH_GRAVE 0x00CC
-#define LATIN_CAPITAL_LETTER_I_WITH_ACUTE 0x00CD
-#define LATIN_CAPITAL_LETTER_I_WITH_CIRCUMFLEX 0x00CE
-#define LATIN_CAPITAL_LETTER_I_WITH_DIAERESIS 0x00CF
-#define LATIN_CAPITAL_LETTER_ETH 0x00D0
-#define LATIN_CAPITAL_LETTER_N_WITH_TILDE 0x00D1
-#define LATIN_CAPITAL_LETTER_O_WITH_GRAVE 0x00D2
-#define LATIN_CAPITAL_LETTER_O_WITH_ACUTE 0x00D3
-#define LATIN_CAPITAL_LETTER_O_WITH_CIRCUMFLEX 0x00D4
-#define LATIN_CAPITAL_LETTER_O_WITH_TILDE 0x00D5
-#define LATIN_CAPITAL_LETTER_O_WITH_DIAERESIS 0x00D6
-#define MULTIPLICATION_SIGN 0x00D7
-#define LATIN_CAPITAL_LETTER_O_WITH_STROKE 0x00D8
-#define LATIN_CAPITAL_LETTER_U_WITH_GRAVE 0x00D9
-#define LATIN_CAPITAL_LETTER_U_WITH_ACUTE 0x00DA
-#define LATIN_CAPITAL_LETTER_U_WITH_CIRCUMFLEX 0x00DB
-#define LATIN_CAPITAL_LETTER_U_WITH_DIAERESIS 0x00DC
-#define LATIN_CAPITAL_LETTER_Y_WITH_ACUTE 0x00DD
-#define LATIN_CAPITAL_LETTER_THORN 0x00DE
-#define LATIN_SMALL_LETTER_SHARP_S 0x00DF
-#define LATIN_SMALL_LETTER_A_WITH_GRAVE 0x00E0
-#define LATIN_SMALL_LETTER_A_WITH_ACUTE 0x00E1
-#define LATIN_SMALL_LETTER_A_WITH_CIRCUMFLEX 0x00E2
-#define LATIN_SMALL_LETTER_A_WITH_TILDE 0x00E3
-#define LATIN_SMALL_LETTER_A_WITH_DIAERESIS 0x00E4
-#define LATIN_SMALL_LETTER_A_WITH_RING_ABOVE 0x00E5
-#define LATIN_SMALL_LETTER_AE 0x00E6
-#define LATIN_SMALL_LETTER_C_WITH_CEDILLA 0x00E7
-#define LATIN_SMALL_LETTER_E_WITH_GRAVE 0x00E8
-#define LATIN_SMALL_LETTER_E_WITH_ACUTE 0x00E9
-#define LATIN_SMALL_LETTER_E_WITH_CIRCUMFLEX 0x00EA
-#define LATIN_SMALL_LETTER_E_WITH_DIAERESIS 0x00EB
-#define LATIN_SMALL_LETTER_I_WITH_GRAVE 0x00EC
-#define LATIN_SMALL_LETTER_I_WITH_ACUTE 0x00ED
-#define LATIN_SMALL_LETTER_I_WITH_CIRCUMFLEX 0x00EE
-#define LATIN_SMALL_LETTER_I_WITH_DIAERESIS 0x00EF
-#define LATIN_SMALL_LETTER_ETH 0x00F0
-#define LATIN_SMALL_LETTER_N_WITH_TILDE 0x00F1
-#define LATIN_SMALL_LETTER_O_WITH_GRAVE 0x00F2
-#define LATIN_SMALL_LETTER_O_WITH_ACUTE 0x00F3
-#define LATIN_SMALL_LETTER_O_WITH_CIRCUMFLEX 0x00F4
-#define LATIN_SMALL_LETTER_O_WITH_TILDE 0x00F5
-#define LATIN_SMALL_LETTER_O_WITH_DIAERESIS 0x00F6
-#define DIVISION_SIGN 0x00F7
-#define LATIN_SMALL_LETTER_O_WITH_STROKE 0x00F8
-#define LATIN_SMALL_LETTER_U_WITH_GRAVE 0x00F9
-#define LATIN_SMALL_LETTER_U_WITH_ACUTE 0x00FA
-#define LATIN_SMALL_LETTER_U_WITH_CIRCUMFLEX 0x00FB
-#define LATIN_SMALL_LETTER_U_WITH_DIAERESIS 0x00FC
-#define LATIN_SMALL_LETTER_Y_WITH_ACUTE 0x00FD
-#define LATIN_SMALL_LETTER_THORN 0x00FE
-#define LATIN_SMALL_LETTER_Y_WITH_DIAERESIS 0x00FF
-
-/* latin extended-A */
-#define LATIN_CAPITAL_LETTER_A_WITH_MACRON 0x0100
-#define LATIN_SMALL_LETTER_A_WITH_MACRON 0x0101
-#define LATIN_CAPITAL_LETTER_A_WITH_BREVE 0x0102
-#define LATIN_SMALL_LETTER_A_WITH_BREVE 0x0103
-#define LATIN_CAPITAL_LETTER_A_WITH_OGONEK 0x0104
-#define LATIN_SMALL_LETTER_A_WITH_OGONEK 0x0105
-#define LATIN_CAPITAL_LETTER_C_WITH_ACUTE 0x0106
-#define LATIN_SMALL_LETTER_C_WITH_ACUTE 0x0107
-#define LATIN_CAPITAL_LETTER_C_WITH_CIRCUMFLEX 0x0108
-#define LATIN_SMALL_LETTER_C_WITH_CIRCUMFLEX 0x0109
-#define LATIN_CAPITAL_LETTER_C_WITH_DOT_ABOVE 0x010A
-#define LATIN_SMALL_LETTER_C_WITH_DOT_ABOVE 0x010B
-#define LATIN_CAPITAL_LETTER_C_WITH_CARON 0x010C
-#define LATIN_SMALL_LETTER_C_WITH_CARON 0x010D
-#define LATIN_CAPITAL_LETTER_D_WITH_CARON 0x010E
-#define LATIN_SMALL_LETTER_D_WITH_CARON 0x010F
-#define LATIN_CAPITAL_LETTER_D_WITH_STROKE 0x0110
-#define LATIN_SMALL_LETTER_D_WITH_STROKE 0x0111
-#define LATIN_CAPITAL_LETTER_E_WITH_MACRON 0x0112
-#define LATIN_SMALL_LETTER_E_WITH_MACRON 0x0113
-#define LATIN_CAPITAL_LETTER_E_WITH_BREVE 0x0114
-#define LATIN_SMALL_LETTER_E_WITH_BREVE 0x0115
-#define LATIN_CAPITAL_LETTER_E_WITH_DOT_ABOVE 0x0116
-#define LATIN_SMALL_LETTER_E_WITH_DOT_ABOVE 0x0117
-#define LATIN_CAPITAL_LETTER_E_WITH_OGONEK 0x0118
-#define LATIN_SMALL_LETTER_E_WITH_OGONEK 0x0119
-#define LATIN_CAPITAL_LETTER_E_WITH_CARON 0x011A
-#define LATIN_SMALL_LETTER_E_WITH_CARON 0x011B
-#define LATIN_CAPITAL_LETTER_G_WITH_CIRCUMFLEX 0x011C
-#define LATIN_SMALL_LETTER_G_WITH_CIRCUMFLEX 0x011D
-#define LATIN_CAPITAL_LETTER_G_WITH_BREVE 0x011E
-#define LATIN_SMALL_LETTER_G_WITH_BREVE 0x011F
-#define LATIN_CAPITAL_LETTER_G_WITH_DOT_ABOVE 0x0120
-#define LATIN_SMALL_LETTER_G_WITH_DOT_ABOVE 0x0121
-#define LATIN_CAPITAL_LETTER_G_WITH_CEDILLA 0x0122
-#define LATIN_SMALL_LETTER_G_WITH_CEDILLA 0x0123
-#define LATIN_CAPITAL_LETTER_H_WITH_CIRCUMFLEX 0x0124
-#define LATIN_SMALL_LETTER_H_WITH_CIRCUMFLEX 0x0125
-#define LATIN_CAPITAL_LETTER_H_WITH_STROKE 0x0126
-#define LATIN_SMALL_LETTER_H_WITH_STROKE 0x0127
-#define LATIN_CAPITAL_LETTER_I_WITH_TILDE 0x0128
-#define LATIN_SMALL_LETTER_I_WITH_TILDE 0x0129
-#define LATIN_CAPITAL_LETTER_I_WITH_MACRON 0x012A
-#define LATIN_SMALL_LETTER_I_WITH_MACRON 0x012B
-#define LATIN_CAPITAL_LETTER_I_WITH_BREVE 0x012C
-#define LATIN_SMALL_LETTER_I_WITH_BREVE 0x012D
-#define LATIN_CAPITAL_LETTER_I_WITH_OGONEK 0x012E
-#define LATIN_SMALL_LETTER_I_WITH_OGONEK 0x012F
-#define LATIN_CAPITAL_LETTER_I_WITH_DOT_ABOVE 0x0130
-#define LATIN_SMALL_LETTER_DOTLESS_I 0x0131
-#define LATIN_CAPITAL_LIGATURE_IJ 0x0132
-#define LATIN_SMALL_LIGATURE_IJ 0x0133
-#define LATIN_CAPITAL_LETTER_J_WITH_CIRCUMFLEX 0x0134
-#define LATIN_SMALL_LETTER_J_WITH_CIRCUMFLEX 0x0135
-#define LATIN_CAPITAL_LETTER_K_WITH_CEDILLA 0x0136
-#define LATIN_SMALL_LETTER_K_WITH_CEDILLA 0x0137
-#define LATIN_SMALL_LETTER_KRA 0x0138
-#define LATIN_CAPITAL_LETTER_L_WITH_ACUTE 0x0139
-#define LATIN_SMALL_LETTER_L_WITH_ACUTE 0x013A
-#define LATIN_CAPITAL_LETTER_L_WITH_CEDILLA 0x013B
-#define LATIN_SMALL_LETTER_L_WITH_CEDILLA 0x013C
-#define LATIN_CAPITAL_LETTER_L_WITH_CARON 0x013D
-#define LATIN_SMALL_LETTER_L_WITH_CARON 0x013E
-#define LATIN_CAPITAL_LETTER_L_WITH_MIDDLE_DOT 0x013F
-#define LATIN_SMALL_LETTER_L_WITH_MIDDLE_DOT 0x0140
-#define LATIN_CAPITAL_LETTER_L_WITH_STROKE 0x0141
-#define LATIN_SMALL_LETTER_L_WITH_STROKE 0x0142
-#define LATIN_CAPITAL_LETTER_N_WITH_ACUTE 0x0143
-#define LATIN_SMALL_LETTER_N_WITH_ACUTE 0x0144
-#define LATIN_CAPITAL_LETTER_N_WITH_CEDILLA 0x0145
-#define LATIN_SMALL_LETTER_N_WITH_CEDILLA 0x0146
-#define LATIN_CAPITAL_LETTER_N_WITH_CARON 0x0147
-#define LATIN_SMALL_LETTER_N_WITH_CARON 0x0148
-#define LATIN_SMALL_LETTER_N_PRECEDED_BY_APOSTROPHE 0x0149
-#define LATIN_CAPITAL_LETTER_ENG 0x014A
-#define LATIN_SMALL_LETTER_ENG 0x014B
-#define LATIN_CAPITAL_LETTER_O_WITH_MACRON 0x014C
-#define LATIN_SMALL_LETTER_O_WITH_MACRON 0x014D
-#define LATIN_CAPITAL_LETTER_O_WITH_BREVE 0x014E
-#define LATIN_SMALL_LETTER_O_WITH_BREVE 0x014F
-#define LATIN_CAPITAL_LETTER_O_WITH_DOUBLE_ACUTE 0x0150
-#define LATIN_SMALL_LETTER_O_WITH_DOUBLE_ACUTE 0x0151
-#define LATIN_CAPITAL_LIGATURE_OE 0x0152
-#define LATIN_SMALL_LIGATURE_OE 0x0153
-#define LATIN_CAPITAL_LETTER_R_WITH_ACUTE 0x0154
-#define LATIN_SMALL_LETTER_R_WITH_ACUTE 0x0155
-#define LATIN_CAPITAL_LETTER_R_WITH_CEDILLA 0x0156
-#define LATIN_SMALL_LETTER_R_WITH_CEDILLA 0x0157
-#define LATIN_CAPITAL_LETTER_R_WITH_CARON 0x0158
-#define LATIN_SMALL_LETTER_R_WITH_CARON 0x0159
-#define LATIN_CAPITAL_LETTER_S_WITH_ACUTE 0x015A
-#define LATIN_SMALL_LETTER_S_WITH_ACUTE 0x015B
-#define LATIN_CAPITAL_LETTER_S_WITH_CIRCUMFLEX 0x015C
-#define LATIN_SMALL_LETTER_S_WITH_CIRCUMFLEX 0x015D
-#define LATIN_CAPITAL_LETTER_S_WITH_CEDILLA 0x015E
-#define LATIN_SMALL_LETTER_S_WITH_CEDILLA 0x015F
-#define LATIN_CAPITAL_LETTER_S_WITH_CARON 0x0160
-#define LATIN_SMALL_LETTER_S_WITH_CARON 0x0161
-#define LATIN_CAPITAL_LETTER_T_WITH_CEDILLA 0x0162
-#define LATIN_SMALL_LETTER_T_WITH_CEDILLA 0x0163
-#define LATIN_CAPITAL_LETTER_T_WITH_CARON 0x0164
-#define LATIN_SMALL_LETTER_T_WITH_CARON 0x0165
-#define LATIN_CAPITAL_LETTER_T_WITH_STROKE 0x0166
-#define LATIN_SMALL_LETTER_T_WITH_STROKE 0x0167
-#define LATIN_CAPITAL_LETTER_U_WITH_TILDE 0x0168
-#define LATIN_SMALL_LETTER_U_WITH_TILDE 0x0169
-#define LATIN_CAPITAL_LETTER_U_WITH_MACRON 0x016A
-#define LATIN_SMALL_LETTER_U_WITH_MACRON 0x016B
-#define LATIN_CAPITAL_LETTER_U_WITH_BREVE 0x016C
-#define LATIN_SMALL_LETTER_U_WITH_BREVE 0x016D
-#define LATIN_CAPITAL_LETTER_U_WITH_RING_ABOVE 0x016E
-#define LATIN_SMALL_LETTER_U_WITH_RING_ABOVE 0x016F
-#define LATIN_CAPITAL_LETTER_U_WITH_DOUBLE_ACUTE 0x0170
-#define LATIN_SMALL_LETTER_U_WITH_DOUBLE_ACUTE 0x0171
-#define LATIN_CAPITAL_LETTER_U_WITH_OGONEK 0x0172
-#define LATIN_SMALL_LETTER_U_WITH_OGONEK 0x0173
-#define LATIN_CAPITAL_LETTER_W_WITH_CIRCUMFLEX 0x0174
-#define LATIN_SMALL_LETTER_W_WITH_CIRCUMFLEX 0x0175
-#define LATIN_CAPITAL_LETTER_Y_WITH_CIRCUMFLEX 0x0176
-#define LATIN_SMALL_LETTER_Y_WITH_CIRCUMFLEX 0x0177
-#define LATIN_CAPITAL_LETTER_Y_WITH_DIAERESIS 0x0178
-#define LATIN_CAPITAL_LETTER_Z_WITH_ACUTE 0x0179
-#define LATIN_SMALL_LETTER_Z_WITH_ACUTE 0x017A
-#define LATIN_CAPITAL_LETTER_Z_WITH_DOT_ABOVE 0x017B
-#define LATIN_SMALL_LETTER_Z_WITH_DOT_ABOVE 0x017C
-#define LATIN_CAPITAL_LETTER_Z_WITH_CARON 0x017D
-#define LATIN_SMALL_LETTER_Z_WITH_CARON 0x017E
-#define LATIN_SMALL_LETTER_LONG_S 0x017F
-
-/* latin extended B */
-#define LATIN_SMALL_LETTER_B_WITH_STROKE 0x0180
-#define LATIN_CAPITAL_LETTER_B_WITH_HOOK 0x0181
-#define LATIN_CAPITAL_LETTER_B_WITH_TOPBAR 0x0182
-#define LATIN_SMALL_LETTER_B_WITH_TOPBAR 0x0183
-#define LATIN_CAPITAL_LETTER_TONE_SIX 0x0184
-#define LATIN_SMALL_LETTER_TONE_SIX 0x0185
-#define LATIN_CAPITAL_LETTER_OPEN_O 0x0186
-#define LATIN_CAPITAL_LETTER_C_WITH_HOOK 0x0187
-#define LATIN_SMALL_LETTER_C_WITH_HOOK 0x0188
-#define LATIN_CAPITAL_LETTER_AFRICAN_D 0x0189
-#define LATIN_CAPITAL_LETTER_D_WITH_HOOK 0x018A
-#define LATIN_CAPITAL_LETTER_D_WITH_TOPBAR 0x018B
-#define LATIN_SMALL_LETTER_D_WITH_TOPBAR 0x018C
-#define LATIN_SMALL_LETTER_TURNED_DELTA 0x018D
-#define LATIN_CAPITAL_LETTER_REVERSED_E 0x018E
-#define LATIN_CAPITAL_LETTER_SCHWA 0x018F
-#define LATIN_CAPITAL_LETTER_OPEN_E 0x0190
-#define LATIN_CAPITAL_LETTER_F_WITH_HOOK 0x0191
-#define LATIN_SMALL_LETTER_F_WITH_HOOK 0x0192
-#define LATIN_CAPITAL_LETTER_G_WITH_HOOK 0x0193
-#define LATIN_CAPITAL_LETTER_GAMMA 0x0194
-#define LATIN_SMALL_LETTER_HV 0x0195
-#define LATIN_CAPITAL_LETTER_IOTA 0x0196
-#define LATIN_CAPITAL_LETTER_I_WITH_STROKE 0x0197
-#define LATIN_CAPITAL_LETTER_K_WITH_HOOK 0x0198
-#define LATIN_SMALL_LETTER_K_WITH_HOOK 0x0199
-#define LATIN_SMALL_LETTER_L_WITH_BAR 0x019A
-#define LATIN_SMALL_LETTER_LAMBDA_WITH_STROKE 0x019B
-#define LATIN_CAPITAL_LETTER_TURNED_M 0x019C
-#define LATIN_CAPITAL_LETTER_N_WITH_LEFT_HOOK 0x019D
-#define LATIN_SMALL_LETTER_N_WITH_LONG_RIGHT_LEG 0x019E
-#define LATIN_CAPITAL_LETTER_O_WITH_MIDDLE_TILDE 0x019F
-#define LATIN_CAPITAL_LETTER_O_WITH_HORN 0x01A0
-#define LATIN_SMALL_LETTER_O_WITH_HORN 0x01A1
-#define LATIN_CAPITAL_LETTER_OI 0x01A2
-#define LATIN_SMALL_LETTER_OI 0x01A3
-#define LATIN_CAPITAL_LETTER_P_WITH_HOOK 0x01A4
-#define LATIN_SMALL_LETTER_P_WITH_HOOK 0x01A5
-#define LATIN_LETTER_YR 0x01A6
-#define LATIN_CAPITAL_LETTER_TONE_TWO 0x01A7
-#define LATIN_SMALL_LETTER_TONE_TWO 0x01A8
-#define LATIN_CAPITAL_LETTER_ESH 0x01A9
-#define LATIN_LETTER_REVERSED_ESH_LOOP 0x01AA
-#define LATIN_SMALL_LETTER_T_WITH_PALATAL_HOOK 0x01AB
-#define LATIN_CAPITAL_LETTER_T_WITH_HOOK 0x01AC
-#define LATIN_SMALL_LETTER_T_WITH_HOOK 0x01AD
-#define LATIN_CAPITAL_LETTER_T_WITH_RETROFLEX_HOOK 0x01AE
-#define LATIN_CAPITAL_LETTER_U_WITH_HORN 0x01AF
-#define LATIN_SMALL_LETTER_U_WITH_HORN 0x01B0
-#define LATIN_CAPITAL_LETTER_UPSILON 0x01B1
-#define LATIN_CAPITAL_LETTER_V_WITH_HOOK 0x01B2
-#define LATIN_CAPITAL_LETTER_Y_WITH_HOOK 0x01B3
-#define LATIN_SMALL_LETTER_Y_WITH_HOOK 0x01B4
-#define LATIN_CAPITAL_LETTER_Z_WITH_STROKE 0x01B5
-#define LATIN_SMALL_LETTER_Z_WITH_STROKE 0x01B6
-#define LATIN_CAPITAL_LETTER_EZH 0x01B7
-#define LATIN_CAPITAL_LETTER_EZH_REVERSED 0x01B8
-#define LATIN_SMALL_LETTER_EZH_REVERSED 0x01B9
-#define LATIN_SMALL_LETTER_EZH_WITH_TAIL 0x01BA
-#define LATIN_LETTER_TWO_WITH_STROKE 0x01BB
-#define LATIN_CAPITAL_LETTER_TONE_FIVE 0x01BC
-#define LATIN_SMALL_LETTER_TONE_FIVE 0x01BD
-#define LATIN_LETTER_INVERTED_GLOTTAL_STOP_WITH_STROKE 0x01BE
-#define LATIN_LETTER_WYNN 0x01BF
-#define LATIN_LETTER_DENTAL_CLICK 0x01C0
-#define LATIN_LETTER_LATERAL_CLICK 0x01C1
-#define LATIN_LETTER_ALVEOLAR_CLICK 0x01C2
-#define LATIN_LETTER_RETROFLEX_CLICK 0x01C3
-#define LATIN_CAPITAL_LETTER_DZ_WITH_CARON 0x01C4
-#define LATIN_CAPITAL_LETTER_D_WITH_SMALL_LETTER_Z_WITH_CARON 0x01C5
-#define LATIN_SMALL_LETTER_DZ_WITH_CARON 0x01C6
-#define LATIN_CAPITAL_LETTER_LJ 0x01C7
-#define LATIN_CAPITAL_LETTER_L_WITH_SMALL_LETTER_J 0x01C8
-#define LATIN_SMALL_LETTER_LJ 0x01C9
-#define LATIN_CAPITAL_LETTER_NJ 0x01CA
-#define LATIN_CAPITAL_LETTER_N_WITH_SMALL_LETTER_J 0x01CB
-#define LATIN_SMALL_LETTER_NJ 0x01CC
-#define LATIN_CAPITAL_LETTER_A_WITH_CARON 0x01CD
-#define LATIN_SMALL_LETTER_A_WITH_CARON 0x01CE
-#define LATIN_CAPITAL_LETTER_I_WITH_CARON 0x01CF
-#define LATIN_SMALL_LETTER_I_WITH_CARON 0x01D0
-#define LATIN_CAPITAL_LETTER_O_WITH_CARON 0x01D1
-#define LATIN_SMALL_LETTER_O_WITH_CARON 0x01D2
-#define LATIN_CAPITAL_LETTER_U_WITH_CARON 0x01D3
-#define LATIN_SMALL_LETTER_U_WITH_CARON 0x01D4
-#define LATIN_CAPITAL_LETTER_U_WITH_DIAERESIS_AND_MACRON 0x01D5
-#define LATIN_SMALL_LETTER_U_WITH_DIAERESIS_AND_MACRON 0x01D6
-#define LATIN_CAPITAL_LETTER_U_WITH_DIAERESIS_AND_ACUTE 0x01D7
-#define LATIN_SMALL_LETTER_U_WITH_DIAERESIS_AND_ACUTE 0x01D8
-#define LATIN_CAPITAL_LETTER_U_WITH_DIAERESIS_AND_CARON 0x01D9
-#define LATIN_SMALL_LETTER_U_WITH_DIAERESIS_AND_CARON 0x01DA
-#define LATIN_CAPITAL_LETTER_U_WITH_DIAERESIS_AND_GRAVE 0x01DB
-#define LATIN_SMALL_LETTER_U_WITH_DIAERESIS_AND_GRAVE 0x01DC
-#define LATIN_SMALL_LETTER_TURNED_E 0x01DD
-#define LATIN_CAPITAL_LETTER_A_WITH_DIAERESIS_AND_MACRON 0x01DE
-#define LATIN_SMALL_LETTER_A_WITH_DIAERESIS_AND_MACRON 0x01DF
-#define LATIN_CAPITAL_LETTER_A_WITH_DOT_ABOVE_AND_MACRON 0x01E0
-#define LATIN_SMALL_LETTER_A_WITH_DOT_ABOVE_AND_MACRON 0x01E1
-#define LATIN_CAPITAL_LETTER_AE_WITH_MACRON 0x01E2
-#define LATIN_SMALL_LETTER_AE_WITH_MACRON 0x01E3
-#define LATIN_CAPITAL_LETTER_G_WITH_STROKE 0x01E4
-#define LATIN_SMALL_LETTER_G_WITH_STROKE 0x01E5
-#define LATIN_CAPITAL_LETTER_G_WITH_CARON 0x01E6
-#define LATIN_SMALL_LETTER_G_WITH_CARON 0x01E7
-#define LATIN_CAPITAL_LETTER_K_WITH_CARON 0x01E8
-#define LATIN_SMALL_LETTER_K_WITH_CARON 0x01E9
-#define LATIN_CAPITAL_LETTER_O_WITH_OGONEK 0x01EA
-#define LATIN_SMALL_LETTER_O_WITH_OGONEK 0x01EB
-#define LATIN_CAPITAL_LETTER_O_WITH_OGONEK_AND_MACRON 0x01EC
-#define LATIN_SMALL_LETTER_O_WITH_OGONEK_AND_MACRON 0x01ED
-#define LATIN_CAPITAL_LETTER_EZH_WITH_CARON 0x01EE
-#define LATIN_SMALL_LETTER_EZH_WITH_CARON 0x01EF
-#define LATIN_SMALL_LETTER_J_WITH_CARON 0x01F0
-#define LATIN_CAPITAL_LETTER_DZ 0x01F1
-#define LATIN_CAPITAL_LETTER_D_WITH_SMALL_LETTER_Z 0x01F2
-#define LATIN_SMALL_LETTER_DZ 0x01F3
-#define LATIN_CAPITAL_LETTER_G_WITH_ACUTE 0x01F4
-#define LATIN_SMALL_LETTER_G_WITH_ACUTE 0x01F5
-#define LATIN_CAPITAL_LETTER_HWAIR 0x01F6
-#define LATIN_CAPITAL_LETTER_WYNN 0x01F7
-#define LATIN_CAPITAL_LETTER_N_WITH_GRAVE 0x01F8
-#define LATIN_SMALL_LETTER_N_WITH_GRAVE 0x01F9
-#define LATIN_CAPITAL_LETTER_A_WITH_RING_ABOVE_AND_ACUTE 0x01FA
-#define LATIN_SMALL_LETTER_A_WITH_RING_ABOVE_AND_ACUTE 0x01FB
-#define LATIN_CAPITAL_LETTER_AE_WITH_ACUTE 0x01FC
-#define LATIN_SMALL_LETTER_AE_WITH_ACUTE 0x01FD
-#define LATIN_CAPITAL_LETTER_O_WITH_STROKE_AND_ACUTE 0x01FE
-#define LATIN_SMALL_LETTER_O_WITH_STROKE_AND_ACUTE 0x01FF
-#define LATIN_CAPITAL_LETTER_A_WITH_DOUBLE_GRAVE 0x0200
-#define LATIN_SMALL_LETTER_A_WITH_DOUBLE_GRAVE 0x0201
-#define LATIN_CAPITAL_LETTER_A_WITH_INVERTED_BREVE 0x0202
-#define LATIN_SMALL_LETTER_A_WITH_INVERTED_BREVE 0x0203
-#define LATIN_CAPITAL_LETTER_E_WITH_DOUBLE_GRAVE 0x0204
-#define LATIN_SMALL_LETTER_E_WITH_DOUBLE_GRAVE 0x0205
-#define LATIN_CAPITAL_LETTER_E_WITH_INVERTED_BREVE 0x0206
-#define LATIN_SMALL_LETTER_E_WITH_INVERTED_BREVE 0x0207
-#define LATIN_CAPITAL_LETTER_I_WITH_DOUBLE_GRAVE 0x0208
-#define LATIN_SMALL_LETTER_I_WITH_DOUBLE_GRAVE 0x0209
-#define LATIN_CAPITAL_LETTER_I_WITH_INVERTED_BREVE 0x020A
-#define LATIN_SMALL_LETTER_I_WITH_INVERTED_BREVE 0x020B
-#define LATIN_CAPITAL_LETTER_O_WITH_DOUBLE_GRAVE 0x020C
-#define LATIN_SMALL_LETTER_O_WITH_DOUBLE_GRAVE 0x020D
-#define LATIN_CAPITAL_LETTER_O_WITH_INVERTED_BREVE 0x020E
-#define LATIN_SMALL_LETTER_O_WITH_INVERTED_BREVE 0x020F
-#define LATIN_CAPITAL_LETTER_R_WITH_DOUBLE_GRAVE 0x0210
-#define LATIN_SMALL_LETTER_R_WITH_DOUBLE_GRAVE 0x0211
-#define LATIN_CAPITAL_LETTER_R_WITH_INVERTED_BREVE 0x0212
-#define LATIN_SMALL_LETTER_R_WITH_INVERTED_BREVE 0x0213
-#define LATIN_CAPITAL_LETTER_U_WITH_DOUBLE_GRAVE 0x0214
-#define LATIN_SMALL_LETTER_U_WITH_DOUBLE_GRAVE 0x0215
-#define LATIN_CAPITAL_LETTER_U_WITH_INVERTED_BREVE 0x0216
-#define LATIN_SMALL_LETTER_U_WITH_INVERTED_BREVE 0x0217
-#define LATIN_CAPITAL_LETTER_S_WITH_COMMA_BELOW 0x0218
-#define LATIN_SMALL_LETTER_S_WITH_COMMA_BELOW 0x0219
-#define LATIN_CAPITAL_LETTER_T_WITH_COMMA_BELOW 0x021A
-#define LATIN_SMALL_LETTER_T_WITH_COMMA_BELOW 0x021B
-#define LATIN_CAPITAL_LETTER_YOGH 0x021C
-#define LATIN_SMALL_LETTER_YOGH 0x021D
-#define LATIN_CAPITAL_LETTER_H_WITH_CARON 0x021E
-#define LATIN_SMALL_LETTER_H_WITH_CARON 0x021F
-#define LATIN_CAPITAL_LETTER_OU 0x0222
-#define LATIN_SMALL_LETTER_OU 0x0223
-#define LATIN_CAPITAL_LETTER_Z_WITH_HOOK 0x0224
-#define LATIN_SMALL_LETTER_Z_WITH_HOOK 0x0225
-#define LATIN_CAPITAL_LETTER_A_WITH_DOT_ABOVE 0x0226
-#define LATIN_SMALL_LETTER_A_WITH_DOT_ABOVE 0x0227
-#define LATIN_CAPITAL_LETTER_E_WITH_CEDILLA 0x0228
-#define LATIN_SMALL_LETTER_E_WITH_CEDILLA 0x0229
-#define LATIN_CAPITAL_LETTER_O_WITH_DIAERESIS_AND_MACRON 0x022A
-#define LATIN_SMALL_LETTER_O_WITH_DIAERESIS_AND_MACRON 0x022B
-#define LATIN_CAPITAL_LETTER_O_WITH_TILDE_AND_MACRON 0x022C
-#define LATIN_SMALL_LETTER_O_WITH_TILDE_AND_MACRON 0x022D
-#define LATIN_CAPITAL_LETTER_O_WITH_DOT_ABOVE 0x022E
-#define LATIN_SMALL_LETTER_O_WITH_DOT_ABOVE 0x022F
-#define LATIN_CAPITAL_LETTER_O_WITH_DOT_ABOVE_AND_MACRON 0x0230
-#define LATIN_SMALL_LETTER_O_WITH_DOT_ABOVE_AND_MACRON 0x0231
-#define LATIN_CAPITAL_LETTER_Y_WITH_MACRON 0x0232
-#define LATIN_SMALL_LETTER_Y_WITH_MACRON 0x0233
-
-/* IPA extensions */
-#define LATIN_SMALL_LETTER_TURNED_A 0x0250
-#define LATIN_SMALL_LETTER_ALPHA 0x0251
-#define LATIN_SMALL_LETTER_TURNED_ALPHA 0x0252
-#define LATIN_SMALL_LETTER_B_WITH_HOOK 0x0253
-#define LATIN_SMALL_LETTER_OPEN_O 0x0254
-#define LATIN_SMALL_LETTER_C_WITH_CURL 0x0255
-#define LATIN_SMALL_LETTER_D_WITH_TAIL 0x0256
-#define LATIN_SMALL_LETTER_D_WITH_HOOK 0x0257
-#define LATIN_SMALL_LETTER_REVERSED_E 0x0258
-#define LATIN_SMALL_LETTER_SCHWA 0x0259
-#define LATIN_SMALL_LETTER_SCHWA_WITH_HOOK 0x025A
-#define LATIN_SMALL_LETTER_OPEN_E 0x025B
-#define LATIN_SMALL_LETTER_REVERSED_OPEN_E 0x025C
-#define LATIN_SMALL_LETTER_REVERSED_OPEN_E_WITH_HOOK 0x025D
-#define LATIN_SMALL_LETTER_CLOSED_REVERSED_OPEN_E 0x025E
-#define LATIN_SMALL_LETTER_DOTLESS_J_WITH_STROKE 0x025F
-#define LATIN_SMALL_LETTER_G_WITH_HOOK 0x0260
-#define LATIN_SMALL_LETTER_SCRIPT_G 0x0261
-#define LATIN_LETTER_SMALL_CAPITAL_G 0x0262
-#define LATIN_SMALL_LETTER_GAMMA 0x0263
-#define LATIN_SMALL_LETTER_RAMS_HORN 0x0264
-#define LATIN_SMALL_LETTER_TURNED_H 0x0265
-#define LATIN_SMALL_LETTER_H_WITH_HOOK 0x0266
-#define LATIN_SMALL_LETTER_HENG_WITH_HOOK 0x0267
-#define LATIN_SMALL_LETTER_I_WITH_STROKE 0x0268
-#define LATIN_SMALL_LETTER_IOTA 0x0269
-#define LATIN_LETTER_SMALL_CAPITAL_I 0x026A
-#define LATIN_SMALL_LETTER_L_WITH_MIDDLE_TILDE 0x026B
-#define LATIN_SMALL_LETTER_L_WITH_BELT 0x026C
-#define LATIN_SMALL_LETTER_L_WITH_RETROFLEX_HOOK 0x026D
-#define LATIN_SMALL_LETTER_LEZH 0x026E
-#define LATIN_SMALL_LETTER_TURNED_M 0x026F
-#define LATIN_SMALL_LETTER_TURNED_M_WITH_LONG_LEG 0x0270
-#define LATIN_SMALL_LETTER_M_WITH_HOOK 0x0271
-#define LATIN_SMALL_LETTER_N_WITH_LEFT_HOOK 0x0272
-#define LATIN_SMALL_LETTER_N_WITH_RETROFLEX_HOOK 0x0273
-#define LATIN_LETTER_SMALL_CAPITAL_N 0x0274
-#define LATIN_SMALL_LETTER_BARRED_O 0x0275
-#define LATIN_LETTER_SMALL_CAPITAL_OE 0x0276
-#define LATIN_SMALL_LETTER_CLOSED_OMEGA 0x0277
-#define LATIN_SMALL_LETTER_PHI 0x0278
-#define LATIN_SMALL_LETTER_TURNED_R 0x0279
-#define LATIN_SMALL_LETTER_TURNED_R_WITH_LONG_LEG 0x027A
-#define LATIN_SMALL_LETTER_TURNED_R_WITH_HOOK 0x027B
-#define LATIN_SMALL_LETTER_R_WITH_LONG_LEG 0x027C
-#define LATIN_SMALL_LETTER_R_WITH_TAIL 0x027D
-#define LATIN_SMALL_LETTER_R_WITH_FISHHOOK 0x027E
-#define LATIN_SMALL_LETTER_REVERSED_R_WITH_FISHHOOK 0x027F
-#define LATIN_LETTER_SMALL_CAPITAL_R 0x0280
-#define LATIN_LETTER_SMALL_CAPITAL_INVERTED_R 0x0281
-#define LATIN_SMALL_LETTER_S_WITH_HOOK 0x0282
-#define LATIN_SMALL_LETTER_ESH 0x0283
-#define LATIN_SMALL_LETTER_DOTLESS_J_WITH_STROKE_AND_HOOK 0x0284
-#define LATIN_SMALL_LETTER_SQUAT_REVERSED_ESH 0x0285
-#define LATIN_SMALL_LETTER_ESH_WITH_CURL 0x0286
-#define LATIN_SMALL_LETTER_TURNED_T 0x0287
-#define LATIN_SMALL_LETTER_T_WITH_RETROFLEX_HOOK 0x0288
-#define LATIN_SMALL_LETTER_U_BAR 0x0289
-#define LATIN_SMALL_LETTER_UPSILON 0x028A
-#define LATIN_SMALL_LETTER_V_WITH_HOOK 0x028B
-#define LATIN_SMALL_LETTER_TURNED_V 0x028C
-#define LATIN_SMALL_LETTER_TURNED_W 0x028D
-#define LATIN_SMALL_LETTER_TURNED_Y 0x028E
-#define LATIN_LETTER_SMALL_CAPITAL_Y 0x028F
-#define LATIN_SMALL_LETTER_Z_WITH_RETROFLEX_HOOK 0x0290
-#define LATIN_SMALL_LETTER_Z_WITH_CURL 0x0291
-#define LATIN_SMALL_LETTER_EZH 0x0292
-#define LATIN_SMALL_LETTER_EZH_WITH_CURL 0x0293
-#define LATIN_LETTER_GLOTTAL_STOP 0x0294
-#define LATIN_LETTER_PHARYNGEAL_VOICED_FRICATIVE 0x0295
-#define LATIN_LETTER_INVERTED_GLOTTAL_STOP 0x0296
-#define LATIN_LETTER_STRETCHED_C 0x0297
-#define LATIN_LETTER_BILABIAL_CLICK 0x0298
-#define LATIN_LETTER_SMALL_CAPITAL_B 0x0299
-#define LATIN_SMALL_LETTER_CLOSED_OPEN_E 0x029A
-#define LATIN_LETTER_SMALL_CAPITAL_G_WITH_HOOK 0x029B
-#define LATIN_LETTER_SMALL_CAPITAL_H 0x029C
-#define LATIN_SMALL_LETTER_J_WITH_CROSSED_TAIL 0x029D
-#define LATIN_SMALL_LETTER_TURNED_K 0x029E
-#define LATIN_LETTER_SMALL_CAPITAL_L 0x029F
-#define LATIN_SMALL_LETTER_Q_WITH_HOOK 0x02A0
-#define LATIN_LETTER_GLOTTAL_STOP_WITH_STROKE 0x02A1
-#define LATIN_LETTER_REVERSED_GLOTTAL_STOP_WITH_STROKE 0x02A2
-#define LATIN_SMALL_LETTER_DZ_DIGRAPH 0x02A3
-#define LATIN_SMALL_LETTER_DEZH_DIGRAPH 0x02A4
-#define LATIN_SMALL_LETTER_DZ_DIGRAPH_WITH_CURL 0x02A5
-#define LATIN_SMALL_LETTER_TS_DIGRAPH 0x02A6
-#define LATIN_SMALL_LETTER_TESH_DIGRAPH 0x02A7
-#define LATIN_SMALL_LETTER_TC_DIGRAPH_WITH_CURL 0x02A8
-#define LATIN_SMALL_LETTER_FENG_DIGRAPH 0x02A9
-#define LATIN_SMALL_LETTER_LS_DIGRAPH 0x02AA
-#define LATIN_SMALL_LETTER_LZ_DIGRAPH 0x02AB
-#define LATIN_LETTER_BILABIAL_PERCUSSIVE 0x02AC
-#define LATIN_LETTER_BIDENTAL_PERCUSSIVE 0x02AD
-
-/* spacing modifier letters */
-#define MODIFIER_LETTER_SMALL_H 0x02B0
-#define MODIFIER_LETTER_SMALL_H_WITH_HOOK 0x02B1
-#define MODIFIER_LETTER_SMALL_J 0x02B2
-#define MODIFIER_LETTER_SMALL_R 0x02B3
-#define MODIFIER_LETTER_SMALL_TURNED_R 0x02B4
-#define MODIFIER_LETTER_SMALL_TURNED_R_WITH_HOOK 0x02B5
-#define MODIFIER_LETTER_SMALL_CAPITAL_INVERTED_R 0x02B6
-#define MODIFIER_LETTER_SMALL_W 0x02B7
-#define MODIFIER_LETTER_SMALL_Y 0x02B8
-#define MODIFIER_LETTER_PRIME 0x02B9
-#define MODIFIER_LETTER_DOUBLE_PRIME 0x02BA
-#define MODIFIER_LETTER_TURNED_COMMA 0x02BB
-#define MODIFIER_LETTER_APOSTROPHE 0x02BC
-#define MODIFIER_LETTER_REVERSED_COMMA 0x02BD
-#define MODIFIER_LETTER_RIGHT_HALF_RING 0x02BE
-#define MODIFIER_LETTER_LEFT_HALF_RING 0x02BF
-#define MODIFIER_LETTER_GLOTTAL_STOP 0x02C0
-#define MODIFIER_LETTER_REVERSED_GLOTTAL_STOP 0x02C1
-#define MODIFIER_LETTER_LEFT_ARROWHEAD 0x02C2
-#define MODIFIER_LETTER_RIGHT_ARROWHEAD 0x02C3
-#define MODIFIER_LETTER_UP_ARROWHEAD 0x02C4
-#define MODIFIER_LETTER_DOWN_ARROWHEAD 0x02C5
-#define MODIFIER_LETTER_CIRCUMFLEX_ACCENT 0x02C6
-#define CARON 0x02C7
-#define MODIFIER_LETTER_VERTICAL_LINE 0x02C8
-#define MODIFIER_LETTER_MACRON 0x02C9
-#define MODIFIER_LETTER_ACUTE_ACCENT 0x02CA
-#define MODIFIER_LETTER_GRAVE_ACCENT 0x02CB
-#define MODIFIER_LETTER_LOW_VERTICAL_LINE 0x02CC
-#define MODIFIER_LETTER_LOW_MACRON 0x02CD
-#define MODIFIER_LETTER_LOW_GRAVE_ACCENT 0x02CE
-#define MODIFIER_LETTER_LOW_ACUTE_ACCENT 0x02CF
-#define MODIFIER_LETTER_TRIANGULAR_COLON 0x02D0
-#define MODIFIER_LETTER_HALF_TRIANGULAR_COLON 0x02D1
-#define MODIFIER_LETTER_CENTRED_RIGHT_HALF_RING 0x02D2
-#define MODIFIER_LETTER_CENTRED_LEFT_HALF_RING 0x02D3
-#define MODIFIER_LETTER_UP_TACK 0x02D4
-#define MODIFIER_LETTER_DOWN_TACK 0x02D5
-#define MODIFIER_LETTER_PLUS_SIGN 0x02D6
-#define MODIFIER_LETTER_MINUS_SIGN 0x02D7
-#define BREVE 0x02D8
-#define DOT_ABOVE 0x02D9
-#define RING_ABOVE 0x02DA
-#define OGONEK 0x02DB
-#define SMALL_TILDE 0x02DC
-#define DOUBLE_ACUTE_ACCENT 0x02DD
-#define MODIFIER_LETTER_RHOTIC_HOOK 0x02DE
-#define MODIFIER_LETTER_CROSS_ACCENT 0x02DF
-#define MODIFIER_LETTER_SMALL_GAMMA 0x02E0
-#define MODIFIER_LETTER_SMALL_L 0x02E1
-#define MODIFIER_LETTER_SMALL_S 0x02E2
-#define MODIFIER_LETTER_SMALL_X 0x02E3
-#define MODIFIER_LETTER_SMALL_REVERSED_GLOTTAL_STOP 0x02E4
-#define MODIFIER_LETTER_EXTRA_HIGH_TONE_BAR 0x02E5
-#define MODIFIER_LETTER_HIGH_TONE_BAR 0x02E6
-#define MODIFIER_LETTER_MID_TONE_BAR 0x02E7
-#define MODIFIER_LETTER_LOW_TONE_BAR 0x02E8
-#define MODIFIER_LETTER_EXTRA_LOW_TONE_BAR 0x02E9
-#define MODIFIER_LETTER_YIN_DEPARTING_TONE_MARK 0x02EA
-#define MODIFIER_LETTER_YANG_DEPARTING_TONE_MARK 0x02EB
-#define MODIFIER_LETTER_VOICING 0x02EC
-#define MODIFIER_LETTER_UNASPIRATED 0x02ED
-#define MODIFIER_LETTER_DOUBLE_APOSTROPHE 0x02EE
-
-/* combining diacritical marks */
-#define COMBINING_GRAVE_ACCENT 0x0300
-#define COMBINING_ACUTE_ACCENT 0x0301
-#define COMBINING_CIRCUMFLEX_ACCENT 0x0302
-#define COMBINING_TILDE 0x0303
-#define COMBINING_MACRON 0x0304
-#define COMBINING_OVERLINE 0x0305
-#define COMBINING_BREVE 0x0306
-#define COMBINING_DOT_ABOVE 0x0307
-#define COMBINING_DIAERESIS 0x0308
-#define COMBINING_HOOK_ABOVE 0x0309
-#define COMBINING_RING_ABOVE 0x030A
-#define COMBINING_DOUBLE_ACUTE_ACCENT 0x030B
-#define COMBINING_CARON 0x030C
-#define COMBINING_VERTICAL_LINE_ABOVE 0x030D
-#define COMBINING_DOUBLE_VERTICAL_LINE_ABOVE 0x030E
-#define COMBINING_DOUBLE_GRAVE_ACCENT 0x030F
-#define COMBINING_CANDRABINDU 0x0310
-#define COMBINING_INVERTED_BREVE 0x0311
-#define COMBINING_TURNED_COMMA_ABOVE 0x0312
-#define COMBINING_COMMA_ABOVE 0x0313
-#define COMBINING_REVERSED_COMMA_ABOVE 0x0314
-#define COMBINING_COMMA_ABOVE_RIGHT 0x0315
-#define COMBINING_GRAVE_ACCENT_BELOW 0x0316
-#define COMBINING_ACUTE_ACCENT_BELOW 0x0317
-#define COMBINING_LEFT_TACK_BELOW 0x0318
-#define COMBINING_RIGHT_TACK_BELOW 0x0319
-#define COMBINING_LEFT_ANGLE_ABOVE 0x031A
-#define COMBINING_HORN 0x031B
-#define COMBINING_LEFT_HALF_RING_BELOW 0x031C
-#define COMBINING_UP_TACK_BELOW 0x031D
-#define COMBINING_DOWN_TACK_BELOW 0x031E
-#define COMBINING_PLUS_SIGN_BELOW 0x031F
-#define COMBINING_MINUS_SIGN_BELOW 0x0320
-#define COMBINING_PALATALIZED_HOOK_BELOW 0x0321
-#define COMBINING_RETROFLEX_HOOK_BELOW 0x0322
-#define COMBINING_DOT_BELOW 0x0323
-#define COMBINING_DIAERESIS_BELOW 0x0324
-#define COMBINING_RING_BELOW 0x0325
-#define COMBINING_COMMA_BELOW 0x0326
-#define COMBINING_CEDILLA 0x0327
-#define COMBINING_OGONEK 0x0328
-#define COMBINING_VERTICAL_LINE_BELOW 0x0329
-#define COMBINING_BRIDGE_BELOW 0x032A
-#define COMBINING_INVERTED_DOUBLE_ARCH_BELOW 0x032B
-#define COMBINING_CARON_BELOW 0x032C
-#define COMBINING_CIRCUMFLEX_ACCENT_BELOW 0x032D
-#define COMBINING_BREVE_BELOW 0x032E
-#define COMBINING_INVERTED_BREVE_BELOW 0x032F
-#define COMBINING_TILDE_BELOW 0x0330
-#define COMBINING_MACRON_BELOW 0x0331
-#define COMBINING_LOW_LINE 0x0332
-#define COMBINING_DOUBLE_LOW_LINE 0x0333
-#define COMBINING_TILDE_OVERLAY 0x0334
-#define COMBINING_SHORT_STROKE_OVERLAY 0x0335
-#define COMBINING_LONG_STROKE_OVERLAY 0x0336
-#define COMBINING_SHORT_SOLIDUS_OVERLAY 0x0337
-#define COMBINING_LONG_SOLIDUS_OVERLAY 0x0338
-#define COMBINING_RIGHT_HALF_RING_BELOW 0x0339
-#define COMBINING_INVERTED_BRIDGE_BELOW 0x033A
-#define COMBINING_SQUARE_BELOW 0x033B
-#define COMBINING_SEAGULL_BELOW 0x033C
-#define COMBINING_X_ABOVE 0x033D
-#define COMBINING_VERTICAL_TILDE 0x033E
-#define COMBINING_DOUBLE_OVERLINE 0x033F
-#define COMBINING_GRAVE_TONE_MARK 0x0340
-#define COMBINING_ACUTE_TONE_MARK 0x0341
-#define COMBINING_GREEK_PERISPOMENI 0x0342
-#define COMBINING_GREEK_KORONIS 0x0343
-#define COMBINING_GREEK_DIALYTIKA_TONOS 0x0344
-#define COMBINING_GREEK_YPOGEGRAMMENI 0x0345
-#define COMBINING_BRIDGE_ABOVE 0x0346
-#define COMBINING_EQUALS_SIGN_BELOW 0x0347
-#define COMBINING_DOUBLE_VERTICAL_LINE_BELOW 0x0348
-#define COMBINING_LEFT_ANGLE_BELOW 0x0349
-#define COMBINING_NOT_TILDE_ABOVE 0x034A
-#define COMBINING_HOMOTHETIC_ABOVE 0x034B
-#define COMBINING_ALMOST_EQUAL_TO_ABOVE 0x034C
-#define COMBINING_LEFT_RIGHT_ARROW_BELOW 0x034D
-#define COMBINING_UPWARDS_ARROW_BELOW 0x034E
-#define COMBINING_DOUBLE_TILDE 0x0360
-#define COMBINING_DOUBLE_INVERTED_BREVE 0x0361
-#define COMBINING_DOUBLE_RIGHTWARDS_ARROW_BELOW 0x0362
-
-/* greek letters */
-#define GREEK_NUMERAL_SIGN 0x0374
-#define GREEK_LOWER_NUMERAL_SIGN 0x0375
-#define GREEK_YPOGEGRAMMENI 0x037A
-#define GREEK_QUESTION_MARK 0x037E
-#define GREEK_TONOS 0x0384
-#define GREEK_DIALYTIKA_TONOS 0x0385
-#define GREEK_CAPITAL_LETTER_ALPHA_WITH_TONOS 0x0386
-#define GREEK_ANO_TELEIA 0x0387
-#define GREEK_CAPITAL_LETTER_EPSILON_WITH_TONOS 0x0388
-#define GREEK_CAPITAL_LETTER_ETA_WITH_TONOS 0x0389
-#define GREEK_CAPITAL_LETTER_IOTA_WITH_TONOS 0x038A
-#define GREEK_CAPITAL_LETTER_OMICRON_WITH_TONOS 0x038C
-#define GREEK_CAPITAL_LETTER_UPSILON_WITH_TONOS 0x038E
-#define GREEK_CAPITAL_LETTER_OMEGA_WITH_TONOS 0x038F
-#define GREEK_SMALL_LETTER_IOTA_WITH_DIALYTIKA_AND_TONOS 0x0390
-#define GREEK_CAPITAL_LETTER_ALPHA 0x0391
-#define GREEK_CAPITAL_LETTER_BETA 0x0392
-#define GREEK_CAPITAL_LETTER_GAMMA 0x0393
-#define GREEK_CAPITAL_LETTER_DELTA 0x0394
-#define GREEK_CAPITAL_LETTER_EPSILON 0x0395
-#define GREEK_CAPITAL_LETTER_ZETA 0x0396
-#define GREEK_CAPITAL_LETTER_ETA 0x0397
-#define GREEK_CAPITAL_LETTER_THETA 0x0398
-#define GREEK_CAPITAL_LETTER_IOTA 0x0399
-#define GREEK_CAPITAL_LETTER_KAPPA 0x039A
-#define GREEK_CAPITAL_LETTER_LAMDA 0x039B
-#define GREEK_CAPITAL_LETTER_MU 0x039C
-#define GREEK_CAPITAL_LETTER_NU 0x039D
-#define GREEK_CAPITAL_LETTER_XI 0x039E
-#define GREEK_CAPITAL_LETTER_OMICRON 0x039F
-#define GREEK_CAPITAL_LETTER_PI 0x03A0
-#define GREEK_CAPITAL_LETTER_RHO 0x03A1
-#define GREEK_CAPITAL_LETTER_SIGMA 0x03A3
-#define GREEK_CAPITAL_LETTER_TAU 0x03A4
-#define GREEK_CAPITAL_LETTER_UPSILON 0x03A5
-#define GREEK_CAPITAL_LETTER_PHI 0x03A6
-#define GREEK_CAPITAL_LETTER_CHI 0x03A7
-#define GREEK_CAPITAL_LETTER_PSI 0x03A8
-#define GREEK_CAPITAL_LETTER_OMEGA 0x03A9
-#define GREEK_CAPITAL_LETTER_IOTA_WITH_DIALYTIKA 0x03AA
-#define GREEK_CAPITAL_LETTER_UPSILON_WITH_DIALYTIKA 0x03AB
-#define GREEK_SMALL_LETTER_ALPHA_WITH_TONOS 0x03AC
-#define GREEK_SMALL_LETTER_EPSILON_WITH_TONOS 0x03AD
-#define GREEK_SMALL_LETTER_ETA_WITH_TONOS 0x03AE
-#define GREEK_SMALL_LETTER_IOTA_WITH_TONOS 0x03AF
-#define GREEK_SMALL_LETTER_UPSILON_WITH_DIALYTIKA_AND_TONOS 0x03B0
-#define GREEK_SMALL_LETTER_ALPHA 0x03B1
-#define GREEK_SMALL_LETTER_BETA 0x03B2
-#define GREEK_SMALL_LETTER_GAMMA 0x03B3
-#define GREEK_SMALL_LETTER_DELTA 0x03B4
-#define GREEK_SMALL_LETTER_EPSILON 0x03B5
-#define GREEK_SMALL_LETTER_ZETA 0x03B6
-#define GREEK_SMALL_LETTER_ETA 0x03B7
-#define GREEK_SMALL_LETTER_THETA 0x03B8
-#define GREEK_SMALL_LETTER_IOTA 0x03B9
-#define GREEK_SMALL_LETTER_KAPPA 0x03BA
-#define GREEK_SMALL_LETTER_LAMDA 0x03BB
-#define GREEK_SMALL_LETTER_MU 0x03BC
-#define GREEK_SMALL_LETTER_NU 0x03BD
-#define GREEK_SMALL_LETTER_XI 0x03BE
-#define GREEK_SMALL_LETTER_OMICRON 0x03BF
-#define GREEK_SMALL_LETTER_PI 0x03C0
-#define GREEK_SMALL_LETTER_RHO 0x03C1
-#define GREEK_SMALL_LETTER_FINAL_SIGMA 0x03C2
-#define GREEK_SMALL_LETTER_SIGMA 0x03C3
-#define GREEK_SMALL_LETTER_TAU 0x03C4
-#define GREEK_SMALL_LETTER_UPSILON 0x03C5
-#define GREEK_SMALL_LETTER_PHI 0x03C6
-#define GREEK_SMALL_LETTER_CHI 0x03C7
-#define GREEK_SMALL_LETTER_PSI 0x03C8
-#define GREEK_SMALL_LETTER_OMEGA 0x03C9
-#define GREEK_SMALL_LETTER_IOTA_WITH_DIALYTIKA 0x03CA
-#define GREEK_SMALL_LETTER_UPSILON_WITH_DIALYTIKA 0x03CB
-#define GREEK_SMALL_LETTER_OMICRON_WITH_TONOS 0x03CC
-#define GREEK_SMALL_LETTER_UPSILON_WITH_TONOS 0x03CD
-#define GREEK_SMALL_LETTER_OMEGA_WITH_TONOS 0x03CE
-#define GREEK_BETA_SYMBOL 0x03D0
-#define GREEK_THETA_SYMBOL 0x03D1
-#define GREEK_UPSILON_WITH_HOOK_SYMBOL 0x03D2
-#define GREEK_UPSILON_WITH_ACUTE_AND_HOOK_SYMBOL 0x03D3
-#define GREEK_UPSILON_WITH_DIAERESIS_AND_HOOK_SYMBOL 0x03D4
-#define GREEK_PHI_SYMBOL 0x03D5
-#define GREEK_PI_SYMBOL 0x03D6
-#define GREEK_KAI_SYMBOL 0x03D7
-#define GREEK_LETTER_STIGMA 0x03DA
-#define GREEK_SMALL_LETTER_STIGMA 0x03DB
-#define GREEK_LETTER_DIGAMMA 0x03DC
-#define GREEK_SMALL_LETTER_DIGAMMA 0x03DD
-#define GREEK_LETTER_KOPPA 0x03DE
-#define GREEK_SMALL_LETTER_KOPPA 0x03DF
-#define GREEK_LETTER_SAMPI 0x03E0
-#define GREEK_SMALL_LETTER_SAMPI 0x03E1
-
-/* general punctuation (partial) */
-#define HYPHEN 0x2010
-#define NON_BREAKING_HYPHEN 0x2011
-#define FIGURE_DASH 0x2012
-#define EN_DASH 0x2013
-#define EM_DASH 0x2014
-#define HORIZONTAL_BAR 0x2015
-#define LEFT_SINGLE_QUOTATION_MARK 0x2018
-#define RIGHT_SINGLE_QUOTATION_MARK 0x2019
-#define SINGLE_LOW_9_QUOTATION_MARK 0x201A
-#define SINGLE_HIGH_REVERSED_9_QUOTATION_MARK 0x201B
-#define LEFT_DOUBLE_QUOTATION_MARK 0x201C
-#define RIGHT_DOUBLE_QUOTATION_MARK 0x201D
-#define DOUBLE_LOW_9_QUOTATION_MARK 0x201E
-#define DOUBLE_HIGH_REVERSED_9_QUOTATION_MARK 0x201F
-#define DAGGER 0x2020
-#define DOUBLE_DAGGER 0x2021
-#define BULLET 0x2022
-#define TRIANGULAR_BULLET 0x2023
-#define HYPHENATION_POINT 0x2027
-#define HORIZONTAL_ELLIPSIS 0x2026
-#define PER_MILLE_SIGN 0x2030
-#define SINGLE_LEFT_POINTING_ANGLE_QUOTATION_MARK 0x2039
-#define SINGLE_RIGHT_POINTING_ANGLE_QUOTATION_MARK 0x203A
-#define EURO_CURRENCY_SIGN 0x20AC
-
-/* mathematical operators */
-#define FOR_ALL 0x2200
-#define COMPLEMENT 0x2201
-#define PARTIAL_DIFFERENTIAL 0x2202
-#define THERE_EXISTS 0x2203
-#define THERE_DOES_NOT_EXIST 0x2204
-#define EMPTY_SET 0x2205
-#define INCREMENT 0x2206
-#define NABLA 0x2207
-#define ELEMENT_OF 0x2208
-#define NOT_AN_ELEMENT_OF 0x2209
-#define SMALL_ELEMENT_OF 0x220A
-#define CONTAINS_AS_MEMBER 0x220B
-#define DOES_NOT_CONTAIN_AS_MEMBER 0x220C
-#define SMALL_CONTAINS_AS_MEMBER 0x220D
-#define END_OF_PROOF 0x220E
-#define N_ARY_PRODUCT 0x220F
-#define N_ARY_COPRODUCT 0x2210
-#define N_ARY_SUMMATION 0x2211
-#define MINUS_SIGN 0x2212
-#define MINUS_OR_PLUS_SIGN 0x2213
-#define DOT_PLUS 0x2214
-#define DIVISION_SLASH 0x2215
-#define SET_MINUS 0x2216
-#define ASTERISK_OPERATOR 0x2217
-#define RING_OPERATOR 0x2218
-#define BULLET_OPERATOR 0x2219
-#define SQUARE_ROOT 0x221A
-#define CUBE_ROOT 0x221B
-#define FOURTH_ROOT 0x221C
-#define PROPORTIONAL_TO 0x221D
-/* INFINITY conflicts with math.h */
-#define INFINITY 0x221E
-#define RIGHT_ANGLE 0x221F
-#define ANGLE 0x2220
-#define MEASURED_ANGLE 0x2221
-#define SPHERICAL_ANGLE 0x2222
-#define DIVIDES 0x2223
-#define DOES_NOT_DIVIDE 0x2224
-#define PARALLEL_TO 0x2225
-#define NOT_PARALLEL_TO 0x2226
-#define LOGICAL_AND 0x2227
-#define LOGICAL_OR 0x2228
-#define INTERSECTION 0x2229
-#define UNION 0x222A
-#define INTEGRAL 0x222B
-#define DOUBLE_INTEGRAL 0x222C
-#define TRIPLE_INTEGRAL 0x222D
-#define CONTOUR_INTEGRAL 0x222E
-#define SURFACE_INTEGRAL 0x222F
-#define VOLUME_INTEGRAL 0x2230
-#define CLOCKWISE_INTEGRAL 0x2231
-#define CLOCKWISE_CONTOUR_INTEGRAL 0x2232
-#define ANTICLOCKWISE_CONTOUR_INTEGRAL 0x2233
-#define THEREFORE 0x2234
-#define BECAUSE 0x2235
-#define RATIO 0x2236
-#define PROPORTION 0x2237
-#define DOT_MINUS 0x2238
-#define EXCESS 0x2239
-#define GEOMETRIC_PROPORTION 0x223A
-#define HOMOTHETIC 0x223B
-#define TILDE_OPERATOR 0x223C
-#define REVERSED_TILDE 0x223D
-#define INVERTED_LAZY_S 0x223E
-#define SINE_WAVE 0x223F
-#define WREATH_PRODUCT 0x2240
-#define NOT_TILDE 0x2241
-#define MINUS_TILDE 0x2242
-#define ASYMPTOTICALLY_EQUAL_TO 0x2243
-#define NOT_ASYMPTOTICALLY_EQUAL_TO 0x2244
-#define APPROXIMATELY_EQUAL_TO 0x2245
-#define APPROXIMATELY_BUT_NOT_ACTUALLY_EQUAL_TO 0x2246
-#define NEITHER_APPROXIMATELY_NOR_ACTUALLY_EQUAL_TO 0x2247
-#define ALMOST_EQUAL_TO 0x2248
-#define NOT_ALMOST_EQUAL_TO 0x2249
-#define ALMOST_EQUAL_OR_EQUAL_TO 0x224A
-#define TRIPLE_TILDE 0x224B
-#define ALL_EQUAL_TO 0x224C
-#define EQUIVALENT_TO 0x224D
-#define GEOMETRICALLY_EQUIVALENT_TO 0x224E
-#define DIFFERENCE_BETWEEN 0x224F
-#define APPROACHES_THE_LIMIT 0x2250
-#define GEOMETRICALLY_EQUAL_TO 0x2251
-#define APPROXIMATELY_EQUAL_TO_OR_THE_IMAGE_OF 0x2252
-#define IMAGE_OF_OR_APPROXIMATELY_EQUAL_TO 0x2253
-#define COLON_EQUALS 0x2254
-#define EQUALS_COLON 0x2255
-#define RING_IN_EQUAL_TO 0x2256
-#define RING_EQUAL_TO 0x2257
-#define CORRESPONDS_TO 0x2258
-#define ESTIMATES 0x2259
-#define EQUIANGULAR_TO 0x225A
-#define STAR_EQUALS 0x225B
-#define DELTA_EQUAL_TO 0x225C
-#define EQUAL_TO_BY_DEFINITION 0x225D
-#define MEASURED_BY 0x225E
-#define QUESTIONED_EQUAL_TO 0x225F
-#define NOT_EQUAL_TO 0x2260
-#define IDENTICAL_TO 0x2261
-#define NOT_IDENTICAL_TO 0x2262
-#define STRICTLY_EQUIVALENT_TO 0x2263
-#define LESS_THAN_OR_EQUAL_TO 0x2264
-#define GREATER_THAN_OR_EQUAL_TO 0x2265
-#define LESS_THAN_OVER_EQUAL_TO 0x2266
-#define GREATER_THAN_OVER_EQUAL_TO 0x2267
-#define LESS_THAN_BUT_NOT_EQUAL_TO 0x2268
-#define GREATER_THAN_BUT_NOT_EQUAL_TO 0x2269
-#define MUCH_LESS_THAN 0x226A
-#define MUCH_GREATER_THAN 0x226B
-#define BETWEEN 0x226C
-#define NOT_EQUIVALENT_TO 0x226D
-#define NOT_LESS_THAN 0x226E
-#define NOT_GREATER_THAN 0x226F
-#define NEITHER_LESS_THAN_NOR_EQUAL_TO 0x2270
-#define NEITHER_GREATER_THAN_NOR_EQUAL_TO 0x2271
-#define LESS_THAN_OR_EQUIVALENT_TO 0x2272
-#define GREATER_THAN_OR_EQUIVALENT_TO 0x2273
-#define NEITHER_LESS_THAN_NOR_EQUIVALENT_TO 0x2274
-#define NEITHER_GREATER_THAN_NOR_EQUIVALENT_TO 0x2275
-#define LESS_THAN_OR_GREATER_THAN 0x2276
-#define GREATER_THAN_OR_LESS_THAN 0x2277
-#define NEITHER_LESS_THAN_NOR_GREATER_THAN 0x2278
-#define NEITHER_GREATER_THAN_NOR_LESS_THAN 0x2279
-#define PRECEDES 0x227A
-#define SUCCEEDS 0x227B
-#define PRECEDES_OR_EQUAL_TO 0x227C
-#define SUCCEEDS_OR_EQUAL_TO 0x227D
-#define PRECEDES_OR_EQUIVALENT_TO 0x227E
-#define SUCCEEDS_OR_EQUIVALENT_TO 0x227F
-#define DOES_NOT_PRECEDE 0x2280
-#define DOES_NOT_SUCCEED 0x2281
-#define SUBSET_OF 0x2282
-#define SUPERSET_OF 0x2283
-#define NOT_A_SUBSET_OF 0x2284
-#define NOT_A_SUPERSET_OF 0x2285
-#define SUBSET_OF_OR_EQUAL_TO 0x2286
-#define SUPERSET_OF_OR_EQUAL_TO 0x2287
-#define NEITHER_A_SUBSET_OF_NOR_EQUAL_TO 0x2288
-#define NEITHER_A_SUPERSET_OF_NOR_EQUAL_TO 0x2289
-#define SUBSET_OF_WITH_NOT_EQUAL_TO 0x228A
-#define SUPERSET_OF_WITH_NOT_EQUAL_TO 0x228B
-#define MULTISET 0x228C
-#define MULTISET_MULTIPLICATION 0x228D
-#define MULTISET_UNION 0x228E
-#define SQUARE_IMAGE_OF 0x228F
-#define SQUARE_ORIGINAL_OF 0x2290
-#define SQUARE_IMAGE_OF_OR_EQUAL_TO 0x2291
-#define SQUARE_ORIGINAL_OF_OR_EQUAL_TO 0x2292
-#define SQUARE_CAP 0x2293
-#define SQUARE_CUP 0x2294
-#define CIRCLED_PLUS 0x2295
-#define CIRCLED_MINUS 0x2296
-#define CIRCLED_TIMES 0x2297
-#define CIRCLED_DIVISION_SLASH 0x2298
-#define CIRCLED_DOT_OPERATOR 0x2299
-#define CIRCLED_RING_OPERATOR 0x229A
-#define CIRCLED_ASTERISK_OPERATOR 0x229B
-#define CIRCLED_EQUALS 0x229C
-#define CIRCLED_DASH 0x229D
-#define SQUARED_PLUS 0x229E
-#define SQUARED_MINUS 0x229F
-#define SQUARED_TIMES 0x22A0
-#define SQUARED_DOT_OPERATOR 0x22A1
-#define RIGHT_TACK 0x22A2
-#define LEFT_TACK 0x22A3
-#define DOWN_TACK 0x22A4
-#define UP_TACK 0x22A5
-#define ASSERTION 0x22A6
-#define MODELS 0x22A7
-#define TRUEx 0x22A8
-#define FORCES 0x22A9
-#define TRIPLE_VERTICAL_BAR_RIGHT_TURNSTILE 0x22AA
-#define DOUBLE_VERTICAL_BAR_DOUBLE_RIGHT_TURNSTILE 0x22AB
-#define DOES_NOT_PROVE 0x22AC
-#define NOT_TRUE 0x22AD
-#define DOES_NOT_FORCE 0x22AE
-#define NEGATED_DOUBLE_VERTICAL_BAR_DOUBLE_RIGHT_TURNSTILE 0x22AF
-#define PRECEDES_UNDER_RELATION 0x22B0
-#define SUCCEEDS_UNDER_RELATION 0x22B1
-#define NORMAL_SUBGROUP_OF 0x22B2
-#define CONTAINS_AS_NORMAL_SUBGROUP 0x22B3
-#define NORMAL_SUBGROUP_OF_OR_EQUAL_TO 0x22B4
-#define CONTAINS_AS_NORMAL_SUBGROUP_OR_EQUAL_TO 0x22B5
-#define ORIGINAL_OF 0x22B6
-#define IMAGE_OF 0x22B7
-#define MULTIMAP 0x22B8
-#define HERMITIAN_CONJUGATE_MATRIX 0x22B9
-#define INTERCALATE 0x22BA
-#define XOR 0x22BB
-#define NAND 0x22BC
-#define NOR 0x22BD
-#define RIGHT_ANGLE_WITH_ARC 0x22BE
-#define RIGHT_TRIANGLE 0x22BF
-#define N_ARY_LOGICAL_AND 0x22C0
-#define N_ARY_LOGICAL_OR 0x22C1
-#define N_ARY_INTERSECTION 0x22C2
-#define N_ARY_UNION 0x22C3
-#define DIAMOND_OPERATOR 0x22C4
-#define DOT_OPERATOR 0x22C5
-#define STAR_OPERATOR 0x22C6
-#define DIVISION_TIMES 0x22C7
-#define BOWTIE 0x22C8
-#define LEFT_NORMAL_FACTOR_SEMIDIRECT_PRODUCT 0x22C9
-#define RIGHT_NORMAL_FACTOR_SEMIDIRECT_PRODUCT 0x22CA
-#define LEFT_SEMIDIRECT_PRODUCT 0x22CB
-#define RIGHT_SEMIDIRECT_PRODUCT 0x22CC
-#define REVERSED_TILDE_EQUALS 0x22CD
-#define CURLY_LOGICAL_OR 0x22CE
-#define CURLY_LOGICAL_AND 0x22CF
-#define DOUBLE_SUBSET 0x22D0
-#define DOUBLE_SUPERSET 0x22D1
-#define DOUBLE_INTERSECTION 0x22D2
-#define DOUBLE_UNION 0x22D3
-#define PITCHFORK 0x22D4
-#define EQUAL_AND_PARALLEL_TO 0x22D5
-#define LESS_THAN_WITH_DOT 0x22D6
-#define GREATER_THAN_WITH_DOT 0x22D7
-#define VERY_MUCH_LESS_THAN 0x22D8
-#define VERY_MUCH_GREATER_THAN 0x22D9
-#define LESS_THAN_EQUAL_TO_OR_GREATER_THAN 0x22DA
-#define GREATER_THAN_EQUAL_TO_OR_LESS_THAN 0x22DB
-#define EQUAL_TO_OR_LESS_THAN 0x22DC
-#define EQUAL_TO_OR_GREATER_THAN 0x22DD
-#define EQUAL_TO_OR_PRECEDES 0x22DE
-#define EQUAL_TO_OR_SUCCEEDS 0x22DF
-#define DOES_NOT_PRECEDE_OR_EQUAL 0x22E0
-#define DOES_NOT_SUCCEED_OR_EQUAL 0x22E1
-#define NOT_SQUARE_IMAGE_OF_OR_EQUAL_TO 0x22E2
-#define NOT_SQUARE_ORIGINAL_OF_OR_EQUAL_TO 0x22E3
-#define SQUARE_IMAGE_OF_OR_NOT_EQUAL_TO 0x22E4
-#define SQUARE_ORIGINAL_OF_OR_NOT_EQUAL_TO 0x22E5
-#define LESS_THAN_BUT_NOT_EQUIVALENT_TO 0x22E6
-#define GREATER_THAN_BUT_NOT_EQUIVALENT_TO 0x22E7
-#define PRECEDES_BUT_NOT_EQUIVALENT_TO 0x22E8
-#define SUCCEEDS_BUT_NOT_EQUIVALENT_TO 0x22E9
-#define NOT_NORMAL_SUBGROUP_OF 0x22EA
-#define DOES_NOT_CONTAIN_AS_NORMAL_SUBGROUP 0x22EB
-#define NOT_NORMAL_SUBGROUP_OF_OR_EQUAL_TO 0x22EC
-#define DOES_NOT_CONTAIN_AS_NORMAL_SUBGROUP_OR_EQUAL 0x22ED
-#define VERTICAL_ELLIPSIS 0x22EE
-#define MIDLINE_HORIZONTAL_ELLIPSIS 0x22EF
-#define UP_RIGHT_DIAGONAL_ELLIPSIS 0x22F0
-#define DOWN_RIGHT_DIAGONAL_ELLIPSIS 0x22F1
-
-/* Optical Character Recognition in Unicode (see wikipedia/OCR)
- * range: 0x2440-0x245F
- */
-#define OCR_Hook 0x2440
-#define OCR_Chair 0x2441
-#define OCR_Fork 0x2442
-#define OCR_Inverted_Fork 0x2443
-#define OCR_Belt_Buckle 0x2444
-#define OCR_Bow_Tie 0x2445
-
-/* the following 4 MICR chars (magnetic ink character recognition)
- * They look like: |: ,|' ||' ||| (known also as MICR-A,B,C,D)
- */
-#define OCR_Branch_Bank_Identification 0x2446
-#define OCR_Amount_Of_Check 0x2447
-#define OCR_Customer_Account_Number 0x2448
-#define OCR_Dash 0x2449
-
-#define OCR_Double_Backslash 0x244A
-
-/* latin ligatures */
-#define LATIN_SMALL_LIGATURE_FF 0xFB00
-#define LATIN_SMALL_LIGATURE_FI 0xFB01
-#define LATIN_SMALL_LIGATURE_FL 0xFB02
-#define LATIN_SMALL_LIGATURE_FFI 0xFB03
-#define LATIN_SMALL_LIGATURE_FFL 0xFB04
-#define LATIN_SMALL_LIGATURE_LONG_S_T 0xFB05
-#define LATIN_SMALL_LIGATURE_ST 0xFB06
-
-#endif
+++ /dev/null
-/* swfscripts.c
-
- AVM2 Utility Actionscripts
-
- Extension module for the rfxswf library.
- Part of the swftools package.
-
- Copyright (c) 2007 Alessandro Molina
- Copyright (c) 2007,2008 Matthias Kramm <kramm@quiss.org>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-#include <stdarg.h>
-#include "../rfxswf.h"
-
-static unsigned AVM2_uint32toU30(unsigned val, char * out)
-{
- unsigned len = 0;
-
- while(val) {
- out[len++] = (val&~0x7f?0x80:0) | (val & 0x7F);
- val >>= 7;
- }
-
- return len;
-}
-
-void AVM2_InsertStops(SWF*swf)
-{
- TAG * t;
-
- //MAIN AS3 CLASS INIT
- unsigned frame_nums = 0;
-
- /* Count number of pages to set up stop callback for every frame */
- t = swf->firstTag;
- while(t) {
- if (t->id == ST_SHOWFRAME) ++frame_nums;
- t = t->next;
- }
-
- TAG * classCall = swf_InsertTagBefore(swf, swf->firstTag, ST_SYMBOLCLASS);
- swf_SetU16(classCall, 1); // number of symbols
- swf_SetU16(classCall, 0); // object id
- swf_SetString(classCall, "stop_fla:MainTimeline"); // class to associate with the symbol
-
- //0x52 is the Flash9 equivalent to DoAction
- char init_pool[322] = {
- 0x01,0x00,0x00,0x00, /* Flag Parameter to ST_DOABC (1 = lazy load)*/
- 0x00, /* 0 terminated class name */
- 0x10,0x00,0x2e,0x00, /* ABC file magic number (minor version, major version) */
- 0x00, /* zero integers */
- 0x00, /* zero unsigned integers */
- 0x00, /* zero doubles */
-
- 0x11, /* 16 strings (+1) */
- 0x08, 's','t','o','p','_','f','l','a',
- 0x0c, 'M','a','i','n','T','i','m','e','l','i','n','e',
- 0x0d, 'f','l','a','s','h','.','d','i','s','p','l','a','y',
- 0x09, 'M','o','v','i','e','C','l','i','p',
- 0x15, 's','t','o','p','_','f','l','a',':','M','a','i','n','T','i','m','e','l','i','n','e',
- 0x06, 'd','o','s','t','o','p',
- 0x00, // Empty string: ref. to the global namespace
- 0x04, 's','t','o','p',
- 0x0e, 'a','d','d','F','r','a','m','e','S','c','r','i','p','t',
- 0x06, 'O','b','j','e','c','t',
- 0x0c, 'f','l','a','s','h','.','e','v','e','n','t','s',
- 0x0f, 'E','v','e','n','t','D','i','s','p','a','t','c','h','e','r',
- 0x0d, 'D','i','s','p','l','a','y','O','b','j','e','c','t',
- 0x11, 'I','n','t','e','r','a','c','t','i','v','e','O','b','j','e','c','t',
- 0x16, 'D','i','s','p','l','a','y','O','b','j','e','c','t','C','o','n','t','a','i','n','e','r',
- 0x06, 'S','p','r','i','t','e',
-
- 0x07, /* 6 namespaces (+1) */
- 0x16,0x01, /* kind: CONSTANT_PackageNamespace, ref. to: stop_fla */
- 0x16,0x03, /* kind: CONSTANT_PackageNamespace, ref. to: flash.display */
- 0x18,0x05, /* kind: CONSTANT_ProtectedNamespace, ref. to: stop_fla:MainTimeline */
- 0x17,0x01, /* kind: CONSTANT_PackageInternalNs, ref. to: MainTimeline */
- 0x16,0x07, /* kind: CONSTANT_PackageNamespace, ref. to the global namespace */
- 0x16,0x0b, /* kind: CONSTANT_PackageNamespace, ref. to: flash.events */
-
- 0x00, /* zero namespace sets */
-
- 0x0c, /* 11 MultiNames (+1) */
- /* 1st value: Multiname kind (0x07 = Qualified Name, a multiname with 1 namespace, refers to a method)
- 2nd value: refers to namespace name index in the namespace table
- 3rd value: refers to method name index in the string table */
- 0x07,0x01,0x02, /* stop_fla:MainTimeLine */
- 0x07,0x02,0x04, /* flash.display:MovieClip */
- 0x07,0x04,0x06, /* <4th namespace>:dostop */
- 0x07,0x05,0x08, /* <global>:stop */
- 0x07,0x05,0x09, /* <global>:addFrameScript */
- 0x07,0x05,0x0a, /* <global>:Object */
- 0x07,0x06,0x0c, /* flash.events:EventDispatcher */
- 0x07,0x02,0x0d, /* flash.display:DisplayObject */
- 0x07,0x02,0x0e, /* flash.display:InteractiveObject */
- 0x07,0x02,0x0f, /* flash.display:DisplayObjectContainer */
- 0x07,0x02,0x10, /* flash.display:Sprite */
-
- 0x04, /* 4 Methods */
- /* METHOD 1 */
- 0x00,0x00,0x00,0x00, /* No params (nor params types), no return type, no method name, flags */
- 0x00,0x00,0x00,0x00, /* No params (nor params types), no return type, no method name, flags */
- 0x00,0x00,0x00,0x00, /* No params (nor params types), no return type, no method name, flags */
- 0x00,0x00,0x00,0x00, /* No params (nor params types), no return type, no method name, flags */
-
- 0x00, /* Zero Metadata */
-
- 0x01, /* 1 Class */
- 0x01, /* Name: ref. to multiname no. 1 (MainTimeline) */
- 0x02, /* Super_name (base class): ref. to multiname no. 2 (flash.display) */
- 0x08, /* Flags: 0x08 value indicates that it uses its protected namespace (and make next field exists) */
- 0x03, /* Ref. to namespace no. 3 (MainTimeline, protected namespace for this class) */
- 0x00, /* No. of interfaces: there are no interfaces (nor interface definition) */
- 0x02, /* Initializer index: ref. to method no. 2 */
- 0x01, /* No. of traits */
- /* Trait section */
- 0x03, /* Name: ref. to multiname no. 3 (stop) */
- 0x01, /* 0000: no attributes (nor metadata in the next subsection);
- then 1: type is Trait_Method */
- /* Trait_method section */
- 0x00, /* NO optimization for virtual calls */
- 0x01, /* Ref. to method no. 1 */
- /* HERE FOLLOW THE CLASS DATA */
- 0x00, /* Ref. to method no. 0 as static initializer for this class */
- 0x00, /* No. of traits for this class (no ones) */
-
- 0x01, /* 1 Script */
- 0x03, /* Ref. to method no. 3, invoked prior to any other code in the script */
- 0x01, /* No. of traits */
- /* Trait section */
- 0x01, /* Name: ref. to multiname no. 1 (flash.display:MovieClip) */
- 0x04, /* 0000: no attributes (nor metadata in the next subsection);
- then 4: type is Trait_Class*/
- /* Trait_class section */
- 0x01, /* Slot ID where the trait resides */
- 0x00, /* Class index (there is only one class)*/
-
- 0x04, /* Method body count: there are 4 method bodies */
- /* HERE FOLLOW THE METHOD BODY DATA */
- 0x00, /* Method index, ref. to method no. 0 */
- 0x01, /* Max stack slots the method can use */
- 0x01, /* No. of registers +1 the method can use: this one cannot use registers */
- 0x09,0x0a, /* Min and max scope depth the method can access*/
- 0x03, /* Code length (in bytes) */
- /* The actual method code:
- this is the function stop_fla::MainTimeline$cinit()*/
- 0xd0,0x30,0x47,
- 0x00, /* No. of exceptions (no exceptions) */
- 0x00, /* No. of traits (no traits) */
-
- 0x01, /* Method index, ref. to method no. 1 */
- 0x01, /* Max stack slots the method can use */
- 0x01, /* No. of registers +1 the method can use: this one cannot use registers */
- 0x0a,0x0b, /* Min and max scope depth the method can access*/
- 0x08, /* Code length (in bytes) */
- /* The actual method code:
- this is the function stop_fla::dostop(),
- the one that actually executes the stop() */
- 0xd0,0x30,0x5d,0x04,0x4f,0x04,0x00,0x47,
- 0x00, /* No. of exceptions (no exceptions) */
- 0x00, /* No. of traits (no traits) */
- };
-
- /* Header of stop_fla::MainTimeline() method */
- char constructor_header[5] = {
- 0x02, /* Method index, ref. to method no. 2 */
- 0x03, /* Max stack slots the method can use */
- 0x01, /* No. of registers +1 the method can use: this one cannot use registers */
- 0x0a,0x0b /* Min and max scope depth the method can access*/
- };
-
- char constructor_first[5] = {
- /* The actual method code:
- This is the function stop_fla::MainTimeline()
- Does: calls the super constructor for class #0 (MainTimeline),
- then puts on the stack the object, namespace and name of the arguments
- needed by the addFrameScripts, then calls the addFrameScripts
- */
- 0xd0, /* getlocal0 */
- 0x30, /* pushscope */
- 0xd0, /* getlocal0 */
- 0x49, /* constructsuper */
- 0x00 /* 0 */
- };
-
- char constructor_frame_register[10] = {
- 0x5d, /* findpropstrict */
- 0x05, /* 'addFrameScript' */
- 0x25, /* pushshort */
- 0x00, /* frame number for pushshort */
- 0x02, /* NOP (hack to write u30 value of frame number when > 127) */
- 0x60, /* getlex */
- 0x03, /* 'stop_fla::dostop' */
- 0x4f, /* callpropvoid */
- 0x05, /* 'addFrameScript' */
- 0x02 /* 2*/
- };
-
- char constructor_return[3] = {
- 0x47, /* returnvoid */
- 0x00, /* No. of exceptions (no exceptions) */
- 0x00, /* No. of traits (no traits) */
- };
-
- char script_init_pool[47] = {
- 0x03, /* Method index, ref. to method no. 3 */
- 0x02, /* Max stack slots the method can use */
- 0x01, /* No. of registers +1 the method can use: this one cannot use registers */
- 0x01,0x09, /* Min and max scope depth the method can access*/
- 0x27, /* Code length (in bytes) */
- /* The actual method code:
- this is the function script0$init() */
- 0xd0,0x30,0x65,0x00,0x60,0x06,0x30,0x60,0x07,0x30,0x60,0x08,0x30,0x60,0x09,0x30,0x60,0x0a,0x30,0x60,
- 0x0b,0x30,0x60,0x02,0x30,0x60,0x02,0x58,0x00,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x68,0x01,0x47,
- 0x00, /* No. of exceptions (no exceptions) */
- 0x00 /* No. of traits (no traits) */
- };
- /* END OF THE ABCFILE (Actionscript Byte Code) */
-
- char code_len[5] = {0, };
- unsigned clen_len = AVM2_uint32toU30((6 + sizeof(constructor_frame_register) * frame_nums), code_len);
- unsigned i, offset = 0;
-
- TAG *classInit = swf_InsertTagBefore(swf, swf->firstTag, ST_DOABC);
-
- /* Copy the environment Initialization code */
- swf_SetBlock(classInit, (U8*)init_pool,sizeof(init_pool));
- /* Copy Constructor Method header */
- swf_SetBlock(classInit, (U8*)constructor_header, sizeof(constructor_header));
- /* Add Code block size (u30) to the method header */
- swf_SetBlock(classInit, (U8*)code_len, clen_len);
-
- /* Copy Constructor Method body first part */
- swf_SetBlock(classInit, (U8*)constructor_first, sizeof(constructor_first));
-
- /* Register the callback for every frame */
- for (i = 0; i < frame_nums; ++i) {
- AVM2_uint32toU30(i,constructor_frame_register + 3); // Write current frame number
- swf_SetBlock(classInit, (U8*)constructor_frame_register, sizeof(constructor_frame_register));
- }
-
- /* Copy Constructor method body ending, just a return */
- swf_SetBlock(classInit, (U8*)constructor_return, sizeof(constructor_return));
-
- /* Copy the script init code */
- swf_SetBlock(classInit, (U8*)script_init_pool, sizeof(script_init_pool));
-}
-
-void AVM2_InsertButtonLink(SWF*swf)
-{
- unsigned char displayEventCode[] = {
- // button.dispatchEvent(new Event("pdflinkdown"),true,true)
-
- 0x01, 0x00, 0x00, 0x00, //flags
- 0x00,
- 0x10, 0x00, 0x2e, 0x00, //version
- 0x00, //no ints
- 0x00, //no uints
- 0x00, //no floats
- 0x14, //19 strings
- 0x17, 'e','v','e','n','t','_','o','h','n','e','_','l','i','s','t','e','n','e','r','_','f','l','a',
- 0x0c, 'M','a','i','n','t','i','m','e','l','i','n','e',
- 0x0d, 'f','l','a','s','h','.','d','i','s','p','l','a','y',
- 0x09, 'M','o','v','i','e','c','l','i','p',
- 0x24, 'e','v','e','n','t','_','o','h','n','e','_','l','i','s','t','e','n','e','r','_','f','l','a',':','M','a','i','n','t','i','m','e','l','i','n','e',
- 0x00,
- 0x06, 'b','u','t','t','o','n',
- 0x06, 'f','r','a','m','e','1',
- 0x0c, 'f','l','a','s','h','.','e','v','e','n','t','s',
- 0x05, 'E','v','e','n','t',
- 0x0b, 'p','d','f','l','i','n','k','d','o','w','n',
- 0x0d, 'd','i','s','p','a','t','c','h','E','v','e','n','t',
- 0x0e, 'a','d','d','F','r','a','m','e','S','c','r','i','p','t',
- 0x06, 'O','b','j','e','c','t',
- 0x0f, 'E','v','e','n','t','d','i','s','p','a','t','c','h','e','r',
- 0x0d, 'D','i','s','p','l','a','y','O','b','j','e','c','t',
- 0x11, 'I','n','t','e','r','a','c','t','i','v','e','O','b','j','e','c','t',
- 0x16, 'D','i','s','p','l','a','y','O','b','j','e','c','t','C','o','n','t','a','i','n','e','r',
- 0x06, 'S','p','r','i','t','e',
-
- 0x07, // 6 namespaces
- 0x16, 0x01,
- 0x16, 0x03,
- 0x18, 0x05,
- 0x16, 0x06,
- 0x17, 0x01,
- 0x16, 0x09,
-
- 0x00, //zero namespace sets
-
- 0x0e, //13 multinames
- 0x07, 0x01, 0x02,
- 0x07, 0x02, 0x04,
- 0x07, 0x04, 0x07,
- 0x07, 0x05, 0x08,
- 0x07, 0x06, 0x0a,
- 0x07, 0x04, 0x0c,
- 0x07, 0x04, 0x0d,
- 0x07, 0x04, 0x0e,
- 0x07, 0x06, 0x0f,
- 0x07, 0x02, 0x10,
- 0x07, 0x02, 0x11,
- 0x07, 0x02, 0x12,
- 0x07, 0x02, 0x13,
-
- 0x04, // 4 methods
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
-
- 0x00, // zero metadata
-
- 0x01, // 1 class
- 0x01, 0x02, 0x08, 0x03, 0x00, 0x02,
- 0x02, // 2 traits
- 0x03, 0x00, // name, slot
- 0x00, 0x02, 0x00,
- 0x04, 0x01, // name, method,
- 0x00, 0x01,
- 0x00, // ref to method 0 (initializer)
- 0x00, // no traits
-
- 0x01, // 1 script
- 0x03, 0x01, 0x01, 0x04, 0x01, 0x00,
-
- 0x04, // 4 method bodies
- // method 1
- 0x00, 0x01, 0x01, 0x09, 0x0a,
- 0x03, 0xd0, 0x30, 0x47, // code
- 0x00, 0x00,
- // method 2
- 0x01, 0x05, 0x01, 0x0a, 0x0b,
- 0x11, 0xd0, 0x30, 0x60, 0x03, 0x5d, 0x05, 0x2c, 0x0b, 0x26, 0x26, 0x4a, 0x05, 0x03, 0x4f, 0x06, 0x01, 0x47, // code
- 0x00, 0x00,
- // method 3
- 0x02, 0x03, 0x01, 0x0a, 0x0b,
- 0x0f, 0xd0, 0x30, 0xd0, 0x49, 0x00, 0x5d, 0x07, 0x24, 0x00, 0x60, 0x04, 0x4f, 0x07, 0x02, 0x47, // code
- 0x00, 0x00,
- // method 4
- 0x03, 0x02, 0x01, 0x01, 0x09,
- 0x27, 0xd0, 0x30, 0x65, 0x00, 0x60, 0x08, 0x30, 0x60, 0x09, 0x30, 0x60, 0x0a, 0x30, 0x60, 0x0b, //code
- 0x30, 0x60, 0x0c, 0x30, 0x60, 0x0d, 0x30, 0x60, 0x02, 0x30, 0x60, 0x02, 0x58, 0x00, 0x1d, 0x1d,
- 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x68, 0x01, 0x47,
- 0x00, 0x00,
- };
-}
-
+++ /dev/null
-/* FullBitmapOutputDev.cc
-
- Output Device which creates a bitmap.
-
- Swftools is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- Swftools is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with swftools; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <memory.h>
-#include "config.h"
-#include "FullBitmapOutputDev.h"
-#include "GFXOutputDev.h"
-#include "SplashBitmap.h"
-#include "SplashPattern.h"
-#include "Splash.h"
-#include "../log.h"
-#include "../png.h"
-#include "../devices/record.h"
-
-static SplashColor splash_white = {255,255,255};
-static SplashColor splash_black = {0,0,0};
-
-FullBitmapOutputDev::FullBitmapOutputDev(InfoOutputDev*info, PDFDoc*doc)
-{
- this->doc = doc;
- this->xref = doc->getXRef();
-
- msg("<verbose> Rendering everything to a bitmap");
-
- /* color graphic output device, for creating bitmaps */
- this->rgbdev = new SplashOutputDev(splashModeRGB8, 1, gFalse, splash_white, gTrue, gTrue);
-
- /* device for handling links */
- this->gfxdev = new GFXOutputDev(info, this->doc);
-
- this->rgbdev->startDoc(this->xref);
-}
-FullBitmapOutputDev::~FullBitmapOutputDev()
-{
- if(this->rgbdev) {
- delete this->rgbdev;this->rgbdev = 0;
- }
- if(this->gfxdev) {
- delete this->gfxdev;this->gfxdev= 0;
- }
-}
-
-GBool FullBitmapOutputDev::getVectorAntialias()
-{
- return this->rgbdev->getVectorAntialias();
-}
-void FullBitmapOutputDev::setVectorAntialias(GBool vaa)
-{
- this->rgbdev->setVectorAntialias(vaa);
-}
-void FullBitmapOutputDev::setDevice(gfxdevice_t*dev)
-{
- this->dev = dev;
- gfxdev->setDevice(dev);
-}
-void FullBitmapOutputDev::setMove(int x,int y)
-{
- this->user_movex = x;
- this->user_movey = y;
- gfxdev->setMove(x,y);
-}
-void FullBitmapOutputDev::setClip(int x1,int y1,int x2,int y2)
-{
- this->user_clipx1 = x1;
- this->user_clipy1 = y1;
- this->user_clipx2 = x2;
- this->user_clipy2 = y2;
- gfxdev->setClip(x1,y1,x2,y2);
-}
-void FullBitmapOutputDev::setParameter(const char*key, const char*value)
-{
-}
-void FullBitmapOutputDev::preparePage(int pdfpage, int outputpage)
-{
- gfxdev->preparePage(pdfpage, outputpage);
-}
-
-static void getBitmapBBox(Guchar*alpha, int width, int height, int*xmin, int*ymin, int*xmax, int*ymax)
-{
- *ymin = -1;
- *xmin = width;
- *xmax = 0;
- int x,y;
- for(y=0;y<height;y++) {
- Guchar*a = &alpha[y*width];
- for(x=0;x<width;x++) {
- if(a[x]) break;
- }
- int left = x; //first occupied pixel from left
- int right = x+1; //last non-occupied pixel from right
- for(;x<width;x++) {
- if(a[x]) right=x+1;
- }
-
- if(left!=width) {
- if(*ymin<0)
- *ymin=y;
- *ymax=y+1;
- if(left<*xmin) *xmin = left;
- if(right>*xmax) *xmax = right;
- }
- }
- if(*xmin>=*xmax || *ymin>=*ymax) {
- *xmin = 0;
- *ymin = 0;
- *xmax = 0;
- *ymax = 0;
- }
-}
-
-void FullBitmapOutputDev::flushBitmap()
-{
- int width = rgbdev->getBitmapWidth();
- int height = rgbdev->getBitmapHeight();
-
- SplashColorPtr rgb = rgbdev->getBitmap()->getDataPtr();
- Guchar*alpha = rgbdev->getBitmap()->getAlphaPtr();
-
- int xmin,ymin,xmax,ymax;
- getBitmapBBox(alpha, width, height, &xmin,&ymin,&xmax,&ymax);
-
- /* clip against (-movex, -movey, -movex+width, -movey+height) */
- if(xmin < -this->movex) xmin = -this->movex;
- if(ymin < -this->movey) ymin = -this->movey;
- if(xmax > -this->movex + width) xmax = -this->movex+this->width;
- if(ymax > -this->movey + height) ymax = -this->movey+this->height;
-
- msg("<verbose> Flushing bitmap (bbox: %d,%d,%d,%d)", xmin,ymin,xmax,ymax);
-
- if((xmax-xmin)<=0 || (ymax-ymin)<=0) // no bitmap, nothing to do
- return;
-
- if(sizeof(SplashColor)!=3) {
- msg("<error> sizeof(SplashColor)!=3");
- return;
- }
- //xmin = ymin = 0;
- //xmax = width;
- //ymax = height;
-
- int rangex = xmax-xmin;
- int rangey = ymax-ymin;
- gfximage_t*img = (gfximage_t*)malloc(sizeof(gfximage_t));
- img->data = (gfxcolor_t*)malloc(rangex * rangey * 4);
- img->width = rangex;
- img->height = rangey;
- int x,y;
- for(y=0;y<rangey;y++) {
- SplashColorPtr in=&rgb[((y+ymin)*width+xmin)*sizeof(SplashColor)];
- gfxcolor_t*out = &img->data[y*rangex];
- Guchar*ain = &alpha[(y+ymin)*width+xmin];
- for(x=0;x<rangex;x++) {
- // blend against a white background
- out[x].r = (in[x*3+0]*ain[x])/255 + 255-ain[x];
- out[x].g = (in[x*3+1]*ain[x])/255 + 255-ain[x];
- out[x].b = (in[x*3+2]*ain[x])/255 + 255-ain[x];
- out[x].a = 255;//ain[x];
- }
- }
- /* transform bitmap rectangle to "device space" */
- xmin += movex;
- ymin += movey;
- xmax += movex;
- ymax += movey;
-
- gfxmatrix_t m;
- m.tx = xmin;
- m.ty = ymin;
- m.m00 = m.m11 = 1;
- m.m10 = m.m01 = 0;
-
- gfxline_t* line = gfxline_makerectangle(xmin, ymin, xmax, ymax);
- dev->fillbitmap(dev, line, img, &m, 0);
- gfxline_free(line);
-
- free(img->data);img->data=0;free(img);img=0;
-}
-
-void FullBitmapOutputDev::startPage(int pageNum, GfxState *state, double crop_x1, double crop_y1, double crop_x2, double crop_y2)
-{
- double x1,y1,x2,y2;
- state->transform(crop_x1,crop_y1,&x1,&y1);
- state->transform(crop_x2,crop_y2,&x2,&y2);
- if(x2<x1) {double x3=x1;x1=x2;x2=x3;}
- if(y2<y1) {double y3=y1;y1=y2;y2=y3;}
-
- this->movex = -(int)x1 - user_movex;
- this->movey = -(int)y1 - user_movey;
-
- if(user_clipx1|user_clipy1|user_clipx2|user_clipy2) {
- x1 = user_clipx1;
- x2 = user_clipx2;
- y1 = user_clipy1;
- y2 = user_clipy2;
- }
- this->width = (int)(x2-x1);
- this->height = (int)(y2-y1);
-
- msg("<debug> startPage");
- rgbdev->startPage(pageNum, state, crop_x1, crop_y1, crop_x2, crop_y2);
- gfxdev->startPage(pageNum, state, crop_x1, crop_y1, crop_x2, crop_y2);
-}
-
-void FullBitmapOutputDev::endPage()
-{
- msg("<verbose> endPage (FullBitmapOutputDev)");
- flushBitmap();
- rgbdev->endPage();
- gfxdev->endPage();
-}
-GBool FullBitmapOutputDev::upsideDown()
-{
- return rgbdev->upsideDown();
-}
-GBool FullBitmapOutputDev::useDrawChar()
-{
- return rgbdev->useDrawChar();
-}
-GBool FullBitmapOutputDev::useTilingPatternFill()
-{
- return rgbdev->useTilingPatternFill();
-}
-GBool FullBitmapOutputDev::useShadedFills()
-{
- return rgbdev->useShadedFills();
-}
-GBool FullBitmapOutputDev::useDrawForm()
-{
- return rgbdev->useDrawForm();
-}
-GBool FullBitmapOutputDev::interpretType3Chars()
-{
- return rgbdev->interpretType3Chars();
-}
-GBool FullBitmapOutputDev::needNonText()
-{
- return rgbdev->needNonText();
-}
-void FullBitmapOutputDev::setDefaultCTM(double *ctm)
-{
- rgbdev->setDefaultCTM(ctm);
- gfxdev->setDefaultCTM(ctm);
-}
-void FullBitmapOutputDev::saveState(GfxState *state)
-{
- rgbdev->saveState(state);
-}
-void FullBitmapOutputDev::restoreState(GfxState *state)
-{
- rgbdev->restoreState(state);
-}
-void FullBitmapOutputDev::updateAll(GfxState *state)
-{
- rgbdev->updateAll(state);
-}
-void FullBitmapOutputDev::updateCTM(GfxState *state, double m11, double m12, double m21, double m22, double m31, double m32)
-{
- rgbdev->updateCTM(state,m11,m12,m21,m22,m31,m32);
- gfxdev->updateCTM(state,m11,m12,m21,m22,m31,m32);
-}
-void FullBitmapOutputDev::updateLineDash(GfxState *state)
-{
- rgbdev->updateLineDash(state);
-}
-void FullBitmapOutputDev::updateFlatness(GfxState *state)
-{
- rgbdev->updateFlatness(state);
-}
-void FullBitmapOutputDev::updateLineJoin(GfxState *state)
-{
- rgbdev->updateLineJoin(state);
-}
-void FullBitmapOutputDev::updateLineCap(GfxState *state)
-{
- rgbdev->updateLineCap(state);
-}
-void FullBitmapOutputDev::updateMiterLimit(GfxState *state)
-{
- rgbdev->updateMiterLimit(state);
-}
-void FullBitmapOutputDev::updateLineWidth(GfxState *state)
-{
- rgbdev->updateLineWidth(state);
-}
-void FullBitmapOutputDev::updateStrokeAdjust(GfxState *state)
-{
- rgbdev->updateStrokeAdjust(state);
-}
-void FullBitmapOutputDev::updateFillColorSpace(GfxState *state)
-{
- rgbdev->updateFillColorSpace(state);
-}
-void FullBitmapOutputDev::updateStrokeColorSpace(GfxState *state)
-{
- rgbdev->updateStrokeColorSpace(state);
-}
-void FullBitmapOutputDev::updateFillColor(GfxState *state)
-{
- rgbdev->updateFillColor(state);
-}
-void FullBitmapOutputDev::updateStrokeColor(GfxState *state)
-{
- rgbdev->updateStrokeColor(state);
-}
-void FullBitmapOutputDev::updateBlendMode(GfxState *state)
-{
- rgbdev->updateBlendMode(state);
-}
-void FullBitmapOutputDev::updateFillOpacity(GfxState *state)
-{
- rgbdev->updateFillOpacity(state);
-}
-void FullBitmapOutputDev::updateStrokeOpacity(GfxState *state)
-{
- rgbdev->updateStrokeOpacity(state);
-}
-void FullBitmapOutputDev::updateFillOverprint(GfxState *state)
-{
- rgbdev->updateFillOverprint(state);
-}
-void FullBitmapOutputDev::updateStrokeOverprint(GfxState *state)
-{
- rgbdev->updateStrokeOverprint(state);
-}
-void FullBitmapOutputDev::updateTransfer(GfxState *state)
-{
- rgbdev->updateTransfer(state);
-}
-void FullBitmapOutputDev::updateFont(GfxState *state)
-{
- rgbdev->updateFont(state);
-}
-void FullBitmapOutputDev::updateTextMat(GfxState *state)
-{
- rgbdev->updateTextMat(state);
-}
-void FullBitmapOutputDev::updateCharSpace(GfxState *state)
-{
- rgbdev->updateCharSpace(state);
-}
-void FullBitmapOutputDev::updateRender(GfxState *state)
-{
- rgbdev->updateRender(state);
-}
-void FullBitmapOutputDev::updateRise(GfxState *state)
-{
- rgbdev->updateRise(state);
-}
-void FullBitmapOutputDev::updateWordSpace(GfxState *state)
-{
- rgbdev->updateWordSpace(state);
-}
-void FullBitmapOutputDev::updateHorizScaling(GfxState *state)
-{
- rgbdev->updateHorizScaling(state);
-}
-void FullBitmapOutputDev::updateTextPos(GfxState *state)
-{
- rgbdev->updateTextPos(state);
-}
-void FullBitmapOutputDev::updateTextShift(GfxState *state, double shift)
-{
- rgbdev->updateTextShift(state, shift);
-}
-
-void FullBitmapOutputDev::stroke(GfxState *state)
-{
- msg("<debug> stroke");
- rgbdev->stroke(state);
-}
-void FullBitmapOutputDev::fill(GfxState *state)
-{
- msg("<debug> fill");
- rgbdev->fill(state);
-}
-void FullBitmapOutputDev::eoFill(GfxState *state)
-{
- msg("<debug> eoFill");
- rgbdev->eoFill(state);
-}
-#if (xpdfMajorVersion*10000 + xpdfMinorVersion*100 + xpdfUpdateVersion) < 30207
-void FullBitmapOutputDev::tilingPatternFill(GfxState *state, Object *str,
- int paintType, Dict *resDict,
- double *mat, double *bbox,
- int x0, int y0, int x1, int y1,
- double xStep, double yStep)
-{
- msg("<debug> tilingPatternFill");
- rgbdev->tilingPatternFill(state, str, paintType, resDict, mat, bbox, x0, y0, x1, y1, xStep, yStep);
-}
-#else
-void FullBitmapOutputDev::tilingPatternFill(GfxState *state, Gfx *gfx, Object *str,
- int paintType, Dict *resDict,
- double *mat, double *bbox,
- int x0, int y0, int x1, int y1,
- double xStep, double yStep)
-{
- msg("<debug> tilingPatternFill");
- rgbdev->tilingPatternFill(state, gfx, str, paintType, resDict, mat, bbox, x0, y0, x1, y1, xStep, yStep);
-}
-#endif
-
-GBool FullBitmapOutputDev::functionShadedFill(GfxState *state, GfxFunctionShading *shading)
-{
- msg("<debug> functionShadedFill");
- return rgbdev->functionShadedFill(state, shading);
-}
-GBool FullBitmapOutputDev::axialShadedFill(GfxState *state, GfxAxialShading *shading)
-{
- msg("<debug> axialShadedFill");
- return rgbdev->axialShadedFill(state, shading);
-}
-GBool FullBitmapOutputDev::radialShadedFill(GfxState *state, GfxRadialShading *shading)
-{
- msg("<debug> radialShadedFill");
- return rgbdev->radialShadedFill(state, shading);
-}
-
-void FullBitmapOutputDev::clip(GfxState *state)
-{
- msg("<debug> clip");
- rgbdev->clip(state);
-}
-void FullBitmapOutputDev::eoClip(GfxState *state)
-{
- msg("<debug> eoClip");
- rgbdev->eoClip(state);
-}
-void FullBitmapOutputDev::clipToStrokePath(GfxState *state)
-{
- msg("<debug> clipToStrokePath");
- rgbdev->clipToStrokePath(state);
-}
-
-void FullBitmapOutputDev::beginStringOp(GfxState *state)
-{
- msg("<debug> beginStringOp");
- rgbdev->beginStringOp(state);
-}
-void FullBitmapOutputDev::endStringOp(GfxState *state)
-{
- msg("<debug> endStringOp");
- rgbdev->endStringOp(state);
-}
-void FullBitmapOutputDev::beginString(GfxState *state, GString *s)
-{
- msg("<debug> beginString");
- rgbdev->beginString(state, s);
-}
-void FullBitmapOutputDev::endString(GfxState *state)
-{
- msg("<debug> endString");
- rgbdev->endString(state);
-}
-void FullBitmapOutputDev::drawChar(GfxState *state, double x, double y,
- double dx, double dy,
- double originX, double originY,
- CharCode code, int nBytes, Unicode *u, int uLen)
-{
- msg("<debug> drawChar");
- rgbdev->drawChar(state, x, y, dx, dy, originX, originY, code, nBytes, u, uLen);
-}
-void FullBitmapOutputDev::drawString(GfxState *state, GString *s)
-{
- msg("<error> internal error: drawString not implemented");
- rgbdev->drawString(state, s);
-}
-void FullBitmapOutputDev::endTextObject(GfxState *state)
-{
- /* FIXME: the below might render things (stroke outlines etc.) to gfxdev which
- might end up unflushed- should be handled similarily as
- drawChar() above
- */
- msg("<debug> endTextObject");
- rgbdev->endTextObject(state);
-}
-
-/* TODO: these four operations below *should* do nothing, as type3
- chars are drawn using operations like fill() */
-GBool FullBitmapOutputDev::beginType3Char(GfxState *state, double x, double y,
- double dx, double dy,
- CharCode code, Unicode *u, int uLen)
-{
- msg("<debug> beginType3Char");
- return rgbdev->beginType3Char(state, x, y, dx, dy, code, u, uLen);
-}
-void FullBitmapOutputDev::type3D0(GfxState *state, double wx, double wy)
-{
- msg("<debug> type3D0");
- rgbdev->type3D0(state, wx, wy);
-}
-void FullBitmapOutputDev::type3D1(GfxState *state, double wx, double wy, double llx, double lly, double urx, double ury)
-{
- msg("<debug> type3D1");
- rgbdev->type3D1(state, wx, wy, llx, lly, urx, ury);
-}
-void FullBitmapOutputDev::endType3Char(GfxState *state)
-{
- msg("<debug> endType3Char");
- rgbdev->endType3Char(state);
-}
-void FullBitmapOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str,
- int width, int height, GBool invert,
- GBool inlineImg)
-{
- msg("<debug> drawImageMask");
- rgbdev->drawImageMask(state, ref, str, width, height, invert, inlineImg);
-}
-void FullBitmapOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
- int width, int height, GfxImageColorMap *colorMap,
- int *maskColors, GBool inlineImg)
-{
- msg("<debug> drawImage");
- rgbdev->drawImage(state, ref, str, width, height, colorMap, maskColors, inlineImg);
-}
-void FullBitmapOutputDev::drawMaskedImage(GfxState *state, Object *ref, Stream *str,
- int width, int height,
- GfxImageColorMap *colorMap,
- Stream *maskStr, int maskWidth, int maskHeight,
- GBool maskInvert)
-{
- msg("<debug> drawMaskedImage");
- rgbdev->drawMaskedImage(state, ref, str, width, height, colorMap, maskStr, maskWidth, maskHeight, maskInvert);
-}
-void FullBitmapOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
- int width, int height,
- GfxImageColorMap *colorMap,
- Stream *maskStr,
- int maskWidth, int maskHeight,
- GfxImageColorMap *maskColorMap)
-{
- msg("<debug> drawSoftMaskedImage");
- rgbdev->drawSoftMaskedImage(state, ref, str, width, height, colorMap, maskStr, maskWidth, maskHeight, maskColorMap);
-}
-void FullBitmapOutputDev::drawForm(Ref id)
-{
- msg("<debug> drawForm");
- rgbdev->drawForm(id);
-}
-
-void FullBitmapOutputDev::processLink(Link *link, Catalog *catalog)
-{
- msg("<debug> processLink");
- gfxdev->processLink(link, catalog);
-}
-
-void FullBitmapOutputDev::beginTransparencyGroup(GfxState *state, double *bbox,
- GfxColorSpace *blendingColorSpace,
- GBool isolated, GBool knockout,
- GBool forSoftMask)
-{
- msg("<debug> beginTransparencyGroup");
- rgbdev->beginTransparencyGroup(state, bbox, blendingColorSpace, isolated, knockout, forSoftMask);
-}
-void FullBitmapOutputDev::endTransparencyGroup(GfxState *state)
-{
- msg("<debug> endTransparencyGroup");
- rgbdev->endTransparencyGroup(state);
-}
-void FullBitmapOutputDev::paintTransparencyGroup(GfxState *state, double *bbox)
-{
- msg("<debug> paintTransparencyGroup");
- rgbdev->paintTransparencyGroup(state,bbox);
-}
-void FullBitmapOutputDev::setSoftMask(GfxState *state, double *bbox, GBool alpha, Function *transferFunc, GfxColor *backdropColor)
-{
- msg("<debug> setSoftMask");
- rgbdev->setSoftMask(state, bbox, alpha, transferFunc, backdropColor);
-}
-void FullBitmapOutputDev::clearSoftMask(GfxState *state)
-{
- msg("<debug> clearSoftMask");
- rgbdev->clearSoftMask(state);
-}
+++ /dev/null
-/* FullBitmapOutputDev.cc
- Output device which creates a bitmap.
-
- This file is part of swftools.
-
- Swftools is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- Swftools is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with swftools; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-#ifndef __FullBitmapOutputDev_h__
-#define __FullBitmapOutputDev_h__
-
-#include "../gfxdevice.h"
-#include "../gfxsource.h"
-#include "../gfxtools.h"
-
-#include "config.h"
-#include "GFXOutputDev.h"
-#include "InfoOutputDev.h"
-#include "PDFDoc.h"
-#include "CommonOutputDev.h"
-
-#define STATE_PARALLEL 0
-#define STATE_TEXT_IS_ABOVE 1
-#define STATE_BITMAP_IS_ABOVE 2
-
-class FullBitmapOutputDev: public CommonOutputDev {
-public:
- FullBitmapOutputDev(InfoOutputDev*info, PDFDoc*doc);
- virtual ~FullBitmapOutputDev();
-
- // CommonOutputDev:
- virtual void setDevice(gfxdevice_t*dev);
- virtual void setMove(int x,int y);
- virtual void setClip(int x1,int y1,int x2,int y2);
- virtual void setParameter(const char*key, const char*value);
- virtual void preparePage(int pdfpage, int outputpage);
-
- // OutputDev:
- virtual GBool upsideDown();
- virtual GBool useDrawChar();
- virtual GBool useTilingPatternFill();
- virtual GBool useShadedFills();
- virtual GBool useDrawForm();
- virtual GBool interpretType3Chars();
- virtual GBool needNonText();
- virtual void setDefaultCTM(double *ctm);
-/* virtual GBool checkPageSlice(Page *page, double hDPI, double vDPI,
- int rotate, GBool useMediaBox, GBool crop,
- int sliceX, int sliceY, int sliceW, int sliceH,
- GBool printing, Catalog *catalog,
- GBool (*abortCheckCbk)(void *data) = NULL,
- void *abortCheckCbkData = NULL);*/
-
- virtual void startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2);
- virtual void endPage();
-
- virtual void saveState(GfxState *state);
- virtual void restoreState(GfxState *state);
-
- virtual void updateAll(GfxState *state);
- virtual void updateCTM(GfxState *state, double m11, double m12, double m21, double m22, double m31, double m32);
- virtual void updateLineDash(GfxState *state);
- virtual void updateFlatness(GfxState *state);
- virtual void updateLineJoin(GfxState *state);
- virtual void updateLineCap(GfxState *state);
- virtual void updateMiterLimit(GfxState *state);
- virtual void updateLineWidth(GfxState *state);
- virtual void updateStrokeAdjust(GfxState *state);
- virtual void updateFillColorSpace(GfxState *state);
- virtual void updateStrokeColorSpace(GfxState *state);
- virtual void updateFillColor(GfxState *state);
- virtual void updateStrokeColor(GfxState *state);
- virtual void updateBlendMode(GfxState *state);
- virtual void updateFillOpacity(GfxState *state);
- virtual void updateStrokeOpacity(GfxState *state);
- virtual void updateFillOverprint(GfxState *state);
- virtual void updateStrokeOverprint(GfxState *state);
- virtual void updateTransfer(GfxState *state);
- virtual void updateFont(GfxState *state);
- virtual void updateTextMat(GfxState *state);
- virtual void updateCharSpace(GfxState *state);
- virtual void updateRender(GfxState *state);
- virtual void updateRise(GfxState *state);
- virtual void updateWordSpace(GfxState *state);
- virtual void updateHorizScaling(GfxState *state);
- virtual void updateTextPos(GfxState *state);
- virtual void updateTextShift(GfxState *state, double shift);
-
- virtual void stroke(GfxState *state);
- virtual void fill(GfxState *state);
- virtual void eoFill(GfxState *state);
-#if (xpdfMajorVersion < 3) || (xpdfMinorVersion < 2) || (xpdfUpdateVersion < 7)
- virtual void tilingPatternFill(GfxState *state, Object *str,
- int paintType, Dict *resDict,
- double *mat, double *bbox,
- int x0, int y0, int x1, int y1,
- double xStep, double yStep);
-#else
- virtual void tilingPatternFill(GfxState *state, Gfx *gfx, Object *str,
- int paintType, Dict *resDict,
- double *mat, double *bbox,
- int x0, int y0, int x1, int y1,
- double xStep, double yStep);
-#endif
-
- virtual GBool functionShadedFill(GfxState *state,
- GfxFunctionShading *shading);
- virtual GBool axialShadedFill(GfxState *state, GfxAxialShading *shading);
- virtual GBool radialShadedFill(GfxState *state, GfxRadialShading *shading);
-
- virtual void clip(GfxState *state);
- virtual void eoClip(GfxState *state);
- virtual void clipToStrokePath(GfxState *state);
-
- virtual void beginStringOp(GfxState *state);
- virtual void endStringOp(GfxState *state);
- virtual void beginString(GfxState *state, GString *s);
- virtual void endString(GfxState *state);
- virtual void drawChar(GfxState *state, double x, double y,
- double dx, double dy,
- double originX, double originY,
- CharCode code, int nBytes, Unicode *u, int uLen);
- virtual void drawString(GfxState *state, GString *s);
- virtual GBool beginType3Char(GfxState *state, double x, double y,
- double dx, double dy,
- CharCode code, Unicode *u, int uLen);
- virtual void endType3Char(GfxState *state);
- virtual void endTextObject(GfxState *state);
-
- virtual void drawImageMask(GfxState *state, Object *ref, Stream *str,
- int width, int height, GBool invert,
- GBool inlineImg);
- virtual void drawImage(GfxState *state, Object *ref, Stream *str,
- int width, int height, GfxImageColorMap *colorMap,
- int *maskColors, GBool inlineImg);
- virtual void drawMaskedImage(GfxState *state, Object *ref, Stream *str,
- int width, int height,
- GfxImageColorMap *colorMap,
- Stream *maskStr, int maskWidth, int maskHeight,
- GBool maskInvert);
- virtual void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
- int width, int height,
- GfxImageColorMap *colorMap,
- Stream *maskStr,
- int maskWidth, int maskHeight,
- GfxImageColorMap *maskColorMap);
-
- virtual void type3D0(GfxState *state, double wx, double wy);
- virtual void type3D1(GfxState *state, double wx, double wy, double llx, double lly, double urx, double ury);
-
- virtual void drawForm(Ref id);
-
- virtual void beginTransparencyGroup(GfxState *state, double *bbox,
- GfxColorSpace *blendingColorSpace,
- GBool isolated, GBool knockout,
- GBool forSoftMask);
- virtual void endTransparencyGroup(GfxState *state);
- virtual void paintTransparencyGroup(GfxState *state, double *bbox);
- virtual void setSoftMask(GfxState *state, double *bbox, GBool alpha, Function *transferFunc, GfxColor *backdropColor);
- virtual void clearSoftMask(GfxState *state);
-
- virtual void processLink(Link *link, Catalog *catalog);
-
- virtual void setVectorAntialias(GBool vaa);
- virtual GBool getVectorAntialias();
-
-
-private:
- void flushBitmap();
- char config_extrafontdata;
- PDFDoc*doc;
- XRef*xref;
- SplashOutputDev*rgbdev;
-
- GFXOutputDev*gfxdev;
- gfxdevice_t*dev;
-
- int movex, movey;
- int width, height;
-
- int user_movex, user_movey;
- int user_clipx1, user_clipy1;
- int user_clipx2, user_clipy2;
-};
-
-#endif
+++ /dev/null
-# Generated automatically from Makefile.in by configure.
-top_builddir = ../..
-srcdir = .
-top_srcdir = ../..
-include ../../Makefile.common
-
-all: swf.$(O) image.$(O)
-
-libswf: ../libswf$(A)
-
-swf.$(O): swf.c swf.h
- $(C) swf.c -o swf.$(O)
-
-image.$(O): image.c image.h
- $(C) image.c -o image.$(O)
-
-swfrender: $(libswf_objects) ../../src/swfrender.c ../devices/render.$(O)
- $(L) ../../src/swfrender.c $(libswf_objects) ../librfxswf$(A) ../gfxtools.$(O) ../png.$(O) ../devices/render.$(O) -o swfrender $(LIBS)
-
-install:
-uninstall:
-
-clean:
- rm -f *.o *.obj *.lo *.a *.lib *.la gmon.out
-
+++ /dev/null
-#include <stdlib.h>
-#include <stdio.h>
-#include <memory.h>
-#include "../gfxdevice.h"
-#include "../gfxsource.h"
-#include "../gfxtools.h"
-#include "../log.h"
-#include "../mem.h"
-#include "../jpeg.h"
-#include "../png.h"
-#include "image.h"
-
-typedef struct _image_page_internal
-{
-} image_page_internal_t;
-
-typedef struct _image_doc_internal
-{
- gfximage_t img;
-} image_doc_internal_t;
-
-void imagepage_destroy(gfxpage_t*image_page)
-{
- image_page_internal_t*i= (image_page_internal_t*)image_page->internal;
- free(image_page->internal);image_page->internal = 0;
- free(image_page);image_page=0;
-}
-
-void imagepage_render(gfxpage_t*page, gfxdevice_t*output)
-{
- image_page_internal_t*i = (image_page_internal_t*)page->internal;
- image_doc_internal_t*pi = (image_doc_internal_t*)page->parent->internal;
-
- gfxcxform_t cxform;
- memset(&cxform, 0, sizeof(cxform));
- cxform.rr = 1;
- cxform.gg = 1;
- cxform.bb = 1;
- cxform.aa = 1;
-
- gfxmatrix_t m;
- memset(&m, 0, sizeof(m));
- m.m00 = 1;
- m.m11 = 1;
-
- gfxline_t* rect = gfxline_makerectangle(0, 0, pi->img.width, pi->img.height);
- output->fillbitmap(output, rect, &pi->img, &m, &cxform);
- gfxline_free(rect);
-}
-
-void imagepage_rendersection(gfxpage_t*page, gfxdevice_t*output, gfxcoord_t x, gfxcoord_t y, gfxcoord_t _x1, gfxcoord_t _y1, gfxcoord_t _x2, gfxcoord_t _y2)
-{
- image_page_internal_t*i = (image_page_internal_t*)page->internal;
- image_doc_internal_t*pi = (image_doc_internal_t*)page->parent->internal;
-
- gfxcxform_t cxform;
- memset(&cxform, 0, sizeof(cxform));
- cxform.rr = 1;
- cxform.gg = 1;
- cxform.bb = 1;
- cxform.aa = 1;
-
- gfxmatrix_t m;
- memset(&m, 0, sizeof(m));
- m.m00 = 1;
- m.m11 = 1;
- m.tx = x;
- m.ty = y;
-
- gfxline_t* rect = gfxline_makerectangle(0, 0, pi->img.width, pi->img.height);
- gfxline_t* rect2 = gfxline_makerectangle(_x1, _y1, _x2, _y2);
-
- output->startclip(output, rect2);
- output->fillbitmap(output, rect, &pi->img, &m, &cxform);
- output->endclip(output);
- gfxline_free(rect);
- gfxline_free(rect2);
-}
-
-void image_doc_destroy(gfxdocument_t*gfx)
-{
- image_doc_internal_t*i= (image_doc_internal_t*)gfx->internal;
-
- free(i->img.data);i->img.data = 0;
-
- free(gfx->internal);gfx->internal=0;
- free(gfx);gfx=0;
-}
-
-void image_doc_set_parameter(gfxdocument_t*gfx, const char*name, const char*value)
-{
- image_doc_internal_t*i= (image_doc_internal_t*)gfx->internal;
-}
-
-gfxpage_t* image_doc_getpage(gfxdocument_t*doc, int page)
-{
- image_doc_internal_t*di= (image_doc_internal_t*)doc->internal;
- if(page != 1)
- return 0;
-
- gfxpage_t* image_page = (gfxpage_t*)malloc(sizeof(gfxpage_t));
- image_page_internal_t*pi= (image_page_internal_t*)malloc(sizeof(image_page_internal_t));
- memset(pi, 0, sizeof(image_page_internal_t));
-
- image_page->internal = pi;
- image_page->destroy = imagepage_destroy;
- image_page->render = imagepage_render;
- image_page->rendersection = imagepage_rendersection;
- image_page->width = di->img.width;
- image_page->height = di->img.height;
- image_page->parent = doc;
- image_page->nr = page;
- return image_page;
-}
-
-static void image_set_parameter(gfxsource_t*src, const char*name, const char*value)
-{
- msg("<verbose> (gfxsource_image) setting parameter %s to \"%s\"", name, value);
-}
-
-static gfxdocument_t*image_open(gfxsource_t*src, const char*filename)
-{
- gfxdocument_t*image_doc = (gfxdocument_t*)malloc(sizeof(gfxdocument_t));
- memset(image_doc, 0, sizeof(gfxdocument_t));
- image_doc_internal_t*i= (image_doc_internal_t*)malloc(sizeof(image_doc_internal_t));
- memset(i, 0, sizeof(image_doc_internal_t));
-
- gfxcolor_t*data = 0;
- int width = 0;
- int height = 0;
-
- if(!getPNG(filename, &width, &height, (unsigned char**)&data)) {
- if(!jpeg_load(filename, (unsigned char**)&data, &width, &height)) {
- msg("<error> Couldn't load image %s", filename);
- return 0;
- }
- }
- i->img.data = data;
- i->img.width = width;
- i->img.height = height;
-
- image_doc->num_pages = 1;
- image_doc->internal = i;
- image_doc->get = 0;
- image_doc->destroy = image_doc_destroy;
- image_doc->set_parameter = image_doc_set_parameter;
- image_doc->getpage = image_doc_getpage;
-
- return image_doc;
-}
-
-gfxsource_t*gfxsource_image_create()
-{
- gfxsource_t*src = (gfxsource_t*)malloc(sizeof(gfxsource_t));
- memset(src, 0, sizeof(gfxsource_t));
- src->set_parameter = image_set_parameter;
- src->open = image_open;
- return src;
-}
+++ /dev/null
-#ifndef __image_h__
-#define __image_h__
-
-#include "../gfxdevice.h"
-#include "../gfxsource.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-gfxsource_t*gfxsource_image_create();
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
+++ /dev/null
-#include <assert.h>
-#include "../gfxdevice.h"
-#include "../gfxsource.h"
-#include "../gfxtools.h"
-#include "../log.h"
-#include "../mem.h"
-#include "../png.h"
-#include "../rfxswf.h"
-#include "swf.h"
-
-typedef struct _map16_t
-{
- void** ids;
-} map16_t;
-
-typedef struct _swf_page_internal
-{
- int frame;
-} swf_page_internal_t;
-
-typedef struct _swf_doc_internal
-{
- map16_t*id2char;
- int clips;
- SWF swf;
- int width,height;
- MATRIX m;
-} swf_doc_internal_t;
-
-#define TYPE_SHAPE 1
-#define TYPE_BITMAP 2
-#define TYPE_SPRITE 3
-#define TYPE_FONT 4
-#define TYPE_TEXT 5
-
-typedef struct _character
-{
- U16 id;
- TAG*tag;
- char type;
- void*data;
-} character_t;
-
-typedef struct _placement
-{
- SWFPLACEOBJECT po;
- int age;
- int startFrame;
-} placement_t;
-
-typedef struct _sprite
-{
- int frameCount;
-} sprite_t;
-
-struct _render
-{
- map16_t*id2char;
- gfxdevice_t*device;
- MATRIX m;
- int clips;
- int*clips_waiting;
-};
-typedef struct _render render_t;
-
-
-static void placement_free(placement_t*p)
-{
- swf_PlaceObjectFree(&p->po);
- free(p);
-}
-
-//---- object/depth handling ----
-
-map16_t* map16_new()
-{
- map16_t*map = rfx_calloc(sizeof(map16_t));
- /* TODO: replace this by a more sophisticated data structure */
- map->ids = (void**)rfx_calloc(sizeof(character_t)*65536);
- return map;
-}
-character_t*map16_get_id(map16_t*map, int id)
-{
- if(id<0 || id>=65536)
- return 0;
- return map->ids[id];
-}
-void map16_free(map16_t*map)
-{
- free(map->ids);
-}
-void map16_add_id(map16_t*map, int nr, void*id)
-{
- if(map->ids[nr])
- fprintf(stderr, "Warning: ID %d defined more than once\n");
- map->ids[nr] = id;
-}
-void map16_remove_id(map16_t*map, int nr)
-{
- map->ids[nr] = 0;
-}
-void map16_enumerate(map16_t*map, void (*f)(void*self, int id, void*data), void*self)
-{
- int t;
- for(t=0;t<65536;t++) {
- if(map->ids[t]) {
- f(self, t, map->ids[t]);
- }
- }
-}
-//---- conversion stuff ----
-
-static void convertMatrix(MATRIX*from, gfxmatrix_t*to)
-{
- to->m00 = from->sx / 65536.0; to->m10 = from->r1 / 65536.0;
- to->m01 = from->r0 / 65536.0; to->m11 = from->sy / 65536.0;
- to->tx = from->tx/20.0;
- to->ty = from->ty/20.0;
-}
-
-static void convertCXForm(CXFORM*from, gfxcxform_t*to)
-{
- memset(to, 0, sizeof(gfxcxform_t));
- to->aa = from->a0 / 256.0;
- to->rr = from->r0 / 256.0;
- to->gg = from->g0 / 256.0;
- to->bb = from->b0 / 256.0;
- to->ta = from->a1;
- to->tr = from->r1;
- to->tg = from->g1;
- to->tb = from->b1;
-}
-
-static gfxgradient_t* convertGradient(GRADIENT*from)
-{
- gfxgradient_t*g = rfx_calloc(from->num * sizeof(gfxgradient_t));
- int t;
- for(t=0;t<from->num;t++) {
- g[t].pos = from->ratios[t] / 255.0;
- g[t].color = *(gfxcolor_t*)&from->rgba[t];
- if(t<from->num-1)
- g[t].next = &g[t+1];
- else
- g[t].next = 0;
- }
- return g;
-}
-
-gfxline_t* swfline_to_gfxline(SHAPELINE*line, int linestyle, int fillstyle0)
-{
- gfxdrawer_t d;
- SCOORD x=0,y=0;
- gfxline_t*l;
- gfxdrawer_target_gfxline(&d);
- if(line && line->type != moveTo) {
- fprintf(stderr, "Warning: Shape doesn't start with a moveTo\n");
- }
- while(line) {
- if(line->fillstyle0 == fillstyle0 || line->fillstyle1 == fillstyle0 ||
- line->linestyle == linestyle) {
- if(line->type == lineTo) {
- d.moveTo(&d, x/20.0,y/20.0);
- d.lineTo(&d, line->x/20.0,line->y/20.0);
- } else if(line->type == splineTo) {
- d.moveTo(&d, x/20.0,y/20.0);
- d.splineTo(&d, line->sx/20.0, line->sy/20.0, line->x/20.0,line->y/20.0);
- }
- }
- x = line->x;
- y = line->y;
- line = line->next;
- }
- l = d.result(&d);
- return l;
-}
-
-
-//---- bitmap handling ----
-
-gfximage_t* gfximage_new(RGBA*data, int width, int height)
-{
- gfximage_t* b = (gfximage_t*)rfx_calloc(sizeof(gfximage_t));
- b->data = (gfxcolor_t*)data;
- b->width = width;
- b->height = height;
- return b;
-}
-
-void gfximage_free(gfximage_t*b)
-{
- free(b->data); //!
- b->data = 0;
- free(b);
-}
-
-static gfximage_t* findimage(render_t*r, U16 id)
-{
- character_t*c = (character_t*)map16_get_id(r->id2char, id);
- assert(c && c->type == TYPE_BITMAP);
- gfximage_t*img = (gfximage_t*)c->data;
-
- /*char filename[80];
- sprintf(filename, "bitmap%d.png", id);
- writePNG(filename, (unsigned char*)img->data, img->width, img->height);
- printf("saving bitmap %d to %s\n", id, filename);*/
-
- return c->data;
-}
-//---- shape handling ----
-
-static void renderFilled(render_t*r, gfxline_t*line, FILLSTYLE*f, CXFORM*cx, MATRIX*po_m)
-{
- if(f->type == FILL_SOLID) {
- gfxcolor_t c = *(gfxcolor_t*)&f->color;
- r->device->fill(r->device, line, &c);
- } else if(f->type == FILL_TILED || f->type == FILL_CLIPPED) {
- gfximage_t* img = findimage(r, f->id_bitmap);
- gfxmatrix_t m;
- gfxcxform_t gfxcx;
- convertCXForm(cx, &gfxcx);
- MATRIX m2;
- swf_MatrixJoin(&m2, po_m, &f->m);
- convertMatrix(&m2, &m);
- m.m00/=20.0; m.m10/=20.0;
- m.m01/=20.0; m.m11/=20.0;
- /* TODO: handle clipped */
- r->device->fillbitmap(r->device, line, img, &m, &gfxcx);
- } else if(f->type == FILL_LINEAR || f->type == FILL_RADIAL) {
- gfxmatrix_t m;
- gfxgradient_t* g;
- convertMatrix(&f->m, &m);
- g = convertGradient(&f->gradient);
- r->device->fillgradient(r->device, line, g, f->type == FILL_LINEAR ? gfxgradient_linear : gfxgradient_radial, &m);
- free(g);
- }
-}
-
-//---- font handling ----
-
-typedef struct
-{
- int numchars;
- gfxline_t**glyphs;
-} font_t;
-
-typedef struct textcallbackblock
-{
- render_t*r;
- MATRIX m;
-} textcallbackblock_t;
-
-static void textcallback(void*self, int*chars, int*xpos, int nr, int fontid, int fontsize,
- int xstart, int ystart, RGBA* color)
-{
- textcallbackblock_t * info = (textcallbackblock_t*)self;
- font_t*font = 0;
- int t;
- character_t*cfont = map16_get_id(info->r->id2char, fontid);
- if(!cfont) {
- fprintf(stderr, "Font %d unknown\n", fontid);
- return;
- }
- if(cfont->type != TYPE_FONT) {
- fprintf(stderr, "ID %d is not a font\n", fontid);
- return;
- }
- font = cfont->data;
-
- for(t=0;t<nr;t++) {
- int x = xstart + xpos[t];
- int y = ystart;
- MATRIX m = info->m;
- SPOINT p;
-
- p.x = x; p.y = y;
- p = swf_TurnPoint(p, &m);
-
- m.sx = (m.sx * fontsize) / 1024;
- m.sy = (m.sy * fontsize) / 1024;
- m.r0 = (m.r0 * fontsize) / 1024;
- m.r1 = (m.r1 * fontsize) / 1024;
- m.tx = p.x;
- m.ty = p.y;
-
- gfxmatrix_t gm;
- convertMatrix(&m, &gm);
-
- if(chars[t]<0 || chars[t]>= font->numchars) {
- fprintf(stderr, "Character out of range: %d\n", chars[t]);
- } else {
- gfxline_t*line = gfxline_clone(font->glyphs[chars[t]]);
- gfxline_transform(line, &gm);
- FILLSTYLE f;
- f.type = FILL_SOLID;
- f.color = *color;
- renderFilled(info->r, line, &f, 0, 0);
- gfxline_free(line);
- }
- }
-}
-
-
-//---- tag handling ----
-
-static map16_t* extractDefinitions(SWF*swf)
-{
- map16_t*map = map16_new();
- TAG*tag = swf->firstTag;
- while(tag)
- {
- int id = 0;
- if(swf_isDefiningTag(tag)) {
- id = swf_GetDefineID(tag);
- }
-
- if(tag->id == ST_DEFINESPRITE) {
- character_t*c = rfx_calloc(sizeof(character_t));
- sprite_t*s = rfx_calloc(sizeof(sprite_t));
- swf_SetTagPos(tag, 0);
- swf_GetU16(tag); //id
- s->frameCount = swf_GetU16(tag); //frameno
- c->tag = tag;
- c->type = TYPE_SPRITE;
- c->data = s;
- map16_add_id(map, id, c);
- }
- else if(tag->id == ST_DEFINESHAPE ||
- tag->id == ST_DEFINESHAPE2 ||
- tag->id == ST_DEFINESHAPE3) {
- character_t*c = rfx_calloc(sizeof(character_t));
- c->tag = tag;
- c->type = TYPE_SHAPE;
- map16_add_id(map, id, c);
- }
- else if(tag->id == ST_DEFINEFONT ||
- tag->id == ST_DEFINEFONT2) {
- character_t*c = rfx_calloc(sizeof(character_t));
- SWFFONT*swffont = 0;
- font_t*font = (font_t*)rfx_calloc(sizeof(font_t));
- swf_FontExtract(swf, id, &swffont);
- font->numchars = swffont->numchars;
- font->glyphs = (gfxline_t**)rfx_calloc(sizeof(gfxline_t*)*font->numchars);
- int t;
- RGBA color_white = {255,255,255,255};
- for(t=0;t<font->numchars;t++) {
- if(!swffont->glyph[t].shape->fillstyle.n) {
- swf_ShapeAddSolidFillStyle(swffont->glyph[t].shape, &color_white);
- }
- SHAPE2*s2 = swf_ShapeToShape2(swffont->glyph[t].shape);
- font->glyphs[t] = swfline_to_gfxline(s2->lines, 0, 1);
- swf_Shape2Free(s2);
- }
- swf_FontFree(swffont);
-
- c->tag = tag;
- c->type = TYPE_FONT;
- c->data = font;
- map16_add_id(map, id, c);
- }
- else if(tag->id == ST_DEFINETEXT ||
- tag->id == ST_DEFINETEXT2) {
- character_t*c = rfx_calloc(sizeof(character_t));
- c->tag = tag;
- c->type = TYPE_TEXT;
- c->data = 0;
- map16_add_id(map, id, c);
- }
- else if(tag->id == ST_DEFINEBITSJPEG ||
- tag->id == ST_DEFINEBITSJPEG2 ||
- tag->id == ST_DEFINEBITSJPEG3 ||
- tag->id == ST_DEFINEBITSLOSSLESS ||
- tag->id == ST_DEFINEBITSLOSSLESS2) {
- character_t*c = rfx_calloc(sizeof(character_t));
- int width, height;
- void*data = swf_ExtractImage(tag, &width, &height);
- gfximage_t*b = gfximage_new(data, width, height);
- c->tag = tag;
- c->type = TYPE_BITMAP;
- c->data = b;
- map16_add_id(map, id, c);
- }
-
- tag = tag->next;
- }
- return map;
-}
-
-void swf_FreeTaglist(TAG*tag)
-{
- while(tag)
- {
- TAG * tnew = tag->next;
- if (tag->data)
- rfx_free(tag->data);
- rfx_free(tag);
- tag = tnew;
- }
-}
-
-static void increaseAge(void*self, int id, void*data)
-{
- placement_t*p = (placement_t*)data;
- p->age++;
-}
-
-static map16_t* extractFrame(TAG*startTag, int frame_to_extract)
-{
- map16_t*depthmap = map16_new();
- TAG*tag = startTag;
- int frame = 1;
- int insprite = 0;
- for(;tag;tag = tag->next) {
- if(tag->id == ST_END)
- break;
- if(tag->id == ST_DEFINESPRITE) {
- while(tag->id != ST_END)
- tag = tag->next;
- continue;
- }
- if(tag->id == ST_PLACEOBJECT ||
- tag->id == ST_PLACEOBJECT2) {
- placement_t* p = rfx_calloc(sizeof(placement_t));
- p->age = 1;
- p->startFrame = frame;
- swf_GetPlaceObject(tag, &p->po);
- if(p->po.move) {
- placement_t*old = (placement_t*)map16_get_id(depthmap, p->po.depth);
- p->po.id = old->po.id;
- map16_remove_id(depthmap, p->po.depth);
- placement_free(p);
- } else {
- map16_add_id(depthmap, p->po.depth, p);
- }
- }
- if(tag->id == ST_REMOVEOBJECT ||
- tag->id == ST_REMOVEOBJECT2) {
- U16 depth = swf_GetDepth(tag);
- map16_remove_id(depthmap, depth);
- }
- if(tag->id == ST_SHOWFRAME || tag->id == ST_END) {
- if(frame == frame_to_extract) {
- return depthmap;
- }
- if(tag->id == ST_SHOWFRAME) {
- frame++;
- map16_enumerate(depthmap, increaseAge, 0);
- }
- }
- }
- fprintf(stderr, "gfxsource_swf: frame %d not found\n", frame_to_extract);
- return depthmap;
-}
-
-// ---- rendering ----
-
-static void stopClippings(int from, render_t*r)
-{
- int t;
- for(t=from;t<r->clips;t++)
- r->device->endclip(r->device);
- r->clips = from;
-}
-
-void swf_ShapeApplyMatrix(SHAPE2*shape, MATRIX*m)
-{
-}
-
-RGBA swf_ColorTransform(RGBA*color, CXFORM*cx)
-{
- RGBA dest;
- dest.r = (cx->r0*color->r + cx->r1*256) >> 8;
- dest.g = (cx->g0*color->g + cx->g1*256) >> 8;
- dest.b = (cx->b0*color->b + cx->b1*256) >> 8;
- dest.a = (cx->a0*color->a + cx->a1*256) >> 8;
- return dest;
-}
-
-void renderOutline(render_t*r, gfxline_t*line, LINESTYLE*l, CXFORM*cx)
-{
- RGBA c = swf_ColorTransform(&l->color, cx);
- gfxcoord_t width = l->width/20.0;
- r->device->stroke(r->device, line, width, (gfxcolor_t*)&c, gfx_capRound, gfx_joinRound, 0.0);
-}
-
-void swf_ApplyMatrixToShape(SHAPE2*shape, MATRIX*m)
-{
- SHAPELINE*line = shape->lines;
- while(line) {
- SPOINT p;
- p.x = line->x; p.y = line->y;
- p = swf_TurnPoint(p, m);
- line->x = p.x; line->y = p.y;
- line = line->next;
- }
-}
-
-static void renderCharacter(render_t*r, placement_t*p, character_t*c)
-{
- if(c->type == TYPE_SHAPE) {
- SHAPE2 shape;
- swf_ParseDefineShape(c->tag, &shape);
- MATRIX m;
- swf_MatrixJoin(&m, &r->m, &p->po.matrix);
- swf_ApplyMatrixToShape(&shape, &m);
- SHAPELINE*line = shape.lines;
- int t;
- for(t=1;t<=shape.numfillstyles;t++) {
- gfxline_t*line;
- line = swfline_to_gfxline(shape.lines, -1, t);
- if(line) {
- if(!p->po.clipdepth) {
- renderFilled(r, line, &shape.fillstyles[t-1], &p->po.cxform, &p->po.matrix);
- } else {
- r->device->startclip(r->device, line);
- r->clips_waiting[p->po.clipdepth]++;
- r->clips++;
- }
- }
- gfxline_free(line);
- /*line = swfline_to_gfxline(shape.lines, -1, -1, t);
- if(line) renderFilled(r, line, &shape.fillstyles[t-1], &p->po.cxform);
- gfxline_free(line);*/
- }
- for(t=1;t<=shape.numlinestyles;t++) {
- gfxline_t*line = swfline_to_gfxline(shape.lines, t, -1);
- if(line) renderOutline(r, line, &shape.linestyles[t-1], &p->po.cxform);
- gfxline_free(line);
- }
- } else if(c->type == TYPE_TEXT) {
- TAG* tag = c->tag;
- textcallbackblock_t info;
- MATRIX mt,mt2;
- swf_SetTagPos(tag, 0);
- swf_GetU16(tag);
- swf_GetRect(tag,0);
- swf_GetMatrix(tag,&mt);
-
- swf_MatrixJoin(&mt2, &r->m, &mt);
- swf_MatrixJoin(&info.m, &mt2, &p->po.matrix);
- info.r = r;
- swf_ParseDefineText(tag, textcallback, &info);
- }
-}
-
-// ---- main ----
-
-static void placeObject(void*self, int id, void*data)
-{
- render_t*r = (render_t*)self;
- placement_t*p = (placement_t*)data;
- character_t*c = map16_get_id(r->id2char, p->po.id);
- if(!c) {
- fprintf(stderr, "Error: ID %d unknown\n", p->po.id);
- return;
- }
- if(c->type == TYPE_SPRITE) {
- int oldclip = r->clips;
- sprite_t* s = (sprite_t*)c->data;
- map16_t* depths = extractFrame(c->tag, p->age % s->frameCount);
- map16_enumerate(depths, placeObject, r);
- stopClippings(oldclip, r);
- return;
- }
- renderCharacter(r, p, c);
-}
-
-void swfpage_destroy(gfxpage_t*swf_page)
-{
- swf_page_internal_t*i= (swf_page_internal_t*)swf_page->internal;
- free(swf_page->internal);swf_page->internal = 0;
- free(swf_page);swf_page=0;
-}
-
-void swfpage_render(gfxpage_t*page, gfxdevice_t*output)
-{
- swf_page_internal_t*i = (swf_page_internal_t*)page->internal;
- swf_doc_internal_t*pi = (swf_doc_internal_t*)page->parent->internal;
- map16_t* depths = extractFrame(pi->swf.firstTag, i->frame);
- render_t r;
- r.id2char = pi->id2char;
- r.clips = 0;
- r.device = output;
- r.m = pi->m;
- r.clips_waiting = malloc(sizeof(r.clips_waiting[0])*65536);
- memset(r.clips_waiting, 0, sizeof(r.clips_waiting[0])*65536);
-
- int t;
- for(t=0;t<65536;t++) {
- int i;
- for(i=0; i<r.clips_waiting[t]; i++) {
- output->endclip(output);
- }
- if(depths->ids[t]) {
- placeObject(&r, t, depths->ids[t]);
- }
- }
- free(r.clips_waiting);
-}
-
-void swfpage_rendersection(gfxpage_t*page, gfxdevice_t*output, gfxcoord_t x, gfxcoord_t y, gfxcoord_t _x1, gfxcoord_t _y1, gfxcoord_t _x2, gfxcoord_t _y2)
-{
- swf_doc_internal_t*pi = (swf_doc_internal_t*)page->parent->internal;
- /* FIXME */
- swfpage_render(page,output);
-}
-
-void swf_doc_destroy(gfxdocument_t*gfx)
-{
- swf_doc_internal_t*i= (swf_doc_internal_t*)gfx->internal;
- swf_FreeTags(&i->swf);
- free(gfx->internal);gfx->internal=0;
- free(gfx);gfx=0;
-}
-
-void swf_doc_set_parameter(gfxdocument_t*gfx, const char*name, const char*value)
-{
- swf_doc_internal_t*i= (swf_doc_internal_t*)gfx->internal;
-}
-
-gfxpage_t* swf_doc_getpage(gfxdocument_t*doc, int page)
-{
- swf_doc_internal_t*di= (swf_doc_internal_t*)doc->internal;
- if(page < 1 || page > doc->num_pages)
- return 0;
-
- gfxpage_t* swf_page = (gfxpage_t*)malloc(sizeof(gfxpage_t));
- swf_page_internal_t*pi= (swf_page_internal_t*)malloc(sizeof(swf_page_internal_t));
- memset(pi, 0, sizeof(swf_page_internal_t));
-
- pi->frame = page;
-
- swf_page->internal = pi;
- swf_page->destroy = swfpage_destroy;
- swf_page->render = swfpage_render;
- swf_page->rendersection = swfpage_rendersection;
- swf_page->width = di->width;
- swf_page->height = di->height;
- swf_page->parent = doc;
- swf_page->nr = page;
- return swf_page;
-}
-
-void swf_set_parameter(gfxsource_t*src, const char*name, const char*value)
-{
- msg("<verbose> setting parameter %s to \"%s\"", name, value);
-}
-
-gfxdocument_t*swf_open(gfxsource_t*src, const char*filename)
-{
- gfxdocument_t*swf_doc = (gfxdocument_t*)malloc(sizeof(gfxdocument_t));
- memset(swf_doc, 0, sizeof(gfxdocument_t));
- swf_doc_internal_t*i= (swf_doc_internal_t*)malloc(sizeof(swf_doc_internal_t));
- memset(i, 0, sizeof(swf_doc_internal_t));
-
- TAG*tag = 0;
- int f;
- int frame;
- render_t r;
- gfxdevice_t d;
-
- if(!filename) {
- return 0;
- }
- f = open(filename,O_RDONLY|O_BINARY);
- if (f<0) {
- perror("Couldn't open file: ");
- return 0;
- }
- if FAILED(swf_ReadSWF(f,&i->swf)) {
- fprintf(stderr, "%s is not a valid SWF file or contains errors.\n",filename);
- close(f);
- return 0;
- }
- swf_UnFoldAll(&i->swf);
-
- i->id2char = extractDefinitions(&i->swf);
- i->width = (i->swf.movieSize.xmax - i->swf.movieSize.xmin) / 20;
- i->height = (i->swf.movieSize.ymax - i->swf.movieSize.ymin) / 20;
-
- swf_GetMatrix(0, &i->m);
- i->m.tx = -i->swf.movieSize.xmin;
- i->m.ty = -i->swf.movieSize.ymin;
-
- swf_doc->num_pages = i->swf.frameCount;
- swf_doc->internal = i;
- swf_doc->get = 0;
- swf_doc->destroy = swf_doc_destroy;
- swf_doc->set_parameter = swf_doc_set_parameter;
- swf_doc->getpage = swf_doc_getpage;
-
- return swf_doc;
-}
-
-gfxsource_t*gfxsource_swf_create()
-{
- gfxsource_t*src = (gfxsource_t*)malloc(sizeof(gfxsource_t));
- memset(src, 0, sizeof(gfxsource_t));
- src->set_parameter = swf_set_parameter;
- src->open = swf_open;
- return src;
-}
+++ /dev/null
-/* swf.h
-
- Part of the swftools package.
-
- Copyright (c) 2008 Matthias Kramm <kramm@quiss.org>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-#ifndef __swfsource_h__
-#define __swfsource_h__
-
-#include "../gfxsource.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-gfxsource_t*gfxsource_swf_create();
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //__pdfsource_h__