From e1b20799068a84b864df2e753c0655989702483d Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Wed, 2 May 2007 01:07:00 +0000 Subject: [PATCH] Recovered from cvs revision 2007-05-01 07:40:00 --- ase/aclocal.m4 | 5938 ++++ ase/ase.dsw | 113 + ase/ase.sln | 175 + ase/awk/Awk.cpp | 35 + ase/awk/Awk.hpp | 28 + ase/awk/Awk.java | 346 + ase/awk/Exception.java | 51 + ase/awk/Extio.java | 75 + ase/awk/StdAwk.java | 865 + ase/awk/aseawk.dsp | 202 + ase/awk/aseawk.vcproj | 521 + ase/awk/aseawk_jni.dsp | 113 + ase/awk/aseawk_jni.vcproj | 258 + ase/awk/awk.c | 256 + ase/awk/awk.h | 505 + ase/awk/awk.txt | 71 + ase/awk/awk_i.h | 338 + ase/awk/descrip.mms | 28 + ase/awk/err.c | 466 + ase/awk/extio.c | 951 + ase/awk/extio.h | 51 + ase/awk/func.c | 1364 + ase/awk/func.h | 49 + ase/awk/jni.c | 2350 ++ ase/awk/jni.def | 24 + ase/awk/jni.h | 60 + ase/awk/makefile.in | 152 + ase/awk/makefile.msw.bcc | 54 + ase/awk/makefile.msw.cl | 45 + ase/awk/map.c | 289 + ase/awk/map.h | 89 + ase/awk/misc.c | 905 + ase/awk/misc.h | 45 + ase/awk/parse.c | 5113 +++ ase/awk/parse.h | 29 + ase/awk/rec.c | 449 + ase/awk/rex.c | 1880 ++ ase/awk/rex.h | 75 + ase/awk/run.c | 7053 ++++ ase/awk/run.h | 119 + ase/awk/tab.c | 239 + ase/awk/tab.h | 69 + ase/awk/tree.c | 1176 + ase/awk/tree.h | 403 + ase/awk/val.c | 839 + ase/awk/val.h | 206 + ase/build.xml | 73 + ase/cmn/asecmn.dsp | 124 + ase/cmn/asecmn.vcproj | 263 + ase/cmn/conf_msw.h | 64 + ase/cmn/conf_unx.h.in | 44 + ase/cmn/conf_vms.h | 90 + ase/cmn/descrip.mms | 17 + ase/cmn/macros.h | 139 + ase/cmn/makefile.in | 49 + ase/cmn/makefile.msw.bcc | 29 + ase/cmn/makefile.msw.cl | 23 + ase/cmn/mem.c | 52 + ase/cmn/mem.h | 25 + ase/cmn/misc.c | 34 + ase/cmn/pack.h | 17 + ase/cmn/str.c | 385 + ase/cmn/str.h | 88 + ase/cmn/types.h | 276 + ase/cmn/unpack.h | 17 + ase/com/Awk.cpp | 1395 + ase/com/Awk.h | 171 + ase/com/Awk.rgs | 25 + ase/com/AwkExtio.cpp | 70 + ase/com/AwkExtio.h | 53 + ase/com/AwkExtio.rgs | 26 + ase/com/Buffer.cpp | 51 + ase/com/Buffer.h | 40 + ase/com/Buffer.rgs | 26 + ase/com/asecom.cpp | 78 + ase/com/asecom.def | 9 + ase/com/asecom.dsp | 207 + ase/com/asecom.idl | 318 + ase/com/asecom.rc | 121 + ase/com/asecom.vcproj | 441 + ase/com/aseps.def | 11 + ase/com/aseps.mk | 16 + ase/com/awk_cp.h | 637 + ase/com/resource.h | 19 + ase/com/stdafx.cpp | 18 + ase/com/stdafx.h | 29 + ase/config/config.guess | 1411 + ase/config/config.sub | 1500 + ase/config/install-sh | 316 + ase/config/ltmain.sh | 6425 ++++ ase/configure | 27053 ++++++++++++++++ ase/configure.ac | 198 + ase/doc/ase-en.man | 30 + ase/doc/ase-ko.man | 29 + ase/doc/awk-en.man | 202 + ase/doc/awk-mini-en.man | 458 + ase/doc/awk.man | 93 + ase/doc/diff.man | 11 + ase/doc/doc.css | 86 + ase/doc/embed.man | 51 + ase/doc/license.man | 19 + ase/doc/lsp-en.man | 22 + ase/doc/quickstart-en.man | 118 + ase/doc/quickstart-ko.man | 116 + ase/lsp/aselsp.dsp | 180 + ase/lsp/aselsp.vcproj | 522 + ase/lsp/descrip.mms | 28 + ase/lsp/env.c | 146 + ase/lsp/env.h | 63 + ase/lsp/err.c | 130 + ase/lsp/eval.c | 380 + ase/lsp/lsp.c | 218 + ase/lsp/lsp.h | 123 + ase/lsp/lsp_i.h | 87 + ase/lsp/makefile.in | 93 + ase/lsp/makefile.msw.bcc | 21 + ase/lsp/makefile.msw.cl | 24 + ase/lsp/mem.c | 603 + ase/lsp/mem.h | 99 + ase/lsp/misc.c | 575 + ase/lsp/misc.h | 26 + ase/lsp/name.c | 125 + ase/lsp/name.h | 42 + ase/lsp/obj.h | 161 + ase/lsp/prim.c | 621 + ase/lsp/prim.h | 69 + ase/lsp/prim_compar.c | 141 + ase/lsp/prim_let.c | 186 + ase/lsp/prim_math.c | 351 + ase/lsp/prim_prog.c | 53 + ase/lsp/print.c | 150 + ase/lsp/read.c | 567 + ase/makefile.in | 46 + ase/net/AssemblyInfo.cpp | 40 + ase/net/Stdafx.cpp | 5 + ase/net/Stdafx.h | 7 + ase/net/app.ico | Bin 0 -> 1078 bytes ase/net/app.rc | 63 + ase/net/asenet.vcproj | 242 + ase/net/resource.h | 3 + ase/rel/doc.awk | 266 + ase/rel/lic.awk | 21 + ase/rel/rel.sh | 144 + ase/rel/unix2dos.awk | 2 + ase/stx/array.c | 18 + ase/stx/array.h | 21 + ase/stx/bootstrp.c | 676 + ase/stx/bootstrp.h | 21 + ase/stx/bytecode.c | 193 + ase/stx/bytecode.h | 56 + ase/stx/class.c | 168 + ase/stx/class.h | 81 + ase/stx/context.c | 75 + ase/stx/context.h | 43 + ase/stx/dict.c | 190 + ase/stx/dict.h | 42 + ase/stx/interp.c | 380 + ase/stx/interp.h | 20 + ase/stx/makefile.bcc | 21 + ase/stx/makefile.cl | 23 + ase/stx/makefile.in | 28 + ase/stx/makefile.lcc | 22 + ase/stx/makefile.tcc | 22 + ase/stx/memory.c | 98 + ase/stx/memory.h | 26 + ase/stx/method.h | 50 + ase/stx/misc.c | 70 + ase/stx/misc.h | 63 + ase/stx/name.c | 146 + ase/stx/name.h | 39 + ase/stx/object.c | 246 + ase/stx/object.h | 40 + ase/stx/parser.c | 1608 + ase/stx/parser.h | 107 + ase/stx/stx.bnf | 196 + ase/stx/stx.c | 70 + ase/stx/stx.h | 163 + ase/stx/stx.txt | 90 + ase/stx/symbol.c | 102 + ase/stx/symbol.h | 40 + ase/stx/token.c | 77 + ase/stx/token.h | 66 + ase/test/awk/AseAwk.java | 142 + ase/test/awk/AseAwkApplet.html | 9 + ase/test/awk/AseAwkApplet.java | 23 + ase/test/awk/AseAwkPanel.java | 404 + ase/test/awk/arg.awk | 34 + ase/test/awk/arr.awk | 18 + ase/test/awk/asetestawk.dsp | 102 + ase/test/awk/asetestawk.vcproj | 247 + ase/test/awk/awk.c | 1082 + ase/test/awk/comp.awk | 121 + ase/test/awk/cou-001.awk | 1 + ase/test/awk/cou-001.out | 15 + ase/test/awk/cou-002.awk | 15 + ase/test/awk/cou-002.out | 29 + ase/test/awk/cou-003.awk | 1 + ase/test/awk/cou-003.out | 6 + ase/test/awk/cou-004.awk | 1 + ase/test/awk/cou-004.out | 5 + ase/test/awk/cou-005.awk | 1 + ase/test/awk/cou-005.out | 6 + ase/test/awk/cou-006.awk | 1 + ase/test/awk/cou-006.out | 5 + ase/test/awk/cou-007.awk | 1 + ase/test/awk/cou-007.out | 6 + ase/test/awk/cou-008.awk | 1 + ase/test/awk/cou-008.out | 6 + ase/test/awk/cou-009.awk | 1 + ase/test/awk/cou-009.out | 9 + ase/test/awk/cou-010.awk | 1 + ase/test/awk/cou-010.out | 6 + ase/test/awk/cou-011.awk | 3 + ase/test/awk/cou-011.out | 2 + ase/test/awk/cou-012.awk | 1 + ase/test/awk/cou-012.out | 4 + ase/test/awk/cou-013.awk | 1 + ase/test/awk/cou-013.out | 9 + ase/test/awk/cou-014.awk | 1 + ase/test/awk/cou-014.out | 9 + ase/test/awk/cou-015.awk | 1 + ase/test/awk/cou-015.out | 9 + ase/test/awk/cou-016.awk | 1 + ase/test/awk/cou-016.out | 9 + ase/test/awk/cou-017.awk | 1 + ase/test/awk/cou-017.out | 5 + ase/test/awk/cou-018.awk | 1 + ase/test/awk/cou-018.out | 2 + ase/test/awk/cou-019.awk | 1 + ase/test/awk/cou-019.out | 9 + ase/test/awk/cou-020.awk | 1 + ase/test/awk/cou-020.out | 9 + ase/test/awk/cou-021.awk | 1 + ase/test/awk/cou-021.out | 8 + ase/test/awk/cou-022.awk | 6 + ase/test/awk/cou-022.out | 27 + ase/test/awk/cou-023.awk | 2 + ase/test/awk/cou-023.out | 20 + ase/test/awk/cou-024.awk | 4 + ase/test/awk/cou-024.out | 9 + ase/test/awk/cou-025.awk | 6 + ase/test/awk/cou-025.out | 14 + ase/test/awk/cou-026.awk | 3 + ase/test/awk/cou-026.out | 16 + ase/test/awk/cou-027.awk | 5 + ase/test/awk/cou-027.out | 16 + ase/test/awk/cou-en.data | 11 + ase/test/awk/crash01.awk | 1 + ase/test/awk/crash02.awk | 9 + ase/test/awk/crash04.awk | 17 + ase/test/awk/crash05.awk | 5 + ase/test/awk/crash08.awk | 23 + ase/test/awk/descrip.mms | 13 + ase/test/awk/emp-001.awk | 1 + ase/test/awk/emp-001.out | 8 + ase/test/awk/emp-002.awk | 1 + ase/test/awk/emp-002.out | 6 + ase/test/awk/emp-003.awk | 1 + ase/test/awk/emp-003.out | 10 + ase/test/awk/emp-004.awk | 1 + ase/test/awk/emp-004.out | 10 + ase/test/awk/emp-005.awk | 1 + ase/test/awk/emp-005.out | 10 + ase/test/awk/emp-006.awk | 1 + ase/test/awk/emp-006.out | 10 + ase/test/awk/emp-007.awk | 1 + ase/test/awk/emp-007.out | 10 + ase/test/awk/emp-008.awk | 1 + ase/test/awk/emp-008.out | 4 + ase/test/awk/emp-009.awk | 1 + ase/test/awk/emp-009.out | 7 + ase/test/awk/emp-010.awk | 1 + ase/test/awk/emp-010.out | 3 + ase/test/awk/emp-011.awk | 1 + ase/test/awk/emp-011.out | 3 + ase/test/awk/emp-012.awk | 1 + ase/test/awk/emp-012.out | 7 + ase/test/awk/emp-013.awk | 2 + ase/test/awk/emp-013.out | 11 + ase/test/awk/emp-014.awk | 1 + ase/test/awk/emp-014.out | 7 + ase/test/awk/emp-015.awk | 5 + ase/test/awk/emp-015.out | 20 + ase/test/awk/emp-016.awk | 2 + ase/test/awk/emp-016.out | 17 + ase/test/awk/emp-017.awk | 2 + ase/test/awk/emp-017.out | 8 + ase/test/awk/emp-018.awk | 1 + ase/test/awk/emp-018.out | 4 + ase/test/awk/emp-019.awk | 5 + ase/test/awk/emp-019.out | 12 + ase/test/awk/emp-020.awk | 2 + ase/test/awk/emp-020.out | 9 + ase/test/awk/emp-021.awk | 2 + ase/test/awk/emp-021.out | 8 + ase/test/awk/emp-022.awk | 2 + ase/test/awk/emp-022.out | 8 + ase/test/awk/emp-023.awk | 1 + ase/test/awk/emp-023.out | 10 + ase/test/awk/emp-024.awk | 4 + ase/test/awk/emp-024.out | 9 + ase/test/awk/emp-025.awk | 7 + ase/test/awk/emp-025.out | 12 + ase/test/awk/emp-026.awk | 12 + ase/test/awk/emp-026.out | 18 + ase/test/awk/emp-027.awk | 8 + ase/test/awk/emp-027.out | 15 + ase/test/awk/emp-en.data | 6 + ase/test/awk/emp-ko.data | 6 + ase/test/awk/err-001.awk | Bin 0 -> 10 bytes ase/test/awk/err-001.out | 1 + ase/test/awk/err-002.awk | 3 + ase/test/awk/err-002.out | 4 + ase/test/awk/err-003.awk | 6 + ase/test/awk/err-003.out | 8 + ase/test/awk/err-004.awk | 3 + ase/test/awk/err-004.out | 5 + ase/test/awk/err-005.awk | 4 + ase/test/awk/err-005.out | 6 + ase/test/awk/err-006.awk | 3 + ase/test/awk/err-006.out | 5 + ase/test/awk/err-007.awk | 4 + ase/test/awk/err-007.out | 1 + ase/test/awk/err-008.awk | 6 + ase/test/awk/err-008.out | 1 + ase/test/awk/err-009.awk | 19 + ase/test/awk/err-009.out | 1 + ase/test/awk/err-010.awk | 15 + ase/test/awk/err-010.out | 1 + ase/test/awk/err-011.awk | 13 + ase/test/awk/err-011.out | 1 + ase/test/awk/err-012.awk | 14 + ase/test/awk/err-012.out | 1 + ase/test/awk/err-013.awk | 3 + ase/test/awk/err-013.out | 1 + ase/test/awk/err-014.awk | 7 + ase/test/awk/err-014.out | 1 + ase/test/awk/err-015.awk | 3 + ase/test/awk/err-015.out | 1 + ase/test/awk/err-016.awk | 5 + ase/test/awk/err-016.out | 1 + ase/test/awk/err-017.awk | 1 + ase/test/awk/err-017.out | 1 + ase/test/awk/err-018.awk | 2 + ase/test/awk/err-018.out | 1 + ase/test/awk/err-019.awk | 5 + ase/test/awk/err-019.out | 1 + ase/test/awk/err-020.awk | 4 + ase/test/awk/err-020.out | 5 + ase/test/awk/err-021.awk | 4 + ase/test/awk/err-021.out | 6 + ase/test/awk/err-en.data | 2 + ase/test/awk/histsort.awk | 8 + ase/test/awk/ite-001.awk | 7 + ase/test/awk/ite-002.awk | 4 + ase/test/awk/makefile.in | 59 + ase/test/awk/makefile.msw.bcc | 34 + ase/test/awk/makefile.msw.cl | 43 + ase/test/awk/manifest | 1 + ase/test/awk/match.awk | 19 + ase/test/awk/mini.c | 427 + ase/test/awk/mkjar.bat | 8 + ase/test/awk/negnum.data | 6 + ase/test/awk/num.awk | 27 + ase/test/awk/pow.awk | 43 + ase/test/awk/regress.sh | 140 + ase/test/awk/t1.awk | 21 + ase/test/awk/t10.awk | 22 + ase/test/awk/t11.awk | 17 + ase/test/awk/t12.awk | 38 + ase/test/awk/t13.awk | 22 + ase/test/awk/t14.awk | 28 + ase/test/awk/t15.awk | 16 + ase/test/awk/t16.awk | 1 + ase/test/awk/t17.awk | 18 + ase/test/awk/t18.awk | 21 + ase/test/awk/t19.awk | 4 + ase/test/awk/t2.awk | 24 + ase/test/awk/t20.awk | 8 + ase/test/awk/t21.awk | 8 + ase/test/awk/t22.awk | 15 + ase/test/awk/t23.awk | 19 + ase/test/awk/t24.awk | 6 + ase/test/awk/t25.awk | 13 + ase/test/awk/t26.awk | 13 + ase/test/awk/t27.awk | 6 + ase/test/awk/t28.awk | 41 + ase/test/awk/t29.awk | 3 + ase/test/awk/t3.awk | 25 + ase/test/awk/t30.awk | 3 + ase/test/awk/t31.awk | 2 + ase/test/awk/t32.awk | 2 + ase/test/awk/t33.awk | 15 + ase/test/awk/t34.awk | 1 + ase/test/awk/t35.awk | 4 + ase/test/awk/t36.awk | 47 + ase/test/awk/t37.awk | 6 + ase/test/awk/t38.awk | 9 + ase/test/awk/t39.awk | 9 + ase/test/awk/t4.awk | 21 + ase/test/awk/t40.awk | 8 + ase/test/awk/t41.awk | 4 + ase/test/awk/t42.awk | 13 + ase/test/awk/t43.awk | 3 + ase/test/awk/t44.awk | 3 + ase/test/awk/t45.awk | 1 + ase/test/awk/t46.awk | 1 + ase/test/awk/t47.awk | 19 + ase/test/awk/t48.awk | 3 + ase/test/awk/t49.awk | 5 + ase/test/awk/t5.awk | 10 + ase/test/awk/t50.awk | 6 + ase/test/awk/t6.awk | 21 + ase/test/awk/t7.awk | 5 + ase/test/awk/t8.awk | 2 + ase/test/awk/t9.awk | 25 + ase/test/awk/unr-001.awk | 6 + ase/test/awk/wordfreq.awk | 20 + ase/test/awk/x.awk | 31 + ase/test/cnt/AwkForm.Designer.cs | 381 + ase/test/cnt/AwkForm.cs | 87 + ase/test/cnt/AwkForm.resx | 123 + ase/test/cnt/Program.cs | 20 + ase/test/cnt/Properties/AssemblyInfo.cs | 33 + ase/test/cnt/Properties/Resources.Designer.cs | 63 + ase/test/cnt/Properties/Resources.resx | 117 + ase/test/cnt/Properties/Settings.Designer.cs | 26 + ase/test/cnt/Properties/Settings.settings | 7 + ase/test/cnt/asetestcnt.csproj | 89 + ase/test/com/AwkExtioConsole.cls | 32 + ase/test/com/AwkForm.frm | 552 + ase/test/com/AwkForm.frx | Bin 0 -> 17 bytes ase/test/com/asetestcom.vbp | 39 + ase/test/com/asetestcom.vbw | 2 + ase/test/com/awk.js | 72 + ase/test/com/awk.vbs | 30 + ase/test/lsp/asetestlsp.dsp | 102 + ase/test/lsp/asetestlsp.vcproj | 247 + ase/test/lsp/descrip.mms | 13 + ase/test/lsp/lsp.c | 402 + ase/test/lsp/makefile.in | 23 + ase/test/lsp/makefile.msw.bcc | 19 + ase/test/lsp/makefile.msw.cl | 17 + ase/test/lsp/t1.lsp | 21 + ase/test/lsp/t2.lsp | 170 + ase/test/lsp/t3.lsp | 8 + ase/test/lsp/t4.lsp | 7 + ase/test/lsp/t5.lsp | 8 + ase/test/lsp/t6.lsp | 9 + ase/test/lsp/t7.lsp | 4 + ase/test/stx/helper.st | 13 + ase/test/stx/makefile.bcc | 21 + ase/test/stx/makefile.cl | 20 + ase/test/stx/makefile.in | 19 + ase/test/stx/makefile.lcc | 24 + ase/test/stx/makefile.tcc | 19 + ase/test/stx/parser.c | 230 + ase/test/stx/stx.c | 237 + ase/test/stx/test.st | 13 + ase/test/stx/test1.st | 10 + ase/test/stx/test2.st | 2 + ase/test/stx/test3.st | 2 + ase/utl/aseutl.dsp | 127 + ase/utl/aseutl.vcproj | 267 + ase/utl/ctype.c | 150 + ase/utl/ctype.h | 34 + ase/utl/descrip.mms | 16 + ase/utl/main.c | 89 + ase/utl/main.h | 26 + ase/utl/makefile.in | 49 + ase/utl/makefile.msw.bcc | 31 + ase/utl/makefile.msw.cl | 23 + ase/utl/stdio.c | 366 + ase/utl/stdio.h | 55 + 474 files changed, 99385 insertions(+) create mode 100644 ase/aclocal.m4 create mode 100644 ase/ase.dsw create mode 100644 ase/ase.sln create mode 100644 ase/awk/Awk.cpp create mode 100644 ase/awk/Awk.hpp create mode 100644 ase/awk/Awk.java create mode 100644 ase/awk/Exception.java create mode 100644 ase/awk/Extio.java create mode 100644 ase/awk/StdAwk.java create mode 100644 ase/awk/aseawk.dsp create mode 100644 ase/awk/aseawk.vcproj create mode 100644 ase/awk/aseawk_jni.dsp create mode 100644 ase/awk/aseawk_jni.vcproj create mode 100644 ase/awk/awk.c create mode 100644 ase/awk/awk.h create mode 100644 ase/awk/awk.txt create mode 100644 ase/awk/awk_i.h create mode 100644 ase/awk/descrip.mms create mode 100644 ase/awk/err.c create mode 100644 ase/awk/extio.c create mode 100644 ase/awk/extio.h create mode 100644 ase/awk/func.c create mode 100644 ase/awk/func.h create mode 100644 ase/awk/jni.c create mode 100644 ase/awk/jni.def create mode 100644 ase/awk/jni.h create mode 100644 ase/awk/makefile.in create mode 100644 ase/awk/makefile.msw.bcc create mode 100644 ase/awk/makefile.msw.cl create mode 100644 ase/awk/map.c create mode 100644 ase/awk/map.h create mode 100644 ase/awk/misc.c create mode 100644 ase/awk/misc.h create mode 100644 ase/awk/parse.c create mode 100644 ase/awk/parse.h create mode 100644 ase/awk/rec.c create mode 100644 ase/awk/rex.c create mode 100644 ase/awk/rex.h create mode 100644 ase/awk/run.c create mode 100644 ase/awk/run.h create mode 100644 ase/awk/tab.c create mode 100644 ase/awk/tab.h create mode 100644 ase/awk/tree.c create mode 100644 ase/awk/tree.h create mode 100644 ase/awk/val.c create mode 100644 ase/awk/val.h create mode 100644 ase/build.xml create mode 100644 ase/cmn/asecmn.dsp create mode 100644 ase/cmn/asecmn.vcproj create mode 100644 ase/cmn/conf_msw.h create mode 100644 ase/cmn/conf_unx.h.in create mode 100644 ase/cmn/conf_vms.h create mode 100644 ase/cmn/descrip.mms create mode 100644 ase/cmn/macros.h create mode 100644 ase/cmn/makefile.in create mode 100644 ase/cmn/makefile.msw.bcc create mode 100644 ase/cmn/makefile.msw.cl create mode 100644 ase/cmn/mem.c create mode 100644 ase/cmn/mem.h create mode 100644 ase/cmn/misc.c create mode 100644 ase/cmn/pack.h create mode 100644 ase/cmn/str.c create mode 100644 ase/cmn/str.h create mode 100644 ase/cmn/types.h create mode 100644 ase/cmn/unpack.h create mode 100644 ase/com/Awk.cpp create mode 100644 ase/com/Awk.h create mode 100644 ase/com/Awk.rgs create mode 100644 ase/com/AwkExtio.cpp create mode 100644 ase/com/AwkExtio.h create mode 100644 ase/com/AwkExtio.rgs create mode 100644 ase/com/Buffer.cpp create mode 100644 ase/com/Buffer.h create mode 100644 ase/com/Buffer.rgs create mode 100644 ase/com/asecom.cpp create mode 100644 ase/com/asecom.def create mode 100644 ase/com/asecom.dsp create mode 100644 ase/com/asecom.idl create mode 100644 ase/com/asecom.rc create mode 100644 ase/com/asecom.vcproj create mode 100644 ase/com/aseps.def create mode 100644 ase/com/aseps.mk create mode 100644 ase/com/awk_cp.h create mode 100644 ase/com/resource.h create mode 100644 ase/com/stdafx.cpp create mode 100644 ase/com/stdafx.h create mode 100755 ase/config/config.guess create mode 100755 ase/config/config.sub create mode 100755 ase/config/install-sh create mode 100644 ase/config/ltmain.sh create mode 100755 ase/configure create mode 100644 ase/configure.ac create mode 100644 ase/doc/ase-en.man create mode 100644 ase/doc/ase-ko.man create mode 100644 ase/doc/awk-en.man create mode 100644 ase/doc/awk-mini-en.man create mode 100644 ase/doc/awk.man create mode 100644 ase/doc/diff.man create mode 100644 ase/doc/doc.css create mode 100644 ase/doc/embed.man create mode 100644 ase/doc/license.man create mode 100644 ase/doc/lsp-en.man create mode 100644 ase/doc/quickstart-en.man create mode 100644 ase/doc/quickstart-ko.man create mode 100644 ase/lsp/aselsp.dsp create mode 100644 ase/lsp/aselsp.vcproj create mode 100644 ase/lsp/descrip.mms create mode 100644 ase/lsp/env.c create mode 100644 ase/lsp/env.h create mode 100644 ase/lsp/err.c create mode 100644 ase/lsp/eval.c create mode 100644 ase/lsp/lsp.c create mode 100644 ase/lsp/lsp.h create mode 100644 ase/lsp/lsp_i.h create mode 100644 ase/lsp/makefile.in create mode 100644 ase/lsp/makefile.msw.bcc create mode 100644 ase/lsp/makefile.msw.cl create mode 100644 ase/lsp/mem.c create mode 100644 ase/lsp/mem.h create mode 100644 ase/lsp/misc.c create mode 100644 ase/lsp/misc.h create mode 100644 ase/lsp/name.c create mode 100644 ase/lsp/name.h create mode 100644 ase/lsp/obj.h create mode 100644 ase/lsp/prim.c create mode 100644 ase/lsp/prim.h create mode 100644 ase/lsp/prim_compar.c create mode 100644 ase/lsp/prim_let.c create mode 100644 ase/lsp/prim_math.c create mode 100644 ase/lsp/prim_prog.c create mode 100644 ase/lsp/print.c create mode 100644 ase/lsp/read.c create mode 100644 ase/makefile.in create mode 100644 ase/net/AssemblyInfo.cpp create mode 100644 ase/net/Stdafx.cpp create mode 100644 ase/net/Stdafx.h create mode 100644 ase/net/app.ico create mode 100644 ase/net/app.rc create mode 100644 ase/net/asenet.vcproj create mode 100644 ase/net/resource.h create mode 100644 ase/rel/doc.awk create mode 100644 ase/rel/lic.awk create mode 100755 ase/rel/rel.sh create mode 100644 ase/rel/unix2dos.awk create mode 100644 ase/stx/array.c create mode 100644 ase/stx/array.h create mode 100644 ase/stx/bootstrp.c create mode 100644 ase/stx/bootstrp.h create mode 100644 ase/stx/bytecode.c create mode 100644 ase/stx/bytecode.h create mode 100644 ase/stx/class.c create mode 100644 ase/stx/class.h create mode 100644 ase/stx/context.c create mode 100644 ase/stx/context.h create mode 100644 ase/stx/dict.c create mode 100644 ase/stx/dict.h create mode 100644 ase/stx/interp.c create mode 100644 ase/stx/interp.h create mode 100644 ase/stx/makefile.bcc create mode 100644 ase/stx/makefile.cl create mode 100644 ase/stx/makefile.in create mode 100644 ase/stx/makefile.lcc create mode 100644 ase/stx/makefile.tcc create mode 100644 ase/stx/memory.c create mode 100644 ase/stx/memory.h create mode 100644 ase/stx/method.h create mode 100644 ase/stx/misc.c create mode 100644 ase/stx/misc.h create mode 100644 ase/stx/name.c create mode 100644 ase/stx/name.h create mode 100644 ase/stx/object.c create mode 100644 ase/stx/object.h create mode 100644 ase/stx/parser.c create mode 100644 ase/stx/parser.h create mode 100644 ase/stx/stx.bnf create mode 100644 ase/stx/stx.c create mode 100644 ase/stx/stx.h create mode 100644 ase/stx/stx.txt create mode 100644 ase/stx/symbol.c create mode 100644 ase/stx/symbol.h create mode 100644 ase/stx/token.c create mode 100644 ase/stx/token.h create mode 100644 ase/test/awk/AseAwk.java create mode 100644 ase/test/awk/AseAwkApplet.html create mode 100644 ase/test/awk/AseAwkApplet.java create mode 100644 ase/test/awk/AseAwkPanel.java create mode 100644 ase/test/awk/arg.awk create mode 100644 ase/test/awk/arr.awk create mode 100644 ase/test/awk/asetestawk.dsp create mode 100644 ase/test/awk/asetestawk.vcproj create mode 100644 ase/test/awk/awk.c create mode 100644 ase/test/awk/comp.awk create mode 100644 ase/test/awk/cou-001.awk create mode 100644 ase/test/awk/cou-001.out create mode 100644 ase/test/awk/cou-002.awk create mode 100644 ase/test/awk/cou-002.out create mode 100644 ase/test/awk/cou-003.awk create mode 100644 ase/test/awk/cou-003.out create mode 100644 ase/test/awk/cou-004.awk create mode 100644 ase/test/awk/cou-004.out create mode 100644 ase/test/awk/cou-005.awk create mode 100644 ase/test/awk/cou-005.out create mode 100644 ase/test/awk/cou-006.awk create mode 100644 ase/test/awk/cou-006.out create mode 100644 ase/test/awk/cou-007.awk create mode 100644 ase/test/awk/cou-007.out create mode 100644 ase/test/awk/cou-008.awk create mode 100644 ase/test/awk/cou-008.out create mode 100644 ase/test/awk/cou-009.awk create mode 100644 ase/test/awk/cou-009.out create mode 100644 ase/test/awk/cou-010.awk create mode 100644 ase/test/awk/cou-010.out create mode 100644 ase/test/awk/cou-011.awk create mode 100644 ase/test/awk/cou-011.out create mode 100644 ase/test/awk/cou-012.awk create mode 100644 ase/test/awk/cou-012.out create mode 100644 ase/test/awk/cou-013.awk create mode 100644 ase/test/awk/cou-013.out create mode 100644 ase/test/awk/cou-014.awk create mode 100644 ase/test/awk/cou-014.out create mode 100644 ase/test/awk/cou-015.awk create mode 100644 ase/test/awk/cou-015.out create mode 100644 ase/test/awk/cou-016.awk create mode 100644 ase/test/awk/cou-016.out create mode 100644 ase/test/awk/cou-017.awk create mode 100644 ase/test/awk/cou-017.out create mode 100644 ase/test/awk/cou-018.awk create mode 100644 ase/test/awk/cou-018.out create mode 100644 ase/test/awk/cou-019.awk create mode 100644 ase/test/awk/cou-019.out create mode 100644 ase/test/awk/cou-020.awk create mode 100644 ase/test/awk/cou-020.out create mode 100644 ase/test/awk/cou-021.awk create mode 100644 ase/test/awk/cou-021.out create mode 100644 ase/test/awk/cou-022.awk create mode 100644 ase/test/awk/cou-022.out create mode 100644 ase/test/awk/cou-023.awk create mode 100644 ase/test/awk/cou-023.out create mode 100644 ase/test/awk/cou-024.awk create mode 100644 ase/test/awk/cou-024.out create mode 100644 ase/test/awk/cou-025.awk create mode 100644 ase/test/awk/cou-025.out create mode 100644 ase/test/awk/cou-026.awk create mode 100644 ase/test/awk/cou-026.out create mode 100644 ase/test/awk/cou-027.awk create mode 100644 ase/test/awk/cou-027.out create mode 100644 ase/test/awk/cou-en.data create mode 100644 ase/test/awk/crash01.awk create mode 100644 ase/test/awk/crash02.awk create mode 100644 ase/test/awk/crash04.awk create mode 100644 ase/test/awk/crash05.awk create mode 100644 ase/test/awk/crash08.awk create mode 100644 ase/test/awk/descrip.mms create mode 100644 ase/test/awk/emp-001.awk create mode 100644 ase/test/awk/emp-001.out create mode 100644 ase/test/awk/emp-002.awk create mode 100644 ase/test/awk/emp-002.out create mode 100644 ase/test/awk/emp-003.awk create mode 100644 ase/test/awk/emp-003.out create mode 100644 ase/test/awk/emp-004.awk create mode 100644 ase/test/awk/emp-004.out create mode 100644 ase/test/awk/emp-005.awk create mode 100644 ase/test/awk/emp-005.out create mode 100644 ase/test/awk/emp-006.awk create mode 100644 ase/test/awk/emp-006.out create mode 100644 ase/test/awk/emp-007.awk create mode 100644 ase/test/awk/emp-007.out create mode 100644 ase/test/awk/emp-008.awk create mode 100644 ase/test/awk/emp-008.out create mode 100644 ase/test/awk/emp-009.awk create mode 100644 ase/test/awk/emp-009.out create mode 100644 ase/test/awk/emp-010.awk create mode 100644 ase/test/awk/emp-010.out create mode 100644 ase/test/awk/emp-011.awk create mode 100644 ase/test/awk/emp-011.out create mode 100644 ase/test/awk/emp-012.awk create mode 100644 ase/test/awk/emp-012.out create mode 100644 ase/test/awk/emp-013.awk create mode 100644 ase/test/awk/emp-013.out create mode 100644 ase/test/awk/emp-014.awk create mode 100644 ase/test/awk/emp-014.out create mode 100644 ase/test/awk/emp-015.awk create mode 100644 ase/test/awk/emp-015.out create mode 100644 ase/test/awk/emp-016.awk create mode 100644 ase/test/awk/emp-016.out create mode 100644 ase/test/awk/emp-017.awk create mode 100644 ase/test/awk/emp-017.out create mode 100644 ase/test/awk/emp-018.awk create mode 100644 ase/test/awk/emp-018.out create mode 100644 ase/test/awk/emp-019.awk create mode 100644 ase/test/awk/emp-019.out create mode 100644 ase/test/awk/emp-020.awk create mode 100644 ase/test/awk/emp-020.out create mode 100644 ase/test/awk/emp-021.awk create mode 100644 ase/test/awk/emp-021.out create mode 100644 ase/test/awk/emp-022.awk create mode 100644 ase/test/awk/emp-022.out create mode 100644 ase/test/awk/emp-023.awk create mode 100644 ase/test/awk/emp-023.out create mode 100644 ase/test/awk/emp-024.awk create mode 100644 ase/test/awk/emp-024.out create mode 100644 ase/test/awk/emp-025.awk create mode 100644 ase/test/awk/emp-025.out create mode 100644 ase/test/awk/emp-026.awk create mode 100644 ase/test/awk/emp-026.out create mode 100644 ase/test/awk/emp-027.awk create mode 100644 ase/test/awk/emp-027.out create mode 100644 ase/test/awk/emp-en.data create mode 100644 ase/test/awk/emp-ko.data create mode 100644 ase/test/awk/err-001.awk create mode 100644 ase/test/awk/err-001.out create mode 100644 ase/test/awk/err-002.awk create mode 100644 ase/test/awk/err-002.out create mode 100644 ase/test/awk/err-003.awk create mode 100644 ase/test/awk/err-003.out create mode 100644 ase/test/awk/err-004.awk create mode 100644 ase/test/awk/err-004.out create mode 100644 ase/test/awk/err-005.awk create mode 100644 ase/test/awk/err-005.out create mode 100644 ase/test/awk/err-006.awk create mode 100644 ase/test/awk/err-006.out create mode 100644 ase/test/awk/err-007.awk create mode 100644 ase/test/awk/err-007.out create mode 100644 ase/test/awk/err-008.awk create mode 100644 ase/test/awk/err-008.out create mode 100644 ase/test/awk/err-009.awk create mode 100644 ase/test/awk/err-009.out create mode 100644 ase/test/awk/err-010.awk create mode 100644 ase/test/awk/err-010.out create mode 100644 ase/test/awk/err-011.awk create mode 100644 ase/test/awk/err-011.out create mode 100644 ase/test/awk/err-012.awk create mode 100644 ase/test/awk/err-012.out create mode 100644 ase/test/awk/err-013.awk create mode 100644 ase/test/awk/err-013.out create mode 100644 ase/test/awk/err-014.awk create mode 100644 ase/test/awk/err-014.out create mode 100644 ase/test/awk/err-015.awk create mode 100644 ase/test/awk/err-015.out create mode 100644 ase/test/awk/err-016.awk create mode 100644 ase/test/awk/err-016.out create mode 100644 ase/test/awk/err-017.awk create mode 100644 ase/test/awk/err-017.out create mode 100644 ase/test/awk/err-018.awk create mode 100644 ase/test/awk/err-018.out create mode 100644 ase/test/awk/err-019.awk create mode 100644 ase/test/awk/err-019.out create mode 100644 ase/test/awk/err-020.awk create mode 100644 ase/test/awk/err-020.out create mode 100644 ase/test/awk/err-021.awk create mode 100644 ase/test/awk/err-021.out create mode 100644 ase/test/awk/err-en.data create mode 100644 ase/test/awk/histsort.awk create mode 100644 ase/test/awk/ite-001.awk create mode 100644 ase/test/awk/ite-002.awk create mode 100644 ase/test/awk/makefile.in create mode 100644 ase/test/awk/makefile.msw.bcc create mode 100644 ase/test/awk/makefile.msw.cl create mode 100644 ase/test/awk/manifest create mode 100644 ase/test/awk/match.awk create mode 100644 ase/test/awk/mini.c create mode 100644 ase/test/awk/mkjar.bat create mode 100644 ase/test/awk/negnum.data create mode 100644 ase/test/awk/num.awk create mode 100644 ase/test/awk/pow.awk create mode 100755 ase/test/awk/regress.sh create mode 100644 ase/test/awk/t1.awk create mode 100644 ase/test/awk/t10.awk create mode 100644 ase/test/awk/t11.awk create mode 100644 ase/test/awk/t12.awk create mode 100644 ase/test/awk/t13.awk create mode 100644 ase/test/awk/t14.awk create mode 100644 ase/test/awk/t15.awk create mode 100644 ase/test/awk/t16.awk create mode 100644 ase/test/awk/t17.awk create mode 100644 ase/test/awk/t18.awk create mode 100644 ase/test/awk/t19.awk create mode 100644 ase/test/awk/t2.awk create mode 100644 ase/test/awk/t20.awk create mode 100644 ase/test/awk/t21.awk create mode 100644 ase/test/awk/t22.awk create mode 100644 ase/test/awk/t23.awk create mode 100644 ase/test/awk/t24.awk create mode 100644 ase/test/awk/t25.awk create mode 100644 ase/test/awk/t26.awk create mode 100644 ase/test/awk/t27.awk create mode 100644 ase/test/awk/t28.awk create mode 100644 ase/test/awk/t29.awk create mode 100644 ase/test/awk/t3.awk create mode 100644 ase/test/awk/t30.awk create mode 100644 ase/test/awk/t31.awk create mode 100644 ase/test/awk/t32.awk create mode 100644 ase/test/awk/t33.awk create mode 100644 ase/test/awk/t34.awk create mode 100644 ase/test/awk/t35.awk create mode 100644 ase/test/awk/t36.awk create mode 100644 ase/test/awk/t37.awk create mode 100644 ase/test/awk/t38.awk create mode 100644 ase/test/awk/t39.awk create mode 100644 ase/test/awk/t4.awk create mode 100644 ase/test/awk/t40.awk create mode 100644 ase/test/awk/t41.awk create mode 100644 ase/test/awk/t42.awk create mode 100644 ase/test/awk/t43.awk create mode 100644 ase/test/awk/t44.awk create mode 100644 ase/test/awk/t45.awk create mode 100644 ase/test/awk/t46.awk create mode 100644 ase/test/awk/t47.awk create mode 100644 ase/test/awk/t48.awk create mode 100644 ase/test/awk/t49.awk create mode 100644 ase/test/awk/t5.awk create mode 100644 ase/test/awk/t50.awk create mode 100644 ase/test/awk/t6.awk create mode 100644 ase/test/awk/t7.awk create mode 100644 ase/test/awk/t8.awk create mode 100644 ase/test/awk/t9.awk create mode 100644 ase/test/awk/unr-001.awk create mode 100644 ase/test/awk/wordfreq.awk create mode 100644 ase/test/awk/x.awk create mode 100644 ase/test/cnt/AwkForm.Designer.cs create mode 100644 ase/test/cnt/AwkForm.cs create mode 100644 ase/test/cnt/AwkForm.resx create mode 100644 ase/test/cnt/Program.cs create mode 100644 ase/test/cnt/Properties/AssemblyInfo.cs create mode 100644 ase/test/cnt/Properties/Resources.Designer.cs create mode 100644 ase/test/cnt/Properties/Resources.resx create mode 100644 ase/test/cnt/Properties/Settings.Designer.cs create mode 100644 ase/test/cnt/Properties/Settings.settings create mode 100644 ase/test/cnt/asetestcnt.csproj create mode 100644 ase/test/com/AwkExtioConsole.cls create mode 100644 ase/test/com/AwkForm.frm create mode 100644 ase/test/com/AwkForm.frx create mode 100644 ase/test/com/asetestcom.vbp create mode 100644 ase/test/com/asetestcom.vbw create mode 100644 ase/test/com/awk.js create mode 100644 ase/test/com/awk.vbs create mode 100644 ase/test/lsp/asetestlsp.dsp create mode 100644 ase/test/lsp/asetestlsp.vcproj create mode 100644 ase/test/lsp/descrip.mms create mode 100644 ase/test/lsp/lsp.c create mode 100644 ase/test/lsp/makefile.in create mode 100644 ase/test/lsp/makefile.msw.bcc create mode 100644 ase/test/lsp/makefile.msw.cl create mode 100644 ase/test/lsp/t1.lsp create mode 100644 ase/test/lsp/t2.lsp create mode 100644 ase/test/lsp/t3.lsp create mode 100644 ase/test/lsp/t4.lsp create mode 100644 ase/test/lsp/t5.lsp create mode 100644 ase/test/lsp/t6.lsp create mode 100644 ase/test/lsp/t7.lsp create mode 100644 ase/test/stx/helper.st create mode 100644 ase/test/stx/makefile.bcc create mode 100644 ase/test/stx/makefile.cl create mode 100644 ase/test/stx/makefile.in create mode 100644 ase/test/stx/makefile.lcc create mode 100644 ase/test/stx/makefile.tcc create mode 100644 ase/test/stx/parser.c create mode 100644 ase/test/stx/stx.c create mode 100644 ase/test/stx/test.st create mode 100644 ase/test/stx/test1.st create mode 100644 ase/test/stx/test2.st create mode 100644 ase/test/stx/test3.st create mode 100644 ase/utl/aseutl.dsp create mode 100644 ase/utl/aseutl.vcproj create mode 100644 ase/utl/ctype.c create mode 100644 ase/utl/ctype.h create mode 100644 ase/utl/descrip.mms create mode 100644 ase/utl/main.c create mode 100644 ase/utl/main.h create mode 100644 ase/utl/makefile.in create mode 100644 ase/utl/makefile.msw.bcc create mode 100644 ase/utl/makefile.msw.cl create mode 100644 ase/utl/stdio.c create mode 100644 ase/utl/stdio.h diff --git a/ase/aclocal.m4 b/ase/aclocal.m4 new file mode 100644 index 00000000..fbaaf827 --- /dev/null +++ b/ase/aclocal.m4 @@ -0,0 +1,5938 @@ +# generated automatically by aclocal 1.9.2 -*- Autoconf -*- + +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 +# Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- + +# serial 47 AC_PROG_LIBTOOL + + +# AC_PROVIDE_IFELSE(MACRO-NAME, IF-PROVIDED, IF-NOT-PROVIDED) +# ----------------------------------------------------------- +# If this macro is not defined by Autoconf, define it here. +m4_ifdef([AC_PROVIDE_IFELSE], + [], + [m4_define([AC_PROVIDE_IFELSE], + [m4_ifdef([AC_PROVIDE_$1], + [$2], [$3])])]) + + +# AC_PROG_LIBTOOL +# --------------- +AC_DEFUN([AC_PROG_LIBTOOL], +[AC_REQUIRE([_AC_PROG_LIBTOOL])dnl +dnl If AC_PROG_CXX has already been expanded, run AC_LIBTOOL_CXX +dnl immediately, otherwise, hook it in at the end of AC_PROG_CXX. + AC_PROVIDE_IFELSE([AC_PROG_CXX], + [AC_LIBTOOL_CXX], + [define([AC_PROG_CXX], defn([AC_PROG_CXX])[AC_LIBTOOL_CXX + ])]) +dnl And a similar setup for Fortran 77 support + AC_PROVIDE_IFELSE([AC_PROG_F77], + [AC_LIBTOOL_F77], + [define([AC_PROG_F77], defn([AC_PROG_F77])[AC_LIBTOOL_F77 +])]) + +dnl Quote A][M_PROG_GCJ so that aclocal doesn't bring it in needlessly. +dnl If either AC_PROG_GCJ or A][M_PROG_GCJ have already been expanded, run +dnl AC_LIBTOOL_GCJ immediately, otherwise, hook it in at the end of both. + AC_PROVIDE_IFELSE([AC_PROG_GCJ], + [AC_LIBTOOL_GCJ], + [AC_PROVIDE_IFELSE([A][M_PROG_GCJ], + [AC_LIBTOOL_GCJ], + [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ], + [AC_LIBTOOL_GCJ], + [ifdef([AC_PROG_GCJ], + [define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[AC_LIBTOOL_GCJ])]) + ifdef([A][M_PROG_GCJ], + [define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[AC_LIBTOOL_GCJ])]) + ifdef([LT_AC_PROG_GCJ], + [define([LT_AC_PROG_GCJ], + defn([LT_AC_PROG_GCJ])[AC_LIBTOOL_GCJ])])])]) +])])# AC_PROG_LIBTOOL + + +# _AC_PROG_LIBTOOL +# ---------------- +AC_DEFUN([_AC_PROG_LIBTOOL], +[AC_REQUIRE([AC_LIBTOOL_SETUP])dnl +AC_BEFORE([$0],[AC_LIBTOOL_CXX])dnl +AC_BEFORE([$0],[AC_LIBTOOL_F77])dnl +AC_BEFORE([$0],[AC_LIBTOOL_GCJ])dnl + +# This can be used to rebuild libtool when needed +LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh" + +# Always use our own libtool. +LIBTOOL='$(SHELL) $(top_builddir)/libtool' +AC_SUBST(LIBTOOL)dnl + +# Prevent multiple expansion +define([AC_PROG_LIBTOOL], []) +])# _AC_PROG_LIBTOOL + + +# AC_LIBTOOL_SETUP +# ---------------- +AC_DEFUN([AC_LIBTOOL_SETUP], +[AC_PREREQ(2.50)dnl +AC_REQUIRE([AC_ENABLE_SHARED])dnl +AC_REQUIRE([AC_ENABLE_STATIC])dnl +AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl +AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_PROG_LD])dnl +AC_REQUIRE([AC_PROG_LD_RELOAD_FLAG])dnl +AC_REQUIRE([AC_PROG_NM])dnl + +AC_REQUIRE([AC_PROG_LN_S])dnl +AC_REQUIRE([AC_DEPLIBS_CHECK_METHOD])dnl +# Autoconf 2.13's AC_OBJEXT and AC_EXEEXT macros only works for C compilers! +AC_REQUIRE([AC_OBJEXT])dnl +AC_REQUIRE([AC_EXEEXT])dnl +dnl + +AC_LIBTOOL_SYS_MAX_CMD_LEN +AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE +AC_LIBTOOL_OBJDIR + +AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl +_LT_AC_PROG_ECHO_BACKSLASH + +case $host_os in +aix3*) + # AIX sometimes has problems with the GCC collect2 program. For some + # reason, if we set the COLLECT_NAMES environment variable, the problems + # vanish in a puff of smoke. + if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES + fi + ;; +esac + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed='sed -e s/^X//' +[sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g'] + +# Same as above, but do not quote variable references. +[double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g'] + +# Sed substitution to delay expansion of an escaped shell variable in a +# double_quote_subst'ed string. +delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' + +# Sed substitution to avoid accidental globbing in evaled expressions +no_glob_subst='s/\*/\\\*/g' + +# Constants: +rm="rm -f" + +# Global variables: +default_ofile=libtool +can_build_shared=yes + +# All known linkers require a `.a' archive for static linking (except M$VC, +# which needs '.lib'). +libext=a +ltmain="$ac_aux_dir/ltmain.sh" +ofile="$default_ofile" +with_gnu_ld="$lt_cv_prog_gnu_ld" + +AC_CHECK_TOOL(AR, ar, false) +AC_CHECK_TOOL(RANLIB, ranlib, :) +AC_CHECK_TOOL(STRIP, strip, :) + +old_CC="$CC" +old_CFLAGS="$CFLAGS" + +# Set sane defaults for various variables +test -z "$AR" && AR=ar +test -z "$AR_FLAGS" && AR_FLAGS=cru +test -z "$AS" && AS=as +test -z "$CC" && CC=cc +test -z "$LTCC" && LTCC=$CC +test -z "$DLLTOOL" && DLLTOOL=dlltool +test -z "$LD" && LD=ld +test -z "$LN_S" && LN_S="ln -s" +test -z "$MAGIC_CMD" && MAGIC_CMD=file +test -z "$NM" && NM=nm +test -z "$SED" && SED=sed +test -z "$OBJDUMP" && OBJDUMP=objdump +test -z "$RANLIB" && RANLIB=: +test -z "$STRIP" && STRIP=: +test -z "$ac_objext" && ac_objext=o + +# Determine commands to create old-style static archives. +old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs' +old_postinstall_cmds='chmod 644 $oldlib' +old_postuninstall_cmds= + +if test -n "$RANLIB"; then + case $host_os in + openbsd*) + old_postinstall_cmds="\$RANLIB -t \$oldlib~$old_postinstall_cmds" + ;; + *) + old_postinstall_cmds="\$RANLIB \$oldlib~$old_postinstall_cmds" + ;; + esac + old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" +fi + +# Only perform the check for file, if the check method requires it +case $deplibs_check_method in +file_magic*) + if test "$file_magic_cmd" = '$MAGIC_CMD'; then + AC_PATH_MAGIC + fi + ;; +esac + +AC_PROVIDE_IFELSE([AC_LIBTOOL_DLOPEN], enable_dlopen=yes, enable_dlopen=no) +AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL], +enable_win32_dll=yes, enable_win32_dll=no) + +AC_ARG_ENABLE([libtool-lock], + [AC_HELP_STRING([--disable-libtool-lock], + [avoid locking (might break parallel builds)])]) +test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes + +AC_ARG_WITH([pic], + [AC_HELP_STRING([--with-pic], + [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], + [pic_mode="$withval"], + [pic_mode=default]) +test -z "$pic_mode" && pic_mode=default + +# Use C for the default configuration in the libtool script +tagname= +AC_LIBTOOL_LANG_C_CONFIG +_LT_AC_TAGCONFIG +])# AC_LIBTOOL_SETUP + + +# _LT_AC_SYS_COMPILER +# ------------------- +AC_DEFUN([_LT_AC_SYS_COMPILER], +[AC_REQUIRE([AC_PROG_CC])dnl + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# Allow CC to be a program name with arguments. +compiler=$CC +])# _LT_AC_SYS_COMPILER + + +# _LT_AC_SYS_LIBPATH_AIX +# ---------------------- +# Links a minimal program and checks the executable +# for the system default hardcoded library path. In most cases, +# this is /usr/lib:/lib, but when the MPI compilers are used +# the location of the communication and MPI libs are included too. +# If we don't find anything, use the default library path according +# to the aix ld manual. +AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX], +[AC_LINK_IFELSE(AC_LANG_PROGRAM,[ +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'`; fi],[]) +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +])# _LT_AC_SYS_LIBPATH_AIX + + +# _LT_AC_SHELL_INIT(ARG) +# ---------------------- +AC_DEFUN([_LT_AC_SHELL_INIT], +[ifdef([AC_DIVERSION_NOTICE], + [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)], + [AC_DIVERT_PUSH(NOTICE)]) +$1 +AC_DIVERT_POP +])# _LT_AC_SHELL_INIT + + +# _LT_AC_PROG_ECHO_BACKSLASH +# -------------------------- +# Add some code to the start of the generated configure script which +# will find an echo command which doesn't interpret backslashes. +AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH], +[_LT_AC_SHELL_INIT([ +# Check that we are running under the correct shell. +SHELL=${CONFIG_SHELL-/bin/sh} + +case X$ECHO in +X*--fallback-echo) + # Remove one level of quotation (which was required for Make). + ECHO=`echo "$ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','` + ;; +esac + +echo=${ECHO-echo} +if test "X[$]1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift +elif test "X[$]1" = X--fallback-echo; then + # Avoid inline document here, it may be left over + : +elif test "X`($echo '\t') 2>/dev/null`" = 'X\t' ; then + # Yippee, $echo works! + : +else + # Restart under the correct shell. + exec $SHELL "[$]0" --no-reexec ${1+"[$]@"} +fi + +if test "X[$]1" = X--fallback-echo; then + # used as fallback echo + shift + cat </dev/null && + echo_test_string="`eval $cmd`" && + (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null + then + break + fi + done +fi + +if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + : +else + # The Solaris, AIX, and Digital Unix default echo programs unquote + # backslashes. This makes it impossible to quote backslashes using + # echo "$something" | sed 's/\\/\\\\/g' + # + # So, first we look for a working echo in the user's PATH. + + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for dir in $PATH /usr/ucb; do + IFS="$lt_save_ifs" + if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && + test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + echo="$dir/echo" + break + fi + done + IFS="$lt_save_ifs" + + if test "X$echo" = Xecho; then + # We didn't find a better echo, so look for alternatives. + if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`(print -r "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + # This shell has a builtin print -r that does the trick. + echo='print -r' + elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) && + test "X$CONFIG_SHELL" != X/bin/ksh; then + # If we have ksh, try running configure again with it. + ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} + export ORIGINAL_CONFIG_SHELL + CONFIG_SHELL=/bin/ksh + export CONFIG_SHELL + exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"} + else + # Try using printf. + echo='printf %s\n' + if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + # Cool, printf works + : + elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && + test "X$echo_testing_string" = 'X\t' && + echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL + export CONFIG_SHELL + SHELL="$CONFIG_SHELL" + export SHELL + echo="$CONFIG_SHELL [$]0 --fallback-echo" + elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && + test "X$echo_testing_string" = 'X\t' && + echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + echo="$CONFIG_SHELL [$]0 --fallback-echo" + else + # maybe with a smaller string... + prev=: + + for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do + if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null + then + break + fi + prev="$cmd" + done + + if test "$prev" != 'sed 50q "[$]0"'; then + echo_test_string=`eval $prev` + export echo_test_string + exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"} + else + # Oops. We lost completely, so just stick with echo. + echo=echo + fi + fi + fi + fi +fi +fi + +# Copy echo and quote the copy suitably for passing to libtool from +# the Makefile, instead of quoting the original, which is used later. +ECHO=$echo +if test "X$ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then + ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo" +fi + +AC_SUBST(ECHO) +])])# _LT_AC_PROG_ECHO_BACKSLASH + + +# _LT_AC_LOCK +# ----------- +AC_DEFUN([_LT_AC_LOCK], +[AC_ARG_ENABLE([libtool-lock], + [AC_HELP_STRING([--disable-libtool-lock], + [avoid locking (might break parallel builds)])]) +test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes + +# Some flags need to be propagated to the compiler or linker for good +# libtool support. +case $host in +ia64-*-hpux*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case `/usr/bin/file conftest.$ac_objext` in + *ELF-32*) + HPUX_IA64_MODE="32" + ;; + *ELF-64*) + HPUX_IA64_MODE="64" + ;; + esac + fi + rm -rf conftest* + ;; +*-*-irix6*) + # Find out which ABI we are using. + echo '[#]line __oline__ "configure"' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + if test "$lt_cv_prog_gnu_ld" = yes; then + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -melf32bsmip" + ;; + *N32*) + LD="${LD-ld} -melf32bmipn32" + ;; + *64-bit*) + LD="${LD-ld} -melf64bmip" + ;; + esac + else + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -32" + ;; + *N32*) + LD="${LD-ld} -n32" + ;; + *64-bit*) + LD="${LD-ld} -64" + ;; + esac + fi + fi + rm -rf conftest* + ;; + +x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case "`/usr/bin/file conftest.o`" in + *32-bit*) + case $host in + x86_64-*linux*) + LD="${LD-ld} -m elf_i386" + ;; + ppc64-*linux*|powerpc64-*linux*) + LD="${LD-ld} -m elf32ppclinux" + ;; + s390x-*linux*) + LD="${LD-ld} -m elf_s390" + ;; + sparc64-*linux*) + LD="${LD-ld} -m elf32_sparc" + ;; + esac + ;; + *64-bit*) + case $host in + x86_64-*linux*) + LD="${LD-ld} -m elf_x86_64" + ;; + ppc*-*linux*|powerpc*-*linux*) + LD="${LD-ld} -m elf64ppc" + ;; + s390*-*linux*) + LD="${LD-ld} -m elf64_s390" + ;; + sparc*-*linux*) + LD="${LD-ld} -m elf64_sparc" + ;; + esac + ;; + esac + fi + rm -rf conftest* + ;; + +*-*-sco3.2v5*) + # On SCO OpenServer 5, we need -belf to get full-featured binaries. + SAVE_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -belf" + AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, + [AC_LANG_PUSH(C) + AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) + AC_LANG_POP]) + if test x"$lt_cv_cc_needs_belf" != x"yes"; then + # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf + CFLAGS="$SAVE_CFLAGS" + fi + ;; +AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL], +[*-*-cygwin* | *-*-mingw* | *-*-pw32*) + AC_CHECK_TOOL(DLLTOOL, dlltool, false) + AC_CHECK_TOOL(AS, as, false) + AC_CHECK_TOOL(OBJDUMP, objdump, false) + ;; + ]) +esac + +need_locks="$enable_libtool_lock" + +])# _LT_AC_LOCK + + +# AC_LIBTOOL_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, +# [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE]) +# ---------------------------------------------------------------- +# Check whether the given compiler option works +AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], +[AC_REQUIRE([LT_AC_PROG_SED]) +AC_CACHE_CHECK([$1], [$2], + [$2=no + ifelse([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4]) + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="$3" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ + -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&AS_MESSAGE_LOG_FD + echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + if test ! -s conftest.err; then + $2=yes + fi + fi + $rm conftest* +]) + +if test x"[$]$2" = xyes; then + ifelse([$5], , :, [$5]) +else + ifelse([$6], , :, [$6]) +fi +])# AC_LIBTOOL_COMPILER_OPTION + + +# AC_LIBTOOL_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, +# [ACTION-SUCCESS], [ACTION-FAILURE]) +# ------------------------------------------------------------ +# Check whether the given compiler option works +AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], +[AC_CACHE_CHECK([$1], [$2], + [$2=no + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS $3" + printf "$lt_simple_link_test_code" > conftest.$ac_ext + if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + # Append any errors to the config.log. + cat conftest.err 1>&AS_MESSAGE_LOG_FD + else + $2=yes + fi + fi + $rm conftest* + LDFLAGS="$save_LDFLAGS" +]) + +if test x"[$]$2" = xyes; then + ifelse([$4], , :, [$4]) +else + ifelse([$5], , :, [$5]) +fi +])# AC_LIBTOOL_LINKER_OPTION + + +# AC_LIBTOOL_SYS_MAX_CMD_LEN +# -------------------------- +AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], +[# find the maximum length of command line arguments +AC_MSG_CHECKING([the maximum length of command line arguments]) +AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl + i=0 + teststring="ABCD" + + case $build_os in + msdosdjgpp*) + # On DJGPP, this test can blow up pretty badly due to problems in libc + # (any single argument exceeding 2000 bytes causes a buffer overrun + # during glob expansion). Even if it were fixed, the result of this + # check would be larger than it should be. + lt_cv_sys_max_cmd_len=12288; # 12K is about right + ;; + + gnu*) + # Under GNU Hurd, this test is not required because there is + # no limit to the length of command line arguments. + # Libtool will interpret -1 as no limit whatsoever + lt_cv_sys_max_cmd_len=-1; + ;; + + cygwin* | mingw*) + # On Win9x/ME, this test blows up -- it succeeds, but takes + # about 5 minutes as the teststring grows exponentially. + # Worse, since 9x/ME are not pre-emptively multitasking, + # you end up with a "frozen" computer, even though with patience + # the test eventually succeeds (with a max line length of 256k). + # Instead, let's just punt: use the minimum linelength reported by + # all of the supported platforms: 8192 (on NT/2K/XP). + lt_cv_sys_max_cmd_len=8192; + ;; + + amigaos*) + # On AmigaOS with pdksh, this test takes hours, literally. + # So we just punt and use a minimum line length of 8192. + lt_cv_sys_max_cmd_len=8192; + ;; + + *) + # If test is not a shell built-in, we'll probably end up computing a + # maximum length that is only half of the actual maximum length, but + # we can't tell. + while (test "X"`$CONFIG_SHELL [$]0 --fallback-echo "X$teststring" 2>/dev/null` \ + = "XX$teststring") >/dev/null 2>&1 && + new_result=`expr "X$teststring" : ".*" 2>&1` && + lt_cv_sys_max_cmd_len=$new_result && + test $i != 17 # 1/2 MB should be enough + do + i=`expr $i + 1` + teststring=$teststring$teststring + done + teststring= + # Add a significant safety factor because C++ compilers can tack on massive + # amounts of additional arguments before passing them to the linker. + # It appears as though 1/2 is a usable value. + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` + ;; + esac +]) +if test -n $lt_cv_sys_max_cmd_len ; then + AC_MSG_RESULT($lt_cv_sys_max_cmd_len) +else + AC_MSG_RESULT(none) +fi +])# AC_LIBTOOL_SYS_MAX_CMD_LEN + + +# _LT_AC_CHECK_DLFCN +# -------------------- +AC_DEFUN([_LT_AC_CHECK_DLFCN], +[AC_CHECK_HEADERS(dlfcn.h)dnl +])# _LT_AC_CHECK_DLFCN + + +# _LT_AC_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, +# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) +# ------------------------------------------------------------------ +AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF], +[AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl +if test "$cross_compiling" = yes; then : + [$4] +else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext < +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LT_DLGLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LT_DLGLOBAL DL_GLOBAL +# else +# define LT_DLGLOBAL 0 +# endif +#endif + +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LT_DLLAZY_OR_NOW +# ifdef RTLD_LAZY +# define LT_DLLAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LT_DLLAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LT_DLLAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LT_DLLAZY_OR_NOW DL_NOW +# else +# define LT_DLLAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +#ifdef __cplusplus +extern "C" void exit (int); +#endif + +void fnord() { int i=42;} +int main () +{ + void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); + int status = $lt_dlunknown; + + if (self) + { + if (dlsym (self,"fnord")) status = $lt_dlno_uscore; + else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + /* dlclose (self); */ + } + + exit (status); +}] +EOF + if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then + (./conftest; exit; ) 2>/dev/null + lt_status=$? + case x$lt_status in + x$lt_dlno_uscore) $1 ;; + x$lt_dlneed_uscore) $2 ;; + x$lt_unknown|x*) $3 ;; + esac + else : + # compilation failed + $3 + fi +fi +rm -fr conftest* +])# _LT_AC_TRY_DLOPEN_SELF + + +# AC_LIBTOOL_DLOPEN_SELF +# ------------------- +AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], +[AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl +if test "x$enable_dlopen" != xyes; then + enable_dlopen=unknown + enable_dlopen_self=unknown + enable_dlopen_self_static=unknown +else + lt_cv_dlopen=no + lt_cv_dlopen_libs= + + case $host_os in + beos*) + lt_cv_dlopen="load_add_on" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ;; + + mingw* | pw32*) + lt_cv_dlopen="LoadLibrary" + lt_cv_dlopen_libs= + ;; + + cygwin*) + lt_cv_dlopen="dlopen" + lt_cv_dlopen_libs= + ;; + + darwin*) + # if libdl is installed we need to link against it + AC_CHECK_LIB([dl], [dlopen], + [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[ + lt_cv_dlopen="dyld" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ]) + ;; + + *) + AC_CHECK_FUNC([shl_load], + [lt_cv_dlopen="shl_load"], + [AC_CHECK_LIB([dld], [shl_load], + [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld"], + [AC_CHECK_FUNC([dlopen], + [lt_cv_dlopen="dlopen"], + [AC_CHECK_LIB([dl], [dlopen], + [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"], + [AC_CHECK_LIB([svld], [dlopen], + [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"], + [AC_CHECK_LIB([dld], [dld_link], + [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld"]) + ]) + ]) + ]) + ]) + ]) + ;; + esac + + if test "x$lt_cv_dlopen" != xno; then + enable_dlopen=yes + else + enable_dlopen=no + fi + + case $lt_cv_dlopen in + dlopen) + save_CPPFLAGS="$CPPFLAGS" + test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" + + save_LDFLAGS="$LDFLAGS" + eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" + + save_LIBS="$LIBS" + LIBS="$lt_cv_dlopen_libs $LIBS" + + AC_CACHE_CHECK([whether a program can dlopen itself], + lt_cv_dlopen_self, [dnl + _LT_AC_TRY_DLOPEN_SELF( + lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes, + lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) + ]) + + if test "x$lt_cv_dlopen_self" = xyes; then + LDFLAGS="$LDFLAGS $link_static_flag" + AC_CACHE_CHECK([whether a statically linked program can dlopen itself], + lt_cv_dlopen_self_static, [dnl + _LT_AC_TRY_DLOPEN_SELF( + lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes, + lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross) + ]) + fi + + CPPFLAGS="$save_CPPFLAGS" + LDFLAGS="$save_LDFLAGS" + LIBS="$save_LIBS" + ;; + esac + + case $lt_cv_dlopen_self in + yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; + *) enable_dlopen_self=unknown ;; + esac + + case $lt_cv_dlopen_self_static in + yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; + *) enable_dlopen_self_static=unknown ;; + esac +fi +])# AC_LIBTOOL_DLOPEN_SELF + + +# AC_LIBTOOL_PROG_CC_C_O([TAGNAME]) +# --------------------------------- +# Check to see if options -c and -o are simultaneously supported by compiler +AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O], +[AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl +AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext], + [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)], + [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no + $rm -r conftest 2>/dev/null + mkdir conftest + cd conftest + mkdir out + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + + lt_compiler_flag="-o out/conftest2.$ac_objext" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ + -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&AS_MESSAGE_LOG_FD + echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + if test ! -s out/conftest.err; then + _LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes + fi + fi + chmod u+w . + $rm conftest* + # SGI C++ compiler will create directory out/ii_files/ for + # template instantiation + test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files + $rm out/* && rmdir out + cd .. + rmdir conftest + $rm conftest* +]) +])# AC_LIBTOOL_PROG_CC_C_O + + +# AC_LIBTOOL_SYS_HARD_LINK_LOCKS([TAGNAME]) +# ----------------------------------------- +# Check to see if we can do hard links to lock some files if needed +AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], +[AC_REQUIRE([_LT_AC_LOCK])dnl + +hard_links="nottested" +if test "$_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then + # do not overwrite the value of need_locks provided by the user + AC_MSG_CHECKING([if we can lock with hard links]) + hard_links=yes + $rm conftest* + ln conftest.a conftest.b 2>/dev/null && hard_links=no + touch conftest.a + ln conftest.a conftest.b 2>&5 || hard_links=no + ln conftest.a conftest.b 2>/dev/null && hard_links=no + AC_MSG_RESULT([$hard_links]) + if test "$hard_links" = no; then + AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe]) + need_locks=warn + fi +else + need_locks=no +fi +])# AC_LIBTOOL_SYS_HARD_LINK_LOCKS + + +# AC_LIBTOOL_OBJDIR +# ----------------- +AC_DEFUN([AC_LIBTOOL_OBJDIR], +[AC_CACHE_CHECK([for objdir], [lt_cv_objdir], +[rm -f .libs 2>/dev/null +mkdir .libs 2>/dev/null +if test -d .libs; then + lt_cv_objdir=.libs +else + # MS-DOS does not allow filenames that begin with a dot. + lt_cv_objdir=_libs +fi +rmdir .libs 2>/dev/null]) +objdir=$lt_cv_objdir +])# AC_LIBTOOL_OBJDIR + + +# AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH([TAGNAME]) +# ---------------------------------------------- +# Check hardcoding attributes. +AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], +[AC_MSG_CHECKING([how to hardcode library paths into programs]) +_LT_AC_TAGVAR(hardcode_action, $1)= +if test -n "$_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)" || \ + test -n "$_LT_AC_TAGVAR(runpath_var $1)" || \ + test "X$_LT_AC_TAGVAR(hardcode_automatic, $1)"="Xyes" ; then + + # We can hardcode non-existant directories. + if test "$_LT_AC_TAGVAR(hardcode_direct, $1)" != no && + # If the only mechanism to avoid hardcoding is shlibpath_var, we + # have to relink, otherwise we might link with an installed library + # when we should be linking with a yet-to-be-installed one + ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)" != no && + test "$_LT_AC_TAGVAR(hardcode_minus_L, $1)" != no; then + # Linking always hardcodes the temporary library directory. + _LT_AC_TAGVAR(hardcode_action, $1)=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + _LT_AC_TAGVAR(hardcode_action, $1)=immediate + fi +else + # We cannot hardcode anything, or else we can only hardcode existing + # directories. + _LT_AC_TAGVAR(hardcode_action, $1)=unsupported +fi +AC_MSG_RESULT([$_LT_AC_TAGVAR(hardcode_action, $1)]) + +if test "$_LT_AC_TAGVAR(hardcode_action, $1)" = relink; then + # Fast installation is not supported + enable_fast_install=no +elif test "$shlibpath_overrides_runpath" = yes || + test "$enable_shared" = no; then + # Fast installation is not necessary + enable_fast_install=needless +fi +])# AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH + + +# AC_LIBTOOL_SYS_LIB_STRIP +# ------------------------ +AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP], +[striplib= +old_striplib= +AC_MSG_CHECKING([whether stripping libraries is possible]) +if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then + test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" + test -z "$striplib" && striplib="$STRIP --strip-unneeded" + AC_MSG_RESULT([yes]) +else +# FIXME - insert some real tests, host_os isn't really good enough + case $host_os in + darwin*) + if test -n "$STRIP" ; then + striplib="$STRIP -x" + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) +fi + ;; + *) + AC_MSG_RESULT([no]) + ;; + esac +fi +])# AC_LIBTOOL_SYS_LIB_STRIP + + +# AC_LIBTOOL_SYS_DYNAMIC_LINKER +# ----------------------------- +# PORTME Fill in your ld.so characteristics +AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER], +[AC_MSG_CHECKING([dynamic linker characteristics]) +library_names_spec= +libname_spec='lib$name' +soname_spec= +shrext_cmds=".so" +postinstall_cmds= +postuninstall_cmds= +finish_cmds= +finish_eval= +shlibpath_var= +shlibpath_overrides_runpath=unknown +version_type=none +dynamic_linker="$host_os ld.so" +sys_lib_dlsearch_path_spec="/lib /usr/lib" +if test "$GCC" = yes; then + sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then + # if the path contains ";" then we assume it to be the separator + # otherwise default to the standard path separator (i.e. ":") - it is + # assumed that no part of a normal pathname contains ";" but that should + # okay in the real world where ";" in dirpaths is itself problematic. + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi +else + sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" +fi +need_lib_prefix=unknown +hardcode_into_libs=no + +# when you set need_version to no, make sure it does not cause -set_version +# flags to be left without arguments +need_version=unknown + +case $host_os in +aix3*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' + shlibpath_var=LIBPATH + + # AIX 3 has no versioning support, so we append a major version to the name. + soname_spec='${libname}${release}${shared_ext}$major' + ;; + +aix4* | aix5*) + version_type=linux + need_lib_prefix=no + need_version=no + hardcode_into_libs=yes + if test "$host_cpu" = ia64; then + # AIX 5 supports IA64 + library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + else + # With GCC up to 2.95.x, collect2 would create an import file + # for dependence libraries. The import file would start with + # the line `#! .'. This would cause the generated library to + # depend on `.', always an invalid library. This was fixed in + # development snapshots of GCC prior to 3.0. + case $host_os in + aix4 | aix4.[[01]] | aix4.[[01]].*) + if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' + echo ' yes ' + echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then + : + else + can_build_shared=no + fi + ;; + esac + # AIX (on Power*) has no versioning support, so currently we can not hardcode correct + # soname into executable. Probably we can add versioning support to + # collect2, so additional links can be useful in future. + if test "$aix_use_runtimelinking" = yes; then + # If using run time linking (on AIX 4.2 or later) use lib.so + # instead of lib.a to let people know that these are not + # typical AIX shared libraries. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + else + # We preserve .a as extension for shared libraries through AIX4.2 + # and later when we are not doing run time linking. + library_names_spec='${libname}${release}.a $libname.a' + soname_spec='${libname}${release}${shared_ext}$major' + fi + shlibpath_var=LIBPATH + fi + ;; + +amigaos*) + library_names_spec='$libname.ixlibrary $libname.a' + # Create ${libname}_ixlibrary.a entries in /sys/libs. + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' + ;; + +beos*) + library_names_spec='${libname}${shared_ext}' + dynamic_linker="$host_os ld.so" + shlibpath_var=LIBRARY_PATH + ;; + +bsdi4*) + version_type=linux + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" + sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" + # the default ld.so.conf also contains /usr/contrib/lib and + # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow + # libtool to hard-code these into programs + ;; + +cygwin* | mingw* | pw32*) + version_type=windows + shrext_cmds=".dll" + need_version=no + need_lib_prefix=no + + case $GCC,$host_os in + yes,cygwin* | yes,mingw* | yes,pw32*) + library_names_spec='$libname.dll.a' + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \${file}`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $rm \$dlpath' + shlibpath_overrides_runpath=yes + + case $host_os in + cygwin*) + # Cygwin DLLs use 'cyg' prefix rather than 'lib' + soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" + ;; + mingw*) + # MinGW DLLs use traditional 'lib' prefix + soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if echo "$sys_lib_search_path_spec" | [grep ';[c-zC-Z]:/' >/dev/null]; then + # It is most probably a Windows format PATH printed by + # mingw gcc, but we are running on Cygwin. Gcc prints its search + # path with ; separators, and with drive letters. We can handle the + # drive letters (cygwin fileutils understands them), so leave them, + # especially as we might pass files found there to a mingw objdump, + # which wouldn't understand a cygwinified path. Ahh. + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + ;; + pw32*) + # pw32 DLLs use 'pw' prefix rather than 'lib' + library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + ;; + esac + ;; + + *) + library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib' + ;; + esac + dynamic_linker='Win32 ld.exe' + # FIXME: first we should search . and the directory the executable is in + shlibpath_var=PATH + ;; + +darwin* | rhapsody*) + dynamic_linker="$host_os dyld" + version_type=darwin + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext' + soname_spec='${libname}${release}${major}$shared_ext' + shlibpath_overrides_runpath=yes + shlibpath_var=DYLD_LIBRARY_PATH + shrext_cmds='$(test .$module = .yes && echo .so || echo .dylib)' + # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same. + if test "$GCC" = yes; then + sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"` + else + sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib' + fi + sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' + ;; + +dgux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +freebsd1*) + dynamic_linker=no + ;; + +kfreebsd*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='GNU ld.so' + ;; + +freebsd*) + objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout` + version_type=freebsd-$objformat + case $version_type in + freebsd-elf*) + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + need_version=no + need_lib_prefix=no + ;; + freebsd-*) + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' + need_version=yes + ;; + esac + shlibpath_var=LD_LIBRARY_PATH + case $host_os in + freebsd2*) + shlibpath_overrides_runpath=yes + ;; + freebsd3.[01]* | freebsdelf3.[01]*) + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + *) # from 3.2 on + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + esac + ;; + +gnu*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + hardcode_into_libs=yes + ;; + +hpux9* | hpux10* | hpux11*) + # Give a soname corresponding to the major version so that dld.sl refuses to + # link against other versions. + version_type=sunos + need_lib_prefix=no + need_version=no + case "$host_cpu" in + ia64*) + shrext_cmds='.so' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.so" + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + if test "X$HPUX_IA64_MODE" = X32; then + sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" + else + sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" + fi + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + hppa*64*) + shrext_cmds='.sl' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.sl" + shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + *) + shrext_cmds='.sl' + dynamic_linker="$host_os dld.sl" + shlibpath_var=SHLIB_PATH + shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + ;; + esac + # HP-UX runs *really* slowly unless shared libraries are mode 555. + postinstall_cmds='chmod 555 $lib' + ;; + +irix5* | irix6* | nonstopux*) + case $host_os in + nonstopux*) version_type=nonstopux ;; + *) + if test "$lt_cv_prog_gnu_ld" = yes; then + version_type=linux + else + version_type=irix + fi ;; + esac + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' + case $host_os in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in # libtool.m4 will add one of these switches to LD + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") + libsuff= shlibsuff= libmagic=32-bit;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") + libsuff=32 shlibsuff=N32 libmagic=N32;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") + libsuff=64 shlibsuff=64 libmagic=64-bit;; + *) libsuff= shlibsuff= libmagic=never-match;; + esac + ;; + esac + shlibpath_var=LD_LIBRARY${shlibsuff}_PATH + shlibpath_overrides_runpath=no + sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" + sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" + hardcode_into_libs=yes + ;; + +# No shared lib support for Linux oldld, aout, or coff. +linux*oldld* | linux*aout* | linux*coff*) + dynamic_linker=no + ;; + +# This must be Linux ELF. +linux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + # find out which ABI we are using + libsuff= + case "$host_cpu" in + x86_64*|s390x*|powerpc64*) + echo '[#]line __oline__ "configure"' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case `/usr/bin/file conftest.$ac_objext` in + *64-bit*) + libsuff=64 + sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}" + ;; + esac + fi + rm -rf conftest* + ;; + esac + + # Append ld.so.conf contents to the search path + if test -f /etc/ld.so.conf; then + lt_ld_extra=`$SED -e 's/[:,\t]/ /g;s/=[^=]*$//;s/=[^= ]* / /g' /etc/ld.so.conf | tr '\n' ' '` + sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra" + fi + + # We used to test for /lib/ld.so.1 and disable shared libraries on + # powerpc, because MkLinux only supported shared libraries with the + # GNU dynamic linker. Since this was broken with cross compilers, + # most powerpc-linux boxes support dynamic linking these days and + # people can always --disable-shared, the test was removed, and we + # assume the GNU/Linux dynamic linker is in use. + dynamic_linker='GNU/Linux ld.so' + ;; + +knetbsd*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='GNU ld.so' + ;; + +netbsd*) + version_type=sunos + need_lib_prefix=no + need_version=no + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + dynamic_linker='NetBSD (a.out) ld.so' + else + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='NetBSD ld.elf_so' + fi + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + +newsos6) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +nto-qnx*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +openbsd*) + version_type=sunos + need_lib_prefix=no + need_version=yes + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + case $host_os in + openbsd2.[[89]] | openbsd2.[[89]].*) + shlibpath_overrides_runpath=no + ;; + *) + shlibpath_overrides_runpath=yes + ;; + esac + else + shlibpath_overrides_runpath=yes + fi + ;; + +os2*) + libname_spec='$name' + shrext_cmds=".dll" + need_lib_prefix=no + library_names_spec='$libname${shared_ext} $libname.a' + dynamic_linker='OS/2 ld.exe' + shlibpath_var=LIBPATH + ;; + +osf3* | osf4* | osf5*) + version_type=osf + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" + sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" + ;; + +sco3.2v5*) + version_type=osf + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + ;; + +solaris*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + # ldd complains unless libraries are executable + postinstall_cmds='chmod +x $lib' + ;; + +sunos4*) + version_type=sunos + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + if test "$with_gnu_ld" = yes; then + need_lib_prefix=no + fi + need_version=yes + ;; + +sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + case $host_vendor in + sni) + shlibpath_overrides_runpath=no + need_lib_prefix=no + export_dynamic_flag_spec='${wl}-Blargedynsym' + runpath_var=LD_RUN_PATH + ;; + siemens) + need_lib_prefix=no + ;; + motorola) + need_lib_prefix=no + need_version=no + shlibpath_overrides_runpath=no + sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' + ;; + esac + ;; + +sysv4*MP*) + if test -d /usr/nec ;then + version_type=linux + library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' + soname_spec='$libname${shared_ext}.$major' + shlibpath_var=LD_LIBRARY_PATH + fi + ;; + +uts4*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +*) + dynamic_linker=no + ;; +esac +AC_MSG_RESULT([$dynamic_linker]) +test "$dynamic_linker" = no && can_build_shared=no +])# AC_LIBTOOL_SYS_DYNAMIC_LINKER + + +# _LT_AC_TAGCONFIG +# ---------------- +AC_DEFUN([_LT_AC_TAGCONFIG], +[AC_ARG_WITH([tags], + [AC_HELP_STRING([--with-tags@<:@=TAGS@:>@], + [include additional configurations @<:@automatic@:>@])], + [tagnames="$withval"]) + +if test -f "$ltmain" && test -n "$tagnames"; then + if test ! -f "${ofile}"; then + AC_MSG_WARN([output file `$ofile' does not exist]) + fi + + if test -z "$LTCC"; then + eval "`$SHELL ${ofile} --config | grep '^LTCC='`" + if test -z "$LTCC"; then + AC_MSG_WARN([output file `$ofile' does not look like a libtool script]) + else + AC_MSG_WARN([using `LTCC=$LTCC', extracted from `$ofile']) + fi + fi + + # Extract list of available tagged configurations in $ofile. + # Note that this assumes the entire list is on one line. + available_tags=`grep "^available_tags=" "${ofile}" | $SED -e 's/available_tags=\(.*$\)/\1/' -e 's/\"//g'` + + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for tagname in $tagnames; do + IFS="$lt_save_ifs" + # Check whether tagname contains only valid characters + case `$echo "X$tagname" | $Xsed -e 's:[[-_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,/]]::g'` in + "") ;; + *) AC_MSG_ERROR([invalid tag name: $tagname]) + ;; + esac + + if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "${ofile}" > /dev/null + then + AC_MSG_ERROR([tag name \"$tagname\" already exists]) + fi + + # Update the list of available tags. + if test -n "$tagname"; then + echo appending configuration tag \"$tagname\" to $ofile + + case $tagname in + CXX) + if test -n "$CXX" && test "X$CXX" != "Xno"; then + AC_LIBTOOL_LANG_CXX_CONFIG + else + tagname="" + fi + ;; + + F77) + if test -n "$F77" && test "X$F77" != "Xno"; then + AC_LIBTOOL_LANG_F77_CONFIG + else + tagname="" + fi + ;; + + GCJ) + if test -n "$GCJ" && test "X$GCJ" != "Xno"; then + AC_LIBTOOL_LANG_GCJ_CONFIG + else + tagname="" + fi + ;; + + RC) + AC_LIBTOOL_LANG_RC_CONFIG + ;; + + *) + AC_MSG_ERROR([Unsupported tag name: $tagname]) + ;; + esac + + # Append the new tag name to the list of available tags. + if test -n "$tagname" ; then + available_tags="$available_tags $tagname" + fi + fi + done + IFS="$lt_save_ifs" + + # Now substitute the updated list of available tags. + if eval "sed -e 's/^available_tags=.*\$/available_tags=\"$available_tags\"/' \"$ofile\" > \"${ofile}T\""; then + mv "${ofile}T" "$ofile" + chmod +x "$ofile" + else + rm -f "${ofile}T" + AC_MSG_ERROR([unable to update list of available tagged configurations.]) + fi +fi +])# _LT_AC_TAGCONFIG + + +# AC_LIBTOOL_DLOPEN +# ----------------- +# enable checks for dlopen support +AC_DEFUN([AC_LIBTOOL_DLOPEN], + [AC_BEFORE([$0],[AC_LIBTOOL_SETUP]) +])# AC_LIBTOOL_DLOPEN + + +# AC_LIBTOOL_WIN32_DLL +# -------------------- +# declare package support for building win32 dll's +AC_DEFUN([AC_LIBTOOL_WIN32_DLL], +[AC_BEFORE([$0], [AC_LIBTOOL_SETUP]) +])# AC_LIBTOOL_WIN32_DLL + + +# AC_ENABLE_SHARED([DEFAULT]) +# --------------------------- +# implement the --enable-shared flag +# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. +AC_DEFUN([AC_ENABLE_SHARED], +[define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl +AC_ARG_ENABLE([shared], + [AC_HELP_STRING([--enable-shared@<:@=PKGS@:>@], + [build shared libraries @<:@default=]AC_ENABLE_SHARED_DEFAULT[@:>@])], + [p=${PACKAGE-default} + case $enableval in + yes) enable_shared=yes ;; + no) enable_shared=no ;; + *) + enable_shared=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_shared=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac], + [enable_shared=]AC_ENABLE_SHARED_DEFAULT) +])# AC_ENABLE_SHARED + + +# AC_DISABLE_SHARED +# ----------------- +#- set the default shared flag to --disable-shared +AC_DEFUN([AC_DISABLE_SHARED], +[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +AC_ENABLE_SHARED(no) +])# AC_DISABLE_SHARED + + +# AC_ENABLE_STATIC([DEFAULT]) +# --------------------------- +# implement the --enable-static flag +# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. +AC_DEFUN([AC_ENABLE_STATIC], +[define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl +AC_ARG_ENABLE([static], + [AC_HELP_STRING([--enable-static@<:@=PKGS@:>@], + [build static libraries @<:@default=]AC_ENABLE_STATIC_DEFAULT[@:>@])], + [p=${PACKAGE-default} + case $enableval in + yes) enable_static=yes ;; + no) enable_static=no ;; + *) + enable_static=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_static=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac], + [enable_static=]AC_ENABLE_STATIC_DEFAULT) +])# AC_ENABLE_STATIC + + +# AC_DISABLE_STATIC +# ----------------- +# set the default static flag to --disable-static +AC_DEFUN([AC_DISABLE_STATIC], +[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +AC_ENABLE_STATIC(no) +])# AC_DISABLE_STATIC + + +# AC_ENABLE_FAST_INSTALL([DEFAULT]) +# --------------------------------- +# implement the --enable-fast-install flag +# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. +AC_DEFUN([AC_ENABLE_FAST_INSTALL], +[define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl +AC_ARG_ENABLE([fast-install], + [AC_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@], + [optimize for fast installation @<:@default=]AC_ENABLE_FAST_INSTALL_DEFAULT[@:>@])], + [p=${PACKAGE-default} + case $enableval in + yes) enable_fast_install=yes ;; + no) enable_fast_install=no ;; + *) + enable_fast_install=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_fast_install=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac], + [enable_fast_install=]AC_ENABLE_FAST_INSTALL_DEFAULT) +])# AC_ENABLE_FAST_INSTALL + + +# AC_DISABLE_FAST_INSTALL +# ----------------------- +# set the default to --disable-fast-install +AC_DEFUN([AC_DISABLE_FAST_INSTALL], +[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +AC_ENABLE_FAST_INSTALL(no) +])# AC_DISABLE_FAST_INSTALL + + +# AC_LIBTOOL_PICMODE([MODE]) +# -------------------------- +# implement the --with-pic flag +# MODE is either `yes' or `no'. If omitted, it defaults to `both'. +AC_DEFUN([AC_LIBTOOL_PICMODE], +[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +pic_mode=ifelse($#,1,$1,default) +])# AC_LIBTOOL_PICMODE + + +# AC_PROG_EGREP +# ------------- +# This is predefined starting with Autoconf 2.54, so this conditional +# definition can be removed once we require Autoconf 2.54 or later. +m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP], +[AC_CACHE_CHECK([for egrep], [ac_cv_prog_egrep], + [if echo a | (grep -E '(a|b)') >/dev/null 2>&1 + then ac_cv_prog_egrep='grep -E' + else ac_cv_prog_egrep='egrep' + fi]) + EGREP=$ac_cv_prog_egrep + AC_SUBST([EGREP]) +])]) + + +# AC_PATH_TOOL_PREFIX +# ------------------- +# find a file program which can recognise shared library +AC_DEFUN([AC_PATH_TOOL_PREFIX], +[AC_REQUIRE([AC_PROG_EGREP])dnl +AC_MSG_CHECKING([for $1]) +AC_CACHE_VAL(lt_cv_path_MAGIC_CMD, +[case $MAGIC_CMD in +[[\\/*] | ?:[\\/]*]) + lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. + ;; +*) + lt_save_MAGIC_CMD="$MAGIC_CMD" + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR +dnl $ac_dummy forces splitting on constant user-supplied paths. +dnl POSIX.2 word splitting is done only on the output of word expansions, +dnl not every word. This closes a longstanding sh security hole. + ac_dummy="ifelse([$2], , $PATH, [$2])" + for ac_dir in $ac_dummy; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$1; then + lt_cv_path_MAGIC_CMD="$ac_dir/$1" + if test -n "$file_magic_test_file"; then + case $deplibs_check_method in + "file_magic "*) + file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`" + MAGIC_CMD="$lt_cv_path_MAGIC_CMD" + if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | + $EGREP "$file_magic_regex" > /dev/null; then + : + else + cat <&2 + +*** Warning: the command libtool uses to detect shared libraries, +*** $file_magic_cmd, produces output that libtool cannot recognize. +*** The result is that libtool may fail to recognize shared libraries +*** as such. This will affect the creation of libtool libraries that +*** depend on shared libraries, but programs linked with such libtool +*** libraries will work regardless of this problem. Nevertheless, you +*** may want to report the problem to your system manager and/or to +*** bug-libtool@gnu.org + +EOF + fi ;; + esac + fi + break + fi + done + IFS="$lt_save_ifs" + MAGIC_CMD="$lt_save_MAGIC_CMD" + ;; +esac]) +MAGIC_CMD="$lt_cv_path_MAGIC_CMD" +if test -n "$MAGIC_CMD"; then + AC_MSG_RESULT($MAGIC_CMD) +else + AC_MSG_RESULT(no) +fi +])# AC_PATH_TOOL_PREFIX + + +# AC_PATH_MAGIC +# ------------- +# find a file program which can recognise a shared library +AC_DEFUN([AC_PATH_MAGIC], +[AC_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH) +if test -z "$lt_cv_path_MAGIC_CMD"; then + if test -n "$ac_tool_prefix"; then + AC_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH) + else + MAGIC_CMD=: + fi +fi +])# AC_PATH_MAGIC + + +# AC_PROG_LD +# ---------- +# find the pathname to the GNU or non-GNU linker +AC_DEFUN([AC_PROG_LD], +[AC_ARG_WITH([gnu-ld], + [AC_HELP_STRING([--with-gnu-ld], + [assume the C compiler uses GNU ld @<:@default=no@:>@])], + [test "$withval" = no || with_gnu_ld=yes], + [with_gnu_ld=no]) +AC_REQUIRE([LT_AC_PROG_SED])dnl +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +ac_prog=ld +if test "$GCC" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + AC_MSG_CHECKING([for ld used by $CC]) + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return which upsets mingw + ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $ac_prog in + # Accept absolute paths. + [[\\/]]* | ?:[[\\/]]*) + re_direlt='/[[^/]][[^/]]*/\.\./' + # Canonicalize the pathname of ld + ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'` + while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do + ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + AC_MSG_CHECKING([for GNU ld]) +else + AC_MSG_CHECKING([for non-GNU ld]) +fi +AC_CACHE_VAL(lt_cv_path_LD, +[if test -z "$LD"; then + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + lt_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some GNU ld's only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + case `"$lt_cv_path_LD" -v 2>&1 &1 /dev/null; then + case $host_cpu in + i*86 ) + # Not sure whether the presence of OpenBSD here was a mistake. + # Let's accept both of them until this is cleared up. + lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD)/i[[3-9]]86 (compact )?demand paged shared library' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` + ;; + esac + else + lt_cv_deplibs_check_method=pass_all + fi + ;; + +gnu*) + lt_cv_deplibs_check_method=pass_all + ;; + +hpux10.20* | hpux11*) + lt_cv_file_magic_cmd=/usr/bin/file + case "$host_cpu" in + ia64*) + lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64' + lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so + ;; + hppa*64*) + [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]'] + lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl + ;; + *) + lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]].[[0-9]]) shared library' + lt_cv_file_magic_test_file=/usr/lib/libc.sl + ;; + esac + ;; + +irix5* | irix6* | nonstopux*) + case $LD in + *-32|*"-32 ") libmagic=32-bit;; + *-n32|*"-n32 ") libmagic=N32;; + *-64|*"-64 ") libmagic=64-bit;; + *) libmagic=never-match;; + esac + lt_cv_deplibs_check_method=pass_all + ;; + +# This must be Linux ELF. +linux*) + case $host_cpu in + alpha*|hppa*|i*86|ia64*|m68*|mips*|powerpc*|sparc*|s390*|sh*|x86_64*) + lt_cv_deplibs_check_method=pass_all ;; + *) + # glibc up to 2.1.1 does not perform some relocations on ARM + # this will be overridden with pass_all, but let us keep it just in case + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' ;; + esac + lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so` + lt_cv_deplibs_check_method=pass_all + ;; + +netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' + else + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$' + fi + ;; + +newos6*) + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=/usr/lib/libnls.so + ;; + +nto-qnx*) + lt_cv_deplibs_check_method=unknown + ;; + +openbsd*) + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB shared object' + else + lt_cv_deplibs_check_method='file_magic OpenBSD.* shared library' + fi + ;; + +osf3* | osf4* | osf5*) + lt_cv_deplibs_check_method=pass_all + ;; + +sco3.2v5*) + lt_cv_deplibs_check_method=pass_all + ;; + +solaris*) + lt_cv_deplibs_check_method=pass_all + ;; + +sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + case $host_vendor in + motorola) + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]' + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` + ;; + ncr) + lt_cv_deplibs_check_method=pass_all + ;; + sequent) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' + ;; + sni) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib" + lt_cv_file_magic_test_file=/lib/libc.so + ;; + siemens) + lt_cv_deplibs_check_method=pass_all + ;; + esac + ;; + +sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[[78]]* | unixware7* | sysv4*uw2*) + lt_cv_deplibs_check_method=pass_all + ;; +esac +]) +file_magic_cmd=$lt_cv_file_magic_cmd +deplibs_check_method=$lt_cv_deplibs_check_method +test -z "$deplibs_check_method" && deplibs_check_method=unknown +])# AC_DEPLIBS_CHECK_METHOD + + +# AC_PROG_NM +# ---------- +# find the pathname to a BSD-compatible name lister +AC_DEFUN([AC_PROG_NM], +[AC_CACHE_CHECK([for BSD-compatible nm], lt_cv_path_NM, +[if test -n "$NM"; then + # Let the user override the test. + lt_cv_path_NM="$NM" +else + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + tmp_nm="$ac_dir/${ac_tool_prefix}nm" + if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then + # Check to see if the nm accepts a BSD-compat flag. + # Adding the `sed 1q' prevents false positives on HP-UX, which says: + # nm: unknown option "B" ignored + # Tru64's nm complains that /dev/null is an invalid object file + case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in + */dev/null* | *'Invalid file or object type'*) + lt_cv_path_NM="$tmp_nm -B" + break + ;; + *) + case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in + */dev/null*) + lt_cv_path_NM="$tmp_nm -p" + break + ;; + *) + lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but + continue # so that we can try to find one that supports BSD flags + ;; + esac + esac + fi + done + IFS="$lt_save_ifs" + test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm +fi]) +NM="$lt_cv_path_NM" +])# AC_PROG_NM + + +# AC_CHECK_LIBM +# ------------- +# check for math library +AC_DEFUN([AC_CHECK_LIBM], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +LIBM= +case $host in +*-*-beos* | *-*-cygwin* | *-*-pw32* | *-*-darwin*) + # These system don't have libm, or don't need it + ;; +*-ncr-sysv4.3*) + AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw") + AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm") + ;; +*) + AC_CHECK_LIB(m, cos, LIBM="-lm") + ;; +esac +])# AC_CHECK_LIBM + + +# AC_LIBLTDL_CONVENIENCE([DIRECTORY]) +# ----------------------------------- +# sets LIBLTDL to the link flags for the libltdl convenience library and +# LTDLINCL to the include flags for the libltdl header and adds +# --enable-ltdl-convenience to the configure arguments. Note that LIBLTDL +# and LTDLINCL are not AC_SUBSTed, nor is AC_CONFIG_SUBDIRS called. If +# DIRECTORY is not provided, it is assumed to be `libltdl'. LIBLTDL will +# be prefixed with '${top_builddir}/' and LTDLINCL will be prefixed with +# '${top_srcdir}/' (note the single quotes!). If your package is not +# flat and you're not using automake, define top_builddir and +# top_srcdir appropriately in the Makefiles. +AC_DEFUN([AC_LIBLTDL_CONVENIENCE], +[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl + case $enable_ltdl_convenience in + no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;; + "") enable_ltdl_convenience=yes + ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;; + esac + LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdlc.la + LTDLINCL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl']) + # For backwards non-gettext consistent compatibility... + INCLTDL="$LTDLINCL" +])# AC_LIBLTDL_CONVENIENCE + + +# AC_LIBLTDL_INSTALLABLE([DIRECTORY]) +# ----------------------------------- +# sets LIBLTDL to the link flags for the libltdl installable library and +# LTDLINCL to the include flags for the libltdl header and adds +# --enable-ltdl-install to the configure arguments. Note that LIBLTDL +# and LTDLINCL are not AC_SUBSTed, nor is AC_CONFIG_SUBDIRS called. If +# DIRECTORY is not provided and an installed libltdl is not found, it is +# assumed to be `libltdl'. LIBLTDL will be prefixed with '${top_builddir}/' +# and LTDLINCL will be prefixed with '${top_srcdir}/' (note the single +# quotes!). If your package is not flat and you're not using automake, +# define top_builddir and top_srcdir appropriately in the Makefiles. +# In the future, this macro may have to be called after AC_PROG_LIBTOOL. +AC_DEFUN([AC_LIBLTDL_INSTALLABLE], +[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl + AC_CHECK_LIB(ltdl, lt_dlinit, + [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no], + [if test x"$enable_ltdl_install" = xno; then + AC_MSG_WARN([libltdl not installed, but installation disabled]) + else + enable_ltdl_install=yes + fi + ]) + if test x"$enable_ltdl_install" = x"yes"; then + ac_configure_args="$ac_configure_args --enable-ltdl-install" + LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdl.la + LTDLINCL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl']) + else + ac_configure_args="$ac_configure_args --enable-ltdl-install=no" + LIBLTDL="-lltdl" + LTDLINCL= + fi + # For backwards non-gettext consistent compatibility... + INCLTDL="$LTDLINCL" +])# AC_LIBLTDL_INSTALLABLE + + +# AC_LIBTOOL_CXX +# -------------- +# enable support for C++ libraries +AC_DEFUN([AC_LIBTOOL_CXX], +[AC_REQUIRE([_LT_AC_LANG_CXX]) +])# AC_LIBTOOL_CXX + + +# _LT_AC_LANG_CXX +# --------------- +AC_DEFUN([_LT_AC_LANG_CXX], +[AC_REQUIRE([AC_PROG_CXX]) +AC_REQUIRE([AC_PROG_CXXCPP]) +_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}CXX]) +])# _LT_AC_LANG_CXX + + +# AC_LIBTOOL_F77 +# -------------- +# enable support for Fortran 77 libraries +AC_DEFUN([AC_LIBTOOL_F77], +[AC_REQUIRE([_LT_AC_LANG_F77]) +])# AC_LIBTOOL_F77 + + +# _LT_AC_LANG_F77 +# --------------- +AC_DEFUN([_LT_AC_LANG_F77], +[AC_REQUIRE([AC_PROG_F77]) +_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}F77]) +])# _LT_AC_LANG_F77 + + +# AC_LIBTOOL_GCJ +# -------------- +# enable support for GCJ libraries +AC_DEFUN([AC_LIBTOOL_GCJ], +[AC_REQUIRE([_LT_AC_LANG_GCJ]) +])# AC_LIBTOOL_GCJ + + +# _LT_AC_LANG_GCJ +# --------------- +AC_DEFUN([_LT_AC_LANG_GCJ], +[AC_PROVIDE_IFELSE([AC_PROG_GCJ],[], + [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],[], + [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ],[], + [ifdef([AC_PROG_GCJ],[AC_REQUIRE([AC_PROG_GCJ])], + [ifdef([A][M_PROG_GCJ],[AC_REQUIRE([A][M_PROG_GCJ])], + [AC_REQUIRE([A][C_PROG_GCJ_OR_A][M_PROG_GCJ])])])])])]) +_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}GCJ]) +])# _LT_AC_LANG_GCJ + + +# AC_LIBTOOL_RC +# -------------- +# enable support for Windows resource files +AC_DEFUN([AC_LIBTOOL_RC], +[AC_REQUIRE([LT_AC_PROG_RC]) +_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}RC]) +])# AC_LIBTOOL_RC + + +# AC_LIBTOOL_LANG_C_CONFIG +# ------------------------ +# Ensure that the configuration vars for the C compiler are +# suitably defined. Those variables are subsequently used by +# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'. +AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG], [_LT_AC_LANG_C_CONFIG]) +AC_DEFUN([_LT_AC_LANG_C_CONFIG], +[lt_save_CC="$CC" +AC_LANG_PUSH(C) + +# Source file extension for C test sources. +ac_ext=c + +# Object file extension for compiled C test sources. +objext=o +_LT_AC_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="int some_variable = 0;\n" + +# Code to be used in simple link tests +lt_simple_link_test_code='int main(){return(0);}\n' + +_LT_AC_SYS_COMPILER + +# +# Check for any special shared library compilation flags. +# +_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)= +if test "$GCC" = no; then + case $host_os in + sco3.2v5*) + _LT_AC_TAGVAR(lt_prog_cc_shlib, $1)='-belf' + ;; + esac +fi +if test -n "$_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)"; then + AC_MSG_WARN([`$CC' requires `$_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)' to build shared libraries]) + if echo "$old_CC $old_CFLAGS " | grep "[[ ]]$_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)[[ ]]" >/dev/null; then : + else + AC_MSG_WARN([add `$_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)' to the CC or CFLAGS env variable and reconfigure]) + _LT_AC_TAGVAR(lt_cv_prog_cc_can_build_shared, $1)=no + fi +fi + + +# +# Check to make sure the static flag actually works. +# +AC_LIBTOOL_LINKER_OPTION([if $compiler static flag $_LT_AC_TAGVAR(lt_prog_compiler_static, $1) works], + _LT_AC_TAGVAR(lt_prog_compiler_static_works, $1), + $_LT_AC_TAGVAR(lt_prog_compiler_static, $1), + [], + [_LT_AC_TAGVAR(lt_prog_compiler_static, $1)=]) + + +AC_LIBTOOL_PROG_COMPILER_NO_RTTI($1) +AC_LIBTOOL_PROG_COMPILER_PIC($1) +AC_LIBTOOL_PROG_CC_C_O($1) +AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1) +AC_LIBTOOL_PROG_LD_SHLIBS($1) +AC_LIBTOOL_SYS_DYNAMIC_LINKER($1) +AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1) +AC_LIBTOOL_SYS_LIB_STRIP +AC_LIBTOOL_DLOPEN_SELF($1) + +# Report which librarie types wil actually be built +AC_MSG_CHECKING([if libtool supports shared libraries]) +AC_MSG_RESULT([$can_build_shared]) + +AC_MSG_CHECKING([whether to build shared libraries]) +test "$can_build_shared" = "no" && enable_shared=no + +# On AIX, shared libraries and static libraries use the same namespace, and +# are all built from PIC. +case "$host_os" in +aix3*) + test "$enable_shared" = yes && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + +aix4* | aix5*) + if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then + test "$enable_shared" = yes && enable_static=no + fi + ;; + darwin* | rhapsody*) + if test "$GCC" = yes; then + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no + case "$host_os" in + rhapsody* | darwin1.[[012]]) + _LT_AC_TAGVAR(allow_undefined_flag, $1)='-undefined suppress' + ;; + *) # Darwin 1.3 on + if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then + _LT_AC_TAGVAR(allow_undefined_flag, $1)='-flat_namespace -undefined suppress' + else + case ${MACOSX_DEPLOYMENT_TARGET} in + 10.[[012]]) + _LT_AC_TAGVAR(allow_undefined_flag, $1)='-flat_namespace -undefined suppress' + ;; + 10.*) + _LT_AC_TAGVAR(allow_undefined_flag, $1)='-undefined dynamic_lookup' + ;; + esac + fi + ;; + esac + output_verbose_link_cmd='echo' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs$compiler_flags -install_name $rpath/$soname $verstring' + _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' + # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs$compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + _LT_AC_TAGVAR(hardcode_direct, $1)=no + _LT_AC_TAGVAR(hardcode_automatic, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-all_load $convenience' + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + else + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; +esac +AC_MSG_RESULT([$enable_shared]) + +AC_MSG_CHECKING([whether to build static libraries]) +# Make sure either enable_shared or enable_static is yes. +test "$enable_shared" = yes || enable_static=yes +AC_MSG_RESULT([$enable_static]) + +AC_LIBTOOL_CONFIG($1) + +AC_LANG_POP +CC="$lt_save_CC" +])# AC_LIBTOOL_LANG_C_CONFIG + + +# AC_LIBTOOL_LANG_CXX_CONFIG +# -------------------------- +# Ensure that the configuration vars for the C compiler are +# suitably defined. Those variables are subsequently used by +# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'. +AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG], [_LT_AC_LANG_CXX_CONFIG(CXX)]) +AC_DEFUN([_LT_AC_LANG_CXX_CONFIG], +[AC_LANG_PUSH(C++) +AC_REQUIRE([AC_PROG_CXX]) +AC_REQUIRE([AC_PROG_CXXCPP]) + +_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no +_LT_AC_TAGVAR(allow_undefined_flag, $1)= +_LT_AC_TAGVAR(always_export_symbols, $1)=no +_LT_AC_TAGVAR(archive_expsym_cmds, $1)= +_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)= +_LT_AC_TAGVAR(hardcode_direct, $1)=no +_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)= +_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= +_LT_AC_TAGVAR(hardcode_libdir_separator, $1)= +_LT_AC_TAGVAR(hardcode_minus_L, $1)=no +_LT_AC_TAGVAR(hardcode_automatic, $1)=no +_LT_AC_TAGVAR(module_cmds, $1)= +_LT_AC_TAGVAR(module_expsym_cmds, $1)= +_LT_AC_TAGVAR(link_all_deplibs, $1)=unknown +_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_AC_TAGVAR(no_undefined_flag, $1)= +_LT_AC_TAGVAR(whole_archive_flag_spec, $1)= +_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no + +# Dependencies to place before and after the object being linked: +_LT_AC_TAGVAR(predep_objects, $1)= +_LT_AC_TAGVAR(postdep_objects, $1)= +_LT_AC_TAGVAR(predeps, $1)= +_LT_AC_TAGVAR(postdeps, $1)= +_LT_AC_TAGVAR(compiler_lib_search_path, $1)= + +# Source file extension for C++ test sources. +ac_ext=cc + +# Object file extension for compiled C++ test sources. +objext=o +_LT_AC_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="int some_variable = 0;\n" + +# Code to be used in simple link tests +lt_simple_link_test_code='int main(int, char *[]) { return(0); }\n' + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. +_LT_AC_SYS_COMPILER + +# Allow CC to be a program name with arguments. +lt_save_CC=$CC +lt_save_LD=$LD +lt_save_GCC=$GCC +GCC=$GXX +lt_save_with_gnu_ld=$with_gnu_ld +lt_save_path_LD=$lt_cv_path_LD +if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then + lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx +else + unset lt_cv_prog_gnu_ld +fi +if test -n "${lt_cv_path_LDCXX+set}"; then + lt_cv_path_LD=$lt_cv_path_LDCXX +else + unset lt_cv_path_LD +fi +test -z "${LDCXX+set}" || LD=$LDCXX +CC=${CXX-"c++"} +compiler=$CC +_LT_AC_TAGVAR(compiler, $1)=$CC +cc_basename=`$echo X"$compiler" | $Xsed -e 's%^.*/%%'` + +# We don't want -fno-exception wen compiling C++ code, so set the +# no_builtin_flag separately +if test "$GXX" = yes; then + _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' +else + _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= +fi + +if test "$GXX" = yes; then + # Set up default GNU C++ configuration + + AC_PROG_LD + + # Check if GNU C++ uses GNU ld as the underlying linker, since the + # archiving commands below assume that GNU ld is being used. + if test "$with_gnu_ld" = yes; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + + # If archive_cmds runs LD, not CC, wlarc should be empty + # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to + # investigate it a little bit more. (MM) + wlarc='${wl}' + + # ancient GNU ld didn't support --whole-archive et. al. + if eval "`$CC -print-prog-name=ld` --help 2>&1" | \ + grep 'no-whole-archive' > /dev/null; then + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)= + fi + else + with_gnu_ld=no + wlarc= + + # A generic and very simple default shared library creation + # command for GNU C++ for the case where it uses the native + # linker, instead of GNU ld. If possible, this setting should + # overridden to take advantage of the native linker features on + # the platform it is being used on. + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' + fi + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"' + +else + GXX=no + with_gnu_ld=no + wlarc= +fi + +# PORTME: fill in a description of your system's C++ link characteristics +AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) +_LT_AC_TAGVAR(ld_shlibs, $1)=yes +case $host_os in + aix3*) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + aix4* | aix5*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag="" + else + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*) + for ld_flag in $LDFLAGS; do + case $ld_flag in + *-brtl*) + aix_use_runtimelinking=yes + break + ;; + esac + done + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + _LT_AC_TAGVAR(archive_cmds, $1)='' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + + if test "$GXX" = yes; then + case $host_os in aix4.[012]|aix4.[012].*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && \ + strings "$collect2name" | grep resolve_lib_name >/dev/null + then + # We have reworked collect2 + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + else + # We have old collect2 + _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)= + fi + esac + shared_flag='-shared' + else + # not using gcc + if test "$host_cpu" = ia64; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test "$aix_use_runtimelinking" = yes; then + shared_flag='${wl}-G' + else + shared_flag='${wl}-bM:SRE' + fi + fi + fi + + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to export. + _LT_AC_TAGVAR(always_export_symbols, $1)=yes + if test "$aix_use_runtimelinking" = yes; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + _LT_AC_TAGVAR(allow_undefined_flag, $1)='-berok' + # Determine the default libpath from the value encoded in an empty executable. + _LT_AC_SYS_LIBPATH_AIX + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" + + _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag" + else + if test "$host_cpu" = ia64; then + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' + _LT_AC_TAGVAR(allow_undefined_flag, $1)="-z nodefs" + _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an empty executable. + _LT_AC_SYS_LIBPATH_AIX + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' + # -bexpall does not export symbols beginning with underscore (_) + _LT_AC_TAGVAR(always_export_symbols, $1)=yes + # Exported symbols can be pulled into shared objects from archives + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=' ' + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes + # This is similar to how AIX traditionally builds it's shared libraries. + _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' + fi + fi + ;; + chorus*) + case $cc_basename in + *) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + cygwin* | mingw* | pw32*) + # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, + # as there is no search path for DLLs. + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_AC_TAGVAR(always_export_symbols, $1)=no + _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + + if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib' + # If the export-symbols file already is a .def file (1st line + # is EXPORTS), use it as is; otherwise, prepend... + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib' + else + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + darwin* | rhapsody*) + if test "$GXX" = yes; then + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no + case "$host_os" in + rhapsody* | darwin1.[[012]]) + _LT_AC_TAGVAR(allow_undefined_flag, $1)='-undefined suppress' + ;; + *) # Darwin 1.3 on + if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then + _LT_AC_TAGVAR(allow_undefined_flag, $1)='-flat_namespace -undefined suppress' + else + case ${MACOSX_DEPLOYMENT_TARGET} in + 10.[[012]]) + _LT_AC_TAGVAR(allow_undefined_flag, $1)='-flat_namespace -undefined suppress' + ;; + 10.*) + _LT_AC_TAGVAR(allow_undefined_flag, $1)='-undefined dynamic_lookup' + ;; + esac + fi + ;; + esac + lt_int_apple_cc_single_mod=no + output_verbose_link_cmd='echo' + if $CC -dumpspecs 2>&1 | grep 'single_module' >/dev/null ; then + lt_int_apple_cc_single_mod=yes + fi + if test "X$lt_int_apple_cc_single_mod" = Xyes ; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring' + else + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -r ${wl}-bind_at_load -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring' + fi + _LT_AC_TAGVAR(module_cmds, $1)='$CC ${wl}-bind_at_load $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' + + # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's + if test "X$lt_int_apple_cc_single_mod" = Xyes ; then + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + else + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r ${wl}-bind_at_load -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + fi + _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + _LT_AC_TAGVAR(hardcode_direct, $1)=no + _LT_AC_TAGVAR(hardcode_automatic, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-all_load $convenience' + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + else + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + dgux*) + case $cc_basename in + ec++) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + ghcx) + # Green Hills C++ Compiler + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + freebsd[12]*) + # C++ shared libraries reported to be fairly broken before switch to ELF + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + freebsd-elf*) + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no + ;; + freebsd* | kfreebsd*-gnu) + # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF + # conventions + _LT_AC_TAGVAR(ld_shlibs, $1)=yes + ;; + gnu*) + ;; + hpux9*) + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, + # but as the default + # location of the library. + + case $cc_basename in + CC) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + aCC) + _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "[-]L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + *) + if test "$GXX" = yes; then + _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + else + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + hpux10*|hpux11*) + if test $with_gnu_ld = no; then + case "$host_cpu" in + hppa*64*) + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + ;; + ia64*) + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + ;; + *) + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + ;; + esac + fi + case "$host_cpu" in + hppa*64*) + _LT_AC_TAGVAR(hardcode_direct, $1)=no + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + ia64*) + _LT_AC_TAGVAR(hardcode_direct, $1)=no + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, + # but as the default + # location of the library. + ;; + *) + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, + # but as the default + # location of the library. + ;; + esac + + case $cc_basename in + CC) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + aCC) + case "$host_cpu" in + hppa*64*|ia64*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname -o $lib $linker_flags $libobjs $deplibs' + ;; + *) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + esac + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + *) + if test "$GXX" = yes; then + if test $with_gnu_ld = no; then + case "$host_cpu" in + ia64*|hppa*64*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname -o $lib $linker_flags $libobjs $deplibs' + ;; + *) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + esac + fi + else + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + irix5* | irix6*) + case $cc_basename in + CC) + # SGI C++ + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib' + + # Archives containing C++ object files must be created using + # "CC -ar", where "CC" is the IRIX C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs' + ;; + *) + if test "$GXX" = yes; then + if test "$with_gnu_ld" = no; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib' + else + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` -o $lib' + fi + fi + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + ;; + esac + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + ;; + linux*) + case $cc_basename in + KCC) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | grep "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath,$libdir' + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + + # Archives containing C++ object files must be created using + # "CC -Bstatic", where "CC" is the KAI C++ compiler. + _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' + ;; + icpc) + # Intel C++ + with_gnu_ld=yes + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' + ;; + cxx) + # Compaq C++ + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' + + runpath_var=LD_RUN_PATH + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + esac + ;; + lynxos*) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + m88k*) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + mvs*) + case $cc_basename in + cxx) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' + wlarc= + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + fi + # Workaround some broken pre-1.5 toolchains + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' + ;; + osf3*) + case $cc_basename in + KCC) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + + # Archives containing C++ object files must be created using + # "CC -Bstatic", where "CC" is the KAI C++ compiler. + _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' + + ;; + RCC) + # Rational C++ 2.4.1 + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + cxx) + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${objdir}/so_locations -o $lib' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + *) + if test "$GXX" = yes && test "$with_gnu_ld" = no; then + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"' + + else + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + osf4* | osf5*) + case $cc_basename in + KCC) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + + # Archives containing C++ object files must be created using + # the KAI C++ compiler. + _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' + ;; + RCC) + # Rational C++ 2.4.1 + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + cxx) + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ + echo "-hidden">> $lib.exp~ + $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname -Wl,-input -Wl,$lib.exp `test -n "$verstring" && echo -set_version $verstring` -update_registry $objdir/so_locations -o $lib~ + $rm $lib.exp' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + *) + if test "$GXX" = yes && test "$with_gnu_ld" = no; then + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"' + + else + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + psos*) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + sco*) + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no + case $cc_basename in + CC) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + sunos4*) + case $cc_basename in + CC) + # Sun C++ 4.x + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + lcc) + # Lucid + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + solaris*) + case $cc_basename in + CC) + # Sun C++ 4.2, 5.x and Centerline C++ + _LT_AC_TAGVAR(no_undefined_flag, $1)=' -zdefs' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -nolib -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $CC -G${allow_undefined_flag} -nolib ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + case $host_os in + solaris2.[0-5] | solaris2.[0-5].*) ;; + *) + # The C++ compiler is used as linker so we must use $wl + # flag to pass the commands to the underlying system + # linker. + # Supported since Solaris 2.6 (maybe 2.5.1?) + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' + ;; + esac + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -G $CFLAGS -v conftest.$objext 2>&1 | grep "\-[[LR]]"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + + # Archives containing C++ object files must be created using + # "CC -xar", where "CC" is the Sun C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' + ;; + gcx) + # Green Hills C++ Compiler + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + + # The C++ compiler must be used to create the archive. + _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs' + ;; + *) + # GNU C++ compiler with Solaris linker + if test "$GXX" = yes && test "$with_gnu_ld" = no; then + _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs' + if $CC --version | grep -v '^2\.7' > /dev/null; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd="$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\"" + else + # g++ 2.7 appears to require `-G' NOT `-shared' on this + # platform. + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd="$CC -G $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\"" + fi + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir' + fi + ;; + esac + ;; + sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[[78]]* | unixware7*) + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no + ;; + tandem*) + case $cc_basename in + NCC) + # NonStop-UX NCC 3.20 + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + vxworks*) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; +esac +AC_MSG_RESULT([$_LT_AC_TAGVAR(ld_shlibs, $1)]) +test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no + +_LT_AC_TAGVAR(GCC, $1)="$GXX" +_LT_AC_TAGVAR(LD, $1)="$LD" + +AC_LIBTOOL_POSTDEP_PREDEP($1) +AC_LIBTOOL_PROG_COMPILER_PIC($1) +AC_LIBTOOL_PROG_CC_C_O($1) +AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1) +AC_LIBTOOL_PROG_LD_SHLIBS($1) +AC_LIBTOOL_SYS_DYNAMIC_LINKER($1) +AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1) +AC_LIBTOOL_SYS_LIB_STRIP +AC_LIBTOOL_DLOPEN_SELF($1) + +AC_LIBTOOL_CONFIG($1) + +AC_LANG_POP +CC=$lt_save_CC +LDCXX=$LD +LD=$lt_save_LD +GCC=$lt_save_GCC +with_gnu_ldcxx=$with_gnu_ld +with_gnu_ld=$lt_save_with_gnu_ld +lt_cv_path_LDCXX=$lt_cv_path_LD +lt_cv_path_LD=$lt_save_path_LD +lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld +lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld +])# AC_LIBTOOL_LANG_CXX_CONFIG + +# AC_LIBTOOL_POSTDEP_PREDEP([TAGNAME]) +# ------------------------ +# Figure out "hidden" library dependencies from verbose +# compiler output when linking a shared library. +# Parse the compiler output and extract the necessary +# objects, libraries and library flags. +AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP],[ +dnl we can't use the lt_simple_compile_test_code here, +dnl because it contains code intended for an executable, +dnl not a library. It's possible we should let each +dnl tag define a new lt_????_link_test_code variable, +dnl but it's only used here... +ifelse([$1],[],[cat > conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext <> "$cfgfile" +ifelse([$1], [], +[#! $SHELL + +# `$echo "$cfgfile" | sed 's%^.*/%%'` - Provide generalized library-building support services. +# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP) +# NOTE: Changes made to this file will be lost: look at ltmain.sh. +# +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 +# Free Software Foundation, Inc. +# +# This file is part of GNU Libtool: +# Originally by Gordon Matzigkeit , 1996 +# +# 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. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# A sed program that does not truncate output. +SED=$lt_SED + +# Sed that helps us avoid accidentally triggering echo(1) options like -n. +Xsed="$SED -e s/^X//" + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +if test "X\${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi + +# The names of the tagged configurations supported by this script. +available_tags= + +# ### BEGIN LIBTOOL CONFIG], +[# ### BEGIN LIBTOOL TAG CONFIG: $tagname]) + +# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: + +# Shell to use when invoking shell scripts. +SHELL=$lt_SHELL + +# Whether or not to build shared libraries. +build_libtool_libs=$enable_shared + +# Whether or not to build static libraries. +build_old_libs=$enable_static + +# Whether or not to add -lc for building shared libraries. +build_libtool_need_lc=$_LT_AC_TAGVAR(archive_cmds_need_lc, $1) + +# Whether or not to disallow shared libs when runtime libs are static +allow_libtool_libs_with_static_runtimes=$_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1) + +# Whether or not to optimize for fast installation. +fast_install=$enable_fast_install + +# The host system. +host_alias=$host_alias +host=$host + +# An echo program that does not interpret backslashes. +echo=$lt_echo + +# The archiver. +AR=$lt_AR +AR_FLAGS=$lt_AR_FLAGS + +# A C compiler. +LTCC=$lt_LTCC + +# A language-specific compiler. +CC=$lt_[]_LT_AC_TAGVAR(compiler, $1) + +# Is the compiler the GNU C compiler? +with_gcc=$_LT_AC_TAGVAR(GCC, $1) + +# An ERE matcher. +EGREP=$lt_EGREP + +# The linker used to build libraries. +LD=$lt_[]_LT_AC_TAGVAR(LD, $1) + +# Whether we need hard or soft links. +LN_S=$lt_LN_S + +# A BSD-compatible nm program. +NM=$lt_NM + +# A symbol stripping program +STRIP=$lt_STRIP + +# Used to examine libraries when file_magic_cmd begins "file" +MAGIC_CMD=$MAGIC_CMD + +# Used on cygwin: DLL creation program. +DLLTOOL="$DLLTOOL" + +# Used on cygwin: object dumper. +OBJDUMP="$OBJDUMP" + +# Used on cygwin: assembler. +AS="$AS" + +# The name of the directory that contains temporary libtool files. +objdir=$objdir + +# How to create reloadable object files. +reload_flag=$lt_reload_flag +reload_cmds=$lt_reload_cmds + +# How to pass a linker flag through the compiler. +wl=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_wl, $1) + +# Object file suffix (normally "o"). +objext="$ac_objext" + +# Old archive suffix (normally "a"). +libext="$libext" + +# Shared library suffix (normally ".so"). +shrext_cmds='$shrext_cmds' + +# Executable file suffix (normally ""). +exeext="$exeext" + +# Additional compiler flags for building library objects. +pic_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) +pic_mode=$pic_mode + +# What is the maximum length of a command? +max_cmd_len=$lt_cv_sys_max_cmd_len + +# Does compiler simultaneously support -c and -o options? +compiler_c_o=$lt_[]_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1) + +# Must we lock files when doing compilation ? +need_locks=$lt_need_locks + +# Do we need the lib prefix for modules? +need_lib_prefix=$need_lib_prefix + +# Do we need a version for libraries? +need_version=$need_version + +# Whether dlopen is supported. +dlopen_support=$enable_dlopen + +# Whether dlopen of programs is supported. +dlopen_self=$enable_dlopen_self + +# Whether dlopen of statically linked programs is supported. +dlopen_self_static=$enable_dlopen_self_static + +# Compiler flag to prevent dynamic linking. +link_static_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_static, $1) + +# Compiler flag to turn off builtin functions. +no_builtin_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) + +# Compiler flag to allow reflexive dlopens. +export_dynamic_flag_spec=$lt_[]_LT_AC_TAGVAR(export_dynamic_flag_spec, $1) + +# Compiler flag to generate shared objects directly from archives. +whole_archive_flag_spec=$lt_[]_LT_AC_TAGVAR(whole_archive_flag_spec, $1) + +# Compiler flag to generate thread-safe objects. +thread_safe_flag_spec=$lt_[]_LT_AC_TAGVAR(thread_safe_flag_spec, $1) + +# Library versioning type. +version_type=$version_type + +# Format of library name prefix. +libname_spec=$lt_libname_spec + +# List of archive names. First name is the real one, the rest are links. +# The last name is the one that the linker finds with -lNAME. +library_names_spec=$lt_library_names_spec + +# The coded name of the library, if different from the real name. +soname_spec=$lt_soname_spec + +# Commands used to build and install an old-style archive. +RANLIB=$lt_RANLIB +old_archive_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_cmds, $1) +old_postinstall_cmds=$lt_old_postinstall_cmds +old_postuninstall_cmds=$lt_old_postuninstall_cmds + +# Create an old-style archive from a shared archive. +old_archive_from_new_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_from_new_cmds, $1) + +# Create a temporary old-style archive to link instead of a shared archive. +old_archive_from_expsyms_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1) + +# Commands used to build and install a shared archive. +archive_cmds=$lt_[]_LT_AC_TAGVAR(archive_cmds, $1) +archive_expsym_cmds=$lt_[]_LT_AC_TAGVAR(archive_expsym_cmds, $1) +postinstall_cmds=$lt_postinstall_cmds +postuninstall_cmds=$lt_postuninstall_cmds + +# Commands used to build a loadable module (assumed same as above if empty) +module_cmds=$lt_[]_LT_AC_TAGVAR(module_cmds, $1) +module_expsym_cmds=$lt_[]_LT_AC_TAGVAR(module_expsym_cmds, $1) + +# Commands to strip libraries. +old_striplib=$lt_old_striplib +striplib=$lt_striplib + +# Dependencies to place before the objects being linked to create a +# shared library. +predep_objects=$lt_[]_LT_AC_TAGVAR(predep_objects, $1) + +# Dependencies to place after the objects being linked to create a +# shared library. +postdep_objects=$lt_[]_LT_AC_TAGVAR(postdep_objects, $1) + +# Dependencies to place before the objects being linked to create a +# shared library. +predeps=$lt_[]_LT_AC_TAGVAR(predeps, $1) + +# Dependencies to place after the objects being linked to create a +# shared library. +postdeps=$lt_[]_LT_AC_TAGVAR(postdeps, $1) + +# The library search path used internally by the compiler when linking +# a shared library. +compiler_lib_search_path=$lt_[]_LT_AC_TAGVAR(compiler_lib_search_path, $1) + +# Method to check whether dependent libraries are shared objects. +deplibs_check_method=$lt_deplibs_check_method + +# Command to use when deplibs_check_method == file_magic. +file_magic_cmd=$lt_file_magic_cmd + +# Flag that allows shared libraries with undefined symbols to be built. +allow_undefined_flag=$lt_[]_LT_AC_TAGVAR(allow_undefined_flag, $1) + +# Flag that forces no undefined symbols. +no_undefined_flag=$lt_[]_LT_AC_TAGVAR(no_undefined_flag, $1) + +# Commands used to finish a libtool library installation in a directory. +finish_cmds=$lt_finish_cmds + +# Same as above, but a single script fragment to be evaled but not shown. +finish_eval=$lt_finish_eval + +# Take the output of nm and produce a listing of raw symbols and C names. +global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe + +# Transform the output of nm in a proper C declaration +global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl + +# Transform the output of nm in a C name address pair +global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address + +# This is the shared library runtime path variable. +runpath_var=$runpath_var + +# This is the shared library path variable. +shlibpath_var=$shlibpath_var + +# Is shlibpath searched before the hard-coded library search path? +shlibpath_overrides_runpath=$shlibpath_overrides_runpath + +# How to hardcode a shared library path into an executable. +hardcode_action=$_LT_AC_TAGVAR(hardcode_action, $1) + +# Whether we should hardcode library paths into libraries. +hardcode_into_libs=$hardcode_into_libs + +# Flag to hardcode \$libdir into a binary during linking. +# This must work even if \$libdir does not exist. +hardcode_libdir_flag_spec=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) + +# If ld is used when linking, flag to hardcode \$libdir into +# a binary during linking. This must work even if \$libdir does +# not exist. +hardcode_libdir_flag_spec_ld=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1) + +# Whether we need a single -rpath flag with a separated argument. +hardcode_libdir_separator=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_separator, $1) + +# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the +# resulting binary. +hardcode_direct=$_LT_AC_TAGVAR(hardcode_direct, $1) + +# Set to yes if using the -LDIR flag during linking hardcodes DIR into the +# resulting binary. +hardcode_minus_L=$_LT_AC_TAGVAR(hardcode_minus_L, $1) + +# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into +# the resulting binary. +hardcode_shlibpath_var=$_LT_AC_TAGVAR(hardcode_shlibpath_var, $1) + +# Set to yes if building a shared library automatically hardcodes DIR into the library +# and all subsequent libraries and executables linked against it. +hardcode_automatic=$_LT_AC_TAGVAR(hardcode_automatic, $1) + +# Variables whose values should be saved in libtool wrapper scripts and +# restored at relink time. +variables_saved_for_relink="$variables_saved_for_relink" + +# Whether libtool must link a program against all its dependency libraries. +link_all_deplibs=$_LT_AC_TAGVAR(link_all_deplibs, $1) + +# Compile-time system search path for libraries +sys_lib_search_path_spec=$lt_sys_lib_search_path_spec + +# Run-time system search path for libraries +sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec + +# Fix the shell variable \$srcfile for the compiler. +fix_srcfile_path="$_LT_AC_TAGVAR(fix_srcfile_path, $1)" + +# Set to yes if exported symbols are required. +always_export_symbols=$_LT_AC_TAGVAR(always_export_symbols, $1) + +# The commands to list exported symbols. +export_symbols_cmds=$lt_[]_LT_AC_TAGVAR(export_symbols_cmds, $1) + +# The commands to extract the exported symbol list from a shared archive. +extract_expsyms_cmds=$lt_extract_expsyms_cmds + +# Symbols that should not be listed in the preloaded symbols. +exclude_expsyms=$lt_[]_LT_AC_TAGVAR(exclude_expsyms, $1) + +# Symbols that must always be exported. +include_expsyms=$lt_[]_LT_AC_TAGVAR(include_expsyms, $1) + +ifelse([$1],[], +[# ### END LIBTOOL CONFIG], +[# ### END LIBTOOL TAG CONFIG: $tagname]) + +__EOF__ + +ifelse([$1],[], [ + case $host_os in + aix3*) + cat <<\EOF >> "$cfgfile" + +# AIX sometimes has problems with the GCC collect2 program. For some +# reason, if we set the COLLECT_NAMES environment variable, the problems +# vanish in a puff of smoke. +if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES +fi +EOF + ;; + esac + + # We use sed instead of cat because bash on DJGPP gets confused if + # if finds mixed CR/LF and LF-only lines. Since sed operates in + # text mode, it properly converts lines to CR/LF. This bash problem + # is reportedly fixed, but why not run on old versions too? + sed '$q' "$ltmain" >> "$cfgfile" || (rm -f "$cfgfile"; exit 1) + + mv -f "$cfgfile" "$ofile" || \ + (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") + chmod +x "$ofile" +]) +else + # If there is no Makefile yet, we rely on a make rule to execute + # `config.status --recheck' to rerun these tests and create the + # libtool script then. + ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'` + if test -f "$ltmain_in"; then + test -f Makefile && make "$ltmain" + fi +fi +])# AC_LIBTOOL_CONFIG + + +# AC_LIBTOOL_PROG_COMPILER_NO_RTTI([TAGNAME]) +# ------------------------------------------- +AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], +[AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl + +_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= + +if test "$GCC" = yes; then + _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' + + AC_LIBTOOL_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions], + lt_cv_prog_compiler_rtti_exceptions, + [-fno-rtti -fno-exceptions], [], + [_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"]) +fi +])# AC_LIBTOOL_PROG_COMPILER_NO_RTTI + + +# AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE +# --------------------------------- +AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], +[AC_REQUIRE([AC_CANONICAL_HOST]) +AC_REQUIRE([AC_PROG_NM]) +AC_REQUIRE([AC_OBJEXT]) +# Check for command to grab the raw symbol name followed by C symbol from nm. +AC_MSG_CHECKING([command to parse $NM output from $compiler object]) +AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe], +[ +# These are sane defaults that work on at least a few old systems. +# [They come from Ultrix. What could be older than Ultrix?!! ;)] + +# Character class describing NM global symbol codes. +symcode='[[BCDEGRST]]' + +# Regexp to match symbols that can be accessed directly from C. +sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)' + +# Transform the above into a raw symbol and a C symbol. +symxfrm='\1 \2\3 \3' + +# Transform an extracted symbol line into a proper C declaration +lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern int \1;/p'" + +# Transform an extracted symbol line into symbol name and symbol address +lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" + +# Define system-specific variables. +case $host_os in +aix*) + symcode='[[BCDT]]' + ;; +cygwin* | mingw* | pw32*) + symcode='[[ABCDGISTW]]' + ;; +hpux*) # Its linker distinguishes data from code symbols + if test "$host_cpu" = ia64; then + symcode='[[ABCDEGRST]]' + fi + lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" + lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" + ;; +irix* | nonstopux*) + symcode='[[BCDEGRST]]' + ;; +osf*) + symcode='[[BCDEGQRST]]' + ;; +solaris* | sysv5*) + symcode='[[BDRT]]' + ;; +sysv4) + symcode='[[DFNSTU]]' + ;; +esac + +# Handle CRLF in mingw tool chain +opt_cr= +case $build_os in +mingw*) + opt_cr=`echo 'x\{0,1\}' | tr x '\015'` # option cr in regexp + ;; +esac + +# If we're using GNU nm, then use its standard symbol codes. +case `$NM -V 2>&1` in +*GNU* | *'with BFD'*) + symcode='[[ABCDGIRSTW]]' ;; +esac + +# Try without a prefix undercore, then with it. +for ac_symprfx in "" "_"; do + + # Write the raw and C identifiers. + lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*\($ac_symprfx\)$sympat$opt_cr$/$symxfrm/p'" + + # Check to see that the pipe works correctly. + pipe_works=no + + rm -f conftest* + cat > conftest.$ac_ext < $nlist) && test -s "$nlist"; then + # Try sorting and uniquifying the output. + if sort "$nlist" | uniq > "$nlist"T; then + mv -f "$nlist"T "$nlist" + else + rm -f "$nlist"T + fi + + # Make sure that we snagged all the symbols we need. + if grep ' nm_test_var$' "$nlist" >/dev/null; then + if grep ' nm_test_func$' "$nlist" >/dev/null; then + cat < conftest.$ac_ext +#ifdef __cplusplus +extern "C" { +#endif + +EOF + # Now generate the symbol file. + eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | grep -v main >> conftest.$ac_ext' + + cat <> conftest.$ac_ext +#if defined (__STDC__) && __STDC__ +# define lt_ptr_t void * +#else +# define lt_ptr_t char * +# define const +#endif + +/* The mapping between symbol names and symbols. */ +const struct { + const char *name; + lt_ptr_t address; +} +lt_preloaded_symbols[[]] = +{ +EOF + $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (lt_ptr_t) \&\2},/" < "$nlist" | grep -v main >> conftest.$ac_ext + cat <<\EOF >> conftest.$ac_ext + {0, (lt_ptr_t) 0} +}; + +#ifdef __cplusplus +} +#endif +EOF + # Now try linking the two files. + mv conftest.$ac_objext conftstm.$ac_objext + lt_save_LIBS="$LIBS" + lt_save_CFLAGS="$CFLAGS" + LIBS="conftstm.$ac_objext" + CFLAGS="$CFLAGS$_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)" + if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then + pipe_works=yes + fi + LIBS="$lt_save_LIBS" + CFLAGS="$lt_save_CFLAGS" + else + echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD + fi + else + echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD + fi + else + echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD + fi + else + echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD + cat conftest.$ac_ext >&5 + fi + rm -f conftest* conftst* + + # Do not use the global_symbol_pipe unless it works. + if test "$pipe_works" = yes; then + break + else + lt_cv_sys_global_symbol_pipe= + fi +done +]) +if test -z "$lt_cv_sys_global_symbol_pipe"; then + lt_cv_sys_global_symbol_to_cdecl= +fi +if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then + AC_MSG_RESULT(failed) +else + AC_MSG_RESULT(ok) +fi +]) # AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE + + +# AC_LIBTOOL_PROG_COMPILER_PIC([TAGNAME]) +# --------------------------------------- +AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC], +[_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)= +_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= +_LT_AC_TAGVAR(lt_prog_compiler_static, $1)= + +AC_MSG_CHECKING([for $compiler option to produce PIC]) + ifelse([$1],[CXX],[ + # C++ specific cases for pic, static, wl, etc. + if test "$GXX" = yes; then + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + fi + ;; + amigaos*) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the `-m68020' flag to GCC prevents building anything better, + # like `-m68040'. + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' + ;; + beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + mingw* | os2* | pw32*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT' + ;; + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' + ;; + *djgpp*) + # DJGPP does not support shared libraries at all + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= + ;; + sysv4*MP*) + if test -d /usr/nec; then + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic + fi + ;; + hpux*) + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case "$host_cpu" in + hppa*64*|ia64*) + ;; + *) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + ;; + *) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + else + case $host_os in + aix4* | aix5*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + else + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' + fi + ;; + chorus*) + case $cc_basename in + cxch68) + # Green Hills C++ Compiler + # _LT_AC_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" + ;; + esac + ;; + dgux*) + case $cc_basename in + ec++) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + ;; + ghcx) + # Green Hills C++ Compiler + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + ;; + *) + ;; + esac + ;; + freebsd* | kfreebsd*-gnu) + # FreeBSD uses GNU C++ + ;; + hpux9* | hpux10* | hpux11*) + case $cc_basename in + CC) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)="${ac_cv_prog_cc_wl}-a ${ac_cv_prog_cc_wl}archive" + if test "$host_cpu" != ia64; then + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z' + fi + ;; + aCC) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)="${ac_cv_prog_cc_wl}-a ${ac_cv_prog_cc_wl}archive" + case "$host_cpu" in + hppa*64*|ia64*) + # +Z the default + ;; + *) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z' + ;; + esac + ;; + *) + ;; + esac + ;; + irix5* | irix6* | nonstopux*) + case $cc_basename in + CC) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + # CC pic flag -KPIC is the default. + ;; + *) + ;; + esac + ;; + linux*) + case $cc_basename in + KCC) + # KAI C++ Compiler + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + icpc) + # Intel C++ + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + cxx) + # Compaq C++ + # Make sure the PIC flag is empty. It appears that all Alpha + # Linux and Compaq Tru64 Unix objects are PIC. + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + *) + ;; + esac + ;; + lynxos*) + ;; + m88k*) + ;; + mvs*) + case $cc_basename in + cxx) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall' + ;; + *) + ;; + esac + ;; + netbsd*) + ;; + osf3* | osf4* | osf5*) + case $cc_basename in + KCC) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' + ;; + RCC) + # Rational C++ 2.4.1 + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + ;; + cxx) + # Digital/Compaq C++ + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # Make sure the PIC flag is empty. It appears that all Alpha + # Linux and Compaq Tru64 Unix objects are PIC. + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + *) + ;; + esac + ;; + psos*) + ;; + sco*) + case $cc_basename in + CC) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + *) + ;; + esac + ;; + solaris*) + case $cc_basename in + CC) + # Sun C++ 4.2, 5.x and Centerline C++ + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + ;; + gcx) + # Green Hills C++ Compiler + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' + ;; + *) + ;; + esac + ;; + sunos4*) + case $cc_basename in + CC) + # Sun C++ 4.x + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + lcc) + # Lucid + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + ;; + *) + ;; + esac + ;; + tandem*) + case $cc_basename in + NCC) + # NonStop-UX NCC 3.20 + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + ;; + *) + ;; + esac + ;; + unixware*) + ;; + vxworks*) + ;; + *) + _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + ;; + esac + fi +], +[ + if test "$GCC" = yes; then + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + fi + ;; + + amigaos*) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the `-m68020' flag to GCC prevents building anything better, + # like `-m68040'. + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' + ;; + + beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + + mingw* | pw32* | os2*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT' + ;; + + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' + ;; + + msdosdjgpp*) + # Just because we use GCC doesn't mean we suddenly get shared libraries + # on systems that don't support them. + _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + enable_shared=no + ;; + + sysv4*MP*) + if test -d /usr/nec; then + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic + fi + ;; + + hpux*) + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case "$host_cpu" in + hppa*64*|ia64*) + # +Z the default + ;; + *) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + ;; + + *) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + else + # PORTME Check for flag to pass linker flags through the system compiler. + case $host_os in + aix*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + else + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' + fi + ;; + + mingw* | pw32* | os2*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT' + ;; + + hpux9* | hpux10* | hpux11*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case "$host_cpu" in + hppa*64*|ia64*) + # +Z the default + ;; + *) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z' + ;; + esac + # Is there a better lt_prog_compiler_static that works with the bundled CC? + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' + ;; + + irix5* | irix6* | nonstopux*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # PIC (with -KPIC) is the default. + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + + newsos6) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + linux*) + case $CC in + icc* | ecc*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + ccc*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # All Alpha code is PIC. + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + esac + ;; + + osf3* | osf4* | osf5*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # All OSF/1 code is PIC. + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + + sco3.2v5*) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-Kpic' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-dn' + ;; + + solaris*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + sunos4*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + sysv4*MP*) + if test -d /usr/nec ;then + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + fi + ;; + + uts4*) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + *) + _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + ;; + esac + fi +]) +AC_MSG_RESULT([$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)]) + +# +# Check to make sure the PIC flag actually works. +# +if test -n "$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)"; then + AC_LIBTOOL_COMPILER_OPTION([if $compiler PIC flag $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) works], + _LT_AC_TAGVAR(lt_prog_compiler_pic_works, $1), + [$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])], [], + [case $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) in + "" | " "*) ;; + *) _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)" ;; + esac], + [_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= + _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no]) +fi +case "$host_os" in + # For platforms which do not support PIC, -DPIC is meaningless: + *djgpp*) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= + ;; + *) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])" + ;; +esac +]) + + +# AC_LIBTOOL_PROG_LD_SHLIBS([TAGNAME]) +# ------------------------------------ +# See if the linker supports building shared libraries. +AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS], +[AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) +ifelse([$1],[CXX],[ + _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + case $host_os in + aix4* | aix5*) + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to AIX nm, but means don't demangle with GNU nm + if $NM -V 2>&1 | grep 'GNU' > /dev/null; then + _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols' + else + _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols' + fi + ;; + pw32*) + _LT_AC_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds" + ;; + cygwin* | mingw*) + _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGS]] /s/.* \([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols' + ;; + *) + _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + ;; + esac +],[ + runpath_var= + _LT_AC_TAGVAR(allow_undefined_flag, $1)= + _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no + _LT_AC_TAGVAR(archive_cmds, $1)= + _LT_AC_TAGVAR(archive_expsym_cmds, $1)= + _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)= + _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1)= + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)= + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)= + _LT_AC_TAGVAR(thread_safe_flag_spec, $1)= + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)= + _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)= + _LT_AC_TAGVAR(hardcode_direct, $1)=no + _LT_AC_TAGVAR(hardcode_minus_L, $1)=no + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported + _LT_AC_TAGVAR(link_all_deplibs, $1)=unknown + _LT_AC_TAGVAR(hardcode_automatic, $1)=no + _LT_AC_TAGVAR(module_cmds, $1)= + _LT_AC_TAGVAR(module_expsym_cmds, $1)= + _LT_AC_TAGVAR(always_export_symbols, $1)=no + _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + # include_expsyms should be a list of space-separated symbols to be *always* + # included in the symbol list + _LT_AC_TAGVAR(include_expsyms, $1)= + # exclude_expsyms can be an extended regexp of symbols to exclude + # it will be wrapped by ` (' and `)$', so one must not match beginning or + # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', + # as well as any symbol that contains `d'. + _LT_AC_TAGVAR(exclude_expsyms, $1)="_GLOBAL_OFFSET_TABLE_" + # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out + # platforms (ab)use it in PIC code, but their linkers get confused if + # the symbol is explicitly referenced. Since portable code cannot + # rely on this symbol name, it's probably fine to never include it in + # preloaded symbol tables. + extract_expsyms_cmds= + + case $host_os in + cygwin* | mingw* | pw32*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + if test "$GCC" != yes; then + with_gnu_ld=no + fi + ;; + openbsd*) + with_gnu_ld=no + ;; + esac + + _LT_AC_TAGVAR(ld_shlibs, $1)=yes + if test "$with_gnu_ld" = yes; then + # If archive_cmds runs LD, not CC, wlarc should be empty + wlarc='${wl}' + + # See if GNU ld supports shared libraries. + case $host_os in + aix3* | aix4* | aix5*) + # On AIX/PPC, the GNU linker is very broken + if test "$host_cpu" != ia64; then + _LT_AC_TAGVAR(ld_shlibs, $1)=no + cat <&2 + +*** Warning: the GNU linker, at least up to release 2.9.1, is reported +*** to be unable to reliably create shared libraries on AIX. +*** Therefore, libtool is disabling shared libraries support. If you +*** really care for shared libraries, you may want to modify your PATH +*** so that a non-GNU linker is found, and then restart. + +EOF + fi + ;; + + amigaos*) + _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + + # Samuel A. Falvo II reports + # that the semantics of dynamic libraries on AmigaOS, at least up + # to version 4, is to share data among multiple programs linked + # with the same dynamic library. Since this doesn't match the + # behavior of shared libraries on other platforms, we can't use + # them. + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + + beos*) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + else + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + cygwin* | mingw* | pw32*) + # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, + # as there is no search path for DLLs. + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_AC_TAGVAR(always_export_symbols, $1)=no + _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGS]] /s/.* \([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols' + + if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib' + # If the export-symbols file already is a .def file (1st line + # is EXPORTS), use it as is; otherwise, prepend... + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib' + else + ld_shlibs=no + fi + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' + wlarc= + else + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + fi + ;; + + solaris* | sysv5*) + if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then + _LT_AC_TAGVAR(ld_shlibs, $1)=no + cat <&2 + +*** Warning: The releases 2.8.* of the GNU linker cannot reliably +*** create shared libraries on Solaris systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.9.1 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +EOF + elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + sunos4*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' + wlarc= + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + linux*) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + tmp_archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_cmds, $1)="$tmp_archive_cmds" + supports_anon_versioning=no + case `$LD -v 2>/dev/null` in + *\ [01].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11 + *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... + *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... + *\ 2.11.*) ;; # other 2.11 versions + *) supports_anon_versioning=yes ;; + esac + if test $supports_anon_versioning = yes; then + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $output_objdir/$libname.ver~ +cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ +$echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' + else + _LT_AC_TAGVAR(archive_expsym_cmds, $1)="$tmp_archive_cmds" + fi + else + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + *) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + + if test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = yes; then + runpath_var=LD_RUN_PATH + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + # ancient GNU ld didn't support --whole-archive et. al. + if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)= + fi + fi + else + # PORTME fill in a description of your system's linker (not GNU ld) + case $host_os in + aix3*) + _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_AC_TAGVAR(always_export_symbols, $1)=yes + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + if test "$GCC" = yes && test -z "$link_static_flag"; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported + fi + ;; + + aix4* | aix5*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag="" + else + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to AIX nm, but means don't demangle with GNU nm + if $NM -V 2>&1 | grep 'GNU' > /dev/null; then + _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols' + else + _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols' + fi + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*) + for ld_flag in $LDFLAGS; do + if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then + aix_use_runtimelinking=yes + break + fi + done + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + _LT_AC_TAGVAR(archive_cmds, $1)='' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + + if test "$GCC" = yes; then + case $host_os in aix4.[012]|aix4.[012].*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && \ + strings "$collect2name" | grep resolve_lib_name >/dev/null + then + # We have reworked collect2 + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + else + # We have old collect2 + _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)= + fi + esac + shared_flag='-shared' + else + # not using gcc + if test "$host_cpu" = ia64; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test "$aix_use_runtimelinking" = yes; then + shared_flag='${wl}-G' + else + shared_flag='${wl}-bM:SRE' + fi + fi + fi + + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to export. + _LT_AC_TAGVAR(always_export_symbols, $1)=yes + if test "$aix_use_runtimelinking" = yes; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + _LT_AC_TAGVAR(allow_undefined_flag, $1)='-berok' + # Determine the default libpath from the value encoded in an empty executable. + _LT_AC_SYS_LIBPATH_AIX + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" + _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag" + else + if test "$host_cpu" = ia64; then + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' + _LT_AC_TAGVAR(allow_undefined_flag, $1)="-z nodefs" + _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an empty executable. + _LT_AC_SYS_LIBPATH_AIX + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' + # -bexpall does not export symbols beginning with underscore (_) + _LT_AC_TAGVAR(always_export_symbols, $1)=yes + # Exported symbols can be pulled into shared objects from archives + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=' ' + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes + # This is similar to how AIX traditionally builds it's shared libraries. + _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' + fi + fi + ;; + + amigaos*) + _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + # see comment about different semantics on the GNU ld section + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + + bsdi4*) + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic + ;; + + cygwin* | mingw* | pw32*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' + _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=".dll" + # FIXME: Setting linknames here is a bad hack. + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames=' + # The linker will automatically build a .lib file if we build a DLL. + _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)='true' + # FIXME: Should let the user specify the lib program. + _LT_AC_TAGVAR(old_archive_cmds, $1)='lib /OUT:$oldlib$oldobjs$old_deplibs' + fix_srcfile_path='`cygpath -w "$srcfile"`' + _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + ;; + + darwin* | rhapsody*) + if test "$GXX" = yes ; then + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no + case "$host_os" in + rhapsody* | darwin1.[[012]]) + _LT_AC_TAGVAR(allow_undefined_flag, $1)='-undefined suppress' + ;; + *) # Darwin 1.3 on + if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then + _LT_AC_TAGVAR(allow_undefined_flag, $1)='-flat_namespace -undefined suppress' + else + case ${MACOSX_DEPLOYMENT_TARGET} in + 10.[[012]]) + _LT_AC_TAGVAR(allow_undefined_flag, $1)='-flat_namespace -undefined suppress' + ;; + 10.*) + _LT_AC_TAGVAR(allow_undefined_flag, $1)='-undefined dynamic_lookup' + ;; + esac + fi + ;; + esac + lt_int_apple_cc_single_mod=no + output_verbose_link_cmd='echo' + if $CC -dumpspecs 2>&1 | grep 'single_module' >/dev/null ; then + lt_int_apple_cc_single_mod=yes + fi + if test "X$lt_int_apple_cc_single_mod" = Xyes ; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring' + else + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -r ${wl}-bind_at_load -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring' + fi + _LT_AC_TAGVAR(module_cmds, $1)='$CC ${wl}-bind_at_load $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' + # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's + if test "X$lt_int_apple_cc_single_mod" = Xyes ; then + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + else + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r ${wl}-bind_at_load -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + fi + _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + _LT_AC_TAGVAR(hardcode_direct, $1)=no + _LT_AC_TAGVAR(hardcode_automatic, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-all_load $convenience' + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + else + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + dgux*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + freebsd1*) + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + + # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor + # support. Future versions do this automatically, but an explicit c++rt0.o + # does not break anything, and helps significantly (at the cost of a little + # extra space). + freebsd2.2*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + # Unfortunately, older versions of FreeBSD 2 do not have this feature. + freebsd2*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + # FreeBSD 3 and greater uses gcc -shared to do shared libraries. + freebsd* | kfreebsd*-gnu) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + hpux9*) + if test "$GCC" = yes; then + _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + else + _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + fi + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + ;; + + hpux10* | hpux11*) + if test "$GCC" = yes -a "$with_gnu_ld" = no; then + case "$host_cpu" in + hppa*64*|ia64*) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + else + case "$host_cpu" in + hppa*64*|ia64*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname -o $lib $libobjs $deplibs $linker_flags' + ;; + *) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' + ;; + esac + fi + if test "$with_gnu_ld" = no; then + case "$host_cpu" in + hppa*64*) + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_AC_TAGVAR(hardcode_direct, $1)=no + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + ia64*) + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(hardcode_direct, $1)=no + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + ;; + *) + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + ;; + esac + fi + ;; + + irix5* | irix6* | nonstopux*) + if test "$GCC" = yes; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir' + fi + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out + else + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF + fi + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + newsos6) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + openbsd*) + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + else + case $host_os in + openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + ;; + *) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + ;; + esac + fi + ;; + + os2*) + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_AC_TAGVAR(archive_cmds, $1)='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' + _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' + ;; + + osf3*) + if test "$GCC" = yes; then + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + fi + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + ;; + + osf4* | osf5*) # as osf3* with the addition of -msym flag + if test "$GCC" = yes; then + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + else + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~ + $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib~$rm $lib.exp' + + # Both c and cxx compiler support -rpath directly + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' + fi + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + ;; + + sco3.2v5*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + ;; + + solaris*) + _LT_AC_TAGVAR(no_undefined_flag, $1)=' -z text' + if test "$GCC" = yes; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp' + else + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' + fi + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + case $host_os in + solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; + *) # Supported since Solaris 2.6 (maybe 2.5.1?) + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' ;; + esac + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + ;; + + sunos4*) + if test "x$host_vendor" = xsequent; then + # Use $CC to link under sequent, because it throws in some extra .o + # files that make .init and .fini sections work. + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' + fi + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + sysv4) + case $host_vendor in + sni) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes # is this really true??? + ;; + siemens) + ## LD is ld it makes a PLAMLIB + ## CC just makes a GrossModule. + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs' + _LT_AC_TAGVAR(hardcode_direct, $1)=no + ;; + motorola) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie + ;; + esac + runpath_var='LD_RUN_PATH' + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + sysv4.3*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + _LT_AC_TAGVAR(ld_shlibs, $1)=yes + fi + ;; + + sysv4.2uw2*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_minus_L, $1)=no + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + hardcode_runpath_var=yes + runpath_var=LD_RUN_PATH + ;; + + sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[[78]]* | unixware7*) + _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z ${wl}text' + if test "$GCC" = yes; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + runpath_var='LD_RUN_PATH' + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + sysv5*) + _LT_AC_TAGVAR(no_undefined_flag, $1)=' -z text' + # $CC -shared without GNU ld will not create a library from C++ + # object files and a static libstdc++, better avoid it by now + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)= + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + runpath_var='LD_RUN_PATH' + ;; + + uts4*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + *) + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + esac + fi +]) +AC_MSG_RESULT([$_LT_AC_TAGVAR(ld_shlibs, $1)]) +test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no + +variables_saved_for_relink="PATH $shlibpath_var $runpath_var" +if test "$GCC" = yes; then + variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" +fi + +# +# Do we need to explicitly link libc? +# +case "x$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)" in +x|xyes) + # Assume -lc should be added + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes + + if test "$enable_shared" = yes && test "$GCC" = yes; then + case $_LT_AC_TAGVAR(archive_cmds, $1) in + *'~'*) + # FIXME: we may have to deal with multi-command sequences. + ;; + '$CC '*) + # Test whether the compiler implicitly links with -lc since on some + # systems, -lgcc has to come before -lc. If gcc already passes -lc + # to ld, don't add -lc before -lgcc. + AC_MSG_CHECKING([whether -lc should be explicitly linked in]) + $rm conftest* + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + + if AC_TRY_EVAL(ac_compile) 2>conftest.err; then + soname=conftest + lib=conftest + libobjs=conftest.$ac_objext + deplibs= + wl=$_LT_AC_TAGVAR(lt_prog_compiler_wl, $1) + compiler_flags=-v + linker_flags=-v + verstring= + output_objdir=. + libname=conftest + lt_save_allow_undefined_flag=$_LT_AC_TAGVAR(allow_undefined_flag, $1) + _LT_AC_TAGVAR(allow_undefined_flag, $1)= + if AC_TRY_EVAL(_LT_AC_TAGVAR(archive_cmds, $1) 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) + then + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no + else + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes + fi + _LT_AC_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag + else + cat conftest.err 1>&5 + fi + $rm conftest* + AC_MSG_RESULT([$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)]) + ;; + esac + fi + ;; +esac +])# AC_LIBTOOL_PROG_LD_SHLIBS + + +# _LT_AC_FILE_LTDLL_C +# ------------------- +# Be careful that the start marker always follows a newline. +AC_DEFUN([_LT_AC_FILE_LTDLL_C], [ +# /* ltdll.c starts here */ +# #define WIN32_LEAN_AND_MEAN +# #include +# #undef WIN32_LEAN_AND_MEAN +# #include +# +# #ifndef __CYGWIN__ +# # ifdef __CYGWIN32__ +# # define __CYGWIN__ __CYGWIN32__ +# # endif +# #endif +# +# #ifdef __cplusplus +# extern "C" { +# #endif +# BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved); +# #ifdef __cplusplus +# } +# #endif +# +# #ifdef __CYGWIN__ +# #include +# DECLARE_CYGWIN_DLL( DllMain ); +# #endif +# HINSTANCE __hDllInstance_base; +# +# BOOL APIENTRY +# DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved) +# { +# __hDllInstance_base = hInst; +# return TRUE; +# } +# /* ltdll.c ends here */ +])# _LT_AC_FILE_LTDLL_C + + +# _LT_AC_TAGVAR(VARNAME, [TAGNAME]) +# --------------------------------- +AC_DEFUN([_LT_AC_TAGVAR], [ifelse([$2], [], [$1], [$1_$2])]) + + +# old names +AC_DEFUN([AM_PROG_LIBTOOL], [AC_PROG_LIBTOOL]) +AC_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) +AC_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) +AC_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) +AC_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) +AC_DEFUN([AM_PROG_LD], [AC_PROG_LD]) +AC_DEFUN([AM_PROG_NM], [AC_PROG_NM]) + +# This is just to silence aclocal about the macro not being used +ifelse([AC_DISABLE_FAST_INSTALL]) + +AC_DEFUN([LT_AC_PROG_GCJ], +[AC_CHECK_TOOL(GCJ, gcj, no) + test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2" + AC_SUBST(GCJFLAGS) +]) + +AC_DEFUN([LT_AC_PROG_RC], +[AC_CHECK_TOOL(RC, windres, no) +]) + +# NOTE: This macro has been submitted for inclusion into # +# GNU Autoconf as AC_PROG_SED. When it is available in # +# a released version of Autoconf we should remove this # +# macro and use it instead. # +# LT_AC_PROG_SED +# -------------- +# Check for a fully-functional sed program, that truncates +# as few characters as possible. Prefer GNU sed if found. +AC_DEFUN([LT_AC_PROG_SED], +[AC_MSG_CHECKING([for a sed that does not truncate output]) +AC_CACHE_VAL(lt_cv_path_SED, +[# Loop through the user's path and test for sed and gsed. +# Then use that list of sed's as ones to test for truncation. +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for lt_ac_prog in sed gsed; do + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then + lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" + fi + done + done +done +lt_ac_max=0 +lt_ac_count=0 +# Add /usr/xpg4/bin/sed as it is typically found on Solaris +# along with /bin/sed that truncates output. +for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do + test ! -f $lt_ac_sed && break + cat /dev/null > conftest.in + lt_ac_count=0 + echo $ECHO_N "0123456789$ECHO_C" >conftest.in + # Check for GNU sed and select it if it is found. + if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then + lt_cv_path_SED=$lt_ac_sed + break + fi + while true; do + cat conftest.in conftest.in >conftest.tmp + mv conftest.tmp conftest.in + cp conftest.in conftest.nl + echo >>conftest.nl + $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break + cmp -s conftest.out conftest.nl || break + # 10000 chars as input seems more than enough + test $lt_ac_count -gt 10 && break + lt_ac_count=`expr $lt_ac_count + 1` + if test $lt_ac_count -gt $lt_ac_max; then + lt_ac_max=$lt_ac_count + lt_cv_path_SED=$lt_ac_sed + fi + done +done +SED=$lt_cv_path_SED +]) +AC_MSG_RESULT([$SED]) +]) + diff --git a/ase/ase.dsw b/ase/ase.dsw new file mode 100644 index 00000000..5565d7d0 --- /dev/null +++ b/ase/ase.dsw @@ -0,0 +1,113 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "asecmn"=.\cmn\asecmn.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "aseutl"=.\utl\aseutl.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "aseawk"=.\awk\aseawk.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "aseawk_jni"=.\awk\aseawk_jni.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "asecom"=.\com\asecom.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "asetestawk"=.\test\awk\asetestawk.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "aselsp"=.\lsp\aselsp.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "asetestlsp"=.\test\lsp\asetestlsp.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/ase/ase.sln b/ase/ase.sln new file mode 100644 index 00000000..846f5846 --- /dev/null +++ b/ase/ase.sln @@ -0,0 +1,175 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "asecmn", "cmn\asecmn.vcproj", "{17621C83-40C9-4305-BAF9-132E250B5FE3}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aseutl", "utl\aseutl.vcproj", "{C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aseawk", "awk\aseawk.vcproj", "{5F2E77D5-1485-48D1-9371-987BC55FEE83}" + ProjectSection(ProjectDependencies) = postProject + {17621C83-40C9-4305-BAF9-132E250B5FE3} = {17621C83-40C9-4305-BAF9-132E250B5FE3} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aesawk_jni", "awk\aseawk_jni.vcproj", "{23B58791-FD44-4F95-9F77-34E4AF45A296}" + ProjectSection(ProjectDependencies) = postProject + {5F2E77D5-1485-48D1-9371-987BC55FEE83} = {5F2E77D5-1485-48D1-9371-987BC55FEE83} + {17621C83-40C9-4305-BAF9-132E250B5FE3} = {17621C83-40C9-4305-BAF9-132E250B5FE3} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "asecom", "com\asecom.vcproj", "{963AF7B5-12E6-42B6-8CBE-89136C1A109B}" + ProjectSection(ProjectDependencies) = postProject + {5F2E77D5-1485-48D1-9371-987BC55FEE83} = {5F2E77D5-1485-48D1-9371-987BC55FEE83} + {C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD} = {C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "asetestawk", "test\awk\asetestawk.vcproj", "{57F1E1D0-28B6-42BF-BAFB-045AEE2DCF4F}" + ProjectSection(ProjectDependencies) = postProject + {5F2E77D5-1485-48D1-9371-987BC55FEE83} = {5F2E77D5-1485-48D1-9371-987BC55FEE83} + {C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD} = {C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aselsp", "lsp\aselsp.vcproj", "{42FE7CED-34B7-45C8-92C9-8856E16640D2}" + ProjectSection(ProjectDependencies) = postProject + {17621C83-40C9-4305-BAF9-132E250B5FE3} = {17621C83-40C9-4305-BAF9-132E250B5FE3} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "asetestlsp", "test\lsp\asetestlsp.vcproj", "{868702B0-CB6B-4F1D-B98A-32193347EFAF}" + ProjectSection(ProjectDependencies) = postProject + {42FE7CED-34B7-45C8-92C9-8856E16640D2} = {42FE7CED-34B7-45C8-92C9-8856E16640D2} + {C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD} = {C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD} + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "asetestcnt", "test\cnt\asetestcnt.csproj", "{F14B75D8-3ED7-4621-B5B9-E96A80B5D809}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "asenet", "net\asenet.vcproj", "{4CBF0E86-D018-49D7-A6B8-0CDA698203F7}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "asecnt", "cnt\asecnt.csproj", "{7F679165-41FB-4E1E-B3F5-23C5EE94166A}" + ProjectSection(ProjectDependencies) = postProject + {963AF7B5-12E6-42B6-8CBE-89136C1A109B} = {963AF7B5-12E6-42B6-8CBE-89136C1A109B} + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|Mixed Platforms = Debug|Mixed Platforms + Debug|Win32 = Debug|Win32 + Release|Any CPU = Release|Any CPU + Release|Mixed Platforms = Release|Mixed Platforms + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {17621C83-40C9-4305-BAF9-132E250B5FE3}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {17621C83-40C9-4305-BAF9-132E250B5FE3}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {17621C83-40C9-4305-BAF9-132E250B5FE3}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {17621C83-40C9-4305-BAF9-132E250B5FE3}.Debug|Win32.ActiveCfg = Debug|Win32 + {17621C83-40C9-4305-BAF9-132E250B5FE3}.Debug|Win32.Build.0 = Debug|Win32 + {17621C83-40C9-4305-BAF9-132E250B5FE3}.Release|Any CPU.ActiveCfg = Release|Win32 + {17621C83-40C9-4305-BAF9-132E250B5FE3}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {17621C83-40C9-4305-BAF9-132E250B5FE3}.Release|Mixed Platforms.Build.0 = Release|Win32 + {17621C83-40C9-4305-BAF9-132E250B5FE3}.Release|Win32.ActiveCfg = Release|Win32 + {17621C83-40C9-4305-BAF9-132E250B5FE3}.Release|Win32.Build.0 = Release|Win32 + {C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD}.Debug|Win32.ActiveCfg = Debug|Win32 + {C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD}.Debug|Win32.Build.0 = Debug|Win32 + {C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD}.Release|Any CPU.ActiveCfg = Release|Win32 + {C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD}.Release|Mixed Platforms.Build.0 = Release|Win32 + {C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD}.Release|Win32.ActiveCfg = Release|Win32 + {C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD}.Release|Win32.Build.0 = Release|Win32 + {5F2E77D5-1485-48D1-9371-987BC55FEE83}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {5F2E77D5-1485-48D1-9371-987BC55FEE83}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {5F2E77D5-1485-48D1-9371-987BC55FEE83}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {5F2E77D5-1485-48D1-9371-987BC55FEE83}.Debug|Win32.ActiveCfg = Debug|Win32 + {5F2E77D5-1485-48D1-9371-987BC55FEE83}.Debug|Win32.Build.0 = Debug|Win32 + {5F2E77D5-1485-48D1-9371-987BC55FEE83}.Release|Any CPU.ActiveCfg = Release|Win32 + {5F2E77D5-1485-48D1-9371-987BC55FEE83}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {5F2E77D5-1485-48D1-9371-987BC55FEE83}.Release|Mixed Platforms.Build.0 = Release|Win32 + {5F2E77D5-1485-48D1-9371-987BC55FEE83}.Release|Win32.ActiveCfg = Release|Win32 + {5F2E77D5-1485-48D1-9371-987BC55FEE83}.Release|Win32.Build.0 = Release|Win32 + {23B58791-FD44-4F95-9F77-34E4AF45A296}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {23B58791-FD44-4F95-9F77-34E4AF45A296}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {23B58791-FD44-4F95-9F77-34E4AF45A296}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {23B58791-FD44-4F95-9F77-34E4AF45A296}.Debug|Win32.ActiveCfg = Debug|Win32 + {23B58791-FD44-4F95-9F77-34E4AF45A296}.Debug|Win32.Build.0 = Debug|Win32 + {23B58791-FD44-4F95-9F77-34E4AF45A296}.Release|Any CPU.ActiveCfg = Release|Win32 + {23B58791-FD44-4F95-9F77-34E4AF45A296}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {23B58791-FD44-4F95-9F77-34E4AF45A296}.Release|Mixed Platforms.Build.0 = Release|Win32 + {23B58791-FD44-4F95-9F77-34E4AF45A296}.Release|Win32.ActiveCfg = Release|Win32 + {23B58791-FD44-4F95-9F77-34E4AF45A296}.Release|Win32.Build.0 = Release|Win32 + {963AF7B5-12E6-42B6-8CBE-89136C1A109B}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {963AF7B5-12E6-42B6-8CBE-89136C1A109B}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {963AF7B5-12E6-42B6-8CBE-89136C1A109B}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {963AF7B5-12E6-42B6-8CBE-89136C1A109B}.Debug|Win32.ActiveCfg = Debug|Win32 + {963AF7B5-12E6-42B6-8CBE-89136C1A109B}.Debug|Win32.Build.0 = Debug|Win32 + {963AF7B5-12E6-42B6-8CBE-89136C1A109B}.Release|Any CPU.ActiveCfg = Release|Win32 + {963AF7B5-12E6-42B6-8CBE-89136C1A109B}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {963AF7B5-12E6-42B6-8CBE-89136C1A109B}.Release|Mixed Platforms.Build.0 = Release|Win32 + {963AF7B5-12E6-42B6-8CBE-89136C1A109B}.Release|Win32.ActiveCfg = Release|Win32 + {963AF7B5-12E6-42B6-8CBE-89136C1A109B}.Release|Win32.Build.0 = Release|Win32 + {57F1E1D0-28B6-42BF-BAFB-045AEE2DCF4F}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {57F1E1D0-28B6-42BF-BAFB-045AEE2DCF4F}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {57F1E1D0-28B6-42BF-BAFB-045AEE2DCF4F}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {57F1E1D0-28B6-42BF-BAFB-045AEE2DCF4F}.Debug|Win32.ActiveCfg = Debug|Win32 + {57F1E1D0-28B6-42BF-BAFB-045AEE2DCF4F}.Debug|Win32.Build.0 = Debug|Win32 + {57F1E1D0-28B6-42BF-BAFB-045AEE2DCF4F}.Release|Any CPU.ActiveCfg = Release|Win32 + {57F1E1D0-28B6-42BF-BAFB-045AEE2DCF4F}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {57F1E1D0-28B6-42BF-BAFB-045AEE2DCF4F}.Release|Mixed Platforms.Build.0 = Release|Win32 + {57F1E1D0-28B6-42BF-BAFB-045AEE2DCF4F}.Release|Win32.ActiveCfg = Release|Win32 + {57F1E1D0-28B6-42BF-BAFB-045AEE2DCF4F}.Release|Win32.Build.0 = Release|Win32 + {42FE7CED-34B7-45C8-92C9-8856E16640D2}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {42FE7CED-34B7-45C8-92C9-8856E16640D2}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {42FE7CED-34B7-45C8-92C9-8856E16640D2}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {42FE7CED-34B7-45C8-92C9-8856E16640D2}.Debug|Win32.ActiveCfg = Debug|Win32 + {42FE7CED-34B7-45C8-92C9-8856E16640D2}.Debug|Win32.Build.0 = Debug|Win32 + {42FE7CED-34B7-45C8-92C9-8856E16640D2}.Release|Any CPU.ActiveCfg = Release|Win32 + {42FE7CED-34B7-45C8-92C9-8856E16640D2}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {42FE7CED-34B7-45C8-92C9-8856E16640D2}.Release|Mixed Platforms.Build.0 = Release|Win32 + {42FE7CED-34B7-45C8-92C9-8856E16640D2}.Release|Win32.ActiveCfg = Release|Win32 + {42FE7CED-34B7-45C8-92C9-8856E16640D2}.Release|Win32.Build.0 = Release|Win32 + {868702B0-CB6B-4F1D-B98A-32193347EFAF}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {868702B0-CB6B-4F1D-B98A-32193347EFAF}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {868702B0-CB6B-4F1D-B98A-32193347EFAF}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {868702B0-CB6B-4F1D-B98A-32193347EFAF}.Debug|Win32.ActiveCfg = Debug|Win32 + {868702B0-CB6B-4F1D-B98A-32193347EFAF}.Debug|Win32.Build.0 = Debug|Win32 + {868702B0-CB6B-4F1D-B98A-32193347EFAF}.Release|Any CPU.ActiveCfg = Release|Win32 + {868702B0-CB6B-4F1D-B98A-32193347EFAF}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {868702B0-CB6B-4F1D-B98A-32193347EFAF}.Release|Mixed Platforms.Build.0 = Release|Win32 + {868702B0-CB6B-4F1D-B98A-32193347EFAF}.Release|Win32.ActiveCfg = Release|Win32 + {868702B0-CB6B-4F1D-B98A-32193347EFAF}.Release|Win32.Build.0 = Release|Win32 + {F14B75D8-3ED7-4621-B5B9-E96A80B5D809}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F14B75D8-3ED7-4621-B5B9-E96A80B5D809}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F14B75D8-3ED7-4621-B5B9-E96A80B5D809}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {F14B75D8-3ED7-4621-B5B9-E96A80B5D809}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {F14B75D8-3ED7-4621-B5B9-E96A80B5D809}.Debug|Win32.ActiveCfg = Debug|Any CPU + {F14B75D8-3ED7-4621-B5B9-E96A80B5D809}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F14B75D8-3ED7-4621-B5B9-E96A80B5D809}.Release|Any CPU.Build.0 = Release|Any CPU + {F14B75D8-3ED7-4621-B5B9-E96A80B5D809}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {F14B75D8-3ED7-4621-B5B9-E96A80B5D809}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {F14B75D8-3ED7-4621-B5B9-E96A80B5D809}.Release|Win32.ActiveCfg = Release|Any CPU + {4CBF0E86-D018-49D7-A6B8-0CDA698203F7}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {4CBF0E86-D018-49D7-A6B8-0CDA698203F7}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {4CBF0E86-D018-49D7-A6B8-0CDA698203F7}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {4CBF0E86-D018-49D7-A6B8-0CDA698203F7}.Debug|Win32.ActiveCfg = Debug|Win32 + {4CBF0E86-D018-49D7-A6B8-0CDA698203F7}.Debug|Win32.Build.0 = Debug|Win32 + {4CBF0E86-D018-49D7-A6B8-0CDA698203F7}.Release|Any CPU.ActiveCfg = Release|Win32 + {4CBF0E86-D018-49D7-A6B8-0CDA698203F7}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {4CBF0E86-D018-49D7-A6B8-0CDA698203F7}.Release|Mixed Platforms.Build.0 = Release|Win32 + {4CBF0E86-D018-49D7-A6B8-0CDA698203F7}.Release|Win32.ActiveCfg = Release|Win32 + {4CBF0E86-D018-49D7-A6B8-0CDA698203F7}.Release|Win32.Build.0 = Release|Win32 + {7F679165-41FB-4E1E-B3F5-23C5EE94166A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7F679165-41FB-4E1E-B3F5-23C5EE94166A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7F679165-41FB-4E1E-B3F5-23C5EE94166A}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {7F679165-41FB-4E1E-B3F5-23C5EE94166A}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {7F679165-41FB-4E1E-B3F5-23C5EE94166A}.Debug|Win32.ActiveCfg = Debug|Any CPU + {7F679165-41FB-4E1E-B3F5-23C5EE94166A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7F679165-41FB-4E1E-B3F5-23C5EE94166A}.Release|Any CPU.Build.0 = Release|Any CPU + {7F679165-41FB-4E1E-B3F5-23C5EE94166A}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {7F679165-41FB-4E1E-B3F5-23C5EE94166A}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {7F679165-41FB-4E1E-B3F5-23C5EE94166A}.Release|Win32.ActiveCfg = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/ase/awk/Awk.cpp b/ase/awk/Awk.cpp new file mode 100644 index 00000000..20ed9397 --- /dev/null +++ b/ase/awk/Awk.cpp @@ -0,0 +1,35 @@ +/* + * $Id: Awk.cpp,v 1.1 2007/04/30 05:47:33 bacon Exp $ + */ + +#include + +namespace ASE +{ + + Awk::Awk (): awk (ASE_NULL) + { + } + + Awk::~Awk () + { + if (awk != ASE_NULL) + { + ase_awk_close (awk); + awk = ASE_NULL; + } + } + + int Awk::parse () + { + return ase_awk_parse (awk, ASE_NULL); + } + + int Awk::run (/*const ase_char_t* main*/) + { + //return ase_awk_parse (awk, main); + return 0; + } + +} + diff --git a/ase/awk/Awk.hpp b/ase/awk/Awk.hpp new file mode 100644 index 00000000..ee2ddd70 --- /dev/null +++ b/ase/awk/Awk.hpp @@ -0,0 +1,28 @@ +/* + * $Id: Awk.hpp,v 1.1 2007/04/30 05:47:33 bacon Exp $ + */ + +#ifndef _ASE_AWK_AWK_HPP_ +#define _ASE_AWK_AWK_HPP_ + +#include + +namespace ASE +{ + + class Awk + { + public: + Awk (); + ~Awk (); + + int parse (); + int run (); + + private: + ase_awk_t* awk; + }; + +} + +#endif diff --git a/ase/awk/Awk.java b/ase/awk/Awk.java new file mode 100644 index 00000000..285a94bd --- /dev/null +++ b/ase/awk/Awk.java @@ -0,0 +1,346 @@ +/* + * $Id: Awk.java,v 1.3 2007/04/30 05:47:33 bacon Exp $ + * + * {License} + */ + +package ase.awk; + +public abstract class Awk +{ + // mode for open_source & close_source + public static final int SOURCE_READ = 1; + public static final int SOURCE_WRITE = 2; + + // depth id + public static final int DEPTH_BLOCK_PARSE = (1 << 0); + public static final int DEPTH_BLOCK_RUN = (1 << 1); + public static final int DEPTH_EXPR_PARSE = (1 << 2); + public static final int DEPTH_EXPR_RUN = (1 << 3); + public static final int DEPTH_REX_BUILD = (1 << 4); + public static final int DEPTH_REX_MATCH = (1 << 5); + + // options + public static final int OPTION_IMPLICIT = (1 << 0); + public static final int OPTION_EXPLICIT = (1 << 1); + public static final int OPTION_UNIQUEFN = (1 << 2); + public static final int OPTION_SHADING = (1 << 3); + public static final int OPTION_SHIFT = (1 << 4); + public static final int OPTION_IDIV = (1 << 5); + public static final int OPTION_STRCONCAT = (1 << 6); + public static final int OPTION_EXTIO = (1 << 7); + public static final int OPTION_COPROC = (1 << 8); + public static final int OPTION_BLOCKLESS = (1 << 9); + public static final int OPTION_STRBASEONE = (1 << 10); + public static final int OPTION_STRIPSPACES = (1 << 11); + public static final int OPTION_NEXTOFILE = (1 << 12); + public static final int OPTION_CRLF = (1 << 13); + public static final int OPTION_ARGSTOMAIN = (1 << 14); + + private long handle; + + public Awk () throws Exception + { + this.handle = 0; + + open (); + } + + /* == just in case == */ + protected void finalize () throws Throwable + { + super.finalize (); + if (handle != 0) close (); + } + + /* == native methods == */ + private native void open () throws Exception; + public native void close (); + public native void parse () throws Exception; + public native void run (String main, String[] args) throws Exception; + + private native int getmaxdepth (int id); + private native void setmaxdepth (int id, int depth); + + private native int getoption (); + private native void setoption (int opt); + + private native boolean getdebug (); + private native void setdebug (boolean debug); + + private native void addbfn ( + String name, int min_args, int max_args) throws Exception; + private native void delbfn (String name) throws Exception; + + private native void setfilename ( + long runid, String name) throws Exception; + private native void setofilename ( + long runid, String name) throws Exception; + + private native Object strtonum ( + long runid, String str) throws Exception; + private native String valtostr ( + long runid, Object obj) throws Exception; + + /* == simpler run methods == */ + public void run (String main) throws Exception + { + run (main, null); + } + + public void run (String[] args) throws Exception + { + run (null, args); + } + + public void run () throws Exception + { + run (null, null); + } + + /* == builtin functions == */ + public void addBuiltinFunction ( + String name, int min_args, int max_args) throws Exception + { + addbfn (name, min_args, max_args); + } + + public void deleteBuiltinFunction (String name) throws Exception + { + delbfn (name); + } + + protected long builtinFunctionArgumentToLong ( + long runid, Object obj) throws Exception + { + long n; + + if (obj == null) n = 0; + else + { + if (obj instanceof String) + obj = strtonum (runid, (String)obj); + + if (obj instanceof Long) + { + n = ((Long)obj).longValue (); + } + else if (obj instanceof Double) + { + n = ((Double)obj).longValue (); + } + else if (obj instanceof Integer) + { + n = ((Integer)obj).longValue (); + } + else if (obj instanceof Short) + { + n = ((Short)obj).longValue (); + } + else if (obj instanceof Float) + { + n = ((Float)obj).longValue (); + } + else n = 0; + } + + return n; + } + + protected double builtinFunctionArgumentToDouble ( + long runid, Object obj) throws Exception + { + double n; + + if (obj == null) n = 0.0; + else + { + if (obj instanceof String) + obj = strtonum (runid, (String)obj); + + if (obj instanceof Long) + { + n = ((Long)obj).doubleValue (); + } + else if (obj instanceof Double) + { + n = ((Double)obj).doubleValue (); + } + else if (obj instanceof Integer) + { + n = ((Integer)obj).doubleValue (); + } + else if (obj instanceof Short) + { + n = ((Short)obj).doubleValue (); + } + else if (obj instanceof Float) + { + n = ((Float)obj).doubleValue (); + } + else n = 0.0; + } + + return n; + } + + protected String builtinFunctionArgumentToString ( + long runid, Object obj) throws Exception + { + String str; + + if (obj == null) str = ""; + else if (obj instanceof String) str = (String)obj; + else str = valtostr (runid, obj); + + return str; + } + + /* == console name setters == */ + protected void setConsoleInputName ( + Extio extio, String name) throws Exception + { + /* TODO: setfilename is not safe. for example, it can + * crash the program if runid is invalid. so this wrapper + * needs to do some sanity check. */ + setfilename (extio.getRunId(), name); + } + + protected void setConsoleOutputName ( + Extio extio, String name) throws Exception + { + setofilename (extio.getRunId(), name); + } + + /* == depth limiting == */ + public int getMaxDepth (int id) + { + return getmaxdepth (id); + } + + public void setMaxDepth (int ids, int depth) + { + setmaxdepth (ids, depth); + } + + /* == option == */ + public int getOption () + { + return getoption (); + } + + public void setOption (int opt) + { + setoption (opt); + } + + /* == debug == */ + public boolean getDebug () + { + return getdebug (); + } + + public void setDebug (boolean debug) + { + setdebug (debug); + } + + /* == source code management == */ + protected abstract int openSource (int mode); + protected abstract int closeSource (int mode); + protected abstract int readSource (char[] buf, int len); + protected abstract int writeSource (char[] buf, int len); + + /* == external io interface == */ + protected int openExtio (Extio extio) + { + int type = extio.getType (); + if (type == Extio.TYPE_CONSOLE) return openConsole (extio); + if (type == Extio.TYPE_FILE) return openFile (extio); + if (type == Extio.TYPE_PIPE) return openPipe (extio); + //if (type == Extio.TYPE_COPROC) return openCoproc (extio); + return -1; + } + + protected int closeExtio (Extio extio) + { + int type = extio.getType (); + if (type == Extio.TYPE_CONSOLE) return closeConsole (extio); + if (type == Extio.TYPE_FILE) return closeFile (extio); + if (type == Extio.TYPE_PIPE) return closePipe (extio); + //if (type == Extio.TYPE_COPROC) return closeCoproc (extio); + return -1; + } + + protected int readExtio (Extio extio, char[] buf, int len) + { + // this check is needed because 0 is used to indicate + // the end of the stream. java streams can return 0 + // if the data given is 0 bytes and it didn't reach + // the end of the stream. + if (len <= 0) return -1; + + int type = extio.getType (); + if (type == Extio.TYPE_CONSOLE) + return readConsole (extio, buf, len); + if (type == Extio.TYPE_FILE) + return readFile (extio, buf, len); + if (type == Extio.TYPE_PIPE) + return readPipe (extio, buf, len); + //if (type == Extio.TYPE_COPROC) + // return readCoproc (extio, buf, len); + return -1; + } + + protected int writeExtio (Extio extio, char[] buf, int len) + { + if (len <= 0) return -1; + + int type = extio.getType (); + if (type == Extio.TYPE_CONSOLE) + return writeConsole (extio, buf, len); + if (type == Extio.TYPE_FILE) + return writeFile (extio, buf, len); + if (type == Extio.TYPE_PIPE) + return writePipe (extio, buf, len); + //if (type == Extio.TYPE_COPROC) + // return writeCoproc (extio, buf, len); + return -1; + } + + protected int flushExtio (Extio extio) + { + int type = extio.getType (); + if (type == Extio.TYPE_CONSOLE) return flushConsole (extio); + if (type == Extio.TYPE_FILE) return flushFile (extio); + if (type == Extio.TYPE_PIPE) return flushPipe (extio); + //if (type == Extio.TYPE_COPROC) return flushCoproc (extio); + return -1; + } + + protected int nextExtio (Extio extio) + { + int type = extio.getType (); + if (type == Extio.TYPE_CONSOLE) return nextConsole (extio); + return -1; + } + + protected abstract int openConsole (Extio extio); + protected abstract int closeConsole (Extio extio); + protected abstract int readConsole (Extio extio, char[] buf, int len); + protected abstract int writeConsole (Extio extio, char[] buf, int len); + protected abstract int flushConsole (Extio extio); + protected abstract int nextConsole (Extio extio); + + protected abstract int openFile (Extio extio); + protected abstract int closeFile (Extio extio); + protected abstract int readFile (Extio extio, char[] buf, int len); + protected abstract int writeFile (Extio extio, char[] buf, int len); + protected abstract int flushFile (Extio extio); + + protected abstract int openPipe (Extio extio); + protected abstract int closePipe (Extio extio); + protected abstract int readPipe (Extio extio, char[] buf, int len); + protected abstract int writePipe (Extio extio, char[] buf, int len); + protected abstract int flushPipe (Extio extio); +} diff --git a/ase/awk/Exception.java b/ase/awk/Exception.java new file mode 100644 index 00000000..f63c627f --- /dev/null +++ b/ase/awk/Exception.java @@ -0,0 +1,51 @@ +/* + * $Id: Exception.java,v 1.3 2007/04/30 05:47:33 bacon Exp $ + * + * {License} + */ + +package ase.awk; + +public class Exception extends java.lang.Exception +{ + private int code; + private int line; + + public Exception () + { + super (); + this.code = 0; + this.line = 0; + } + + public Exception (String msg) + { + super (msg); + this.code = 0; + this.line = 0; + } + + public Exception (String msg, int code) + { + super (msg); + this.code = code; + this.line = 0; + } + + public Exception (String msg, int code, int line) + { + super (msg); + this.code = code; + this.line = line; + } + + public int getCode () + { + return this.code; + } + + public int getLine () + { + return this.line; + } +} diff --git a/ase/awk/Extio.java b/ase/awk/Extio.java new file mode 100644 index 00000000..165c3a49 --- /dev/null +++ b/ase/awk/Extio.java @@ -0,0 +1,75 @@ +/* + * $Id: Extio.java,v 1.3 2007/04/30 05:47:33 bacon Exp $ + * + * {License} + */ + +package ase.awk; + +public class Extio +{ + public static final int TYPE_PIPE = 0; + public static final int TYPE_COPROC = 1; + public static final int TYPE_FILE = 2; + public static final int TYPE_CONSOLE = 3; + + public static final int MODE_PIPE_READ = 0; + public static final int MODE_PIPE_WRITE = 1; + + public static final int MODE_FILE_READ = 0; + public static final int MODE_FILE_WRITE = 1; + public static final int MODE_FILE_APPEND = 2; + + public static final int MODE_CONSOLE_READ = 0; + public static final int MODE_CONSOLE_WRITE = 1; + + private String name; + private int type; + private int mode; + private long run_id; + private Object handle; + + protected Extio (String name, int type, int mode, long run_id) + { + this.name = name; + this.type = type; + this.mode = mode; + this.run_id = run_id; + this.handle = null; + } + + public String getName () + { + return this.name; + } + + public int getType () + { + return this.type; + } + + public int getMode () + { + return this.mode; + } + + public long getRunId () + { + return this.run_id; + } + + public void setHandle (Object handle) + { + this.handle = handle; + } + + public Object getHandle () + { + return this.handle; + } + + protected void finalize () throws Throwable + { + super.finalize (); + } +}; diff --git a/ase/awk/StdAwk.java b/ase/awk/StdAwk.java new file mode 100644 index 00000000..dd06a6cc --- /dev/null +++ b/ase/awk/StdAwk.java @@ -0,0 +1,865 @@ +/* + * $Id: StdAwk.java,v 1.3 2007/04/30 05:47:33 bacon Exp $ + * + * {License} + */ + +package ase.awk; + +import java.io.*; + +public abstract class StdAwk extends Awk +{ + private Reader src_in = null; + private Writer src_out = null; + + private String[] sin = null; + private int sin_no = 0; + + private String[] sout = null; + private int sout_no = 0; + + private String[] cin = null; + private int cin_no = 0; + private String[] cout = null; + private int cout_no = 0; + + private long seed; + private java.util.Random random; + + private final static Reader stdin = + new BufferedReader (new InputStreamReader (System.in)); + + private final static Writer stdout = + new BufferedWriter (new OutputStreamWriter (System.out)); + + /* + static + { + stdin = new BufferedReader ( + new InputStreamReader (System.in)); + stdout = new BufferedWriter ( + new OutputStreamWriter (System.out)); + } + */ + + public StdAwk () throws Exception + { + super (); + + seed = System.currentTimeMillis(); + random = new java.util.Random (seed); + + addBuiltinFunction ("sin", 1, 1); + addBuiltinFunction ("cos", 1, 1); + addBuiltinFunction ("tan", 1, 1); + addBuiltinFunction ("atan2", 1, 1); + addBuiltinFunction ("log", 1, 1); + addBuiltinFunction ("exp", 1, 1); + addBuiltinFunction ("sqrt", 1, 1); + addBuiltinFunction ("int", 1, 1); + + addBuiltinFunction ("srand", 0, 1); + addBuiltinFunction ("rand", 0, 0); + + addBuiltinFunction ("systime", 0, 0); + addBuiltinFunction ("strftime", 0, Integer.MAX_VALUE); + + addBuiltinFunction ("system", 1, 1); + } + + /* == major methods == */ + public void parse () throws Exception + { + sin = sourceInputNames (); sin_no = 0; + sout = sourceOutputNames (); sout_no = 0; + super.parse (); + } + + public void run (String main, String[] args) throws Exception + { + cin = consoleInputNames (); cin_no = 0; + cout = consoleOutputNames (); cout_no = 0; + super.run (main, args); + } + + public void run (String main) throws Exception + { + run (main, null); + } + + public void run (String[] args) throws Exception + { + run (null, args); + } + + public void run () throws Exception + { + run (null, null); + } + + + /* == source code names == */ + protected String[] sourceInputNames () { return null; } + protected String[] sourceOutputNames () { return null; } + + /* == console names == */ + protected String[] consoleInputNames () { return null; } + protected String[] consoleOutputNames () { return null; } + + /* == source code == */ + protected int openSource (int mode) + { + if (mode == SOURCE_READ) + { + Reader isr; + sin_no = 0; + + if (sin == null || sin_no >= sin.length) return 0; + + isr = get_stream_reader (sin[sin_no]); + if (isr == null) return -1; + + src_in = isr; + sin_no++; + return 1; + } + else if (mode == SOURCE_WRITE) + { + Writer osw; + sout_no = 0; + + // when sout is null, the source output is treated + // as if the operation has been successful with + // the writeSource and closeSource method. + if (sout == null) return 1; + if (sout_no >= sin.length) return 0; + + osw = get_stream_writer (sout[sout_no]); + if (osw == null) return -1; + + src_out = osw; + sout_no++; + return 1; + } + + return -1; + } + + protected int closeSource (int mode) + { + if (mode == SOURCE_READ) + { + if (src_in != StdAwk.stdin) + { + try { src_in.close (); } + catch (IOException e) { return -1; } + } + return 0; + } + else if (mode == SOURCE_WRITE) + { + if (src_out == null) return 0; + + if (src_out != StdAwk.stdout) + { + try { src_out.close (); } + catch (IOException e) { return -1; } + } + return 0; + } + + return -1; + } + + protected int readSource (char[] buf, int len) + { + try { + int n = src_in.read (buf, 0, len); + while (n == -1) + { + Reader isr; + if (sin == null || sin_no >= sin.length) return 0; + + isr = get_stream_reader (sin[sin_no]); + if (isr == null) return -1; + + if (src_in != StdAwk.stdin) + { + try { src_in.close (); } + catch (IOException ec) { /* ignore */ } + } + + src_in = isr; + sin_no++; + + n = src_in.read (buf, 0, len); + } + + return n; + } + catch (IOException e) + { + return -1; + } + } + + protected int writeSource (char[] buf, int len) + { + if (src_out == null) return len; + + // only the first file is used at the moment. + // this is because the write message doesn't indicate + // the end of the output stream. + try { src_out.write (buf, 0, len); } + catch (IOException e) { return -1; } + + return len; + } + + /* == console interface == */ + protected int openConsole (Extio extio) + { + //System.err.println ("[openConsole called.... name: " + extio.getName() + " mode: " + extio.getMode()); + + int mode = extio.getMode (); + + if (mode == Extio.MODE_CONSOLE_READ) + { + /*InputStream*/Reader isr; + cin_no = 0; + + if (cin == null || cin_no >= cin.length) return 0; + isr = get_stream_reader (cin[cin_no]); + if (isr == null) return -1; + + extio.setHandle (isr); + + try { setConsoleInputName (extio, cin[cin_no]); } + catch (Exception e) { return -1; } + + cin_no++; + return 1; + } + else if (mode == Extio.MODE_CONSOLE_WRITE) + { + Writer osw; + cout_no = 0; + + if (cout == null || cout_no >= cout.length) return 0; + + osw = get_stream_writer (cout[cout_no]); + if (osw == null) return -1; + + extio.setHandle (osw); + try { setConsoleOutputName (extio, cout[cout_no]); } + catch (Exception e) { return -1; } + + cout_no++; + return 1; + } + + return -1; + } + + protected int closeConsole (Extio extio) + { + //System.err.println ("[closeConsole called.... name: " + extio.getName() + " mode: " + extio.getMode()); + + int mode = extio.getMode (); + + if (mode == Extio.MODE_CONSOLE_READ) + { + Reader isr = (Reader)extio.getHandle (); + + if (isr != StdAwk.stdin) + { + try { isr.close (); } + catch (IOException e) { return -1; } + } + return 0; + } + else if (mode == Extio.MODE_CONSOLE_WRITE) + { + Writer osw = (Writer)extio.getHandle (); + /* TODO: selective close the stream... + * system.out should not be closed??? */ + + if (osw != StdAwk.stdout) + { + try { osw.close (); } + catch (IOException e) { return -1; } + } + return 0; + } + + return -1; + } + + protected int readConsole (Extio extio, char[] buf, int len) + { + int mode = extio.getMode (); + + if (mode == Extio.MODE_CONSOLE_READ) + { + Reader isr, tmp; + int n; + + isr = (Reader)extio.getHandle (); + + try { n = isr.read (buf, 0, len); } + catch (IOException e) { return -1; } + + while (n == -1) + { + if (cin == null || cin_no >= cin.length) return 0; + tmp = get_stream_reader (cin[cin_no]); + if (tmp == null) return -1; + + if (isr != StdAwk.stdin) + { + try { isr.close (); } + catch (IOException e) { /* ignore */ } + } + + extio.setHandle (tmp); + try { setConsoleInputName (extio, cin[cin_no]); } + catch (Exception e) { return -1; } + + isr = (Reader)extio.getHandle (); + cin_no++; + + try { n = isr.read (buf, 0, len); } + catch (IOException e) { return -1; } + } + + return n; + } + + return -1; + } + + protected int writeConsole (Extio extio, char[] buf, int len) + { + int mode = extio.getMode (); + + //System.err.println ("[writeConsole called name: " + extio.getName() + " mode: " + extio.getMode()); + + if (mode == Extio.MODE_CONSOLE_WRITE) + { + Writer osw; + + osw = (Writer)extio.getHandle (); + // as the write operation below doesn't + // indicate if it has reached the end, console + // can't be switched here unlike in read_console + try { osw.write (buf, 0, len); osw.flush (); } + catch (IOException e) { return -1; } + + return len; + } + + return -1; + } + + protected int flushConsole (Extio extio) + { + int mode = extio.getMode (); + + if (mode == Extio.MODE_CONSOLE_WRITE) + { + Writer osw; + + osw = (Writer)extio.getHandle (); + + try { osw.flush (); } + catch (IOException e) { return -1; } + + return 0; + } + + return -1; + } + + protected int nextConsole (Extio extio) + { + int mode = extio.getMode (); + + if (mode == Extio.MODE_CONSOLE_READ) + { + Reader isr, tmp; + + isr = (Reader)extio.getHandle (); + + if (cin == null || cin_no >= cin.length) return 0; + tmp = get_stream_reader (cin[cin_no]); + if (tmp == null) return -1; + + if (isr != StdAwk.stdin) + { + try { isr.close (); } + catch (IOException e) { /* ignore */ } + } + + extio.setHandle (tmp); + try { setConsoleInputName (extio, cin[cin_no]); } + catch (Exception e) { return -1; } + + cin_no++; + return 1; + } + else if (mode == Extio.MODE_CONSOLE_WRITE) + { + Writer osw, tmp; + + osw = (Writer)extio.getHandle (); + + if (cout == null || cout_no >= cout.length) return 0; + tmp = get_stream_writer (cout[cout_no]); + if (tmp == null) return -1; + + if (osw != StdAwk.stdout) + { + try { osw.close (); } + catch (IOException e) { /* ignore */ } + } + + extio.setHandle (tmp); + try { setConsoleOutputName (extio, cout[cout_no]); } + catch (Exception e) { return -1;} + + cout_no++; + return 1; + } + + return -1; + } + + private Reader get_stream_reader (String name) + { + Reader isr; + + if (name == null || name.length() == 0) isr = StdAwk.stdin; + else + { + FileInputStream fis; + try { fis = new FileInputStream (name); } + catch (IOException e) { return null; } + isr = new BufferedReader(new InputStreamReader (fis)); + } + + return isr; + } + + private Writer get_stream_writer (String name) + { + Writer osw; + + if (name == null || name.length() == 0) osw = StdAwk.stdout; + else + { + FileOutputStream fos; + try { fos = new FileOutputStream (name); } + catch (IOException e) { return null; } + osw = new BufferedWriter (new OutputStreamWriter (fos)); + } + + return osw; + } + + /* == file interface == */ + protected int openFile (Extio extio) + { + int mode = extio.getMode(); + + if (mode == Extio.MODE_FILE_READ) + { + FileInputStream fis; + Reader isr; + + try { fis = new FileInputStream (extio.getName()); } + catch (IOException e) { return -1; } + + isr = new BufferedReader (new InputStreamReader (fis)); + extio.setHandle (isr); + return 1; + } + else if (mode == Extio.MODE_FILE_WRITE) + { + FileOutputStream fos; + Writer osw; + + try { fos = new FileOutputStream (extio.getName()); } + catch (IOException e) { return -1; } + + osw = new BufferedWriter (new OutputStreamWriter (fos)); + extio.setHandle (osw); + return 1; + } + else if (mode == Extio.MODE_FILE_APPEND) + { + FileOutputStream fos; + Writer osw; + + try { fos = new FileOutputStream (extio.getName(), true); } + catch (IOException e) { return -1; } + + osw = new BufferedWriter (new OutputStreamWriter (fos)); + extio.setHandle (osw); + return 1; + } + + return -1; + } + + protected int closeFile (Extio extio) + { + int mode = extio.getMode(); + + if (mode == Extio.MODE_FILE_READ) + { + Reader isr; + isr = (Reader)extio.getHandle(); + if (isr != StdAwk.stdin) + { + try { isr.close (); } + catch (IOException e) { return -1; } + } + return 0; + } + else if (mode == Extio.MODE_FILE_WRITE) + { + Writer osw; + osw = (Writer)extio.getHandle(); + if (osw != StdAwk.stdout) + { + try { osw.close (); } + catch (IOException e) { return -1; } + } + return 0; + } + else if (mode == Extio.MODE_FILE_APPEND) + { + Writer osw; + osw = (Writer)extio.getHandle(); + if (osw != StdAwk.stdout) + { + try { osw.close (); } + catch (IOException e) { return -1; } + } + return 0; + } + + return -1; + } + + protected int readFile (Extio extio, char[] buf, int len) + { + int mode = extio.getMode(); + + if (mode == Extio.MODE_FILE_READ) + { + Reader isr; + isr = (Reader)extio.getHandle(); + + try + { + len = isr.read (buf, 0, len); + if (len == -1) len = 0; + } + catch (IOException e) { len = -1; } + return len; + } + + return -1; + } + + protected int writeFile (Extio extio, char[] buf, int len) + { + int mode = extio.getMode(); + + if (mode == Extio.MODE_FILE_WRITE || + mode == Extio.MODE_FILE_APPEND) + { + Writer osw; + osw = (Writer)extio.getHandle(); + try { osw.write (buf, 0, len); } + catch (IOException e) { len = -1; } + return len; + } + + return -1; + } + + protected int flushFile (Extio extio) + { + int mode = extio.getMode (); + + if (mode == Extio.MODE_FILE_WRITE || + mode == Extio.MODE_FILE_APPEND) + { + Writer osw; + osw = (Writer)extio.getHandle (); + try { osw.flush (); } + catch (IOException e) { return -1; } + return 0; + } + + return -1; + } + + /* == pipe interface == */ + protected int openPipe (Extio extio) + { + int mode = extio.getMode(); + + if (mode == Extio.MODE_PIPE_READ) + { + + Process proc; + Reader isr; + + try { proc = popen (extio.getName()); } + catch (IOException e) { return -1; } + + isr = new BufferedReader (new InputStreamReader (proc.getInputStream())); + extio.setHandle (isr); + return 1; + } + else if (mode == Extio.MODE_PIPE_WRITE) + { + Process proc; + Writer osw; + + try { proc = popen (extio.getName()); } + catch (IOException e) { return -1; } + + osw = new BufferedWriter (new OutputStreamWriter (proc.getOutputStream())); + extio.setHandle (osw); + return 1; + } + + return -1; + } + + protected int closePipe (Extio extio) + { + int mode = extio.getMode(); + + if (mode == Extio.MODE_PIPE_READ) + { + Reader isr; + isr = (Reader)extio.getHandle(); + if (isr != StdAwk.stdin) + { + try { isr.close (); } + catch (IOException e) { return -1; } + } + return 0; + } + else if (mode == Extio.MODE_PIPE_WRITE) + { + Writer osw; + osw = (Writer)extio.getHandle(); + if (osw != StdAwk.stdout) + { + try { osw.close (); } + catch (IOException e) { return -1; } + } + return 0; + } + + return -1; + } + + protected int readPipe (Extio extio, char[] buf, int len) + { + int mode = extio.getMode(); + + if (mode == Extio.MODE_PIPE_READ) + { + Reader isr; + isr = (Reader)extio.getHandle(); + + try + { + len = isr.read (buf, 0, len); + if (len == -1) len = 0; + } + catch (IOException e) { len = -1; } + return len; + } + + return -1; + } + + protected int writePipe (Extio extio, char[] buf, int len) + { + int mode = extio.getMode(); + + if (mode == Extio.MODE_PIPE_WRITE) + { + Writer osw; + osw = (Writer)extio.getHandle(); + try { osw.write (buf, 0, len); } + catch (IOException e) { len = -1; } + return len; + } + + return -1; + } + + protected int flushPipe (Extio extio) + { + int mode = extio.getMode (); + + if (mode == Extio.MODE_PIPE_WRITE) + { + Writer osw; + osw = (Writer)extio.getHandle (); + try { osw.flush (); } + catch (IOException e) { return -1; } + return 0; + } + + return -1; + } + + + /* == arithmetic built-in functions */ + public Object bfn_sin (long runid, Object[] args) throws Exception + { + double x = builtinFunctionArgumentToDouble (runid, args[0]); + return new Double (Math.sin(x)); + } + + public Object bfn_cos (long runid, Object[] args) throws Exception + { + double x = builtinFunctionArgumentToDouble (runid, args[0]); + return new Double (Math.cos(x)); + } + + public Object bfn_tan (long runid, Object[] args) throws Exception + { + double x = builtinFunctionArgumentToDouble (runid, args[0]); + return new Double (Math.tan(x)); + } + + public Object bfn_atan2 (long runid, Object[] args) throws Exception + { + double y = builtinFunctionArgumentToDouble (runid, args[0]); + double x = builtinFunctionArgumentToDouble (runid, args[1]); + return new Double (Math.atan2(y,x)); + } + + public Object bfn_log (long runid, Object[] args) throws Exception + { + double x = builtinFunctionArgumentToDouble (runid, args[0]); + return new Double (Math.log(x)); + } + + public Object bfn_exp (long runid, Object[] args) throws Exception + { + double x = builtinFunctionArgumentToDouble (runid, args[0]); + return new Double (Math.exp(x)); + } + + public Object bfn_sqrt (long runid, Object[] args) throws Exception + { + double x = builtinFunctionArgumentToDouble (runid, args[0]); + return new Double (Math.sqrt(x)); + } + + public Object bfn_int (long runid, Object[] args) throws Exception + { + long x = builtinFunctionArgumentToLong (runid, args[0]); + return new Long (x); + } + + public Object bfn_rand (long runid, Object[] args) + { + return new Double (random.nextDouble ()); + } + + public Object bfn_srand (long runid, Object[] args) throws Exception + { + long prev_seed = seed; + + seed = (args == null || args.length == 0)? + System.currentTimeMillis (): + builtinFunctionArgumentToLong (runid, args[0]); + + random.setSeed (seed); + return new Long (prev_seed); + } + + public Object bfn_systime (long runid, Object[] args) + { + long msec = System.currentTimeMillis (); + return new Long (msec / 1000); + } + + public Object bfn_strftime (long runid, Object[] args) + { + // TODO: implement this... + return null; + } + + /* miscellaneous built-in functions */ + public Object bfn_system (long runid, Object[] args) throws Exception + { + String str = builtinFunctionArgumentToString (runid, args[0]); + Process proc = null; + int n = 0; + + str = builtinFunctionArgumentToString (runid, args[0]); + + try { proc = popen (str); } + catch (IOException e) { n = -1; } + + if (proc != null) + { + InputStream is; + byte[] buf = new byte[1024]; + + is = proc.getInputStream(); + + // TODO; better error handling... program execution.. io redirection??? + try { while (is.read (buf) != -1) ; } + catch (IOException e) { n = -1; }; + + try { n = proc.waitFor (); } + catch (InterruptedException e) + { + proc.destroy (); + n = -1; + } + } + + return new Long (n); + } + + /* == utility functions == */ + private Process popen (String command) throws IOException + { + String full; + + /* TODO: consider OS names and versions */ + full = System.getenv ("ComSpec"); + if (full != null) + { + full = full + " /c " + command; + } + else + { + full = System.getenv ("SHELL"); + if (full != null) + { + full = "/bin/sh -c \"" + command + "\""; + } + else full = command; + } + + return Runtime.getRuntime().exec (full); + } +} diff --git a/ase/awk/aseawk.dsp b/ase/awk/aseawk.dsp new file mode 100644 index 00000000..8387e03b --- /dev/null +++ b/ase/awk/aseawk.dsp @@ -0,0 +1,202 @@ +# Microsoft Developer Studio Project File - Name="aseawk" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=aseawk - Win32 Release +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "aseawk.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "aseawk.mak" CFG="aseawk - Win32 Release" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "aseawk - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "aseawk - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "aseawk - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "../release/lib" +# PROP Intermediate_Dir "release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +MTL=midl.exe +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "_USRDLL" /Yu"stdafx.h" /FD /c +# ADD CPP /nologo /MT /Za /W3 /GX /O2 /I "..\.." /D "NDEBUG" /D "WIN32" /D "_UNICODE" /FD /c +# SUBTRACT CPP /YX /Yc /Yu +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo + +!ELSEIF "$(CFG)" == "aseawk - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "../debug/lib" +# PROP Intermediate_Dir "debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +MTL=midl.exe +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_UNICODE" /D "_USRDLL" /Yu"stdafx.h" /FD /GZ /c +# ADD CPP /nologo /MTd /Za /W3 /Gm /GX /ZI /Od /I "..\.." /D "_DEBUG" /D "WIN32" /D "_UNICODE" /FD /GZ /c +# SUBTRACT CPP /YX /Yc /Yu +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo + +!ENDIF + +# Begin Target + +# Name "aseawk - Win32 Release" +# Name "aseawk - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\awk.c +# End Source File +# Begin Source File + +SOURCE=.\err.c +# End Source File +# Begin Source File + +SOURCE=.\extio.c +# End Source File +# Begin Source File + +SOURCE=.\func.c +# End Source File +# Begin Source File + +SOURCE=.\map.c +# End Source File +# Begin Source File + +SOURCE=.\misc.c +# End Source File +# Begin Source File + +SOURCE=.\parse.c +# End Source File +# Begin Source File + +SOURCE=.\rec.c +# End Source File +# Begin Source File + +SOURCE=.\rex.c +# End Source File +# Begin Source File + +SOURCE=.\run.c +# End Source File +# Begin Source File + +SOURCE=.\tab.c +# End Source File +# Begin Source File + +SOURCE=.\tree.c +# End Source File +# Begin Source File + +SOURCE=.\val.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\awk.h +# End Source File +# Begin Source File + +SOURCE=.\awk_i.h +# End Source File +# Begin Source File + +SOURCE=.\extio.h +# End Source File +# Begin Source File + +SOURCE=.\func.h +# End Source File +# Begin Source File + +SOURCE=.\map.h +# End Source File +# Begin Source File + +SOURCE=.\parse.h +# End Source File +# Begin Source File + +SOURCE=.\rex.h +# End Source File +# Begin Source File + +SOURCE=.\run.h +# End Source File +# Begin Source File + +SOURCE=.\tab.h +# End Source File +# Begin Source File + +SOURCE=.\tree.h +# End Source File +# Begin Source File + +SOURCE=.\val.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/ase/awk/aseawk.vcproj b/ase/awk/aseawk.vcproj new file mode 100644 index 00000000..9e236b43 --- /dev/null +++ b/ase/awk/aseawk.vcproj @@ -0,0 +1,521 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ase/awk/aseawk_jni.dsp b/ase/awk/aseawk_jni.dsp new file mode 100644 index 00000000..c029e913 --- /dev/null +++ b/ase/awk/aseawk_jni.dsp @@ -0,0 +1,113 @@ +# Microsoft Developer Studio Project File - Name="aesawk_jni" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=aesawk_jni - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "aseawk_jni.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "aseawk_jni.mak" CFG="aesawk_jni - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "aesawk_jni - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "aesawk_jni - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "aesawk_jni - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "../release/lib" +# PROP Intermediate_Dir "release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "JNI_EXPORTS" /YX /FD /c +# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\.." /I "$(JAVA_HOME)\include" /I "$(JAVA_HOME)\include\win32" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "_USRDLL" /FD /c +# SUBTRACT CPP /YX +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 +# ADD LINK32 asecmn.lib aseawk.lib aseutl.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /implib:"release/aseawk_jni.lib" /libpath:"$(OutDir)" + +!ELSEIF "$(CFG)" == "aesawk_jni - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "../debug/lib" +# PROP Intermediate_Dir "debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "JNI_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\.." /I "$(JAVA_HOME)\include" /I "$(JAVA_HOME)\include\win32" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_UNICODE" /D "_USRDLL" /FD /GZ /c +# SUBTRACT CPP /YX +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 asecmn.lib aseawk.lib aseutl.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /implib:"debug/aseawk_jni.lib" /pdbtype:sept /libpath:"$(OutDir)" + +!ENDIF + +# Begin Target + +# Name "aesawk_jni - Win32 Release" +# Name "aesawk_jni - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\jni.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\jni.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/ase/awk/aseawk_jni.vcproj b/ase/awk/aseawk_jni.vcproj new file mode 100644 index 00000000..36aa4530 --- /dev/null +++ b/ase/awk/aseawk_jni.vcproj @@ -0,0 +1,258 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ase/awk/awk.c b/ase/awk/awk.c new file mode 100644 index 00000000..2ad404d7 --- /dev/null +++ b/ase/awk/awk.c @@ -0,0 +1,256 @@ +/* + * $Id: awk.c,v 1.3 2007/04/30 05:47:33 bacon Exp $ + * + * {License} + */ + +#if defined(__BORLANDC__) +#pragma hdrstop +#define Library +#endif + +#include + +static void free_afn (void* awk, void* afn); + +ase_awk_t* ase_awk_open (const ase_awk_prmfns_t* prmfns, void* custom_data) +{ + ase_awk_t* awk; + + ASE_ASSERT (prmfns != ASE_NULL); + + ASE_ASSERT (prmfns->mmgr.malloc != ASE_NULL && + prmfns->mmgr.free != ASE_NULL); + + ASE_ASSERT (prmfns->ccls.is_upper != ASE_NULL && + prmfns->ccls.is_lower != ASE_NULL && + prmfns->ccls.is_alpha != ASE_NULL && + prmfns->ccls.is_digit != ASE_NULL && + prmfns->ccls.is_xdigit != ASE_NULL && + prmfns->ccls.is_alnum != ASE_NULL && + prmfns->ccls.is_space != ASE_NULL && + prmfns->ccls.is_print != ASE_NULL && + prmfns->ccls.is_graph != ASE_NULL && + prmfns->ccls.is_cntrl != ASE_NULL && + prmfns->ccls.is_punct != ASE_NULL && + prmfns->ccls.to_upper != ASE_NULL && + prmfns->ccls.to_lower != ASE_NULL); + + ASE_ASSERT (prmfns->misc.pow != ASE_NULL && + prmfns->misc.sprintf != ASE_NULL && + prmfns->misc.dprintf != ASE_NULL); + +#if defined(_WIN32) && defined(_MSC_VER) && defined(_DEBUG) + awk = (ase_awk_t*) malloc (ASE_SIZEOF(ase_awk_t)); +#else + awk = (ase_awk_t*) prmfns->mmgr.malloc ( + prmfns->mmgr.custom_data, ASE_SIZEOF(ase_awk_t)); +#endif + if (awk == ASE_NULL) return ASE_NULL; + + /* it uses the built-in ase_awk_memset because awk is not + * fully initialized yet */ + ase_memset (awk, 0, ASE_SIZEOF(ase_awk_t)); + ase_memcpy (&awk->prmfns, prmfns, ASE_SIZEOF(awk->prmfns)); + + if (ase_str_open ( + &awk->token.name, 128, &awk->prmfns.mmgr) == ASE_NULL) + { + ASE_AWK_FREE (awk, awk); + return ASE_NULL; + } + + /* TODO: initial map size?? */ + if (ase_awk_map_open ( + &awk->tree.afns, awk, 256, free_afn, awk) == ASE_NULL) + { + ase_str_close (&awk->token.name); + ASE_AWK_FREE (awk, awk); + return ASE_NULL; + } + + if (ase_awk_tab_open (&awk->parse.globals, awk) == ASE_NULL) + { + ase_str_close (&awk->token.name); + ase_awk_map_close (&awk->tree.afns); + ASE_AWK_FREE (awk, awk); + return ASE_NULL; + } + + if (ase_awk_tab_open (&awk->parse.locals, awk) == ASE_NULL) + { + ase_str_close (&awk->token.name); + ase_awk_map_close (&awk->tree.afns); + ase_awk_tab_close (&awk->parse.globals); + ASE_AWK_FREE (awk, awk); + return ASE_NULL; + } + + if (ase_awk_tab_open (&awk->parse.params, awk) == ASE_NULL) + { + ase_str_close (&awk->token.name); + ase_awk_map_close (&awk->tree.afns); + ase_awk_tab_close (&awk->parse.globals); + ase_awk_tab_close (&awk->parse.locals); + ASE_AWK_FREE (awk, awk); + return ASE_NULL; + } + + awk->option = 0; + awk->errnum = ASE_AWK_ENOERR; + awk->errlin = 0; + + awk->parse.nlocals_max = 0; + + awk->tree.nglobals = 0; + awk->tree.nbglobals = 0; + awk->tree.begin = ASE_NULL; + awk->tree.end = ASE_NULL; + awk->tree.chain = ASE_NULL; + awk->tree.chain_tail = ASE_NULL; + awk->tree.chain_size = 0; + + awk->token.prev.type = 0; + awk->token.prev.line = 0; + awk->token.prev.column = 0; + awk->token.type = 0; + awk->token.line = 0; + awk->token.column = 0; + + awk->src.lex.curc = ASE_CHAR_EOF; + awk->src.lex.ungotc_count = 0; + awk->src.lex.line = 1; + awk->src.lex.column = 1; + awk->src.shared.buf_pos = 0; + awk->src.shared.buf_len = 0; + + awk->bfn.sys = ASE_NULL; + awk->bfn.user = ASE_NULL; + + awk->parse.depth.cur.block = 0; + awk->parse.depth.cur.loop = 0; + awk->parse.depth.cur.expr = 0; + + ase_awk_setmaxdepth (awk, ASE_AWK_DEPTH_BLOCK_PARSE, 0); + ase_awk_setmaxdepth (awk, ASE_AWK_DEPTH_BLOCK_RUN, 0); + ase_awk_setmaxdepth (awk, ASE_AWK_DEPTH_EXPR_PARSE, 0); + ase_awk_setmaxdepth (awk, ASE_AWK_DEPTH_EXPR_RUN, 0); + ase_awk_setmaxdepth (awk, ASE_AWK_DEPTH_REX_BUILD, 0); + ase_awk_setmaxdepth (awk, ASE_AWK_DEPTH_REX_MATCH, 0); + + awk->custom_data = custom_data; + return awk; +} + +static void free_afn (void* owner, void* afn) +{ + ase_awk_afn_t* f = (ase_awk_afn_t*)afn; + + /* f->name doesn't have to be freed */ + /*ASE_AWK_FREE ((ase_awk_t*)owner, f->name);*/ + + ase_awk_clrpt ((ase_awk_t*)owner, f->body); + ASE_AWK_FREE ((ase_awk_t*)owner, f); +} + +int ase_awk_close (ase_awk_t* awk) +{ + ase_size_t i; + + if (ase_awk_clear (awk) == -1) return -1; + ase_awk_clrbfn (awk); + + ase_awk_map_close (&awk->tree.afns); + ase_awk_tab_close (&awk->parse.globals); + ase_awk_tab_close (&awk->parse.locals); + ase_awk_tab_close (&awk->parse.params); + ase_str_close (&awk->token.name); + + for (i = 0; i < ASE_COUNTOF(awk->errstr); i++) + { + if (awk->errstr[i] != ASE_NULL) + { + ASE_AWK_FREE (awk, awk->errstr[i]); + awk->errstr[i] = ASE_NULL; + } + } + + /* ASE_AWK_ALLOC, ASE_AWK_FREE, etc can not be used + * from the next line onwards */ + ASE_AWK_FREE (awk, awk); + return 0; +} + +int ase_awk_clear (ase_awk_t* awk) +{ + ase_memset (&awk->src.ios, 0, ASE_SIZEOF(awk->src.ios)); + awk->src.lex.curc = ASE_CHAR_EOF; + awk->src.lex.ungotc_count = 0; + awk->src.lex.line = 1; + awk->src.lex.column = 1; + awk->src.shared.buf_pos = 0; + awk->src.shared.buf_len = 0; + + ase_awk_tab_clear (&awk->parse.globals); + ase_awk_tab_clear (&awk->parse.locals); + ase_awk_tab_clear (&awk->parse.params); + + awk->parse.nlocals_max = 0; + awk->parse.depth.cur.block = 0; + awk->parse.depth.cur.loop = 0; + awk->parse.depth.cur.expr = 0; + + /* clear parse trees */ + awk->tree.ok = 0; + awk->tree.nbglobals = 0; + awk->tree.nglobals = 0; + awk->tree.cur_afn.ptr = ASE_NULL; + awk->tree.cur_afn.len = 0; + ase_awk_map_clear (&awk->tree.afns); + + if (awk->tree.begin != ASE_NULL) + { + ASE_ASSERT (awk->tree.begin->next == ASE_NULL); + ase_awk_clrpt (awk, awk->tree.begin); + awk->tree.begin = ASE_NULL; + } + + if (awk->tree.end != ASE_NULL) + { + ASE_ASSERT (awk->tree.end->next == ASE_NULL); + ase_awk_clrpt (awk, awk->tree.end); + awk->tree.end = ASE_NULL; + } + + while (awk->tree.chain != ASE_NULL) + { + ase_awk_chain_t* next = awk->tree.chain->next; + + if (awk->tree.chain->pattern != ASE_NULL) + ase_awk_clrpt (awk, awk->tree.chain->pattern); + if (awk->tree.chain->action != ASE_NULL) + ase_awk_clrpt (awk, awk->tree.chain->action); + ASE_AWK_FREE (awk, awk->tree.chain); + awk->tree.chain = next; + } + + awk->tree.chain_tail = ASE_NULL; + awk->tree.chain_size = 0; + + return 0; +} + +int ase_awk_getoption (ase_awk_t* awk) +{ + return awk->option; +} + +void ase_awk_setoption (ase_awk_t* awk, int opt) +{ + awk->option = opt; +} + +void* ase_awk_getcustomdata (ase_awk_t* awk) +{ + return awk->custom_data; +} diff --git a/ase/awk/awk.h b/ase/awk/awk.h new file mode 100644 index 00000000..d62dec7b --- /dev/null +++ b/ase/awk/awk.h @@ -0,0 +1,505 @@ +/* + * $Id: awk.h,v 1.3 2007/04/30 05:47:33 bacon Exp $ + * + * {License} + */ + +#ifndef _ASE_AWK_AWK_H_ +#define _ASE_AWK_AWK_H_ + +#include +#include + +typedef struct ase_awk_t ase_awk_t; +typedef struct ase_awk_run_t ase_awk_run_t; +typedef struct ase_awk_val_t ase_awk_val_t; +typedef struct ase_awk_map_t ase_awk_map_t; +typedef struct ase_awk_extio_t ase_awk_extio_t; + +typedef struct ase_awk_prmfns_t ase_awk_prmfns_t; +typedef struct ase_awk_srcios_t ase_awk_srcios_t; +typedef struct ase_awk_runios_t ase_awk_runios_t; +typedef struct ase_awk_runcbs_t ase_awk_runcbs_t; +typedef struct ase_awk_runarg_t ase_awk_runarg_t; + +typedef ase_real_t (*ase_awk_pow_t) (void* custom, ase_real_t x, ase_real_t y); +typedef int (*ase_awk_sprintf_t) ( + void* custom, ase_char_t* buf, ase_size_t size, + const ase_char_t* fmt, ...); +typedef void (*ase_awk_dprintf_t) (void* custom, const ase_char_t* fmt, ...); + +typedef ase_ssize_t (*ase_awk_io_t) ( + int cmd, void* arg, ase_char_t* data, ase_size_t count); + +struct ase_awk_extio_t +{ + ase_awk_run_t* run; /* [IN] */ + int type; /* [IN] console, file, coproc, pipe */ + int mode; /* [IN] read, write, etc */ + ase_char_t* name; /* [IN] */ + void* custom_data; /* [IN] */ + void* handle; /* [OUT] */ + + /* input */ + struct + { + ase_char_t buf[2048]; + ase_size_t pos; + ase_size_t len; + ase_bool_t eof; + ase_bool_t eos; + } in; + + /* output */ + struct + { + ase_bool_t eof; + ase_bool_t eos; + } out; + + ase_awk_extio_t* next; +}; + +struct ase_awk_prmfns_t +{ + ase_mmgr_t mmgr; + ase_ccls_t ccls; + + struct + { + /* utilities */ + ase_awk_pow_t pow; /* required */ + ase_awk_sprintf_t sprintf; /* required */ + ase_awk_dprintf_t dprintf; /* required in the debug mode */ + + /* user-defined data passed to the functions above */ + void* custom_data; /* optional */ + } misc; +}; + +struct ase_awk_srcios_t +{ + ase_awk_io_t in; + ase_awk_io_t out; + void* custom_data; +}; + +struct ase_awk_runios_t +{ + ase_awk_io_t pipe; + ase_awk_io_t coproc; + ase_awk_io_t file; + ase_awk_io_t console; + void* custom_data; +}; + +struct ase_awk_runcbs_t +{ + void (*on_start) ( + ase_awk_run_t* run, void* custom_data); + + void (*on_statement) ( + ase_awk_run_t* run, ase_size_t line, void* custom_data); + + void (*on_return) ( + ase_awk_run_t* run, ase_awk_val_t* ret, void* custom_data); + + void (*on_end) ( + ase_awk_run_t* run, int errnum, void* custom_data); + + void* custom_data; +}; + +struct ase_awk_runarg_t +{ + ase_char_t* ptr; + ase_size_t len; +}; + +/* io function commands */ +enum +{ + ASE_AWK_IO_OPEN = 0, + ASE_AWK_IO_CLOSE = 1, + ASE_AWK_IO_READ = 2, + ASE_AWK_IO_WRITE = 3, + ASE_AWK_IO_FLUSH = 4, + ASE_AWK_IO_NEXT = 5 +}; + +/* various options */ +enum +{ + /* allow undeclared variables and implicit concatenation */ + ASE_AWK_IMPLICIT = (1 << 0), + + /* allow explicit variable declaration and the concatenation + * operator, a period. */ + ASE_AWK_EXPLICIT = (1 << 1), + + /* a function name should not coincide to be a variable name */ + ASE_AWK_UNIQUEFN = (1 << 2), + + /* allow variable shading */ + ASE_AWK_SHADING = (1 << 3), + + /* support shift operators */ + ASE_AWK_SHIFT = (1 << 4), + + /* enable the idiv operator (double slashes) */ + ASE_AWK_IDIV = (1 << 5), + + /* support string concatenation in tokenization. + * this option can change the behavior of a certain construct. + * getline < "abc" ".def" is treated as if it is getline < "abc.def" + * when this option is on. If this option is off, the same expression + * is treated as if it is (getline < "abc") ".def". */ + ASE_AWK_STRCONCAT = (1 << 6), + + /* support getline and print */ + ASE_AWK_EXTIO = (1 << 7), + + /* support co-process */ + ASE_AWK_COPROC = (1 << 8), + + /* support blockless patterns */ + ASE_AWK_BLOCKLESS = (1 << 9), + + /* use 1 as the start index for string operations */ + ASE_AWK_STRBASEONE = (1 << 10), + + /* strip off leading and trailing spaces when splitting a record + * into fields with a regular expression. + * + * Consider the following program. + * BEGIN { FS="[:[:space:]]+"; } + * { + * print "NF=" NF; + * for (i = 0; i < NF; i++) print i " [" $(i+1) "]"; + * } + * + * The program splits " a b c " into [a], [b], [c] when this + * option is on while into [], [a], [b], [c], [] when it is off. + */ + ASE_AWK_STRIPSPACES = (1 << 11), + + /* enable the nextoutfile keyword */ + ASE_AWK_NEXTOFILE = (1 << 12), + + /* cr + lf by default */ + ASE_AWK_CRLF = (1 << 13), + + /* pass the arguments to the main function */ + ASE_AWK_ARGSTOMAIN = (1 << 14) +}; + +/* error code */ +enum +{ + ASE_AWK_ENOERR, /* no error */ + + ASE_AWK_EINVAL, /* invalid parameter */ + ASE_AWK_ENOMEM, /* out of memory */ + ASE_AWK_ENOSUP, /* not supported */ + ASE_AWK_ENOPER, /* operation not allowed */ + ASE_AWK_ENODEV, /* function '%.*s' not found */ + ASE_AWK_ENOSPC, /* no space left on device */ + ASE_AWK_EMFILE, /* too many open files */ + ASE_AWK_EMLINK, /* too many links */ + ASE_AWK_EAGAIN, /* resource temporarily unavailable */ + ASE_AWK_ENOENT, /* file or data not existing */ + ASE_AWK_EEXIST, /* file or data exists */ + ASE_AWK_EFTBIG, /* file or data too big */ + ASE_AWK_ETBUSY, /* system too busy */ + ASE_AWK_EISDIR, /* is a directory */ + ASE_AWK_EIOERR, /* i/o error */ + + ASE_AWK_EOPEN, /* cannot open */ + ASE_AWK_EREAD, /* cannot read */ + ASE_AWK_EWRITE, /* cannot write */ + ASE_AWK_ECLOSE, /* cannot close */ + + ASE_AWK_EINTERN, /* internal error */ + ASE_AWK_ERUNTIME, /* run-time error */ + ASE_AWK_EBLKNST, /* blocke nested too deeply */ + ASE_AWK_EEXPRNST, /* expression nested too deeply */ + + ASE_AWK_ESINOP, + ASE_AWK_ESINCL, + ASE_AWK_ESINRD, + + ASE_AWK_ESOUTOP, + ASE_AWK_ESOUTCL, + ASE_AWK_ESOUTWR, + + ASE_AWK_ELXCHR, /* lexer came accross an wrong character */ + ASE_AWK_ELXUNG, /* lexer failed to unget a character */ + + ASE_AWK_EENDSRC, /* unexpected end of source */ + ASE_AWK_EENDCMT, /* a comment not closed properly */ + ASE_AWK_EENDSTR, /* a string not closed with a quote */ + ASE_AWK_EENDREX, /* unexpected end of a regular expression */ + ASE_AWK_ELBRACE, /* left brace expected */ + ASE_AWK_ELPAREN, /* left parenthesis expected */ + ASE_AWK_ERPAREN, /* right parenthesis expected */ + ASE_AWK_ERBRACK, /* right bracket expected */ + ASE_AWK_ECOMMA, /* comma expected */ + ASE_AWK_ESCOLON, /* semicolon expected */ + ASE_AWK_ECOLON, /* colon expected */ + ASE_AWK_ESTMEND, /* statement not ending with a semicolon */ + ASE_AWK_EIN, /* keyword 'in' is expected */ + ASE_AWK_ENOTVAR, /* not a variable name after 'in' */ + ASE_AWK_EEXPRES, /* expression expected */ + + ASE_AWK_EWHILE, /* keyword 'while' is expected */ + ASE_AWK_EASSIGN, /* assignment statement expected */ + ASE_AWK_EIDENT, /* identifier expected */ + ASE_AWK_EFNNAME, /* not a valid function name */ + ASE_AWK_EBLKBEG, /* BEGIN requires an action block */ + ASE_AWK_EBLKEND, /* END requires an action block */ + ASE_AWK_EDUPBEG, /* duplicate BEGIN */ + ASE_AWK_EDUPEND, /* duplicate END */ + ASE_AWK_EBFNRED, /* builtin function redefined */ + ASE_AWK_EAFNRED, /* function redefined */ + ASE_AWK_EGBLRED, /* global variable redefined */ + ASE_AWK_EPARRED, /* parameter redefined */ + ASE_AWK_EDUPPAR, /* duplicate parameter name */ + ASE_AWK_EDUPGBL, /* duplicate global variable name */ + ASE_AWK_EDUPLCL, /* duplicate local variable name */ + ASE_AWK_EBADPAR, /* not a valid parameter name */ + ASE_AWK_EBADVAR, /* not a valid variable name */ + ASE_AWK_EUNDEF, /* undefined identifier */ + ASE_AWK_ELVALUE, /* l-value required */ + ASE_AWK_EGBLTM, /* too many global variables */ + ASE_AWK_ELCLTM, /* too many local variables */ + ASE_AWK_EPARTM, /* too many parameters */ + ASE_AWK_EDELETE, /* delete not followed by a variable */ + ASE_AWK_EBREAK, /* break outside a loop */ + ASE_AWK_ECONTINUE, /* continue outside a loop */ + ASE_AWK_ENEXTBEG, /* next illegal in BEGIN block */ + ASE_AWK_ENEXTEND, /* next illegal in END block */ + ASE_AWK_ENEXTFBEG, /* nextfile illegal in BEGIN block */ + ASE_AWK_ENEXTFEND, /* nextfile illegal in END block */ + ASE_AWK_EPRINTFARG, /* printf not followed by any arguments */ + ASE_AWK_EPREPST, /* both prefix and postfix increment/decrement + operator present */ + ASE_AWK_EGLNCPS, /* coprocess not supported by getline */ + + /* run time error */ + ASE_AWK_EDIVBY0, /* divide by zero */ + ASE_AWK_EOPERAND, /* invalid operand */ + ASE_AWK_EPOSIDX, /* wrong position index */ + ASE_AWK_EARGTF, /* too few arguments */ + ASE_AWK_EARGTM, /* too many arguments */ + ASE_AWK_EFNNONE, /* no such function */ + ASE_AWK_ENOTIDX, /* variable not indexable */ + ASE_AWK_ENOTDEL, /* variable not deletable */ + ASE_AWK_ENOTMAP, /* value not a map */ + ASE_AWK_ENOTMAPIN, /* right-hand side of 'in' not a map */ + ASE_AWK_ENOTMAPNILIN, /* right-hand side of 'in' not a map nor nil */ + ASE_AWK_ENOTREF, /* value not referenceable */ + ASE_AWK_ENOTASS, /* value not assignable */ + ASE_AWK_EIDXVALASSMAP, /* indexed value cannot be assigned a map */ + ASE_AWK_EPOSVALASSMAP, /* a positional cannot be assigned a map */ + ASE_AWK_EMAPTOSCALAR, /* cannot change a map to a scalar value */ + ASE_AWK_ESCALARTOMAP, /* cannot change a scalar value to a map */ + ASE_AWK_EMAPNOTALLOWED, /* a map is not allowed */ + ASE_AWK_EVALTYPE, /* wrong value type */ + ASE_AWK_ERDELETE, /* delete called with a wrong target */ + ASE_AWK_ERNEXTBEG, /* next called from BEGIN */ + ASE_AWK_ERNEXTEND, /* next called from END */ + ASE_AWK_ERNEXTFBEG, /* nextfile called from BEGIN */ + ASE_AWK_ERNEXTFEND, /* nextfile called from END */ + ASE_AWK_EBFNUSER, /* wrong builtin function implementation */ + ASE_AWK_EBFNIMPL, /* builtin function handler failed */ + ASE_AWK_EIOUSER, /* wrong user io handler implementation */ + ASE_AWK_EIONONE, /* no such io name found */ + ASE_AWK_EIOIMPL, /* i/o callback returned an error */ + ASE_AWK_EIONMEM, /* i/o name empty */ + ASE_AWK_EIONMNL, /* i/o name contains '\0' */ + ASE_AWK_EFMTARG, /* arguments to format string not sufficient */ + ASE_AWK_EFMTCNV, /* recursion detected in format conversion */ + ASE_AWK_ECONVFMTCHR, /* an invalid character found in CONVFMT */ + ASE_AWK_EOFMTCHR, /* an invalid character found in OFMT */ + + /* regular expression error */ + ASE_AWK_EREXRECUR, /* recursion too deep */ + ASE_AWK_EREXRPAREN, /* a right parenthesis is expected */ + ASE_AWK_EREXRBRACKET, /* a right bracket is expected */ + ASE_AWK_EREXRBRACE, /* a right brace is expected */ + ASE_AWK_EREXUNBALPAR, /* unbalanced parenthesis */ + ASE_AWK_EREXCOLON, /* a colon is expected */ + ASE_AWK_EREXCRANGE, /* invalid character range */ + ASE_AWK_EREXCCLASS, /* invalid character class */ + ASE_AWK_EREXBRANGE, /* invalid boundary range */ + ASE_AWK_EREXEND, /* unexpected end of the pattern */ + ASE_AWK_EREXGARBAGE, /* garbage after the pattern */ + + /* the number of error numbers, internal use only */ + ASE_AWK_NUMERRNUM +}; + +/* depth types */ +enum ase_awk_depth_t +{ + ASE_AWK_DEPTH_BLOCK_PARSE = (1 << 0), + ASE_AWK_DEPTH_BLOCK_RUN = (1 << 1), + ASE_AWK_DEPTH_EXPR_PARSE = (1 << 2), + ASE_AWK_DEPTH_EXPR_RUN = (1 << 3), + ASE_AWK_DEPTH_REX_BUILD = (1 << 4), + ASE_AWK_DEPTH_REX_MATCH = (1 << 5) +}; + +/* extio types */ +enum ase_awk_extio_type_t +{ + /* extio types available */ + ASE_AWK_EXTIO_PIPE, + ASE_AWK_EXTIO_COPROC, + ASE_AWK_EXTIO_FILE, + ASE_AWK_EXTIO_CONSOLE, + + /* reserved for internal use only */ + ASE_AWK_EXTIO_NUM +}; + +enum +{ + ASE_AWK_EXTIO_PIPE_READ = 0, + ASE_AWK_EXTIO_PIPE_WRITE = 1, + + /* + ASE_AWK_EXTIO_COPROC_READ = 0, + ASE_AWK_EXTIO_COPROC_WRITE = 1, + ASE_AWK_EXTIO_COPROC_RDWR = 2, + */ + + ASE_AWK_EXTIO_FILE_READ = 0, + ASE_AWK_EXTIO_FILE_WRITE = 1, + ASE_AWK_EXTIO_FILE_APPEND = 2, + + ASE_AWK_EXTIO_CONSOLE_READ = 0, + ASE_AWK_EXTIO_CONSOLE_WRITE = 1 +}; + +#ifdef __cplusplus +extern "C" { +#endif + +ase_awk_t* ase_awk_open (const ase_awk_prmfns_t* prmfns, void* custom_data); +int ase_awk_close (ase_awk_t* awk); +int ase_awk_clear (ase_awk_t* awk); + +void* ase_awk_getcustomdata (ase_awk_t* awk); + +const ase_char_t* ase_awk_geterrstr (ase_awk_t* awk, int num); +int ase_awk_seterrstr (ase_awk_t* awk, int num, const ase_char_t* str); + +int ase_awk_geterrnum (ase_awk_t* awk); +ase_size_t ase_awk_geterrlin (ase_awk_t* awk); +const ase_char_t* ase_awk_geterrmsg (ase_awk_t* awk); +void ase_awk_seterrnum (ase_awk_t* awk, int errnum); + +void ase_awk_geterror ( + ase_awk_t* awk, int* errnum, + ase_size_t* errlin, const ase_char_t** errmsg); + +void ase_awk_seterror ( + ase_awk_t* awk, int errnum, ase_size_t errlin, + const ase_cstr_t* errarg, ase_size_t argcnt); + +int ase_awk_getoption (ase_awk_t* awk); +void ase_awk_setoption (ase_awk_t* awk, int opt); + +ase_size_t ase_awk_getmaxdepth (ase_awk_t* awk, int type); +void ase_awk_setmaxdepth (ase_awk_t* awk, int types, ase_size_t depth); + +int ase_awk_parse (ase_awk_t* awk, ase_awk_srcios_t* srcios); + +/* + * ase_awk_run return 0 on success and -1 on failure, generally speaking. + * A runtime context is required for it to start running the program. + * Once the runtime context is created, the program starts to run. + * The context creation failure is reported by the return value -1 of + * this function. however, the runtime error after the context creation + * is reported differently depending on the use of the callback. + * When no callback is specified (i.e. runcbs is ASE_NULL), ase_awk_run + * returns -1 on an error and awk->errnum is set accordingly. + * However, if a callback is specified (i.e. runcbs is not ASE_NULL), + * ase_awk_run returns 0 on both success and failure. Instead, the + * on_end handler of the callback is triggered with the relevant + * error number. The third parameter to on_end denotes this error number. + */ +int ase_awk_run ( + ase_awk_t* awk, const ase_char_t* main, + ase_awk_runios_t* runios, ase_awk_runcbs_t* runcbs, + ase_awk_runarg_t* runarg, void* custom_data); + +int ase_awk_stop (ase_awk_run_t* run); + +/* functions to access internal stack structure */ +ase_size_t ase_awk_getnargs (ase_awk_run_t* run); +ase_awk_val_t* ase_awk_getarg (ase_awk_run_t* run, ase_size_t idx); +ase_awk_val_t* ase_awk_getglobal (ase_awk_run_t* run, ase_size_t idx); +int ase_awk_setglobal (ase_awk_run_t* run, ase_size_t idx, ase_awk_val_t* val); +void ase_awk_setretval (ase_awk_run_t* run, ase_awk_val_t* val); + +int ase_awk_setfilename ( + ase_awk_run_t* run, const ase_char_t* name, ase_size_t len); +int ase_awk_setofilename ( + ase_awk_run_t* run, const ase_char_t* name, ase_size_t len); + +ase_awk_t* ase_awk_getrunawk (ase_awk_run_t* awk); +void* ase_awk_getruncustomdata (ase_awk_run_t* awk); +ase_awk_map_t* ase_awk_getrunnamedvarmap (ase_awk_run_t* awk); + +/* functions to manipulate the run-time error */ +int ase_awk_getrunerrnum (ase_awk_run_t* run); +ase_size_t ase_awk_getrunerrlin (ase_awk_run_t* run); +const ase_char_t* ase_awk_getrunerrmsg (ase_awk_run_t* run); +void ase_awk_setrunerrnum (ase_awk_run_t* run, int errnum); + +void ase_awk_getrunerror ( + ase_awk_run_t* run, int* errnum, + ase_size_t* errlin, const ase_char_t** errmsg); + +void ase_awk_setrunerror ( + ase_awk_run_t* run, int errnum, ase_size_t errlin, + const ase_cstr_t* errarg, ase_size_t argcnt); + +/* functions to manipulate built-in functions */ +void* ase_awk_addbfn ( + ase_awk_t* awk, const ase_char_t* name, ase_size_t name_len, + int when_valid, ase_size_t min_args, ase_size_t max_args, + const ase_char_t* arg_spec, + int (*handler)(ase_awk_run_t*,const ase_char_t*,ase_size_t)); + +int ase_awk_delbfn ( + ase_awk_t* awk, const ase_char_t* name, ase_size_t name_len); + +void ase_awk_clrbfn (ase_awk_t* awk); + +/* record and field functions */ +int ase_awk_clrrec (ase_awk_run_t* run, ase_bool_t skip_inrec_line); +int ase_awk_setrec (ase_awk_run_t* run, ase_size_t idx, const ase_char_t* str, ase_size_t len); + +/* utility functions exported by awk.h */ +void* ase_awk_malloc (ase_awk_t* awk, ase_size_t size); +void ase_awk_free (ase_awk_t* awk, void* ptr); + +ase_long_t ase_awk_strxtolong ( + ase_awk_t* awk, const ase_char_t* str, ase_size_t len, + int base, const ase_char_t** endptr); +ase_real_t ase_awk_strxtoreal ( + ase_awk_t* awk, const ase_char_t* str, ase_size_t len, + const ase_char_t** endptr); + +ase_size_t ase_awk_longtostr ( + ase_long_t value, int radix, const ase_char_t* prefix, + ase_char_t* buf, ase_size_t size); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ase/awk/awk.txt b/ase/awk/awk.txt new file mode 100644 index 00000000..6e2ea48a --- /dev/null +++ b/ase/awk/awk.txt @@ -0,0 +1,71 @@ +Programs + + pattern { action } + function name (parameter-list) { statement } + +Patterns + BEGIN + END + expresion + /regular expression/ + pattern && pattern + pattern || pattern + !pattern + (pattern) + pattern, pattern -> range pattern + +Actions + break + continue + delete array-element + do statement while (expression) + exit [expression] + expression + if (expression) statement [else statement] + input-output statement + for (expression; expression; expression) statement + for (variable in array) statement + next + return [expression] + while (expression) statement + { statements } + +Variables + +global variables (enabled when awk->opt & XP_AWK_OPT_VARDCL) + + global x; + global x, y; + +local variables (enabled when awk->opt & XP_AWK_OPT_VARDCL) + + local x; + local x, y; + +function arguments (enabled always) + + function funca (x, y) + + +local variables in function declaration (enabled when awk->opt & XP_AWK_OPT_FUNCLOCAL) + + function funca (x, y, v1, v2) + + +variables without any declarations (enabled when awk->opt & XP_AWK_OPT_NAMEDVAR) + + x = 10; // x is put into the global hash table. + + +Optimization + +constant folding + 2 * 10 => 20 + +loop + remove while (0) { ... } + +if + remove if (0) {} + use else_part only + diff --git a/ase/awk/awk_i.h b/ase/awk/awk_i.h new file mode 100644 index 00000000..8bfa1889 --- /dev/null +++ b/ase/awk/awk_i.h @@ -0,0 +1,338 @@ +/* + * $Id: awk_i.h,v 1.3 2007/04/30 05:47:33 bacon Exp $ + * + * {License} + */ + +#ifndef _ASE_AWK_AWKI_H_ +#define _ASE_AWK_AWKI_H_ + +#include +#include + +typedef struct ase_awk_chain_t ase_awk_chain_t; +typedef struct ase_awk_tree_t ase_awk_tree_t; + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef _MSC_VER +#pragma warning (disable: 4996) +#pragma warning (disable: 4296) +#endif + +#define ASE_AWK_MAX_GLOBALS 9999 +#define ASE_AWK_MAX_LOCALS 9999 +#define ASE_AWK_MAX_PARAMS 9999 + +#if defined(_WIN32) && defined(_MSC_VER) && defined(_DEBUG) + #define _CRTDBG_MAP_ALLOC + #include + + #define ASE_AWK_MALLOC(awk,size) malloc (size) + #define ASE_AWK_REALLOC(awk,ptr,size) realloc (ptr, size) + #define ASE_AWK_FREE(awk,ptr) free (ptr) +#else + #define ASE_AWK_MALLOC(awk,size) ASE_MALLOC(&(awk)->prmfns.mmgr,size) + #define ASE_AWK_REALLOC(awk,ptr,size) ASE_REALLOC(&(awk)->prmfns.mmgr,ptr,size) + #define ASE_AWK_FREE(awk,ptr) ASE_FREE(&(awk)->prmfns.mmgr,ptr) +#endif + +#define ASE_AWK_ISUPPER(awk,c) ASE_ISUPPER(&(awk)->prmfns.ccls,c) +#define ASE_AWK_ISLOWER(awk,c) ASE_ISLOWER(&(awk)->prmfns.ccls,c) +#define ASE_AWK_ISALPHA(awk,c) ASE_ISALPHA(&(awk)->prmfns.ccls,c) +#define ASE_AWK_ISDIGIT(awk,c) ASE_ISDIGIT(&(awk)->prmfns.ccls,c) +#define ASE_AWK_ISXDIGIT(awk,c) ASE_ISXDIGIT(&(awk)->prmfns.ccls,c) +#define ASE_AWK_ISALNUM(awk,c) ASE_ISALNUM(&(awk)->prmfns.ccls,c) +#define ASE_AWK_ISSPACE(awk,c) ASE_ISSPACE(&(awk)->prmfns.ccls,c) +#define ASE_AWK_ISPRINT(awk,c) ASE_ISPRINT(&(awk)->prmfns.ccls,c) +#define ASE_AWK_ISGRAPH(awk,c) ASE_ISGRAPH(&(awk)->prmfns.ccls,c) +#define ASE_AWK_ISCNTRL(awk,c) ASE_ISCNTRL(&(awk)->prmfns.ccls,c) +#define ASE_AWK_ISPUNCT(awk,c) ASE_ISPUNCT(&(awk)->prmfns.ccls,c) +#define ASE_AWK_TOUPPER(awk,c) ASE_TOUPPER(&(awk)->prmfns.ccls,c) +#define ASE_AWK_TOLOWER(awk,c) ASE_TOLOWER(&(awk)->prmfns.ccls,c) + +struct ase_awk_tree_t +{ + ase_size_t nglobals; /* total number of globals */ + ase_size_t nbglobals; /* number of builtin globals */ + ase_cstr_t cur_afn; + ase_awk_map_t afns; /* awk function map */ + ase_awk_nde_t* begin; + ase_awk_nde_t* end; + ase_awk_chain_t* chain; + ase_awk_chain_t* chain_tail; + ase_size_t chain_size; /* number of nodes in the chain */ + int ok; +}; + +struct ase_awk_t +{ + ase_awk_prmfns_t prmfns; + void* custom_data; + + /* options */ + int option; + + /* parse tree */ + ase_awk_tree_t tree; + + /* temporary information that the parser needs */ + struct + { + struct + { + int block; + int loop; + int stmnt; /* statement */ + } id; + + struct + { + struct + { + ase_size_t block; + ase_size_t loop; + ase_size_t expr; /* expression */ + } cur; + + struct + { + ase_size_t block; + ase_size_t expr; + } max; + } depth; + + ase_awk_tab_t globals; + ase_awk_tab_t locals; + ase_awk_tab_t params; + ase_size_t nlocals_max; + + ase_awk_nde_t* (*parse_block) ( + ase_awk_t*,ase_size_t,ase_bool_t); + } parse; + + /* source code management */ + struct + { + ase_awk_srcios_t ios; + + struct + { + ase_cint_t curc; + ase_cint_t ungotc[5]; + ase_size_t ungotc_line[5]; + ase_size_t ungotc_column[5]; + ase_size_t ungotc_count; + + ase_size_t line; + ase_size_t column; + } lex; + + struct + { + ase_char_t buf[512]; + ase_size_t buf_pos; + ase_size_t buf_len; + } shared; + } src; + + /* token */ + struct + { + struct + { + int type; + ase_size_t line; + ase_size_t column; + } prev; + + int type; + ase_str_t name; + ase_size_t line; + ase_size_t column; + } token; + + /* builtin functions */ + struct + { + ase_awk_bfn_t* sys; + ase_awk_bfn_t* user; + } bfn; + + struct + { + struct + { + struct + { + ase_size_t block; + ase_size_t expr; + } max; + } depth; + } run; + + struct + { + struct + { + struct + { + ase_size_t build; + ase_size_t match; + } max; + } depth; + } rex; + + struct + { + ase_char_t fmt[1024]; + } tmp; + + /* housekeeping */ + int errnum; + ase_size_t errlin; + ase_char_t errmsg[256]; + + ase_char_t* errstr[ASE_AWK_NUMERRNUM]; +}; + +struct ase_awk_chain_t +{ + ase_awk_nde_t* pattern; + ase_awk_nde_t* action; + ase_awk_chain_t* next; +}; + +struct ase_awk_run_t +{ + int id; + ase_awk_map_t named; + + void** stack; + ase_size_t stack_top; + ase_size_t stack_base; + ase_size_t stack_limit; + int exit_level; + + ase_awk_val_int_t* icache[200]; /* TODO: choose the optimal size */ + ase_awk_val_real_t* rcache[200]; /* TODO: choose the optimal size */ + ase_awk_val_ref_t* fcache[200]; /* TODO: choose the optimal size */ + ase_size_t icache_count; + ase_size_t rcache_count; + ase_size_t fcache_count; + + ase_awk_nde_blk_t* active_block; + ase_byte_t* pattern_range_state; + + struct + { + ase_char_t buf[1024]; + ase_size_t buf_pos; + ase_size_t buf_len; + ase_bool_t eof; + + ase_str_t line; + ase_awk_val_t* d0; /* $0 */ + + ase_size_t maxflds; + ase_size_t nflds; /* NF */ + struct + { + ase_char_t* ptr; + ase_size_t len; + ase_awk_val_t* val; /* $1 .. $NF */ + }* flds; + + } inrec; + + struct + { + void* rs; + void* fs; + int ignorecase; + ase_size_t fnr; + + struct + { + ase_char_t* ptr; + ase_size_t len; + } convfmt; + struct + { + ase_char_t* ptr; + ase_size_t len; + } ofmt; + struct + { + ase_char_t* ptr; + ase_size_t len; + } ofs; + struct + { + ase_char_t* ptr; + ase_size_t len; + } ors; + struct + { + ase_char_t* ptr; + ase_size_t len; + } subsep; + } global; + + /* extio chain */ + struct + { + ase_awk_io_t handler[ASE_AWK_EXTIO_NUM]; + void* custom_data; + ase_awk_extio_t* chain; + } extio; + + struct + { + ase_str_t fmt; + ase_str_t out; + + struct + { + ase_char_t* ptr; + ase_size_t len; /* length */ + ase_size_t inc; /* increment */ + } tmp; + } format; + + struct + { + struct + { + ase_size_t block; + ase_size_t expr; /* expression */ + } cur; + + struct + { + ase_size_t block; + ase_size_t expr; + } max; + } depth; + + int errnum; + ase_size_t errlin; + ase_char_t errmsg[256]; + + void* custom_data; + + ase_awk_t* awk; + ase_awk_runcbs_t* cbs; +}; + +#endif diff --git a/ase/awk/descrip.mms b/ase/awk/descrip.mms new file mode 100644 index 00000000..0623de56 --- /dev/null +++ b/ase/awk/descrip.mms @@ -0,0 +1,28 @@ +# +# OpenVMS MMS/MMK +# + +objects = awk.obj,err.obj,tree.obj,str.obj,tab.obj,map.obj,parse.obj,run.obj,rec.obj,val.obj,func.obj,misc.obj,extio.obj,rex.obj + +CFLAGS = /include="../.." +#CFLAGS = /pointer_size=long /include="../.." +LIBRFLAGS = + +aseawk.olb : $(objects) + $(LIBR)/create $(MMS$TARGET) $(objects) +# $(LIBR)/replace $(LIBRFLAGS) $(MMS$TARGET),$(objects) + +awk.obj depends_on awk.c +err.obj depends_on err.c +tree.obj depends_on tree.c +str.obj depends_on str.c +tab.obj depends_on tab.c +map.obj depends_on map.c +parse.obj depends_on parse.c +run.obj depends_on run.c +rec.obj depends_on rec.c +val.obj depends_on val.c +func.obj depends_on func.c +misc.obj depends_on misc.c +extio.obj depends_on extio.c +rex.obj depends_on rex.c diff --git a/ase/awk/err.c b/ase/awk/err.c new file mode 100644 index 00000000..91df8c14 --- /dev/null +++ b/ase/awk/err.c @@ -0,0 +1,466 @@ +/* + * $Id: err.c,v 1.3 2007/04/30 05:47:33 bacon Exp $ + * + * {License} + */ + +#include + +static const ase_char_t* __geterrstr (int errnum) +{ + static const ase_char_t* errstr[] = + { + ASE_T("no error"), + + ASE_T("invalid parameter"), + ASE_T("out of memory"), + ASE_T("not supported"), + ASE_T("operation not allowed"), + ASE_T("no such device"), + ASE_T("no space left on device"), + ASE_T("too many open files"), + ASE_T("too many links"), + ASE_T("resource temporarily unavailable"), + ASE_T("'%.*s' not existing"), + ASE_T("'%.*s' already exists"), + ASE_T("file or data too big"), + ASE_T("system too busy"), + ASE_T("is a directory"), + ASE_T("i/o error"), + + ASE_T("cannot open '%.*s'"), + ASE_T("cannot read '%.*s'"), + ASE_T("cannot write '%.*s'"), + ASE_T("cannot close '%.*s'"), + + ASE_T("internal error that should never have happened"), + ASE_T("general run-time error"), + ASE_T("block nested too deeply"), + ASE_T("expressio nested too deeply"), + + ASE_T("cannot open source input"), + ASE_T("cannot close source input"), + ASE_T("cannot read source input"), + + ASE_T("cannot open source output"), + ASE_T("cannot close source output"), + ASE_T("cannot write source output"), + + ASE_T("invalid character '%.*s'"), + ASE_T("cannot unget character"), + + ASE_T("unexpected end of source"), + ASE_T("a comment not closed properly"), + ASE_T("a string not closed with a quote"), + ASE_T("unexpected end of a regular expression"), + ASE_T("a left brace expected n place of '%.*s'"), + ASE_T("a left parenthesis expected in place of '%.*s'"), + ASE_T("a right parenthesis expected in place of '%.*s'"), + ASE_T("a right bracket expected in place of '%.*s'"), + ASE_T("a comma expected in place of '%.*s'"), + ASE_T("a semicolon expected in place of '%.*s'"), + ASE_T("a colon expected in place of '%.*s'"), + ASE_T("statement not ending with a semicolon"), + ASE_T("'in' expected in place of '%.*s'"), + ASE_T("right-hand side of the 'in' operator not a variable"), + ASE_T("invalid expression"), + + ASE_T("keyword 'while' expected in place of '%.*s'"), + ASE_T("invalid assignment statement"), + ASE_T("an identifier expected in place of '%.*s'"), + ASE_T("'%.*s' not a valid function name"), + ASE_T("BEGIN not followed by a left bracket on the same line"), + ASE_T("END not followed by a left bracket on the same line"), + ASE_T("duplicate BEGIN"), + ASE_T("duplicate END"), + ASE_T("built-in function '%.*s' redefined"), + ASE_T("function '%.*s' redefined"), + ASE_T("global variable '%.*s' redefined"), + ASE_T("parameter '%.*s' redefined"), + ASE_T("duplicate parameter name '%.*s'"), + ASE_T("duplicate global variable '%.*s'"), + ASE_T("duplicate local variable '%.*s'"), + ASE_T("'%.*s' not a valid parameter name"), + ASE_T("'%.*s' not a valid variable name"), + ASE_T("undefined identifier '%.*s'"), + ASE_T("l-value required"), + ASE_T("too many global variables"), + ASE_T("too many local variables"), + ASE_T("too many parameters"), + ASE_T("delete statement not followed by a normal variable"), + ASE_T("break statement outside a loop"), + ASE_T("continue statement outside a loop"), + ASE_T("next statement illegal in the BEGIN block"), + ASE_T("next statement illegal in the END block"), + ASE_T("nextfile statement illegal in the BEGIN block"), + ASE_T("nextfile statement illegal in the END block"), + ASE_T("printf not followed by any arguments"), + ASE_T("both prefix and postfix increment/decrement operator present"), + ASE_T("coprocess not supported by getline"), + + ASE_T("divide by zero"), + ASE_T("invalid operand"), + ASE_T("wrong position index"), + ASE_T("too few arguments"), + ASE_T("too many arguments"), + ASE_T("function '%.*s' not found"), + ASE_T("variable not indexable"), + ASE_T("variable '%.*s' not deletable"), + ASE_T("value not a map"), + ASE_T("right-hand side of the 'in' operator not a map"), + ASE_T("right-hand side of the 'in' operator not a map nor nil"), + ASE_T("value not referenceable"), + ASE_T("value not assignable"), + ASE_T("an indexed value cannot be assigned a map"), + ASE_T("a positional value cannot be assigned a map"), + ASE_T("map '%.*s' not assignable with a scalar"), + ASE_T("cannot change a scalar value to a map"), + ASE_T("a map is not allowed"), + ASE_T("invalid value type"), + ASE_T("delete statement called with a wrong target"), + ASE_T("next statement called from the BEGIN block"), + ASE_T("next statement called from the END block"), + ASE_T("nextfile statement called from the BEGIN block"), + ASE_T("nextfile statement called from the END block"), + ASE_T("wrong implementation of built-in function handler"), + ASE_T("built-in function handler returned an error"), + ASE_T("wrong implementation of user-defined io handler"), + ASE_T("no such io name found"), + ASE_T("i/o handler returned an error"), + ASE_T("i/o name empty"), + ASE_T("i/o name containing a null character"), + ASE_T("not sufficient arguments to formatting sequence"), + ASE_T("recursion detected in format conversion"), + ASE_T("invalid character in CONVFMT"), + ASE_T("invalid character in OFMT"), + + ASE_T("recursion too deep in the regular expression"), + ASE_T("a right parenthesis expected in the regular expression"), + ASE_T("a right bracket expected in the regular expression"), + ASE_T("a right brace expected in the regular expression"), + ASE_T("unbalanced parenthesis in the regular expression"), + ASE_T("a colon expected in the regular expression"), + ASE_T("invalid character range in the regular expression"), + ASE_T("invalid character class in the regular expression"), + ASE_T("invalid boundary range in the regular expression"), + ASE_T("unexpected end of the regular expression"), + ASE_T("garbage after the regular expression") + }; + + if (errnum >= 0 && errnum < ASE_COUNTOF(errstr)) + { + return errstr[errnum]; + } + + return ASE_T("unknown error"); +} + +const ase_char_t* ase_awk_geterrstr (ase_awk_t* awk, int num) +{ + if (awk != ASE_NULL && + awk->errstr[num] != ASE_NULL) return awk->errstr[num]; + return __geterrstr (num); +} + +int ase_awk_seterrstr (ase_awk_t* awk, int num, const ase_char_t* str) +{ + ase_char_t* dup; + + if (str == ASE_NULL) dup = ASE_NULL; + else + { + dup = ase_strdup (str, &awk->prmfns.mmgr); + if (dup == ASE_NULL) return -1; + } + + if (awk->errstr[num] != ASE_NULL) + ASE_AWK_FREE (awk, awk->errstr[num]); + + else awk->errstr[num] = dup; + return 0; +} + +int ase_awk_geterrnum (ase_awk_t* awk) +{ + return awk->errnum; +} + +ase_size_t ase_awk_geterrlin (ase_awk_t* awk) +{ + return awk->errlin; +} + +const ase_char_t* ase_awk_geterrmsg (ase_awk_t* awk) +{ + if (awk->errmsg[0] == ASE_T('\0')) + return ase_awk_geterrstr (awk, awk->errnum); + return awk->errmsg; +} + +void ase_awk_geterror ( + ase_awk_t* awk, int* errnum, + ase_size_t* errlin, const ase_char_t** errmsg) +{ + if (errnum != ASE_NULL) *errnum = awk->errnum; + if (errlin != ASE_NULL) *errlin = awk->errlin; + if (errmsg != ASE_NULL) + { + if (awk->errmsg[0] == ASE_T('\0')) + *errmsg = ase_awk_geterrstr (awk, awk->errnum); + else + *errmsg = awk->errmsg; + } +} + +void ase_awk_seterrnum (ase_awk_t* awk, int errnum) +{ + awk->errnum = errnum; + awk->errlin = 0; + awk->errmsg[0] = ASE_T('\0'); +} + +void ase_awk_seterror ( + ase_awk_t* awk, int errnum, ase_size_t errlin, + const ase_cstr_t* errarg, ase_size_t argcnt) +{ + const ase_char_t* errfmt; + ase_size_t fmtlen; + + ASE_ASSERT (argcnt <= 5); + + awk->errnum = errnum; + awk->errlin = errlin; + + errfmt = ase_awk_geterrstr (awk, errnum); + fmtlen = ase_strlen(errfmt); + + switch (argcnt) + { + case 0: + awk->prmfns.misc.sprintf ( + awk->prmfns.misc.custom_data, + awk->errmsg, + ASE_COUNTOF(awk->errmsg), + errfmt); + return; + + case 1: + { + ase_char_t tmp[ASE_COUNTOF(awk->errmsg)]; + ase_size_t len, tl; + + if (fmtlen < ASE_COUNTOF(awk->errmsg) && + errarg[0].len + fmtlen >= ASE_COUNTOF(awk->errmsg)) + { + len = ASE_COUNTOF(awk->errmsg) - fmtlen - 3 - 1; + tl = ase_strxncpy (tmp, ASE_COUNTOF(tmp), errarg[0].ptr, len); + tmp[tl] = ASE_T('.'); + tmp[tl+1] = ASE_T('.'); + tmp[tl+2] = ASE_T('.'); + len += 3; + } + else + { + len = errarg[0].len; + ase_strxncpy (tmp, ASE_COUNTOF(tmp), errarg[0].ptr, len); + } + + awk->prmfns.misc.sprintf ( + awk->prmfns.misc.custom_data, + awk->errmsg, + ASE_COUNTOF(awk->errmsg), + errfmt, len, tmp); + return; + } + + case 2: + awk->prmfns.misc.sprintf ( + awk->prmfns.misc.custom_data, + awk->errmsg, + ASE_COUNTOF(awk->errmsg), + errfmt, + errarg[0].len, errarg[0].ptr, + errarg[1].len, errarg[1].ptr); + return; + + case 3: + awk->prmfns.misc.sprintf ( + awk->prmfns.misc.custom_data, + awk->errmsg, + ASE_COUNTOF(awk->errmsg), + errfmt, + errarg[0].len, errarg[0].ptr, + errarg[1].len, errarg[1].ptr, + errarg[2].len, errarg[2].ptr); + return; + + case 4: + awk->prmfns.misc.sprintf ( + awk->prmfns.misc.custom_data, + awk->errmsg, + ASE_COUNTOF(awk->errmsg), + errfmt, + errarg[0].len, errarg[0].ptr, + errarg[1].len, errarg[1].ptr, + errarg[2].len, errarg[2].ptr, + errarg[3].len, errarg[3].ptr); + return; + + case 5: + awk->prmfns.misc.sprintf ( + awk->prmfns.misc.custom_data, + awk->errmsg, + ASE_COUNTOF(awk->errmsg), + errfmt, + errarg[0].len, errarg[0].ptr, + errarg[1].len, errarg[1].ptr, + errarg[2].len, errarg[2].ptr, + errarg[3].len, errarg[3].ptr, + errarg[4].len, errarg[4].ptr); + return; + } +} + +int ase_awk_getrunerrnum (ase_awk_run_t* run) +{ + return run->errnum; +} + +ase_size_t ase_awk_getrunerrlin (ase_awk_run_t* run) +{ + return run->errlin; +} + +const ase_char_t* ase_awk_getrunerrmsg (ase_awk_run_t* run) +{ + if (run->errmsg[0] == ASE_T('\0')) + return ase_awk_geterrstr (run->awk, run->errnum); + + return run->errmsg; +} + +void ase_awk_setrunerrnum (ase_awk_run_t* run, int errnum) +{ + run->errnum = errnum; + run->errlin = 0; + run->errmsg[0] = ASE_T('\0'); +} + +void ase_awk_getrunerror ( + ase_awk_run_t* run, int* errnum, + ase_size_t* errlin, const ase_char_t** errmsg) +{ + if (errnum != ASE_NULL) *errnum = run->errnum; + if (errlin != ASE_NULL) *errlin = run->errlin; + if (errmsg != ASE_NULL) + { + if (run->errmsg[0] == ASE_T('\0')) + *errmsg = ase_awk_geterrstr (run->awk, run->errnum); + else + *errmsg = run->errmsg; + } +} + +void ase_awk_setrunerror ( + ase_awk_run_t* run, int errnum, ase_size_t errlin, + const ase_cstr_t* errarg, ase_size_t argcnt) +{ + const ase_char_t* errfmt; + ase_size_t fmtlen; + + ASE_ASSERT (argcnt <= 5); + + run->errnum = errnum; + run->errlin = errlin; + + errfmt = ase_awk_geterrstr (run->awk, errnum); + fmtlen = ase_strlen (errfmt); + + switch (argcnt) + { + case 0: + /* TODO: convert % to %% if the original % is not + * the first % of the %% sequence */ + run->awk->prmfns.misc.sprintf ( + run->awk->prmfns.misc.custom_data, + run->errmsg, + ASE_COUNTOF(run->errmsg), + errfmt); + return; + + case 1: + { + ase_char_t tmp[ASE_COUNTOF(run->errmsg)]; + ase_size_t len, tl; + + if (fmtlen < ASE_COUNTOF(run->errmsg) && + errarg[0].len + fmtlen >= ASE_COUNTOF(run->errmsg)) + { + len = ASE_COUNTOF(run->errmsg) - fmtlen - 3 - 1; + tl = ase_strxncpy (tmp, ASE_COUNTOF(tmp), errarg[0].ptr, len); + tmp[tl] = ASE_T('.'); + tmp[tl+1] = ASE_T('.'); + tmp[tl+2] = ASE_T('.'); + len += 3; + } + else + { + len = errarg[0].len; + ase_strxncpy (tmp, ASE_COUNTOF(tmp), errarg[0].ptr, len); + } + + run->awk->prmfns.misc.sprintf ( + run->awk->prmfns.misc.custom_data, + run->errmsg, + ASE_COUNTOF(run->errmsg), + errfmt, len, tmp); + return; + } + + case 2: + run->awk->prmfns.misc.sprintf ( + run->awk->prmfns.misc.custom_data, + run->errmsg, + ASE_COUNTOF(run->errmsg), + errfmt, + errarg[0].len, errarg[0].ptr, + errarg[1].len, errarg[1].ptr); + return; + + case 3: + run->awk->prmfns.misc.sprintf ( + run->awk->prmfns.misc.custom_data, + run->errmsg, + ASE_COUNTOF(run->errmsg), + errfmt, + errarg[0].len, errarg[0].ptr, + errarg[1].len, errarg[1].ptr, + errarg[2].len, errarg[2].ptr); + return; + + case 4: + run->awk->prmfns.misc.sprintf ( + run->awk->prmfns.misc.custom_data, + run->errmsg, + ASE_COUNTOF(run->errmsg), + errfmt, + errarg[0].len, errarg[0].ptr, + errarg[1].len, errarg[1].ptr, + errarg[2].len, errarg[2].ptr, + errarg[3].len, errarg[3].ptr); + return; + + case 5: + run->awk->prmfns.misc.sprintf ( + run->awk->prmfns.misc.custom_data, + run->errmsg, + ASE_COUNTOF(run->errmsg), + errfmt, + errarg[0].len, errarg[0].ptr, + errarg[1].len, errarg[1].ptr, + errarg[2].len, errarg[2].ptr, + errarg[3].len, errarg[3].ptr, + errarg[4].len, errarg[4].ptr); + return; + } +} diff --git a/ase/awk/extio.c b/ase/awk/extio.c new file mode 100644 index 00000000..e942124e --- /dev/null +++ b/ase/awk/extio.c @@ -0,0 +1,951 @@ +/* + * $Id: extio.c,v 1.3 2007/04/30 05:47:33 bacon Exp $ + * + * {License} + */ + +#include + +enum +{ + MASK_READ = 0x0100, + MASK_WRITE = 0x0200, + MASK_RDWR = 0x0400, + + MASK_CLEAR = 0x00FF +}; + +static int in_type_map[] = +{ + /* the order should match the order of the + * ASE_AWK_IN_XXX values in tree.h */ + ASE_AWK_EXTIO_PIPE, + ASE_AWK_EXTIO_COPROC, + ASE_AWK_EXTIO_FILE, + ASE_AWK_EXTIO_CONSOLE +}; + +static int in_mode_map[] = +{ + /* the order should match the order of the + * ASE_AWK_IN_XXX values in tree.h */ + ASE_AWK_EXTIO_PIPE_READ, + 0, + ASE_AWK_EXTIO_FILE_READ, + ASE_AWK_EXTIO_CONSOLE_READ +}; + +static int in_mask_map[] = +{ + MASK_READ, + MASK_RDWR, + MASK_READ, + MASK_READ +}; + +static int out_type_map[] = +{ + /* the order should match the order of the + * ASE_AWK_OUT_XXX values in tree.h */ + ASE_AWK_EXTIO_PIPE, + ASE_AWK_EXTIO_COPROC, + ASE_AWK_EXTIO_FILE, + ASE_AWK_EXTIO_FILE, + ASE_AWK_EXTIO_CONSOLE +}; + +static int out_mode_map[] = +{ + /* the order should match the order of the + * ASE_AWK_OUT_XXX values in tree.h */ + ASE_AWK_EXTIO_PIPE_WRITE, + 0, + ASE_AWK_EXTIO_FILE_WRITE, + ASE_AWK_EXTIO_FILE_APPEND, + ASE_AWK_EXTIO_CONSOLE_WRITE +}; + +static int out_mask_map[] = +{ + MASK_WRITE, + MASK_RDWR, + MASK_WRITE, + MASK_WRITE, + MASK_WRITE +}; + +int ase_awk_readextio ( + ase_awk_run_t* run, int in_type, + const ase_char_t* name, ase_str_t* buf) +{ + ase_awk_extio_t* p = run->extio.chain; + ase_awk_io_t handler; + int extio_type, extio_mode, extio_mask, n, ret; + ase_awk_val_t* rs; + ase_char_t* rs_ptr; + ase_size_t rs_len; + ase_size_t line_len = 0; + ase_char_t c = ASE_T('\0'), pc; + + ASE_ASSERT (in_type >= 0 && in_type <= ASE_COUNTOF(in_type_map)); + ASE_ASSERT (in_type >= 0 && in_type <= ASE_COUNTOF(in_mode_map)); + ASE_ASSERT (in_type >= 0 && in_type <= ASE_COUNTOF(in_mask_map)); + + /* translate the in_type into the relevant extio type and mode */ + extio_type = in_type_map[in_type]; + extio_mode = in_mode_map[in_type]; + extio_mask = in_mask_map[in_type]; + + handler = run->extio.handler[extio_type]; + if (handler == ASE_NULL) + { + /* no io handler provided */ + ase_awk_setrunerrnum (run, ASE_AWK_EIOUSER); + return -1; + } + + while (p != ASE_NULL) + { + if (p->type == (extio_type | extio_mask) && + ase_strcmp (p->name,name) == 0) break; + p = p->next; + } + + if (p == ASE_NULL) + { + p = (ase_awk_extio_t*) ASE_AWK_MALLOC ( + run->awk, ASE_SIZEOF(ase_awk_extio_t)); + if (p == ASE_NULL) + { + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return -1; + } + + p->name = ase_strdup (name, &run->awk->prmfns.mmgr); + if (p->name == ASE_NULL) + { + ASE_AWK_FREE (run->awk, p); + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return -1; + } + + p->run = run; + p->type = (extio_type | extio_mask); + p->mode = extio_mode; + p->handle = ASE_NULL; + p->next = ASE_NULL; + p->custom_data = run->extio.custom_data; + + p->in.buf[0] = ASE_T('\0'); + p->in.pos = 0; + p->in.len = 0; + p->in.eof = ase_false; + p->in.eos = ase_false; + + ase_awk_setrunerrnum (run, ASE_AWK_ENOERR); + + n = handler (ASE_AWK_IO_OPEN, p, ASE_NULL, 0); + if (n <= -1) + { + ASE_AWK_FREE (run->awk, p->name); + ASE_AWK_FREE (run->awk, p); + + if (run->errnum == ASE_AWK_ENOERR) + { + /* if the error number has not been + * set by the user handler */ + ase_awk_setrunerrnum (run, ASE_AWK_EIOIMPL); + } + + return -1; + } + + /* chain it */ + p->next = run->extio.chain; + run->extio.chain = p; + + /* usually, n == 0 indicates that it has reached the end + * of the input. the user io handler can return 0 for the + * open request if it doesn't have any files to open. One + * advantage of doing this would be that you can skip the + * entire pattern-block matching and exeuction. */ + if (n == 0) + { + p->in.eos = ase_true; + return 0; + } + } + + if (p->in.eos) + { + /* no more streams. */ + return 0; + } + + /* ready to read a line */ + ase_str_clear (buf); + + /* get the record separator */ + rs = ase_awk_getglobal (run, ASE_AWK_GLOBAL_RS); + ase_awk_refupval (run, rs); + + if (rs->type == ASE_AWK_VAL_NIL) + { + rs_ptr = ASE_NULL; + rs_len = 0; + } + else if (rs->type == ASE_AWK_VAL_STR) + { + rs_ptr = ((ase_awk_val_str_t*)rs)->buf; + rs_len = ((ase_awk_val_str_t*)rs)->len; + } + else + { + rs_ptr = ase_awk_valtostr ( + run, rs, ASE_AWK_VALTOSTR_CLEAR, ASE_NULL, &rs_len); + if (rs_ptr == ASE_NULL) + { + ase_awk_refdownval (run, rs); + return -1; + } + } + + ret = 1; + + /* call the io handler */ + while (1) + { + if (p->in.pos >= p->in.len) + { + ase_ssize_t n; + + if (p->in.eof) + { + if (ASE_STR_LEN(buf) == 0) ret = 0; + break; + } + + ase_awk_setrunerrnum (run, ASE_AWK_ENOERR); + + n = handler (ASE_AWK_IO_READ, + p, p->in.buf, ASE_COUNTOF(p->in.buf)); + if (n <= -1) + { + if (run->errnum == ASE_AWK_ENOERR) + { + /* if the error number has not been + * set by the user handler */ + ase_awk_setrunerrnum (run, ASE_AWK_EIOIMPL); + } + + ret = -1; + break; + } + + if (n == 0) + { + p->in.eof = ase_true; + if (ASE_STR_LEN(buf) == 0) ret = 0; + break; + } + + p->in.len = n; + p->in.pos = 0; + } + + pc = c; + c = p->in.buf[p->in.pos++]; + + if (rs_ptr == ASE_NULL) + { + /* separate by a new line */ + if (c == ASE_T('\n')) + { + if (pc == ASE_T('\r') && + ASE_STR_LEN(buf) > 0) + { + ASE_STR_LEN(buf) -= 1; + } + break; + } + } + else if (rs_len == 0) + { + /* separate by a blank line */ + if (c == ASE_T('\n')) + { + if (pc == ASE_T('\r') && + ASE_STR_LEN(buf) > 0) + { + ASE_STR_LEN(buf) -= 1; + } + } + + if (line_len == 0 && c == ASE_T('\n')) + { + if (ASE_STR_LEN(buf) <= 0) + { + /* if the record is empty when a blank + * line is encountered, the line + * terminator should not be added to + * the record */ + continue; + } + + /* when a blank line is encountered, + * it needs to snip off the line + * terminator of the previous line */ + ASE_STR_LEN(buf) -= 1; + break; + } + } + else if (rs_len == 1) + { + if (c == rs_ptr[0]) break; + } + else + { + const ase_char_t* match_ptr; + ase_size_t match_len; + + ASE_ASSERT (run->global.rs != ASE_NULL); + + n = ase_awk_matchrex ( + run->awk, run->global.rs, + ((run->global.ignorecase)? ASE_AWK_REX_IGNORECASE: 0), + ASE_STR_BUF(buf), ASE_STR_LEN(buf), + &match_ptr, &match_len, &run->errnum); + if (n == -1) + { + ret = -1; + break; + } + + if (n == 1) + { + /* the match should be found at the end of + * the current buffer */ + ASE_ASSERT ( + ASE_STR_BUF(buf) + ASE_STR_LEN(buf) == + match_ptr + match_len); + + ASE_STR_LEN(buf) -= match_len; + break; + } + } + + if (ase_str_ccat (buf, c) == (ase_size_t)-1) + { + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + ret = -1; + break; + } + + /* TODO: handle different line terminator like \r\n */ + if (c == ASE_T('\n')) line_len = 0; + else line_len = line_len + 1; + } + + if (rs_ptr != ASE_NULL && + rs->type != ASE_AWK_VAL_STR) ASE_AWK_FREE (run->awk, rs_ptr); + ase_awk_refdownval (run, rs); + + /* increment NR */ + if (ret != -1 && ret != 0) + { + ase_awk_val_t* nr; + ase_long_t lv; + ase_real_t rv; + + nr = ase_awk_getglobal (run, ASE_AWK_GLOBAL_NR); + ase_awk_refupval (run, nr); + n = ase_awk_valtonum (run, nr, &lv, &rv); + ase_awk_refdownval (run, nr); + + if (n == -1) ret = -1; + else + { + if (n == 1) lv = (ase_long_t)rv; + + nr = ase_awk_makeintval (run, lv + 1); + if (nr == ASE_NULL) + { + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + ret = -1; + } + else + { + if (ase_awk_setglobal ( + run, ASE_AWK_GLOBAL_NR, nr) == -1) ret = -1; + } + } + } + + return ret; +} + +int ase_awk_writeextio_val ( + ase_awk_run_t* run, int out_type, + const ase_char_t* name, ase_awk_val_t* v) +{ + ase_char_t* str; + ase_size_t len; + int n; + + if (v->type == ASE_AWK_VAL_STR) + { + str = ((ase_awk_val_str_t*)v)->buf; + len = ((ase_awk_val_str_t*)v)->len; + } + else + { + str = ase_awk_valtostr ( + run, v, + ASE_AWK_VALTOSTR_CLEAR | ASE_AWK_VALTOSTR_PRINT, + ASE_NULL, &len); + if (str == ASE_NULL) return -1; + } + + n = ase_awk_writeextio_str (run, out_type, name, str, len); + + if (v->type != ASE_AWK_VAL_STR) ASE_AWK_FREE (run->awk, str); + return n; +} + +int ase_awk_writeextio_str ( + ase_awk_run_t* run, int out_type, + const ase_char_t* name, ase_char_t* str, ase_size_t len) +{ + ase_awk_extio_t* p = run->extio.chain; + ase_awk_io_t handler; + int extio_type, extio_mode, extio_mask, n; + + ASE_ASSERT (out_type >= 0 && out_type <= ASE_COUNTOF(out_type_map)); + ASE_ASSERT (out_type >= 0 && out_type <= ASE_COUNTOF(out_mode_map)); + ASE_ASSERT (out_type >= 0 && out_type <= ASE_COUNTOF(out_mask_map)); + + /* translate the out_type into the relevant extio type and mode */ + extio_type = out_type_map[out_type]; + extio_mode = out_mode_map[out_type]; + extio_mask = out_mask_map[out_type]; + + handler = run->extio.handler[extio_type]; + if (handler == ASE_NULL) + { + /* no io handler provided */ + ase_awk_setrunerrnum (run, ASE_AWK_EIOUSER); + return -1; + } + + /* look for the corresponding extio for name */ + while (p != ASE_NULL) + { + /* the file "1.tmp", in the following code snippets, + * would be opened by the first print statement, but not by + * the second print statement. this is because + * both ASE_AWK_OUT_FILE and ASE_AWK_OUT_FILE_APPEND are + * translated to ASE_AWK_EXTIO_FILE and it is used to + * keep track of file handles.. + * + * print "1111" >> "1.tmp" + * print "1111" > "1.tmp" + */ + if (p->type == (extio_type | extio_mask) && + ase_strcmp (p->name, name) == 0) break; + p = p->next; + } + + /* if there is not corresponding extio for name, create one */ + if (p == ASE_NULL) + { + p = (ase_awk_extio_t*) ASE_AWK_MALLOC ( + run->awk, ASE_SIZEOF(ase_awk_extio_t)); + if (p == ASE_NULL) + { + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return -1; + } + + p->name = ase_strdup (name, &run->awk->prmfns.mmgr); + if (p->name == ASE_NULL) + { + ASE_AWK_FREE (run->awk, p); + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return -1; + } + + p->run = run; + p->type = (extio_type | extio_mask); + p->mode = extio_mode; + p->handle = ASE_NULL; + p->next = ASE_NULL; + p->custom_data = run->extio.custom_data; + + p->out.eof = ase_false; + p->out.eos = ase_false; + + ase_awk_setrunerrnum (run, ASE_AWK_ENOERR); + n = handler (ASE_AWK_IO_OPEN, p, ASE_NULL, 0); + if (n <= -1) + { + ASE_AWK_FREE (run->awk, p->name); + ASE_AWK_FREE (run->awk, p); + + if (run->errnum == ASE_AWK_ENOERR) + ase_awk_setrunerrnum (run, ASE_AWK_EIOIMPL); + + return -1; + } + + /* chain it */ + p->next = run->extio.chain; + run->extio.chain = p; + + /* usually, n == 0 indicates that it has reached the end + * of the input. the user io handler can return 0 for the + * open request if it doesn't have any files to open. One + * advantage of doing this would be that you can skip the + * entire pattern-block matching and exeuction. */ + if (n == 0) + { + p->out.eos = ase_true; + return 0; + } + } + + if (p->out.eos) + { + /* no more streams */ + return 0; + } + + if (p->out.eof) + { + /* it has reached the end of the stream but this function + * has been recalled */ + return 0; + } + + while (len > 0) + { + ase_awk_setrunerrnum (run, ASE_AWK_ENOERR); + n = handler (ASE_AWK_IO_WRITE, p, str, len); + if (n <= -1) + { + if (run->errnum == ASE_AWK_ENOERR) + ase_awk_setrunerrnum (run, ASE_AWK_EIOIMPL); + + return -1; + } + + if (n == 0) + { + p->out.eof = ase_true; + return 0; + } + + len -= n; + str += n; + } + + return 1; +} + +int ase_awk_flushextio ( + ase_awk_run_t* run, int out_type, const ase_char_t* name) +{ + ase_awk_extio_t* p = run->extio.chain; + ase_awk_io_t handler; + int extio_type, /*extio_mode,*/ extio_mask, n; + ase_bool_t ok = ase_false; + + ASE_ASSERT (out_type >= 0 && out_type <= ASE_COUNTOF(out_type_map)); + ASE_ASSERT (out_type >= 0 && out_type <= ASE_COUNTOF(out_mode_map)); + ASE_ASSERT (out_type >= 0 && out_type <= ASE_COUNTOF(out_mask_map)); + + /* translate the out_type into the relevant extio type and mode */ + extio_type = out_type_map[out_type]; + /*extio_mode = out_mode_map[out_type];*/ + extio_mask = out_mask_map[out_type]; + + handler = run->extio.handler[extio_type]; + if (handler == ASE_NULL) + { + /* no io handler provided */ + ase_awk_setrunerrnum (run, ASE_AWK_EIOUSER); + return -1; + } + + /* look for the corresponding extio for name */ + while (p != ASE_NULL) + { + if (p->type == (extio_type | extio_mask) && + (name == ASE_NULL || ase_strcmp(p->name,name) == 0)) + { + ase_awk_setrunerrnum (run, ASE_AWK_ENOERR); + n = handler (ASE_AWK_IO_FLUSH, p, ASE_NULL, 0); + + if (n <= -1) + { + if (run->errnum == ASE_AWK_ENOERR) + ase_awk_setrunerrnum (run, ASE_AWK_EIOIMPL); + return -1; + } + + ok = ase_true; + } + + p = p->next; + } + + if (ok) return 0; + + /* there is no corresponding extio for name */ + ase_awk_setrunerrnum (run, ASE_AWK_EIONONE); + return -1; +} + +int ase_awk_nextextio_read ( + ase_awk_run_t* run, int in_type, const ase_char_t* name) +{ + ase_awk_extio_t* p = run->extio.chain; + ase_awk_io_t handler; + int extio_type, /*extio_mode,*/ extio_mask, n; + + ASE_ASSERT (in_type >= 0 && in_type <= ASE_COUNTOF(in_type_map)); + ASE_ASSERT (in_type >= 0 && in_type <= ASE_COUNTOF(in_mode_map)); + ASE_ASSERT (in_type >= 0 && in_type <= ASE_COUNTOF(in_mask_map)); + + /* translate the in_type into the relevant extio type and mode */ + extio_type = in_type_map[in_type]; + /*extio_mode = in_mode_map[in_type];*/ + extio_mask = in_mask_map[in_type]; + + handler = run->extio.handler[extio_type]; + if (handler == ASE_NULL) + { + /* no io handler provided */ + ase_awk_setrunerrnum (run, ASE_AWK_EIOUSER); + return -1; + } + + while (p != ASE_NULL) + { + if (p->type == (extio_type | extio_mask) && + ase_strcmp (p->name,name) == 0) break; + p = p->next; + } + + if (p == ASE_NULL) + { + /* something is totally wrong */ + ASE_ASSERT ( + !"should never happen - cannot find the relevant extio entry"); + ase_awk_setrunerror (run, ASE_AWK_EINTERN, 0, ASE_NULL, 0); + return -1; + } + + if (p->in.eos) + { + /* no more streams. */ + return 0; + } + + ase_awk_setrunerrnum (run, ASE_AWK_ENOERR); + n = handler (ASE_AWK_IO_NEXT, p, ASE_NULL, 0); + if (n <= -1) + { + if (run->errnum == ASE_AWK_ENOERR) + ase_awk_setrunerrnum (run, ASE_AWK_EIOIMPL); + return -1; + } + + if (n == 0) + { + /* the next stream cannot be opened. + * set the eos flags so that the next call to nextextio_read + * will return 0 without executing the handler */ + p->in.eos = ase_true; + } + else + { + /* as the next stream has been opened successfully, + * the eof flag should be cleared if set */ + p->in.eof = ase_false; + + /* also the previous input buffer must be reset */ + p->in.pos = 0; + p->in.len = 0; + } + + return n; +} + +int ase_awk_nextextio_write ( + ase_awk_run_t* run, int out_type, const ase_char_t* name) +{ + ase_awk_extio_t* p = run->extio.chain; + ase_awk_io_t handler; + int extio_type, /*extio_mode,*/ extio_mask, n; + + ASE_ASSERT (out_type >= 0 && out_type <= ASE_COUNTOF(out_type_map)); + ASE_ASSERT (out_type >= 0 && out_type <= ASE_COUNTOF(out_mode_map)); + ASE_ASSERT (out_type >= 0 && out_type <= ASE_COUNTOF(out_mask_map)); + + /* translate the out_type into the relevant extio type and mode */ + extio_type = out_type_map[out_type]; + /*extio_mode = out_mode_map[out_type];*/ + extio_mask = out_mask_map[out_type]; + + handler = run->extio.handler[extio_type]; + if (handler == ASE_NULL) + { + /* no io handler provided */ + ase_awk_setrunerrnum (run, ASE_AWK_EIOUSER); + return -1; + } + + while (p != ASE_NULL) + { + if (p->type == (extio_type | extio_mask) && + ase_strcmp (p->name,name) == 0) break; + p = p->next; + } + + if (p == ASE_NULL) + { + /* something is totally wrong */ + ASE_ASSERT (!"should never happen - cannot find the relevant extio entry"); + + ase_awk_setrunerror (run, ASE_AWK_EINTERN, 0, ASE_NULL, 0); + return -1; + } + + if (p->out.eos) + { + /* no more streams. */ + return 0; + } + + ase_awk_setrunerrnum (run, ASE_AWK_ENOERR); + n = handler (ASE_AWK_IO_NEXT, p, ASE_NULL, 0); + if (n <= -1) + { + if (run->errnum == ASE_AWK_ENOERR) + ase_awk_setrunerrnum (run, ASE_AWK_EIOIMPL); + return -1; + } + + if (n == 0) + { + /* the next stream cannot be opened. + * set the eos flags so that the next call to nextextio_write + * will return 0 without executing the handler */ + p->out.eos = ase_true; + } + else + { + /* as the next stream has been opened successfully, + * the eof flag should be cleared if set */ + p->out.eof = ase_false; + } + + return n; +} + +int ase_awk_closeextio_read ( + ase_awk_run_t* run, int in_type, const ase_char_t* name) +{ + ase_awk_extio_t* p = run->extio.chain, * px = ASE_NULL; + ase_awk_io_t handler; + int extio_type, /*extio_mode,*/ extio_mask; + + ASE_ASSERT (in_type >= 0 && in_type <= ASE_COUNTOF(in_type_map)); + ASE_ASSERT (in_type >= 0 && in_type <= ASE_COUNTOF(in_mode_map)); + ASE_ASSERT (in_type >= 0 && in_type <= ASE_COUNTOF(in_mask_map)); + + /* translate the in_type into the relevant extio type and mode */ + extio_type = in_type_map[in_type]; + /*extio_mode = in_mode_map[in_type];*/ + extio_mask = in_mask_map[in_type]; + + handler = run->extio.handler[extio_type]; + if (handler == ASE_NULL) + { + /* no io handler provided */ + ase_awk_setrunerrnum (run, ASE_AWK_EIOUSER); + return -1; + } + + while (p != ASE_NULL) + { + if (p->type == (extio_type | extio_mask) && + ase_strcmp (p->name, name) == 0) + { + ase_awk_io_t handler; + + handler = run->extio.handler[p->type & MASK_CLEAR]; + if (handler != ASE_NULL) + { + if (handler (ASE_AWK_IO_CLOSE, p, ASE_NULL, 0) <= -1) + { + /* this is not a run-time error.*/ + ase_awk_setrunerror (run, ASE_AWK_EIOIMPL, 0, ASE_NULL, 0); + return -1; + } + } + + if (px != ASE_NULL) px->next = p->next; + else run->extio.chain = p->next; + + ASE_AWK_FREE (run->awk, p->name); + ASE_AWK_FREE (run->awk, p); + return 0; + } + + px = p; + p = p->next; + } + + /* the name given is not found */ + ase_awk_setrunerrnum (run, ASE_AWK_EIONONE); + return -1; +} + +int ase_awk_closeextio_write ( + ase_awk_run_t* run, int out_type, const ase_char_t* name) +{ + ase_awk_extio_t* p = run->extio.chain, * px = ASE_NULL; + ase_awk_io_t handler; + int extio_type, /*extio_mode,*/ extio_mask; + + ASE_ASSERT (out_type >= 0 && out_type <= ASE_COUNTOF(out_type_map)); + ASE_ASSERT (out_type >= 0 && out_type <= ASE_COUNTOF(out_mode_map)); + ASE_ASSERT (out_type >= 0 && out_type <= ASE_COUNTOF(out_mask_map)); + + /* translate the out_type into the relevant extio type and mode */ + extio_type = out_type_map[out_type]; + /*extio_mode = out_mode_map[out_type];*/ + extio_mask = out_mask_map[out_type]; + + handler = run->extio.handler[extio_type]; + if (handler == ASE_NULL) + { + /* no io handler provided */ + ase_awk_setrunerror (run, ASE_AWK_EIOUSER, 0, ASE_NULL, 0); + return -1; + } + + while (p != ASE_NULL) + { + if (p->type == (extio_type | extio_mask) && + ase_strcmp (p->name, name) == 0) + { + ase_awk_io_t handler; + + handler = run->extio.handler[p->type & MASK_CLEAR]; + if (handler != ASE_NULL) + { + ase_awk_setrunerrnum (run, ASE_AWK_ENOERR); + if (handler (ASE_AWK_IO_CLOSE, p, ASE_NULL, 0) <= -1) + { + if (run->errnum == ASE_AWK_ENOERR) + ase_awk_setrunerrnum (run, ASE_AWK_EIOIMPL); + return -1; + } + } + + if (px != ASE_NULL) px->next = p->next; + else run->extio.chain = p->next; + + ASE_AWK_FREE (run->awk, p->name); + ASE_AWK_FREE (run->awk, p); + return 0; + } + + px = p; + p = p->next; + } + + ase_awk_setrunerrnum (run, ASE_AWK_EIONONE); + return -1; +} + +int ase_awk_closeextio (ase_awk_run_t* run, const ase_char_t* name) +{ + ase_awk_extio_t* p = run->extio.chain, * px = ASE_NULL; + + while (p != ASE_NULL) + { + /* it handles the first that matches the given name + * regardless of the extio type */ + if (ase_strcmp (p->name, name) == 0) + { + ase_awk_io_t handler; + + handler = run->extio.handler[p->type & MASK_CLEAR]; + if (handler != ASE_NULL) + { + ase_awk_setrunerrnum (run, ASE_AWK_ENOERR); + if (handler (ASE_AWK_IO_CLOSE, p, ASE_NULL, 0) <= -1) + { + /* this is not a run-time error.*/ + if (run->errnum == ASE_AWK_ENOERR) + ase_awk_setrunerrnum (run, ASE_AWK_EIOIMPL); + return -1; + } + } + + if (px != ASE_NULL) px->next = p->next; + else run->extio.chain = p->next; + + ASE_AWK_FREE (run->awk, p->name); + ASE_AWK_FREE (run->awk, p); + + return 0; + } + + px = p; + p = p->next; + } + + ase_awk_setrunerrnum (run, ASE_AWK_EIONONE); + return -1; +} + +void ase_awk_clearextio (ase_awk_run_t* run) +{ + ase_awk_extio_t* next; + ase_awk_io_t handler; + int n; + + while (run->extio.chain != ASE_NULL) + { + handler = run->extio.handler[ + run->extio.chain->type & MASK_CLEAR]; + next = run->extio.chain->next; + + if (handler != ASE_NULL) + { + ase_awk_setrunerrnum (run, ASE_AWK_ENOERR); + n = handler (ASE_AWK_IO_CLOSE, run->extio.chain, ASE_NULL, 0); + if (n <= -1) + { + if (run->errnum == ASE_AWK_ENOERR) + ase_awk_setrunerrnum (run, ASE_AWK_EIOIMPL); + /* TODO: some warnings need to be shown??? */ + } + } + + ASE_AWK_FREE (run->awk, run->extio.chain->name); + ASE_AWK_FREE (run->awk, run->extio.chain); + + run->extio.chain = next; + } +} diff --git a/ase/awk/extio.h b/ase/awk/extio.h new file mode 100644 index 00000000..7fc04e1c --- /dev/null +++ b/ase/awk/extio.h @@ -0,0 +1,51 @@ +/* + * $Id: extio.h,v 1.3 2007/04/30 05:47:33 bacon Exp $ + * + * {License} + */ + +#ifndef _ASE_AWK_EXTIO_H_ +#define _ASE_AWK_EXTIO_H_ + +#ifndef _ASE_AWK_AWK_H_ +#error Never include this file directly. Include instead +#endif + +#ifdef __cplusplus +extern "C" +#endif + +int ase_awk_readextio ( + ase_awk_run_t* run, int in_type, + const ase_char_t* name, ase_str_t* buf); + +int ase_awk_writeextio_val ( + ase_awk_run_t* run, int out_type, + const ase_char_t* name, ase_awk_val_t* v); + +int ase_awk_writeextio_str ( + ase_awk_run_t* run, int out_type, + const ase_char_t* name, ase_char_t* str, ase_size_t len); + +int ase_awk_flushextio ( + ase_awk_run_t* run, int out_type, const ase_char_t* name); + +int ase_awk_nextextio_read ( + ase_awk_run_t* run, int in_type, const ase_char_t* name); + +int ase_awk_nextextio_write ( + ase_awk_run_t* run, int out_type, const ase_char_t* name); + +int ase_awk_closeextio_read ( + ase_awk_run_t* run, int in_type, const ase_char_t* name); +int ase_awk_closeextio_write ( + ase_awk_run_t* run, int out_type, const ase_char_t* name); +int ase_awk_closeextio (ase_awk_run_t* run, const ase_char_t* name); + +void ase_awk_clearextio (ase_awk_run_t* run); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ase/awk/func.c b/ase/awk/func.c new file mode 100644 index 00000000..e762fdc6 --- /dev/null +++ b/ase/awk/func.c @@ -0,0 +1,1364 @@ +/* + * $Id: func.c,v 1.3 2007/04/30 05:47:33 bacon Exp $ + * + * {License} + */ + +#include + +static int __bfn_close (ase_awk_run_t*, const ase_char_t*, ase_size_t); +static int __bfn_fflush (ase_awk_run_t*, const ase_char_t*, ase_size_t); +static int __bfn_index (ase_awk_run_t*, const ase_char_t*, ase_size_t); +static int __bfn_length (ase_awk_run_t*, const ase_char_t*, ase_size_t); +static int __bfn_substr (ase_awk_run_t*, const ase_char_t*, ase_size_t); +static int __bfn_split (ase_awk_run_t*, const ase_char_t*, ase_size_t); +static int __bfn_tolower (ase_awk_run_t*, const ase_char_t*, ase_size_t); +static int __bfn_toupper (ase_awk_run_t*, const ase_char_t*, ase_size_t); +static int __bfn_gsub (ase_awk_run_t*, const ase_char_t*, ase_size_t); +static int __bfn_sub (ase_awk_run_t*, const ase_char_t*, ase_size_t); +static int __bfn_match (ase_awk_run_t*, const ase_char_t*, ase_size_t); +static int __bfn_sprintf (ase_awk_run_t*, const ase_char_t*, ase_size_t); + +#undef MAX +#define MAX ASE_TYPE_UNSIGNED_MAX(ase_size_t) + +static ase_awk_bfn_t __sys_bfn[] = +{ + /* io functions */ + { {ASE_T("close"), 5}, ASE_AWK_EXTIO, {1, 1, ASE_NULL}, __bfn_close}, + { {ASE_T("fflush"), 6}, ASE_AWK_EXTIO, {0, 1, ASE_NULL}, __bfn_fflush}, + + /* string functions */ + { {ASE_T("index"), 5}, 0, {2, 2, ASE_NULL}, __bfn_index}, + { {ASE_T("substr"), 6}, 0, {2, 3, ASE_NULL}, __bfn_substr}, + { {ASE_T("length"), 6}, 0, {1, 1, ASE_NULL}, __bfn_length}, + { {ASE_T("split"), 5}, 0, {2, 3, ASE_T("vrv")}, __bfn_split}, + { {ASE_T("tolower"), 7}, 0, {1, 1, ASE_NULL}, __bfn_tolower}, + { {ASE_T("toupper"), 7}, 0, {1, 1, ASE_NULL}, __bfn_toupper}, + { {ASE_T("gsub"), 4}, 0, {2, 3, ASE_T("xvr")}, __bfn_gsub}, + { {ASE_T("sub"), 3}, 0, {2, 3, ASE_T("xvr")}, __bfn_sub}, + { {ASE_T("match"), 5}, 0, {2, 2, ASE_T("vx")}, __bfn_match}, + { {ASE_T("sprintf"), 7}, 0, {1, MAX, ASE_NULL}, __bfn_sprintf}, + + { {ASE_NULL, 0}, 0, {0, 0, ASE_NULL}, ASE_NULL} +}; + +void* ase_awk_addbfn ( + ase_awk_t* awk, const ase_char_t* name, ase_size_t name_len, + int when_valid, ase_size_t min_args, ase_size_t max_args, + const ase_char_t* arg_spec, + int (*handler)(ase_awk_run_t*,const ase_char_t*,ase_size_t)) +{ + ase_awk_bfn_t* p; + + if (ase_awk_getbfn (awk, name, name_len) != ASE_NULL) + { + ase_cstr_t errarg; + + errarg.ptr = name; + errarg.len = name_len; + + ase_awk_seterror (awk, ASE_AWK_EEXIST, 0, &errarg, 1); + return ASE_NULL; + } + + p = (ase_awk_bfn_t*) ASE_AWK_MALLOC (awk, ASE_SIZEOF(ase_awk_bfn_t)); + if (p == ASE_NULL) + { + ase_awk_seterror (awk, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return ASE_NULL; + } + + p->name.ptr = ase_strxdup (name, name_len, &awk->prmfns.mmgr); + if (p->name.ptr == ASE_NULL) + { + ASE_AWK_FREE (awk, p); + ase_awk_seterror (awk, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return ASE_NULL; + } + + p->name.len = name_len; + p->valid = when_valid; + p->arg.min = min_args; + p->arg.max = max_args; + if (arg_spec == ASE_NULL) p->arg.spec = ASE_NULL; + else + { + p->arg.spec = ase_strdup (arg_spec, &awk->prmfns.mmgr); + if (p->arg.spec == ASE_NULL) + { + ASE_AWK_FREE (awk, p->name.ptr); + ASE_AWK_FREE (awk, p); + ase_awk_seterror (awk, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return ASE_NULL; + } + } + p->handler = handler; + + p->next = awk->bfn.user; + awk->bfn.user = p; + + return p; +} + +int ase_awk_delbfn (ase_awk_t* awk, const ase_char_t* name, ase_size_t name_len) +{ + ase_awk_bfn_t* p, * pp = ASE_NULL; + ase_cstr_t errarg; + + for (p = awk->bfn.user; p != ASE_NULL; p = p->next) + { + if (ase_strxncmp ( + p->name.ptr, p->name.len, name, name_len) == 0) + { + if (pp == ASE_NULL) + awk->bfn.user = p->next; + else pp->next = p->next; + + if (p->arg.spec != ASE_NULL) + ASE_AWK_FREE (awk, p->arg.spec); + ASE_AWK_FREE (awk, p->name.ptr); + ASE_AWK_FREE (awk, p); + return 0; + } + + pp = p; + } + + errarg.ptr = name; + errarg.len = name_len; + + ase_awk_seterror (awk, ASE_AWK_ENOENT, 0, &errarg, 1); + return -1; +} + +void ase_awk_clrbfn (ase_awk_t* awk) +{ + ase_awk_bfn_t* p, * np; + + p = awk->bfn.user; + while (p != ASE_NULL) + { + np = p->next; + if (p->arg.spec != ASE_NULL) + ASE_AWK_FREE (awk, p->arg.spec); + ASE_AWK_FREE (awk, p->name.ptr); + ASE_AWK_FREE (awk, p); + p = np; + } + + awk->bfn.user = ASE_NULL; +} + +ase_awk_bfn_t* ase_awk_getbfn ( + ase_awk_t* awk, const ase_char_t* name, ase_size_t len) +{ + ase_awk_bfn_t* p; + + for (p = __sys_bfn; p->name.ptr != ASE_NULL; p++) + { + if (p->valid != 0 && + (awk->option & p->valid) == 0) continue; + + if (ase_strxncmp ( + p->name.ptr, p->name.len, name, len) == 0) return p; + } + + for (p = awk->bfn.user; p != ASE_NULL; p = p->next) + { + if (p->valid != 0 && + (awk->option & p->valid) == 0) continue; + + if (ase_strxncmp ( + p->name.ptr, p->name.len, name, len) == 0) return p; + } + + return ASE_NULL; +} + +static int __bfn_close ( + ase_awk_run_t* run, const ase_char_t* fnm, ase_size_t fnl) +{ + ase_size_t nargs; + ase_awk_val_t* v, * a0; + int n; + + ase_char_t* name; + ase_size_t len; + + nargs = ase_awk_getnargs (run); + ASE_ASSERT (nargs == 1); +/* TODO: support close (xxx, "to"/"from") like gawk */ + + a0 = ase_awk_getarg (run, 0); + ASE_ASSERT (a0 != ASE_NULL); + + if (a0->type == ASE_AWK_VAL_STR) + { + name = ((ase_awk_val_str_t*)a0)->buf; + len = ((ase_awk_val_str_t*)a0)->len; + } + else + { + name = ase_awk_valtostr ( + run, a0, ASE_AWK_VALTOSTR_CLEAR, ASE_NULL, &len); + if (name == ASE_NULL) return -1; + } + + if (len == 0) + { + /* getline or print doesn't allow an emptry for the + * input or output file name. so close should not allow + * it either. + * another reason for this is if close is called explicitly + * with an empty string, it may close the console that uses + * an empty string for its identification because closeextio + * closes any extios that match the name given unlike + * closeextio_read or closeextio_write. */ + if (a0->type != ASE_AWK_VAL_STR) ASE_AWK_FREE (run->awk, name); + n = -1; + goto skip_close; + } + + while (len > 0) + { + if (name[--len] == ASE_T('\0')) + { + /* the name contains a null string. + * make close return -1 */ + if (a0->type != ASE_AWK_VAL_STR) + ASE_AWK_FREE (run->awk, name); + n = -1; + goto skip_close; + } + } + + n = ase_awk_closeextio (run, name); + /* + if (n == -1 && run->errnum != ASE_AWK_EIONONE) + { + if (a0->type != ASE_AWK_VAL_STR) + ASE_AWK_FREE (run->awk, name); + return -1; + } + */ + + if (a0->type != ASE_AWK_VAL_STR) ASE_AWK_FREE (run->awk, name); + +skip_close: + v = ase_awk_makeintval (run, (ase_long_t)n); + if (v == ASE_NULL) + { + ase_awk_setrunerrnum (run, ASE_AWK_ENOMEM); + return -1; + } + + ase_awk_setretval (run, v); + return 0; +} + +static int __flush_extio ( + ase_awk_run_t* run, int extio, const ase_char_t* name, int n) +{ + int n2; + + if (run->extio.handler[extio] != ASE_NULL) + { + n2 = ase_awk_flushextio (run, extio, name); + if (n2 == -1) + { + /* + if (run->errnum == ASE_AWK_EIOIMPL) n = -1; + else if (run->errnum == ASE_AWK_EIONONE) + { + if (n != 0) n = -2; + } + else n = -99; + */ + if (run->errnum == ASE_AWK_EIONONE) + { + if (n != 0) n = -2; + } + else n = -1; + } + else if (n != -1) n = 0; + } + + return n; +} + +static int __bfn_fflush ( + ase_awk_run_t* run, const ase_char_t* fnm, ase_size_t fnl) +{ + ase_size_t nargs; + ase_awk_val_t* a0; + ase_char_t* str0; + ase_size_t len0; + int n; + + nargs = ase_awk_getnargs (run); + ASE_ASSERT (nargs == 0 || nargs == 1); + + if (nargs == 0) + { + /* flush the console output. + * fflush() should return -1 on errors */ + n = ase_awk_flushextio (run, ASE_AWK_OUT_CONSOLE, ASE_T("")); + } + else + { + ase_char_t* ptr, * end; + + a0 = ase_awk_getarg (run, 0); + if (a0->type == ASE_AWK_VAL_STR) + { + str0 = ((ase_awk_val_str_t*)a0)->buf; + len0 = ((ase_awk_val_str_t*)a0)->len; + } + else + { + str0 = ase_awk_valtostr ( + run, a0, ASE_AWK_VALTOSTR_CLEAR, ASE_NULL, &len0); + if (str0 == ASE_NULL) return -1; + + } + + /* the target name contains a null character. + * make fflush return -1 */ + ptr = str0; end = str0 + len0; + while (ptr < end) + { + if (*ptr == ASE_T('\0')) + { + if (a0->type != ASE_AWK_VAL_STR) + ASE_AWK_FREE (run->awk, str0); + n = -1; + goto skip_flush; + } + + ptr++; + } + + /* flush the given extio */ + n = __flush_extio ( + run, ASE_AWK_EXTIO_FILE, + ((len0 == 0)? ASE_NULL: str0), 1); + /*if (n == -99) return -1;*/ + n = __flush_extio ( + run, ASE_AWK_EXTIO_PIPE, + ((len0 == 0)? ASE_NULL: str0), n); + /*if (n == -99) return -1;*/ + n = __flush_extio ( + run, ASE_AWK_EXTIO_COPROC, + ((len0 == 0)? ASE_NULL: str0), n); + /*if (n == -99) return -1;*/ + + /* if n remains 1, no ip handlers have been defined for + * file, pipe, and coproc. so make fflush return -1. + * if n is -2, no such named io has been found at all + * if n is -1, the io handler has returned an error */ + if (n != 0) n = -1; + + if (a0->type != ASE_AWK_VAL_STR) ASE_AWK_FREE (run->awk, str0); + } + +skip_flush: + a0 = ase_awk_makeintval (run, (ase_long_t)n); + if (a0 == ASE_NULL) + { + ase_awk_setrunerrnum (run, ASE_AWK_ENOMEM); + return -1; + } + + ase_awk_setretval (run, a0); + return 0; +} + +static int __bfn_index ( + ase_awk_run_t* run, const ase_char_t* fnm, ase_size_t fnl) +{ + ase_size_t nargs; + ase_awk_val_t* a0, * a1; + ase_char_t* str0, * str1, * ptr; + ase_size_t len0, len1; + ase_long_t idx; + + nargs = ase_awk_getnargs (run); + ASE_ASSERT (nargs == 2); + + a0 = ase_awk_getarg (run, 0); + a1 = ase_awk_getarg (run, 1); + + if (a0->type == ASE_AWK_VAL_STR) + { + str0 = ((ase_awk_val_str_t*)a0)->buf; + len0 = ((ase_awk_val_str_t*)a0)->len; + } + else + { + str0 = ase_awk_valtostr ( + run, a0, ASE_AWK_VALTOSTR_CLEAR, ASE_NULL, &len0); + if (str0 == ASE_NULL) return -1; + } + + if (a1->type == ASE_AWK_VAL_STR) + { + str1 = ((ase_awk_val_str_t*)a1)->buf; + len1 = ((ase_awk_val_str_t*)a1)->len; + } + else + { + str1 = ase_awk_valtostr ( + run, a1, ASE_AWK_VALTOSTR_CLEAR, ASE_NULL, &len1); + if (str1 == ASE_NULL) + { + if (a0->type != ASE_AWK_VAL_STR) + ASE_AWK_FREE (run->awk, str0); + return -1; + } + } + + ptr = ase_strxnstr (str0, len0, str1, len1); + idx = (ptr == ASE_NULL)? -1: (ase_long_t)(ptr - str0); + + if (ase_awk_getoption(run->awk) & ASE_AWK_STRBASEONE) idx = idx + 1; + + if (a0->type != ASE_AWK_VAL_STR) ASE_AWK_FREE (run->awk, str0); + if (a1->type != ASE_AWK_VAL_STR) ASE_AWK_FREE (run->awk, str1); + + a0 = ase_awk_makeintval (run, idx); + if (a0 == ASE_NULL) + { + ase_awk_setrunerrnum (run, ASE_AWK_ENOMEM); + return -1; + } + + ase_awk_setretval (run, a0); + return 0; +} + +static int __bfn_length ( + ase_awk_run_t* run, const ase_char_t* fnm, ase_size_t fnl) +{ + ase_size_t nargs; + ase_awk_val_t* v; + ase_char_t* str; + ase_size_t len; + + nargs = ase_awk_getnargs (run); + ASE_ASSERT (nargs == 1); + + v = ase_awk_getarg (run, 0); + if (v->type == ASE_AWK_VAL_STR) + { + len = ((ase_awk_val_str_t*)v)->len; + } + else + { + str = ase_awk_valtostr ( + run, v, ASE_AWK_VALTOSTR_CLEAR, ASE_NULL, &len); + if (str == ASE_NULL) return -1; + ASE_AWK_FREE (run->awk, str); + } + + v = ase_awk_makeintval (run, len); + if (v == ASE_NULL) + { + ase_awk_setrunerrnum (run, ASE_AWK_ENOMEM); + return -1; + } + + ase_awk_setretval (run, v); + return 0; +} + +static int __bfn_substr ( + ase_awk_run_t* run, const ase_char_t* fnm, ase_size_t fnl) +{ + ase_size_t nargs; + ase_awk_val_t* a0, * a1, * a2, * r; + ase_char_t* str; + ase_size_t len; + ase_long_t lindex, lcount; + ase_real_t rindex, rcount; + int n; + + nargs = ase_awk_getnargs (run); + ASE_ASSERT (nargs >= 2 && nargs <= 3); + + a0 = ase_awk_getarg (run, 0); + a1 = ase_awk_getarg (run, 1); + a2 = (nargs >= 3)? ase_awk_getarg (run, 2): ASE_NULL; + + if (a0->type == ASE_AWK_VAL_STR) + { + str = ((ase_awk_val_str_t*)a0)->buf; + len = ((ase_awk_val_str_t*)a0)->len; + } + else + { + str = ase_awk_valtostr ( + run, a0, ASE_AWK_VALTOSTR_CLEAR, ASE_NULL, &len); + if (str == ASE_NULL) return -1; + } + + n = ase_awk_valtonum (run, a1, &lindex, &rindex); + if (n == -1) + { + if (a0->type != ASE_AWK_VAL_STR) ASE_AWK_FREE (run->awk, str); + return -1; + } + if (n == 1) lindex = (ase_long_t)rindex; + + if (a2 == ASE_NULL) lcount = (ase_long_t)len; + else + { + n = ase_awk_valtonum (run, a2, &lcount, &rcount); + if (n == -1) + { + if (a0->type != ASE_AWK_VAL_STR) + ASE_AWK_FREE (run->awk, str); + return -1; + } + if (n == 1) lcount = (ase_long_t)rcount; + } + + if (ase_awk_getoption(run->awk) & ASE_AWK_STRBASEONE) lindex = lindex - 1; + if (lindex >= len) lindex = len; + else if (lindex < 0) lindex = 0; + + if (lcount < 0) lcount = 0; + else if (lcount > len - lindex) lcount = len - lindex; + + r = ase_awk_makestrval (run, &str[lindex], (ase_size_t)lcount); + if (r == ASE_NULL) + { + if (a0->type != ASE_AWK_VAL_STR) ASE_AWK_FREE (run->awk, str); + ase_awk_setrunerrnum (run, ASE_AWK_ENOMEM); + return -1; + } + + if (a0->type != ASE_AWK_VAL_STR) ASE_AWK_FREE (run->awk, str); + ase_awk_setretval (run, r); + return 0; +} + +static int __bfn_split ( + ase_awk_run_t* run, const ase_char_t* fnm, ase_size_t fnl) +{ + ase_size_t nargs; + ase_awk_val_t* a0, * a1, * a2, * t1, * t2, ** a1_ref; + ase_char_t* str, * str_free, * p, * tok; + ase_size_t str_len, str_left, tok_len; + ase_long_t sta, num; + ase_char_t key[ASE_SIZEOF(ase_long_t)*8+2]; + ase_size_t key_len; + ase_char_t* fs_ptr, * fs_free; + ase_size_t fs_len; + void* fs_rex = ASE_NULL; + void* fs_rex_free = ASE_NULL; + int errnum; + + nargs = ase_awk_getnargs (run); + ASE_ASSERT (nargs >= 2 && nargs <= 3); + + a0 = ase_awk_getarg (run, 0); + a1 = ase_awk_getarg (run, 1); + a2 = (nargs >= 3)? ase_awk_getarg (run, 2): ASE_NULL; + + ASE_ASSERT (a1->type == ASE_AWK_VAL_REF); + + if (((ase_awk_val_ref_t*)a1)->id >= ASE_AWK_VAL_REF_NAMEDIDX && + ((ase_awk_val_ref_t*)a1)->id <= ASE_AWK_VAL_REF_ARGIDX) + { + /* an indexed value should not be assigned another map */ + ase_awk_setrunerrnum (run, ASE_AWK_EIDXVALASSMAP); + return -1; + } + + if (((ase_awk_val_ref_t*)a1)->id == ASE_AWK_VAL_REF_POS) + { + /* a positional should not be assigned a map */ + ase_awk_setrunerrnum (run, ASE_AWK_EPOSVALASSMAP); + return -1; + } + + a1_ref = (ase_awk_val_t**)((ase_awk_val_ref_t*)a1)->adr; + if ((*a1_ref)->type != ASE_AWK_VAL_NIL && + (*a1_ref)->type != ASE_AWK_VAL_MAP) + { + /* cannot change a scalar value to a map */ + ase_awk_setrunerrnum (run, ASE_AWK_ESCALARTOMAP); + return -1; + } + + if (a0->type == ASE_AWK_VAL_STR) + { + str = ((ase_awk_val_str_t*)a0)->buf; + str_len = ((ase_awk_val_str_t*)a0)->len; + str_free = ASE_NULL; + } + else + { + str = ase_awk_valtostr ( + run, a0, ASE_AWK_VALTOSTR_CLEAR, ASE_NULL, &str_len); + if (str == ASE_NULL) return -1; + str_free = str; + } + + if (a2 == ASE_NULL) + { + /* get the value from FS */ + t1 = ase_awk_getglobal (run, ASE_AWK_GLOBAL_FS); + if (t1->type == ASE_AWK_VAL_NIL) + { + fs_ptr = ASE_T(" "); + fs_len = 1; + fs_free = ASE_NULL; + } + else if (t1->type == ASE_AWK_VAL_STR) + { + fs_ptr = ((ase_awk_val_str_t*)t1)->buf; + fs_len = ((ase_awk_val_str_t*)t1)->len; + fs_free = ASE_NULL; + } + else + { + fs_ptr = ase_awk_valtostr ( + run, t1, ASE_AWK_VALTOSTR_CLEAR, ASE_NULL, &fs_len); + if (fs_ptr == ASE_NULL) + { + if (str_free != ASE_NULL) + ASE_AWK_FREE (run->awk, str_free); + return -1; + } + fs_free = fs_ptr; + } + + if (fs_len > 1) + { + fs_rex = run->global.fs; + fs_rex_free = ASE_NULL; + } + } + else + { + if (a2->type == ASE_AWK_VAL_STR) + { + fs_ptr = ((ase_awk_val_str_t*)a2)->buf; + fs_len = ((ase_awk_val_str_t*)a2)->len; + fs_free = ASE_NULL; + } + else + { + fs_ptr = ase_awk_valtostr ( + run, a2, ASE_AWK_VALTOSTR_CLEAR, ASE_NULL, &fs_len); + if (fs_ptr == ASE_NULL) + { + if (str_free != ASE_NULL) + ASE_AWK_FREE (run->awk, str_free); + return -1; + } + fs_free = fs_ptr; + } + + if (fs_len > 1) + { + fs_rex = ase_awk_buildrex ( + run->awk, fs_ptr, fs_len, &errnum); + if (fs_rex == ASE_NULL) + { + if (str_free != ASE_NULL) + ASE_AWK_FREE (run->awk, str_free); + if (fs_free != ASE_NULL) + ASE_AWK_FREE (run->awk, fs_free); + ase_awk_setrunerrnum (run, errnum); + return -1; + } + fs_rex_free = fs_rex; + } + } + + t1 = ase_awk_makemapval (run); + if (t1 == ASE_NULL) + { + if (str_free != ASE_NULL) + ASE_AWK_FREE (run->awk, str_free); + if (fs_free != ASE_NULL) + ASE_AWK_FREE (run->awk, fs_free); + if (fs_rex_free != ASE_NULL) + ase_awk_freerex (run->awk, fs_rex_free); + ase_awk_setrunerrnum (run, ASE_AWK_ENOMEM); + return -1; + } + + ase_awk_refdownval (run, *a1_ref); + *a1_ref = t1; + ase_awk_refupval (run, *a1_ref); + + p = str; str_left = str_len; + sta = (ase_awk_getoption(run->awk) & ASE_AWK_STRBASEONE)? 1: 0; + num = sta; + + while (p != ASE_NULL) + { + if (fs_len <= 1) + { + p = ase_awk_strxntok (run, + p, str_len, fs_ptr, fs_len, &tok, &tok_len); + } + else + { + p = ase_awk_strxntokbyrex (run, p, str_len, + fs_rex, &tok, &tok_len, &errnum); + if (p == ASE_NULL && errnum != ASE_AWK_ENOERR) + { + if (str_free != ASE_NULL) + ASE_AWK_FREE (run->awk, str_free); + if (fs_free != ASE_NULL) + ASE_AWK_FREE (run->awk, fs_free); + if (fs_rex_free != ASE_NULL) + ase_awk_freerex (run->awk, fs_rex_free); + ase_awk_setrunerrnum (run, errnum); + return -1; + } + } + + if (num == 0 && p == ASE_NULL && tok_len == 0) + { + /* no field at all*/ + break; + } + + ASE_ASSERT ( + (tok != ASE_NULL && tok_len > 0) || tok_len == 0); + + /* create the field string */ + t2 = ase_awk_makestrval (run, tok, tok_len); + if (t2 == ASE_NULL) + { + if (str_free != ASE_NULL) + ASE_AWK_FREE (run->awk, str_free); + if (fs_free != ASE_NULL) + ASE_AWK_FREE (run->awk, fs_free); + if (fs_rex_free != ASE_NULL) + ase_awk_freerex (run->awk, fs_rex_free); + ase_awk_setrunerrnum (run, ASE_AWK_ENOMEM); + return -1; + } + + /* put it into the map */ + key_len = ase_awk_longtostr ( + num, 10, ASE_NULL, key, ASE_COUNTOF(key)); + ASE_ASSERT (key_len != (ase_size_t)-1); + + /* don't forget to update the reference count when you + * handle the assignment-like situation. anyway, it is + * incremented in advance as if the assignment was successful. + * it is decremented if the assignement fails. */ + ase_awk_refupval (run, t2); + + if (ase_awk_map_putx ( + ((ase_awk_val_map_t*)t1)->map, + key, key_len, t2, ASE_NULL) == -1) + { + ase_awk_refdownval (run, t2); + + if (str_free != ASE_NULL) + ASE_AWK_FREE (run->awk, str_free); + if (fs_free != ASE_NULL) + ASE_AWK_FREE (run->awk, fs_free); + if (fs_rex_free != ASE_NULL) + ase_awk_freerex (run->awk, fs_rex_free); + ase_awk_setrunerrnum (run, ASE_AWK_ENOMEM); + return -1; + } + + num++; + str_len = str_left - (p - str); + } + + if (str_free != ASE_NULL) ASE_AWK_FREE (run->awk, str_free); + if (fs_free != ASE_NULL) ASE_AWK_FREE (run->awk, fs_free); + if (fs_rex_free != ASE_NULL) ase_awk_freerex (run->awk, fs_rex_free); + + if (sta == 1) num--; + + t1 = ase_awk_makeintval (run, num); + if (t1 == ASE_NULL) + { + ase_awk_setrunerrnum (run, ASE_AWK_ENOMEM); + return -1; + } + + ase_awk_setretval (run, t1); + return 0; +} + +static int __bfn_tolower ( + ase_awk_run_t* run, const ase_char_t* fnm, ase_size_t fnl) +{ + ase_size_t nargs; + ase_char_t* str; + ase_size_t len, i; + ase_awk_val_t* a0, * r; + + nargs = ase_awk_getnargs (run); + ASE_ASSERT (nargs == 1); + + a0 = ase_awk_getarg (run, 0); + + if (a0->type == ASE_AWK_VAL_STR) + { + str = ((ase_awk_val_str_t*)a0)->buf; + len = ((ase_awk_val_str_t*)a0)->len; + } + else + { + str = ase_awk_valtostr ( + run, a0, ASE_AWK_VALTOSTR_CLEAR, ASE_NULL, &len); + if (str == ASE_NULL) return -1; + } + + for (i = 0; i < len; i++) str[i] = ASE_AWK_TOLOWER (run->awk, str[i]); + + r = ase_awk_makestrval (run, str, len); + if (r == ASE_NULL) + { + if (a0->type != ASE_AWK_VAL_STR) ASE_AWK_FREE (run->awk, str); + ase_awk_setrunerrnum (run, ASE_AWK_ENOMEM); + return -1; + } + + if (a0->type != ASE_AWK_VAL_STR) ASE_AWK_FREE (run->awk, str); + ase_awk_setretval (run, r); + return 0; +} + +static int __bfn_toupper ( + ase_awk_run_t* run, const ase_char_t* fnm, ase_size_t fnl) +{ + ase_size_t nargs; + ase_char_t* str; + ase_size_t len, i; + ase_awk_val_t* a0, * r; + + nargs = ase_awk_getnargs (run); + ASE_ASSERT (nargs == 1); + + a0 = ase_awk_getarg (run, 0); + + if (a0->type == ASE_AWK_VAL_STR) + { + str = ((ase_awk_val_str_t*)a0)->buf; + len = ((ase_awk_val_str_t*)a0)->len; + } + else + { + str = ase_awk_valtostr ( + run, a0, ASE_AWK_VALTOSTR_CLEAR, ASE_NULL, &len); + if (str == ASE_NULL) return -1; + } + + for (i = 0; i < len; i++) str[i] = ASE_AWK_TOUPPER (run->awk, str[i]); + + r = ase_awk_makestrval (run, str, len); + if (r == ASE_NULL) + { + if (a0->type != ASE_AWK_VAL_STR) ASE_AWK_FREE (run->awk, str); + ase_awk_setrunerrnum (run, ASE_AWK_ENOMEM); + return -1; + } + + if (a0->type != ASE_AWK_VAL_STR) ASE_AWK_FREE (run->awk, str); + ase_awk_setretval (run, r); + return 0; +} + +static int __substitute (ase_awk_run_t* run, ase_long_t max_count) +{ + ase_size_t nargs; + ase_awk_val_t* a0, * a1, * a2, ** a2_ref, * v; + ase_char_t* a0_ptr, * a1_ptr, * a2_ptr; + ase_size_t a0_len, a1_len, a2_len; + ase_char_t* a0_ptr_free = ASE_NULL; + ase_char_t* a1_ptr_free = ASE_NULL; + ase_char_t* a2_ptr_free = ASE_NULL; + void* rex = ASE_NULL; + int opt, n; + const ase_char_t* cur_ptr, * mat_ptr; + ase_size_t cur_len, mat_len, i, m; + ase_str_t new; + ase_long_t sub_count; + + nargs = ase_awk_getnargs (run); + ASE_ASSERT (nargs >= 2 && nargs <= 3); + + a0 = ase_awk_getarg (run, 0); + a1 = ase_awk_getarg (run, 1); + a2 = (nargs >= 3)? ase_awk_getarg (run, 2): ASE_NULL; + + ASE_ASSERT (a2 == ASE_NULL || a2->type == ASE_AWK_VAL_REF); + +#define FREE_A_PTRS(awk) \ + do { \ + if (a2_ptr_free != ASE_NULL) ASE_AWK_FREE (awk, a2_ptr_free); \ + if (a1_ptr_free != ASE_NULL) ASE_AWK_FREE (awk, a1_ptr_free); \ + if (a0_ptr_free != ASE_NULL) ASE_AWK_FREE (awk, a0_ptr_free); \ + } while (0) +#define FREE_A0_REX(awk,rex) \ + do { \ + if (a0->type != ASE_AWK_VAL_REX) ase_awk_freerex (awk, rex); \ + } while (0) + + if (a0->type == ASE_AWK_VAL_REX) + { + rex = ((ase_awk_val_rex_t*)a0)->code; + } + else if (a0->type == ASE_AWK_VAL_STR) + { + a0_ptr = ((ase_awk_val_str_t*)a0)->buf; + a0_len = ((ase_awk_val_str_t*)a0)->len; + } + else + { + a0_ptr = ase_awk_valtostr ( + run, a0, ASE_AWK_VALTOSTR_CLEAR, ASE_NULL, &a0_len); + if (a0_ptr == ASE_NULL) + { + FREE_A_PTRS (run->awk); + return -1; + } + a0_ptr_free = a0_ptr; + } + + if (a1->type == ASE_AWK_VAL_STR) + { + a1_ptr = ((ase_awk_val_str_t*)a1)->buf; + a1_len = ((ase_awk_val_str_t*)a1)->len; + } + else + { + a1_ptr = ase_awk_valtostr ( + run, a1, ASE_AWK_VALTOSTR_CLEAR, ASE_NULL, &a1_len); + if (a1_ptr == ASE_NULL) + { + FREE_A_PTRS (run->awk); + return -1; + } + a1_ptr_free = a1_ptr; + } + + if (a2 == ASE_NULL) + { + /* is this correct? any needs to use inrec.d0? */ + a2_ptr = ASE_STR_BUF(&run->inrec.line); + a2_len = ASE_STR_LEN(&run->inrec.line); + } + else if (((ase_awk_val_ref_t*)a2)->id == ASE_AWK_VAL_REF_POS) + { + ase_size_t idx; + + idx = (ase_size_t)((ase_awk_val_ref_t*)a2)->adr; + if (idx == 0) + { + a2_ptr = ASE_STR_BUF(&run->inrec.line); + a2_len = ASE_STR_LEN(&run->inrec.line); + } + else if (idx <= run->inrec.nflds) + { + a2_ptr = run->inrec.flds[idx-1].ptr; + a2_len = run->inrec.flds[idx-1].len; + } + else + { + a2_ptr = ASE_T(""); + a2_len = 0; + } + } + else + { + a2_ref = (ase_awk_val_t**)((ase_awk_val_ref_t*)a2)->adr; + + if ((*a2_ref)->type == ASE_AWK_VAL_MAP) + { + FREE_A_PTRS (run->awk); + /* a map is not allowed as the third parameter */ + ase_awk_setrunerrnum (run, ASE_AWK_EMAPNOTALLOWED); + return -1; + } + + if ((*a2_ref)->type == ASE_AWK_VAL_STR) + { + a2_ptr = ((ase_awk_val_str_t*)(*a2_ref))->buf; + a2_len = ((ase_awk_val_str_t*)(*a2_ref))->len; + } + else + { + a2_ptr = ase_awk_valtostr ( + run, *a2_ref, ASE_AWK_VALTOSTR_CLEAR, ASE_NULL, &a2_len); + if (a2_ptr == ASE_NULL) + { + FREE_A_PTRS (run->awk); + return -1; + } + a2_ptr_free = a2_ptr; + } + } + + if (ase_str_open (&new, a2_len, &run->awk->prmfns.mmgr) == ASE_NULL) + { + FREE_A_PTRS (run->awk); + ase_awk_setrunerrnum (run, ASE_AWK_ENOMEM); + return -1; + } + + if (a0->type != ASE_AWK_VAL_REX) + { + rex = ase_awk_buildrex (run->awk, a0_ptr, a0_len, &run->errnum); + if (rex == ASE_NULL) + { + ase_str_close (&new); + FREE_A_PTRS (run->awk); + return -1; + } + } + + opt = (run->global.ignorecase)? ASE_AWK_REX_IGNORECASE: 0; + cur_ptr = a2_ptr; + cur_len = a2_len; + sub_count = 0; + + while (1) + { + if (max_count == 0 || sub_count < max_count) + { + n = ase_awk_matchrex ( + run->awk, rex, opt, cur_ptr, cur_len, + &mat_ptr, &mat_len, &run->errnum); + } + else n = 0; + + if (n == -1) + { + FREE_A0_REX (run->awk, rex); + ase_str_close (&new); + FREE_A_PTRS (run->awk); + return -1; + } + + if (n == 0) + { + /* no more match found */ + if (ase_str_ncat ( + &new, cur_ptr, cur_len) == (ase_size_t)-1) + { + FREE_A0_REX (run->awk, rex); + ase_str_close (&new); + FREE_A_PTRS (run->awk); + return -1; + } + break; + } + + if (ase_str_ncat ( + &new, cur_ptr, mat_ptr - cur_ptr) == (ase_size_t)-1) + { + FREE_A0_REX (run->awk, rex); + ase_str_close (&new); + FREE_A_PTRS (run->awk); + return -1; + } + + for (i = 0; i < a1_len; i++) + { + if ((i+1) < a1_len && + a1_ptr[i] == ASE_T('\\') && + a1_ptr[i+1] == ASE_T('&')) + { + m = ase_str_ccat (&new, ASE_T('&')); + i++; + } + else if (a1_ptr[i] == ASE_T('&')) + { + m = ase_str_ncat (&new, mat_ptr, mat_len); + } + else + { + m = ase_str_ccat (&new, a1_ptr[i]); + } + + if (m == (ase_size_t)-1) + { + FREE_A0_REX (run->awk, rex); + ase_str_close (&new); + FREE_A_PTRS (run->awk); + return -1; + } + } + + sub_count++; + cur_len = cur_len - ((mat_ptr - cur_ptr) + mat_len); + cur_ptr = mat_ptr + mat_len; + } + + FREE_A0_REX (run->awk, rex); + + if (sub_count > 0) + { + if (a2 == ASE_NULL) + { + if (ase_awk_setrec (run, 0, + ASE_STR_BUF(&new), ASE_STR_LEN(&new)) == -1) + { + ase_str_close (&new); + FREE_A_PTRS (run->awk); + return -1; + } + } + else if (((ase_awk_val_ref_t*)a2)->id == ASE_AWK_VAL_REF_POS) + { + int n; + + n = ase_awk_setrec ( + run, (ase_size_t)((ase_awk_val_ref_t*)a2)->adr, + ASE_STR_BUF(&new), ASE_STR_LEN(&new)); + + if (n == -1) + { + ase_str_close (&new); + FREE_A_PTRS (run->awk); + return -1; + } + } + else + { + v = ase_awk_makestrval (run, + ASE_STR_BUF(&new), ASE_STR_LEN(&new)); + if (v == ASE_NULL) + { + ase_str_close (&new); + FREE_A_PTRS (run->awk); + return -1; + } + + ase_awk_refdownval (run, *a2_ref); + *a2_ref = v; + ase_awk_refupval (run, *a2_ref); + } + } + + ase_str_close (&new); + FREE_A_PTRS (run->awk); + +#undef FREE_A0_REX +#undef FREE_A_PTRS + + v = ase_awk_makeintval (run, sub_count); + if (v == ASE_NULL) + { + ase_awk_setrunerrnum (run, ASE_AWK_ENOMEM); + return -1; + } + + ase_awk_setretval (run, v); + return 0; +} + +static int __bfn_gsub ( + ase_awk_run_t* run, const ase_char_t* fnm, ase_size_t fnl) +{ + return __substitute (run, 0); +} + +static int __bfn_sub ( + ase_awk_run_t* run, const ase_char_t* fnm, ase_size_t fnl) +{ + return __substitute (run, 1); +} + +static int __bfn_match ( + ase_awk_run_t* run, const ase_char_t* fnm, ase_size_t fnl) +{ + ase_size_t nargs; + ase_awk_val_t* a0, * a1; + ase_char_t* str0, * str1; + ase_size_t len0, len1; + ase_long_t idx; + void* rex; + int opt, n; + const ase_char_t* mat_ptr; + ase_size_t mat_len; + + nargs = ase_awk_getnargs (run); + ASE_ASSERT (nargs == 2); + + a0 = ase_awk_getarg (run, 0); + a1 = ase_awk_getarg (run, 1); + + if (a0->type == ASE_AWK_VAL_STR) + { + str0 = ((ase_awk_val_str_t*)a0)->buf; + len0 = ((ase_awk_val_str_t*)a0)->len; + } + else + { + str0 = ase_awk_valtostr ( + run, a0, ASE_AWK_VALTOSTR_CLEAR, ASE_NULL, &len0); + if (str0 == ASE_NULL) return -1; + } + + if (a1->type == ASE_AWK_VAL_REX) + { + rex = ((ase_awk_val_rex_t*)a1)->code; + } + else + { + if (a1->type == ASE_AWK_VAL_STR) + { + str1 = ((ase_awk_val_str_t*)a1)->buf; + len1 = ((ase_awk_val_str_t*)a1)->len; + } + else + { + str1 = ase_awk_valtostr ( + run, a1, ASE_AWK_VALTOSTR_CLEAR, ASE_NULL, &len1); + if (str1 == ASE_NULL) + { + if (a0->type != ASE_AWK_VAL_STR) + ASE_AWK_FREE (run->awk, str0); + return -1; + } + } + + rex = ase_awk_buildrex (run->awk, str1, len1, &run->errnum); + if (rex == ASE_NULL) + { + if (a0->type != ASE_AWK_VAL_STR) + ASE_AWK_FREE (run->awk, str0); + return -1; + } + + if (a1->type != ASE_AWK_VAL_STR) ASE_AWK_FREE (run->awk, str1); + } + + opt = (run->global.ignorecase)? ASE_AWK_REX_IGNORECASE: 0; + n = ase_awk_matchrex ( + run->awk, rex, opt, str0, len0, + &mat_ptr, &mat_len, &run->errnum); + + if (a0->type != ASE_AWK_VAL_STR) ASE_AWK_FREE (run->awk, str0); + if (a1->type != ASE_AWK_VAL_REX) ase_awk_freerex (run->awk, rex); + + if (n == -1) return -1; + + idx = (n == 0)? -1: (ase_long_t)(mat_ptr - str0); + if (ase_awk_getoption(run->awk) & ASE_AWK_STRBASEONE) idx = idx + 1; + + a0 = ase_awk_makeintval (run, idx); + if (a0 == ASE_NULL) + { + ase_awk_setrunerrnum (run, ASE_AWK_ENOMEM); + return -1; + } + + ase_awk_refupval (run, a0); + + a1 = ase_awk_makeintval (run, + ((n == 0)? (ase_long_t)-1: (ase_long_t)mat_len)); + if (a1 == ASE_NULL) + { + ase_awk_refdownval (run, a0); + ase_awk_setrunerrnum (run, ASE_AWK_ENOMEM); + return -1; + } + + ase_awk_refupval (run, a1); + + if (ase_awk_setglobal (run, ASE_AWK_GLOBAL_RSTART, a0) == -1) + { + ase_awk_refdownval (run, a1); + ase_awk_refdownval (run, a0); + return -1; + } + + if (ase_awk_setglobal (run, ASE_AWK_GLOBAL_RLENGTH, a1) == -1) + { + ase_awk_refdownval (run, a1); + ase_awk_refdownval (run, a0); + return -1; + } + + ase_awk_setretval (run, a0); + + ase_awk_refdownval (run, a1); + ase_awk_refdownval (run, a0); + return 0; +} + +static int __bfn_sprintf ( + ase_awk_run_t* run, const ase_char_t* fnm, ase_size_t fnl) +{ + ase_size_t nargs; + ase_awk_val_t* a0; + ase_char_t* str0, * ptr; + ase_size_t len0, len; + ase_str_t out, fbu; + + nargs = ase_awk_getnargs (run); + ASE_ASSERT (nargs > 0); + + if (ase_str_open (&out, 256, &run->awk->prmfns.mmgr) == ASE_NULL) + { + ase_awk_setrunerrnum (run, ASE_AWK_ENOMEM); + return -1; + } + if (ase_str_open (&fbu, 256, &run->awk->prmfns.mmgr) == ASE_NULL) + { + ase_str_close (&out); + ase_awk_setrunerrnum (run, ASE_AWK_ENOMEM); + return -1; + } + + a0 = ase_awk_getarg (run, 0); + if (a0->type == ASE_AWK_VAL_STR) + { + str0 = ((ase_awk_val_str_t*)a0)->buf; + len0 = ((ase_awk_val_str_t*)a0)->len; + } + else + { + str0 = ase_awk_valtostr ( + run, a0, ASE_AWK_VALTOSTR_CLEAR, ASE_NULL, &len0); + if (str0 == ASE_NULL) + { + ase_str_close (&fbu); + ase_str_close (&out); + return -1; + } + } + + ptr = ase_awk_format (run, + &out, &fbu, str0, len0, nargs, ASE_NULL, &len); + if (a0->type != ASE_AWK_VAL_STR) ASE_AWK_FREE (run->awk, str0); + if (ptr == ASE_NULL) + { + ase_str_close (&fbu); + ase_str_close (&out); + return -1; + } + + a0 = ase_awk_makestrval_nodup (run, ptr, len); + if (a0 == ASE_NULL) + { + ase_str_close (&fbu); + ase_str_close (&out); + ase_awk_setrunerrnum (run, ASE_AWK_ENOMEM); + return -1; + } + + ase_str_close (&fbu); + ase_str_forfeit (&out); + ase_awk_setretval (run, a0); + return 0; +} diff --git a/ase/awk/func.h b/ase/awk/func.h new file mode 100644 index 00000000..edefa60a --- /dev/null +++ b/ase/awk/func.h @@ -0,0 +1,49 @@ +/* + * $Id: func.h,v 1.3 2007/04/30 05:47:33 bacon Exp $ + * + * {License} + */ + +#ifndef _ASE_AWK_FUNC_H_ +#define _ASE_AWK_FUNC_H_ + +#ifndef _ASE_AWK_AWK_H_ +#error Never include this file directly. Include instead +#endif + +typedef struct ase_awk_bfn_t ase_awk_bfn_t; + +struct ase_awk_bfn_t +{ + struct + { + ase_char_t* ptr; + ase_size_t len; + } name; + + int valid; /* the entry is valid when this option is set */ + + struct + { + ase_size_t min; + ase_size_t max; + ase_char_t* spec; + } arg; + + int (*handler) (ase_awk_run_t*, const ase_char_t*, ase_size_t); + + ase_awk_bfn_t* next; +}; + +#ifdef __cplusplus +extern "C" { +#endif + +ase_awk_bfn_t* ase_awk_getbfn ( + ase_awk_t* awk, const ase_char_t* name, ase_size_t len); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ase/awk/jni.c b/ase/awk/jni.c new file mode 100644 index 00000000..6f5215e8 --- /dev/null +++ b/ase/awk/jni.c @@ -0,0 +1,2350 @@ +/* + * $Id: jni.c,v 1.3 2007/04/30 05:47:33 bacon Exp $ + * + * {License} + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#ifdef _WIN32 +#include +#include +#endif + +#ifndef ASE_CHAR_IS_WCHAR + #error this module supports ASE_CHAR_IS_WCHAR only +#endif + +#define CLASS_OUTOFMEMORYERROR "java/lang/OutOfMemoryError" +#define CLASS_EXCEPTION "ase/awk/Exception" +#define CLASS_EXTIO "ase/awk/Extio" +#define FIELD_HANDLE "handle" + +#define MSG_SIZE 256 + +enum +{ + SOURCE_READ = 1, + SOURCE_WRITE = 2 +}; + +static ase_ssize_t __read_source ( + int cmd, void* arg, ase_char_t* data, ase_size_t count); +static ase_ssize_t __write_source ( + int cmd, void* arg, ase_char_t* data, ase_size_t count); +static ase_ssize_t __process_extio ( + int cmd, void* arg, ase_char_t* data, ase_size_t count); + +typedef struct awk_data_t awk_data_t; +typedef struct srcio_data_t srcio_data_t; +typedef struct runio_data_t runio_data_t; +typedef struct run_data_t run_data_t; + +struct awk_data_t +{ + int debug; +}; + +struct srcio_data_t +{ + JNIEnv* env; + jobject obj; +}; + +struct runio_data_t +{ + JNIEnv* env; + jobject obj; +}; + +struct run_data_t +{ + JNIEnv* env; + jobject obj; + + jclass string_class; + jclass integer_class; + jclass long_class; + jclass short_class; + jclass float_class; + jclass double_class; + jclass object_class; + + jmethodID integer_init; + jmethodID long_init; + jmethodID short_init; + jmethodID float_init; + jmethodID double_init; + + jmethodID integer_value; + jmethodID long_value; + jmethodID short_value; + jmethodID float_value; + jmethodID double_value; +}; + +static void* awk_malloc (void* custom, ase_size_t n) +{ + return malloc (n); +} + +static void* awk_realloc (void* custom, void* ptr, ase_size_t n) +{ + return realloc (ptr, n); +} + +static void awk_free (void* custom, void* ptr) +{ + free (ptr); +} + +/* custom character class functions */ +static ase_bool_t awk_isupper (void* custom, ase_cint_t c) +{ + return ase_isupper (c); +} + +static ase_bool_t awk_islower (void* custom, ase_cint_t c) +{ + return ase_islower (c); +} + +static ase_bool_t awk_isalpha (void* custom, ase_cint_t c) +{ + return ase_isalpha (c); +} + +static ase_bool_t awk_isdigit (void* custom, ase_cint_t c) +{ + return ase_isdigit (c); +} + +static ase_bool_t awk_isxdigit (void* custom, ase_cint_t c) +{ + return ase_isxdigit (c); +} + +static ase_bool_t awk_isalnum (void* custom, ase_cint_t c) +{ + return ase_isalnum (c); +} + +static ase_bool_t awk_isspace (void* custom, ase_cint_t c) +{ + return ase_isspace (c); +} + +static ase_bool_t awk_isprint (void* custom, ase_cint_t c) +{ + return ase_isprint (c); +} + +static ase_bool_t awk_isgraph (void* custom, ase_cint_t c) +{ + return ase_isgraph (c); +} + +static ase_bool_t awk_iscntrl (void* custom, ase_cint_t c) +{ + return ase_iscntrl (c); +} + +static ase_bool_t awk_ispunct (void* custom, ase_cint_t c) +{ + return ase_ispunct (c); +} + +static ase_cint_t awk_toupper (void* custom, ase_cint_t c) +{ + return ase_toupper (c); +} + +static ase_cint_t awk_tolower (void* custom, ase_cint_t c) +{ + return ase_tolower (c); +} + +static ase_real_t awk_pow (void* custom, ase_real_t x, ase_real_t y) +{ + return pow (x, y); +} + +static int awk_sprintf ( + void* custom, ase_char_t* buf, ase_size_t size, + const ase_char_t* fmt, ...) +{ + int n; + + va_list ap; + va_start (ap, fmt); + n = ase_vsprintf (buf, size, fmt, ap); + va_end (ap); + + return n; +} + +static void awk_dprintf (void* custom, const ase_char_t* fmt, ...) +{ + va_list ap; + va_start (ap, fmt); + ase_vfprintf (stderr, fmt, ap); + va_end (ap); +} + +#ifndef NDEBUG +void ase_assert_abort (void) +{ + abort (); +} + +void ase_assert_printf (const ase_char_t* fmt, ...) +{ + va_list ap; + va_start (ap, fmt); + ase_vfprintf (stdout, fmt, ap); + va_end (ap); +} +#endif + +static void throw_exception ( + JNIEnv* env, const ase_char_t* msg, jint code, jint line) +{ + jclass except_class; + jmethodID except_cons; + jstring except_msg; + jthrowable except_obj; + ase_size_t len; + + except_class = (*env)->FindClass (env, CLASS_EXCEPTION); + if (except_class == NULL) + { + /* the exception to be thrown by FindClass is not cleared. + * 1. this should not happend as the ase.awk.Exception + * class should always be there. + * 2. if it happens, this exception may abort the entire + * program as the exception is not likely to be handled + * explicitly by the java program. */ + return; + } + + except_cons = (*env)->GetMethodID ( + env, except_class, "", "(Ljava/lang/String;II)V"); + if (except_cons == NULL) + { + /* the potential exception to be thrown by the GetMethodID + * method is not cleared here for the same reason as the + * FindClass method above */ + (*env)->DeleteLocalRef (env, except_class); + return; + } + + len = ase_strlen(msg); + if (len > 0 && ASE_SIZEOF(jchar) != ASE_SIZEOF(ase_char_t)) + { + ase_size_t i; + jchar* tmp = (jchar*) malloc (ASE_SIZEOF(jchar)*len); + if (tmp == NULL) + { + (*env)->DeleteLocalRef (env, except_class); + + except_class = (*env)->FindClass ( + env, CLASS_OUTOFMEMORYERROR); + if (except_class == NULL) return; + + (*env)->ThrowNew (env, except_class, "out of memory"); + (*env)->DeleteLocalRef (env, except_class); + return; + } + + for (i = 0; i < len; i++) tmp[i] = (jchar)msg[i]; + except_msg = (*env)->NewString (env, tmp, len); + free (tmp); + } + else + { + except_msg = (*env)->NewString (env, (jchar*)msg, len); + } + + if (except_msg == NULL) + { + (*env)->DeleteLocalRef (env, except_class); + return; + } + + except_obj = (*env)->NewObject ( + env, except_class, except_cons, + except_msg, code, line); + + (*env)->DeleteLocalRef (env, except_msg); + (*env)->DeleteLocalRef (env, except_class); + + if (except_obj == NULL) return; + + (*env)->Throw (env, except_obj); + (*env)->DeleteLocalRef (env, except_obj); +} + +static jboolean is_debug (ase_awk_t* awk) +{ + awk_data_t* awk_data = (awk_data_t*)ase_awk_getcustomdata (awk); + return awk_data->debug? JNI_TRUE: JNI_FALSE; +} + +JNIEXPORT void JNICALL Java_ase_awk_Awk_open (JNIEnv* env, jobject obj) +{ + jclass class; + jfieldID handle; + ase_awk_t* awk; + ase_awk_prmfns_t prmfns; + awk_data_t* awk_data; + int opt; + + memset (&prmfns, 0, sizeof(prmfns)); + + prmfns.mmgr.malloc = awk_malloc; + prmfns.mmgr.realloc = awk_realloc; + prmfns.mmgr.free = awk_free; + prmfns.mmgr.custom_data = NULL; + + prmfns.ccls.is_upper = awk_isupper; + prmfns.ccls.is_lower = awk_islower; + prmfns.ccls.is_alpha = awk_isalpha; + prmfns.ccls.is_digit = awk_isdigit; + prmfns.ccls.is_xdigit = awk_isxdigit; + prmfns.ccls.is_alnum = awk_isalnum; + prmfns.ccls.is_space = awk_isspace; + prmfns.ccls.is_print = awk_isprint; + prmfns.ccls.is_graph = awk_isgraph; + prmfns.ccls.is_cntrl = awk_iscntrl; + prmfns.ccls.is_punct = awk_ispunct; + prmfns.ccls.to_upper = awk_toupper; + prmfns.ccls.to_lower = awk_tolower; + prmfns.ccls.custom_data = NULL; + + prmfns.misc.pow = awk_pow; + prmfns.misc.sprintf = awk_sprintf; + prmfns.misc.dprintf = awk_dprintf; + prmfns.misc.custom_data = NULL; + + awk_data = (awk_data_t*) malloc (sizeof(awk_data_t)); + if (awk_data == NULL) + { + throw_exception ( + env, + ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM), + ASE_AWK_ENOMEM, + 0); + return; + } + + memset (awk_data, 0, sizeof(awk_data_t)); + + awk = ase_awk_open (&prmfns, awk_data); + if (awk == NULL) + { + throw_exception ( + env, + ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM), + ASE_AWK_ENOMEM, + 0); + return; + } + + class = (*env)->GetObjectClass(env, obj); + handle = (*env)->GetFieldID (env, class, FIELD_HANDLE, "J"); + (*env)->DeleteLocalRef (env, class); + if (handle == NULL) + { + /* internal error. no handle field + * NoSuchFieldError, ExceptionInitializerError, + * OutOfMemoryError might occur */ + + ase_awk_close (awk); + free (awk_data); + return; + } + + (*env)->SetLongField (env, obj, handle, (jlong)awk); + + opt = ASE_AWK_EXPLICIT | ASE_AWK_UNIQUEFN | ASE_AWK_SHADING | + ASE_AWK_IMPLICIT | ASE_AWK_SHIFT | ASE_AWK_IDIV | + ASE_AWK_EXTIO | ASE_AWK_BLOCKLESS | ASE_AWK_NEXTOFILE; + ase_awk_setoption (awk, opt); +} + +JNIEXPORT void JNICALL Java_ase_awk_Awk_close (JNIEnv* env, jobject obj) +{ + jclass class; + jfieldID handle; + ase_awk_t* awk; + + class = (*env)->GetObjectClass(env, obj); + handle = (*env)->GetFieldID (env, class, FIELD_HANDLE, "J"); + (*env)->DeleteLocalRef (env, class); + if (handle == NULL) + { + /* internal error. no handle field + * NoSuchFieldError, ExceptionInitializerError, + * OutOfMemoryError might occur */ + return; + } + + awk = (ase_awk_t*) (*env)->GetLongField (env, obj, handle); + if (awk != NULL) + { + /* the handle is not NULL. close it */ + void* tmp = ase_awk_getcustomdata (awk); + ase_awk_close (awk); + (*env)->SetLongField (env, obj, handle, (jlong)0); + free (tmp); + } +} + +JNIEXPORT void JNICALL Java_ase_awk_Awk_parse (JNIEnv* env, jobject obj) +{ + jclass class; + jfieldID handle; + + ase_awk_t* awk; + ase_awk_srcios_t srcios; + srcio_data_t srcio_data; + + class = (*env)->GetObjectClass (env, obj); + handle = (*env)->GetFieldID (env, class, FIELD_HANDLE, "J"); + (*env)->DeleteLocalRef (env, class); + if (handle == NULL) + { + /* internal error. no handle field + * NoSuchFieldError, ExceptionInitializerError, + * OutOfMemoryError might occur */ + return; + } + + awk = (ase_awk_t*) (*env)->GetLongField (env, obj, handle); + + srcio_data.env = env; + srcio_data.obj = obj; + + srcios.in = __read_source; + srcios.out = __write_source; + srcios.custom_data = &srcio_data; + + if (ase_awk_parse (awk, &srcios) == -1) + { + throw_exception ( + env, + ase_awk_geterrmsg(awk), + ase_awk_geterrnum(awk), + ase_awk_geterrlin(awk)); + + return; + } +} + +#define DELETE_CLASS_REFS(env, run_data) \ + do { \ + (*env)->DeleteLocalRef (env, run_data.integer_class); \ + (*env)->DeleteLocalRef (env, run_data.long_class); \ + (*env)->DeleteLocalRef (env, run_data.float_class); \ + (*env)->DeleteLocalRef (env, run_data.double_class); \ + (*env)->DeleteLocalRef (env, run_data.string_class); \ + (*env)->DeleteLocalRef (env, run_data.object_class); \ + } while (0) + +static ase_char_t* java_strxdup (const jchar* str, jint len) +{ + if (len > 0 && ASE_SIZEOF(jchar) != ASE_SIZEOF(ase_char_t)) + { + ase_char_t* tmp; + ase_size_t i; + + tmp = (ase_char_t*) malloc ((len+1) * ASE_SIZEOF(ase_char_t)); + if (tmp == ASE_NULL) return ASE_NULL; + + for (i = 0; i < (ase_size_t)len; i++) tmp[i] = (ase_char_t)str[i]; + tmp[i] = ASE_T('\0'); + + return tmp; + } + else + { + ase_char_t* tmp; + + tmp = (ase_char_t*) malloc ((len+1) * ASE_SIZEOF(ase_char_t)); + if (tmp == ASE_NULL) return ASE_NULL; + + ase_strncpy (tmp, (ase_char_t*)str, (ase_size_t)len); + return tmp; + } +} + +JNIEXPORT void JNICALL Java_ase_awk_Awk_run (JNIEnv* env, jobject obj, jstring mfn, jobjectArray args) +{ + jclass class; + jfieldID handle; + + ase_awk_t* awk; + ase_awk_runios_t runios; + runio_data_t runio_data; + run_data_t run_data; + ase_char_t* mmm; + + ase_size_t len, i; + const jchar* ptr; + + ase_awk_runarg_t* runarg = NULL; + + class = (*env)->GetObjectClass (env, obj); + handle = (*env)->GetFieldID (env, class, FIELD_HANDLE, "J"); + (*env)->DeleteLocalRef (env, class); + if (handle == 0) + { + /* internal error. no handle field + * NoSuchFieldError, ExceptionInitializerError, + * OutOfMemoryError might occur */ + return; + } + + awk = (ase_awk_t*) (*env)->GetLongField (env, obj, handle); + + run_data.env = env; + run_data.obj = obj; + + /* would global reference be necessary? */ + run_data.string_class = (*env)->FindClass (env, "java/lang/String"); + run_data.integer_class = (*env)->FindClass (env, "java/lang/Integer"); + run_data.long_class = (*env)->FindClass (env, "java/lang/Long"); + run_data.short_class = (*env)->FindClass (env, "java/lang/Short"); + run_data.float_class = (*env)->FindClass (env, "java/lang/Float"); + run_data.double_class = (*env)->FindClass (env, "java/lang/Double"); + run_data.object_class = (*env)->FindClass (env, "java/lang/Object"); + + ASE_ASSERT (run_data.string_class != NULL); + ASE_ASSERT (run_data.integer_class != NULL); + ASE_ASSERT (run_data.short_class != NULL); + ASE_ASSERT (run_data.long_class != NULL); + ASE_ASSERT (run_data.float_class != NULL); + ASE_ASSERT (run_data.double_class != NULL); + ASE_ASSERT (run_data.object_class != NULL); + + run_data.integer_init = (*env)->GetMethodID ( + env, run_data.integer_class, "", "(I)V"); + run_data.long_init = (*env)->GetMethodID ( + env, run_data.long_class, "", "(J)V"); + run_data.short_init = (*env)->GetMethodID ( + env, run_data.short_class, "", "(S)V"); + run_data.float_init = (*env)->GetMethodID ( + env, run_data.float_class, "", "(F)V"); + run_data.double_init = (*env)->GetMethodID ( + env, run_data.double_class, "", "(D)V"); + + ASE_ASSERT (run_data.integer_init != NULL); + ASE_ASSERT (run_data.long_init != NULL); + ASE_ASSERT (run_data.short_init != NULL); + ASE_ASSERT (run_data.float_init != NULL); + ASE_ASSERT (run_data.double_init != NULL); + + run_data.integer_value = (*env)->GetMethodID ( + env, run_data.integer_class, "intValue", "()I"); + run_data.long_value = (*env)->GetMethodID ( + env, run_data.long_class, "longValue", "()J"); + run_data.short_value = (*env)->GetMethodID ( + env, run_data.short_class, "shortValue", "()S"); + run_data.float_value = (*env)->GetMethodID ( + env, run_data.float_class, "floatValue", "()F"); + run_data.double_value = (*env)->GetMethodID ( + env, run_data.double_class, "doubleValue", "()D"); + + ASE_ASSERTX (run_data.integer_value != NULL, + "The Integer class must has the method - int intValue()"); + ASE_ASSERTX (run_data.long_value != NULL, + "The Long class must has the method - long longValue()"); + ASE_ASSERTX (run_data.short_value != NULL, + "The Short class must has the method - short shortValue()"); + ASE_ASSERTX (run_data.float_value != NULL, + "The Float class must has the method - float floatValue()"); + ASE_ASSERTX (run_data.double_value != NULL, + "The Double class must has the method - double doubleValue()"); + + runio_data.env = env; + runio_data.obj = obj; + + runios.pipe = __process_extio; + runios.coproc = ASE_NULL; + runios.file = __process_extio; + runios.console = __process_extio; + runios.custom_data = &runio_data; + + if (mfn == NULL) + { + mmm = NULL; + ptr = NULL; + } + else + { + /* process the main entry point */ + + len = (*env)->GetStringLength (env, mfn); + + if (len > 0) + { + ase_size_t i; + + ptr = (*env)->GetStringChars (env, mfn, JNI_FALSE); + if (ptr == NULL) + { + (*env)->ExceptionClear (env); + DELETE_CLASS_REFS (env, run_data); + throw_exception ( + env, + ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM), + ASE_AWK_ENOMEM, + 0); + return; + } + + mmm = (ase_char_t*) malloc (ASE_SIZEOF(ase_char_t)*(len+1)); + if (mmm == ASE_NULL) + { + (*env)->ReleaseStringChars (env, mfn, ptr); + DELETE_CLASS_REFS (env, run_data); + throw_exception ( + env, + ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM), + ASE_AWK_ENOMEM, + 0); + return; + } + + for (i = 0; i < len; i++) + { + mmm[i] = (ase_char_t)ptr[i]; + if (mmm[i] == ASE_T('\0')) + { + free (mmm); + (*env)->ReleaseStringChars (env, mfn, ptr); + DELETE_CLASS_REFS (env, run_data); + throw_exception ( + env, + ASE_T("main function name not valid"), + ASE_AWK_EINVAL, + 0); + return; + } + } + mmm[len] = ASE_T('\0'); + } + else + { + mmm = NULL; + ptr = NULL; + } + } + + if (args != NULL) + { + /* compose arguments */ + + len = (*env)->GetArrayLength (env, args); + + runarg = malloc (sizeof(ase_awk_runarg_t) * (len+1)); + if (runarg == NULL) + { + if (mmm != NULL) free (mmm); + if (ptr != NULL) (*env)->ReleaseStringChars (env, mfn, ptr); + DELETE_CLASS_REFS (env, run_data); + + throw_exception ( + env, + ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM), + ASE_AWK_ENOMEM, + 0); + + return; + } + + for (i = 0; i < len; i++) + { + const jchar* tmp; + jstring obj = (jstring)(*env)->GetObjectArrayElement (env, args, i); + + runarg[i].len = (*env)->GetStringLength (env, obj); + tmp = (*env)->GetStringChars (env, obj, JNI_FALSE); + if (tmp == NULL) + { + ase_size_t j; + + for (j = 0; j < i; j++) free (runarg[j].ptr); + free (runarg); + + (*env)->DeleteLocalRef (env, obj); + + if (mmm != NULL && mmm) free (mmm); + if (ptr != NULL) (*env)->ReleaseStringChars (env, mfn, ptr); + DELETE_CLASS_REFS (env, run_data); + + throw_exception ( + env, + ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM), + ASE_AWK_ENOMEM, + 0); + + return; + } + + runarg[i].ptr = java_strxdup (tmp, runarg[i].len); + if (runarg[i].ptr == NULL) + { + ase_size_t j; + + for (j = 0; j < i; j++) free (runarg[j].ptr); + free (runarg); + + (*env)->ReleaseStringChars (env, obj, tmp); + (*env)->DeleteLocalRef (env, obj); + + if (mmm != NULL) free (mmm); + if (ptr != NULL) (*env)->ReleaseStringChars (env, mfn, ptr); + DELETE_CLASS_REFS (env, run_data); + + throw_exception ( + env, + ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM), + ASE_AWK_ENOMEM, + 0); + + return; + } + + (*env)->ReleaseStringChars (env, obj, tmp); + (*env)->DeleteLocalRef (env, obj); + } + + runarg[i].ptr = NULL; + runarg[i].len = 0; + } + + if (ase_awk_run (awk, + mmm, &runios, ASE_NULL, runarg, &run_data) == -1) + { + if (runarg != NULL) + { + for (i = 0; i < len; i++) free (runarg[i].ptr); + free (runarg); + } + + if (mmm != NULL) free (mmm); + if (ptr != NULL) (*env)->ReleaseStringChars (env, mfn, ptr); + DELETE_CLASS_REFS (env, run_data); + + throw_exception ( + env, + ase_awk_geterrmsg(awk), + ase_awk_geterrnum(awk), + ase_awk_geterrlin(awk)); + return; + } + + if (runarg != NULL) + { + for (i = 0; i < len; i++) free (runarg[i].ptr); + free (runarg); + } + + if (mmm != NULL) free (mmm); + if (ptr != NULL) (*env)->ReleaseStringChars (env, mfn, ptr); + DELETE_CLASS_REFS (env, run_data); +} + +static ase_ssize_t __java_open_source (JNIEnv* env, jobject obj, int mode) +{ + jclass class; + jfieldID handle; + jmethodID mid; + jint ret; + ase_awk_t* awk; + + class = (*env)->GetObjectClass(env, obj); + handle = (*env)->GetFieldID (env, class, FIELD_HANDLE, "J"); + mid = (*env)->GetMethodID (env, class, "openSource", "(I)I"); + (*env)->DeleteLocalRef (env, class); + if (handle == NULL) + { + (*env)->ExceptionClear (env); + return -1; + } + awk = (ase_awk_t*)(*env)->GetLongField (env, obj, handle); + + if (mid == NULL) + { + if (is_debug(awk)) (*env)->ExceptionDescribe (env); + (*env)->ExceptionClear (env); + return -1; + } + + ret = (*env)->CallIntMethod (env, obj, mid, mode); + if ((*env)->ExceptionOccurred (env)) + { + if (is_debug(awk)) (*env)->ExceptionDescribe (env); + (*env)->ExceptionClear (env); + ret = -1; + } + + return ret; +} + +static ase_ssize_t __java_close_source (JNIEnv* env, jobject obj, int mode) +{ + jclass class; + jfieldID handle; + jmethodID mid; + jint ret; + ase_awk_t* awk; + + class = (*env)->GetObjectClass(env, obj); + handle = (*env)->GetFieldID (env, class, FIELD_HANDLE, "J"); + mid = (*env)->GetMethodID (env, class, "closeSource", "(I)I"); + (*env)->DeleteLocalRef (env, class); + if (handle == NULL) + { + (*env)->ExceptionClear (env); + return -1; + } + awk = (ase_awk_t*)(*env)->GetLongField (env, obj, handle); + + if (mid == NULL) + { + if (is_debug(awk)) (*env)->ExceptionDescribe (env); + (*env)->ExceptionClear (env); + return -1; + } + + ret = (*env)->CallIntMethod (env, obj, mid, mode); + if ((*env)->ExceptionOccurred (env)) + { + if (is_debug(awk)) (*env)->ExceptionDescribe (env); + (*env)->ExceptionClear (env); + ret = -1; + } + + return ret; +} + +static ase_ssize_t __java_read_source ( + JNIEnv* env, jobject obj, ase_char_t* buf, ase_size_t size) +{ + jclass class; + jfieldID handle; + jmethodID mid; + jcharArray array; + jchar* tmp; + jint ret, i; + ase_awk_t* awk; + + class = (*env)->GetObjectClass(env, obj); + handle = (*env)->GetFieldID (env, class, FIELD_HANDLE, "J"); + mid = (*env)->GetMethodID (env, class, "readSource", "([CI)I"); + (*env)->DeleteLocalRef (env, class); + if (handle == NULL) + { + (*env)->ExceptionClear (env); + return -1; + } + awk = (ase_awk_t*)(*env)->GetLongField (env, obj, handle); + + if (mid == NULL) + { + if (is_debug(awk)) (*env)->ExceptionDescribe (env); + (*env)->ExceptionClear (env); + return -1; + } + + array = (*env)->NewCharArray (env, size); + if (array == NULL) + { + if (is_debug(awk)) (*env)->ExceptionDescribe (env); + (*env)->ExceptionClear (env); + return -1; + } + + ret = (*env)->CallIntMethod (env, obj, mid, array, size); + if ((*env)->ExceptionOccurred (env)) + { + if (is_debug(awk)) (*env)->ExceptionDescribe (env); + (*env)->ExceptionClear (env); + ret = -1; + } + + tmp = (*env)->GetCharArrayElements (env, array, 0); + for (i = 0; i < ret; i++) buf[i] = (ase_char_t)tmp[i]; + (*env)->ReleaseCharArrayElements (env, array, tmp, 0); + + (*env)->DeleteLocalRef (env, array); + return i; +} + +static ase_ssize_t __java_write_source ( + JNIEnv* env, jobject obj, ase_char_t* buf, ase_size_t size) +{ + jclass class; + jfieldID handle; + jmethodID mid; + jcharArray array; + jchar* tmp; + jint ret; + ase_size_t i; + ase_awk_t* awk; + + class = (*env)->GetObjectClass(env, obj); + handle = (*env)->GetFieldID (env, class, FIELD_HANDLE, "J"); + mid = (*env)->GetMethodID (env, class, "writeSource", "([CI)I"); + (*env)->DeleteLocalRef (env, class); + if (handle == NULL) + { + (*env)->ExceptionClear (env); + return -1; + } + awk = (ase_awk_t*)(*env)->GetLongField (env, obj, handle); + + if (mid == NULL) + { + if (is_debug(awk)) (*env)->ExceptionDescribe (env); + (*env)->ExceptionClear (env); + return -1; + } + + array = (*env)->NewCharArray (env, size); + if (array == NULL) + { + if (is_debug(awk)) (*env)->ExceptionDescribe (env); + (*env)->ExceptionClear (env); + return -1; + } + + tmp = (*env)->GetCharArrayElements (env, array, 0); + for (i = 0; i < size; i++) tmp[i] = (jchar)buf[i]; + (*env)->ReleaseCharArrayElements (env, array, tmp, 0); + + ret = (*env)->CallIntMethod (env, obj, mid, array, size); + if ((*env)->ExceptionOccurred (env)) + { + if (is_debug(awk)) (*env)->ExceptionDescribe (env); + (*env)->ExceptionClear (env); + ret = -1; + } + + (*env)->DeleteLocalRef (env, array); + return ret; +} + +static ase_ssize_t __java_open_extio ( + JNIEnv* env, jobject obj, char* meth, ase_awk_extio_t* extio) +{ + jclass class; + jfieldID handle; + jmethodID mid; + jclass extio_class; + jmethodID extio_cons; + jobject extio_object; + jstring extio_name; + jint ret; + ase_awk_t* awk; + ase_size_t len; + + /* get the method - meth */ + class = (*env)->GetObjectClass(env, obj); + handle = (*env)->GetFieldID (env, class, FIELD_HANDLE, "J"); + mid = (*env)->GetMethodID (env, class, meth, "(Lase/awk/Extio;)I"); + (*env)->DeleteLocalRef (env, class); + + if (handle == NULL) + { + (*env)->ExceptionClear (env); + return -1; + } + awk = (ase_awk_t*)(*env)->GetLongField (env, obj, handle); + + if (mid == NULL) + { + if (is_debug(awk)) (*env)->ExceptionDescribe (env); + (*env)->ExceptionClear (env); + return -1; + } + + /* look for extio class */ + extio_class = (*env)->FindClass (env, CLASS_EXTIO); + if (extio_class == NULL) + { + if (is_debug(awk)) (*env)->ExceptionDescribe (env); + (*env)->ExceptionClear (env); + return -1; + } + + /* get the constructor */ + extio_cons = (*env)->GetMethodID ( + env, extio_class, "", "(Ljava/lang/String;IIJ)V"); + if (extio_cons == NULL) + { + if (is_debug(awk)) (*env)->ExceptionDescribe (env); + (*env)->ExceptionClear (env); + (*env)->DeleteLocalRef (env, extio_class); + return -1; + } + + /* construct the name */ + len = ase_strlen(extio->name); + if (len > 0 && ASE_SIZEOF(jchar) != ASE_SIZEOF(ase_char_t)) + { + ase_size_t i; + jchar* tmp = (jchar*) malloc (ASE_SIZEOF(jchar)*len); + if (tmp == NULL) + { + (*env)->DeleteLocalRef (env, extio_class); + return -1; + } + + for (i = 0; i < len; i++) tmp[i] = (jchar)extio->name[i]; + extio_name = (*env)->NewString (env, tmp, len); + free (tmp); + } + else + { + extio_name = (*env)->NewString (env, (jchar*)extio->name, len); + } + + if (extio_name == NULL) + { + if (is_debug(awk)) (*env)->ExceptionDescribe (env); + (*env)->ExceptionClear (env); + (*env)->DeleteLocalRef (env, extio_class); + return -1; + } + + /* construct the extio object */ + extio_object = (*env)->NewObject ( + env, extio_class, extio_cons, + extio_name, extio->type & 0xFF, extio->mode, (jlong)extio->run); + (*env)->DeleteLocalRef (env, extio_class); + if (extio_object == NULL) + { + if (is_debug(awk)) (*env)->ExceptionDescribe (env); + (*env)->ExceptionClear (env); + (*env)->DeleteLocalRef (env, extio_name); + return -1; + } + + (*env)->DeleteLocalRef (env, extio_name); + + /* execute the method */ + ret = (*env)->CallIntMethod (env, obj, mid, extio_object); + if ((*env)->ExceptionOccurred(env)) + { + /* clear the exception */ + if (is_debug(awk)) (*env)->ExceptionDescribe (env); + (*env)->ExceptionClear (env); + ret = -1; + } + + if (ret >= 0) + { + /* ret == -1 failed to open the stream + * ret == 0 opened the stream and reached its end + * ret == 1 opened the stream. */ + extio->handle = (*env)->NewGlobalRef (env, extio_object); + /* + if (extio->handle == NULL) + { + // TODO: close the stream ... + if (is_debug(awk)) (*env)->ExceptionDescribe (env); + (*env)->ExceptionClear (env); + ret = -1; + } + */ + } + + (*env)->DeleteLocalRef (env, extio_object); + return ret; +} + +static ase_ssize_t __java_close_extio ( + JNIEnv* env, jobject obj, char* meth, ase_awk_extio_t* extio) +{ + jclass class; + jfieldID handle; + jmethodID mid; + jint ret; + ase_awk_t* awk; + + class = (*env)->GetObjectClass(env, obj); + handle = (*env)->GetFieldID (env, class, FIELD_HANDLE, "J"); + mid = (*env)->GetMethodID (env, class, meth, "(Lase/awk/Extio;)I"); + (*env)->DeleteLocalRef (env, class); + + if (handle == NULL) + { + (*env)->ExceptionClear (env); + return -1; + } + awk = (ase_awk_t*)(*env)->GetLongField (env, obj, handle); + if (mid == NULL) + { + if (is_debug(awk)) (*env)->ExceptionDescribe (env); + (*env)->ExceptionClear (env); + return -1; + } + + ret = (*env)->CallIntMethod (env, obj, mid, extio->handle); + if ((*env)->ExceptionOccurred (env)) + { + if (is_debug(awk)) (*env)->ExceptionDescribe (env); + (*env)->ExceptionClear (env); + ret = -1; + } + + if (ret >= 0) + { + /* ret == -1 failed to close the stream + * ret == 0 closed the stream */ + (*env)->DeleteGlobalRef (env, extio->handle); + extio->handle = NULL; + } + + return ret; +} + +static ase_ssize_t __java_read_extio ( + JNIEnv* env, jobject obj, char* meth, + ase_awk_extio_t* extio, ase_char_t* buf, ase_size_t size) +{ + jclass class; + jfieldID handle; + jmethodID mid; + jcharArray array; + jchar* tmp; + jint ret, i; + ase_awk_t* awk; + + class = (*env)->GetObjectClass(env, obj); + handle = (*env)->GetFieldID (env, class, FIELD_HANDLE, "J"); + mid = (*env)->GetMethodID (env, class, meth, "(Lase/awk/Extio;[CI)I"); + (*env)->DeleteLocalRef (env, class); + + if (handle == NULL) + { + (*env)->ExceptionClear (env); + return -1; + } + awk = (ase_awk_t*)(*env)->GetLongField (env, obj, handle); + + if (mid == NULL) + { + if (is_debug(awk)) (*env)->ExceptionDescribe (env); + (*env)->ExceptionClear (env); + return -1; + } + + array = (*env)->NewCharArray (env, size); + if (array == NULL) + { + if (is_debug(awk)) (*env)->ExceptionDescribe (env); + (*env)->ExceptionClear (env); + return -1; + } + + ret = (*env)->CallIntMethod (env, obj, mid, extio->handle, array, size); + if ((*env)->ExceptionOccurred (env)) + { + if (is_debug(awk)) (*env)->ExceptionDescribe (env); + (*env)->ExceptionClear (env); + ret = -1; + } + + if (ret > 0) + { + tmp = (*env)->GetCharArrayElements (env, array, 0); + for (i = 0; i < ret; i++) buf[i] = (ase_char_t)tmp[i]; + (*env)->ReleaseCharArrayElements (env, array, tmp, 0); + } + + (*env)->DeleteLocalRef (env, array); + return ret; +} + +static ase_ssize_t __java_write_extio ( + JNIEnv* env, jobject obj, char* meth, + ase_awk_extio_t* extio, ase_char_t* data, ase_size_t size) +{ + jclass class; + jfieldID handle; + jmethodID mid; + jcharArray array; + jchar* tmp; + jint ret; + ase_size_t i; + ase_awk_t* awk; + + class = (*env)->GetObjectClass(env, obj); + handle = (*env)->GetFieldID (env, class, FIELD_HANDLE, "J"); + mid = (*env)->GetMethodID (env, class, meth, "(Lase/awk/Extio;[CI)I"); + (*env)->DeleteLocalRef (env, class); + + if (handle == NULL) + { + (*env)->ExceptionClear (env); + return -1; + } + awk = (ase_awk_t*)(*env)->GetLongField (env, obj, handle); + if (mid == NULL) + { + if (is_debug(awk)) (*env)->ExceptionDescribe (env); + (*env)->ExceptionClear (env); + return -1; + } + + array = (*env)->NewCharArray (env, size); + if (array == NULL) + { + if (is_debug(awk)) (*env)->ExceptionDescribe (env); + (*env)->ExceptionClear (env); + return -1; + } + + tmp = (*env)->GetCharArrayElements (env, array, 0); + for (i = 0; i < size; i++) tmp[i] = (jchar)data[i]; + (*env)->ReleaseCharArrayElements (env, array, tmp, 0); + + ret = (*env)->CallIntMethod (env, obj, mid, extio->handle, array, size); + if ((*env)->ExceptionOccurred (env)) + { + if (is_debug(awk)) (*env)->ExceptionDescribe (env); + (*env)->ExceptionClear (env); + ret = -1; + } + + (*env)->DeleteLocalRef (env, array); + return ret; +} + + +static ase_ssize_t __java_flush_extio ( + JNIEnv* env, jobject obj, char* meth, ase_awk_extio_t* extio) +{ + jclass class; + jfieldID handle; + jmethodID mid; + jint ret; + ase_awk_t* awk; + + class = (*env)->GetObjectClass(env, obj); + handle = (*env)->GetFieldID (env, class, FIELD_HANDLE, "J"); + mid = (*env)->GetMethodID (env, class, meth, "(Lase/awk/Extio;)I"); + (*env)->DeleteLocalRef (env, class); + if (handle == NULL) + { + (*env)->ExceptionClear (env); + return -1; + } + awk = (ase_awk_t*)(*env)->GetLongField (env, obj, handle); + if (mid == NULL) + { + if (is_debug(awk)) (*env)->ExceptionDescribe (env); + (*env)->ExceptionClear (env); + return -1; + } + + ret = (*env)->CallIntMethod (env, obj, mid, extio->handle); + if ((*env)->ExceptionOccurred (env)) + { + if (is_debug(awk)) (*env)->ExceptionDescribe (env); + (*env)->ExceptionClear (env); + ret = -1; + } + + return ret; +} + +static ase_ssize_t __java_next_extio ( + JNIEnv* env, jobject obj, char* meth, ase_awk_extio_t* extio) +{ + jclass class; + jfieldID handle; + jmethodID mid; + jint ret; + ase_awk_t* awk; + + class = (*env)->GetObjectClass(env, obj); + handle = (*env)->GetFieldID (env, class, FIELD_HANDLE, "J"); + mid = (*env)->GetMethodID (env, class, meth, "(Lase/awk/Extio;)I"); + (*env)->DeleteLocalRef (env, class); + if (handle == NULL) + { + (*env)->ExceptionClear (env); + return -1; + } + awk = (ase_awk_t*)(*env)->GetLongField (env, obj, handle); + if (mid == NULL) + { + (*env)->ExceptionClear (env); + return -1; + } + + ret = (*env)->CallIntMethod (env, obj, mid, extio->handle); + if ((*env)->ExceptionOccurred (env)) + { + if (is_debug(awk)) (*env)->ExceptionDescribe (env); + (*env)->ExceptionClear (env); + ret = -1; + } + + return ret; +} + +static ase_ssize_t __read_source ( + int cmd, void* arg, ase_char_t* data, ase_size_t count) +{ + srcio_data_t* srcio_data = (srcio_data_t*)arg; + + if (cmd == ASE_AWK_IO_OPEN) + { + return __java_open_source ( + srcio_data->env, srcio_data->obj, SOURCE_READ); + } + else if (cmd == ASE_AWK_IO_CLOSE) + { + return __java_close_source ( + srcio_data->env, srcio_data->obj, SOURCE_READ); + } + else if (cmd == ASE_AWK_IO_READ) + { + return __java_read_source ( + srcio_data->env, srcio_data->obj, data, count); + } + + return -1; +} + +static ase_ssize_t __write_source ( + int cmd, void* arg, ase_char_t* data, ase_size_t count) +{ + srcio_data_t* srcio_data = (srcio_data_t*)arg; + + if (cmd == ASE_AWK_IO_OPEN) + { + return __java_open_source ( + srcio_data->env, srcio_data->obj, SOURCE_WRITE); + } + else if (cmd == ASE_AWK_IO_CLOSE) + { + return __java_close_source ( + srcio_data->env, srcio_data->obj, SOURCE_WRITE); + } + else if (cmd == ASE_AWK_IO_WRITE) + { + return __java_write_source ( + srcio_data->env, srcio_data->obj, data, count); + } + + return -1; +} + +static ase_ssize_t __process_extio ( + int cmd, void* arg, ase_char_t* data, ase_size_t size) +{ + ase_awk_extio_t* epa = (ase_awk_extio_t*)arg; + runio_data_t* runio_data = (runio_data_t*)epa->custom_data; + + if (cmd == ASE_AWK_IO_OPEN) + { + return __java_open_extio ( + runio_data->env, runio_data->obj, + "openExtio", epa); + } + else if (cmd == ASE_AWK_IO_CLOSE) + { + return __java_close_extio ( + runio_data->env, runio_data->obj, + "closeExtio", epa); + } + else if (cmd == ASE_AWK_IO_READ) + { + return __java_read_extio ( + runio_data->env, runio_data->obj, + "readExtio", epa, data, size); + } + else if (cmd == ASE_AWK_IO_WRITE) + { + return __java_write_extio ( + runio_data->env, runio_data->obj, + "writeExtio", epa, data, size); + } + else if (cmd == ASE_AWK_IO_FLUSH) + { + return __java_flush_extio ( + runio_data->env, runio_data->obj, + "flushExtio", epa); + } + else if (cmd == ASE_AWK_IO_NEXT) + { + return __java_next_extio ( + runio_data->env, runio_data->obj, + "nextExtio", epa); + } + + return -1; +} + +static int __handle_bfn ( + ase_awk_run_t* run, const ase_char_t* fnm, ase_size_t fnl) +{ + jclass class; + jmethodID method; + jstring name; + const char* name_utf; + run_data_t* run_data; + JNIEnv* env; + jobject obj; + jint i, nargs; + jobjectArray args; + jobject arg, ret; + ase_awk_val_t* v; + ase_awk_t* awk; + + run_data = ase_awk_getruncustomdata (run); + nargs = ase_awk_getnargs (run); + awk = ase_awk_getrunawk (run); + + env = run_data->env; + obj = run_data->obj; + + /*if (fnl > 0 && ASE_SIZEOF(jchar) != ASE_SIZEOF(ase_char_t))*/ + { + ase_size_t i; + jchar* tmp = (jchar*) malloc (ASE_SIZEOF(jchar)*(fnl+4)); + if (tmp == NULL) + { + ase_awk_setrunerrnum (run, ASE_AWK_ENOMEM); + return -1; + } + + tmp[0] = (jchar*)'b'; + tmp[1] = (jchar*)'f'; + tmp[2] = (jchar*)'n'; + tmp[3] = (jchar*)'_'; + for (i = 0; i < fnl; i++) tmp[i+4] = (jchar)fnm[i]; + name = (*env)->NewString (env, tmp, fnl+4); + free (tmp); + } + /*else + { + name = (*env)->NewString (env, (jchar*)fnm, fnl); + }*/ + + if (name == NULL) + { + if (is_debug(awk)) (*env)->ExceptionDescribe (env); + (*env)->ExceptionClear (env); + ase_awk_setrunerrnum (run, ASE_AWK_ENOMEM); + return -1; + } + name_utf = (*env)->GetStringUTFChars (env, name, JNI_FALSE); + if (name_utf == NULL) + { + (*env)->DeleteLocalRef (env, name); + ase_awk_setrunerrnum (run, ASE_AWK_ENOMEM); + return -1; + } + + class = (*env)->GetObjectClass(env, obj); + method = (*env)->GetMethodID ( + env, class, name_utf, + "(J[Ljava/lang/Object;)Ljava/lang/Object;"); + (*env)->DeleteLocalRef (env, class); + (*env)->ReleaseStringUTFChars (env, name, name_utf); + (*env)->DeleteLocalRef (env, name); + if (method == NULL) + { + /* if the method is not found, the exception is thrown. + * clear it to prevent it from being thrown */ + if (is_debug(awk)) (*env)->ExceptionDescribe (env); + (*env)->ExceptionClear (env); + ase_awk_setrunerrnum (run, ASE_AWK_EBFNUSER); + return -1; + } + + args = (*env)->NewObjectArray ( + env, nargs, run_data->object_class, NULL); + if (args == NULL) + { + if (is_debug(awk)) (*env)->ExceptionDescribe (env); + (*env)->ExceptionClear (env); + ase_awk_setrunerrnum (run, ASE_AWK_ENOMEM); + return -1; + } + + for (i = 0; i < nargs; i++) + { + v = ase_awk_getarg (run, i); + + arg = NULL; + + if (v->type == ASE_AWK_VAL_INT) + { + jlong jv; + + jv = ((ase_awk_val_int_t*)v)->val; + arg = (*env)->NewObject (env, + run_data->long_class, + run_data->long_init, jv); + } + else if (v->type == ASE_AWK_VAL_REAL) + { + jdouble jv; + + jv = ((ase_awk_val_real_t*)v)->val; + arg = (*env)->NewObject (env, + run_data->double_class, + run_data->double_init, jv); + } + else if (v->type == ASE_AWK_VAL_STR) + { + ase_size_t len = ((ase_awk_val_str_t*)v)->len; + + if (ASE_SIZEOF(jchar) != ASE_SIZEOF(ase_char_t)) + { + ase_size_t i; + + jchar* tmp = (jchar*) malloc (ASE_SIZEOF(jchar)*len); + if (tmp == NULL) + { + (*env)->DeleteLocalRef (env, args); + ase_awk_setrunerrnum (run, ASE_AWK_ENOMEM); + return -1; + } + + for (i = 0; i < len; i++) + tmp[i] = (jchar)((ase_awk_val_str_t*)v)->buf[i]; + + arg = (*env)->NewString (env, tmp, len); + + free (tmp); + } + else + { + arg = (*env)->NewString ( + env, (jchar*)((ase_awk_val_str_t*)v)->buf, len); + } + } + + if (v->type != ASE_AWK_VAL_NIL && arg == NULL) + { + if ((*env)->ExceptionOccurred (env)) + { + if (is_debug(awk)) + (*env)->ExceptionDescribe (env); + (*env)->ExceptionClear (env); + } + (*env)->DeleteLocalRef (env, args); + ase_awk_setrunerrnum (run, ASE_AWK_ENOMEM); + return -1; + } + + (*env)->SetObjectArrayElement (env, args, i, arg); + if (arg != NULL) (*env)->DeleteLocalRef (env, arg); + } + + ret = (*env)->CallObjectMethod (env, obj, method, (jlong)run, args); + if ((*env)->ExceptionOccurred (env)) + { + if (is_debug(ase_awk_getrunawk(run))) + (*env)->ExceptionDescribe (env); + + (*env)->ExceptionClear (env); + (*env)->DeleteLocalRef (env, args); + + ase_awk_setrunerrnum (run, ASE_AWK_EBFNIMPL); + return -1; + } + + (*env)->DeleteLocalRef (env, args); + + if (ret == NULL) + { + ase_awk_setretval (run, ase_awk_val_nil); + } + else if ((*env)->IsInstanceOf (env, ret, run_data->integer_class)) + { + jint jv = (*env)->CallIntMethod ( + env, ret, run_data->integer_value); + + v = ase_awk_makeintval (run, jv); + if (v == NULL) + { + (*env)->DeleteLocalRef (env, ret); + ase_awk_setrunerrnum (run, ASE_AWK_ENOMEM); + return -1; + } + + (*env)->DeleteLocalRef (env, ret); + ase_awk_setretval (run, v); + } + else if ((*env)->IsInstanceOf (env, ret, run_data->long_class)) + { + jlong jv = (*env)->CallLongMethod ( + env, ret, run_data->long_value); + + v = ase_awk_makeintval (run, jv); + if (v == NULL) + { + (*env)->DeleteLocalRef (env, ret); + ase_awk_setrunerrnum (run, ASE_AWK_ENOMEM); + return -1; + } + + (*env)->DeleteLocalRef (env, ret); + ase_awk_setretval (run, v); + } + else if ((*env)->IsInstanceOf (env, ret, run_data->short_class)) + { + jshort jv = (*env)->CallShortMethod ( + env, ret, run_data->short_value); + + v = ase_awk_makeintval (run, jv); + if (v == NULL) + { + (*env)->DeleteLocalRef (env, ret); + ase_awk_setrunerrnum (run, ASE_AWK_ENOMEM); + return -1; + } + + (*env)->DeleteLocalRef (env, ret); + ase_awk_setretval (run, v); + } + else if ((*env)->IsInstanceOf (env, ret, run_data->float_class)) + { + jfloat jv = (*env)->CallFloatMethod ( + env, ret, run_data->float_value); + v = ase_awk_makerealval (run, jv); + if (v == NULL) + { + (*env)->DeleteLocalRef (env, ret); + ase_awk_setrunerrnum (run, ASE_AWK_ENOMEM); + return -1; + } + + (*env)->DeleteLocalRef (env, ret); + ase_awk_setretval (run, v); + } + else if ((*env)->IsInstanceOf (env, ret, run_data->double_class)) + { + jdouble jv = (*env)->CallDoubleMethod ( + env, ret, run_data->double_value); + v = ase_awk_makerealval (run, jv); + if (v == NULL) + { + (*env)->DeleteLocalRef (env, ret); + ase_awk_setrunerrnum (run, ASE_AWK_ENOMEM); + return -1; + } + + (*env)->DeleteLocalRef (env, ret); + ase_awk_setretval (run, v); + } + else if ((*env)->IsInstanceOf (env, ret, run_data->string_class)) + { + jsize len; + const jchar* ptr; + + len = (*env)->GetStringLength (env, ret); + ptr = (*env)->GetStringChars (env, ret, JNI_FALSE); + if (ptr == NULL) + { + (*env)->DeleteLocalRef (env, ret); + ase_awk_setrunerrnum (run, ASE_AWK_ENOMEM); + return -1; + } + + if (len > 0 && ASE_SIZEOF(jchar) != ASE_SIZEOF(ase_char_t)) + { + ase_size_t i; + ase_char_t* tmp = (ase_char_t*) + malloc (ASE_SIZEOF(ase_char_t)*len); + if (tmp == ASE_NULL) + { + (*env)->ReleaseStringChars (env, ret, ptr); + (*env)->DeleteLocalRef (env, ret); + ase_awk_setrunerrnum (run, ASE_AWK_ENOMEM); + return -1; + } + + for (i = 0; i < len; i++) tmp[i] = (ase_char_t)ptr[i]; + v = ase_awk_makestrval (run, tmp, len); + free (tmp); + } + else + { + v = ase_awk_makestrval (run, (ase_char_t*)ptr, len); + } + + if (v == NULL) + { + (*env)->ReleaseStringChars (env, ret, ptr); + (*env)->DeleteLocalRef (env, ret); + ase_awk_setrunerrnum (run, ASE_AWK_ENOMEM); + return -1; + } + + (*env)->ReleaseStringChars (env, ret, ptr); + (*env)->DeleteLocalRef (env, ret); + ase_awk_setretval (run, v); + } + else + { + (*env)->DeleteLocalRef (env, ret); + ase_awk_setrunerrnum (run, ASE_AWK_EBFNUSER); + return -1; + } + + return 0; +} + +JNIEXPORT void JNICALL Java_ase_awk_Awk_addbfn ( + JNIEnv* env, jobject obj, jstring name, jint min_args, jint max_args) +{ + jclass class; + jfieldID handle; + jint n; + + ase_awk_t* awk; + const jchar* ptr; + jsize len; + + class = (*env)->GetObjectClass(env, obj); + handle = (*env)->GetFieldID (env, class, FIELD_HANDLE, "J"); + (*env)->DeleteLocalRef (env, class); + if (handle == NULL) + { + /* internal error. no handle field + * NoSuchFieldError, ExceptionInitializerError, + * OutOfMemoryError might occur */ + return; + } + + awk = (ase_awk_t*) (*env)->GetLongField (env, obj, handle); + + len = (*env)->GetStringLength (env, name); + ptr = (*env)->GetStringChars (env, name, JNI_FALSE); + if (ptr == NULL) + { + (*env)->ExceptionClear (env); + + throw_exception ( + env, + ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM), + ASE_AWK_ENOMEM, + 0); + return; + } + + if (len > 0 && ASE_SIZEOF(jchar) != ASE_SIZEOF(ase_char_t)) + { + ase_size_t i; + ase_char_t* tmp = (ase_char_t*) + malloc (ASE_SIZEOF(ase_char_t)*len); + if (tmp == ASE_NULL) + { + (*env)->ReleaseStringChars (env, name, ptr); + throw_exception ( + env, + ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM), + ASE_AWK_ENOMEM, + 0); + return; + } + + for (i = 0; i < len; i++) tmp[i] = (ase_char_t)ptr[i]; + n = (ase_awk_addbfn (awk, tmp, len, 0, + min_args, max_args, ASE_NULL, __handle_bfn) == NULL)? -1: 0; + free (tmp); + } + else + { + n = (ase_awk_addbfn (awk, (ase_char_t*)ptr, len, 0, + min_args, max_args, ASE_NULL, __handle_bfn) == NULL)? -1: 0; + } + + + (*env)->ReleaseStringChars (env, name, ptr); + + if (n == -1) + { + throw_exception ( + env, + ase_awk_geterrmsg(awk), + ase_awk_geterrnum(awk), + ase_awk_geterrlin(awk)); + } +} + +JNIEXPORT void JNICALL Java_ase_awk_Awk_delbfn ( + JNIEnv* env, jobject obj, jstring name) +{ + jclass class; + jfieldID handle; + jint n; + + ase_awk_t* awk; + const jchar* ptr; + jsize len; + + class = (*env)->GetObjectClass(env, obj); + handle = (*env)->GetFieldID (env, class, FIELD_HANDLE, "J"); + (*env)->DeleteLocalRef (env, class); + if (handle == NULL) + { + /* internal error. no handle field + * NoSuchFieldError, ExceptionInitializerError, + * OutOfMemoryError might occur */ + return; + } + + awk = (ase_awk_t*) (*env)->GetLongField (env, obj, handle); + + len = (*env)->GetStringLength (env, name); + ptr = (*env)->GetStringChars (env, name, JNI_FALSE); + if (ptr == NULL) + { + (*env)->ExceptionClear (env); + throw_exception ( + env, + ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM), + ASE_AWK_ENOMEM, + 0); + return; + } + + if (len > 0 && ASE_SIZEOF(jchar) != ASE_SIZEOF(ase_char_t)) + { + ase_size_t i; + ase_char_t* tmp = (ase_char_t*) + malloc (ASE_SIZEOF(ase_char_t)*len); + if (tmp == ASE_NULL) + { + (*env)->ReleaseStringChars (env, name, ptr); + throw_exception ( + env, + ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM), + ASE_AWK_ENOMEM, + 0); + return; + } + + for (i = 0; i < len; i++) tmp[i] = (ase_char_t)ptr[i]; + n = ase_awk_delbfn (awk, tmp, len); + free (tmp); + } + else + { + n = ase_awk_delbfn (awk, (ase_char_t*)ptr, len); + } + + (*env)->ReleaseStringChars (env, name, ptr); + + if (n == -1) + { + throw_exception ( + env, + ase_awk_geterrmsg(awk), + ase_awk_geterrnum(awk), + ase_awk_geterrlin(awk)); + } +} + +JNIEXPORT jint JNICALL Java_ase_awk_Awk_getmaxdepth ( + JNIEnv* env, jobject obj, jint id) +{ + jclass class; + jfieldID handle; + ase_awk_t* awk; + + class = (*env)->GetObjectClass(env, obj); + handle = (*env)->GetFieldID (env, class, FIELD_HANDLE, "J"); + (*env)->DeleteLocalRef (env, class); + if (handle == NULL) return 0; /* should never happen */ + + awk = (ase_awk_t*) (*env)->GetLongField (env, obj, handle); + return (jint)ase_awk_getmaxdepth (awk, id); +} + +JNIEXPORT void JNICALL Java_ase_awk_Awk_setmaxdepth ( + JNIEnv* env, jobject obj, jint ids, jint depth) +{ + jclass class; + jfieldID handle; + ase_awk_t* awk; + + class = (*env)->GetObjectClass(env, obj); + handle = (*env)->GetFieldID (env, class, FIELD_HANDLE, "J"); + (*env)->DeleteLocalRef (env, class); + if (handle == NULL) + { + /* internal error. no handle field + * NoSuchFieldError, ExceptionInitializerError, + * OutOfMemoryError might occur */ + return; + } + + awk = (ase_awk_t*) (*env)->GetLongField (env, obj, handle); + ase_awk_setmaxdepth (awk, ids, depth); +} + +JNIEXPORT jint JNICALL Java_ase_awk_Awk_getoption ( + JNIEnv* env, jobject obj) +{ + jclass class; + jfieldID handle; + ase_awk_t* awk; + + class = (*env)->GetObjectClass(env, obj); + handle = (*env)->GetFieldID (env, class, FIELD_HANDLE, "J"); + (*env)->DeleteLocalRef (env, class); + if (handle == NULL) + { + /* internal error. no handle field + * NoSuchFieldError, ExceptionInitializerError, + * OutOfMemoryError might occur */ + return 0; + } + + awk = (ase_awk_t*) (*env)->GetLongField (env, obj, handle); + return ase_awk_getoption (awk); +} + +JNIEXPORT void JNICALL Java_ase_awk_Awk_setoption ( + JNIEnv* env, jobject obj, jint options) +{ + jclass class; + jfieldID handle; + ase_awk_t* awk; + + class = (*env)->GetObjectClass(env, obj); + handle = (*env)->GetFieldID (env, class, FIELD_HANDLE, "J"); + (*env)->DeleteLocalRef (env, class); + if (handle == NULL) + { + /* internal error. no handle field + * NoSuchFieldError, ExceptionInitializerError, + * OutOfMemoryError might occur */ + return; + } + + awk = (ase_awk_t*) (*env)->GetLongField (env, obj, handle); + ase_awk_setoption (awk, (int)options); +} + +JNIEXPORT jboolean JNICALL Java_ase_awk_Awk_getdebug ( + JNIEnv* env, jobject obj) +{ + jclass class; + jfieldID handle; + ase_awk_t* awk; + + class = (*env)->GetObjectClass(env, obj); + handle = (*env)->GetFieldID (env, class, FIELD_HANDLE, "J"); + (*env)->DeleteLocalRef (env, class); + if (handle == NULL) + { + /* internal error. no handle field + * NoSuchFieldError, ExceptionInitializerError, + * OutOfMemoryError might occur */ + return JNI_FALSE; + } + + awk = (ase_awk_t*) (*env)->GetLongField (env, obj, handle); + return ((awk_data_t*)ase_awk_getcustomdata(awk))->debug? JNI_TRUE: JNI_FALSE; +} + +JNIEXPORT void JNICALL Java_ase_awk_Awk_setdebug ( + JNIEnv* env, jobject obj, jboolean debug) +{ + jclass class; + jfieldID handle; + ase_awk_t* awk; + + class = (*env)->GetObjectClass(env, obj); + handle = (*env)->GetFieldID (env, class, FIELD_HANDLE, "J"); + (*env)->DeleteLocalRef (env, class); + if (handle == NULL) + { + /* internal error. no handle field + * NoSuchFieldError, ExceptionInitializerError, + * OutOfMemoryError might occur */ + return; + } + + awk = (ase_awk_t*) (*env)->GetLongField (env, obj, handle); + ((awk_data_t*)ase_awk_getcustomdata(awk))->debug = debug; +} + +JNIEXPORT void JNICALL Java_ase_awk_Awk_setfilename ( + JNIEnv* env, jobject obj, jlong runid, jstring name) +{ + ase_awk_run_t* run = (ase_awk_run_t*)runid; + const jchar* ptr; + jsize len; + jint n; + + len = (*env)->GetStringLength (env, name); + ptr = (*env)->GetStringChars (env, name, JNI_FALSE); + if (ptr == NULL) + { + (*env)->ExceptionClear (env); + throw_exception ( + env, + ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM), + ASE_AWK_ENOMEM, + 0); + return; + } + + if (len > 0 && ASE_SIZEOF(jchar) != ASE_SIZEOF(ase_char_t)) + { + ase_size_t i; + ase_char_t* tmp = (ase_char_t*) + malloc (ASE_SIZEOF(ase_char_t)*len); + if (tmp == ASE_NULL) + { + (*env)->ReleaseStringChars (env, name, ptr); + + throw_exception ( + env, + ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM), + ASE_AWK_ENOMEM, + 0); + return; + } + + for (i = 0; i < len; i++) tmp[i] = (ase_char_t)ptr[i]; + n = ase_awk_setfilename (run, tmp, len); + free (tmp); + } + else + { + n = ase_awk_setfilename (run, (ase_char_t*)ptr, len); + } + + (*env)->ReleaseStringChars (env, name, ptr); + + if (n == -1) + { + throw_exception ( + env, + ase_awk_getrunerrmsg(run), + ase_awk_getrunerrnum(run), + ase_awk_getrunerrlin(run)); + } +} + +JNIEXPORT void JNICALL Java_ase_awk_Awk_setofilename ( + JNIEnv* env, jobject obj, jlong runid, jstring name) +{ + ase_awk_run_t* run = (ase_awk_run_t*)runid; + const jchar* ptr; + jsize len; + jint n; + + len = (*env)->GetStringLength (env, name); + ptr = (*env)->GetStringChars (env, name, JNI_FALSE); + if (ptr == NULL) + { + (*env)->ExceptionClear (env); + throw_exception ( + env, + ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM), + ASE_AWK_ENOMEM, + 0); + return; + } + + if (len > 0 && ASE_SIZEOF(jchar) != ASE_SIZEOF(ase_char_t)) + { + ase_size_t i; + ase_char_t* tmp = (ase_char_t*) + malloc (ASE_SIZEOF(ase_char_t)*len); + if (tmp == ASE_NULL) + { + (*env)->ReleaseStringChars (env, name, ptr); + + throw_exception ( + env, + ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM), + ASE_AWK_ENOMEM, + 0); + return; + } + + for (i = 0; i < len; i++) tmp[i] = (ase_char_t)ptr[i]; + n = ase_awk_setofilename (run, tmp, len); + free (tmp); + } + else + { + n = ase_awk_setofilename (run, (ase_char_t*)ptr, len); + } + + (*env)->ReleaseStringChars (env, name, ptr); + + if (n == -1) + { + throw_exception ( + env, + ase_awk_getrunerrmsg(run), + ase_awk_getrunerrnum(run), + ase_awk_getrunerrlin(run)); + } +} + +JNIEXPORT jobject JNICALL Java_ase_awk_Awk_strtonum ( + JNIEnv* env, jobject obj, jlong runid, jstring str) +{ + const jchar* ptr; + jsize len; + jint n; + ase_long_t lv; + ase_real_t rv; + jobject ret; + run_data_t* run_data; + + len = (*env)->GetStringLength (env, str); + ptr = (*env)->GetStringChars (env, str, JNI_FALSE); + if (ptr == NULL) + { + (*env)->ExceptionClear (env); + throw_exception ( + env, + ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM), + ASE_AWK_ENOMEM, + 0); + return NULL; + } + + if (len > 0 && ASE_SIZEOF(jchar) != ASE_SIZEOF(ase_char_t)) + { + ase_size_t i; + ase_char_t* tmp = (ase_char_t*) + malloc (ASE_SIZEOF(ase_char_t)*len); + if (tmp == ASE_NULL) + { + (*env)->ReleaseStringChars (env, str, ptr); + throw_exception ( + env, + ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM), + ASE_AWK_ENOMEM, + 0); + return NULL; + } + + for (i = 0; i < len; i++) tmp[i] = (ase_char_t)ptr[i]; + n = ase_awk_strtonum ( + (ase_awk_run_t*)runid, tmp, len, &lv, &rv); + free (tmp); + } + else + { + n = ase_awk_strtonum ( + (ase_awk_run_t*)runid, + (ase_char_t*)ptr, len, &lv, &rv); + } + (*env)->ReleaseStringChars (env, str, ptr); + + run_data = ase_awk_getruncustomdata ((ase_awk_run_t*)runid); + if (n == 0) + { + ret = (*env)->NewObject (env, + run_data->long_class, + run_data->long_init, (jlong)lv); + } + else + { + ret = (*env)->NewObject (env, + run_data->double_class, + run_data->double_init, (jdouble)rv); + } + + return ret; +} + + +JNIEXPORT jstring JNICALL Java_ase_awk_Awk_valtostr ( + JNIEnv* env, jobject obj, jlong runid, jobject val) +{ + ase_awk_run_t* run = (ase_awk_run_t*)runid; + run_data_t* run_data; + jstring ret; + ase_awk_val_t* v; + ase_char_t* str; + ase_size_t len; + ase_awk_t* awk; + + awk = ase_awk_getrunawk (run); + + if (val == NULL) + { + ret = (*env)->NewString (env, NULL, 0); + + if (ret == NULL) + { + (*env)->ExceptionClear (env); + + throw_exception ( + env, + ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM), + ASE_AWK_ENOMEM, + 0); + } + return ret; + } + + run_data = ase_awk_getruncustomdata (run); + + if ((*env)->IsInstanceOf (env, val, run_data->string_class)) + { + const jchar* ptr; + + len = (*env)->GetStringLength (env, val); + ptr = (*env)->GetStringChars (env, val, JNI_FALSE); + if (ptr == NULL) + { + (*env)->ExceptionClear (env); + + throw_exception ( + env, + ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM), + ASE_AWK_ENOMEM, + 0); + + return NULL; + } + + ret = (*env)->NewString (env, ptr, len); + (*env)->ReleaseStringChars (env, ret, ptr); + return ret; + } + + if ((*env)->IsInstanceOf (env, val, run_data->integer_class)) + { + jint jv; + jv = (*env)->CallIntMethod ( + env, val, run_data->integer_value); + v = ase_awk_makeintval (run, jv); + } + else if ((*env)->IsInstanceOf (env, val, run_data->long_class)) + { + jlong jv = (*env)->CallLongMethod ( + env, val, run_data->long_value); + v = ase_awk_makeintval (run, jv); + } + else if ((*env)->IsInstanceOf (env, val, run_data->short_class)) + { + jshort jv = (*env)->CallShortMethod ( + env, val, run_data->short_value); + v = ase_awk_makeintval (run, jv); + } + else if ((*env)->IsInstanceOf (env, val, run_data->float_class)) + { + jfloat jv = (*env)->CallFloatMethod ( + env, val, run_data->float_value); + v = ase_awk_makerealval (run, jv); + } + else if ((*env)->IsInstanceOf (env, val, run_data->double_class)) + { + jdouble jv = (*env)->CallDoubleMethod ( + env, val, run_data->double_value); + v = ase_awk_makerealval (run, jv); + } + else + { + throw_exception ( + env, + ase_awk_geterrstr(ASE_NULL, ASE_AWK_EVALTYPE), + ASE_AWK_EVALTYPE, + 0); + return NULL; + } + + if (v == NULL) + { + throw_exception ( + env, + ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM), + ASE_AWK_ENOMEM, + 0); + return NULL; + } + + ase_awk_refupval (run, v); + str = ase_awk_valtostr (run, v, ASE_AWK_VALTOSTR_CLEAR, NULL, &len); + ase_awk_refdownval (run, v); + + if (str == NULL) + { + + throw_exception ( + env, + ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM), + ASE_AWK_ENOMEM, + 0); + return NULL; + } + + if (len > 0 && ASE_SIZEOF(jchar) != ASE_SIZEOF(ase_char_t)) + { + ase_size_t i; + jchar* tmp = (jchar*) malloc (ASE_SIZEOF(jchar)*len); + if (tmp == NULL) + { + ase_awk_free (awk, str); + throw_exception ( + env, + ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM), + ASE_AWK_ENOMEM, + 0); + return NULL; + } + + for (i = 0; i < len; i++) tmp[i] = (jchar)str[i]; + ret = (*env)->NewString (env, tmp, len); + free (tmp); + } + else + { + ret = (*env)->NewString (env, (jchar*)str, len); + } + + ase_awk_free (awk, str); + if (ret == NULL) + { + (*env)->ExceptionClear (env); + + throw_exception ( + env, + ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM), + ASE_AWK_ENOMEM, + 0); + } + + return ret; +} + diff --git a/ase/awk/jni.def b/ase/awk/jni.def new file mode 100644 index 00000000..d15dd6b9 --- /dev/null +++ b/ase/awk/jni.def @@ -0,0 +1,24 @@ +LIBRARY "aseawk_jni.dll" + +EXPORTS + Java_ase_awk_Awk_open + Java_ase_awk_Awk_close + Java_ase_awk_Awk_parse + Java_ase_awk_Awk_run + + Java_ase_awk_Awk_getmaxdepth + Java_ase_awk_Awk_setmaxdepth + + Java_ase_awk_Awk_getoption + Java_ase_awk_Awk_setoption + + Java_ase_awk_Awk_getdebug + Java_ase_awk_Awk_setdebug + + Java_ase_awk_Awk_addbfn + Java_ase_awk_Awk_delbfn + Java_ase_awk_Awk_setfilename + Java_ase_awk_Awk_setofilename + Java_ase_awk_Awk_strtonum + Java_ase_awk_Awk_valtostr + diff --git a/ase/awk/jni.h b/ase/awk/jni.h new file mode 100644 index 00000000..495e5b67 --- /dev/null +++ b/ase/awk/jni.h @@ -0,0 +1,60 @@ +/* + * $Id: jni.h,v 1.3 2007/04/30 05:47:33 bacon Exp $ + * + * {License} + */ + +#ifndef _ASE_AWK_JNI_H_ +#define _ASE_AWK_JNI_H_ + +#if defined(__APPLE__) && defined(__MACH__) +#include +#else +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +JNIEXPORT void JNICALL Java_ase_awk_Awk_open (JNIEnv* env, jobject obj); +JNIEXPORT void JNICALL Java_ase_awk_Awk_close (JNIEnv* env, jobject obj); +JNIEXPORT void JNICALL Java_ase_awk_Awk_parse (JNIEnv* env, jobject obj); +JNIEXPORT void JNICALL Java_ase_awk_Awk_run ( + JNIEnv* env, jobject obj, jstring mfn, jobjectArray args); + +JNIEXPORT void JNICALL Java_ase_awk_Awk_addbfn ( + JNIEnv* env, jobject obj, jstring name, jint min_args, jint max_args); +JNIEXPORT void JNICALL Java_ase_awk_Awk_delbfn ( + JNIEnv* env, jobject obj, jstring name); + +JNIEXPORT jint JNICALL Java_ase_awk_Awk_getmaxdepth ( + JNIEnv* env, jobject obj, jint id); +JNIEXPORT void JNICALL Java_ase_awk_Awk_setmaxdepth ( + JNIEnv* env, jobject obj, jint ids, jint depth); + +JNIEXPORT jint JNICALL Java_ase_awk_Awk_getoption ( + JNIEnv* env, jobject obj); +JNIEXPORT void JNICALL Java_ase_awk_Awk_setoption ( + JNIEnv* env, jobject obj, jint options); + +JNIEXPORT jboolean JNICALL Java_ase_awk_Awk_getdebug ( + JNIEnv* env, jobject obj); +JNIEXPORT void JNICALL Java_ase_awk_Awk_setdebug ( + JNIEnv* env, jobject obj, jboolean debug); + +JNIEXPORT void JNICALL Java_ase_awk_Awk_setfilename ( + JNIEnv* env, jobject obj, jlong runid, jstring name); +JNIEXPORT void JNICALL Java_ase_awk_Awk_setofilename ( + JNIEnv* env, jobject obj, jlong runid, jstring name); + +JNIEXPORT jobject JNICALL Java_ase_awk_Awk_strtonum ( + JNIEnv* env, jobject obj, jlong runid, jstring str); +JNIEXPORT jstring JNICALL Java_ase_awk_Awk_valtostr ( + JNIEnv* env, jobject obj, jlong runid, jobject val); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ase/awk/makefile.in b/ase/awk/makefile.in new file mode 100644 index 00000000..b06408f7 --- /dev/null +++ b/ase/awk/makefile.in @@ -0,0 +1,152 @@ +# +# $Id: makefile.in,v 1.3 2007/04/30 05:47:33 bacon Exp $ +# + +NAME = aseawk + +TOP_BUILDDIR = @abs_top_builddir@ +TOP_INSTALLDIR = @prefix@/ase + +CC = @CC@ +CXX = @CXX@ +AR = ar +RANLIB = @RANLIB@ +CFLAGS = @CFLAGS@ -I@abs_top_builddir@/.. +CXXFLAGS = @CXXFLAGS@ -I@abs_top_builddir@/.. +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ +MODE = @BUILDMODE@ + +JAVAC = @JAVAC@ +JAR = @JAR@ +CFLAGS_JNI = @CFLAGS_JNI@ +JNI = @JNI@ + +LIBTOOL_COMPILE = ../libtool --mode=compile +LIBTOOL_LINK = ../libtool --mode=link + +OUT_DIR = ../$(MODE)/lib +OUT_FILE_LIB = $(OUT_DIR)/lib$(NAME).a +OUT_FILE_JNI = $(OUT_DIR)/lib$(NAME)_jni.la +OUT_FILE_LIB_CXX = $(OUT_DIR)/lib$(NAME)++.a +OUT_FILE_JAR = $(OUT_DIR)/$(NAME).jar + +TMP_DIR = $(MODE) +TMP_DIR_CXX = $(TMP_DIR)/cxx + +OBJ_FILES_LIB = \ + $(TMP_DIR)/awk.o \ + $(TMP_DIR)/err.o \ + $(TMP_DIR)/tree.o \ + $(TMP_DIR)/tab.o \ + $(TMP_DIR)/map.o \ + $(TMP_DIR)/parse.o \ + $(TMP_DIR)/run.o \ + $(TMP_DIR)/rec.o \ + $(TMP_DIR)/val.o \ + $(TMP_DIR)/func.o \ + $(TMP_DIR)/misc.o \ + $(TMP_DIR)/extio.o \ + $(TMP_DIR)/rex.o + +OBJ_FILES_JNI = $(TMP_DIR)/jni.o + +OBJ_FILES_LIB_CXX = \ + $(OBJ_FILES_LIB) \ + $(TMP_DIR)/cxx/Awk.o + +OBJ_FILES_SO = $(OBJ_FILES_LIB:.o=.lo) $(OBJ_FILES_JNI:.o=.lo) + +OBJ_FILES_JAR = \ + $(TMP_DIR)/ase/awk/Awk.class \ + $(TMP_DIR)/ase/awk/StdAwk.class \ + $(TMP_DIR)/ase/awk/Extio.class \ + $(TMP_DIR)/ase/awk/Exception.class + +lib: build$(JNI) + +build: $(OUT_FILE_LIB) $(OUT_FILE_LIB_CXX) + +buildjni: build $(OUT_FILE_JNI) + +$(OUT_FILE_LIB): $(TMP_DIR) $(OUT_DIR) $(OBJ_FILES_LIB) + $(AR) cr $(OUT_FILE_LIB) $(OBJ_FILES_LIB) + if [ "$(RANLIB)" = "ranlib" ]; then ranlib $(OUT_FILE_LIB); fi + +$(OUT_FILE_JNI): $(TMP_DIR) $(OBJ_FILES_JNI) $(OBJ_FILES_JAR) $(OUT_FILE_LIB) + $(LIBTOOL_LINK) $(CC) -rpath $(TOP_INSTALLDIR)/lib -version-info 1:0:0 -o $(OUT_FILE_JNI) $(OBJ_FILES_SO) -lm -L$(OUT_DIR) -l$(NAME) -lasecmn -laseutl + $(JAR) -Mcvf $(OUT_FILE_JAR) -C $(TMP_DIR) ase + +$(OUT_FILE_LIB_CXX): $(TMP_DIR_CXX) $(OUT_DIR) $(OBJ_FILES_LIB_CXX) + $(AR) cr $(OUT_FILE_LIB_CXX) $(OBJ_FILES_LIB_CXX) + if [ "$(RANLIB)" = "ranlib" ]; then ranlib $(OUT_FILE_LIB_CXX); fi + +$(TMP_DIR)/awk.o: awk.c + $(LIBTOOL_COMPILE) $(CC) $(CFLAGS) -o $@ -c awk.c + +$(TMP_DIR)/err.o: err.c + $(LIBTOOL_COMPILE) $(CC) $(CFLAGS) -o $@ -c err.c + +$(TMP_DIR)/tree.o: tree.c + $(LIBTOOL_COMPILE) $(CC) $(CFLAGS) -o $@ -c tree.c + +$(TMP_DIR)/tab.o: tab.c + $(LIBTOOL_COMPILE) $(CC) $(CFLAGS) -o $@ -c tab.c + +$(TMP_DIR)/map.o: map.c + $(LIBTOOL_COMPILE) $(CC) $(CFLAGS) -o $@ -c map.c + +$(TMP_DIR)/parse.o: parse.c + $(LIBTOOL_COMPILE) $(CC) $(CFLAGS) -o $@ -c parse.c + +$(TMP_DIR)/run.o: run.c + $(LIBTOOL_COMPILE) $(CC) $(CFLAGS) -o $@ -c run.c + +$(TMP_DIR)/rec.o: rec.c + $(LIBTOOL_COMPILE) $(CC) $(CFLAGS) -o $@ -c rec.c + +$(TMP_DIR)/val.o: val.c + $(LIBTOOL_COMPILE) $(CC) $(CFLAGS) -o $@ -c val.c + +$(TMP_DIR)/func.o: func.c + $(LIBTOOL_COMPILE) $(CC) $(CFLAGS) -o $@ -c func.c + +$(TMP_DIR)/misc.o: misc.c + $(LIBTOOL_COMPILE) $(CC) $(CFLAGS) -o $@ -c misc.c + +$(TMP_DIR)/extio.o: extio.c + $(LIBTOOL_COMPILE) $(CC) $(CFLAGS) -o $@ -c extio.c + +$(TMP_DIR)/rex.o: rex.c + $(LIBTOOL_COMPILE) $(CC) $(CFLAGS) -o $@ -c rex.c + +$(TMP_DIR)/jni.o: jni.c + $(LIBTOOL_COMPILE) $(CC) $(CFLAGS) $(CFLAGS_JNI) -o $@ -c jni.c + +$(TMP_DIR)/ase/awk/Awk.class: + $(JAVAC) -classpath ../.. -d $(TMP_DIR) Awk.java + +$(TMP_DIR)/ase/awk/StdAwk.class: + $(JAVAC) -classpath ../.. -d $(TMP_DIR) StdAwk.java + +$(TMP_DIR)/ase/awk/Extio.class: + $(JAVAC) -classpath ../.. -d $(TMP_DIR) Extio.java + +$(TMP_DIR)/ase/awk/Exception.class: + $(JAVAC) -classpath ../.. -d $(TMP_DIR) Exception.java + +$(TMP_DIR)/cxx/Awk.o: + $(CXX) $(CXXFLAGS) -o $@ -c Awk.cpp + +$(OUT_DIR): + mkdir -p $(OUT_DIR) + +$(TMP_DIR): + mkdir -p $(TMP_DIR) + +$(TMP_DIR_CXX): $(TMP_DIR) + mkdir -p $(TMP_DIR)/cxx + +clean: + rm -rf $(OUT_FILE_LIB) $(OUT_FILE_JNI) $(OUT_FILE_JAR) $(OUT_FILE_LIB_CXX) $(OBJ_FILES_LIB) $(OBJ_FILES_JNI) $(OBJ_FILES_JAR) $(OBJ_FILES_LIB_CXX) + diff --git a/ase/awk/makefile.msw.bcc b/ase/awk/makefile.msw.bcc new file mode 100644 index 00000000..d6b74775 --- /dev/null +++ b/ase/awk/makefile.msw.bcc @@ -0,0 +1,54 @@ +OUT = aseawk + +C_SRCS = awk.c err.c tree.c tab.c map.c parse.c \ + run.c rec.c val.c func.c misc.c extio.c rex.c +JNI_SRCS = jni.c +JAVA_SRCS = Exception.java Extio.java Awk.java StdAwk.java + +C_OBJS = $(C_SRCS:.c=.obj) +JNI_OBJS = $(JNI_SRCS:.c=.obj) +JAVA_OBJS = $(JAVA_SRCS:.java=.class) + +JNI_INCPATH = \ + -I"$(JAVA_HOME)/include" \ + -I"$(JAVA_HOME)/include/win32" + +CC = bcc32 +LD = ilink32 +AR = tlib +JAVAC = javac + +CFLAGS_COMMON = -O2 -WM -WU -RT- -w -q -I../.. $(JNI_INCPATH) +CFLAGS_RELEASE = $(CFLAGS_COMMON) -DNDEBUG +CFLAGS_DEBUG = $(CFLAGS_COMMON) -D_DEBUG #-DDEBUG_REX +CFLAGS = $(CFLAGS_DEBUG) +#CFLAGS = $(CFLAGS_RELEASE) +JAVACFLAGS = -classpath ../.. + +LDFLAGS = -Tpd -ap -Gn -c -q +STARTUP = c0d32w.obj +LIBS = import32.lib cw32mt.lib + +JNI_LDFLAGS = $(LDFLAGS) -L..\cmn -L..\utl +JNI_LIBS = $(LIBS) $(OUT).lib asecmn.lib aseutl.lib + +all: lib + +lib: $(C_OBJS) + $(AR) $(OUT).lib @&&! ++-$(**: = &^ ++-) +! + +jni: lib $(JNI_OBJS) $(JAVA_OBJS) + $(LD) $(JNI_LDFLAGS) $(STARTUP) $(JNI_OBJS),$(OUT)_jni.dll,,$(JNI_LIBS),jni.def, + +clean: + -del $(OBJS) $(OUT).lib $(OUT)_jni.dll *.obj *.class + +.SUFFIXES: .c .obj .java .class +.c.obj: + $(CC) $(CFLAGS) -c $< + +.java.class: + $(JAVAC) $(JAVACFLAGS) $< diff --git a/ase/awk/makefile.msw.cl b/ase/awk/makefile.msw.cl new file mode 100644 index 00000000..9356e259 --- /dev/null +++ b/ase/awk/makefile.msw.cl @@ -0,0 +1,45 @@ +OUT = aseawk + +C_SRCS = awk.c err.c tree.c tab.c map.c parse.c \ + run.c rec.c val.c func.c misc.c extio.c rex.c +JNI_SRCS = jni.c +JAVA_SRCS = Exception.java Extio.java Awk.java StdAwk.java + +C_OBJS = $(C_SRCS:.c=.obj) +JNI_OBJS = $(JNI_SRCS:.c=.obj) +JAVA_OBJS = $(JAVA_SRCS:.java=.class) + +JNI_INC = \ + /I"$(JAVA_HOME)/include" \ + /I"$(JAVA_HOME)/include\win32" + +CC = cl +LD = link +JAVAC = javac + +#CFLAGS = /nologo /O2 /MT /W3 /GR- /GS- /Za -I../.. $(JNI_INC) +CFLAGS = /nologo /O2 /MT /W3 /GR- /GS- -I../.. $(JNI_INC) +JAVACFLAGS = -classpath ../.. -Xlint:unchecked + +all: lib + +lib: $(C_OBJS) + $(LD) /lib @<< +/nologo /out:$(OUT).lib $(C_OBJS) +<< + +jni: lib $(JNI_OBJS) $(JAVA_OBJS) + $(LD) /dll /def:jni.def /subsystem:windows /version:0.1 /release @<< +/nologo /out:$(OUT)_jni.dll $(JNI_OBJS) /libpath:../cmn /libpath:../utl /implib:tmp.lib user32.lib $(OUT).lib asecmn.lib aseutl.lib +<< + del tmp.lib tmp.exp + +clean: + del $(OBJS) $(OUT).lib $(OUT)_jni.dll *.obj *.class + +.SUFFIXES: .c .obj .java .class +.c.obj: + $(CC) $(CFLAGS) /c $< + +.java.class: + $(JAVAC) $(JAVACFLAGS) $< diff --git a/ase/awk/map.c b/ase/awk/map.c new file mode 100644 index 00000000..82487744 --- /dev/null +++ b/ase/awk/map.c @@ -0,0 +1,289 @@ +/* + * $Id: map.c,v 1.3 2007/04/30 05:47:33 bacon Exp $ + * + * {License} + */ + +#include + +/* TODO: improve the entire map routines. + support automatic bucket resizing and remaping, etc. */ + +static ase_size_t hashkey (const ase_char_t* keyptr, ase_size_t keylen); + +#define FREE_PAIR(map,pair) \ + do { \ + ASE_AWK_FREE ((map)->awk, (ase_char_t*)PAIR_KEYPTR(pair)); \ + if ((map)->freeval != ASE_NULL) \ + (map)->freeval ((map)->owner, PAIR_VAL(pair)); \ + ASE_AWK_FREE ((map)->awk, pair); \ + } while (0) + +ase_awk_map_t* ase_awk_map_open ( + ase_awk_map_t* map, void* owner, ase_size_t capa, + void(*freeval)(void*,void*), ase_awk_t* awk) +{ + ASE_ASSERTX (capa > 0, "the initial capacity should be greater than 0"); + + if (map == ASE_NULL) + { + map = (ase_awk_map_t*) ASE_AWK_MALLOC ( + awk, ASE_SIZEOF(ase_awk_map_t)); + if (map == ASE_NULL) return ASE_NULL; + map->__dynamic = ase_true; + } + else map->__dynamic = ase_false; + + map->awk = awk; + map->buck = (ase_awk_pair_t**) + ASE_AWK_MALLOC (awk, ASE_SIZEOF(ase_awk_pair_t*) * capa); + if (map->buck == ASE_NULL) + { + if (map->__dynamic) ASE_AWK_FREE (awk, map); + return ASE_NULL; + } + + map->owner = owner; + map->capa = capa; + map->size = 0; + map->freeval = freeval; + while (capa > 0) map->buck[--capa] = ASE_NULL; + + return map; +} + +void ase_awk_map_close (ase_awk_map_t* map) +{ + ase_awk_map_clear (map); + ASE_AWK_FREE (map->awk, map->buck); + if (map->__dynamic) ASE_AWK_FREE (map->awk, map); +} + +void ase_awk_map_clear (ase_awk_map_t* map) +{ + ase_size_t i; + ase_awk_pair_t* pair, * next; + + for (i = 0; i < map->capa; i++) + { + pair = map->buck[i]; + + while (pair != ASE_NULL) + { + next = PAIR_LNK(pair); + FREE_PAIR (map, pair); + map->size--; + pair = next; + } + + map->buck[i] = ASE_NULL; + } +} + +ase_size_t ase_awk_map_getsize (ase_awk_map_t* map) +{ + return map->size; +} + +ase_awk_pair_t* ase_awk_map_get ( + ase_awk_map_t* map, const ase_char_t* keyptr, ase_size_t keylen) +{ + ase_awk_pair_t* pair; + ase_size_t hc; + + hc = hashkey(keyptr,keylen) % map->capa; + pair = map->buck[hc]; + + while (pair != ASE_NULL) + { + + if (ase_strxncmp ( + PAIR_KEYPTR(pair), PAIR_KEYLEN(pair), + keyptr, keylen) == 0) return pair; + + pair = PAIR_LNK(pair); + } + + return ASE_NULL; +} + +ase_awk_pair_t* ase_awk_map_put ( + ase_awk_map_t* map, ase_char_t* keyptr, ase_size_t keylen, void* val) +{ + int n; + ase_awk_pair_t* px; + + n = ase_awk_map_putx (map, keyptr, keylen, val, &px); + if (n < 0) return ASE_NULL; + return px; +} + +int ase_awk_map_putx ( + ase_awk_map_t* map, ase_char_t* keyptr, ase_size_t keylen, + void* val, ase_awk_pair_t** px) +{ + ase_awk_pair_t* pair; + ase_size_t hc; + + hc = hashkey(keyptr,keylen) % map->capa; + pair = map->buck[hc]; + + while (pair != ASE_NULL) + { + if (ase_strxncmp ( + PAIR_KEYPTR(pair), PAIR_KEYLEN(pair), + keyptr, keylen) == 0) + { + if (px != ASE_NULL) + *px = ase_awk_map_setpair (map, pair, val); + else + ase_awk_map_setpair (map, pair, val); + + return 0; /* value changed for the existing key */ + } + pair = PAIR_LNK(pair); + } + + pair = (ase_awk_pair_t*) ASE_AWK_MALLOC ( + map->awk, ASE_SIZEOF(ase_awk_pair_t)); + if (pair == ASE_NULL) return -1; /* error */ + + /* duplicate the key if it is new */ + PAIR_KEYPTR(pair) = ase_strxdup ( + keyptr, keylen, &map->awk->prmfns.mmgr); + if (PAIR_KEYPTR(pair) == ASE_NULL) + { + ASE_AWK_FREE (map->awk, pair); + return -1; /* error */ + } + + PAIR_KEYLEN(pair) = keylen; + PAIR_VAL(pair) = val; + PAIR_LNK(pair) = map->buck[hc]; + map->buck[hc] = pair; + map->size++; + + if (px != ASE_NULL) *px = pair; + return 1; /* new key added */ +} + +ase_awk_pair_t* ase_awk_map_set ( + ase_awk_map_t* map, ase_char_t* keyptr, ase_size_t keylen, void* val) +{ + ase_awk_pair_t* pair; + ase_size_t hc; + + hc = hashkey(keyptr,keylen) % map->capa; + pair = map->buck[hc]; + + while (pair != ASE_NULL) + { + if (ase_strxncmp ( + PAIR_KEYPTR(pair), PAIR_KEYLEN(pair), + keyptr, keylen) == 0) + { + return ase_awk_map_setpair (map, pair, val); + } + pair = PAIR_LNK(pair); + } + + return ASE_NULL; +} + +ase_awk_pair_t* ase_awk_map_getpair ( + ase_awk_map_t* map, const ase_char_t* keyptr, ase_size_t keylen, + void** val) +{ + ase_awk_pair_t* pair; + + pair = ase_awk_map_get (map, keyptr, keylen); + if (pair == ASE_NULL) return ASE_NULL; + *val = PAIR_VAL(pair); + + return pair; +} + +ase_awk_pair_t* ase_awk_map_setpair ( + ase_awk_map_t* map, ase_awk_pair_t* pair, void* val) +{ + /* use this function with care */ + if (PAIR_VAL(pair) != val) + { + if (map->freeval != ASE_NULL) + { + map->freeval (map->owner, PAIR_VAL(pair)); + } + PAIR_VAL(pair) = val; + } + + return pair; +} + +int ase_awk_map_remove ( + ase_awk_map_t* map, ase_char_t* keyptr, ase_size_t keylen) +{ + ase_awk_pair_t* pair, * prev; + ase_size_t hc; + + hc = hashkey(keyptr,keylen) % map->capa; + pair = map->buck[hc]; + prev = ASE_NULL; + + while (pair != ASE_NULL) + { + if (ase_strxncmp ( + PAIR_KEYPTR(pair), PAIR_KEYLEN(pair), + keyptr, keylen) == 0) + { + if (prev == ASE_NULL) + map->buck[hc] = PAIR_LNK(pair); + else prev->next = PAIR_LNK(pair); + + FREE_PAIR (map, pair); + map->size--; + + return 0; + } + + prev = pair; + pair = PAIR_LNK(pair); + } + + return -1; +} + +int ase_awk_map_walk (ase_awk_map_t* map, + int (*walker) (ase_awk_pair_t*,void*), void* arg) +{ + ase_size_t i; + ase_awk_pair_t* pair, * next; + + for (i = 0; i < map->capa; i++) + { + pair = map->buck[i]; + + while (pair != ASE_NULL) + { + next = PAIR_LNK(pair); + if (walker(pair,arg) == -1) return -1; + pair = next; + } + } + + return 0; +} + +static ase_size_t hashkey (const ase_char_t* keyptr, ase_size_t keylen) +{ + ase_size_t n = 0, i; + const ase_char_t* end = keyptr + keylen; + + while (keyptr < end) + { + ase_byte_t* bp = (ase_byte_t*)keyptr; + for (i = 0; i < ASE_SIZEOF(*keyptr); i++) n = n * 31 + *bp++; + keyptr++; + } + + return n; +} diff --git a/ase/awk/map.h b/ase/awk/map.h new file mode 100644 index 00000000..dd16ff2f --- /dev/null +++ b/ase/awk/map.h @@ -0,0 +1,89 @@ +/* + * $Id: map.h,v 1.3 2007/04/30 05:47:33 bacon Exp $ + * + * {License} + */ + +#ifndef _ASE_AWK_MAP_H_ +#define _ASE_AWK_MAP_H_ + +#ifndef _ASE_AWK_AWK_H_ +#error Include first +#endif + +/*typedef struct ase_awk_map_t ase_awk_map_t;*/ +typedef struct ase_awk_pair_t ase_awk_pair_t; + +struct ase_awk_pair_t +{ + struct + { + ase_char_t* ptr; + ase_size_t len; + } key; + + void* val; + ase_awk_pair_t* next; +}; + +struct ase_awk_map_t +{ + void* owner; + ase_size_t size; + ase_size_t capa; + ase_awk_pair_t** buck; + void (*freeval) (void*,void*); + ase_awk_t* awk; + ase_bool_t __dynamic; +}; + +#define PAIR_KEYPTR(p) ((p)->key.ptr) +#define PAIR_KEYLEN(p) ((p)->key.len) +#define PAIR_VAL(p) ((p)->val) +#define PAIR_LNK(p) ((p)->next) + +#ifdef __cplusplus +extern "C" { +#endif + +ase_awk_map_t* ase_awk_map_open ( + ase_awk_map_t* map, void* owner, ase_size_t capa, + void(*freeval)(void*,void*), ase_awk_t* awk); + +void ase_awk_map_close (ase_awk_map_t* map); + +void ase_awk_map_clear (ase_awk_map_t* map); + +ase_size_t ase_awk_map_getsize (ase_awk_map_t* map); + +ase_awk_pair_t* ase_awk_map_get ( + ase_awk_map_t* map, const ase_char_t* keyptr, ase_size_t keylen); + +ase_awk_pair_t* ase_awk_map_put ( + ase_awk_map_t* map, ase_char_t* keyptr, ase_size_t keylen, void* val); + +int ase_awk_map_putx ( + ase_awk_map_t* map, ase_char_t* keyptr, ase_size_t keylen, + void* val, ase_awk_pair_t** px); + +ase_awk_pair_t* ase_awk_map_set ( + ase_awk_map_t* map, ase_char_t* keyptr, ase_size_t keylen, void* val); + +ase_awk_pair_t* ase_awk_map_getpair ( + ase_awk_map_t* map, const ase_char_t* keyptr, ase_size_t keylen, + void** val); + +ase_awk_pair_t* ase_awk_map_setpair ( + ase_awk_map_t* map, ase_awk_pair_t* pair, void* val); + +int ase_awk_map_remove ( + ase_awk_map_t* map, ase_char_t* keyptr, ase_size_t keylen); + +int ase_awk_map_walk (ase_awk_map_t* map, + int (*walker)(ase_awk_pair_t*,void*), void* arg); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ase/awk/misc.c b/ase/awk/misc.c new file mode 100644 index 00000000..98b6632e --- /dev/null +++ b/ase/awk/misc.c @@ -0,0 +1,905 @@ +/* + * $Id: misc.c,v 1.3 2007/04/30 05:47:33 bacon Exp $ + * + * {License} + */ + +#include + +void* ase_awk_malloc (ase_awk_t* awk, ase_size_t size) +{ + return ASE_AWK_MALLOC (awk, size); +} + +void ase_awk_free (ase_awk_t* awk, void* ptr) +{ + ASE_AWK_FREE (awk, ptr); +} + +ase_long_t ase_awk_strxtolong ( + ase_awk_t* awk, const ase_char_t* str, ase_size_t len, + int base, const ase_char_t** endptr) +{ + ase_long_t n = 0; + const ase_char_t* p; + const ase_char_t* end; + ase_size_t rem; + int digit, negative = 0; + + ASE_ASSERT (base < 37); + + p = str; + end = str + len; + + /* strip off leading spaces */ + /*while (ASE_AWK_ISSPACE(awk,*p)) p++;*/ + + /* check for a sign */ + /*while (*p != ASE_T('\0')) */ + while (p < end) + { + if (*p == ASE_T('-')) + { + negative = ~negative; + p++; + } + else if (*p == ASE_T('+')) p++; + else break; + } + + /* check for a binary/octal/hexadecimal notation */ + rem = end - p; + if (base == 0) + { + if (rem >= 1 && *p == ASE_T('0')) + { + p++; + + if (rem == 1) base = 8; + else if (*p == ASE_T('x') || *p == ASE_T('X')) + { + p++; base = 16; + } + else if (*p == ASE_T('b') || *p == ASE_T('B')) + { + p++; base = 2; + } + else base = 8; + } + else base = 10; + } + else if (rem >= 2 && base == 16) + { + if (*p == ASE_T('0') && + (*(p+1) == ASE_T('x') || *(p+1) == ASE_T('X'))) p += 2; + } + else if (rem >= 2 && base == 2) + { + if (*p == ASE_T('0') && + (*(p+1) == ASE_T('b') || *(p+1) == ASE_T('B'))) p += 2; + } + + /* process the digits */ + /*while (*p != ASE_T('\0'))*/ + while (p < end) + { + if (*p >= ASE_T('0') && *p <= ASE_T('9')) + digit = *p - ASE_T('0'); + else if (*p >= ASE_T('A') && *p <= ASE_T('Z')) + digit = *p - ASE_T('A') + 10; + else if (*p >= ASE_T('a') && *p <= ASE_T('z')) + digit = *p - ASE_T('a') + 10; + else break; + + if (digit >= base) break; + n = n * base + digit; + + p++; + } + + if (endptr != ASE_NULL) *endptr = p; + return (negative)? -n: n; +} + + +/* + * ase_awk_strtoreal is almost a replica of strtod. + * + * strtod.c -- + * + * Source code for the "strtod" library procedure. + * + * Copyright (c) 1988-1993 The Regents of the University of California. + * Copyright (c) 1994 Sun Microsystems, Inc. + * + * Permission to use, copy, modify, and distribute this + * software and its documentation for any purpose and without + * fee is hereby granted, provided that the above copyright + * notice appear in all copies. The University of California + * makes no representations about the suitability of this + * software for any purpose. It is provided "as is" without + * express or implied warranty. + */ + +#define MAX_EXPONENT 511 + +ase_real_t ase_awk_strtoreal (ase_awk_t* awk, const ase_char_t* str) +{ + /* + * Table giving binary powers of 10. Entry is 10^2^i. + * Used to convert decimal exponents into floating-point numbers. + */ + static ase_real_t powers_of_10[] = + { + 10., 100., 1.0e4, 1.0e8, 1.0e16, + 1.0e32, 1.0e64, 1.0e128, 1.0e256 + }; + + ase_real_t fraction, dbl_exp, * d; + const ase_char_t* p; + ase_cint_t c; + int exp = 0; /* Esseonent read from "EX" field */ + + /* + * Esseonent that derives from the fractional part. Under normal + * circumstatnces, it is the negative of the number of digits in F. + * However, if I is very long, the last digits of I get dropped + * (otherwise a long I with a large negative exponent could cause an + * unnecessary overflow on I alone). In this case, frac_exp is + * incremented one for each dropped digit. + */ + + int frac_exp; + int mant_size; /* Number of digits in mantissa. */ + int dec_pt; /* Number of mantissa digits BEFORE decimal point */ + const ase_char_t *pexp; /* Temporarily holds location of exponent in string */ + int negative = 0, exp_negative = 0; + + p = str; + + /* strip off leading blanks */ + /*while (ASE_AWK_ISSPACE(awk,*p)) p++;*/ + + /* check for a sign */ + while (*p != ASE_T('\0')) + { + if (*p == ASE_T('-')) + { + negative = ~negative; + p++; + } + else if (*p == ASE_T('+')) p++; + else break; + } + + /* Count the number of digits in the mantissa (including the decimal + * point), and also locate the decimal point. */ + dec_pt = -1; + for (mant_size = 0; ; mant_size++) + { + c = *p; + if (!ASE_AWK_ISDIGIT (awk, c)) + { + if ((c != ASE_T('.')) || (dec_pt >= 0)) break; + dec_pt = mant_size; + } + p++; + } + + /* + * Now suck up the digits in the mantissa. Use two integers to + * collect 9 digits each (this is faster than using floating-point). + * If the mantissa has more than 18 digits, ignore the extras, since + * they can't affect the value anyway. + */ + pexp = p; + p -= mant_size; + if (dec_pt < 0) + { + dec_pt = mant_size; + } + else + { + mant_size--; /* One of the digits was the point */ + } + + if (mant_size > 18) + { + frac_exp = dec_pt - 18; + mant_size = 18; + } + else + { + frac_exp = dec_pt - mant_size; + } + + if (mant_size == 0) + { + fraction = 0.0; + /*p = str;*/ + p = pexp; + goto done; + } + else + { + int frac1, frac2; + frac1 = 0; + for ( ; mant_size > 9; mant_size--) + { + c = *p; + p++; + if (c == ASE_T('.')) + { + c = *p; + p++; + } + frac1 = 10 * frac1 + (c - ASE_T('0')); + } + frac2 = 0; + for (; mant_size > 0; mant_size--) { + c = *p; + p++; + if (c == ASE_T('.')) + { + c = *p; + p++; + } + frac2 = 10*frac2 + (c - ASE_T('0')); + } + fraction = (1.0e9 * frac1) + frac2; + } + + /* Skim off the exponent */ + p = pexp; + if ((*p == ASE_T('E')) || (*p == ASE_T('e'))) + { + p++; + if (*p == ASE_T('-')) + { + exp_negative = 1; + p++; + } + else + { + if (*p == ASE_T('+')) p++; + exp_negative = 0; + } + if (!ASE_AWK_ISDIGIT (awk, *p)) + { + /* p = pexp; */ + /* goto done; */ + goto no_exp; + } + while (ASE_AWK_ISDIGIT (awk, *p)) + { + exp = exp * 10 + (*p - ASE_T('0')); + p++; + } + } + +no_exp: + if (exp_negative) exp = frac_exp - exp; + else exp = frac_exp + exp; + + /* + * Generate a floating-point number that represents the exponent. + * Do this by processing the exponent one bit at a time to combine + * many powers of 2 of 10. Then combine the exponent with the + * fraction. + */ + if (exp < 0) + { + exp_negative = 1; + exp = -exp; + } + else exp_negative = 0; + + if (exp > MAX_EXPONENT) exp = MAX_EXPONENT; + + dbl_exp = 1.0; + + for (d = powers_of_10; exp != 0; exp >>= 1, d++) + { + if (exp & 01) dbl_exp *= *d; + } + + if (exp_negative) fraction /= dbl_exp; + else fraction *= dbl_exp; + +done: + return (negative)? -fraction: fraction; +} + +ase_real_t ase_awk_strxtoreal ( + ase_awk_t* awk, const ase_char_t* str, ase_size_t len, + const ase_char_t** endptr) +{ + /* + * Table giving binary powers of 10. Entry is 10^2^i. + * Used to convert decimal exponents into floating-point numbers. + */ + static ase_real_t powers_of_10[] = + { + 10., 100., 1.0e4, 1.0e8, 1.0e16, + 1.0e32, 1.0e64, 1.0e128, 1.0e256 + }; + + ase_real_t fraction, dbl_exp, * d; + const ase_char_t* p, * end; + ase_cint_t c; + int exp = 0; /* Esseonent read from "EX" field */ + + /* + * Esseonent that derives from the fractional part. Under normal + * circumstatnces, it is the negative of the number of digits in F. + * However, if I is very long, the last digits of I get dropped + * (otherwise a long I with a large negative exponent could cause an + * unnecessary overflow on I alone). In this case, frac_exp is + * incremented one for each dropped digit. + */ + + int frac_exp; + int mant_size; /* Number of digits in mantissa. */ + int dec_pt; /* Number of mantissa digits BEFORE decimal point */ + const ase_char_t *pexp; /* Temporarily holds location of exponent in string */ + int negative = 0, exp_negative = 0; + + p = str; + end = str + len; + + /* Strip off leading blanks and check for a sign */ + /*while (ASE_AWK_ISSPACE(awk,*p)) p++;*/ + + /*while (*p != ASE_T('\0')) */ + while (p < end) + { + if (*p == ASE_T('-')) + { + negative = ~negative; + p++; + } + else if (*p == ASE_T('+')) p++; + else break; + } + + /* Count the number of digits in the mantissa (including the decimal + * point), and also locate the decimal point. */ + dec_pt = -1; + /*for (mant_size = 0; ; mant_size++) */ + for (mant_size = 0; p < end; mant_size++) + { + c = *p; + if (!ASE_AWK_ISDIGIT (awk, c)) + { + if (c != ASE_T('.') || dec_pt >= 0) break; + dec_pt = mant_size; + } + p++; + } + + /* + * Now suck up the digits in the mantissa. Use two integers to + * collect 9 digits each (this is faster than using floating-point). + * If the mantissa has more than 18 digits, ignore the extras, since + * they can't affect the value anyway. + */ + pexp = p; + p -= mant_size; + if (dec_pt < 0) + { + dec_pt = mant_size; + } + else + { + mant_size--; /* One of the digits was the point */ + } + + if (mant_size > 18) /* TODO: is 18 correct for ase_real_t??? */ + { + frac_exp = dec_pt - 18; + mant_size = 18; + } + else + { + frac_exp = dec_pt - mant_size; + } + + if (mant_size == 0) + { + fraction = 0.0; + /*p = str;*/ + p = pexp; + goto done; + } + else + { + int frac1, frac2; + + frac1 = 0; + for ( ; mant_size > 9; mant_size--) + { + c = *p; + p++; + if (c == ASE_T('.')) + { + c = *p; + p++; + } + frac1 = 10 * frac1 + (c - ASE_T('0')); + } + + frac2 = 0; + for (; mant_size > 0; mant_size--) { + c = *p++; + if (c == ASE_T('.')) + { + c = *p; + p++; + } + frac2 = 10 * frac2 + (c - ASE_T('0')); + } + fraction = (1.0e9 * frac1) + frac2; + } + + /* Skim off the exponent */ + p = pexp; + if (p < end && (*p == ASE_T('E') || *p == ASE_T('e'))) + { + p++; + + if (p < end) + { + if (*p == ASE_T('-')) + { + exp_negative = 1; + p++; + } + else + { + if (*p == ASE_T('+')) p++; + exp_negative = 0; + } + } + else exp_negative = 0; + + if (!(p < end && ASE_AWK_ISDIGIT (awk, *p))) + { + /*p = pexp;*/ + /*goto done;*/ + goto no_exp; + } + + while (p < end && ASE_AWK_ISDIGIT (awk, *p)) + { + exp = exp * 10 + (*p - ASE_T('0')); + p++; + } + } + +no_exp: + if (exp_negative) exp = frac_exp - exp; + else exp = frac_exp + exp; + + /* + * Generate a floating-point number that represents the exponent. + * Do this by processing the exponent one bit at a time to combine + * many powers of 2 of 10. Then combine the exponent with the + * fraction. + */ + if (exp < 0) + { + exp_negative = 1; + exp = -exp; + } + else exp_negative = 0; + + if (exp > MAX_EXPONENT) exp = MAX_EXPONENT; + + dbl_exp = 1.0; + + for (d = powers_of_10; exp != 0; exp >>= 1, d++) + { + if (exp & 01) dbl_exp *= *d; + } + + if (exp_negative) fraction /= dbl_exp; + else fraction *= dbl_exp; + +done: + if (endptr != ASE_NULL) *endptr = p; + return (negative)? -fraction: fraction; +} + +ase_size_t ase_awk_longtostr ( + ase_long_t value, int radix, const ase_char_t* prefix, + ase_char_t* buf, ase_size_t size) +{ + ase_long_t t, rem; + ase_size_t len, ret, i; + ase_size_t prefix_len; + + prefix_len = (prefix != ASE_NULL)? ase_strlen(prefix): 0; + + t = value; + if (t == 0) + { + /* zero */ + if (buf == ASE_NULL) + { + /* if buf is not given, + * return the number of bytes required */ + return prefix_len + 1; + } + + if (size < prefix_len+1) + { + /* buffer too small */ + return (ase_size_t)-1; + } + + for (i = 0; i < prefix_len; i++) buf[i] = prefix[i]; + buf[prefix_len] = ASE_T('0'); + if (size > prefix_len+1) buf[prefix_len+1] = ASE_T('\0'); + return prefix_len+1; + } + + /* non-zero values */ + len = prefix_len; + if (t < 0) { t = -t; len++; } + while (t > 0) { len++; t /= radix; } + + if (buf == ASE_NULL) + { + /* if buf is not given, return the number of bytes required */ + return len; + } + + if (size < len) return (ase_size_t)-1; /* buffer too small */ + if (size > len) buf[len] = ASE_T('\0'); + ret = len; + + t = value; + if (t < 0) t = -t; + + while (t > 0) + { + rem = t % radix; + if (rem >= 10) + buf[--len] = (ase_char_t)rem + ASE_T('a') - 10; + else + buf[--len] = (ase_char_t)rem + ASE_T('0'); + t /= radix; + } + + if (value < 0) + { + for (i = 1; i <= prefix_len; i++) + { + buf[i] = prefix[i-1]; + len--; + } + buf[--len] = ASE_T('-'); + } + else + { + for (i = 0; i < prefix_len; i++) buf[i] = prefix[i]; + } + + return ret; +} + +ase_char_t* ase_awk_strtok ( + ase_awk_run_t* run, const ase_char_t* s, + const ase_char_t* delim, ase_char_t** tok, ase_size_t* tok_len) +{ + return ase_awk_strxntok ( + run, s, ase_strlen(s), + delim, ase_strlen(delim), tok, tok_len); +} + +ase_char_t* ase_awk_strxtok ( + ase_awk_run_t* run, const ase_char_t* s, ase_size_t len, + const ase_char_t* delim, ase_char_t** tok, ase_size_t* tok_len) +{ + return ase_awk_strxntok ( + run, s, len, + delim, ase_strlen(delim), tok, tok_len); +} + +ase_char_t* ase_awk_strntok ( + ase_awk_run_t* run, const ase_char_t* s, + const ase_char_t* delim, ase_size_t delim_len, + ase_char_t** tok, ase_size_t* tok_len) +{ + return ase_awk_strxntok ( + run, s, ase_strlen(s), + delim, delim_len, tok, tok_len); +} + +ase_char_t* ase_awk_strxntok ( + ase_awk_run_t* run, const ase_char_t* s, ase_size_t len, + const ase_char_t* delim, ase_size_t delim_len, + ase_char_t** tok, ase_size_t* tok_len) +{ + const ase_char_t* p = s, *d; + const ase_char_t* end = s + len; + const ase_char_t* sp = ASE_NULL, * ep = ASE_NULL; + const ase_char_t* delim_end = delim + delim_len; + ase_char_t c; + int delim_mode; + +#define __DELIM_NULL 0 +#define __DELIM_EMPTY 1 +#define __DELIM_SPACES 2 +#define __DELIM_NOSPACES 3 +#define __DELIM_COMPOSITE 4 + if (delim == ASE_NULL) delim_mode = __DELIM_NULL; + else + { + delim_mode = __DELIM_EMPTY; + + for (d = delim; d < delim_end; d++) + { + if (ASE_AWK_ISSPACE(run->awk,*d)) + { + if (delim_mode == __DELIM_EMPTY) + delim_mode = __DELIM_SPACES; + else if (delim_mode == __DELIM_NOSPACES) + { + delim_mode = __DELIM_COMPOSITE; + break; + } + } + else + { + if (delim_mode == __DELIM_EMPTY) + delim_mode = __DELIM_NOSPACES; + else if (delim_mode == __DELIM_SPACES) + { + delim_mode = __DELIM_COMPOSITE; + break; + } + } + } + + /* TODO: verify the following statement... */ + if (delim_mode == __DELIM_SPACES && + delim_len == 1 && + delim[0] != ASE_T(' ')) delim_mode = __DELIM_NOSPACES; + } + + if (delim_mode == __DELIM_NULL) + { + /* when ASE_NULL is given as "delim", it trims off the + * leading and trailing spaces characters off the source + * string "s" eventually. */ + + while (p < end && ASE_AWK_ISSPACE(run->awk,*p)) p++; + while (p < end) + { + c = *p; + + if (!ASE_AWK_ISSPACE(run->awk,c)) + { + if (sp == ASE_NULL) sp = p; + ep = p; + } + p++; + } + } + else if (delim_mode == __DELIM_EMPTY) + { + /* each character in the source string "s" becomes a token. */ + if (p < end) + { + c = *p; + sp = p; + ep = p++; + } + } + else if (delim_mode == __DELIM_SPACES) + { + /* each token is delimited by space characters. all leading + * and trailing spaces are removed. */ + + while (p < end && ASE_AWK_ISSPACE(run->awk,*p)) p++; + while (p < end) + { + c = *p; + if (ASE_AWK_ISSPACE(run->awk,c)) break; + if (sp == ASE_NULL) sp = p; + ep = p++; + } + while (p < end && ASE_AWK_ISSPACE(run->awk,*p)) p++; + } + else if (delim_mode == __DELIM_NOSPACES) + { + /* each token is delimited by one of charaters + * in the delimeter set "delim". */ + if (run->global.ignorecase) + { + while (p < end) + { + c = ASE_AWK_TOUPPER(run->awk, *p); + for (d = delim; d < delim_end; d++) + { + if (c == ASE_AWK_TOUPPER(run->awk,*d)) goto exit_loop; + } + + if (sp == ASE_NULL) sp = p; + ep = p++; + } + } + else + { + while (p < end) + { + c = *p; + for (d = delim; d < delim_end; d++) + { + if (c == *d) goto exit_loop; + } + + if (sp == ASE_NULL) sp = p; + ep = p++; + } + } + } + else /* if (delim_mode == __DELIM_COMPOSITE) */ + { + /* each token is delimited by one of non-space charaters + * in the delimeter set "delim". however, all space characters + * surrounding the token are removed */ + while (p < end && ASE_AWK_ISSPACE(run->awk,*p)) p++; + if (run->global.ignorecase) + { + while (p < end) + { + c = ASE_AWK_TOUPPER(run->awk, *p); + if (ASE_AWK_ISSPACE(run->awk,c)) + { + p++; + continue; + } + for (d = delim; d < delim_end; d++) + { + if (c == ASE_AWK_TOUPPER(run->awk,*d)) goto exit_loop; + } + if (sp == ASE_NULL) sp = p; + ep = p++; + } + } + else + { + while (p < end) + { + c = *p; + if (ASE_AWK_ISSPACE(run->awk,c)) + { + p++; + continue; + } + for (d = delim; d < delim_end; d++) + { + if (c == *d) goto exit_loop; + } + if (sp == ASE_NULL) sp = p; + ep = p++; + } + } + } + +exit_loop: + if (sp == ASE_NULL) + { + *tok = ASE_NULL; + *tok_len = (ase_size_t)0; + } + else + { + *tok = (ase_char_t*)sp; + *tok_len = ep - sp + 1; + } + + /* if ASE_NULL is returned, this function should not be called anymore */ + if (p >= end) return ASE_NULL; + if (delim_mode == __DELIM_EMPTY || + delim_mode == __DELIM_SPACES) return (ase_char_t*)p; + return (ase_char_t*)++p; +} + +ase_char_t* ase_awk_strxntokbyrex ( + ase_awk_run_t* run, const ase_char_t* s, ase_size_t len, + void* rex, ase_char_t** tok, ase_size_t* tok_len, int* errnum) +{ + int n; + ase_char_t* match_ptr; + ase_size_t match_len, i; + ase_size_t left = len; + const ase_char_t* ptr = s; + const ase_char_t* str_ptr = s; + ase_size_t str_len = len; + + while (len > 0) + { + n = ase_awk_matchrex ( + run->awk, rex, + ((run->global.ignorecase)? ASE_AWK_REX_IGNORECASE: 0), + ptr, left, (const ase_char_t**)&match_ptr, &match_len, + errnum); + if (n == -1) return ASE_NULL; + if (n == 0) + { + /* no match has been found. + * return the entire string as a token */ + *tok = (ase_char_t*)str_ptr; + *tok_len = str_len; + *errnum = ASE_AWK_ENOERR; + return ASE_NULL; + } + + ASE_ASSERT (n == 1); + + if (match_len == 0) + { + ptr++; + left--; + } + else if (run->awk->option & ASE_AWK_STRIPSPACES) + { + /* match at the beginning of the input string */ + if (match_ptr == s) + { + for (i = 0; i < match_len; i++) + { + if (!ASE_AWK_ISSPACE(run->awk, match_ptr[i])) + goto exit_loop; + } + + /* the match that are all spaces at the + * beginning of the input string is skipped */ + ptr += match_len; + left -= match_len; + str_ptr = s + match_len; + str_len -= match_len; + } + else break; + } + else break; + } + +exit_loop: + if (len == 0) + { + *tok = (ase_char_t*)str_ptr; + *tok_len = str_len; + *errnum = ASE_AWK_ENOERR; + return ASE_NULL; + } + + *tok = (ase_char_t*)str_ptr; + *tok_len = match_ptr - str_ptr; + + for (i = 0; i < match_len; i++) + { + if (!ASE_AWK_ISSPACE(run->awk, match_ptr[i])) + { + *errnum = ASE_AWK_ENOERR; + return match_ptr+match_len; + } + } + + *errnum = ASE_AWK_ENOERR; + + if (run->awk->option & ASE_AWK_STRIPSPACES) + { + return (match_ptr+match_len >= s+len)? + ASE_NULL: (match_ptr+match_len); + } + else + { + return (match_ptr+match_len > s+len)? + ASE_NULL: (match_ptr+match_len); + } +} + diff --git a/ase/awk/misc.h b/ase/awk/misc.h new file mode 100644 index 00000000..f397c3c6 --- /dev/null +++ b/ase/awk/misc.h @@ -0,0 +1,45 @@ +/* + * $Id: misc.h,v 1.3 2007/04/30 05:47:33 bacon Exp $ + * + * {License} + */ + +#ifndef _ASE_AWK_MISC_H_ +#define _ASE_AWK_MISC_H_ + +#ifndef _ASE_AWK_AWK_H_ +#error Never include this file directly. Include instead +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +ase_char_t* ase_awk_strtok ( + ase_awk_run_t* run, const ase_char_t* s, + const ase_char_t* delim, ase_char_t** tok, ase_size_t* tok_len); + +ase_char_t* ase_awk_strxtok ( + ase_awk_run_t* run, const ase_char_t* s, ase_size_t len, + const ase_char_t* delim, ase_char_t** tok, ase_size_t* tok_len); + +ase_char_t* ase_awk_strntok ( + ase_awk_run_t* run, const ase_char_t* s, + const ase_char_t* delim, ase_size_t delim_len, + ase_char_t** tok, ase_size_t* tok_len); + +ase_char_t* ase_awk_strxntok ( + ase_awk_run_t* run, const ase_char_t* s, ase_size_t len, + const ase_char_t* delim, ase_size_t delim_len, + ase_char_t** tok, ase_size_t* tok_len); + +ase_char_t* ase_awk_strxntokbyrex ( + ase_awk_run_t* run, const ase_char_t* s, ase_size_t len, + void* rex, ase_char_t** tok, ase_size_t* tok_len, int* errnum); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/ase/awk/parse.c b/ase/awk/parse.c new file mode 100644 index 00000000..63e3d867 --- /dev/null +++ b/ase/awk/parse.c @@ -0,0 +1,5113 @@ +/* + * $Id: parse.c,v 1.3 2007/04/30 05:47:33 bacon Exp $ + * + * {License} + */ + +#include + +enum +{ + TOKEN_EOF, + TOKEN_NEWLINE, + + /* TOKEN_XXX_ASSIGNs should in sync + * with assop in assign_to_opcode */ + TOKEN_ASSIGN, + TOKEN_PLUS_ASSIGN, + TOKEN_MINUS_ASSIGN, + TOKEN_MUL_ASSIGN, + TOKEN_DIV_ASSIGN, + TOKEN_IDIV_ASSIGN, + TOKEN_MOD_ASSIGN, + TOKEN_EXP_ASSIGN, + + TOKEN_EQ, + TOKEN_NE, + TOKEN_LE, + TOKEN_LT, + TOKEN_GE, + TOKEN_GT, + TOKEN_NM, /* not match */ + TOKEN_NOT, + TOKEN_PLUS, + TOKEN_PLUSPLUS, + TOKEN_MINUS, + TOKEN_MINUSMINUS, + TOKEN_MUL, + TOKEN_DIV, + TOKEN_IDIV, + TOKEN_MOD, + TOKEN_LOR, + TOKEN_LAND, + TOKEN_BOR, + TOKEN_BXOR, + TOKEN_BAND, + TOKEN_BORAND, + TOKEN_TILDE, /* used for unary bitwise-not and regex match */ + TOKEN_RSHIFT, + TOKEN_LSHIFT, + TOKEN_IN, + TOKEN_EXP, + + TOKEN_LPAREN, + TOKEN_RPAREN, + TOKEN_LBRACE, + TOKEN_RBRACE, + TOKEN_LBRACK, + TOKEN_RBRACK, + + TOKEN_DOLLAR, + TOKEN_COMMA, + TOKEN_PERIOD, + TOKEN_SEMICOLON, + TOKEN_COLON, + TOKEN_QUEST, + + TOKEN_BEGIN, + TOKEN_END, + TOKEN_FUNCTION, + + TOKEN_LOCAL, + TOKEN_GLOBAL, + + TOKEN_IF, + TOKEN_ELSE, + TOKEN_WHILE, + TOKEN_FOR, + TOKEN_DO, + TOKEN_BREAK, + TOKEN_CONTINUE, + TOKEN_RETURN, + TOKEN_EXIT, + TOKEN_NEXT, + TOKEN_NEXTFILE, + TOKEN_NEXTINFILE, + TOKEN_NEXTOFILE, + TOKEN_DELETE, + TOKEN_PRINT, + TOKEN_PRINTF, + + TOKEN_GETLINE, + TOKEN_IDENT, + TOKEN_INT, + TOKEN_REAL, + TOKEN_STR, + TOKEN_REX, + + __TOKEN_COUNT__ +}; + +enum +{ + PARSE_GLOBAL, + PARSE_FUNCTION, + PARSE_BEGIN, + PARSE_END, + PARSE_BEGIN_BLOCK, + PARSE_END_BLOCK, + PARSE_PATTERN, + PARSE_ACTION_BLOCK +}; + +enum +{ + PARSE_LOOP_NONE, + PARSE_LOOP_WHILE, + PARSE_LOOP_FOR, + PARSE_LOOP_DOWHILE +}; + +typedef struct binmap_t binmap_t; + +struct binmap_t +{ + int token; + int binop; +}; + +static int parse (ase_awk_t* awk); + +static ase_awk_t* parse_progunit (ase_awk_t* awk); +static ase_awk_t* collect_globals (ase_awk_t* awk); +static ase_awk_t* add_builtin_globals (ase_awk_t* awk); +static ase_awk_t* add_global ( + ase_awk_t* awk, const ase_char_t* name, ase_size_t len, + ase_size_t line, int force); +static ase_awk_t* collect_locals (ase_awk_t* awk, ase_size_t nlocals); + +static ase_awk_nde_t* parse_function (ase_awk_t* awk); +static ase_awk_nde_t* parse_begin (ase_awk_t* awk); +static ase_awk_nde_t* parse_end (ase_awk_t* awk); +static ase_awk_chain_t* parse_pattern_block ( + ase_awk_t* awk, ase_awk_nde_t* ptn, ase_bool_t blockless); + +static ase_awk_nde_t* parse_block (ase_awk_t* awk, ase_size_t line, ase_bool_t is_top); +static ase_awk_nde_t* parse_block_dc (ase_awk_t* awk, ase_size_t line, ase_bool_t is_top); +static ase_awk_nde_t* parse_statement (ase_awk_t* awk, ase_size_t line); +static ase_awk_nde_t* parse_statement_nb (ase_awk_t* awk, ase_size_t line); + +static ase_awk_nde_t* parse_expression (ase_awk_t* awk, ase_size_t line); +static ase_awk_nde_t* parse_expression0 (ase_awk_t* awk, ase_size_t line); +static ase_awk_nde_t* parse_basic_expr (ase_awk_t* awk, ase_size_t line); + +static ase_awk_nde_t* parse_binary_expr ( + ase_awk_t* awk, ase_size_t line, const binmap_t* binmap, + ase_awk_nde_t*(*next_level_func)(ase_awk_t*,ase_size_t)); + +static ase_awk_nde_t* parse_logical_or (ase_awk_t* awk, ase_size_t line); +static ase_awk_nde_t* parse_logical_and (ase_awk_t* awk, ase_size_t line); +static ase_awk_nde_t* parse_in (ase_awk_t* awk, ase_size_t line); +static ase_awk_nde_t* parse_regex_match (ase_awk_t* awk, ase_size_t line); +static ase_awk_nde_t* parse_bitwise_or (ase_awk_t* awk, ase_size_t line); +static ase_awk_nde_t* parse_bitwise_or_with_extio (ase_awk_t* awk, ase_size_t line); +static ase_awk_nde_t* parse_bitwise_xor (ase_awk_t* awk, ase_size_t line); +static ase_awk_nde_t* parse_bitwise_and (ase_awk_t* awk, ase_size_t line); +static ase_awk_nde_t* parse_equality (ase_awk_t* awk, ase_size_t line); +static ase_awk_nde_t* parse_relational (ase_awk_t* awk, ase_size_t line); +static ase_awk_nde_t* parse_shift (ase_awk_t* awk, ase_size_t line); +static ase_awk_nde_t* parse_concat (ase_awk_t* awk, ase_size_t line); +static ase_awk_nde_t* parse_additive (ase_awk_t* awk, ase_size_t line); +static ase_awk_nde_t* parse_multiplicative (ase_awk_t* awk, ase_size_t line); + +static ase_awk_nde_t* parse_unary (ase_awk_t* awk, ase_size_t line); +static ase_awk_nde_t* parse_exponent (ase_awk_t* awk, ase_size_t line); +static ase_awk_nde_t* parse_unary_exp (ase_awk_t* awk, ase_size_t line); +static ase_awk_nde_t* parse_increment (ase_awk_t* awk, ase_size_t line); +static ase_awk_nde_t* parse_primary (ase_awk_t* awk, ase_size_t line); +static ase_awk_nde_t* parse_primary_ident (ase_awk_t* awk, ase_size_t line); + +static ase_awk_nde_t* parse_hashidx ( + ase_awk_t* awk, ase_char_t* name, ase_size_t name_len, + ase_size_t line); +static ase_awk_nde_t* parse_fncall ( + ase_awk_t* awk, ase_char_t* name, ase_size_t name_len, + ase_awk_bfn_t* bfn, ase_size_t line); +static ase_awk_nde_t* parse_if (ase_awk_t* awk, ase_size_t line); +static ase_awk_nde_t* parse_while (ase_awk_t* awk, ase_size_t line); +static ase_awk_nde_t* parse_for (ase_awk_t* awk, ase_size_t line); +static ase_awk_nde_t* parse_dowhile (ase_awk_t* awk, ase_size_t line); +static ase_awk_nde_t* parse_break (ase_awk_t* awk, ase_size_t line); +static ase_awk_nde_t* parse_continue (ase_awk_t* awk, ase_size_t line); +static ase_awk_nde_t* parse_return (ase_awk_t* awk, ase_size_t line); +static ase_awk_nde_t* parse_exit (ase_awk_t* awk, ase_size_t line); +static ase_awk_nde_t* parse_next (ase_awk_t* awk, ase_size_t line); +static ase_awk_nde_t* parse_nextfile (ase_awk_t* awk, ase_size_t line, int out); +static ase_awk_nde_t* parse_delete (ase_awk_t* awk, ase_size_t line); +static ase_awk_nde_t* parse_print (ase_awk_t* awk, ase_size_t line, int type); + +static int get_token (ase_awk_t* awk); +static int get_number (ase_awk_t* awk); +static int get_charstr (ase_awk_t* awk); +static int get_rexstr (ase_awk_t* awk); +static int get_string ( + ase_awk_t* awk, ase_char_t end_char, + ase_char_t esc_char, ase_bool_t keep_esc_char); +static int get_char (ase_awk_t* awk); +static int unget_char (ase_awk_t* awk, ase_cint_t c); +static int skip_spaces (ase_awk_t* awk); +static int skip_comment (ase_awk_t* awk); +static int classify_ident ( + ase_awk_t* awk, const ase_char_t* name, ase_size_t len); +static int assign_to_opcode (ase_awk_t* awk); +static int is_plain_var (ase_awk_nde_t* nde); +static int is_var (ase_awk_nde_t* nde); + +static int deparse (ase_awk_t* awk); +static int deparse_func (ase_awk_pair_t* pair, void* arg); +static int put_char (ase_awk_t* awk, ase_char_t c); +static int flush_out (ase_awk_t* awk); + +typedef struct kwent_t kwent_t; + +struct kwent_t +{ + const ase_char_t* name; + ase_size_t name_len; + int type; + int valid; /* the entry is valid when this option is set */ +}; + +static kwent_t kwtab[] = +{ + /* operators */ + { ASE_T("in"), 2, TOKEN_IN, 0 }, + + /* top-level block starters */ + { ASE_T("BEGIN"), 5, TOKEN_BEGIN, 0 }, + { ASE_T("END"), 3, TOKEN_END, 0 }, + { ASE_T("function"), 8, TOKEN_FUNCTION, 0 }, + { ASE_T("func"), 4, TOKEN_FUNCTION, 0 }, + + /* keywords for variable declaration */ + { ASE_T("local"), 5, TOKEN_LOCAL, ASE_AWK_EXPLICIT }, + { ASE_T("global"), 6, TOKEN_GLOBAL, ASE_AWK_EXPLICIT }, + + /* keywords that start statements excluding expression statements */ + { ASE_T("if"), 2, TOKEN_IF, 0 }, + { ASE_T("else"), 4, TOKEN_ELSE, 0 }, + { ASE_T("while"), 5, TOKEN_WHILE, 0 }, + { ASE_T("for"), 3, TOKEN_FOR, 0 }, + { ASE_T("do"), 2, TOKEN_DO, 0 }, + { ASE_T("break"), 5, TOKEN_BREAK, 0 }, + { ASE_T("continue"), 8, TOKEN_CONTINUE, 0 }, + { ASE_T("return"), 6, TOKEN_RETURN, 0 }, + { ASE_T("exit"), 4, TOKEN_EXIT, 0 }, + { ASE_T("next"), 4, TOKEN_NEXT, 0 }, + { ASE_T("nextfile"), 8, TOKEN_NEXTFILE, 0 }, + { ASE_T("nextofile"), 9, TOKEN_NEXTOFILE, ASE_AWK_NEXTOFILE }, + { ASE_T("delete"), 6, TOKEN_DELETE, 0 }, + { ASE_T("print"), 5, TOKEN_PRINT, ASE_AWK_EXTIO }, + { ASE_T("printf"), 6, TOKEN_PRINTF, ASE_AWK_EXTIO }, + + /* keywords that can start an expression */ + { ASE_T("getline"), 7, TOKEN_GETLINE, ASE_AWK_EXTIO }, + + { ASE_NULL, 0, 0, 0 } +}; + +typedef struct global_t global_t; + +struct global_t +{ + const ase_char_t* name; + ase_size_t name_len; + int valid; +}; + +static global_t gtab[] = +{ + { ASE_T("ARGC"), 4, 0 }, + { ASE_T("ARGV"), 4, 0 }, + { ASE_T("CONVFMT"), 7, 0 }, + { ASE_T("ENVIRON"), 7, 0 }, + { ASE_T("FILENAME"), 8, 0 }, + { ASE_T("FNR"), 3, 0 }, + { ASE_T("FS"), 2, 0 }, + { ASE_T("IGNORECASE"), 10, 0 }, + { ASE_T("NF"), 2, 0 }, + { ASE_T("NR"), 2, 0 }, + { ASE_T("OFILENAME"), 9, ASE_AWK_NEXTOFILE }, + { ASE_T("OFMT"), 4, 0 }, + { ASE_T("OFS"), 3, 0 }, + { ASE_T("ORS"), 3, 0 }, + { ASE_T("RLENGTH"), 7, 0 }, + { ASE_T("RS"), 2, 0 }, + { ASE_T("RSTART"), 6, 0 }, + { ASE_T("SUBSEP"), 6, 0 }, + { ASE_NULL, 0, 0 } +}; + +#define GET_CHAR(awk) \ + do { if (get_char (awk) == -1) return -1; } while(0) + +#define GET_CHAR_TO(awk,c) \ + do { \ + if (get_char (awk) == -1) return -1; \ + c = (awk)->src.lex.curc; \ + } while(0) + +#define SET_TOKEN_TYPE(awk,code) do { (awk)->token.type = (code); } while (0) + +#define ADD_TOKEN_CHAR(awk,c) \ + do { \ + if (ase_str_ccat(&(awk)->token.name,(c)) == (ase_size_t)-1) \ + { \ + ase_awk_seterror (awk, ASE_AWK_ENOMEM, (awk)->token.line, ASE_NULL, 0); \ + return -1; \ + } \ + } while (0) + +#define MATCH(awk,token_type) ((awk)->token.type == (token_type)) + +#define CLRERR(awk) ase_awk_seterrnum(awk,ASE_AWK_ENOERR) +#define ISNOERR(awk) ((awk)->errnum == ASE_AWK_ENOERR) +#define SETERR(awk,code) ase_awk_seterrnum(awk,code) +#define SETERRLIN(awk,code,line) ase_awk_seterror(awk,code,line,ASE_NULL,0) +#define SETERRTOK(awk,code) \ + do { \ + ase_cstr_t errarg; \ + errarg.len = ASE_STR_LEN(&(awk)->token.name); \ + errarg.ptr = ASE_STR_BUF(&(awk)->token.name); \ + if (MATCH(awk,TOKEN_EOF)) \ + ase_awk_seterror (awk, code, (awk)->token.prev.line, &errarg, 1); \ + else \ + ase_awk_seterror (awk, code, (awk)->token.line, &errarg, 1); \ + } while (0) + +#define SETERRARG(awk,code,line,arg,leng) \ + do { \ + ase_cstr_t errarg; \ + errarg.len = (leng); \ + errarg.ptr = (arg); \ + ase_awk_seterror ((awk), (code), (line), &errarg, 1); \ + } while (0) + +ase_size_t ase_awk_getmaxdepth (ase_awk_t* awk, int type) +{ + return (type == ASE_AWK_DEPTH_BLOCK_PARSE)? awk->parse.depth.max.block: + (type == ASE_AWK_DEPTH_BLOCK_RUN)? awk->run.depth.max.block: + (type == ASE_AWK_DEPTH_EXPR_PARSE)? awk->parse.depth.max.expr: + (type == ASE_AWK_DEPTH_EXPR_RUN)? awk->run.depth.max.expr: + (type == ASE_AWK_DEPTH_REX_BUILD)? awk->rex.depth.max.build: + (type == ASE_AWK_DEPTH_REX_MATCH)? awk->rex.depth.max.match: 0; +} + +void ase_awk_setmaxdepth (ase_awk_t* awk, int types, ase_size_t depth) +{ + if (types & ASE_AWK_DEPTH_BLOCK_PARSE) + { + awk->parse.depth.max.block = depth; + if (depth <= 0) + awk->parse.parse_block = parse_block; + else + awk->parse.parse_block = parse_block_dc; + } + + if (types & ASE_AWK_DEPTH_EXPR_PARSE) + { + awk->parse.depth.max.expr = depth; + } + + if (types & ASE_AWK_DEPTH_BLOCK_RUN) + { + awk->run.depth.max.block = depth; + } + + if (types & ASE_AWK_DEPTH_EXPR_RUN) + { + awk->run.depth.max.expr = depth; + } + + if (types & ASE_AWK_DEPTH_REX_BUILD) + { + awk->rex.depth.max.build = depth; + } + + if (types & ASE_AWK_DEPTH_REX_MATCH) + { + awk->rex.depth.max.match = depth; + } +} + +const ase_char_t* ase_awk_getglobalname ( + ase_awk_t* awk, ase_size_t idx, ase_size_t* len) +{ + *len = gtab[idx].name_len; + return gtab[idx].name; +} + +int ase_awk_parse (ase_awk_t* awk, ase_awk_srcios_t* srcios) +{ + int n; + + ASE_ASSERTX ( + srcios != ASE_NULL && srcios->in != ASE_NULL, + "the source code input stream must be provided at least"); + ASE_ASSERT (awk->parse.depth.cur.loop == 0); + ASE_ASSERT (awk->parse.depth.cur.expr == 0); + + ase_awk_clear (awk); + ase_memcpy (&awk->src.ios, srcios, ASE_SIZEOF(awk->src.ios)); + + n = parse (awk); + + ASE_ASSERT (awk->parse.depth.cur.loop == 0); + ASE_ASSERT (awk->parse.depth.cur.expr == 0); + + return n; +} + +static int parse (ase_awk_t* awk) +{ + int n = 0, op; + + ASE_ASSERT (awk->src.ios.in != ASE_NULL); + + CLRERR (awk); + op = awk->src.ios.in ( + ASE_AWK_IO_OPEN, awk->src.ios.custom_data, ASE_NULL, 0); + if (op <= -1) + { + /* cannot open the source file. + * it doesn't even have to call CLOSE */ + if (ISNOERR(awk)) SETERR (awk, ASE_AWK_ESINOP); + return -1; + } + + if (add_builtin_globals (awk) == ASE_NULL) + { + n = -1; + goto exit_parse; + } + + /* the user io handler for the source code input returns 0 when + * it doesn't have any files to open. this is the same condition + * as the source code file is empty. so it will perform the parsing + * when op is positive, which means there are something to parse */ + if (op > 0) + { + /* get the first character */ + if (get_char(awk) == -1) + { + n = -1; + goto exit_parse; + } + + /* get the first token */ + if (get_token(awk) == -1) + { + n = -1; + goto exit_parse; + } + + while (1) + { + if (MATCH(awk,TOKEN_EOF)) break; + if (MATCH(awk,TOKEN_NEWLINE)) continue; + + if (parse_progunit (awk) == ASE_NULL) + { + n = -1; + goto exit_parse; + } + } + } + + awk->tree.nglobals = ase_awk_tab_getsize(&awk->parse.globals); + + if (awk->src.ios.out != ASE_NULL) + { + if (deparse (awk) == -1) + { + n = -1; + goto exit_parse; + } + } + +exit_parse: + if (n == 0) CLRERR (awk); + if (awk->src.ios.in ( + ASE_AWK_IO_CLOSE, awk->src.ios.custom_data, ASE_NULL, 0) != 0) + { + if (n == 0) + { + /* this is to keep the earlier error above + * that might be more critical than this */ + if (ISNOERR(awk)) SETERR (awk, ASE_AWK_ESINCL); + n = -1; + } + } + + if (n == -1) ase_awk_clear (awk); + else awk->tree.ok = 1; + + return n; +} + +static ase_awk_t* parse_progunit (ase_awk_t* awk) +{ + /* + pattern { action } + function name (parameter-list) { statement } + */ + + ASE_ASSERT (awk->parse.depth.cur.loop == 0); + + if ((awk->option & ASE_AWK_EXPLICIT) && MATCH(awk,TOKEN_GLOBAL)) + { + ase_size_t nglobals; + + awk->parse.id.block = PARSE_GLOBAL; + + if (get_token(awk) == -1) return ASE_NULL; + + nglobals = ase_awk_tab_getsize(&awk->parse.globals); + if (collect_globals (awk) == ASE_NULL) + { + ase_awk_tab_remove ( + &awk->parse.globals, nglobals, + ase_awk_tab_getsize(&awk->parse.globals) - nglobals); + return ASE_NULL; + } + } + else if (MATCH(awk,TOKEN_FUNCTION)) + { + awk->parse.id.block = PARSE_FUNCTION; + if (parse_function (awk) == ASE_NULL) return ASE_NULL; + } + else if (MATCH(awk,TOKEN_BEGIN)) + { + awk->parse.id.block = PARSE_BEGIN; + if (get_token(awk) == -1) return ASE_NULL; + + if ((awk->option & ASE_AWK_BLOCKLESS) && + (MATCH(awk,TOKEN_NEWLINE) || MATCH(awk,TOKEN_EOF))) + { + /* when the blockless pattern is supported + * BEGIN and { should be located on the same line */ + SETERRLIN (awk, ASE_AWK_EBLKBEG, awk->token.prev.line); + return ASE_NULL; + } + + if (!MATCH(awk,TOKEN_LBRACE)) + { + SETERRTOK (awk, ASE_AWK_ELBRACE); + return ASE_NULL; + } + + awk->parse.id.block = PARSE_BEGIN_BLOCK; + if (parse_begin (awk) == ASE_NULL) return ASE_NULL; + } + else if (MATCH(awk,TOKEN_END)) + { + awk->parse.id.block = PARSE_END; + if (get_token(awk) == -1) return ASE_NULL; + + if ((awk->option & ASE_AWK_BLOCKLESS) && + (MATCH(awk,TOKEN_NEWLINE) || MATCH(awk,TOKEN_EOF))) + { + /* when the blockless pattern is supported + * END and { should be located on the same line */ + SETERRLIN (awk, ASE_AWK_EBLKEND, awk->token.prev.line); + return ASE_NULL; + } + + if (!MATCH(awk,TOKEN_LBRACE)) + { + SETERRTOK (awk, ASE_AWK_ELBRACE); + return ASE_NULL; + } + + awk->parse.id.block = PARSE_END_BLOCK; + if (parse_end (awk) == ASE_NULL) return ASE_NULL; + } + else if (MATCH(awk,TOKEN_LBRACE)) + { + /* patternless block */ + awk->parse.id.block = PARSE_ACTION_BLOCK; + if (parse_pattern_block ( + awk, ASE_NULL, ase_false) == ASE_NULL) return ASE_NULL; + } + else + { + /* + expressions + /regular expression/ + pattern && pattern + pattern || pattern + !pattern + (pattern) + pattern, pattern + */ + ase_awk_nde_t* ptn; + + awk->parse.id.block = PARSE_PATTERN; + + ptn = parse_expression (awk, awk->token.line); + if (ptn == ASE_NULL) return ASE_NULL; + + ASE_ASSERT (ptn->next == ASE_NULL); + + if (MATCH(awk,TOKEN_COMMA)) + { + if (get_token (awk) == -1) + { + ase_awk_clrpt (awk, ptn); + return ASE_NULL; + } + + ptn->next = parse_expression (awk, awk->token.line); + if (ptn->next == ASE_NULL) + { + ase_awk_clrpt (awk, ptn); + return ASE_NULL; + } + } + + if ((awk->option & ASE_AWK_BLOCKLESS) && + (MATCH(awk,TOKEN_NEWLINE) || MATCH(awk,TOKEN_EOF))) + { + /* blockless pattern */ + ase_bool_t newline = MATCH(awk,TOKEN_NEWLINE); + + awk->parse.id.block = PARSE_ACTION_BLOCK; + if (parse_pattern_block ( + awk, ptn, ase_true) == ASE_NULL) + { + ase_awk_clrpt (awk, ptn); + return ASE_NULL; + } + + if (newline) + { + if (get_token (awk) == -1) + { + /* ptn has been added to the chain. + * it doesn't have to be cleared here + * as ase_awk_clear does it */ + /*ase_awk_clrpt (awk, ptn);*/ + return ASE_NULL; + } + } + } + else + { + /* parse the action block */ + if (!MATCH(awk,TOKEN_LBRACE)) + { + ase_awk_clrpt (awk, ptn); + SETERRTOK (awk, ASE_AWK_ELBRACE); + return ASE_NULL; + } + + awk->parse.id.block = PARSE_ACTION_BLOCK; + if (parse_pattern_block ( + awk, ptn, ase_false) == ASE_NULL) + { + ase_awk_clrpt (awk, ptn); + return ASE_NULL; + } + } + } + + return awk; +} + +static ase_awk_nde_t* parse_function (ase_awk_t* awk) +{ + ase_char_t* name; + ase_char_t* name_dup; + ase_size_t name_len; + ase_awk_nde_t* body; + ase_awk_afn_t* afn; + ase_size_t nargs; + ase_awk_pair_t* pair; + int n; + + /* eat up the keyword 'function' and get the next token */ + ASE_ASSERT (MATCH(awk,TOKEN_FUNCTION)); + if (get_token(awk) == -1) return ASE_NULL; + + /* match a function name */ + if (!MATCH(awk,TOKEN_IDENT)) + { + /* cannot find a valid identifier for a function name */ + SETERRTOK (awk, ASE_AWK_EFNNAME); + return ASE_NULL; + } + + name = ASE_STR_BUF(&awk->token.name); + name_len = ASE_STR_LEN(&awk->token.name); + + /* check if it is a builtin function */ + if (ase_awk_getbfn (awk, name, name_len) != ASE_NULL) + { + SETERRARG (awk, ASE_AWK_EBFNRED, awk->token.line, name, name_len); + return ASE_NULL; + } + + if (ase_awk_map_get(&awk->tree.afns, name, name_len) != ASE_NULL) + { + /* the function is defined previously */ + SETERRARG ( + awk, ASE_AWK_EAFNRED, awk->token.line, + name, name_len); + return ASE_NULL; + } + + if (awk->option & ASE_AWK_UNIQUEFN) + { + /* check if it coincides to be a global variable name */ + ase_size_t g; + + g = ase_awk_tab_find (&awk->parse.globals, 0, name, name_len); + if (g != (ase_size_t)-1) + { + SETERRARG ( + awk, ASE_AWK_EGBLRED, awk->token.line, + name, name_len); + + return ASE_NULL; + } + } + + /* clone the function name before it is overwritten */ + name_dup = ase_strxdup (name, name_len, &awk->prmfns.mmgr); + if (name_dup == ASE_NULL) + { + SETERRLIN (awk, ASE_AWK_ENOMEM, awk->token.line); + return ASE_NULL; + } + + /* get the next token */ + if (get_token(awk) == -1) + { + ASE_AWK_FREE (awk, name_dup); + return ASE_NULL; + } + + /* match a left parenthesis */ + if (!MATCH(awk,TOKEN_LPAREN)) + { + /* a function name is not followed by a left parenthesis */ + ASE_AWK_FREE (awk, name_dup); + + SETERRTOK (awk, ASE_AWK_ELPAREN); + return ASE_NULL; + } + + /* get the next token */ + if (get_token(awk) == -1) + { + ASE_AWK_FREE (awk, name_dup); + return ASE_NULL; + } + + /* make sure that parameter table is empty */ + ASE_ASSERT (ase_awk_tab_getsize(&awk->parse.params) == 0); + + /* read parameter list */ + if (MATCH(awk,TOKEN_RPAREN)) + { + /* no function parameter found. get the next token */ + if (get_token(awk) == -1) + { + ASE_AWK_FREE (awk, name_dup); + return ASE_NULL; + } + } + else + { + while (1) + { + ase_char_t* param; + ase_size_t param_len; + + if (!MATCH(awk,TOKEN_IDENT)) + { + ASE_AWK_FREE (awk, name_dup); + ase_awk_tab_clear (&awk->parse.params); + SETERRTOK (awk, ASE_AWK_EBADPAR); + return ASE_NULL; + } + + param = ASE_STR_BUF(&awk->token.name); + param_len = ASE_STR_LEN(&awk->token.name); + + if (awk->option & ASE_AWK_UNIQUEFN) + { + /* check if a parameter conflicts with a function */ + if (ase_strxncmp (name_dup, name_len, param, param_len) == 0 || + ase_awk_map_get (&awk->tree.afns, param, param_len) != ASE_NULL) + { + ASE_AWK_FREE (awk, name_dup); + ase_awk_tab_clear (&awk->parse.params); + + SETERRARG ( + awk, ASE_AWK_EAFNRED, awk->token.line, + param, param_len); + + return ASE_NULL; + } + + /* NOTE: the following is not a conflict + * global x; + * function f (x) { print x; } + * x in print x is a parameter + */ + } + + /* check if a parameter conflicts with other parameters */ + if (ase_awk_tab_find ( + &awk->parse.params, + 0, param, param_len) != (ase_size_t)-1) + { + ASE_AWK_FREE (awk, name_dup); + ase_awk_tab_clear (&awk->parse.params); + + SETERRARG ( + awk, ASE_AWK_EDUPPAR, awk->token.line, + param, param_len); + + return ASE_NULL; + } + + /* push the parameter to the parameter list */ + if (ase_awk_tab_getsize ( + &awk->parse.params) >= ASE_AWK_MAX_PARAMS) + { + ASE_AWK_FREE (awk, name_dup); + ase_awk_tab_clear (&awk->parse.params); + + SETERRTOK (awk, ASE_AWK_EPARTM); + return ASE_NULL; + } + + if (ase_awk_tab_add ( + &awk->parse.params, + param, param_len) == (ase_size_t)-1) + { + ASE_AWK_FREE (awk, name_dup); + ase_awk_tab_clear (&awk->parse.params); + + SETERRLIN (awk, ASE_AWK_ENOMEM, awk->token.line); + return ASE_NULL; + } + + if (get_token (awk) == -1) + { + ASE_AWK_FREE (awk, name_dup); + ase_awk_tab_clear (&awk->parse.params); + return ASE_NULL; + } + + if (MATCH(awk,TOKEN_RPAREN)) break; + + if (!MATCH(awk,TOKEN_COMMA)) + { + ASE_AWK_FREE (awk, name_dup); + ase_awk_tab_clear (&awk->parse.params); + + SETERRTOK (awk, ASE_AWK_ECOMMA); + return ASE_NULL; + } + + if (get_token(awk) == -1) + { + ASE_AWK_FREE (awk, name_dup); + ase_awk_tab_clear (&awk->parse.params); + return ASE_NULL; + } + } + + if (get_token(awk) == -1) + { + ASE_AWK_FREE (awk, name_dup); + ase_awk_tab_clear (&awk->parse.params); + return ASE_NULL; + } + } + + /* check if the function body starts with a left brace */ + if (!MATCH(awk,TOKEN_LBRACE)) + { + ASE_AWK_FREE (awk, name_dup); + ase_awk_tab_clear (&awk->parse.params); + + SETERRTOK (awk, ASE_AWK_ELBRACE); + return ASE_NULL; + } + if (get_token(awk) == -1) + { + ASE_AWK_FREE (awk, name_dup); + ase_awk_tab_clear (&awk->parse.params); + return ASE_NULL; + } + + /* remember the current function name so that the body parser + * can know the name of the current function being parsed */ + awk->tree.cur_afn.ptr = name_dup; + awk->tree.cur_afn.len = name_len; + + /* actual function body */ + body = awk->parse.parse_block (awk, awk->token.prev.line, ase_true); + + /* clear the current function name remembered */ + awk->tree.cur_afn.ptr = ASE_NULL; + awk->tree.cur_afn.len = 0; + + if (body == ASE_NULL) + { + ASE_AWK_FREE (awk, name_dup); + ase_awk_tab_clear (&awk->parse.params); + return ASE_NULL; + } + + /* TODO: study furthur if the parameter names should be saved + * for some reasons - might be need for deparsing output */ + nargs = ase_awk_tab_getsize (&awk->parse.params); + /* parameter names are not required anymore. clear them */ + ase_awk_tab_clear (&awk->parse.params); + + afn = (ase_awk_afn_t*) + ASE_AWK_MALLOC (awk, ASE_SIZEOF(ase_awk_afn_t)); + if (afn == ASE_NULL) + { + ASE_AWK_FREE (awk, name_dup); + ase_awk_clrpt (awk, body); + + SETERRLIN (awk, ASE_AWK_ENOMEM, awk->token.line); + return ASE_NULL; + } + + afn->name = ASE_NULL; /* function name set below */ + afn->name_len = 0; + afn->nargs = nargs; + afn->body = body; + + n = ase_awk_map_putx (&awk->tree.afns, name_dup, name_len, afn, &pair); + if (n < 0) + { + ASE_AWK_FREE (awk, name_dup); + ase_awk_clrpt (awk, body); + ASE_AWK_FREE (awk, afn); + + SETERRLIN (awk, ASE_AWK_ENOMEM, awk->token.line); + return ASE_NULL; + } + + /* duplicate functions should have been detected previously */ + ASE_ASSERT (n != 0); + + afn->name = PAIR_KEYPTR(pair); /* do some trick to save a string. */ + afn->name_len = PAIR_KEYLEN(pair); + ASE_AWK_FREE (awk, name_dup); + + return body; +} + +static ase_awk_nde_t* parse_begin (ase_awk_t* awk) +{ + ase_awk_nde_t* nde; + + ASE_ASSERT (MATCH(awk,TOKEN_LBRACE)); + + if (get_token(awk) == -1) return ASE_NULL; + nde = awk->parse.parse_block (awk, awk->token.prev.line, ase_true); + if (nde == ASE_NULL) return ASE_NULL; + + awk->tree.begin = nde; + return nde; +} + +static ase_awk_nde_t* parse_end (ase_awk_t* awk) +{ + ase_awk_nde_t* nde; + + ASE_ASSERT (MATCH(awk,TOKEN_LBRACE)); + + if (get_token(awk) == -1) return ASE_NULL; + nde = awk->parse.parse_block (awk, awk->token.prev.line, ase_true); + if (nde == ASE_NULL) return ASE_NULL; + + awk->tree.end = nde; + return nde; +} + +static ase_awk_chain_t* parse_pattern_block ( + ase_awk_t* awk, ase_awk_nde_t* ptn, ase_bool_t blockless) +{ + ase_awk_nde_t* nde; + ase_awk_chain_t* chain; + ase_size_t line = awk->token.line; + + if (blockless) nde = ASE_NULL; + else + { + ASE_ASSERT (MATCH(awk,TOKEN_LBRACE)); + if (get_token(awk) == -1) return ASE_NULL; + nde = awk->parse.parse_block (awk, line, ase_true); + if (nde == ASE_NULL) return ASE_NULL; + } + + chain = (ase_awk_chain_t*) + ASE_AWK_MALLOC (awk, ASE_SIZEOF(ase_awk_chain_t)); + if (chain == ASE_NULL) + { + ase_awk_clrpt (awk, nde); + + SETERRLIN (awk, ASE_AWK_ENOMEM, line); + return ASE_NULL; + } + + chain->pattern = ptn; + chain->action = nde; + chain->next = ASE_NULL; + + if (awk->tree.chain == ASE_NULL) + { + awk->tree.chain = chain; + awk->tree.chain_tail = chain; + awk->tree.chain_size++; + } + else + { + awk->tree.chain_tail->next = chain; + awk->tree.chain_tail = chain; + awk->tree.chain_size++; + } + + return chain; +} + +static ase_awk_nde_t* parse_block ( + ase_awk_t* awk, ase_size_t line, ase_bool_t is_top) +{ + ase_awk_nde_t* head, * curr, * nde; + ase_awk_nde_blk_t* block; + ase_size_t nlocals, nlocals_max, tmp; + + nlocals = ase_awk_tab_getsize(&awk->parse.locals); + nlocals_max = awk->parse.nlocals_max; + + /* local variable declarations */ + if (awk->option & ASE_AWK_EXPLICIT) + { + while (1) + { + if (!MATCH(awk,TOKEN_LOCAL)) break; + + if (get_token(awk) == -1) + { + ase_awk_tab_remove ( + &awk->parse.locals, nlocals, + ase_awk_tab_getsize(&awk->parse.locals) - nlocals); + return ASE_NULL; + } + + if (collect_locals (awk, nlocals) == ASE_NULL) + { + ase_awk_tab_remove ( + &awk->parse.locals, nlocals, + ase_awk_tab_getsize(&awk->parse.locals) - nlocals); + return ASE_NULL; + } + } + } + + /* block body */ + head = ASE_NULL; curr = ASE_NULL; + + while (1) + { + if (MATCH(awk,TOKEN_EOF)) + { + ase_awk_tab_remove ( + &awk->parse.locals, nlocals, + ase_awk_tab_getsize(&awk->parse.locals) - nlocals); + if (head != ASE_NULL) ase_awk_clrpt (awk, head); + + SETERRLIN (awk, ASE_AWK_EENDSRC, awk->token.prev.line); + return ASE_NULL; + } + + if (MATCH(awk,TOKEN_RBRACE)) + { + if (get_token(awk) == -1) + { + ase_awk_tab_remove ( + &awk->parse.locals, nlocals, + ase_awk_tab_getsize(&awk->parse.locals) - nlocals); + if (head != ASE_NULL) ase_awk_clrpt (awk, head); + return ASE_NULL; + } + break; + } + + nde = parse_statement (awk, awk->token.line); + if (nde == ASE_NULL) + { + ase_awk_tab_remove ( + &awk->parse.locals, nlocals, + ase_awk_tab_getsize(&awk->parse.locals)-nlocals); + if (head != ASE_NULL) ase_awk_clrpt (awk, head); + return ASE_NULL; + } + + /* remove unnecessary statements */ + if (nde->type == ASE_AWK_NDE_NULL || + (nde->type == ASE_AWK_NDE_BLK && + ((ase_awk_nde_blk_t*)nde)->body == ASE_NULL)) continue; + + if (curr == ASE_NULL) head = nde; + else curr->next = nde; + curr = nde; + } + + block = (ase_awk_nde_blk_t*) + ASE_AWK_MALLOC (awk, ASE_SIZEOF(ase_awk_nde_blk_t)); + if (block == ASE_NULL) + { + ase_awk_tab_remove ( + &awk->parse.locals, nlocals, + ase_awk_tab_getsize(&awk->parse.locals)-nlocals); + ase_awk_clrpt (awk, head); + + SETERRLIN (awk, ASE_AWK_ENOMEM, line); + return ASE_NULL; + } + + tmp = ase_awk_tab_getsize(&awk->parse.locals); + if (tmp > awk->parse.nlocals_max) awk->parse.nlocals_max = tmp; + + ase_awk_tab_remove ( + &awk->parse.locals, nlocals, tmp - nlocals); + + /* adjust the number of locals for a block without any statements */ + /* if (head == ASE_NULL) tmp = 0; */ + + block->type = ASE_AWK_NDE_BLK; + block->line = line; + block->next = ASE_NULL; + block->body = head; + +/* TODO: not only local variables but also nested blocks, +unless it is part of other constructs such as if, can be promoted +and merged to top-level block */ + + /* migrate all block-local variables to a top-level block */ + if (is_top) + { + block->nlocals = awk->parse.nlocals_max - nlocals; + awk->parse.nlocals_max = nlocals_max; + } + else + { + /*block->nlocals = tmp - nlocals;*/ + block->nlocals = 0; + } + + return (ase_awk_nde_t*)block; +} + +static ase_awk_nde_t* parse_block_dc ( + ase_awk_t* awk, ase_size_t line, ase_bool_t is_top) +{ + ase_awk_nde_t* nde; + + ASE_ASSERT (awk->parse.depth.max.block > 0); + + if (awk->parse.depth.cur.block >= awk->parse.depth.max.block) + { + SETERRLIN (awk, ASE_AWK_EBLKNST, awk->token.prev.line); + return ASE_NULL; + } + + awk->parse.depth.cur.block++; + nde = parse_block (awk, line, is_top); + awk->parse.depth.cur.block--; + + return nde; +} + +static ase_awk_t* add_builtin_globals (ase_awk_t* awk) +{ + global_t* p = gtab; + ase_awk_t* tmp; + + awk->tree.nbglobals = 0; + while (p->name != ASE_NULL) + { + + if (p->valid != 0 && (awk->option & p->valid) == 0) + { + /* an invalid global variable are still added + * to the global variable table with an empty name. + * this is to prevent the run-time from looking up + * the variable */ + tmp = add_global (awk, ASE_T(""), 0, 0, 1); + } + else + { + tmp = add_global (awk, p->name, p->name_len, 0, 0); + } + if (tmp == ASE_NULL) return ASE_NULL; + + awk->tree.nbglobals++; + p++; + } + + return awk; +} + +static ase_awk_t* add_global ( + ase_awk_t* awk, const ase_char_t* name, ase_size_t len, + ase_size_t line, int force) +{ + if (!force) + { + if (awk->option & ASE_AWK_UNIQUEFN) + { + /* check if it conflict with a builtin function name */ + if (ase_awk_getbfn (awk, name, len) != ASE_NULL) + { + SETERRARG ( + awk, ASE_AWK_EBFNRED, awk->token.line, + name, len); + + return ASE_NULL; + } + + /* check if it conflict with a function name */ + if (ase_awk_map_get ( + &awk->tree.afns, name, len) != ASE_NULL) + { + SETERRARG ( + awk, ASE_AWK_EAFNRED, line, + name, len); + + return ASE_NULL; + } + } + + /* check if it conflicts with other global variable names */ + if (ase_awk_tab_find ( + &awk->parse.globals, 0, name, len) != (ase_size_t)-1) + { + SETERRARG (awk, ASE_AWK_EDUPGBL, line, name, len); + return ASE_NULL; + } + } + + if (ase_awk_tab_getsize(&awk->parse.globals) >= ASE_AWK_MAX_GLOBALS) + { + SETERRLIN (awk, ASE_AWK_EGBLTM, line); + return ASE_NULL; + } + + if (ase_awk_tab_add (&awk->parse.globals, name, len) == (ase_size_t)-1) + { + SETERRLIN (awk, ASE_AWK_ENOMEM, line); + return ASE_NULL; + } + + return awk; +} + +static ase_awk_t* collect_globals (ase_awk_t* awk) +{ + while (1) + { + if (!MATCH(awk,TOKEN_IDENT)) + { + SETERRTOK (awk, ASE_AWK_EBADVAR); + return ASE_NULL; + } + + if (add_global ( + awk, + ASE_STR_BUF(&awk->token.name), + ASE_STR_LEN(&awk->token.name), + awk->token.line, + 0) == ASE_NULL) return ASE_NULL; + + if (get_token(awk) == -1) return ASE_NULL; + + if (MATCH(awk,TOKEN_SEMICOLON)) break; + + if (!MATCH(awk,TOKEN_COMMA)) + { + SETERRTOK (awk, ASE_AWK_ECOMMA); + return ASE_NULL; + } + + if (get_token(awk) == -1) return ASE_NULL; + } + + /* skip a semicolon */ + if (get_token(awk) == -1) return ASE_NULL; + + return awk; +} + +static ase_awk_t* collect_locals (ase_awk_t* awk, ase_size_t nlocals) +{ + ase_char_t* local; + ase_size_t local_len; + + while (1) + { + if (!MATCH(awk,TOKEN_IDENT)) + { + SETERRTOK (awk, ASE_AWK_EBADVAR); + return ASE_NULL; + } + + local = ASE_STR_BUF(&awk->token.name); + local_len = ASE_STR_LEN(&awk->token.name); + + /* NOTE: it is not checked againt globals names */ + + if (awk->option & ASE_AWK_UNIQUEFN) + { + /* check if it conflict with a builtin function name */ + if (ase_awk_getbfn (awk, local, local_len) != ASE_NULL) + { + SETERRARG ( + awk, ASE_AWK_EBFNRED, awk->token.line, + local, local_len); + return ASE_NULL; + } + + /* check if it conflict with a function name */ + if (ase_strxncmp ( + awk->tree.cur_afn.ptr, awk->tree.cur_afn.len, + local, local_len) == 0 || + ase_awk_map_get ( + &awk->tree.afns, local, local_len) != ASE_NULL) + { + SETERRARG ( + awk, ASE_AWK_EAFNRED, awk->token.line, + local, local_len); + return ASE_NULL; + } + } + + /* check if it conflicts with a paremeter name */ + if (ase_awk_tab_find (&awk->parse.params, + 0, local, local_len) != (ase_size_t)-1) + { + SETERRARG ( + awk, ASE_AWK_EPARRED, awk->token.line, + local, local_len); + return ASE_NULL; + } + + /* check if it conflicts with other local variable names */ + if (ase_awk_tab_find (&awk->parse.locals, + ((awk->option & ASE_AWK_SHADING)? nlocals: 0), + local, local_len) != (ase_size_t)-1) + { + SETERRARG ( + awk, ASE_AWK_EDUPLCL, awk->token.line, + local, local_len); + + return ASE_NULL; + } + + if (ase_awk_tab_getsize(&awk->parse.locals) >= ASE_AWK_MAX_LOCALS) + { + SETERRLIN (awk, ASE_AWK_ELCLTM, awk->token.line); + return ASE_NULL; + } + + if (ase_awk_tab_add ( + &awk->parse.locals, local, local_len) == (ase_size_t)-1) + { + SETERRLIN (awk, ASE_AWK_ENOMEM, awk->token.line); + return ASE_NULL; + } + + if (get_token(awk) == -1) return ASE_NULL; + + if (MATCH(awk,TOKEN_SEMICOLON)) break; + + if (!MATCH(awk,TOKEN_COMMA)) + { + SETERRTOK (awk, ASE_AWK_ECOMMA); + return ASE_NULL; + } + + if (get_token(awk) == -1) return ASE_NULL; + } + + /* skip a semicolon */ + if (get_token(awk) == -1) return ASE_NULL; + + return awk; +} + +static ase_awk_nde_t* parse_statement (ase_awk_t* awk, ase_size_t line) +{ + ase_awk_nde_t* nde; + + if (MATCH(awk,TOKEN_SEMICOLON)) + { + /* null statement */ + nde = (ase_awk_nde_t*) + ASE_AWK_MALLOC (awk, ASE_SIZEOF(ase_awk_nde_t)); + if (nde == ASE_NULL) + { + SETERRLIN (awk, ASE_AWK_ENOMEM, line); + return ASE_NULL; + } + + nde->type = ASE_AWK_NDE_NULL; + nde->line = line; + nde->next = ASE_NULL; + + if (get_token(awk) == -1) + { + ASE_AWK_FREE (awk, nde); + return ASE_NULL; + } + } + else if (MATCH(awk,TOKEN_LBRACE)) + { + if (get_token(awk) == -1) return ASE_NULL; + nde = awk->parse.parse_block ( + awk, awk->token.prev.line, ase_false); + } + else + { + /* the statement id held in awk->parse.id.stmnt denotes + * the token id of the statement currently being parsed. + * the current statement id is saved here because the + * statement id can be changed in parse_statement_nb. + * it will, in turn, call parse_statement which will + * eventually change the statement id. */ + int old_id = awk->parse.id.stmnt; + + /* set the current statement id */ + awk->parse.id.stmnt = awk->token.type; + + /* proceed parsing the statement */ + nde = parse_statement_nb (awk, line); + + /* restore the statement id saved previously */ + awk->parse.id.stmnt = old_id; + } + + return nde; +} + +static ase_awk_nde_t* parse_statement_nb (ase_awk_t* awk, ase_size_t line) +{ + ase_awk_nde_t* nde; + + /* keywords that don't require any terminating semicolon */ + if (MATCH(awk,TOKEN_IF)) + { + if (get_token(awk) == -1) return ASE_NULL; + return parse_if (awk, line); + } + else if (MATCH(awk,TOKEN_WHILE)) + { + if (get_token(awk) == -1) return ASE_NULL; + + awk->parse.depth.cur.loop++; + nde = parse_while (awk, line); + awk->parse.depth.cur.loop--; + + return nde; + } + else if (MATCH(awk,TOKEN_FOR)) + { + if (get_token(awk) == -1) return ASE_NULL; + + awk->parse.depth.cur.loop++; + nde = parse_for (awk, line); + awk->parse.depth.cur.loop--; + + return nde; + } + + /* keywords that require a terminating semicolon */ + if (MATCH(awk,TOKEN_DO)) + { + if (get_token(awk) == -1) return ASE_NULL; + + awk->parse.depth.cur.loop++; + nde = parse_dowhile (awk, line); + awk->parse.depth.cur.loop--; + + return nde; + } + else if (MATCH(awk,TOKEN_BREAK)) + { + if (get_token(awk) == -1) return ASE_NULL; + nde = parse_break (awk, line); + } + else if (MATCH(awk,TOKEN_CONTINUE)) + { + if (get_token(awk) == -1) return ASE_NULL; + nde = parse_continue (awk, line); + } + else if (MATCH(awk,TOKEN_RETURN)) + { + if (get_token(awk) == -1) return ASE_NULL; + nde = parse_return (awk, line); + } + else if (MATCH(awk,TOKEN_EXIT)) + { + if (get_token(awk) == -1) return ASE_NULL; + nde = parse_exit (awk, line); + } + else if (MATCH(awk,TOKEN_NEXT)) + { + if (get_token(awk) == -1) return ASE_NULL; + nde = parse_next (awk, line); + } + else if (MATCH(awk,TOKEN_NEXTFILE)) + { + if (get_token(awk) == -1) return ASE_NULL; + nde = parse_nextfile (awk, line, 0); + } + else if (MATCH(awk,TOKEN_NEXTOFILE)) + { + if (get_token(awk) == -1) return ASE_NULL; + nde = parse_nextfile (awk, line, 1); + } + else if (MATCH(awk,TOKEN_DELETE)) + { + if (get_token(awk) == -1) return ASE_NULL; + nde = parse_delete (awk, line); + } + else if (MATCH(awk,TOKEN_PRINT)) + { + if (get_token(awk) == -1) return ASE_NULL; + nde = parse_print (awk, line, ASE_AWK_NDE_PRINT); + } + else if (MATCH(awk,TOKEN_PRINTF)) + { + if (get_token(awk) == -1) return ASE_NULL; + nde = parse_print (awk, line, ASE_AWK_NDE_PRINTF); + } + else + { + nde = parse_expression (awk, line); + } + + if (nde == ASE_NULL) return ASE_NULL; + + /* check if a statement ends with a semicolon */ + if (!MATCH(awk,TOKEN_SEMICOLON)) + { + if (nde != ASE_NULL) ase_awk_clrpt (awk, nde); + + SETERRLIN (awk, ASE_AWK_ESTMEND, awk->token.prev.line); + return ASE_NULL; + } + + /* eat up the semicolon and read in the next token */ + if (get_token(awk) == -1) + { + if (nde != ASE_NULL) ase_awk_clrpt (awk, nde); + return ASE_NULL; + } + + return nde; +} + +static ase_awk_nde_t* parse_expression (ase_awk_t* awk, ase_size_t line) +{ + ase_awk_nde_t* nde; + + if (awk->parse.depth.max.expr > 0 && + awk->parse.depth.cur.expr >= awk->parse.depth.max.expr) + { + SETERRLIN (awk, ASE_AWK_EEXPRNST, line); + return ASE_NULL; + } + + awk->parse.depth.cur.expr++; + nde = parse_expression0 (awk, line); + awk->parse.depth.cur.expr--; + + return nde; +} + +static ase_awk_nde_t* parse_expression0 (ase_awk_t* awk, ase_size_t line) +{ + ase_awk_nde_t* x, * y; + ase_awk_nde_ass_t* nde; + int opcode; + + x = parse_basic_expr (awk, line); + if (x == ASE_NULL) return ASE_NULL; + + opcode = assign_to_opcode (awk); + if (opcode == -1) + { + /* no assignment operator found. */ + return x; + } + + ASE_ASSERT (x->next == ASE_NULL); + if (!is_var(x) && x->type != ASE_AWK_NDE_POS) + { + ase_awk_clrpt (awk, x); + SETERRLIN (awk, ASE_AWK_EASSIGN, line); + return ASE_NULL; + } + + if (get_token(awk) == -1) + { + ase_awk_clrpt (awk, x); + return ASE_NULL; + } + + /*y = parse_basic_expr (awk);*/ + y = parse_expression (awk, awk->token.line); + if (y == ASE_NULL) + { + ase_awk_clrpt (awk, x); + return ASE_NULL; + } + + nde = (ase_awk_nde_ass_t*) + ASE_AWK_MALLOC (awk, ASE_SIZEOF(ase_awk_nde_ass_t)); + if (nde == ASE_NULL) + { + ase_awk_clrpt (awk, x); + ase_awk_clrpt (awk, y); + + SETERRLIN (awk, ASE_AWK_ENOMEM, line); + return ASE_NULL; + } + + nde->type = ASE_AWK_NDE_ASS; + nde->line = line; + nde->next = ASE_NULL; + nde->opcode = opcode; + nde->left = x; + nde->right = y; + + return (ase_awk_nde_t*)nde; +} + +static ase_awk_nde_t* parse_basic_expr (ase_awk_t* awk, ase_size_t line) +{ + ase_awk_nde_t* nde, * n1, * n2; + + nde = parse_logical_or (awk, line); + if (nde == ASE_NULL) return ASE_NULL; + + if (MATCH(awk,TOKEN_QUEST)) + { + ase_awk_nde_cnd_t* tmp; + + if (get_token(awk) == -1) return ASE_NULL; + + /*n1 = parse_basic_expr (awk, awk->token.line);*/ + n1 = parse_expression (awk, awk->token.line); + if (n1 == ASE_NULL) + { + ase_awk_clrpt (awk, nde); + return ASE_NULL; + } + + if (!MATCH(awk,TOKEN_COLON)) + { + SETERRTOK (awk, ASE_AWK_ECOLON); + return ASE_NULL; + } + if (get_token(awk) == -1) return ASE_NULL; + + /*n2 = parse_basic_expr (awk, awk->token.line);*/ + n2 = parse_expression (awk, awk->token.line); + if (n2 == ASE_NULL) + { + ase_awk_clrpt (awk, nde); + ase_awk_clrpt (awk, n1); + return ASE_NULL; + } + + tmp = (ase_awk_nde_cnd_t*) ASE_AWK_MALLOC ( + awk, ASE_SIZEOF(ase_awk_nde_cnd_t)); + if (tmp == ASE_NULL) + { + ase_awk_clrpt (awk, nde); + ase_awk_clrpt (awk, n1); + ase_awk_clrpt (awk, n2); + + SETERRLIN (awk, ASE_AWK_ENOMEM, line); + return ASE_NULL; + } + + tmp->type = ASE_AWK_NDE_CND; + tmp->line = line; + tmp->next = ASE_NULL; + tmp->test = nde; + tmp->left = n1; + tmp->right = n2; + + nde = (ase_awk_nde_t*)tmp; + } + + return nde; +} + +static ase_awk_nde_t* parse_binary_expr ( + ase_awk_t* awk, ase_size_t line, const binmap_t* binmap, + ase_awk_nde_t*(*next_level_func)(ase_awk_t*,ase_size_t)) +{ + ase_awk_nde_exp_t* nde; + ase_awk_nde_t* left, * right; + int opcode; + + left = next_level_func (awk, line); + if (left == ASE_NULL) return ASE_NULL; + + while (1) + { + const binmap_t* p = binmap; + ase_bool_t matched = ase_false; + + while (p->token != TOKEN_EOF) + { + if (MATCH(awk,p->token)) + { + opcode = p->binop; + matched = ase_true; + break; + } + p++; + } + if (!matched) break; + + if (get_token(awk) == -1) + { + ase_awk_clrpt (awk, left); + return ASE_NULL; + } + + right = next_level_func (awk, awk->token.line); + if (right == ASE_NULL) + { + ase_awk_clrpt (awk, left); + return ASE_NULL; + } + + nde = (ase_awk_nde_exp_t*) ASE_AWK_MALLOC ( + awk, ASE_SIZEOF(ase_awk_nde_exp_t)); + if (nde == ASE_NULL) + { + ase_awk_clrpt (awk, right); + ase_awk_clrpt (awk, left); + + SETERRLIN (awk, ASE_AWK_ENOMEM, line); + return ASE_NULL; + } + + nde->type = ASE_AWK_NDE_EXP_BIN; + nde->line = line; + nde->next = ASE_NULL; + nde->opcode = opcode; + nde->left = left; + nde->right = right; + + left = (ase_awk_nde_t*)nde; + } + + return left; +} + +static ase_awk_nde_t* parse_logical_or (ase_awk_t* awk, ase_size_t line) +{ + static binmap_t map[] = + { + { TOKEN_LOR, ASE_AWK_BINOP_LOR }, + { TOKEN_EOF, 0 } + }; + + return parse_binary_expr (awk, line, map, parse_logical_and); +} + +static ase_awk_nde_t* parse_logical_and (ase_awk_t* awk, ase_size_t line) +{ + static binmap_t map[] = + { + { TOKEN_LAND, ASE_AWK_BINOP_LAND }, + { TOKEN_EOF, 0 } + }; + + return parse_binary_expr (awk, line, map, parse_in); +} + +static ase_awk_nde_t* parse_in (ase_awk_t* awk, ase_size_t line) +{ + /* + static binmap_t map[] = + { + { TOKEN_IN, ASE_AWK_BINOP_IN }, + { TOKEN_EOF, 0 } + }; + + return parse_binary_expr (awk, line, map, parse_regex_match); + */ + + ase_awk_nde_exp_t* nde; + ase_awk_nde_t* left, * right; + ase_size_t line2; + + left = parse_regex_match (awk, line); + if (left == ASE_NULL) return ASE_NULL; + + while (1) + { + if (!MATCH(awk,TOKEN_IN)) break; + + if (get_token(awk) == -1) + { + ase_awk_clrpt (awk, left); + return ASE_NULL; + } + + line2 = awk->token.line; + + right = parse_regex_match (awk, line2); + if (right == ASE_NULL) + { + ase_awk_clrpt (awk, left); + return ASE_NULL; + } + + if (!is_plain_var(right)) + { + ase_awk_clrpt (awk, right); + ase_awk_clrpt (awk, left); + + SETERRLIN (awk, ASE_AWK_ENOTVAR, line2); + return ASE_NULL; + } + + nde = (ase_awk_nde_exp_t*) ASE_AWK_MALLOC ( + awk, ASE_SIZEOF(ase_awk_nde_exp_t)); + if (nde == ASE_NULL) + { + ase_awk_clrpt (awk, right); + ase_awk_clrpt (awk, left); + + SETERRLIN (awk, ASE_AWK_ENOMEM, line); + return ASE_NULL; + } + + nde->type = ASE_AWK_NDE_EXP_BIN; + nde->line = line; + nde->next = ASE_NULL; + nde->opcode = ASE_AWK_BINOP_IN; + nde->left = left; + nde->right = right; + + left = (ase_awk_nde_t*)nde; + } + + return left; +} + +static ase_awk_nde_t* parse_regex_match (ase_awk_t* awk, ase_size_t line) +{ + static binmap_t map[] = + { + { TOKEN_TILDE, ASE_AWK_BINOP_MA }, + { TOKEN_NM, ASE_AWK_BINOP_NM }, + { TOKEN_EOF, 0 }, + }; + + return parse_binary_expr (awk, line, map, parse_bitwise_or); +} + +static ase_awk_nde_t* parse_bitwise_or (ase_awk_t* awk, ase_size_t line) +{ + if (awk->option & ASE_AWK_EXTIO) + { + return parse_bitwise_or_with_extio (awk, line); + } + else + { + static binmap_t map[] = + { + { TOKEN_BOR, ASE_AWK_BINOP_BOR }, + { TOKEN_EOF, 0 } + }; + + return parse_binary_expr ( + awk, line, map, parse_bitwise_xor); + } +} + +static ase_awk_nde_t* parse_bitwise_or_with_extio (ase_awk_t* awk, ase_size_t line) +{ + ase_awk_nde_t* left, * right; + + left = parse_bitwise_xor (awk, line); + if (left == ASE_NULL) return ASE_NULL; + + while (1) + { + int in_type; + + if (MATCH(awk,TOKEN_BOR)) + in_type = ASE_AWK_IN_PIPE; + else if (MATCH(awk,TOKEN_BORAND)) + in_type = ASE_AWK_IN_COPROC; + else break; + + if (get_token(awk) == -1) + { + ase_awk_clrpt (awk, left); + return ASE_NULL; + } + + if (MATCH(awk,TOKEN_GETLINE)) + { + ase_awk_nde_getline_t* nde; + ase_awk_nde_t* var = ASE_NULL; + + /* piped getline */ + if (get_token(awk) == -1) + { + ase_awk_clrpt (awk, left); + return ASE_NULL; + } + + /* TODO: is this correct? */ + + if (MATCH(awk,TOKEN_IDENT)) + { + /* command | getline var */ + + var = parse_primary (awk, awk->token.line); + if (var == ASE_NULL) + { + ase_awk_clrpt (awk, left); + return ASE_NULL; + } + } + + nde = (ase_awk_nde_getline_t*) ASE_AWK_MALLOC ( + awk, ASE_SIZEOF(ase_awk_nde_getline_t)); + if (nde == ASE_NULL) + { + ase_awk_clrpt (awk, left); + + SETERRLIN (awk, ASE_AWK_ENOMEM, line); + return ASE_NULL; + } + + nde->type = ASE_AWK_NDE_GETLINE; + nde->line = line; + nde->next = ASE_NULL; + nde->var = var; + nde->in_type = in_type; + nde->in = left; + + left = (ase_awk_nde_t*)nde; + } + else + { + ase_awk_nde_exp_t* nde; + + if (in_type == ASE_AWK_IN_COPROC) + { + ase_awk_clrpt (awk, left); + + /* TODO: support coprocess */ + SETERRLIN (awk, ASE_AWK_EGLNCPS, line); + return ASE_NULL; + } + + right = parse_bitwise_xor (awk, awk->token.line); + if (right == ASE_NULL) + { + ase_awk_clrpt (awk, left); + return ASE_NULL; + } + + nde = (ase_awk_nde_exp_t*) ASE_AWK_MALLOC ( + awk, ASE_SIZEOF(ase_awk_nde_exp_t)); + if (nde == ASE_NULL) + { + ase_awk_clrpt (awk, right); + ase_awk_clrpt (awk, left); + + SETERRLIN (awk, ASE_AWK_ENOMEM, line); + return ASE_NULL; + } + + nde->type = ASE_AWK_NDE_EXP_BIN; + nde->line = line; + nde->next = ASE_NULL; + nde->opcode = ASE_AWK_BINOP_BOR; + nde->left = left; + nde->right = right; + + left = (ase_awk_nde_t*)nde; + } + } + + return left; +} + +static ase_awk_nde_t* parse_bitwise_xor (ase_awk_t* awk, ase_size_t line) +{ + static binmap_t map[] = + { + { TOKEN_BXOR, ASE_AWK_BINOP_BXOR }, + { TOKEN_EOF, 0 } + }; + + return parse_binary_expr (awk, line, map, parse_bitwise_and); +} + +static ase_awk_nde_t* parse_bitwise_and (ase_awk_t* awk, ase_size_t line) +{ + static binmap_t map[] = + { + { TOKEN_BAND, ASE_AWK_BINOP_BAND }, + { TOKEN_EOF, 0 } + }; + + return parse_binary_expr (awk, line, map, parse_equality); +} + +static ase_awk_nde_t* parse_equality (ase_awk_t* awk, ase_size_t line) +{ + static binmap_t map[] = + { + { TOKEN_EQ, ASE_AWK_BINOP_EQ }, + { TOKEN_NE, ASE_AWK_BINOP_NE }, + { TOKEN_EOF, 0 } + }; + + return parse_binary_expr (awk, line, map, parse_relational); +} + +static ase_awk_nde_t* parse_relational (ase_awk_t* awk, ase_size_t line) +{ + static binmap_t map[] = + { + { TOKEN_GT, ASE_AWK_BINOP_GT }, + { TOKEN_GE, ASE_AWK_BINOP_GE }, + { TOKEN_LT, ASE_AWK_BINOP_LT }, + { TOKEN_LE, ASE_AWK_BINOP_LE }, + { TOKEN_EOF, 0 } + }; + + return parse_binary_expr (awk, line, map, parse_shift); +} + +static ase_awk_nde_t* parse_shift (ase_awk_t* awk, ase_size_t line) +{ + static binmap_t map[] = + { + { TOKEN_LSHIFT, ASE_AWK_BINOP_LSHIFT }, + { TOKEN_RSHIFT, ASE_AWK_BINOP_RSHIFT }, + { TOKEN_EOF, 0 } + }; + + return parse_binary_expr (awk, line, map, parse_concat); +} + +static ase_awk_nde_t* parse_concat (ase_awk_t* awk, ase_size_t line) +{ + ase_awk_nde_exp_t* nde; + ase_awk_nde_t* left, * right; + + left = parse_additive (awk, line); + if (left == ASE_NULL) return ASE_NULL; + + while (1) + { + if (MATCH(awk,TOKEN_PERIOD)) + { + if ((awk->option & ASE_AWK_EXPLICIT) == 0) break; + if (get_token(awk) == -1) return ASE_NULL; + } + else if (MATCH(awk,TOKEN_LPAREN) || + MATCH(awk,TOKEN_DOLLAR) || + awk->token.type >= TOKEN_GETLINE) + { + /* TODO: is the check above sufficient? */ + if ((awk->option & ASE_AWK_IMPLICIT) == 0) break; + } + else break; + + right = parse_additive (awk, awk->token.line); + if (right == ASE_NULL) + { + ase_awk_clrpt (awk, left); + return ASE_NULL; + } + + nde = (ase_awk_nde_exp_t*) ASE_AWK_MALLOC ( + awk, ASE_SIZEOF(ase_awk_nde_exp_t)); + if (nde == ASE_NULL) + { + ase_awk_clrpt (awk, left); + ase_awk_clrpt (awk, right); + + SETERRLIN (awk, ASE_AWK_ENOMEM, line); + return ASE_NULL; + } + + nde->type = ASE_AWK_NDE_EXP_BIN; + nde->line = line; + nde->next = ASE_NULL; + nde->opcode = ASE_AWK_BINOP_CONCAT; + nde->left = left; + nde->right = right; + + left = (ase_awk_nde_t*)nde; + } + + return left; +} + +static ase_awk_nde_t* parse_additive (ase_awk_t* awk, ase_size_t line) +{ + static binmap_t map[] = + { + { TOKEN_PLUS, ASE_AWK_BINOP_PLUS }, + { TOKEN_MINUS, ASE_AWK_BINOP_MINUS }, + { TOKEN_EOF, 0 } + }; + + return parse_binary_expr (awk, line, map, parse_multiplicative); +} + +static ase_awk_nde_t* parse_multiplicative (ase_awk_t* awk, ase_size_t line) +{ + static binmap_t map[] = + { + { TOKEN_MUL, ASE_AWK_BINOP_MUL }, + { TOKEN_DIV, ASE_AWK_BINOP_DIV }, + { TOKEN_IDIV, ASE_AWK_BINOP_IDIV }, + { TOKEN_MOD, ASE_AWK_BINOP_MOD }, + /* { TOKEN_EXP, ASE_AWK_BINOP_EXP }, */ + { TOKEN_EOF, 0 } + }; + + return parse_binary_expr (awk, line, map, parse_unary); +} + +static ase_awk_nde_t* parse_unary (ase_awk_t* awk, ase_size_t line) +{ + ase_awk_nde_exp_t* nde; + ase_awk_nde_t* left; + int opcode; + + opcode = (MATCH(awk,TOKEN_PLUS))? ASE_AWK_UNROP_PLUS: + (MATCH(awk,TOKEN_MINUS))? ASE_AWK_UNROP_MINUS: + (MATCH(awk,TOKEN_NOT))? ASE_AWK_UNROP_NOT: + (MATCH(awk,TOKEN_TILDE))? ASE_AWK_UNROP_BNOT: -1; + + /*if (opcode == -1) return parse_increment (awk);*/ + if (opcode == -1) return parse_exponent (awk, line); + + if (get_token(awk) == -1) return ASE_NULL; + + if (awk->parse.depth.max.expr > 0 && + awk->parse.depth.cur.expr >= awk->parse.depth.max.expr) + { + SETERRLIN (awk, ASE_AWK_EEXPRNST, awk->token.line); + return ASE_NULL; + } + awk->parse.depth.cur.expr++; + left = parse_unary (awk, awk->token.line); + awk->parse.depth.cur.expr--; + if (left == ASE_NULL) return ASE_NULL; + + nde = (ase_awk_nde_exp_t*) + ASE_AWK_MALLOC (awk, ASE_SIZEOF(ase_awk_nde_exp_t)); + if (nde == ASE_NULL) + { + ase_awk_clrpt (awk, left); + + SETERRLIN (awk, ASE_AWK_ENOMEM, line); + return ASE_NULL; + } + + nde->type = ASE_AWK_NDE_EXP_UNR; + nde->line = line; + nde->next = ASE_NULL; + nde->opcode = opcode; + nde->left = left; + nde->right = ASE_NULL; + + return (ase_awk_nde_t*)nde; +} + +static ase_awk_nde_t* parse_exponent (ase_awk_t* awk, ase_size_t line) +{ + static binmap_t map[] = + { + { TOKEN_EXP, ASE_AWK_BINOP_EXP }, + { TOKEN_EOF, 0 } + }; + + return parse_binary_expr (awk, line, map, parse_unary_exp); +} + +static ase_awk_nde_t* parse_unary_exp (ase_awk_t* awk, ase_size_t line) +{ + ase_awk_nde_exp_t* nde; + ase_awk_nde_t* left; + int opcode; + + opcode = (MATCH(awk,TOKEN_PLUS))? ASE_AWK_UNROP_PLUS: + (MATCH(awk,TOKEN_MINUS))? ASE_AWK_UNROP_MINUS: + (MATCH(awk,TOKEN_NOT))? ASE_AWK_UNROP_NOT: + (MATCH(awk,TOKEN_TILDE))? ASE_AWK_UNROP_BNOT: -1; + + if (opcode == -1) return parse_increment (awk, line); + + if (get_token(awk) == -1) return ASE_NULL; + + if (awk->parse.depth.max.expr > 0 && + awk->parse.depth.cur.expr >= awk->parse.depth.max.expr) + { + SETERRLIN (awk, ASE_AWK_EEXPRNST, awk->token.line); + return ASE_NULL; + } + awk->parse.depth.cur.expr++; + left = parse_unary (awk, awk->token.line); + awk->parse.depth.cur.expr--; + if (left == ASE_NULL) return ASE_NULL; + + nde = (ase_awk_nde_exp_t*) + ASE_AWK_MALLOC (awk, ASE_SIZEOF(ase_awk_nde_exp_t)); + if (nde == ASE_NULL) + { + ase_awk_clrpt (awk, left); + + SETERRLIN (awk, ASE_AWK_ENOMEM, line); + return ASE_NULL; + } + + nde->type = ASE_AWK_NDE_EXP_UNR; + nde->line = line; + nde->next = ASE_NULL; + nde->opcode = opcode; + nde->left = left; + nde->right = ASE_NULL; + + return (ase_awk_nde_t*)nde; +} + +static ase_awk_nde_t* parse_increment (ase_awk_t* awk, ase_size_t line) +{ + ase_awk_nde_exp_t* nde; + ase_awk_nde_t* left; + int type, opcode, opcode1, opcode2; + + /* check for prefix increment operator */ + opcode1 = MATCH(awk,TOKEN_PLUSPLUS)? ASE_AWK_INCOP_PLUS: + MATCH(awk,TOKEN_MINUSMINUS)? ASE_AWK_INCOP_MINUS: -1; + + if (opcode1 != -1) + { + if (get_token(awk) == -1) return ASE_NULL; + } + + left = parse_primary (awk, line); + if (left == ASE_NULL) return ASE_NULL; + + /* check for postfix increment operator */ + opcode2 = MATCH(awk,TOKEN_PLUSPLUS)? ASE_AWK_INCOP_PLUS: + MATCH(awk,TOKEN_MINUSMINUS)? ASE_AWK_INCOP_MINUS: -1; + + if (opcode1 != -1 && opcode2 != -1) + { + /* both prefix and postfix increment operator. + * not allowed */ + ase_awk_clrpt (awk, left); + + SETERRLIN (awk, ASE_AWK_EPREPST, line); + return ASE_NULL; + } + else if (opcode1 == -1 && opcode2 == -1) + { + /* no increment operators */ + return left; + } + else if (opcode1 != -1) + { + /* prefix increment operator */ + type = ASE_AWK_NDE_EXP_INCPRE; + opcode = opcode1; + } + else if (opcode2 != -1) + { + /* postfix increment operator */ + type = ASE_AWK_NDE_EXP_INCPST; + opcode = opcode2; + + if (get_token(awk) == -1) return ASE_NULL; + } + + nde = (ase_awk_nde_exp_t*) + ASE_AWK_MALLOC (awk, ASE_SIZEOF(ase_awk_nde_exp_t)); + if (nde == ASE_NULL) + { + ase_awk_clrpt (awk, left); + + SETERRLIN (awk, ASE_AWK_ENOMEM, line); + return ASE_NULL; + } + + nde->type = type; + nde->line = line; + nde->next = ASE_NULL; + nde->opcode = opcode; + nde->left = left; + nde->right = ASE_NULL; + + return (ase_awk_nde_t*)nde; +} + +static ase_awk_nde_t* parse_primary (ase_awk_t* awk, ase_size_t line) +{ + if (MATCH(awk,TOKEN_IDENT)) + { + return parse_primary_ident (awk, line); + } + else if (MATCH(awk,TOKEN_INT)) + { + ase_awk_nde_int_t* nde; + + nde = (ase_awk_nde_int_t*) ASE_AWK_MALLOC ( + awk, ASE_SIZEOF(ase_awk_nde_int_t)); + if (nde == ASE_NULL) + { + SETERRLIN (awk, ASE_AWK_ENOMEM, line); + return ASE_NULL; + } + + nde->type = ASE_AWK_NDE_INT; + nde->line = line; + nde->next = ASE_NULL; + nde->val = ase_awk_strxtolong (awk, + ASE_STR_BUF(&awk->token.name), + ASE_STR_LEN(&awk->token.name), 0, ASE_NULL); + nde->str = ase_strxdup ( + ASE_STR_BUF(&awk->token.name), + ASE_STR_LEN(&awk->token.name), + &awk->prmfns.mmgr); + if (nde->str == ASE_NULL) + { + ASE_AWK_FREE (awk, nde); + return ASE_NULL; + } + nde->len = ASE_STR_LEN(&awk->token.name); + + ASE_ASSERT ( + ASE_STR_LEN(&awk->token.name) == + ase_strlen(ASE_STR_BUF(&awk->token.name))); + + if (get_token(awk) == -1) + { + ASE_AWK_FREE (awk, nde->str); + ASE_AWK_FREE (awk, nde); + return ASE_NULL; + } + + return (ase_awk_nde_t*)nde; + } + else if (MATCH(awk,TOKEN_REAL)) + { + ase_awk_nde_real_t* nde; + + nde = (ase_awk_nde_real_t*) ASE_AWK_MALLOC ( + awk, ASE_SIZEOF(ase_awk_nde_real_t)); + if (nde == ASE_NULL) + { + SETERRLIN (awk, ASE_AWK_ENOMEM, line); + return ASE_NULL; + } + + nde->type = ASE_AWK_NDE_REAL; + nde->line = line; + nde->next = ASE_NULL; + nde->val = ase_awk_strxtoreal (awk, + ASE_STR_BUF(&awk->token.name), + ASE_STR_LEN(&awk->token.name), ASE_NULL); + nde->str = ase_strxdup ( + ASE_STR_BUF(&awk->token.name), + ASE_STR_LEN(&awk->token.name), + &awk->prmfns.mmgr); + if (nde->str == ASE_NULL) + { + ASE_AWK_FREE (awk, nde); + return ASE_NULL; + } + nde->len = ASE_STR_LEN(&awk->token.name); + + ASE_ASSERT ( + ASE_STR_LEN(&awk->token.name) == + ase_strlen(ASE_STR_BUF(&awk->token.name))); + + if (get_token(awk) == -1) + { + ASE_AWK_FREE (awk, nde->str); + ASE_AWK_FREE (awk, nde); + return ASE_NULL; + } + + return (ase_awk_nde_t*)nde; + } + else if (MATCH(awk,TOKEN_STR)) + { + ase_awk_nde_str_t* nde; + + nde = (ase_awk_nde_str_t*) ASE_AWK_MALLOC ( + awk, ASE_SIZEOF(ase_awk_nde_str_t)); + if (nde == ASE_NULL) + { + SETERRLIN (awk, ASE_AWK_ENOMEM, line); + return ASE_NULL; + } + + nde->type = ASE_AWK_NDE_STR; + nde->line = line; + nde->next = ASE_NULL; + nde->len = ASE_STR_LEN(&awk->token.name); + nde->buf = ase_strxdup ( + ASE_STR_BUF(&awk->token.name), + nde->len, + &awk->prmfns.mmgr); + if (nde->buf == ASE_NULL) + { + ASE_AWK_FREE (awk, nde); + SETERRLIN (awk, ASE_AWK_ENOMEM, line); + return ASE_NULL; + } + + if (get_token(awk) == -1) + { + ASE_AWK_FREE (awk, nde->buf); + ASE_AWK_FREE (awk, nde); + return ASE_NULL; + } + + return (ase_awk_nde_t*)nde; + } + else if (MATCH(awk,TOKEN_DIV)) + { + ase_awk_nde_rex_t* nde; + int errnum; + + /* the regular expression is tokenized here because + * of the context-sensitivity of the slash symbol */ + SET_TOKEN_TYPE (awk, TOKEN_REX); + + ase_str_clear (&awk->token.name); + if (get_rexstr (awk) == -1) return ASE_NULL; + ASE_ASSERT (MATCH(awk,TOKEN_REX)); + + nde = (ase_awk_nde_rex_t*) ASE_AWK_MALLOC ( + awk, ASE_SIZEOF(ase_awk_nde_rex_t)); + if (nde == ASE_NULL) + { + SETERRLIN (awk, ASE_AWK_ENOMEM, line); + return ASE_NULL; + } + + nde->type = ASE_AWK_NDE_REX; + nde->line = line; + nde->next = ASE_NULL; + + nde->len = ASE_STR_LEN(&awk->token.name); + nde->buf = ase_strxdup ( + ASE_STR_BUF(&awk->token.name), + ASE_STR_LEN(&awk->token.name), + &awk->prmfns.mmgr); + if (nde->buf == ASE_NULL) + { + ASE_AWK_FREE (awk, nde); + SETERRLIN (awk, ASE_AWK_ENOMEM, line); + return ASE_NULL; + } + + nde->code = ase_awk_buildrex (awk, + ASE_STR_BUF(&awk->token.name), + ASE_STR_LEN(&awk->token.name), + &errnum); + if (nde->code == ASE_NULL) + { + ASE_AWK_FREE (awk, nde->buf); + ASE_AWK_FREE (awk, nde); + + SETERRLIN (awk, errnum, line); + return ASE_NULL; + } + + if (get_token(awk) == -1) + { + ASE_AWK_FREE (awk, nde->buf); + ASE_AWK_FREE (awk, nde->code); + ASE_AWK_FREE (awk, nde); + return ASE_NULL; + } + + return (ase_awk_nde_t*)nde; + } + else if (MATCH(awk,TOKEN_DOLLAR)) + { + ase_awk_nde_pos_t* nde; + ase_awk_nde_t* prim; + + if (get_token(awk)) return ASE_NULL; + + prim = parse_primary (awk, awk->token.line); + if (prim == ASE_NULL) return ASE_NULL; + + nde = (ase_awk_nde_pos_t*) ASE_AWK_MALLOC ( + awk, ASE_SIZEOF(ase_awk_nde_pos_t)); + if (nde == ASE_NULL) + { + ase_awk_clrpt (awk, prim); + SETERRLIN (awk, ASE_AWK_ENOMEM, line); + return ASE_NULL; + } + + nde->type = ASE_AWK_NDE_POS; + nde->line = line; + nde->next = ASE_NULL; + nde->val = prim; + + return (ase_awk_nde_t*)nde; + } + else if (MATCH(awk,TOKEN_LPAREN)) + { + ase_awk_nde_t* nde; + ase_awk_nde_t* last; + + /* eat up the left parenthesis */ + if (get_token(awk) == -1) return ASE_NULL; + + /* parse the sub-expression inside the parentheses */ + nde = parse_expression (awk, awk->token.line); + if (nde == ASE_NULL) return ASE_NULL; + + /* parse subsequent expressions separated by a comma, if any */ + last = nde; + ASE_ASSERT (last->next == ASE_NULL); + + while (MATCH(awk,TOKEN_COMMA)) + { + ase_awk_nde_t* tmp; + + if (get_token(awk) == -1) + { + ase_awk_clrpt (awk, nde); + return ASE_NULL; + } + + tmp = parse_expression (awk, awk->token.line); + if (tmp == ASE_NULL) + { + ase_awk_clrpt (awk, nde); + return ASE_NULL; + } + + ASE_ASSERT (tmp->next == ASE_NULL); + last->next = tmp; + last = tmp; + } + /* ----------------- */ + + /* check for the closing parenthesis */ + if (!MATCH(awk,TOKEN_RPAREN)) + { + ase_awk_clrpt (awk, nde); + + SETERRTOK (awk, ASE_AWK_ERPAREN); + return ASE_NULL; + } + + if (get_token(awk) == -1) + { + ase_awk_clrpt (awk, nde); + return ASE_NULL; + } + + /* check if it is a chained node */ + if (nde->next != ASE_NULL) + { + /* if so, it is a expression group */ + /* (expr1, expr2, expr2) */ + + ase_awk_nde_grp_t* tmp; + + if ((awk->parse.id.stmnt != TOKEN_PRINT && + awk->parse.id.stmnt != TOKEN_PRINTF) || + awk->parse.depth.cur.expr != 1) + { + if (!MATCH(awk,TOKEN_IN)) + { + ase_awk_clrpt (awk, nde); + + SETERRTOK (awk, ASE_AWK_EIN); + return ASE_NULL; + } + } + + tmp = (ase_awk_nde_grp_t*) ASE_AWK_MALLOC ( + awk, ASE_SIZEOF(ase_awk_nde_grp_t)); + if (tmp == ASE_NULL) + { + ase_awk_clrpt (awk, nde); + SETERRLIN (awk, ASE_AWK_ENOMEM, line); + return ASE_NULL; + } + + tmp->type = ASE_AWK_NDE_GRP; + tmp->line = line; + tmp->next = ASE_NULL; + tmp->body = nde; + + nde = (ase_awk_nde_t*)tmp; + } + /* ----------------- */ + + return nde; + } + else if (MATCH(awk,TOKEN_GETLINE)) + { + ase_awk_nde_getline_t* nde; + ase_awk_nde_t* var = ASE_NULL; + ase_awk_nde_t* in = ASE_NULL; + + if (get_token(awk) == -1) return ASE_NULL; + + if (MATCH(awk,TOKEN_IDENT)) + { + /* getline var */ + var = parse_primary (awk, awk->token.line); + if (var == ASE_NULL) return ASE_NULL; + } + + if (MATCH(awk, TOKEN_LT)) + { + /* getline [var] < file */ + if (get_token(awk) == -1) + { + if (var != ASE_NULL) ase_awk_clrpt (awk, var); + return ASE_NULL; + } + + /* TODO: is this correct? */ + /*in = parse_expression (awk);*/ + in = parse_primary (awk, awk->token.line); + if (in == ASE_NULL) + { + if (var != ASE_NULL) ase_awk_clrpt (awk, var); + return ASE_NULL; + } + } + + nde = (ase_awk_nde_getline_t*) ASE_AWK_MALLOC ( + awk, ASE_SIZEOF(ase_awk_nde_getline_t)); + if (nde == ASE_NULL) + { + if (var != ASE_NULL) ase_awk_clrpt (awk, var); + if (in != ASE_NULL) ase_awk_clrpt (awk, in); + SETERRLIN (awk, ASE_AWK_ENOMEM, line); + return ASE_NULL; + } + + nde->type = ASE_AWK_NDE_GETLINE; + nde->line = line; + nde->next = ASE_NULL; + nde->var = var; + nde->in_type = (in == ASE_NULL)? + ASE_AWK_IN_CONSOLE: ASE_AWK_IN_FILE; + nde->in = in; + + return (ase_awk_nde_t*)nde; + } + + /* valid expression introducer is expected */ + SETERRLIN (awk, ASE_AWK_EEXPRES, + (MATCH(awk,TOKEN_EOF)? awk->token.prev.line: line)); + return ASE_NULL; +} + +static ase_awk_nde_t* parse_primary_ident (ase_awk_t* awk, ase_size_t line) +{ + ase_char_t* name_dup; + ase_size_t name_len; + ase_awk_bfn_t* bfn; + + ASE_ASSERT (MATCH(awk,TOKEN_IDENT)); + + name_dup = ase_strxdup ( + ASE_STR_BUF(&awk->token.name), + ASE_STR_LEN(&awk->token.name), + &awk->prmfns.mmgr); + if (name_dup == ASE_NULL) + { + SETERRLIN (awk, ASE_AWK_ENOMEM, line); + return ASE_NULL; + } + name_len = ASE_STR_LEN(&awk->token.name); + + if (get_token(awk) == -1) + { + ASE_AWK_FREE (awk, name_dup); + return ASE_NULL; + } + + /* check if name_dup is a built-in function name */ + bfn = ase_awk_getbfn (awk, name_dup, name_len); + if (bfn != ASE_NULL) + { + ase_awk_nde_t* nde; + + if (!MATCH(awk,TOKEN_LPAREN)) + { + /* built-in function should be in the form + * of the function call */ + ASE_AWK_FREE (awk, name_dup); + + SETERRTOK (awk, ASE_AWK_ELPAREN); + return ASE_NULL; + } + + ASE_AWK_FREE (awk, name_dup); + nde = parse_fncall (awk, ASE_NULL, 0, bfn, line); + return (ase_awk_nde_t*)nde; + } + + /* now we know that name_dup is a normal identifier. */ + if (MATCH(awk,TOKEN_LBRACK)) + { + ase_awk_nde_t* nde; + nde = parse_hashidx (awk, name_dup, name_len, line); + if (nde == ASE_NULL) ASE_AWK_FREE (awk, name_dup); + return (ase_awk_nde_t*)nde; + } + else if (MATCH(awk,TOKEN_LPAREN)) + { + /* function call */ + ase_awk_nde_t* nde; + nde = parse_fncall (awk, name_dup, name_len, ASE_NULL, line); + if (nde == ASE_NULL) ASE_AWK_FREE (awk, name_dup); + return (ase_awk_nde_t*)nde; + } + else + { + /* normal variable */ + ase_awk_nde_var_t* nde; + ase_size_t idxa; + + nde = (ase_awk_nde_var_t*) ASE_AWK_MALLOC ( + awk, ASE_SIZEOF(ase_awk_nde_var_t)); + if (nde == ASE_NULL) + { + ASE_AWK_FREE (awk, name_dup); + SETERRLIN (awk, ASE_AWK_ENOMEM, line); + return ASE_NULL; + } + + /* search the parameter name list */ + idxa = ase_awk_tab_find ( + &awk->parse.params, 0, name_dup, name_len); + if (idxa != (ase_size_t)-1) + { + nde->type = ASE_AWK_NDE_ARG; + nde->line = line; + nde->next = ASE_NULL; + /*nde->id.name = ASE_NULL;*/ + nde->id.name = name_dup; + nde->id.name_len = name_len; + nde->id.idxa = idxa; + nde->idx = ASE_NULL; + + return (ase_awk_nde_t*)nde; + } + + /* search the local variable list */ + idxa = ase_awk_tab_rrfind ( + &awk->parse.locals, 0, name_dup, name_len); + if (idxa != (ase_size_t)-1) + { + nde->type = ASE_AWK_NDE_LOCAL; + nde->line = line; + nde->next = ASE_NULL; + /*nde->id.name = ASE_NULL;*/ + nde->id.name = name_dup; + nde->id.name_len = name_len; + nde->id.idxa = idxa; + nde->idx = ASE_NULL; + + return (ase_awk_nde_t*)nde; + } + + /* search the global variable list */ + idxa = ase_awk_tab_rrfind ( + &awk->parse.globals, 0, name_dup, name_len); + if (idxa != (ase_size_t)-1) + { + nde->type = ASE_AWK_NDE_GLOBAL; + nde->line = line; + nde->next = ASE_NULL; + /*nde->id.name = ASE_NULL;*/ + nde->id.name = name_dup; + nde->id.name_len = name_len; + nde->id.idxa = idxa; + nde->idx = ASE_NULL; + + return (ase_awk_nde_t*)nde; + } + + if (awk->option & ASE_AWK_IMPLICIT) + { + nde->type = ASE_AWK_NDE_NAMED; + nde->line = line; + nde->next = ASE_NULL; + nde->id.name = name_dup; + nde->id.name_len = name_len; + nde->id.idxa = (ase_size_t)-1; + nde->idx = ASE_NULL; + + return (ase_awk_nde_t*)nde; + } + + SETERRARG (awk, ASE_AWK_EUNDEF, line, name_dup, name_len); + + /* undefined variable */ + ASE_AWK_FREE (awk, name_dup); + ASE_AWK_FREE (awk, nde); + + return ASE_NULL; + } +} + +static ase_awk_nde_t* parse_hashidx ( + ase_awk_t* awk, ase_char_t* name, ase_size_t name_len, ase_size_t line) +{ + ase_awk_nde_t* idx, * tmp, * last; + ase_awk_nde_var_t* nde; + ase_size_t idxa; + + idx = ASE_NULL; + last = ASE_NULL; + + do + { + if (get_token(awk) == -1) + { + if (idx != ASE_NULL) ase_awk_clrpt (awk, idx); + return ASE_NULL; + } + + tmp = parse_expression (awk, awk->token.line); + if (tmp == ASE_NULL) + { + if (idx != ASE_NULL) ase_awk_clrpt (awk, idx); + return ASE_NULL; + } + + if (idx == ASE_NULL) + { + ASE_ASSERT (last == ASE_NULL); + idx = tmp; last = tmp; + } + else + { + last->next = tmp; + last = tmp; + } + } + while (MATCH(awk,TOKEN_COMMA)); + + ASE_ASSERT (idx != ASE_NULL); + + if (!MATCH(awk,TOKEN_RBRACK)) + { + ase_awk_clrpt (awk, idx); + + SETERRTOK (awk, ASE_AWK_ERBRACK); + return ASE_NULL; + } + + if (get_token(awk) == -1) + { + ase_awk_clrpt (awk, idx); + return ASE_NULL; + } + + nde = (ase_awk_nde_var_t*) + ASE_AWK_MALLOC (awk, ASE_SIZEOF(ase_awk_nde_var_t)); + if (nde == ASE_NULL) + { + ase_awk_clrpt (awk, idx); + SETERRLIN (awk, ASE_AWK_ENOMEM, line); + return ASE_NULL; + } + + /* search the parameter name list */ + idxa = ase_awk_tab_find (&awk->parse.params, 0, name, name_len); + if (idxa != (ase_size_t)-1) + { + nde->type = ASE_AWK_NDE_ARGIDX; + nde->line = line; + nde->next = ASE_NULL; + /*nde->id.name = ASE_NULL; */ + nde->id.name = name; + nde->id.name_len = name_len; + nde->id.idxa = idxa; + nde->idx = idx; + + return (ase_awk_nde_t*)nde; + } + + /* search the local variable list */ + idxa = ase_awk_tab_rrfind(&awk->parse.locals, 0, name, name_len); + if (idxa != (ase_size_t)-1) + { + nde->type = ASE_AWK_NDE_LOCALIDX; + nde->line = line; + nde->next = ASE_NULL; + /*nde->id.name = ASE_NULL; */ + nde->id.name = name; + nde->id.name_len = name_len; + nde->id.idxa = idxa; + nde->idx = idx; + + return (ase_awk_nde_t*)nde; + } + + /* search the global variable list */ + idxa = ase_awk_tab_rrfind(&awk->parse.globals, 0, name, name_len); + if (idxa != (ase_size_t)-1) + { + nde->type = ASE_AWK_NDE_GLOBALIDX; + nde->line = line; + nde->next = ASE_NULL; + /*nde->id.name = ASE_NULL;*/ + nde->id.name = name; + nde->id.name_len = name_len; + nde->id.idxa = idxa; + nde->idx = idx; + + return (ase_awk_nde_t*)nde; + } + + if (awk->option & ASE_AWK_IMPLICIT) + { + nde->type = ASE_AWK_NDE_NAMEDIDX; + nde->line = line; + nde->next = ASE_NULL; + nde->id.name = name; + nde->id.name_len = name_len; + nde->id.idxa = (ase_size_t)-1; + nde->idx = idx; + + return (ase_awk_nde_t*)nde; + } + + /* undefined variable */ + ase_awk_clrpt (awk, idx); + ASE_AWK_FREE (awk, nde); + + SETERRARG (awk, ASE_AWK_EUNDEF, line, name, name_len); + return ASE_NULL; +} + +static ase_awk_nde_t* parse_fncall ( + ase_awk_t* awk, ase_char_t* name, ase_size_t name_len, + ase_awk_bfn_t* bfn, ase_size_t line) +{ + ase_awk_nde_t* head, * curr, * nde; + ase_awk_nde_call_t* call; + ase_size_t nargs; + + if (get_token(awk) == -1) return ASE_NULL; + + head = curr = ASE_NULL; + nargs = 0; + + if (MATCH(awk,TOKEN_RPAREN)) + { + /* no parameters to the function call */ + if (get_token(awk) == -1) return ASE_NULL; + } + else + { + /* parse function parameters */ + + while (1) + { + nde = parse_expression (awk, awk->token.line); + if (nde == ASE_NULL) + { + if (head != ASE_NULL) ase_awk_clrpt (awk, head); + return ASE_NULL; + } + + if (head == ASE_NULL) head = nde; + else curr->next = nde; + curr = nde; + + nargs++; + + if (MATCH(awk,TOKEN_RPAREN)) + { + if (get_token(awk) == -1) + { + if (head != ASE_NULL) + ase_awk_clrpt (awk, head); + return ASE_NULL; + } + break; + } + + if (!MATCH(awk,TOKEN_COMMA)) + { + if (head != ASE_NULL) ase_awk_clrpt (awk, head); + + SETERRTOK (awk, ASE_AWK_ECOMMA); + return ASE_NULL; + } + + if (get_token(awk) == -1) + { + if (head != ASE_NULL) ase_awk_clrpt (awk, head); + return ASE_NULL; + } + } + + } + + call = (ase_awk_nde_call_t*) + ASE_AWK_MALLOC (awk, ASE_SIZEOF(ase_awk_nde_call_t)); + if (call == ASE_NULL) + { + if (head != ASE_NULL) ase_awk_clrpt (awk, head); + + SETERRLIN (awk, ASE_AWK_ENOMEM, line); + return ASE_NULL; + } + + if (bfn != ASE_NULL) + { + call->type = ASE_AWK_NDE_BFN; + call->line = line; + call->next = ASE_NULL; + + /*call->what.bfn = bfn; */ + call->what.bfn.name.ptr = bfn->name.ptr; + call->what.bfn.name.len = bfn->name.len; + call->what.bfn.arg.min = bfn->arg.min; + call->what.bfn.arg.max = bfn->arg.max; + call->what.bfn.arg.spec = bfn->arg.spec; + call->what.bfn.handler = bfn->handler; + + call->args = head; + call->nargs = nargs; + } + else + { + call->type = ASE_AWK_NDE_AFN; + call->line = line; + call->next = ASE_NULL; + call->what.afn.name.ptr = name; + call->what.afn.name.len = name_len; + call->args = head; + call->nargs = nargs; + } + + return (ase_awk_nde_t*)call; +} + +static ase_awk_nde_t* parse_if (ase_awk_t* awk, ase_size_t line) +{ + ase_awk_nde_t* test; + ase_awk_nde_t* then_part; + ase_awk_nde_t* else_part; + ase_awk_nde_if_t* nde; + + if (!MATCH(awk,TOKEN_LPAREN)) + { + SETERRTOK (awk, ASE_AWK_ELPAREN); + return ASE_NULL; + + } + if (get_token(awk) == -1) return ASE_NULL; + + test = parse_expression (awk, awk->token.line); + if (test == ASE_NULL) return ASE_NULL; + + if (!MATCH(awk,TOKEN_RPAREN)) + { + ase_awk_clrpt (awk, test); + + SETERRTOK (awk, ASE_AWK_ERPAREN); + return ASE_NULL; + } + + if (get_token(awk) == -1) + { + ase_awk_clrpt (awk, test); + return ASE_NULL; + } + + then_part = parse_statement (awk, awk->token.line); + if (then_part == ASE_NULL) + { + ase_awk_clrpt (awk, test); + return ASE_NULL; + } + + if (MATCH(awk,TOKEN_ELSE)) + { + if (get_token(awk) == -1) + { + ase_awk_clrpt (awk, then_part); + ase_awk_clrpt (awk, test); + return ASE_NULL; + } + + else_part = parse_statement (awk, awk->token.prev.line); + if (else_part == ASE_NULL) + { + ase_awk_clrpt (awk, then_part); + ase_awk_clrpt (awk, test); + return ASE_NULL; + } + } + else else_part = ASE_NULL; + + nde = (ase_awk_nde_if_t*) + ASE_AWK_MALLOC (awk, ASE_SIZEOF(ase_awk_nde_if_t)); + if (nde == ASE_NULL) + { + ase_awk_clrpt (awk, else_part); + ase_awk_clrpt (awk, then_part); + ase_awk_clrpt (awk, test); + + SETERRLIN (awk, ASE_AWK_ENOMEM, line); + return ASE_NULL; + } + + nde->type = ASE_AWK_NDE_IF; + nde->line = line; + nde->next = ASE_NULL; + nde->test = test; + nde->then_part = then_part; + nde->else_part = else_part; + + return (ase_awk_nde_t*)nde; +} + +static ase_awk_nde_t* parse_while (ase_awk_t* awk, ase_size_t line) +{ + ase_awk_nde_t* test, * body; + ase_awk_nde_while_t* nde; + + if (!MATCH(awk,TOKEN_LPAREN)) + { + SETERRTOK (awk, ASE_AWK_ELPAREN); + return ASE_NULL; + } + if (get_token(awk) == -1) return ASE_NULL; + + test = parse_expression (awk, awk->token.line); + if (test == ASE_NULL) return ASE_NULL; + + if (!MATCH(awk,TOKEN_RPAREN)) + { + ase_awk_clrpt (awk, test); + + SETERRTOK (awk, ASE_AWK_ERPAREN); + return ASE_NULL; + } + + if (get_token(awk) == -1) + { + ase_awk_clrpt (awk, test); + return ASE_NULL; + } + + body = parse_statement (awk, awk->token.line); + if (body == ASE_NULL) + { + ase_awk_clrpt (awk, test); + return ASE_NULL; + } + + nde = (ase_awk_nde_while_t*) + ASE_AWK_MALLOC (awk, ASE_SIZEOF(ase_awk_nde_while_t)); + if (nde == ASE_NULL) + { + ase_awk_clrpt (awk, body); + ase_awk_clrpt (awk, test); + + SETERRLIN (awk, ASE_AWK_ENOMEM, line); + return ASE_NULL; + } + + nde->type = ASE_AWK_NDE_WHILE; + nde->line = line; + nde->next = ASE_NULL; + nde->test = test; + nde->body = body; + + return (ase_awk_nde_t*)nde; +} + +static ase_awk_nde_t* parse_for (ase_awk_t* awk, ase_size_t line) +{ + ase_awk_nde_t* init, * test, * incr, * body; + ase_awk_nde_for_t* nde; + ase_awk_nde_foreach_t* nde2; + + if (!MATCH(awk,TOKEN_LPAREN)) + { + SETERRTOK (awk, ASE_AWK_ELPAREN); + return ASE_NULL; + } + if (get_token(awk) == -1) return ASE_NULL; + + if (MATCH(awk,TOKEN_SEMICOLON)) init = ASE_NULL; + else + { + /* this line is very ugly. it checks the entire next + * expression or the first element in the expression + * is wrapped by a parenthesis */ + int no_foreach = MATCH(awk,TOKEN_LPAREN); + + init = parse_expression (awk, awk->token.line); + if (init == ASE_NULL) return ASE_NULL; + + if (!no_foreach && init->type == ASE_AWK_NDE_EXP_BIN && + ((ase_awk_nde_exp_t*)init)->opcode == ASE_AWK_BINOP_IN && + is_plain_var(((ase_awk_nde_exp_t*)init)->left)) + { + /* switch to foreach */ + + if (!MATCH(awk,TOKEN_RPAREN)) + { + ase_awk_clrpt (awk, init); + SETERRTOK (awk, ASE_AWK_ERPAREN); + return ASE_NULL; + } + + if (get_token(awk) == -1) + { + ase_awk_clrpt (awk, init); + return ASE_NULL; + } + + body = parse_statement (awk, awk->token.line); + if (body == ASE_NULL) + { + ase_awk_clrpt (awk, init); + return ASE_NULL; + } + + nde2 = (ase_awk_nde_foreach_t*) ASE_AWK_MALLOC ( + awk, ASE_SIZEOF(ase_awk_nde_foreach_t)); + if (nde2 == ASE_NULL) + { + ase_awk_clrpt (awk, init); + ase_awk_clrpt (awk, body); + + SETERRLIN (awk, ASE_AWK_ENOMEM, line); + return ASE_NULL; + } + + nde2->type = ASE_AWK_NDE_FOREACH; + nde2->line = line; + nde2->next = ASE_NULL; + nde2->test = init; + nde2->body = body; + + return (ase_awk_nde_t*)nde2; + } + + if (!MATCH(awk,TOKEN_SEMICOLON)) + { + ase_awk_clrpt (awk, init); + + SETERRTOK (awk, ASE_AWK_ESCOLON); + return ASE_NULL; + } + } + + if (get_token(awk) == -1) + { + ase_awk_clrpt (awk, init); + return ASE_NULL; + } + + if (MATCH(awk,TOKEN_SEMICOLON)) test = ASE_NULL; + else + { + test = parse_expression (awk, awk->token.line); + if (test == ASE_NULL) + { + ase_awk_clrpt (awk, init); + return ASE_NULL; + } + + if (!MATCH(awk,TOKEN_SEMICOLON)) + { + ase_awk_clrpt (awk, init); + ase_awk_clrpt (awk, test); + + SETERRTOK (awk, ASE_AWK_ESCOLON); + return ASE_NULL; + } + } + + if (get_token(awk) == -1) + { + ase_awk_clrpt (awk, init); + ase_awk_clrpt (awk, test); + return ASE_NULL; + } + + if (MATCH(awk,TOKEN_RPAREN)) incr = ASE_NULL; + else + { + incr = parse_expression (awk, awk->token.line); + if (incr == ASE_NULL) + { + ase_awk_clrpt (awk, init); + ase_awk_clrpt (awk, test); + return ASE_NULL; + } + + if (!MATCH(awk,TOKEN_RPAREN)) + { + ase_awk_clrpt (awk, init); + ase_awk_clrpt (awk, test); + ase_awk_clrpt (awk, incr); + + SETERRTOK (awk, ASE_AWK_ERPAREN); + return ASE_NULL; + } + } + + if (get_token(awk) == -1) + { + ase_awk_clrpt (awk, init); + ase_awk_clrpt (awk, test); + ase_awk_clrpt (awk, incr); + return ASE_NULL; + } + + body = parse_statement (awk, awk->token.line); + if (body == ASE_NULL) + { + ase_awk_clrpt (awk, init); + ase_awk_clrpt (awk, test); + ase_awk_clrpt (awk, incr); + return ASE_NULL; + } + + nde = (ase_awk_nde_for_t*) + ASE_AWK_MALLOC (awk, ASE_SIZEOF(ase_awk_nde_for_t)); + if (nde == ASE_NULL) + { + ase_awk_clrpt (awk, init); + ase_awk_clrpt (awk, test); + ase_awk_clrpt (awk, incr); + ase_awk_clrpt (awk, body); + + SETERRLIN (awk, ASE_AWK_ENOMEM, line); + return ASE_NULL; + } + + nde->type = ASE_AWK_NDE_FOR; + nde->line = line; + nde->next = ASE_NULL; + nde->init = init; + nde->test = test; + nde->incr = incr; + nde->body = body; + + return (ase_awk_nde_t*)nde; +} + +static ase_awk_nde_t* parse_dowhile (ase_awk_t* awk, ase_size_t line) +{ + ase_awk_nde_t* test, * body; + ase_awk_nde_while_t* nde; + + ASE_ASSERT (awk->token.prev.type == TOKEN_DO); + + body = parse_statement (awk, awk->token.line); + if (body == ASE_NULL) return ASE_NULL; + + if (!MATCH(awk,TOKEN_WHILE)) + { + ase_awk_clrpt (awk, body); + + SETERRTOK (awk, ASE_AWK_EWHILE); + return ASE_NULL; + } + + if (get_token(awk) == -1) + { + ase_awk_clrpt (awk, body); + return ASE_NULL; + } + + if (!MATCH(awk,TOKEN_LPAREN)) + { + ase_awk_clrpt (awk, body); + + SETERRTOK (awk, ASE_AWK_ELPAREN); + return ASE_NULL; + } + + if (get_token(awk) == -1) + { + ase_awk_clrpt (awk, body); + return ASE_NULL; + } + + test = parse_expression (awk, awk->token.line); + if (test == ASE_NULL) + { + ase_awk_clrpt (awk, body); + return ASE_NULL; + } + + if (!MATCH(awk,TOKEN_RPAREN)) + { + ase_awk_clrpt (awk, body); + ase_awk_clrpt (awk, test); + + SETERRTOK (awk, ASE_AWK_ERPAREN); + return ASE_NULL; + } + + if (get_token(awk) == -1) + { + ase_awk_clrpt (awk, body); + ase_awk_clrpt (awk, test); + return ASE_NULL; + } + + nde = (ase_awk_nde_while_t*) + ASE_AWK_MALLOC (awk, ASE_SIZEOF(ase_awk_nde_while_t)); + if (nde == ASE_NULL) + { + ase_awk_clrpt (awk, body); + ase_awk_clrpt (awk, test); + + SETERRLIN (awk, ASE_AWK_ENOMEM, line); + return ASE_NULL; + } + + nde->type = ASE_AWK_NDE_DOWHILE; + nde->line = line; + nde->next = ASE_NULL; + nde->test = test; + nde->body = body; + + return (ase_awk_nde_t*)nde; +} + +static ase_awk_nde_t* parse_break (ase_awk_t* awk, ase_size_t line) +{ + ase_awk_nde_break_t* nde; + + ASE_ASSERT (awk->token.prev.type == TOKEN_BREAK); + if (awk->parse.depth.cur.loop <= 0) + { + SETERRLIN (awk, ASE_AWK_EBREAK, line); + return ASE_NULL; + } + + nde = (ase_awk_nde_break_t*) + ASE_AWK_MALLOC (awk, ASE_SIZEOF(ase_awk_nde_break_t)); + if (nde == ASE_NULL) + { + SETERRLIN (awk, ASE_AWK_ENOMEM, line); + return ASE_NULL; + } + + nde->type = ASE_AWK_NDE_BREAK; + nde->line = line; + nde->next = ASE_NULL; + + return (ase_awk_nde_t*)nde; +} + +static ase_awk_nde_t* parse_continue (ase_awk_t* awk, ase_size_t line) +{ + ase_awk_nde_continue_t* nde; + + ASE_ASSERT (awk->token.prev.type == TOKEN_CONTINUE); + if (awk->parse.depth.cur.loop <= 0) + { + SETERRLIN (awk, ASE_AWK_ECONTINUE, line); + return ASE_NULL; + } + + nde = (ase_awk_nde_continue_t*) + ASE_AWK_MALLOC (awk, ASE_SIZEOF(ase_awk_nde_continue_t)); + if (nde == ASE_NULL) + { + SETERRLIN (awk, ASE_AWK_ENOMEM, line); + return ASE_NULL; + } + + nde->type = ASE_AWK_NDE_CONTINUE; + nde->line = line; + nde->next = ASE_NULL; + + return (ase_awk_nde_t*)nde; +} + +static ase_awk_nde_t* parse_return (ase_awk_t* awk, ase_size_t line) +{ + ase_awk_nde_return_t* nde; + ase_awk_nde_t* val; + + ASE_ASSERT (awk->token.prev.type == TOKEN_RETURN); + + nde = (ase_awk_nde_return_t*) ASE_AWK_MALLOC ( + awk, ASE_SIZEOF(ase_awk_nde_return_t)); + if (nde == ASE_NULL) + { + SETERRLIN (awk, ASE_AWK_ENOMEM, line); + return ASE_NULL; + } + + nde->type = ASE_AWK_NDE_RETURN; + nde->line = line; + nde->next = ASE_NULL; + + if (MATCH(awk,TOKEN_SEMICOLON)) + { + /* no return value */ + val = ASE_NULL; + } + else + { + val = parse_expression (awk, awk->token.line); + if (val == ASE_NULL) + { + ASE_AWK_FREE (awk, nde); + return ASE_NULL; + } + } + + nde->val = val; + return (ase_awk_nde_t*)nde; +} + +static ase_awk_nde_t* parse_exit (ase_awk_t* awk, ase_size_t line) +{ + ase_awk_nde_exit_t* nde; + ase_awk_nde_t* val; + + ASE_ASSERT (awk->token.prev.type == TOKEN_EXIT); + + nde = (ase_awk_nde_exit_t*) + ASE_AWK_MALLOC (awk, ASE_SIZEOF(ase_awk_nde_exit_t)); + if (nde == ASE_NULL) + { + SETERRLIN (awk, ASE_AWK_ENOMEM, line); + return ASE_NULL; + } + + nde->type = ASE_AWK_NDE_EXIT; + nde->line = line; + nde->next = ASE_NULL; + + if (MATCH(awk,TOKEN_SEMICOLON)) + { + /* no exit code */ + val = ASE_NULL; + } + else + { + val = parse_expression (awk, awk->token.line); + if (val == ASE_NULL) + { + ASE_AWK_FREE (awk, nde); + return ASE_NULL; + } + } + + nde->val = val; + return (ase_awk_nde_t*)nde; +} + +static ase_awk_nde_t* parse_next (ase_awk_t* awk, ase_size_t line) +{ + ase_awk_nde_next_t* nde; + + ASE_ASSERT (awk->token.prev.type == TOKEN_NEXT); + + if (awk->parse.id.block == PARSE_BEGIN_BLOCK) + { + SETERRLIN (awk, ASE_AWK_ENEXTBEG, line); + return ASE_NULL; + } + if (awk->parse.id.block == PARSE_END_BLOCK) + { + SETERRLIN (awk, ASE_AWK_ENEXTEND, line); + return ASE_NULL; + } + + nde = (ase_awk_nde_next_t*) + ASE_AWK_MALLOC (awk, ASE_SIZEOF(ase_awk_nde_next_t)); + if (nde == ASE_NULL) + { + SETERRLIN (awk, ASE_AWK_ENOMEM, line); + return ASE_NULL; + } + nde->type = ASE_AWK_NDE_NEXT; + nde->line = line; + nde->next = ASE_NULL; + + return (ase_awk_nde_t*)nde; +} + +static ase_awk_nde_t* parse_nextfile (ase_awk_t* awk, ase_size_t line, int out) +{ + ase_awk_nde_nextfile_t* nde; + + if (awk->parse.id.block == PARSE_BEGIN_BLOCK) + { + SETERRLIN (awk, ASE_AWK_ENEXTFBEG, line); + return ASE_NULL; + } + if (awk->parse.id.block == PARSE_END_BLOCK) + { + SETERRLIN (awk, ASE_AWK_ENEXTFEND, line); + return ASE_NULL; + } + + nde = (ase_awk_nde_nextfile_t*) + ASE_AWK_MALLOC (awk, ASE_SIZEOF(ase_awk_nde_nextfile_t)); + if (nde == ASE_NULL) + { + SETERRLIN (awk, ASE_AWK_ENOMEM, line); + return ASE_NULL; + } + + nde->type = ASE_AWK_NDE_NEXTFILE; + nde->line = line; + nde->next = ASE_NULL; + nde->out = out; + + return (ase_awk_nde_t*)nde; +} + +static ase_awk_nde_t* parse_delete (ase_awk_t* awk, ase_size_t line) +{ + ase_awk_nde_delete_t* nde; + ase_awk_nde_t* var; + + ASE_ASSERT (awk->token.prev.type == TOKEN_DELETE); + if (!MATCH(awk,TOKEN_IDENT)) + { + SETERRTOK (awk, ASE_AWK_EIDENT); + return ASE_NULL; + } + + var = parse_primary_ident (awk, awk->token.line); + if (var == ASE_NULL) return ASE_NULL; + + if (!is_var (var)) + { + /* a normal identifier is expected */ + ase_awk_clrpt (awk, var); + SETERRLIN (awk, ASE_AWK_EDELETE, line); + return ASE_NULL; + } + + nde = (ase_awk_nde_delete_t*) ASE_AWK_MALLOC ( + awk, ASE_SIZEOF(ase_awk_nde_delete_t)); + if (nde == ASE_NULL) + { + SETERRLIN (awk, ASE_AWK_ENOMEM, line); + return ASE_NULL; + } + + nde->type = ASE_AWK_NDE_DELETE; + nde->line = line; + nde->next = ASE_NULL; + nde->var = var; + + return (ase_awk_nde_t*)nde; +} + +static ase_awk_nde_t* parse_print (ase_awk_t* awk, ase_size_t line, int type) +{ + ase_awk_nde_print_t* nde; + ase_awk_nde_t* args = ASE_NULL; + ase_awk_nde_t* out = ASE_NULL; + int out_type; + + if (!MATCH(awk,TOKEN_SEMICOLON) && + !MATCH(awk,TOKEN_GT) && + !MATCH(awk,TOKEN_RSHIFT) && + !MATCH(awk,TOKEN_BOR) && + !MATCH(awk,TOKEN_BORAND)) + { + ase_awk_nde_t* args_tail; + ase_awk_nde_t* tail_prev; + + args = parse_expression (awk, awk->token.line); + if (args == ASE_NULL) return ASE_NULL; + + args_tail = args; + tail_prev = ASE_NULL; + + if (args->type != ASE_AWK_NDE_GRP) + { + /* args->type == ASE_AWK_NDE_GRP when print (a, b, c) + * args->type != ASE_AWK_NDE_GRP when print a, b, c */ + + while (MATCH(awk,TOKEN_COMMA)) + { + if (get_token(awk) == -1) + { + ase_awk_clrpt (awk, args); + return ASE_NULL; + } + + args_tail->next = parse_expression (awk, awk->token.line); + if (args_tail->next == ASE_NULL) + { + ase_awk_clrpt (awk, args); + return ASE_NULL; + } + + tail_prev = args_tail; + args_tail = args_tail->next; + } + } + + /* print 1 > 2 would print 1 to the file named 2. + * print (1 > 2) would print (1 > 2) on the console */ + if (awk->token.prev.type != TOKEN_RPAREN && + args_tail->type == ASE_AWK_NDE_EXP_BIN) + { + ase_awk_nde_exp_t* ep = (ase_awk_nde_exp_t*)args_tail; + if (ep->opcode == ASE_AWK_BINOP_GT) + { + ase_awk_nde_t* tmp = args_tail; + + if (tail_prev != ASE_NULL) + tail_prev->next = ep->left; + else args = ep->left; + + out = ep->right; + out_type = ASE_AWK_OUT_FILE; + + ASE_AWK_FREE (awk, tmp); + } + else if (ep->opcode == ASE_AWK_BINOP_RSHIFT) + { + ase_awk_nde_t* tmp = args_tail; + + if (tail_prev != ASE_NULL) + tail_prev->next = ep->left; + else args = ep->left; + + out = ep->right; + out_type = ASE_AWK_OUT_FILE_APPEND; + + ASE_AWK_FREE (awk, tmp); + } + else if (ep->opcode == ASE_AWK_BINOP_BOR) + { + ase_awk_nde_t* tmp = args_tail; + + if (tail_prev != ASE_NULL) + tail_prev->next = ep->left; + else args = ep->left; + + out = ep->right; + out_type = ASE_AWK_OUT_PIPE; + + ASE_AWK_FREE (awk, tmp); + } + } + } + + if (out == ASE_NULL) + { + out_type = MATCH(awk,TOKEN_GT)? ASE_AWK_OUT_FILE: + MATCH(awk,TOKEN_RSHIFT)? ASE_AWK_OUT_FILE_APPEND: + MATCH(awk,TOKEN_BOR)? ASE_AWK_OUT_PIPE: + MATCH(awk,TOKEN_BORAND)? ASE_AWK_OUT_COPROC: + ASE_AWK_OUT_CONSOLE; + + if (out_type != ASE_AWK_OUT_CONSOLE) + { + if (get_token(awk) == -1) + { + if (args != ASE_NULL) ase_awk_clrpt (awk, args); + return ASE_NULL; + } + + out = parse_expression (awk, awk->token.line); + if (out == ASE_NULL) + { + if (args != ASE_NULL) ase_awk_clrpt (awk, args); + return ASE_NULL; + } + } + } + + nde = (ase_awk_nde_print_t*) + ASE_AWK_MALLOC (awk, ASE_SIZEOF(ase_awk_nde_print_t)); + if (nde == ASE_NULL) + { + if (args != ASE_NULL) ase_awk_clrpt (awk, args); + if (out != ASE_NULL) ase_awk_clrpt (awk, out); + + SETERRLIN (awk, ASE_AWK_ENOMEM, line); + return ASE_NULL; + } + + ASE_ASSERTX ( + type == ASE_AWK_NDE_PRINT || type == ASE_AWK_NDE_PRINTF, + "the node type should be either ASE_AWK_NDE_PRINT or ASE_AWK_NDE_PRINTF"); + + if (type == ASE_AWK_NDE_PRINTF && args == ASE_NULL) + { + if (out != ASE_NULL) ase_awk_clrpt (awk, out); + SETERRLIN (awk, ASE_AWK_EPRINTFARG, line); + return ASE_NULL; + } + + nde->type = type; + nde->line = line; + nde->next = ASE_NULL; + nde->args = args; + nde->out_type = out_type; + nde->out = out; + + return (ase_awk_nde_t*)nde; +} + +static int get_token (ase_awk_t* awk) +{ + ase_cint_t c; + ase_size_t line; + int n; + + line = awk->token.line; + + awk->token.prev.type = awk->token.type; + awk->token.prev.line = awk->token.line; + awk->token.prev.column = awk->token.column; + + do + { + if (skip_spaces(awk) == -1) return -1; + if ((n = skip_comment(awk)) == -1) return -1; + } + while (n == 1); + + ase_str_clear (&awk->token.name); + awk->token.line = awk->src.lex.line; + awk->token.column = awk->src.lex.column; + + if (line != 0 && (awk->option & ASE_AWK_BLOCKLESS) && + (awk->parse.id.block == PARSE_PATTERN || + awk->parse.id.block == PARSE_BEGIN || + awk->parse.id.block == PARSE_END)) + { + if (awk->token.line != line) + { + SET_TOKEN_TYPE (awk, TOKEN_NEWLINE); + return 0; + } + } + + c = awk->src.lex.curc; + + if (c == ASE_CHAR_EOF) + { + ADD_TOKEN_CHAR (awk, ASE_T('<')); + ADD_TOKEN_CHAR (awk, ASE_T('E')); + ADD_TOKEN_CHAR (awk, ASE_T('O')); + ADD_TOKEN_CHAR (awk, ASE_T('F')); + ADD_TOKEN_CHAR (awk, ASE_T('>')); + + SET_TOKEN_TYPE (awk, TOKEN_EOF); + } + else if (ASE_AWK_ISDIGIT (awk, c)/*|| c == ASE_T('.')*/) + { + if (get_number (awk) == -1) return -1; + } + else if (c == ASE_T('.')) + { + if (get_char (awk) == -1) return -1; + c = awk->src.lex.curc; + + if ((awk->option & ASE_AWK_EXPLICIT) == 0 && + ASE_AWK_ISDIGIT (awk, c)) + { + awk->src.lex.curc = ASE_T('.'); + if (unget_char (awk, c) == -1) return -1; + if (get_number (awk) == -1) return -1; + + } + else /*if (ASE_AWK_ISSPACE (awk, c) || c == ASE_CHAR_EOF)*/ + { + SET_TOKEN_TYPE (awk, TOKEN_PERIOD); + ADD_TOKEN_CHAR (awk, ASE_T('.')); + } + /* + else + { + ase_awk_seterror ( + awk, ASE_AWK_ELXCHR, awk->token.line, + ASE_T("floating point not followed by any valid digits")); + return -1; + } + */ + } + else if (ASE_AWK_ISALPHA (awk, c) || c == ASE_T('_')) + { + int type; + + /* identifier */ + do + { + ADD_TOKEN_CHAR (awk, c); + GET_CHAR_TO (awk, c); + } + while (ASE_AWK_ISALPHA (awk, c) || + c == ASE_T('_') || ASE_AWK_ISDIGIT(awk,c)); + + type = classify_ident (awk, + ASE_STR_BUF(&awk->token.name), + ASE_STR_LEN(&awk->token.name)); + SET_TOKEN_TYPE (awk, type); + } + else if (c == ASE_T('\"')) + { + SET_TOKEN_TYPE (awk, TOKEN_STR); + + if (get_charstr(awk) == -1) return -1; + + while (awk->option & ASE_AWK_STRCONCAT) + { + do + { + if (skip_spaces(awk) == -1) return -1; + if ((n = skip_comment(awk)) == -1) return -1; + } + while (n == 1); + + c = awk->src.lex.curc; + if (c != ASE_T('\"')) break; + + if (get_charstr(awk) == -1) return -1; + } + + } + else if (c == ASE_T('=')) + { + ADD_TOKEN_CHAR (awk, c); + GET_CHAR_TO (awk, c); + if (c == ASE_T('=')) + { + SET_TOKEN_TYPE (awk, TOKEN_EQ); + ADD_TOKEN_CHAR (awk, c); + GET_CHAR (awk); + } + else + { + SET_TOKEN_TYPE (awk, TOKEN_ASSIGN); + } + } + else if (c == ASE_T('!')) + { + ADD_TOKEN_CHAR (awk, c); + GET_CHAR_TO (awk, c); + if (c == ASE_T('=')) + { + SET_TOKEN_TYPE (awk, TOKEN_NE); + ADD_TOKEN_CHAR (awk, c); + GET_CHAR (awk); + } + else if (c == ASE_T('~')) + { + SET_TOKEN_TYPE (awk, TOKEN_NM); + ADD_TOKEN_CHAR (awk, c); + GET_CHAR (awk); + } + else + { + SET_TOKEN_TYPE (awk, TOKEN_NOT); + } + } + else if (c == ASE_T('>')) + { + ADD_TOKEN_CHAR (awk, c); + GET_CHAR_TO (awk, c); + if ((awk->option & ASE_AWK_SHIFT) && c == ASE_T('>')) + { + SET_TOKEN_TYPE (awk, TOKEN_RSHIFT); + ADD_TOKEN_CHAR (awk, c); + GET_CHAR (awk); + } + else if (c == ASE_T('=')) + { + SET_TOKEN_TYPE (awk, TOKEN_GE); + ADD_TOKEN_CHAR (awk, c); + GET_CHAR (awk); + } + else + { + SET_TOKEN_TYPE (awk, TOKEN_GT); + } + } + else if (c == ASE_T('<')) + { + ADD_TOKEN_CHAR (awk, c); + GET_CHAR_TO (awk, c); + + if ((awk->option & ASE_AWK_SHIFT) && c == ASE_T('<')) + { + SET_TOKEN_TYPE (awk, TOKEN_LSHIFT); + ADD_TOKEN_CHAR (awk, c); + GET_CHAR (awk); + } + else if (c == ASE_T('=')) + { + SET_TOKEN_TYPE (awk, TOKEN_LE); + ADD_TOKEN_CHAR (awk, c); + GET_CHAR (awk); + } + else + { + SET_TOKEN_TYPE (awk, TOKEN_LT); + } + } + else if (c == ASE_T('|')) + { + ADD_TOKEN_CHAR (awk, c); + GET_CHAR_TO (awk, c); + if (c == ASE_T('|')) + { + SET_TOKEN_TYPE (awk, TOKEN_LOR); + ADD_TOKEN_CHAR (awk, c); + GET_CHAR (awk); + } + else if ((awk->option & ASE_AWK_COPROC) && c == ASE_T('&')) + { + SET_TOKEN_TYPE (awk, TOKEN_BORAND); + ADD_TOKEN_CHAR (awk, c); + GET_CHAR (awk); + } + else + { + SET_TOKEN_TYPE (awk, TOKEN_BOR); + } + } + else if (c == ASE_T('&')) + { + ADD_TOKEN_CHAR (awk, c); + GET_CHAR_TO (awk, c); + if (c == ASE_T('&')) + { + SET_TOKEN_TYPE (awk, TOKEN_LAND); + ADD_TOKEN_CHAR (awk, c); + GET_CHAR (awk); + } + else + { + SET_TOKEN_TYPE (awk, TOKEN_BAND); + } + } + else if (c == ASE_T('~')) + { + SET_TOKEN_TYPE (awk, TOKEN_TILDE); + ADD_TOKEN_CHAR (awk, c); + GET_CHAR (awk); + } + else if (c == ASE_T('^')) + { + SET_TOKEN_TYPE (awk, TOKEN_BXOR); + ADD_TOKEN_CHAR (awk, c); + GET_CHAR (awk); + } + else if (c == ASE_T('+')) + { + ADD_TOKEN_CHAR (awk, c); + GET_CHAR_TO (awk, c); + if (c == ASE_T('+')) + { + SET_TOKEN_TYPE (awk, TOKEN_PLUSPLUS); + ADD_TOKEN_CHAR (awk, c); + GET_CHAR (awk); + } + else if (c == ASE_T('=')) + { + SET_TOKEN_TYPE (awk, TOKEN_PLUS_ASSIGN); + ADD_TOKEN_CHAR (awk, c); + GET_CHAR (awk); + } + else + { + SET_TOKEN_TYPE (awk, TOKEN_PLUS); + } + } + else if (c == ASE_T('-')) + { + ADD_TOKEN_CHAR (awk, c); + GET_CHAR_TO (awk, c); + if (c == ASE_T('-')) + { + SET_TOKEN_TYPE (awk, TOKEN_MINUSMINUS); + ADD_TOKEN_CHAR (awk, c); + GET_CHAR (awk); + } + else if (c == ASE_T('=')) + { + SET_TOKEN_TYPE (awk, TOKEN_MINUS_ASSIGN); + ADD_TOKEN_CHAR (awk, c); + GET_CHAR (awk); + } + else + { + SET_TOKEN_TYPE (awk, TOKEN_MINUS); + } + } + else if (c == ASE_T('*')) + { + ADD_TOKEN_CHAR (awk, c); + GET_CHAR_TO (awk, c); + + if (c == ASE_T('=')) + { + SET_TOKEN_TYPE (awk, TOKEN_MUL_ASSIGN); + ADD_TOKEN_CHAR (awk, c); + GET_CHAR (awk); + } + else if (c == ASE_T('*')) + { + ADD_TOKEN_CHAR (awk, c); + GET_CHAR_TO (awk, c); + if (c == ASE_T('=')) + { + SET_TOKEN_TYPE (awk, TOKEN_EXP_ASSIGN); + ADD_TOKEN_CHAR (awk, c); + GET_CHAR (awk); + } + else + { + SET_TOKEN_TYPE (awk, TOKEN_EXP); + } + } + else + { + SET_TOKEN_TYPE (awk, TOKEN_MUL); + } + } + else if (c == ASE_T('/')) + { + ADD_TOKEN_CHAR (awk, c); + GET_CHAR_TO (awk, c); + + if (c == ASE_T('=')) + { + SET_TOKEN_TYPE (awk, TOKEN_DIV_ASSIGN); + ADD_TOKEN_CHAR (awk, c); + GET_CHAR (awk); + } + else if ((awk->option & ASE_AWK_IDIV) && c == ASE_T('/')) + { + ADD_TOKEN_CHAR (awk, c); + GET_CHAR_TO (awk, c); + if (c == ASE_T('=')) + { + SET_TOKEN_TYPE (awk, TOKEN_IDIV_ASSIGN); + ADD_TOKEN_CHAR (awk, c); + GET_CHAR (awk); + } + else + { + SET_TOKEN_TYPE (awk, TOKEN_IDIV); + } + } + else + { + SET_TOKEN_TYPE (awk, TOKEN_DIV); + } + } +#if 0 + /* TODO: is it a good idea to use a back-slash for + * the idiv operator like BASIC? */ + else if ((awk->option & ASE_AWK_IDIV) && c == ASE_T('\\')) + { + ADD_TOKEN_CHAR (awk, c); + GET_CHAR_TO (awk, c); + + if (c == ASE_T('=')) + { + SET_TOKEN_TYPE (awk, TOKEN_IDIV_ASSIGN); + ADD_TOKEN_CHAR (awk, c); + GET_CHAR (awk); + } + else + { + SET_TOKEN_TYPE (awk, TOKEN_IDIV); + } + } +#endif + else if (c == ASE_T('%')) + { + ADD_TOKEN_CHAR (awk, c); + GET_CHAR_TO (awk, c); + + if (c == ASE_T('=')) + { + SET_TOKEN_TYPE (awk, TOKEN_MOD_ASSIGN); + ADD_TOKEN_CHAR (awk, c); + GET_CHAR (awk); + } + else + { + SET_TOKEN_TYPE (awk, TOKEN_MOD); + } + } + else if (c == ASE_T('(')) + { + SET_TOKEN_TYPE (awk, TOKEN_LPAREN); + ADD_TOKEN_CHAR (awk, c); + GET_CHAR (awk); + } + else if (c == ASE_T(')')) + { + SET_TOKEN_TYPE (awk, TOKEN_RPAREN); + ADD_TOKEN_CHAR (awk, c); + GET_CHAR (awk); + } + else if (c == ASE_T('{')) + { + SET_TOKEN_TYPE (awk, TOKEN_LBRACE); + ADD_TOKEN_CHAR (awk, c); + GET_CHAR (awk); + } + else if (c == ASE_T('}')) + { + SET_TOKEN_TYPE (awk, TOKEN_RBRACE); + ADD_TOKEN_CHAR (awk, c); + GET_CHAR (awk); + } + else if (c == ASE_T('[')) + { + SET_TOKEN_TYPE (awk, TOKEN_LBRACK); + ADD_TOKEN_CHAR (awk, c); + GET_CHAR (awk); + } + else if (c == ASE_T(']')) + { + SET_TOKEN_TYPE (awk, TOKEN_RBRACK); + ADD_TOKEN_CHAR (awk, c); + GET_CHAR (awk); + } + else if (c == ASE_T('$')) + { + SET_TOKEN_TYPE (awk, TOKEN_DOLLAR); + ADD_TOKEN_CHAR (awk, c); + GET_CHAR (awk); + } + else if (c == ASE_T(',')) + { + SET_TOKEN_TYPE (awk, TOKEN_COMMA); + ADD_TOKEN_CHAR (awk, c); + GET_CHAR (awk); + } + else if (c == ASE_T(';')) + { + SET_TOKEN_TYPE (awk, TOKEN_SEMICOLON); + ADD_TOKEN_CHAR (awk, c); + GET_CHAR (awk); + } + else if (c == ASE_T(':')) + { + SET_TOKEN_TYPE (awk, TOKEN_COLON); + ADD_TOKEN_CHAR (awk, c); + GET_CHAR (awk); + } + else if (c == ASE_T('?')) + { + SET_TOKEN_TYPE (awk, TOKEN_QUEST); + ADD_TOKEN_CHAR (awk, c); + GET_CHAR (awk); + } + else + { + ase_char_t cc = (ase_char_t)c; + SETERRARG (awk, ASE_AWK_ELXCHR, awk->token.line, &cc, 1); + return -1; + } + + return 0; +} + +static int get_number (ase_awk_t* awk) +{ + ase_cint_t c; + + ASE_ASSERT (ASE_STR_LEN(&awk->token.name) == 0); + SET_TOKEN_TYPE (awk, TOKEN_INT); + + c = awk->src.lex.curc; + + if (c == ASE_T('0')) + { + ADD_TOKEN_CHAR (awk, c); + GET_CHAR_TO (awk, c); + + if (c == ASE_T('x') || c == ASE_T('X')) + { + /* hexadecimal number */ + do + { + ADD_TOKEN_CHAR (awk, c); + GET_CHAR_TO (awk, c); + } + while (ASE_AWK_ISXDIGIT (awk, c)); + + return 0; + } + #if 0 + else if (c == ASE_T('b') || c == ASE_T('B')) + { + /* binary number */ + do + { + ADD_TOKEN_CHAR (awk, c); + GET_CHAR_TO (awk, c); + } + while (c == ASE_T('0') || c == ASE_T('1')); + + return 0; + } + #endif + else if (c != '.') + { + /* octal number */ + while (c >= ASE_T('0') && c <= ASE_T('7')) + { + ADD_TOKEN_CHAR (awk, c); + GET_CHAR_TO (awk, c); + } + + return 0; + } + } + + while (ASE_AWK_ISDIGIT (awk, c)) + { + ADD_TOKEN_CHAR (awk, c); + GET_CHAR_TO (awk, c); + } + + if (c == ASE_T('.')) + { + /* floating-point number */ + SET_TOKEN_TYPE (awk, TOKEN_REAL); + + ADD_TOKEN_CHAR (awk, c); + GET_CHAR_TO (awk, c); + + while (ASE_AWK_ISDIGIT (awk, c)) + { + ADD_TOKEN_CHAR (awk, c); + GET_CHAR_TO (awk, c); + } + } + + if (c == ASE_T('E') || c == ASE_T('e')) + { + SET_TOKEN_TYPE (awk, TOKEN_REAL); + + ADD_TOKEN_CHAR (awk, c); + GET_CHAR_TO (awk, c); + + if (c == ASE_T('+') || c == ASE_T('-')) + { + ADD_TOKEN_CHAR (awk, c); + GET_CHAR_TO (awk, c); + } + + while (ASE_AWK_ISDIGIT (awk, c)) + { + ADD_TOKEN_CHAR (awk, c); + GET_CHAR_TO (awk, c); + } + } + + return 0; +} + +static int get_charstr (ase_awk_t* awk) +{ + if (awk->src.lex.curc != ASE_T('\"')) + { + /* the starting quote has been consumed before this function + * has been called */ + ADD_TOKEN_CHAR (awk, awk->src.lex.curc); + } + return get_string (awk, ASE_T('\"'), ASE_T('\\'), ase_false); +} + +static int get_rexstr (ase_awk_t* awk) +{ + if (awk->src.lex.curc == ASE_T('/')) + { + /* this part of the function is different from get_charstr + * because of the way this function is called */ + GET_CHAR (awk); + return 0; + } + else + { + ADD_TOKEN_CHAR (awk, awk->src.lex.curc); + return get_string (awk, ASE_T('/'), ASE_T('\\'), ase_true); + } +} + +static int get_string ( + ase_awk_t* awk, ase_char_t end_char, + ase_char_t esc_char, ase_bool_t keep_esc_char) +{ + ase_cint_t c; + int escaped = 0; + int digit_count = 0; + ase_cint_t c_acc = 0; + + while (1) + { + GET_CHAR_TO (awk, c); + + if (c == ASE_CHAR_EOF) + { + SETERRTOK (awk, ASE_AWK_EENDSTR); + return -1; + } + + if (escaped == 3) + { + if (c >= ASE_T('0') && c <= ASE_T('7')) + { + c_acc = c_acc * 8 + c - ASE_T('0'); + digit_count++; + if (digit_count >= escaped) + { + ADD_TOKEN_CHAR (awk, c_acc); + escaped = 0; + } + continue; + } + else + { + ADD_TOKEN_CHAR (awk, c_acc); + escaped = 0; + } + } + else if (escaped == 2 || escaped == 4 || escaped == 8) + { + if (c >= ASE_T('0') && c <= ASE_T('9')) + { + c_acc = c_acc * 16 + c - ASE_T('0'); + digit_count++; + if (digit_count >= escaped) + { + ADD_TOKEN_CHAR (awk, c_acc); + escaped = 0; + } + continue; + } + else if (c >= ASE_T('A') && c <= ASE_T('F')) + { + c_acc = c_acc * 16 + c - ASE_T('A') + 10; + digit_count++; + if (digit_count >= escaped) + { + ADD_TOKEN_CHAR (awk, c_acc); + escaped = 0; + } + continue; + } + else if (c >= ASE_T('a') && c <= ASE_T('f')) + { + c_acc = c_acc * 16 + c - ASE_T('a') + 10; + digit_count++; + if (digit_count >= escaped) + { + ADD_TOKEN_CHAR (awk, c_acc); + escaped = 0; + } + continue; + } + else + { + ase_char_t rc; + + rc = (escaped == 2)? ASE_T('x'): + (escaped == 4)? ASE_T('u'): ASE_T('U'); + + if (digit_count == 0) ADD_TOKEN_CHAR (awk, rc); + else ADD_TOKEN_CHAR (awk, c_acc); + + escaped = 0; + } + } + + if (escaped == 0 && c == end_char) + { + /* terminating quote */ + /*GET_CHAR_TO (awk, c);*/ + GET_CHAR (awk); + break; + } + + if (escaped == 0 && c == esc_char) + { + escaped = 1; + continue; + } + + if (escaped == 1) + { + if (c == ASE_T('n')) c = ASE_T('\n'); + else if (c == ASE_T('r')) c = ASE_T('\r'); + else if (c == ASE_T('t')) c = ASE_T('\t'); + else if (c == ASE_T('f')) c = ASE_T('\f'); + else if (c == ASE_T('b')) c = ASE_T('\b'); + else if (c == ASE_T('v')) c = ASE_T('\v'); + else if (c == ASE_T('a')) c = ASE_T('\a'); + else if (c >= ASE_T('0') && c <= ASE_T('7')) + { + escaped = 3; + digit_count = 1; + c_acc = c - ASE_T('0'); + continue; + } + else if (c == ASE_T('x')) + { + escaped = 2; + digit_count = 0; + c_acc = 0; + continue; + } + #ifdef ASE_CHAR_IS_WCHAR + else if (c == ASE_T('u') && ASE_SIZEOF(ase_char_t) >= 2) + { + escaped = 4; + digit_count = 0; + c_acc = 0; + continue; + } + else if (c == ASE_T('U') && ASE_SIZEOF(ase_char_t) >= 4) + { + escaped = 8; + digit_count = 0; + c_acc = 0; + continue; + } + #endif + else if (keep_esc_char) + { + ADD_TOKEN_CHAR (awk, esc_char); + } + + escaped = 0; + } + + ADD_TOKEN_CHAR (awk, c); + } + + return 0; +} + +static int get_char (ase_awk_t* awk) +{ + ase_ssize_t n; + /*ase_char_t c;*/ + + if (awk->src.lex.ungotc_count > 0) + { + awk->src.lex.curc = awk->src.lex.ungotc[--awk->src.lex.ungotc_count]; + awk->src.lex.line = awk->src.lex.ungotc_line[awk->src.lex.ungotc_count]; + awk->src.lex.column = awk->src.lex.ungotc_column[awk->src.lex.ungotc_count]; + return 0; + } + + if (awk->src.shared.buf_pos >= awk->src.shared.buf_len) + { + CLRERR (awk); + n = awk->src.ios.in ( + ASE_AWK_IO_READ, awk->src.ios.custom_data, + awk->src.shared.buf, ASE_COUNTOF(awk->src.shared.buf)); + if (n <= -1) + { + if (ISNOERR(awk)) SETERR (awk, ASE_AWK_ESINRD); + return -1; + } + + if (n == 0) + { + awk->src.lex.curc = ASE_CHAR_EOF; + return 0; + } + + awk->src.shared.buf_pos = 0; + awk->src.shared.buf_len = n; + } + + awk->src.lex.curc = awk->src.shared.buf[awk->src.shared.buf_pos++]; + + if (awk->src.lex.curc == ASE_T('\n')) + { + awk->src.lex.line++; + awk->src.lex.column = 1; + } + else awk->src.lex.column++; + + return 0; +} + +static int unget_char (ase_awk_t* awk, ase_cint_t c) +{ + if (awk->src.lex.ungotc_count >= ASE_COUNTOF(awk->src.lex.ungotc)) + { + SETERRLIN (awk, ASE_AWK_ELXUNG, awk->src.lex.line); + return -1; + } + + awk->src.lex.ungotc_line[awk->src.lex.ungotc_count] = awk->src.lex.line; + awk->src.lex.ungotc_column[awk->src.lex.ungotc_count] = awk->src.lex.column; + awk->src.lex.ungotc[awk->src.lex.ungotc_count++] = c; + return 0; +} + +static int skip_spaces (ase_awk_t* awk) +{ + ase_cint_t c = awk->src.lex.curc; + while (ASE_AWK_ISSPACE (awk, c)) GET_CHAR_TO (awk, c); + return 0; +} + +static int skip_comment (ase_awk_t* awk) +{ + ase_cint_t c = awk->src.lex.curc; + ase_size_t line, column; + + if (c == ASE_T('#')) + { + do + { + GET_CHAR_TO (awk, c); + } + while (c != ASE_T('\n') && c != ASE_CHAR_EOF); + + GET_CHAR (awk); + return 1; /* comment by # */ + } + + if (c != ASE_T('/')) return 0; /* not a comment */ + + line = awk->src.lex.line; + column = awk->src.lex.column; + GET_CHAR_TO (awk, c); + + if (c == ASE_T('*')) + { + do + { + GET_CHAR_TO (awk, c); + if (c == ASE_CHAR_EOF) + { + SETERRLIN (awk, ASE_AWK_EENDCMT, awk->src.lex.line); + return -1; + } + + if (c == ASE_T('*')) + { + GET_CHAR_TO (awk, c); + if (c == ASE_CHAR_EOF) + { + SETERRLIN (awk, ASE_AWK_EENDCMT, awk->src.lex.line); + return -1; + } + + if (c == ASE_T('/')) + { + /*GET_CHAR_TO (awk, c);*/ + GET_CHAR (awk); + break; + } + } + } + while (1); + + return 1; /* c-style comment */ + } + + if (unget_char (awk, c) == -1) return -1; /* error */ + awk->src.lex.curc = ASE_T('/'); + awk->src.lex.line = line; + awk->src.lex.column = column; + + return 0; +} + +static int classify_ident ( + ase_awk_t* awk, const ase_char_t* name, ase_size_t len) +{ + kwent_t* kwp; + + for (kwp = kwtab; kwp->name != ASE_NULL; kwp++) + { + if (kwp->valid != 0 && + (awk->option & kwp->valid) == 0) continue; + + if (ase_strxncmp (kwp->name, kwp->name_len, name, len) == 0) + { + return kwp->type; + } + } + + return TOKEN_IDENT; +} + +static int assign_to_opcode (ase_awk_t* awk) +{ + static int assop[] = + { + ASE_AWK_ASSOP_NONE, + ASE_AWK_ASSOP_PLUS, + ASE_AWK_ASSOP_MINUS, + ASE_AWK_ASSOP_MUL, + ASE_AWK_ASSOP_DIV, + ASE_AWK_ASSOP_IDIV, + ASE_AWK_ASSOP_MOD, + ASE_AWK_ASSOP_EXP + }; + + if (awk->token.type >= TOKEN_ASSIGN && + awk->token.type <= TOKEN_EXP_ASSIGN) + { + return assop[awk->token.type - TOKEN_ASSIGN]; + } + + return -1; +} + +static int is_plain_var (ase_awk_nde_t* nde) +{ + return nde->type == ASE_AWK_NDE_GLOBAL || + nde->type == ASE_AWK_NDE_LOCAL || + nde->type == ASE_AWK_NDE_ARG || + nde->type == ASE_AWK_NDE_NAMED; +} + +static int is_var (ase_awk_nde_t* nde) +{ + return nde->type == ASE_AWK_NDE_GLOBAL || + nde->type == ASE_AWK_NDE_LOCAL || + nde->type == ASE_AWK_NDE_ARG || + nde->type == ASE_AWK_NDE_NAMED || + nde->type == ASE_AWK_NDE_GLOBALIDX || + nde->type == ASE_AWK_NDE_LOCALIDX || + nde->type == ASE_AWK_NDE_ARGIDX || + nde->type == ASE_AWK_NDE_NAMEDIDX; +} + +struct deparse_func_t +{ + ase_awk_t* awk; + ase_char_t* tmp; + ase_size_t tmp_len; +}; + +static int deparse (ase_awk_t* awk) +{ + ase_awk_chain_t* chain; + ase_char_t tmp[ASE_SIZEOF(ase_size_t)*8 + 32]; + struct deparse_func_t df; + int n = 0, op; + + ASE_ASSERT (awk->src.ios.out != ASE_NULL); + + awk->src.shared.buf_len = 0; + awk->src.shared.buf_pos = 0; + + CLRERR (awk); + op = awk->src.ios.out ( + ASE_AWK_IO_OPEN, awk->src.ios.custom_data, ASE_NULL, 0); + if (op <= -1) + { + if (ISNOERR(awk)) SETERR (awk, ASE_AWK_ESOUTOP); + return -1; + } + + if (op == 0) + { + /* the result of the open operation indicates that the + * file has been open but reached the end. so it has to + * skip the entire deparsing procedure as it can't write + * any single characters on such an io handler. but note + * that this is not really an error for the parse and deparser. + * + * in fact, there are two ways to skip deparsing. + * 1. set awk->src.ios.out to NULL. + * 2. set awk->src.ios.out to a normal handler but + * make it return 0 on the OPEN request. + */ + n = 0; + goto exit_deparse; + } + +#define EXIT_DEPARSE() do { n = -1; goto exit_deparse; } while(0) + + if (awk->tree.nglobals > awk->tree.nbglobals) + { + ase_size_t i/*, len*/; + + ASE_ASSERT (awk->tree.nglobals > 0); + if (ase_awk_putsrcstr (awk, ASE_T("global ")) == -1) + { + EXIT_DEPARSE (); + } + + for (i = awk->tree.nbglobals; i < awk->tree.nglobals - 1; i++) + { + /* + len = ase_awk_longtostr ((ase_long_t)i, + 10, ASE_T("__global"), tmp, ASE_COUNTOF(tmp)); + ASE_ASSERT (len != (ase_size_t)-1); + if (ase_awk_putsrcstrx (awk, tmp, len) == -1) + { + EXIT_DEPARSE (); + } + */ + if (ase_awk_putsrcstrx (awk, + awk->parse.globals.buf[i].name, + awk->parse.globals.buf[i].name_len) == -1) + { + EXIT_DEPARSE (); + } + + if (ase_awk_putsrcstr (awk, ASE_T(", ")) == -1) + EXIT_DEPARSE (); + } + + /* + len = ase_awk_longtostr ((ase_long_t)i, + 10, ASE_T("__global"), tmp, ASE_COUNTOF(tmp)); + ASE_ASSERT (len != (ase_size_t)-1); + if (ase_awk_putsrcstrx (awk, tmp, len) == -1) + { + EXIT_DEPARSE (); + } + */ + if (ase_awk_putsrcstrx (awk, + awk->parse.globals.buf[i].name, + awk->parse.globals.buf[i].name_len) == -1) + { + EXIT_DEPARSE (); + } + + if (awk->option & ASE_AWK_CRLF) + { + if (ase_awk_putsrcstr (awk, ASE_T(";\r\n\r\n")) == -1) + { + EXIT_DEPARSE (); + } + } + else + { + if (ase_awk_putsrcstr (awk, ASE_T(";\n\n")) == -1) + { + EXIT_DEPARSE (); + } + } + } + + df.awk = awk; + df.tmp = tmp; + df.tmp_len = ASE_COUNTOF(tmp); + + if (ase_awk_map_walk (&awk->tree.afns, deparse_func, &df) == -1) + { + EXIT_DEPARSE (); + } + + if (awk->tree.begin != ASE_NULL) + { + if (ase_awk_putsrcstr (awk, ASE_T("BEGIN ")) == -1) + { + EXIT_DEPARSE (); + } + + if (ase_awk_prnpt (awk, awk->tree.begin) == -1) EXIT_DEPARSE (); + + if (awk->option & ASE_AWK_CRLF) + { + if (put_char (awk, ASE_T('\r')) == -1) + EXIT_DEPARSE (); + } + + if (put_char (awk, ASE_T('\n')) == -1) EXIT_DEPARSE (); + } + + chain = awk->tree.chain; + while (chain != ASE_NULL) + { + if (chain->pattern != ASE_NULL) + { + if (ase_awk_prnptnpt (awk, chain->pattern) == -1) + EXIT_DEPARSE (); + } + + if (chain->action == ASE_NULL) + { + /* blockless pattern */ + if (awk->option & ASE_AWK_CRLF) + { + if (put_char (awk, ASE_T('\r')) == -1) + EXIT_DEPARSE (); + } + + if (put_char (awk, ASE_T('\n')) == -1) + EXIT_DEPARSE (); + } + else + { + if (chain->pattern != ASE_NULL) + { + if (put_char (awk, ASE_T(' ')) == -1) + EXIT_DEPARSE (); + } + if (ase_awk_prnpt (awk, chain->action) == -1) + EXIT_DEPARSE (); + } + + if (awk->option & ASE_AWK_CRLF) + { + if (put_char (awk, ASE_T('\r')) == -1) + EXIT_DEPARSE (); + } + + if (put_char (awk, ASE_T('\n')) == -1) + EXIT_DEPARSE (); + + chain = chain->next; + } + + if (awk->tree.end != ASE_NULL) + { + if (ase_awk_putsrcstr (awk, ASE_T("END ")) == -1) + EXIT_DEPARSE (); + if (ase_awk_prnpt (awk, awk->tree.end) == -1) + EXIT_DEPARSE (); + } + + if (flush_out (awk) == -1) EXIT_DEPARSE (); + +exit_deparse: + if (n == 0) CLRERR (awk); + if (awk->src.ios.out ( + ASE_AWK_IO_CLOSE, awk->src.ios.custom_data, ASE_NULL, 0) != 0) + { + if (n == 0) + { + if (ISNOERR(awk)) SETERR (awk, ASE_AWK_ESOUTCL); + n = -1; + } + } + + return n; +} + +static int deparse_func (ase_awk_pair_t* pair, void* arg) +{ + struct deparse_func_t* df = (struct deparse_func_t*)arg; + ase_awk_afn_t* afn = (ase_awk_afn_t*)pair->val; + ase_size_t i, n; + + ASE_ASSERT (ase_strxncmp (PAIR_KEYPTR(pair), PAIR_KEYLEN(pair), afn->name, afn->name_len) == 0); + + if (ase_awk_putsrcstr (df->awk, ASE_T("function ")) == -1) return -1; + if (ase_awk_putsrcstr (df->awk, afn->name) == -1) return -1; + if (ase_awk_putsrcstr (df->awk, ASE_T(" (")) == -1) return -1; + + for (i = 0; i < afn->nargs; ) + { + n = ase_awk_longtostr (i++, 10, + ASE_T("__param"), df->tmp, df->tmp_len); + ASE_ASSERT (n != (ase_size_t)-1); + if (ase_awk_putsrcstrx (df->awk, df->tmp, n) == -1) return -1; + if (i >= afn->nargs) break; + if (ase_awk_putsrcstr (df->awk, ASE_T(", ")) == -1) return -1; + } + + if (ase_awk_putsrcstr (df->awk, ASE_T(")")) == -1) return -1; + if (df->awk->option & ASE_AWK_CRLF) + { + if (put_char (df->awk, ASE_T('\r')) == -1) return -1; + } + if (put_char (df->awk, ASE_T('\n')) == -1) return -1; + + if (ase_awk_prnpt (df->awk, afn->body) == -1) return -1; + if (df->awk->option & ASE_AWK_CRLF) + { + if (put_char (df->awk, ASE_T('\r')) == -1) return -1; + } + if (put_char (df->awk, ASE_T('\n')) == -1) return -1; + + return 0; +} + +static int put_char (ase_awk_t* awk, ase_char_t c) +{ + awk->src.shared.buf[awk->src.shared.buf_len++] = c; + if (awk->src.shared.buf_len >= ASE_COUNTOF(awk->src.shared.buf)) + { + if (flush_out (awk) == -1) return -1; + } + return 0; +} + +static int flush_out (ase_awk_t* awk) +{ + ase_ssize_t n; + + ASE_ASSERT (awk->src.ios.out != ASE_NULL); + + while (awk->src.shared.buf_pos < awk->src.shared.buf_len) + { + CLRERR (awk); + + n = awk->src.ios.out ( + ASE_AWK_IO_WRITE, awk->src.ios.custom_data, + &awk->src.shared.buf[awk->src.shared.buf_pos], + awk->src.shared.buf_len - awk->src.shared.buf_pos); + if (n <= 0) + { + if (ISNOERR(awk)) SETERR (awk, ASE_AWK_ESOUTWR); + return -1; + } + + awk->src.shared.buf_pos += n; + } + + awk->src.shared.buf_pos = 0; + awk->src.shared.buf_len = 0; + return 0; +} + +int ase_awk_putsrcstr (ase_awk_t* awk, const ase_char_t* str) +{ + while (*str != ASE_T('\0')) + { + if (put_char (awk, *str) == -1) return -1; + str++; + } + + return 0; +} + +int ase_awk_putsrcstrx ( + ase_awk_t* awk, const ase_char_t* str, ase_size_t len) +{ + const ase_char_t* end = str + len; + + while (str < end) + { + if (put_char (awk, *str) == -1) return -1; + str++; + } + + return 0; +} + diff --git a/ase/awk/parse.h b/ase/awk/parse.h new file mode 100644 index 00000000..c668ad21 --- /dev/null +++ b/ase/awk/parse.h @@ -0,0 +1,29 @@ +/* + * $Id: parse.h,v 1.3 2007/04/30 05:47:33 bacon Exp $ + * + * {License} + */ + +#ifndef _ASE_AWK_PARSE_H_ +#define _ASE_AWK_PARSE_H_ + +#ifndef _ASE_AWK_AWK_H_ +#error Never include this file directly. Include instead +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +int ase_awk_putsrcstr (ase_awk_t* awk, const ase_char_t* str); +int ase_awk_putsrcstrx ( + ase_awk_t* awk, const ase_char_t* str, ase_size_t len); + +const ase_char_t* ase_awk_getglobalname ( + ase_awk_t* awk, ase_size_t idx, ase_size_t* len); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ase/awk/rec.c b/ase/awk/rec.c new file mode 100644 index 00000000..739f20cb --- /dev/null +++ b/ase/awk/rec.c @@ -0,0 +1,449 @@ +/* + * $Id: rec.c,v 1.3 2007/04/30 05:47:33 bacon Exp $ + * + * {License} + */ + +#include + +static int __split_record (ase_awk_run_t* run); +static int __recomp_record_fields ( + ase_awk_run_t* run, ase_size_t lv, + const ase_char_t* str, ase_size_t len); + +int ase_awk_setrec ( + ase_awk_run_t* run, ase_size_t idx, + const ase_char_t* str, ase_size_t len) +{ + ase_awk_val_t* v; + + if (idx == 0) + { + if (str == ASE_STR_BUF(&run->inrec.line) && + len == ASE_STR_LEN(&run->inrec.line)) + { + if (ase_awk_clrrec (run, ase_true) == -1) return -1; + } + else + { + if (ase_awk_clrrec (run, ase_false) == -1) return -1; + + if (ase_str_ncpy (&run->inrec.line, str, len) == (ase_size_t)-1) + { + ase_awk_clrrec (run, ase_false); + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return -1; + } + } + + v = ase_awk_makestrval (run, str, len); + if (v == ASE_NULL) + { + ase_awk_clrrec (run, ase_false); + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return -1; + } + + ASE_ASSERT (run->inrec.d0->type == ASE_AWK_VAL_NIL); + /* d0 should be cleared before the next line is reached + * as it doesn't call ase_awk_refdownval on run->inrec.d0 */ + run->inrec.d0 = v; + ase_awk_refupval (run, v); + + if (__split_record (run) == -1) + { + ase_awk_clrrec (run, ase_false); + return -1; + } + } + else + { + if (__recomp_record_fields (run, idx, str, len) == -1) + { + ase_awk_clrrec (run, ase_false); + return -1; + } + + /* recompose $0 */ + v = ase_awk_makestrval (run, + ASE_STR_BUF(&run->inrec.line), + ASE_STR_LEN(&run->inrec.line)); + if (v == ASE_NULL) + { + ase_awk_clrrec (run, ase_false); + ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return -1; + } + + ase_awk_refdownval (run, run->inrec.d0); + run->inrec.d0 = v; + ase_awk_refupval (run, v); + } + + return 0; +} + +static int __split_record (ase_awk_run_t* run) +{ + ase_char_t* p, * tok; + ase_size_t len, tok_len, nflds; + ase_awk_val_t* v, * fs; + ase_char_t* fs_ptr, * fs_free; + ase_size_t fs_len; + int errnum; + + /* inrec should be cleared before __split_record is called */ + ASE_ASSERT (run->inrec.nflds == 0); + + /* get FS */ + fs = ase_awk_getglobal (run, ASE_AWK_GLOBAL_FS); + if (fs->type == ASE_AWK_VAL_NIL) + { + fs_ptr = ASE_T(" "); + fs_len = 1; + fs_free = ASE_NULL; + } + else if (fs->type == ASE_AWK_VAL_STR) + { + fs_ptr = ((ase_awk_val_str_t*)fs)->buf; + fs_len = ((ase_awk_val_str_t*)fs)->len; + fs_free = ASE_NULL; + } + else + { + fs_ptr = ase_awk_valtostr ( + run, fs, ASE_AWK_VALTOSTR_CLEAR, ASE_NULL, &fs_len); + if (fs_ptr == ASE_NULL) return -1; + fs_free = fs_ptr; + } + + /* scan the input record to count the fields */ + p = ASE_STR_BUF(&run->inrec.line); + len = ASE_STR_LEN(&run->inrec.line); + + nflds = 0; + while (p != ASE_NULL) + { + if (fs_len <= 1) + { + p = ase_awk_strxntok (run, + p, len, fs_ptr, fs_len, &tok, &tok_len); + } + else + { + p = ase_awk_strxntokbyrex (run, p, len, + run->global.fs, &tok, &tok_len, &errnum); + if (p == ASE_NULL && errnum != ASE_AWK_ENOERR) + { + if (fs_free != ASE_NULL) + ASE_AWK_FREE (run->awk, fs_free); + ase_awk_setrunerror (run, errnum, 0, ASE_NULL, 0); + return -1; + } + } + + if (nflds == 0 && p == ASE_NULL && tok_len == 0) + { + /* there are no fields. it can just return here + * as ase_awk_clrrec has been called before this */ + if (fs_free != ASE_NULL) ASE_AWK_FREE (run->awk, fs_free); + return 0; + } + + ASE_ASSERT ((tok != ASE_NULL && tok_len > 0) || tok_len == 0); + + nflds++; + len = ASE_STR_LEN(&run->inrec.line) - + (p - ASE_STR_BUF(&run->inrec.line)); + } + + /* allocate space */ + if (nflds > run->inrec.maxflds) + { + void* tmp = ASE_AWK_MALLOC ( + run->awk, ASE_SIZEOF(*run->inrec.flds) * nflds); + if (tmp == ASE_NULL) + { + if (fs_free != ASE_NULL) ASE_AWK_FREE (run->awk, fs_free); + ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return -1; + } + + if (run->inrec.flds != ASE_NULL) + ASE_AWK_FREE (run->awk, run->inrec.flds); + run->inrec.flds = tmp; + run->inrec.maxflds = nflds; + } + + /* scan again and split it */ + p = ASE_STR_BUF(&run->inrec.line); + len = ASE_STR_LEN(&run->inrec.line); + + while (p != ASE_NULL) + { + if (fs_len <= 1) + { + p = ase_awk_strxntok ( + run, p, len, fs_ptr, fs_len, &tok, &tok_len); + } + else + { + p = ase_awk_strxntokbyrex (run, p, len, + run->global.fs, &tok, &tok_len, &errnum); + if (p == ASE_NULL && errnum != ASE_AWK_ENOERR) + { + if (fs_free != ASE_NULL) + ASE_AWK_FREE (run->awk, fs_free); + ase_awk_setrunerror (run, errnum, 0, ASE_NULL, 0); + return -1; + } + } + + ASE_ASSERT ((tok != ASE_NULL && tok_len > 0) || tok_len == 0); + + run->inrec.flds[run->inrec.nflds].ptr = tok; + run->inrec.flds[run->inrec.nflds].len = tok_len; + run->inrec.flds[run->inrec.nflds].val = + ase_awk_makestrval (run, tok, tok_len); + + if (run->inrec.flds[run->inrec.nflds].val == ASE_NULL) + { + if (fs_free != ASE_NULL) ASE_AWK_FREE (run->awk, fs_free); + ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return -1; + } + + ase_awk_refupval (run, run->inrec.flds[run->inrec.nflds].val); + run->inrec.nflds++; + + len = ASE_STR_LEN(&run->inrec.line) - + (p - ASE_STR_BUF(&run->inrec.line)); + } + + if (fs_free != ASE_NULL) ASE_AWK_FREE (run->awk, fs_free); + + /* set the number of fields */ + v = ase_awk_makeintval (run, (ase_long_t)nflds); + if (v == ASE_NULL) + { + ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return -1; + } + + if (ase_awk_setglobal (run, ASE_AWK_GLOBAL_NF, v) == -1) return -1; + + ASE_ASSERT (nflds == run->inrec.nflds); + return 0; +} + +int ase_awk_clrrec (ase_awk_run_t* run, ase_bool_t skip_inrec_line) +{ + ase_size_t i; + int n = 0; + + if (run->inrec.d0 != ase_awk_val_nil) + { + ase_awk_refdownval (run, run->inrec.d0); + run->inrec.d0 = ase_awk_val_nil; + } + + if (run->inrec.nflds > 0) + { + ASE_ASSERT (run->inrec.flds != ASE_NULL); + + for (i = 0; i < run->inrec.nflds; i++) + { + ASE_ASSERT (run->inrec.flds[i].val != ASE_NULL); + ase_awk_refdownval (run, run->inrec.flds[i].val); + } + run->inrec.nflds = 0; + + if (ase_awk_setglobal ( + run, ASE_AWK_GLOBAL_NF, ase_awk_val_zero) == -1) + { + /* first of all, this should never happen. + * if it happened, it would return an error + * after all the clearance tasks */ + n = -1; + } + } + + ASE_ASSERT (run->inrec.nflds == 0); + if (!skip_inrec_line) ase_str_clear (&run->inrec.line); + + return n; +} + +static int __recomp_record_fields ( + ase_awk_run_t* run, ase_size_t lv, + const ase_char_t* str, ase_size_t len) +{ + ase_awk_val_t* v; + ase_size_t max, i, nflds; + + /* recomposes the record and the fields when $N has been assigned + * a new value and recomputes NF accordingly */ + + ASE_ASSERT (lv > 0); + max = (lv > run->inrec.nflds)? lv: run->inrec.nflds; + + nflds = run->inrec.nflds; + if (max > run->inrec.maxflds) + { + void* tmp; + + /* if the given field number is greater than the maximum + * number of fields that the current record can hold, + * the field spaces are resized */ + + if (run->awk->prmfns.mmgr.realloc != ASE_NULL) + { + tmp = ASE_AWK_REALLOC ( + run->awk, run->inrec.flds, + ASE_SIZEOF(*run->inrec.flds) * max); + if (tmp == ASE_NULL) + { + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return -1; + } + } + else + { + tmp = ASE_AWK_MALLOC ( + run->awk, ASE_SIZEOF(*run->inrec.flds) * max); + if (tmp == ASE_NULL) + { + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return -1; + } + if (run->inrec.flds != ASE_NULL) + { + ase_memcpy (tmp, run->inrec.flds, + ASE_SIZEOF(*run->inrec.flds)*run->inrec.maxflds); + ASE_AWK_FREE (run->awk, run->inrec.flds); + } + } + + run->inrec.flds = tmp; + run->inrec.maxflds = max; + } + + lv = lv - 1; /* adjust the value to 0-based index */ + + ase_str_clear (&run->inrec.line); + + for (i = 0; i < max; i++) + { + if (i > 0) + { + if (ase_str_ncat ( + &run->inrec.line, + run->global.ofs.ptr, + run->global.ofs.len) == (ase_size_t)-1) + { + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return -1; + } + } + + if (i == lv) + { + ase_awk_val_t* tmp; + + run->inrec.flds[i].ptr = + ASE_STR_BUF(&run->inrec.line) + + ASE_STR_LEN(&run->inrec.line); + run->inrec.flds[i].len = len; + + if (ase_str_ncat ( + &run->inrec.line, str, len) == (ase_size_t)-1) + { + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return -1; + } + + tmp = ase_awk_makestrval (run, str,len); + if (tmp == ASE_NULL) + { + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return -1; + } + + if (i < nflds) + ase_awk_refdownval (run, run->inrec.flds[i].val); + else run->inrec.nflds++; + + run->inrec.flds[i].val = tmp; + ase_awk_refupval (run, tmp); + } + else if (i >= nflds) + { + run->inrec.flds[i].ptr = + ASE_STR_BUF(&run->inrec.line) + + ASE_STR_LEN(&run->inrec.line); + run->inrec.flds[i].len = 0; + + if (ase_str_cat ( + &run->inrec.line, ASE_T("")) == (ase_size_t)-1) + { + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return -1; + } + + /* ase_awk_refdownval should not be called over + * run->inrec.flds[i].val as it is not initialized + * to any valid values */ + /*ase_awk_refdownval (run, run->inrec.flds[i].val);*/ + run->inrec.flds[i].val = ase_awk_val_zls; + ase_awk_refupval (run, ase_awk_val_zls); + run->inrec.nflds++; + } + else + { + ase_awk_val_str_t* tmp; + + tmp = (ase_awk_val_str_t*)run->inrec.flds[i].val; + + run->inrec.flds[i].ptr = + ASE_STR_BUF(&run->inrec.line) + + ASE_STR_LEN(&run->inrec.line); + run->inrec.flds[i].len = tmp->len; + + if (ase_str_ncat (&run->inrec.line, + tmp->buf, tmp->len) == (ase_size_t)-1) + { + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return -1; + } + } + } + + v = ase_awk_getglobal (run, ASE_AWK_GLOBAL_NF); + ASE_ASSERT (v->type == ASE_AWK_VAL_INT); + + if (((ase_awk_val_int_t*)v)->val != max) + { + v = ase_awk_makeintval (run, (ase_long_t)max); + if (v == ASE_NULL) + { + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return -1; + } + + if (ase_awk_setglobal ( + run, ASE_AWK_GLOBAL_NF, v) == -1) return -1; + } + + return 0; +} + diff --git a/ase/awk/rex.c b/ase/awk/rex.c new file mode 100644 index 00000000..463829d2 --- /dev/null +++ b/ase/awk/rex.c @@ -0,0 +1,1880 @@ +/* + * $Id: rex.c,v 1.3 2007/04/30 05:47:33 bacon Exp $ + * + * {License} + */ + +#include + +#ifdef DEBUG_REX +#include +#endif + +enum +{ + CT_EOF, + CT_SPECIAL, + CT_NORMAL +}; + +enum +{ + LEVEL_TOP, + LEVEL_CHARSET, + LEVEL_RANGE +}; + +enum +{ + CMD_BOL, + CMD_EOL, + CMD_ANY_CHAR, + CMD_ORD_CHAR, + CMD_CHARSET, + CMD_GROUP +}; + +enum +{ + CHARSET_ONE, + CHARSET_RANGE, + CHARSET_CLASS +}; + +enum +{ + CHARSET_CLASS_PUNCT, + CHARSET_CLASS_SPACE, + CHARSET_CLASS_DIGIT, + CHARSET_CLASS_ALNUM +}; + +#define DEF_CODE_CAPA 512 +#define BOUND_MIN 0 +#define BOUND_MAX (ASE_TYPE_MAX(ase_size_t)) + +typedef struct builder_t builder_t; +typedef struct matcher_t matcher_t; +typedef struct match_t match_t; + +typedef struct code_t code_t; +typedef struct rhdr_t rhdr_t; +typedef struct bhdr_t bhdr_t; +typedef struct cshdr_t cshdr_t; + +struct builder_t +{ + ase_awk_t* awk; + + struct + { + const ase_char_t* ptr; + const ase_char_t* end; + const ase_char_t* curp; + struct + { + int type; + ase_char_t value; + } curc; + } ptn; + + struct + { + ase_byte_t* buf; + ase_size_t size; + ase_size_t capa; + } code; + + struct + { + int max; + int cur; + } depth; + + int errnum; +}; + +struct matcher_t +{ + ase_awk_t* awk; + + struct + { + struct + { + const ase_char_t* ptr; + const ase_char_t* end; + } str; + } match; + + struct + { + int max; + int cur; + } depth; + + int ignorecase; + int errnum; +}; + +struct match_t +{ + const ase_char_t* match_ptr; + + ase_bool_t matched; + ase_size_t match_len; + + const ase_byte_t* branch; + const ase_byte_t* branch_end; +}; + +#include + +ASE_BEGIN_PACKED_STRUCT (code_t) + /*ase_byte_t cmd;*/ + short cmd; + short negate; /* only for CMD_CHARSET */ + ase_size_t lbound; + ase_size_t ubound; +ASE_END_PACKED_STRUCT () + +/* compiled regular expression header */ +ASE_BEGIN_PACKED_STRUCT (rhdr_t) + ase_size_t nb; /* number of branches */ + ase_size_t el; /* expression length in bytes */ +ASE_END_PACKED_STRUCT () + +/* branch header */ +ASE_BEGIN_PACKED_STRUCT (bhdr_t) + ase_size_t na; /* number of atoms */ + ase_size_t bl; /* branch length in bytes */ +ASE_END_PACKED_STRUCT () + +/* character set header */ +ASE_BEGIN_PACKED_STRUCT (cshdr_t) + ase_size_t csc; /* count */ + ase_size_t csl; /* length */ +ASE_END_PACKED_STRUCT () + +#include + +typedef const ase_byte_t* (*atom_matcher_t) ( + matcher_t* matcher, const ase_byte_t* base, match_t* mat); + +#define NCHARS_REMAINING(rex) ((rex)->ptn.end - (rex)->ptn.curp) + +#define NEXT_CHAR(rex,level) \ + do { if (__next_char(rex,level) == -1) return -1; } while (0) + +#define ADD_CODE(rex,data,len) \ + do { if (__add_code(rex,data,len) == -1) return -1; } while (0) + +static int __build_pattern (builder_t* rex); +static int __build_pattern0 (builder_t* rex); +static int __build_branch (builder_t* rex); +static int __build_atom (builder_t* rex); +static int __build_charset (builder_t* rex, code_t* cmd); +static int __build_occurrences (builder_t* rex, code_t* cmd); +static int __build_cclass (builder_t* rex, ase_char_t* cc); +static int __build_range (builder_t* rex, code_t* cmd); +static int __next_char (builder_t* rex, int level); +static int __add_code (builder_t* rex, void* data, ase_size_t len); + +static ase_bool_t __begin_with ( + const ase_char_t* str, ase_size_t len, const ase_char_t* what); + +static const ase_byte_t* __match_pattern ( + matcher_t* matcher, const ase_byte_t* base, match_t* mat); +static const ase_byte_t* __match_branch ( + matcher_t* matcher, const ase_byte_t* base, match_t* mat); +static const ase_byte_t* __match_branch_body ( + matcher_t* matcher, const ase_byte_t* base, match_t* mat); +static const ase_byte_t* __match_branch_body0 ( + matcher_t* matcher, const ase_byte_t* base, match_t* mat); +static const ase_byte_t* __match_atom ( + matcher_t* matcher, const ase_byte_t* base, match_t* mat); +static const ase_byte_t* __match_bol ( + matcher_t* matcher, const ase_byte_t* base, match_t* mat); +static const ase_byte_t* __match_eol ( + matcher_t* matcher, const ase_byte_t* base, match_t* mat); +static const ase_byte_t* __match_any_char ( + matcher_t* matcher, const ase_byte_t* base, match_t* mat); +static const ase_byte_t* __match_ord_char ( + matcher_t* matcher, const ase_byte_t* base, match_t* mat); +static const ase_byte_t* __match_charset ( + matcher_t* matcher, const ase_byte_t* base, match_t* mat); +static const ase_byte_t* __match_group ( + matcher_t* matcher, const ase_byte_t* base, match_t* mat); + +static const ase_byte_t* __match_occurrences ( + matcher_t* matcher, ase_size_t si, const ase_byte_t* p, + ase_size_t lbound, ase_size_t ubound, match_t* mat); + +static ase_bool_t __test_charset ( + matcher_t* matcher, const ase_byte_t* p, ase_size_t csc, ase_char_t c); + +static ase_bool_t cc_isalnum (ase_awk_t* awk, ase_char_t c); +static ase_bool_t cc_isalpha (ase_awk_t* awk, ase_char_t c); +static ase_bool_t cc_isblank (ase_awk_t* awk, ase_char_t c); +static ase_bool_t cc_iscntrl (ase_awk_t* awk, ase_char_t c); +static ase_bool_t cc_isdigit (ase_awk_t* awk, ase_char_t c); +static ase_bool_t cc_isgraph (ase_awk_t* awk, ase_char_t c); +static ase_bool_t cc_islower (ase_awk_t* awk, ase_char_t c); +static ase_bool_t cc_isprint (ase_awk_t* awk, ase_char_t c); +static ase_bool_t cc_ispunct (ase_awk_t* awk, ase_char_t c); +static ase_bool_t cc_isspace (ase_awk_t* awk, ase_char_t c); +static ase_bool_t cc_isupper (ase_awk_t* awk, ase_char_t c); +static ase_bool_t cc_isxdigit (ase_awk_t* awk, ase_char_t c); + +static const ase_byte_t* __print_pattern (ase_awk_t* awk, const ase_byte_t* p); +static const ase_byte_t* __print_branch (ase_awk_t* awk, const ase_byte_t* p); +static const ase_byte_t* __print_atom (ase_awk_t* awk, const ase_byte_t* p); + +struct __char_class_t +{ + const ase_char_t* name; + ase_size_t name_len; + ase_bool_t (*func) (ase_awk_t* awk, ase_char_t c); +}; + +static struct __char_class_t __char_class[] = +{ + { ASE_T("alnum"), 5, cc_isalnum }, + { ASE_T("alpha"), 5, cc_isalpha }, + { ASE_T("blank"), 5, cc_isblank }, + { ASE_T("cntrl"), 5, cc_iscntrl }, + { ASE_T("digit"), 5, cc_isdigit }, + { ASE_T("graph"), 5, cc_isgraph }, + { ASE_T("lower"), 5, cc_islower }, + { ASE_T("print"), 5, cc_isprint }, + { ASE_T("punct"), 5, cc_ispunct }, + { ASE_T("space"), 5, cc_isspace }, + { ASE_T("upper"), 5, cc_isupper }, + { ASE_T("xdigit"), 6, cc_isxdigit }, + + /* + { ASE_T("arabic"), 6, cc_isarabic }, + { ASE_T("chinese"), 7, cc_ischinese }, + { ASE_T("english"), 7, cc_isenglish }, + { ASE_T("japanese"), 8, cc_isjapanese }, + { ASE_T("korean"), 6, cc_iskorean }, + { ASE_T("thai"), 4, cc_isthai }, + */ + + { ASE_NULL, 0, ASE_NULL } +}; + +void* ase_awk_buildrex ( + ase_awk_t* awk, const ase_char_t* ptn, ase_size_t len, int* errnum) +{ + builder_t builder; + + builder.awk = awk; + builder.code.capa = DEF_CODE_CAPA; + builder.code.size = 0; + builder.code.buf = (ase_byte_t*) + ASE_AWK_MALLOC (builder.awk, builder.code.capa); + if (builder.code.buf == ASE_NULL) + { + *errnum = ASE_AWK_ENOMEM; + return ASE_NULL; + } + + builder.ptn.ptr = ptn; + builder.ptn.end = builder.ptn.ptr + len; + builder.ptn.curp = builder.ptn.ptr; + + builder.ptn.curc.type = CT_EOF; + builder.ptn.curc.value = ASE_T('\0'); + + builder.depth.max = awk->rex.depth.max.build; + builder.depth.cur = 0; + + if (__next_char (&builder, LEVEL_TOP) == -1) + { + if (errnum != ASE_NULL) *errnum = builder.errnum; + ASE_AWK_FREE (builder.awk, builder.code.buf); + return ASE_NULL; + } + + if (__build_pattern (&builder) == -1) + { + if (errnum != ASE_NULL) *errnum = builder.errnum; + ASE_AWK_FREE (builder.awk, builder.code.buf); + return ASE_NULL; + } + + if (builder.ptn.curc.type != CT_EOF) + { + if (errnum != ASE_NULL) + { + if (builder.ptn.curc.type == CT_SPECIAL && + builder.ptn.curc.value == ASE_T(')')) + { + *errnum = ASE_AWK_EREXUNBALPAR; + } + else + { + *errnum = ASE_AWK_EREXGARBAGE; + } + } + + ASE_AWK_FREE (builder.awk, builder.code.buf); + return ASE_NULL; + } + + return builder.code.buf; +} + +int ase_awk_matchrex ( + ase_awk_t* awk, void* code, int option, + const ase_char_t* str, ase_size_t len, + const ase_char_t** match_ptr, ase_size_t* match_len, int* errnum) +{ + matcher_t matcher; + match_t mat; + ase_size_t offset = 0; + /*const ase_char_t* match_ptr_zero = ASE_NULL;*/ + + matcher.awk = awk; + + /* store the source string */ + matcher.match.str.ptr = str; + matcher.match.str.end = str + len; + + matcher.depth.max = awk->rex.depth.max.match; + matcher.depth.cur = 0; + matcher.ignorecase = (option & ASE_AWK_REX_IGNORECASE)? 1: 0; + + mat.matched = ase_false; + /* TODO: should it allow an offset here??? */ + mat.match_ptr = str + offset; + + /*while (mat.match_ptr < matcher.match.str.end)*/ + while (mat.match_ptr <= matcher.match.str.end) + { + if (__match_pattern (&matcher, code, &mat) == ASE_NULL) + { + if (errnum != ASE_NULL) *errnum = matcher.errnum; + return -1; + } + + if (mat.matched) + { + /* + if (mat.match_len == 0) + { + if (match_ptr_zero == ASE_NULL) + match_ptr_zero = mat.match_ptr; + mat.match_ptr++; + continue; + } + */ + + if (match_ptr != ASE_NULL) *match_ptr = mat.match_ptr; + if (match_len != ASE_NULL) *match_len = mat.match_len; + + /*match_ptr_zero = ASE_NULL;*/ + break; + } + + mat.match_ptr++; + } + + /* + if (match_ptr_zero != ASE_NULL) + { + if (match_ptr != ASE_NULL) *match_ptr = match_ptr_zero; + if (match_len != ASE_NULL) *match_len = 0; + return 1; + } + */ + + return (mat.matched)? 1: 0; +} + +void ase_awk_freerex (ase_awk_t* awk, void* code) +{ + ASE_ASSERT (code != ASE_NULL); + ASE_AWK_FREE (awk, code); +} + +ase_bool_t ase_awk_isemptyrex (ase_awk_t* awk, void* code) +{ + rhdr_t* rhdr = (rhdr_t*) code; + ASE_ASSERT (rhdr != ASE_NULL); + + /* an empty regular expression look like: + * | expression | + * | header | branch | + * | | branch header | + * | NB(1) | EL(16) | NA(1) | BL(8) | */ + return (rhdr->nb == 1 && + rhdr->el == ASE_SIZEOF(ase_size_t)*4)? ase_true: ase_false; +} + +static int __build_pattern (builder_t* builder) +{ + int n; + + if (builder->depth.max > 0 && builder->depth.cur >= builder->depth.max) + { + builder->errnum = ASE_AWK_EREXRECUR; + return -1; + } + + builder->depth.cur++; + n = __build_pattern0 (builder); + builder->depth.cur--; + + return n; +} + +static int __build_pattern0 (builder_t* builder) +{ + ase_size_t zero = 0; + ase_size_t old_size; + ase_size_t pos_nb; + rhdr_t* rhdr; + int n; + + old_size = builder->code.size; + + /* secure space for header and set the header fields to zero */ + pos_nb = builder->code.size; + ADD_CODE (builder, &zero, ASE_SIZEOF(zero)); + ADD_CODE (builder, &zero, ASE_SIZEOF(zero)); + + /* handle the first branch */ + n = __build_branch (builder); + if (n == -1) return -1; + if (n == 0) + { + /* if the pattern is empty, the control reaches here */ + return 0; + } + + rhdr = (rhdr_t*)&builder->code.buf[pos_nb]; + rhdr->nb++; + + /* handle subsequent branches if any */ + while (builder->ptn.curc.type == CT_SPECIAL && + builder->ptn.curc.value == ASE_T('|')) + { + NEXT_CHAR (builder, LEVEL_TOP); + + n = __build_branch(builder); + if (n == -1) return -1; + if (n == 0) + { + /* if the pattern ends with a vertical bar(|), + * this block can be reached. however, such a + * pattern is highly discouraged */ + break; + } + + rhdr = (rhdr_t*)&builder->code.buf[pos_nb]; + rhdr->nb++; + } + + rhdr = (rhdr_t*)&builder->code.buf[pos_nb]; + rhdr->el = builder->code.size - old_size; + + return 1; +} + +static int __build_branch (builder_t* builder) +{ + int n; + ase_size_t zero = 0; + ase_size_t old_size; + ase_size_t pos_na; + code_t* cmd; + bhdr_t* bhdr; + + old_size = builder->code.size; + + pos_na = builder->code.size; + ADD_CODE (builder, &zero, ASE_SIZEOF(zero)); + ADD_CODE (builder, &zero, ASE_SIZEOF(zero)); + + while (1) + { + cmd = (code_t*)&builder->code.buf[builder->code.size]; + + n = __build_atom (builder); + if (n == -1) + { + builder->code.size = old_size; + return -1; + } + + if (n == 0) break; /* no atom */ + + n = __build_occurrences (builder, cmd); + if (n == -1) + { + builder->code.size = old_size; + return -1; + } + + /* n == 0 no bound character. just continue */ + /* n == 1 bound has been applied by build_occurrences */ + + bhdr = (bhdr_t*)&builder->code.buf[pos_na]; + bhdr->na++; + } + + bhdr = (bhdr_t*)&builder->code.buf[pos_na]; + bhdr->bl = builder->code.size - old_size; + + return (builder->code.size == old_size)? 0: 1; +} + +static int __build_atom (builder_t* builder) +{ + int n; + code_t tmp; + + if (builder->ptn.curc.type == CT_EOF) return 0; + + if (builder->ptn.curc.type == CT_SPECIAL) + { + if (builder->ptn.curc.value == ASE_T('(')) + { + tmp.cmd = CMD_GROUP; + tmp.negate = 0; + tmp.lbound = 1; + tmp.ubound = 1; + ADD_CODE (builder, &tmp, ASE_SIZEOF(tmp)); + + NEXT_CHAR (builder, LEVEL_TOP); + + n = __build_pattern (builder); + if (n == -1) return -1; + + if (builder->ptn.curc.type != CT_SPECIAL || + builder->ptn.curc.value != ASE_T(')')) + { + builder->errnum = ASE_AWK_EREXRPAREN; + return -1; + } + } + else if (builder->ptn.curc.value == ASE_T('^')) + { + tmp.cmd = CMD_BOL; + tmp.negate = 0; + tmp.lbound = 1; + tmp.ubound = 1; + ADD_CODE (builder, &tmp, ASE_SIZEOF(tmp)); + } + else if (builder->ptn.curc.value == ASE_T('$')) + { + tmp.cmd = CMD_EOL; + tmp.negate = 0; + tmp.lbound = 1; + tmp.ubound = 1; + ADD_CODE (builder, &tmp, ASE_SIZEOF(tmp)); + } + else if (builder->ptn.curc.value == ASE_T('.')) + { + tmp.cmd = CMD_ANY_CHAR; + tmp.negate = 0; + tmp.lbound = 1; + tmp.ubound = 1; + ADD_CODE (builder, &tmp, ASE_SIZEOF(tmp)); + } + else if (builder->ptn.curc.value == ASE_T('[')) + { + code_t* cmd; + + cmd = (code_t*)&builder->code.buf[builder->code.size]; + + tmp.cmd = CMD_CHARSET; + tmp.negate = 0; + tmp.lbound = 1; + tmp.ubound = 1; + ADD_CODE (builder, &tmp, ASE_SIZEOF(tmp)); + + NEXT_CHAR (builder, LEVEL_CHARSET); + + n = __build_charset (builder, cmd); + if (n == -1) return -1; + + ASE_ASSERT (n != 0); + + if (builder->ptn.curc.type != CT_SPECIAL || + builder->ptn.curc.value != ASE_T(']')) + { + builder->errnum = ASE_AWK_EREXRBRACKET; + return -1; + } + + } + else return 0; + + NEXT_CHAR (builder, LEVEL_TOP); + return 1; + } + else + { + ASE_ASSERT (builder->ptn.curc.type == CT_NORMAL); + + tmp.cmd = CMD_ORD_CHAR; + tmp.negate = 0; + tmp.lbound = 1; + tmp.ubound = 1; + ADD_CODE (builder, &tmp, ASE_SIZEOF(tmp)); + + ADD_CODE (builder, + &builder->ptn.curc.value, + ASE_SIZEOF(builder->ptn.curc.value)); + NEXT_CHAR (builder, LEVEL_TOP); + + return 1; + } +} + +static int __build_charset (builder_t* builder, code_t* cmd) +{ + ase_size_t zero = 0; + ase_size_t old_size; + ase_size_t pos_csc; + cshdr_t* cshdr; + + old_size = builder->code.size; + + pos_csc = builder->code.size; + ADD_CODE (builder, &zero, ASE_SIZEOF(zero)); + ADD_CODE (builder, &zero, ASE_SIZEOF(zero)); + + if (builder->ptn.curc.type == CT_NORMAL && + builder->ptn.curc.value == ASE_T('^')) + { + cmd->negate = 1; + NEXT_CHAR (builder, LEVEL_CHARSET); + } + + while (builder->ptn.curc.type == CT_NORMAL) + { + ase_char_t c0, c1, c2; + int cc = 0; + + c1 = builder->ptn.curc.value; + NEXT_CHAR(builder, LEVEL_CHARSET); + + if (c1 == ASE_T('[') && + builder->ptn.curc.type == CT_NORMAL && + builder->ptn.curc.value == ASE_T(':')) + { + if (__build_cclass (builder, &c1) == -1) return -1; + cc = cc | 1; + } + + c2 = c1; + if (builder->ptn.curc.type == CT_NORMAL && + builder->ptn.curc.value == ASE_T('-')) + { + NEXT_CHAR (builder, LEVEL_CHARSET); + + if (builder->ptn.curc.type == CT_NORMAL) + { + c2 = builder->ptn.curc.value; + NEXT_CHAR (builder, LEVEL_CHARSET); + + if (c2 == ASE_T('[') && + builder->ptn.curc.type == CT_NORMAL && + builder->ptn.curc.value == ASE_T(':')) + { + if (__build_cclass (builder, &c2) == -1) + { + return -1; + } + + cc = cc | 2; + } + } + else cc = cc | 4; + } + + + if (cc == 0 || cc == 4) + { + if (c1 == c2) + { + c0 = CHARSET_ONE; + ADD_CODE (builder, &c0, ASE_SIZEOF(c0)); + ADD_CODE (builder, &c1, ASE_SIZEOF(c1)); + } + else + { + c0 = CHARSET_RANGE; + ADD_CODE (builder, &c0, ASE_SIZEOF(c0)); + ADD_CODE (builder, &c1, ASE_SIZEOF(c1)); + ADD_CODE (builder, &c2, ASE_SIZEOF(c2)); + } + } + else if (cc == 1) + { + c0 = CHARSET_CLASS; + ADD_CODE (builder, &c0, ASE_SIZEOF(c0)); + ADD_CODE (builder, &c1, ASE_SIZEOF(c1)); + } + else + { + /* invalid range */ + #ifdef DEBUG_REX + ase_dprintf ( + ASE_T("__build_charset: invalid character set range\n")); + #endif + builder->errnum = ASE_AWK_EREXCRANGE; + return -1; + } + + cshdr = (cshdr_t*)&builder->code.buf[pos_csc]; + cshdr->csc++; + } + + cshdr = (cshdr_t*)&builder->code.buf[pos_csc]; + cshdr->csl = builder->code.size - old_size; + + return 1; +} + +static int __build_cclass (builder_t* builder, ase_char_t* cc) +{ + const struct __char_class_t* ccp = __char_class; + ase_size_t len = builder->ptn.end - builder->ptn.curp; + + while (ccp->name != ASE_NULL) + { + if (__begin_with (builder->ptn.curp, len, ccp->name)) break; + ccp++; + } + + if (ccp->name == ASE_NULL) + { + /* wrong class name */ + #ifdef DEBUG_REX + ase_dprintf (ASE_T("__build_cclass: wrong class name\n")); + #endif + builder->errnum = ASE_AWK_EREXCCLASS; + return -1; + } + + builder->ptn.curp += ccp->name_len; + + NEXT_CHAR (builder, LEVEL_CHARSET); + if (builder->ptn.curc.type != CT_NORMAL || + builder->ptn.curc.value != ASE_T(':')) + { + #ifdef DEBUG_REX + ase_dprintf (ASE_T("__build_cclass: a colon(:) expected\n")); + #endif + builder->errnum = ASE_AWK_EREXCOLON; + return -1; + } + + NEXT_CHAR (builder, LEVEL_CHARSET); + + /* ] happens to be the charset ender ] */ + if (builder->ptn.curc.type != CT_SPECIAL || + builder->ptn.curc.value != ASE_T(']')) + { + #ifdef DEBUG_REX + ase_dprintf (ASE_T("__build_cclass: ] expected\n")); + #endif + builder->errnum = ASE_AWK_EREXRBRACKET; + return -1; + } + + NEXT_CHAR (builder, LEVEL_CHARSET); + + *cc = (ase_char_t)(ccp - __char_class); + return 1; +} + +static int __build_occurrences (builder_t* builder, code_t* cmd) +{ + if (builder->ptn.curc.type != CT_SPECIAL) return 0; + + switch (builder->ptn.curc.value) + { + case ASE_T('+'): + { + cmd->lbound = 1; + cmd->ubound = BOUND_MAX; + NEXT_CHAR(builder, LEVEL_TOP); + return 1; + } + + case ASE_T('*'): + { + cmd->lbound = 0; + cmd->ubound = BOUND_MAX; + NEXT_CHAR(builder, LEVEL_TOP); + return 1; + } + + case ASE_T('?'): + { + cmd->lbound = 0; + cmd->ubound = 1; + NEXT_CHAR(builder, LEVEL_TOP); + return 1; + } + + case ASE_T('{'): + { + NEXT_CHAR (builder, LEVEL_RANGE); + + if (__build_range(builder, cmd) == -1) return -1; + + if (builder->ptn.curc.type != CT_SPECIAL || + builder->ptn.curc.value != ASE_T('}')) + { + builder->errnum = ASE_AWK_EREXRBRACE; + return -1; + } + + NEXT_CHAR (builder, LEVEL_TOP); + return 1; + } + } + + return 0; +} + +static int __build_range (builder_t* builder, code_t* cmd) +{ + ase_size_t bound; + +/* TODO: should allow white spaces in the range??? +what if it is not in the raight format? convert it to ordinary characters?? */ + bound = 0; + while (builder->ptn.curc.type == CT_NORMAL && + (builder->ptn.curc.value >= ASE_T('0') && + builder->ptn.curc.value <= ASE_T('9'))) + { + bound = bound * 10 + builder->ptn.curc.value - ASE_T('0'); + NEXT_CHAR (builder, LEVEL_RANGE); + } + + cmd->lbound = bound; + + if (builder->ptn.curc.type == CT_SPECIAL && + builder->ptn.curc.value == ASE_T(',')) + { + NEXT_CHAR (builder, LEVEL_RANGE); + + bound = 0; + while (builder->ptn.curc.type == CT_NORMAL && + (builder->ptn.curc.value >= ASE_T('0') && + builder->ptn.curc.value <= ASE_T('9'))) + { + bound = bound * 10 + builder->ptn.curc.value - ASE_T('0'); + NEXT_CHAR (builder, LEVEL_RANGE); + } + + cmd->ubound = bound; + } + else cmd->ubound = BOUND_MAX; + + if (cmd->lbound > cmd->ubound) + { + /* invalid occurrences range */ + builder->errnum = ASE_AWK_EREXBRANGE; + return -1; + } + + return 0; +} + +static int __next_char (builder_t* builder, int level) +{ + if (builder->ptn.curp >= builder->ptn.end) + { + builder->ptn.curc.type = CT_EOF; + builder->ptn.curc.value = ASE_T('\0'); + return 0; + } + + builder->ptn.curc.type = CT_NORMAL; + builder->ptn.curc.value = *builder->ptn.curp++; + + if (builder->ptn.curc.value == ASE_T('\\')) + { + if (builder->ptn.curp >= builder->ptn.end) + { + builder->errnum = ASE_AWK_EREXEND; + return -1; + } + + builder->ptn.curc.value = *builder->ptn.curp++; + return 0; + } + else + { + if (level == LEVEL_TOP) + { + if (builder->ptn.curc.value == ASE_T('[') || + builder->ptn.curc.value == ASE_T('|') || + builder->ptn.curc.value == ASE_T('^') || + builder->ptn.curc.value == ASE_T('$') || + builder->ptn.curc.value == ASE_T('{') || + builder->ptn.curc.value == ASE_T('+') || + builder->ptn.curc.value == ASE_T('?') || + builder->ptn.curc.value == ASE_T('*') || + builder->ptn.curc.value == ASE_T('.') || + builder->ptn.curc.value == ASE_T('(') || + builder->ptn.curc.value == ASE_T(')')) + { + builder->ptn.curc.type = CT_SPECIAL; + } + } + else if (level == LEVEL_CHARSET) + { + if (builder->ptn.curc.value == ASE_T(']')) + { + builder->ptn.curc.type = CT_SPECIAL; + } + } + else if (level == LEVEL_RANGE) + { + if (builder->ptn.curc.value == ASE_T(',') || + builder->ptn.curc.value == ASE_T('}')) + { + builder->ptn.curc.type = CT_SPECIAL; + } + } + } + + return 0; +} + +static int __add_code (builder_t* builder, void* data, ase_size_t len) +{ + if (len > builder->code.capa - builder->code.size) + { + ase_size_t capa = builder->code.capa * 2; + ase_byte_t* tmp; + + if (capa == 0) capa = DEF_CODE_CAPA; + while (len > capa - builder->code.size) { capa = capa * 2; } + + if (builder->awk->prmfns.mmgr.realloc != ASE_NULL) + { + tmp = (ase_byte_t*) ASE_AWK_REALLOC ( + builder->awk, builder->code.buf, capa); + if (tmp == ASE_NULL) + { + builder->errnum = ASE_AWK_ENOMEM; + return -1; + } + } + else + { + tmp = (ase_byte_t*) ASE_AWK_MALLOC (builder->awk, capa); + if (tmp == ASE_NULL) + { + builder->errnum = ASE_AWK_ENOMEM; + return -1; + } + + if (builder->code.buf != ASE_NULL) + { + ase_memcpy (tmp, builder->code.buf, builder->code.capa); + ASE_AWK_FREE (builder->awk, builder->code.buf); + } + } + + builder->code.buf = tmp; + builder->code.capa = capa; + } + + ase_memcpy (&builder->code.buf[builder->code.size], data, len); + builder->code.size += len; + + return 0; +} + +static ase_bool_t __begin_with ( + const ase_char_t* str, ase_size_t len, const ase_char_t* what) +{ + const ase_char_t* end = str + len; + + while (str < end) + { + if (*what == ASE_T('\0')) return ase_true; + if (*what != *str) return ase_false; + + str++; what++; + } + + if (*what == ASE_T('\0')) return ase_true; + return ase_false; +} + +static const ase_byte_t* __match_pattern ( + matcher_t* matcher, const ase_byte_t* base, match_t* mat) +{ + match_t mat2; + ase_size_t i; + const ase_byte_t* p; + rhdr_t* rhdr; + + p = base; + rhdr = (rhdr_t*) p; p += ASE_SIZEOF(*rhdr); + +#ifdef DEBUG_REX + ase_dprintf ( + ASE_T("__match_pattern: NB = %u, EL = %u\n"), + (unsigned int)rhdr->nb, (unsigned int)rhdr->el); +#endif + + mat->matched = ase_false; + mat->match_len = 0; + + for (i = 0; i < rhdr->nb; i++) + { + mat2.match_ptr = mat->match_ptr; + + p = __match_branch (matcher, p, &mat2); + if (p == ASE_NULL) return ASE_NULL; + + if (mat2.matched) + { + mat->matched = ase_true; + mat->match_len = mat2.match_len; + break; + } + } + + return base + rhdr->el; +} + +static const ase_byte_t* __match_branch ( + matcher_t* matcher, const ase_byte_t* base, match_t* mat) +{ + /* branch body base+sizeof(NA)+sizeof(BL)-----+ + * BL base+sizeof(NA) ----------+ | + * base NA ------+ | | + * | | | + * |NA(ase_size_t)|BL(ase_size_t)|ATOMS.........| + */ + mat->branch = base; + mat->branch_end = base + ((bhdr_t*)base)->bl; + + return __match_branch_body ( + matcher, (const ase_byte_t*)((bhdr_t*)base+1), mat); +} + +static const ase_byte_t* __match_branch_body ( + matcher_t* matcher, const ase_byte_t* base, match_t* mat) +{ + const ase_byte_t* n; + + if (matcher->depth.max > 0 && matcher->depth.cur >= matcher->depth.max) + { + matcher->errnum = ASE_AWK_EREXRECUR; + return ASE_NULL; + } + + matcher->depth.cur++; + n = __match_branch_body0 (matcher, base, mat); + matcher->depth.cur--; + + return n; +} + +static const ase_byte_t* __match_branch_body0 ( + matcher_t* matcher, const ase_byte_t* base, match_t* mat) +{ + const ase_byte_t* p; +/* match_t mat2;*/ + ase_size_t match_len = 0; + + mat->matched = ase_false; + mat->match_len = 0; + +/* TODO: is mat2 necessary here ? */ +/* + mat2.match_ptr = mat->match_ptr; + mat2.branch = mat->branch; + mat2.branch_end = mat->branch_end; +*/ + + p = base; + + while (p < mat->branch_end) + { + p = __match_atom (matcher, p, mat); + if (p == ASE_NULL) return ASE_NULL; + + if (!mat->matched) break; + + mat->match_ptr = &mat->match_ptr[mat->match_len]; + match_len += mat->match_len; +#if 0 + p = __match_atom (matcher, p, &mat2); + if (p == ASE_NULL) return ASE_NULL; + + if (!mat2.matched) + { + mat->matched = ase_false; + break; /* stop matching */ + } + + mat->matched = ase_true; + mat->match_len += mat2.match_len; + + mat2.match_ptr = &mat2.match_ptr[mat2.match_len]; +#endif + } + + if (mat->matched) mat->match_len = match_len; + return mat->branch_end; +} + +static const ase_byte_t* __match_atom ( + matcher_t* matcher, const ase_byte_t* base, match_t* mat) +{ + static atom_matcher_t matchers[] = + { + __match_bol, + __match_eol, + __match_any_char, + __match_ord_char, + __match_charset, + __match_group + }; + + ASE_ASSERT ( + ((code_t*)base)->cmd >= 0 && + ((code_t*)base)->cmd < ASE_COUNTOF(matchers)); + + return matchers[((code_t*)base)->cmd] (matcher, base, mat); +} + +static const ase_byte_t* __match_bol ( + matcher_t* matcher, const ase_byte_t* base, match_t* mat) +{ + const ase_byte_t* p = base; + const code_t* cp; + + cp = (const code_t*)p; p += ASE_SIZEOF(*cp); + ASE_ASSERT (cp->cmd == CMD_BOL); + + mat->matched = (mat->match_ptr == matcher->match.str.ptr || + (cp->lbound == cp->ubound && cp->lbound == 0)); + mat->match_len = 0; + + return p; +} + +static const ase_byte_t* __match_eol ( + matcher_t* matcher, const ase_byte_t* base, match_t* mat) +{ + const ase_byte_t* p = base; + const code_t* cp; + + cp = (const code_t*)p; p += ASE_SIZEOF(*cp); + ASE_ASSERT (cp->cmd == CMD_EOL); + + mat->matched = (mat->match_ptr == matcher->match.str.end || + (cp->lbound == cp->ubound && cp->lbound == 0)); + mat->match_len = 0; + + return p; +} + +static const ase_byte_t* __match_any_char ( + matcher_t* matcher, const ase_byte_t* base, match_t* mat) +{ + const ase_byte_t* p = base; + const code_t* cp; + ase_size_t si = 0, lbound, ubound; + + cp = (const code_t*)p; p += ASE_SIZEOF(*cp); + ASE_ASSERT (cp->cmd == CMD_ANY_CHAR); + + lbound = cp->lbound; + ubound = cp->ubound; + + mat->matched = ase_false; + mat->match_len = 0; + + /* merge the same consecutive codes */ + while (p < mat->branch_end && + cp->cmd == ((const code_t*)p)->cmd) + { + lbound += ((const code_t*)p)->lbound; + ubound += ((const code_t*)p)->ubound; + + p += ASE_SIZEOF(*cp); + } + +#ifdef DEBUG_REX + ase_dprintf ( + ASE_T("__match_any_char: lbound = %u, ubound = %u\n"), + (unsigned int)lbound, (unsigned int)ubound); +#endif + + /* find the longest match */ + while (si < ubound) + { + if (&mat->match_ptr[si] >= matcher->match.str.end) break; + si++; + } + +#ifdef DEBUG_REX + ase_dprintf ( + ASE_T("__match_any_char: max si = %u\n"), (unsigned)si); +#endif + + if (si >= lbound && si <= ubound) + { + p = __match_occurrences (matcher, si, p, lbound, ubound, mat); + } + + return p; +} + +static const ase_byte_t* __match_ord_char ( + matcher_t* matcher, const ase_byte_t* base, match_t* mat) +{ + const ase_byte_t* p = base; + const code_t* cp; + ase_size_t si = 0, lbound, ubound; + ase_char_t cc; + + cp = (const code_t*)p; p += ASE_SIZEOF(*cp); + ASE_ASSERT (cp->cmd == CMD_ORD_CHAR); + + lbound = cp->lbound; + ubound = cp->ubound; + + cc = *(ase_char_t*)p; p += ASE_SIZEOF(cc); + if (matcher->ignorecase) cc = ASE_AWK_TOUPPER(matcher->awk, cc); + + /* merge the same consecutive codes + * for example, a{1,10}a{0,10} is shortened to a{1,20} */ + if (matcher->ignorecase) + { + while (p < mat->branch_end && + cp->cmd == ((const code_t*)p)->cmd) + { + if (ASE_AWK_TOUPPER (matcher->awk, *(ase_char_t*)(p+ASE_SIZEOF(*cp))) != cc) break; + + lbound += ((const code_t*)p)->lbound; + ubound += ((const code_t*)p)->ubound; + + p += ASE_SIZEOF(*cp) + ASE_SIZEOF(cc); + } + } + else + { + while (p < mat->branch_end && + cp->cmd == ((const code_t*)p)->cmd) + { + if (*(ase_char_t*)(p+ASE_SIZEOF(*cp)) != cc) break; + + lbound += ((const code_t*)p)->lbound; + ubound += ((const code_t*)p)->ubound; + + p += ASE_SIZEOF(*cp) + ASE_SIZEOF(cc); + } + } + +#ifdef DEBUG_REX + ase_dprintf ( + ASE_T("__match_ord_char: cc = %c, lbound = %u, ubound = %u\n"), + cc, (unsigned int)lbound, (unsigned int)ubound); +#endif + + mat->matched = ase_false; + mat->match_len = 0; + + /* find the longest match */ + if (matcher->ignorecase) + { + while (si < ubound) + { + if (&mat->match_ptr[si] >= matcher->match.str.end) break; +#ifdef DEBUG_REX + ase_dprintf ( + ASE_T("__match_ord_char: %c %c\n"), + cc, mat->match_ptr[si]); +#endif + if (cc != ASE_AWK_TOUPPER (matcher->awk, mat->match_ptr[si])) break; + si++; + } + } + else + { + while (si < ubound) + { + if (&mat->match_ptr[si] >= matcher->match.str.end) break; +#ifdef DEBUG_REX + ase_dprintf ( + ASE_T("__match_ord_char: %c %c\n"), + cc, mat->match_ptr[si]); +#endif + if (cc != mat->match_ptr[si]) break; + si++; + } + } + +#ifdef DEBUG_REX + ase_dprintf ( + ASE_T("__match_ord_char: max occurrences=%u, lbound=%u, ubound=%u\n"), + (unsigned)si, (unsigned)lbound, (unsigned)ubound); +#endif + + if (si >= lbound && si <= ubound) + { + p = __match_occurrences (matcher, si, p, lbound, ubound, mat); + } + + return p; +} + +static const ase_byte_t* __match_charset ( + matcher_t* matcher, const ase_byte_t* base, match_t* mat) +{ + const ase_byte_t* p = base; + ase_size_t si = 0; + ase_bool_t n; + ase_char_t c; + + code_t* cp; + cshdr_t* cshdr; + + cp = (code_t*)p; p += ASE_SIZEOF(*cp); + ASE_ASSERT (cp->cmd == CMD_CHARSET); + + cshdr = (cshdr_t*)p; p += ASE_SIZEOF(*cshdr); + +#ifdef DEBUG_REX + ase_dprintf ( + ASE_T("__match_charset: lbound = %u, ubound = %u\n"), + (unsigned int)cp->lbound, (unsigned int)cp->ubound); +#endif + + mat->matched = ase_false; + mat->match_len = 0; + + while (si < cp->ubound) + { + if (&mat->match_ptr[si] >= matcher->match.str.end) break; + + c = mat->match_ptr[si]; + if (matcher->ignorecase) c = ASE_AWK_TOUPPER(matcher->awk, c); + + n = __test_charset (matcher, p, cshdr->csc, c); + if (cp->negate) n = !n; + if (!n) break; + + si++; + } + + p = p + cshdr->csl - ASE_SIZEOF(*cshdr); + +#ifdef DEBUG_REX + ase_dprintf ( + ASE_T("__match_charset: max occurrences=%u, lbound=%u, ubound=%u\n"), + (unsigned)si, (unsigned)cp->lbound, (unsigned)cp->ubound); +#endif + + if (si >= cp->lbound && si <= cp->ubound) + { + p = __match_occurrences (matcher, si, p, cp->lbound, cp->ubound, mat); + } + + return p; +} + +static const ase_byte_t* __match_group ( + matcher_t* matcher, const ase_byte_t* base, match_t* mat) +{ + const ase_byte_t* p = base; + const code_t* cp; + match_t mat2; + ase_size_t si = 0, grp_len_static[16], * grp_len; + + cp = (const code_t*)p; p += ASE_SIZEOF(*cp); + ASE_ASSERT (cp->cmd == CMD_GROUP); + + mat->matched = ase_false; + mat->match_len = 0; + + /* + * A grouped pattern, unlike other atoms, can match one or more + * characters. When it is requested with a variable occurrences, + * the number of characters that have matched at each occurrence + * needs to be remembered for the backtracking purpose. + * + * An array "grp_len" is used to store the accumulated number of + * characters. grp_len[0] is set to zero always for convenience. + * grp_len[1] holds the number of characters that have matched + * at the first occurrence, grp_len[2] at the second occurrence, + * and so on. + * + * Look at the following example + * + * pattern: (abc){1,3}x string: abcabcabcxyz + * + * grp_len[3] => 9 -----------+ + * grp_len[2] => 6 --------+ | + * grp_len[1] => 3 -----+ | | + * grp_len[0] => 0 --+ | | | + * | | | | + * abcabcabcxyz + */ + + if (cp->ubound < ASE_COUNTOF(grp_len_static)) + { + grp_len = grp_len_static; + } + else + { + grp_len = (ase_size_t*) ASE_AWK_MALLOC ( + matcher->awk, ASE_SIZEOF(ase_size_t) * cp->ubound); + if (grp_len == ASE_NULL) + { + matcher->errnum = ASE_AWK_ENOMEM; + return ASE_NULL; + } + } + + grp_len[si] = 0; + + mat2.match_ptr = mat->match_ptr; + while (si < cp->ubound) + { + if (mat2.match_ptr >= matcher->match.str.end) break; + + if (__match_pattern (matcher, p, &mat2) == ASE_NULL) + { + if (grp_len != grp_len_static) + ASE_AWK_FREE (matcher->awk, grp_len); + return ASE_NULL; + } + if (!mat2.matched) break; + + grp_len[si+1] = grp_len[si] + mat2.match_len; + + mat2.match_ptr += mat2.match_len; + mat2.match_len = 0; + mat2.matched = ase_false; + + si++; + } + + /* increment p by the length of the subpattern */ + p += *(ase_size_t*)(p+ASE_SIZEOF(ase_size_t)); + + /* check the occurrences */ + if (si >= cp->lbound && si <= cp->ubound) + { + if (cp->lbound == cp->ubound || p >= mat->branch_end) + { + mat->matched = ase_true; + mat->match_len = grp_len[si]; + } + else + { + ASE_ASSERT (cp->ubound > cp->lbound); + + do + { + const ase_byte_t* tmp; + + mat2.match_ptr = &mat->match_ptr[grp_len[si]]; + mat2.branch = mat->branch; + mat2.branch_end = mat->branch_end; + + #ifdef DEBUG_REX + ase_dprintf ( + ASE_T("__match_group: GROUP si=%d [%s]\n"), + (unsigned)si, mat->match_ptr); + #endif + tmp = __match_branch_body (matcher, p, &mat2); + if (tmp == ASE_NULL) + { + if (grp_len != grp_len_static) + ASE_AWK_FREE (matcher->awk, grp_len); + return ASE_NULL; + } + + if (mat2.matched) + { + mat->matched = ase_true; + mat->match_len = grp_len[si] + mat2.match_len; + p = tmp; + break; + } + + if (si <= cp->lbound) break; + si--; + } + while (1); + } + + } + + if (grp_len != grp_len_static) ASE_AWK_FREE (matcher->awk, grp_len); + return p; +} + +static const ase_byte_t* __match_occurrences ( + matcher_t* matcher, ase_size_t si, const ase_byte_t* p, + ase_size_t lbound, ase_size_t ubound, match_t* mat) +{ + ASE_ASSERT (si >= lbound && si <= ubound); + /* the match has been found */ + + if (lbound == ubound || p >= mat->branch_end) + { + /* if the match for fixed occurrences was + * requested or no atoms remain unchecked in + * the branch, the match is returned. */ + mat->matched = ase_true; + mat->match_len = si; + } + else + { + /* Otherwise, it checks if the remaining atoms + * match the rest of the string + * + * Let's say the caller of this function was processing + * the first period character in the following example. + * + * pattern: .{1,3}xx string: xxxyy + * + * It scans up to the third "x" in the string. si is set + * to 3 and p points to the first "x" in the pattern. + * It doesn't change mat.match_ptr so mat.match_ptr remains + * the same. + * + * si = 3 p -----+ mat.match_ptr ---+ + * | | + * .{1,3}xx xxxyy + * + * When the code reaches here, the string pointed at by + * &mat.match_ptr[si] is tried to match against the remaining + * pattern pointed at p. + * + * &mat.match_ptr[si] ---+ + * | + * xxxyy + * + * If a match is found, the match and the previous match are + * merged and returned. + * + * If not, si is decremented by one and the match is performed + * from the string pointed at by &mat.match_ptr[si]. + * + * &mat.match_ptr[si] --+ + * | + * xxxyy + * + * This process is repeated until a match is found or si + * becomes less than lbound. (si never becomes less than + * lbound in the implementation below, though) + */ + + ASE_ASSERT (ubound > lbound); + + do + { + match_t mat2; + const ase_byte_t* tmp; + + mat2.match_ptr = &mat->match_ptr[si]; + mat2.branch = mat->branch; + mat2.branch_end = mat->branch_end; + + #ifdef DEBUG_REX + ase_dprintf ( + ASE_T("__match occurrences: si=%u [%s]\n"), + (unsigned)si, mat->match_ptr); + #endif + tmp = __match_branch_body (matcher, p, &mat2); + + if (mat2.matched) + { + mat->matched = ase_true; + mat->match_len = si + mat2.match_len; + p = tmp; + break; + } + + if (si <= lbound) break; + si--; + } + while (1); + } + + return p; +} + +static ase_bool_t __test_charset ( + matcher_t* matcher, const ase_byte_t* p, ase_size_t csc, ase_char_t c) +{ + ase_size_t i; + + for (i = 0; i < csc; i++) + { + ase_char_t c0, c1, c2; + + c0 = *(const ase_char_t*)p; + p += ASE_SIZEOF(c0); + if (c0 == CHARSET_ONE) + { + c1 = *(const ase_char_t*)p; + if (matcher->ignorecase) + c1 = ASE_AWK_TOUPPER(matcher->awk, c1); + #ifdef DEBUG_REX + ase_dprintf ( + ASE_T("__match_charset: %c %c\n"), c, c1); + #endif + if (c == c1) return ase_true; + } + else if (c0 == CHARSET_RANGE) + { + c1 = *(const ase_char_t*)p; + p += ASE_SIZEOF(c1); + c2 = *(const ase_char_t*)p; + + if (matcher->ignorecase) + { + c1 = ASE_AWK_TOUPPER(matcher->awk, c1); + c2 = ASE_AWK_TOUPPER(matcher->awk, c2); + } + #ifdef DEBUG_REX + ase_dprintf ( + ASE_T("__match_charset: %c %c-%c\n"), c, c1, c2); + #endif + if (c >= c1 && c <= c2) return ase_true; + } + else if (c0 == CHARSET_CLASS) + { + c1 = *(const ase_char_t*)p; + #ifdef DEBUG_REX + ase_dprintf ( + ASE_T("__match_charset: %c %s\n"), + c, __char_class[c1].name); + #endif + if (__char_class[c1].func ( + matcher->awk, c)) return ase_true; + } + else + { + ASE_ASSERT (!"should never happen - invalid charset code"); + break; + } + + p += ASE_SIZEOF(c1); + } + + return ase_false; +} + +static ase_bool_t cc_isalnum (ase_awk_t* awk, ase_char_t c) +{ + return ASE_AWK_ISALNUM (awk, c); +} + +static ase_bool_t cc_isalpha (ase_awk_t* awk, ase_char_t c) +{ + return ASE_AWK_ISALPHA (awk, c); +} + +static ase_bool_t cc_isblank (ase_awk_t* awk, ase_char_t c) +{ + return c == ASE_T(' ') || c == ASE_T('\t'); +} + +static ase_bool_t cc_iscntrl (ase_awk_t* awk, ase_char_t c) +{ + return ASE_AWK_ISCNTRL (awk, c); +} + +static ase_bool_t cc_isdigit (ase_awk_t* awk, ase_char_t c) +{ + return ASE_AWK_ISDIGIT (awk, c); +} + +static ase_bool_t cc_isgraph (ase_awk_t* awk, ase_char_t c) +{ + return ASE_AWK_ISGRAPH (awk, c); +} + +static ase_bool_t cc_islower (ase_awk_t* awk, ase_char_t c) +{ + return ASE_AWK_ISLOWER (awk, c); +} + +static ase_bool_t cc_isprint (ase_awk_t* awk, ase_char_t c) +{ + return ASE_AWK_ISPRINT (awk, c); +} + +static ase_bool_t cc_ispunct (ase_awk_t* awk, ase_char_t c) +{ + return ASE_AWK_ISPUNCT (awk, c); +} + +static ase_bool_t cc_isspace (ase_awk_t* awk, ase_char_t c) +{ + return ASE_AWK_ISSPACE (awk, c); +} + +static ase_bool_t cc_isupper (ase_awk_t* awk, ase_char_t c) +{ + return ASE_AWK_ISUPPER (awk, c); +} + +static ase_bool_t cc_isxdigit (ase_awk_t* awk, ase_char_t c) +{ + return ASE_AWK_ISXDIGIT (awk, c); +} + +#define DPRINTF awk->prmfns.misc.dprintf +#define DCUSTOM awk->prmfns.misc.custom_data + +void ase_awk_dprintrex (ase_awk_t* awk, void* rex) +{ + __print_pattern (awk, rex); + DPRINTF (DCUSTOM, awk->prmfns.misc.custom_data, ASE_T("\n")); +} + +static const ase_byte_t* __print_pattern (ase_awk_t* awk, const ase_byte_t* p) +{ + ase_size_t i; + rhdr_t* rhdr; + + rhdr = (rhdr_t*)p; p += ASE_SIZEOF(*rhdr); + + for (i = 0; i < rhdr->nb; i++) + { + if (i != 0) DPRINTF (DCUSTOM, ASE_T("|")); + p = __print_branch (awk, p); + } + + return p; +} + +static const ase_byte_t* __print_branch (ase_awk_t* awk, const ase_byte_t* p) +{ + ase_size_t i; + bhdr_t* bhdr; + + bhdr = (bhdr_t*)p; p += ASE_SIZEOF(*bhdr); + + for (i = 0; i < bhdr->na; i++) + { + p = __print_atom (awk, p); + } + + return p; +} + +static const ase_byte_t* __print_atom (ase_awk_t* awk, const ase_byte_t* p) +{ + const code_t* cp = (const code_t*)p; + + if (cp->cmd == CMD_BOL) + { + DPRINTF (DCUSTOM, ASE_T("^")); + p += ASE_SIZEOF(*cp); + } + else if (cp->cmd == CMD_EOL) + { + DPRINTF (DCUSTOM, ASE_T("$")); + p += ASE_SIZEOF(*cp); + } + else if (cp->cmd == CMD_ANY_CHAR) + { + DPRINTF (DCUSTOM, ASE_T(".")); + p += ASE_SIZEOF(*cp); + } + else if (cp->cmd == CMD_ORD_CHAR) + { + p += ASE_SIZEOF(*cp); + DPRINTF (DCUSTOM, ASE_T("%c"), *(ase_char_t*)p); + p += ASE_SIZEOF(ase_char_t); + } + else if (cp->cmd == CMD_CHARSET) + { + ase_size_t i; + cshdr_t* cshdr; + + p += ASE_SIZEOF(*cp); + DPRINTF (DCUSTOM, ASE_T("[")); + if (cp->negate) DPRINTF (DCUSTOM, ASE_T("^")); + + cshdr = (cshdr_t*)p; p += ASE_SIZEOF(*cshdr); + + for (i = 0; i < cshdr->csc; i++) + { + ase_char_t c0, c1, c2; + + c0 = *(ase_char_t*)p; + p += ASE_SIZEOF(c0); + + if (c0 == CHARSET_ONE) + { + c1 = *(ase_char_t*)p; + DPRINTF (DCUSTOM, ASE_T("%c"), c1); + } + else if (c0 == CHARSET_RANGE) + { + c1 = *(ase_char_t*)p; + p += ASE_SIZEOF(c1); + c2 = *(ase_char_t*)p; + DPRINTF (DCUSTOM, ASE_T("%c-%c"), c1, c2); + } + else if (c0 == CHARSET_CLASS) + { + c1 = *(ase_char_t*)p; + DPRINTF (DCUSTOM, ASE_T("[:%s:]"), __char_class[c1].name); + } + else + { + DPRINTF (DCUSTOM, ASE_T("should never happen - invalid charset code\n")); + } + + p += ASE_SIZEOF(c1); + } + + DPRINTF (DCUSTOM, ASE_T("]")); + } + else if (cp->cmd == CMD_GROUP) + { + p += ASE_SIZEOF(*cp); + DPRINTF (DCUSTOM, ASE_T("(")); + p = __print_pattern (awk, p); + DPRINTF (DCUSTOM, ASE_T(")")); + } + else + { + DPRINTF (DCUSTOM, ASE_T("should never happen - invalid atom code\n")); + } + + if (cp->lbound == 0 && cp->ubound == BOUND_MAX) + DPRINTF (DCUSTOM, ASE_T("*")); + else if (cp->lbound == 1 && cp->ubound == BOUND_MAX) + DPRINTF (DCUSTOM, ASE_T("+")); + else if (cp->lbound == 0 && cp->ubound == 1) + DPRINTF (DCUSTOM, ASE_T("?")); + else if (cp->lbound != 1 || cp->ubound != 1) + { + DPRINTF (DCUSTOM, ASE_T("{%lu,%lu}"), + (unsigned long)cp->lbound, (unsigned long)cp->ubound); + } + + return p; +} + diff --git a/ase/awk/rex.h b/ase/awk/rex.h new file mode 100644 index 00000000..f7df124b --- /dev/null +++ b/ase/awk/rex.h @@ -0,0 +1,75 @@ +/* + * $Id: rex.h,v 1.3 2007/04/30 05:47:33 bacon Exp $ + * + * {License} + */ + +#ifndef _ASE_AWK_REX_H_ +#define _ASE_AWK_REX_H_ + +#ifndef _ASE_AWK_AWK_H_ +#error Never include this file directly. Include instead +#endif + +/* + * Regular Esseression Syntax + * A regular expression is zero or more branches, separated by '|'. + * ...... + * ...... + * + * Compiled form of a regular expression: + * + * | expression | + * | header | branch | branch | branch | + * | nb | el | na | bl | cmd | arg | cmd | arg | na | bl | cmd | arg | na | bl | cmd | + * + * nb: the number of branches + * el: the length of a expression including the length of nb and el + * na: the number of atoms + * bl: the length of a branch including the length of na and bl + * cmd: The command and repetition info encoded together. + * Some commands require an argument to follow them but some other don't. + * It is encoded as follows: + * + * Subexpressions can be nested by having the command "GROUP" + * and a subexpression as its argument. + * + * Examples: + * a.c -> |1|6|5|ORD_CHAR(no bound)|a|ANY_CHAR(no bound)|ORD_CHAR(no bound)|c| + * ab|xy -> |2|10|4|ORD_CHAR(no bound)|a|ORD_CHAR(no bound)|b|4|ORD_CHAR(no bound)|x|ORD_CHAR(no bound)|y| + */ + +#define ASE_AWK_REX_NA(code) (*(ase_size_t*)(code)) + +#define ASE_AWK_REX_LEN(code) \ + (*(ase_size_t*)((ase_byte_t*)(code)+ASE_SIZEOF(ase_size_t))) + +enum ase_awk_rex_opt_t +{ + ASE_AWK_REX_IGNORECASE = (1 << 0) +}; + +#ifdef __cplusplus +extern "C" { +#endif + +void* ase_awk_buildrex ( + ase_awk_t* awk, const ase_char_t* ptn, + ase_size_t len, int* errnum); + +int ase_awk_matchrex ( + ase_awk_t* awk, void* code, int option, + const ase_char_t* str, ase_size_t len, + const ase_char_t** match_ptr, ase_size_t* match_len, int* errnum); + +void ase_awk_freerex (ase_awk_t* awk, void* code); + +ase_bool_t ase_awk_isemptyrex (ase_awk_t* awk, void* code); + +void ase_awk_dprintrex (ase_awk_t* awk, void* rex); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ase/awk/run.c b/ase/awk/run.c new file mode 100644 index 00000000..08bdf5dd --- /dev/null +++ b/ase/awk/run.c @@ -0,0 +1,7053 @@ +/* + * $Id: run.c,v 1.3 2007/04/30 05:47:33 bacon Exp $ + * + * {License} + */ + +#include + +#ifdef DEBUG_RUN +#include +#endif + +#define CMP_ERROR -99 +#define DEF_BUF_CAPA 256 +#define STACK_INCREMENT 512 + +#define STACK_AT(run,n) ((run)->stack[(run)->stack_base+(n)]) +#define STACK_NARGS(run) (STACK_AT(run,3)) +#define STACK_ARG(run,n) STACK_AT(run,3+1+(n)) +#define STACK_LOCAL(run,n) STACK_AT(run,3+(ase_size_t)STACK_NARGS(run)+1+(n)) +#define STACK_RETVAL(run) STACK_AT(run,2) +#define STACK_GLOBAL(run,n) ((run)->stack[(n)]) +#define STACK_RETVAL_GLOBAL(run) ((run)->stack[(run)->awk->tree.nglobals+2]) + +enum exit_level_t +{ + EXIT_NONE, + EXIT_BREAK, + EXIT_CONTINUE, + EXIT_FUNCTION, + EXIT_NEXT, + EXIT_GLOBAL, + EXIT_ABORT +}; + +#define DEFAULT_CONVFMT ASE_T("%.6g") +#define DEFAULT_OFMT ASE_T("%.6g") +#define DEFAULT_OFS ASE_T(" ") +#define DEFAULT_ORS ASE_T("\n") +#define DEFAULT_ORS_CRLF ASE_T("\r\n") +#define DEFAULT_SUBSEP ASE_T("\034") + +/* the index of a positional variable should be a positive interger + * equal to or less than the maximum value of the type by which + * the index is represented. but it has an extra check against the + * maximum value of ase_size_t as the reference is represented + * in a pointer variable of ase_awk_val_ref_t and sizeof(void*) is + * equal to sizeof(ase_size_t). */ +#define IS_VALID_POSIDX(idx) \ + ((idx) >= 0 && \ + (idx) < ASE_TYPE_MAX(ase_long_t) && \ + (idx) < ASE_TYPE_MAX(ase_size_t)) + +static int __set_global ( + ase_awk_run_t* run, ase_size_t idx, + ase_awk_nde_var_t* var, ase_awk_val_t* val); + +static int __init_run ( + ase_awk_run_t* run, ase_awk_t* awk, + ase_awk_runios_t* runios, void* custom_data); +static void __deinit_run (ase_awk_run_t* run); + +static int __build_runarg ( + ase_awk_run_t* run, ase_awk_runarg_t* runarg, ase_size_t* nargs); +static void __cleanup_globals (ase_awk_run_t* run); +static int __set_globals_to_default (ase_awk_run_t* run); + +static int run_main ( + ase_awk_run_t* run, const ase_char_t* main, + ase_awk_runarg_t* runarg); + +static int __run_pattern_blocks (ase_awk_run_t* run); +static int __run_pattern_block_chain ( + ase_awk_run_t* run, ase_awk_chain_t* chain); +static int __run_pattern_block ( + ase_awk_run_t* run, ase_awk_chain_t* chain, ase_size_t block_no); +static int __run_block (ase_awk_run_t* run, ase_awk_nde_blk_t* nde); +static int __run_block0 (ase_awk_run_t* run, ase_awk_nde_blk_t* nde); +static int __run_statement (ase_awk_run_t* run, ase_awk_nde_t* nde); +static int __run_if (ase_awk_run_t* run, ase_awk_nde_if_t* nde); +static int __run_while (ase_awk_run_t* run, ase_awk_nde_while_t* nde); +static int __run_for (ase_awk_run_t* run, ase_awk_nde_for_t* nde); +static int __run_foreach (ase_awk_run_t* run, ase_awk_nde_foreach_t* nde); +static int __run_break (ase_awk_run_t* run, ase_awk_nde_break_t* nde); +static int __run_continue (ase_awk_run_t* run, ase_awk_nde_continue_t* nde); +static int __run_return (ase_awk_run_t* run, ase_awk_nde_return_t* nde); +static int __run_exit (ase_awk_run_t* run, ase_awk_nde_exit_t* nde); +static int __run_next (ase_awk_run_t* run, ase_awk_nde_next_t* nde); +static int __run_nextfile (ase_awk_run_t* run, ase_awk_nde_nextfile_t* nde); +static int __run_delete (ase_awk_run_t* run, ase_awk_nde_delete_t* nde); +static int __run_print (ase_awk_run_t* run, ase_awk_nde_print_t* nde); +static int __run_printf (ase_awk_run_t* run, ase_awk_nde_print_t* nde); +static int __formatted_output ( + ase_awk_run_t* run, int out_type, const ase_char_t* dst, + const ase_char_t* fmt, ase_size_t fmt_len, ase_awk_nde_t* args); + +static ase_awk_val_t* __eval_expression (ase_awk_run_t* run, ase_awk_nde_t* nde); +static ase_awk_val_t* __eval_expression0 (ase_awk_run_t* run, ase_awk_nde_t* nde); + +static ase_awk_val_t* __eval_group (ase_awk_run_t* run, ase_awk_nde_t* nde); + +static ase_awk_val_t* __eval_assignment ( + ase_awk_run_t* run, ase_awk_nde_t* nde); +static ase_awk_val_t* __do_assignment ( + ase_awk_run_t* run, ase_awk_nde_t* var, ase_awk_val_t* val); +static ase_awk_val_t* __do_assignment_scalar ( + ase_awk_run_t* run, ase_awk_nde_var_t* var, ase_awk_val_t* val); +static ase_awk_val_t* __do_assignment_map ( + ase_awk_run_t* run, ase_awk_nde_var_t* var, ase_awk_val_t* val); +static ase_awk_val_t* __do_assignment_pos ( + ase_awk_run_t* run, ase_awk_nde_pos_t* pos, ase_awk_val_t* val); + +static ase_awk_val_t* __eval_binary ( + ase_awk_run_t* run, ase_awk_nde_t* nde); +static ase_awk_val_t* __eval_binop_lor ( + ase_awk_run_t* run, ase_awk_nde_t* left, ase_awk_nde_t* right); +static ase_awk_val_t* __eval_binop_land ( + ase_awk_run_t* run, ase_awk_nde_t* left, ase_awk_nde_t* right); +static ase_awk_val_t* __eval_binop_in ( + ase_awk_run_t* run, ase_awk_nde_t* left, ase_awk_nde_t* right); +static ase_awk_val_t* __eval_binop_bor ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right); +static ase_awk_val_t* __eval_binop_bxor ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right); +static ase_awk_val_t* __eval_binop_band ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right); +static ase_awk_val_t* __eval_binop_eq ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right); +static ase_awk_val_t* __eval_binop_ne ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right); +static ase_awk_val_t* __eval_binop_gt ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right); +static ase_awk_val_t* __eval_binop_ge ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right); +static ase_awk_val_t* __eval_binop_lt ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right); +static ase_awk_val_t* __eval_binop_le ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right); +static ase_awk_val_t* __eval_binop_lshift ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right); +static ase_awk_val_t* __eval_binop_rshift ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right); +static ase_awk_val_t* __eval_binop_plus ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right); +static ase_awk_val_t* __eval_binop_minus ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right); +static ase_awk_val_t* __eval_binop_mul ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right); +static ase_awk_val_t* __eval_binop_div ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right); +static ase_awk_val_t* __eval_binop_idiv ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right); +static ase_awk_val_t* __eval_binop_mod ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right); +static ase_awk_val_t* __eval_binop_exp ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right); +static ase_awk_val_t* __eval_binop_concat ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right); +static ase_awk_val_t* __eval_binop_ma ( + ase_awk_run_t* run, ase_awk_nde_t* left, ase_awk_nde_t* right); +static ase_awk_val_t* __eval_binop_nm ( + ase_awk_run_t* run, ase_awk_nde_t* left, ase_awk_nde_t* right); +static ase_awk_val_t* __eval_binop_match0 ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right, + ase_size_t lline, ase_size_t rline, int ret); + +static ase_awk_val_t* __eval_unary (ase_awk_run_t* run, ase_awk_nde_t* nde); +static ase_awk_val_t* __eval_incpre (ase_awk_run_t* run, ase_awk_nde_t* nde); +static ase_awk_val_t* __eval_incpst (ase_awk_run_t* run, ase_awk_nde_t* nde); +static ase_awk_val_t* __eval_cnd (ase_awk_run_t* run, ase_awk_nde_t* nde); + +static ase_awk_val_t* __eval_bfn (ase_awk_run_t* run, ase_awk_nde_t* nde); +static ase_awk_val_t* __eval_afn (ase_awk_run_t* run, ase_awk_nde_t* nde); +static ase_awk_val_t* __eval_call ( + ase_awk_run_t* run, ase_awk_nde_t* nde, + const ase_char_t* bfn_arg_spec, ase_awk_afn_t* afn); + +static int __get_reference ( + ase_awk_run_t* run, ase_awk_nde_t* nde, ase_awk_val_t*** ref); +static ase_awk_val_t** __get_reference_indexed ( + ase_awk_run_t* run, ase_awk_nde_var_t* nde, ase_awk_val_t** val); + +static ase_awk_val_t* __eval_int (ase_awk_run_t* run, ase_awk_nde_t* nde); +static ase_awk_val_t* __eval_real (ase_awk_run_t* run, ase_awk_nde_t* nde); +static ase_awk_val_t* __eval_str (ase_awk_run_t* run, ase_awk_nde_t* nde); +static ase_awk_val_t* __eval_rex (ase_awk_run_t* run, ase_awk_nde_t* nde); +static ase_awk_val_t* __eval_named (ase_awk_run_t* run, ase_awk_nde_t* nde); +static ase_awk_val_t* __eval_global (ase_awk_run_t* run, ase_awk_nde_t* nde); +static ase_awk_val_t* __eval_local (ase_awk_run_t* run, ase_awk_nde_t* nde); +static ase_awk_val_t* __eval_arg (ase_awk_run_t* run, ase_awk_nde_t* nde); +static ase_awk_val_t* __eval_namedidx (ase_awk_run_t* run, ase_awk_nde_t* nde); +static ase_awk_val_t* __eval_globalidx (ase_awk_run_t* run, ase_awk_nde_t* nde); +static ase_awk_val_t* __eval_localidx (ase_awk_run_t* run, ase_awk_nde_t* nde); +static ase_awk_val_t* __eval_argidx (ase_awk_run_t* run, ase_awk_nde_t* nde); +static ase_awk_val_t* __eval_pos (ase_awk_run_t* run, ase_awk_nde_t* nde); +static ase_awk_val_t* __eval_getline (ase_awk_run_t* run, ase_awk_nde_t* nde); + +static int __raw_push (ase_awk_run_t* run, void* val); +#define __raw_pop(run) \ + do { \ + ASE_ASSERT ((run)->stack_top > (run)->stack_base); \ + (run)->stack_top--; \ + } while (0) +static void __raw_pop_times (ase_awk_run_t* run, ase_size_t times); + +static int __read_record (ase_awk_run_t* run); +static int __shorten_record (ase_awk_run_t* run, ase_size_t nflds); + +static ase_char_t* __idxnde_to_str ( + ase_awk_run_t* run, ase_awk_nde_t* nde, ase_size_t* len); + +typedef ase_awk_val_t* (*binop_func_t) ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right); +typedef ase_awk_val_t* (*eval_expr_t) (ase_awk_run_t* run, ase_awk_nde_t* nde); + +ase_size_t ase_awk_getnargs (ase_awk_run_t* run) +{ + return (ase_size_t) STACK_NARGS (run); +} + +ase_awk_val_t* ase_awk_getarg (ase_awk_run_t* run, ase_size_t idx) +{ + return STACK_ARG (run, idx); +} + +ase_awk_val_t* ase_awk_getglobal (ase_awk_run_t* run, ase_size_t idx) +{ + return STACK_GLOBAL (run, idx); +} + +int ase_awk_setglobal (ase_awk_run_t* run, ase_size_t idx, ase_awk_val_t* val) +{ + return __set_global (run, idx, ASE_NULL, val); +} + +static int __set_global ( + ase_awk_run_t* run, ase_size_t idx, + ase_awk_nde_var_t* var, ase_awk_val_t* val) +{ + ase_awk_val_t* old; + + old = STACK_GLOBAL (run, idx); + if (old->type == ASE_AWK_VAL_MAP) + { + /* once a variable becomes a map, + * it cannot be changed to a scalar variable */ + + if (var != ASE_NULL) + { + /* global variable */ + ase_cstr_t errarg; + + errarg.ptr = var->id.name; + errarg.len = var->id.name_len; + + ase_awk_setrunerror (run, + ASE_AWK_EMAPTOSCALAR, var->line, &errarg, 1); + } + else + { + /* ase_awk_setglobal has been called */ + ase_cstr_t errarg; + + errarg.ptr = ase_awk_getglobalname ( + run->awk, idx, &errarg.len); + ase_awk_setrunerror (run, + ASE_AWK_EMAPTOSCALAR, 0, &errarg, 1); + } + return -1; + } + + /* builtin variables except ARGV cannot be assigned a map */ + if (val->type == ASE_AWK_VAL_MAP && + (idx >= ASE_AWK_GLOBAL_ARGC && idx <= ASE_AWK_GLOBAL_SUBSEP) && + idx != ASE_AWK_GLOBAL_ARGV) + { + /* TODO: better error code */ + ase_awk_setrunerror (run, ASE_AWK_ESCALARTOMAP, 0, ASE_NULL, 0); + return -1; + } + + if (idx == ASE_AWK_GLOBAL_CONVFMT) + { + ase_char_t* convfmt_ptr; + ase_size_t convfmt_len, i; + + convfmt_ptr = ase_awk_valtostr (run, + val, ASE_AWK_VALTOSTR_CLEAR, ASE_NULL, &convfmt_len); + if (convfmt_ptr == ASE_NULL) return -1; + + for (i = 0; i < convfmt_len; i++) + { + if (convfmt_ptr[i] == ASE_T('\0')) + { + ASE_AWK_FREE (run->awk, convfmt_ptr); + ase_awk_setrunerror (run, ASE_AWK_ECONVFMTCHR, 0, ASE_NULL, 0); + return -1; + } + } + + if (run->global.convfmt.ptr != ASE_NULL) + ASE_AWK_FREE (run->awk, run->global.convfmt.ptr); + run->global.convfmt.ptr = convfmt_ptr; + run->global.convfmt.len = convfmt_len; + } + else if (idx == ASE_AWK_GLOBAL_FS) + { + ase_char_t* fs_ptr; + ase_size_t fs_len; + + if (val->type == ASE_AWK_VAL_STR) + { + fs_ptr = ((ase_awk_val_str_t*)val)->buf; + fs_len = ((ase_awk_val_str_t*)val)->len; + } + else + { + /* due to the expression evaluation rule, the + * regular expression can not be an assigned value */ + ASE_ASSERT (val->type != ASE_AWK_VAL_REX); + + fs_ptr = ase_awk_valtostr ( + run, val, ASE_AWK_VALTOSTR_CLEAR, ASE_NULL, &fs_len); + if (fs_ptr == ASE_NULL) return -1; + } + + if (fs_len > 1) + { + void* rex; + + /* compile the regular expression */ + /* TODO: use safebuild */ + rex = ase_awk_buildrex ( + run->awk, fs_ptr, fs_len, &run->errnum); + if (rex == ASE_NULL) + { + if (val->type != ASE_AWK_VAL_STR) + ASE_AWK_FREE (run->awk, fs_ptr); + return -1; + } + + if (run->global.fs != ASE_NULL) + { + ase_awk_freerex (run->awk, run->global.fs); + } + run->global.fs = rex; + } + + if (val->type != ASE_AWK_VAL_STR) ASE_AWK_FREE (run->awk, fs_ptr); + } + else if (idx == ASE_AWK_GLOBAL_IGNORECASE) + { + if ((val->type == ASE_AWK_VAL_INT && + ((ase_awk_val_int_t*)val)->val == 0) || + (val->type == ASE_AWK_VAL_REAL && + ((ase_awk_val_real_t*)val)->val == 0.0) || + (val->type == ASE_AWK_VAL_STR && + ((ase_awk_val_str_t*)val)->len == 0)) + { + run->global.ignorecase = 0; + } + else + { + run->global.ignorecase = 1; + } + } + else if (idx == ASE_AWK_GLOBAL_NF) + { + int n; + ase_long_t lv; + ase_real_t rv; + + n = ase_awk_valtonum (run, val, &lv, &rv); + if (n == -1) return -1; + if (n == 1) lv = (ase_long_t)rv; + + if (lv < run->inrec.nflds) + { + if (__shorten_record (run, (ase_size_t)lv) == -1) + { + /* adjust the error line */ + if (var != ASE_NULL) run->errlin = var->line; + return -1; + } + } + } + else if (idx == ASE_AWK_GLOBAL_OFMT) + { + ase_char_t* ofmt_ptr; + ase_size_t ofmt_len, i; + + ofmt_ptr = ase_awk_valtostr ( + run, val, ASE_AWK_VALTOSTR_CLEAR, ASE_NULL, &ofmt_len); + if (ofmt_ptr == ASE_NULL) return -1; + + for (i = 0; i < ofmt_len; i++) + { + if (ofmt_ptr[i] == ASE_T('\0')) + { + ASE_AWK_FREE (run->awk, ofmt_ptr); + ase_awk_setrunerror (run, ASE_AWK_EOFMTCHR, 0, ASE_NULL, 0); + return -1; + } + } + + if (run->global.ofmt.ptr != ASE_NULL) + ASE_AWK_FREE (run->awk, run->global.ofmt.ptr); + run->global.ofmt.ptr = ofmt_ptr; + run->global.ofmt.len = ofmt_len; + } + else if (idx == ASE_AWK_GLOBAL_OFS) + { + ase_char_t* ofs_ptr; + ase_size_t ofs_len; + + ofs_ptr = ase_awk_valtostr ( + run, val, ASE_AWK_VALTOSTR_CLEAR, ASE_NULL, &ofs_len); + if (ofs_ptr == ASE_NULL) return -1; + + if (run->global.ofs.ptr != ASE_NULL) + ASE_AWK_FREE (run->awk, run->global.ofs.ptr); + run->global.ofs.ptr = ofs_ptr; + run->global.ofs.len = ofs_len; + } + else if (idx == ASE_AWK_GLOBAL_ORS) + { + ase_char_t* ors_ptr; + ase_size_t ors_len; + + ors_ptr = ase_awk_valtostr ( + run, val, ASE_AWK_VALTOSTR_CLEAR, ASE_NULL, &ors_len); + if (ors_ptr == ASE_NULL) return -1; + + if (run->global.ors.ptr != ASE_NULL) + ASE_AWK_FREE (run->awk, run->global.ors.ptr); + run->global.ors.ptr = ors_ptr; + run->global.ors.len = ors_len; + } + else if (idx == ASE_AWK_GLOBAL_RS) + { + ase_char_t* rs_ptr; + ase_size_t rs_len; + + if (val->type == ASE_AWK_VAL_STR) + { + rs_ptr = ((ase_awk_val_str_t*)val)->buf; + rs_len = ((ase_awk_val_str_t*)val)->len; + } + else + { + /* due to the expression evaluation rule, the + * regular expression can not be an assigned value */ + ASE_ASSERT (val->type != ASE_AWK_VAL_REX); + + rs_ptr = ase_awk_valtostr ( + run, val, ASE_AWK_VALTOSTR_CLEAR, ASE_NULL, &rs_len); + if (rs_ptr == ASE_NULL) return -1; + } + + if (rs_len > 1) + { + void* rex; + + /* compile the regular expression */ + /* TODO: use safebuild */ + rex = ase_awk_buildrex ( + run->awk, rs_ptr, rs_len, &run->errnum); + if (rex == ASE_NULL) + { + if (val->type != ASE_AWK_VAL_STR) + ASE_AWK_FREE (run->awk, rs_ptr); + return -1; + } + + if (run->global.rs != ASE_NULL) + { + ase_awk_freerex (run->awk, run->global.rs); + } + run->global.rs = rex; + } + + if (val->type != ASE_AWK_VAL_STR) ASE_AWK_FREE (run->awk, rs_ptr); + } + else if (idx == ASE_AWK_GLOBAL_SUBSEP) + { + ase_char_t* subsep_ptr; + ase_size_t subsep_len; + + subsep_ptr = ase_awk_valtostr ( + run, val, ASE_AWK_VALTOSTR_CLEAR, ASE_NULL, &subsep_len); + if (subsep_ptr == ASE_NULL) return -1; + + if (run->global.subsep.ptr != ASE_NULL) + ASE_AWK_FREE (run->awk, run->global.subsep.ptr); + run->global.subsep.ptr = subsep_ptr; + run->global.subsep.len = subsep_len; + } + + ase_awk_refdownval (run, old); + STACK_GLOBAL(run,idx) = val; + ase_awk_refupval (run, val); + + return 0; +} + +void ase_awk_setretval (ase_awk_run_t* run, ase_awk_val_t* val) +{ + ase_awk_refdownval (run, STACK_RETVAL(run)); + STACK_RETVAL(run) = val; + /* should use the same trick as __run_return_statement */ + ase_awk_refupval (run, val); +} + +int ase_awk_setfilename ( + ase_awk_run_t* run, const ase_char_t* name, ase_size_t len) +{ + ase_awk_val_t* tmp; + int n; + + if (len == 0) tmp = ase_awk_val_zls; + else + { + tmp = ase_awk_makestrval (run, name, len); + if (tmp == ASE_NULL) + { + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return -1; + } + } + + ase_awk_refupval (run, tmp); + n = ase_awk_setglobal (run, ASE_AWK_GLOBAL_FILENAME, tmp); + ase_awk_refdownval (run, tmp); + + return n; +} + +int ase_awk_setofilename ( + ase_awk_run_t* run, const ase_char_t* name, ase_size_t len) +{ + ase_awk_val_t* tmp; + int n; + + if (run->awk->option & ASE_AWK_NEXTOFILE) + { + if (len == 0) tmp = ase_awk_val_zls; + else + { + tmp = ase_awk_makestrval (run, name, len); + if (tmp == ASE_NULL) + { + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return -1; + } + } + + ase_awk_refupval (run, tmp); + n = ase_awk_setglobal (run, ASE_AWK_GLOBAL_OFILENAME, tmp); + ase_awk_refdownval (run, tmp); + } + else n = 0; + + return n; +} + +ase_awk_t* ase_awk_getrunawk (ase_awk_run_t* run) +{ + return run->awk; +} + +void* ase_awk_getruncustomdata (ase_awk_run_t* run) +{ + return run->custom_data; +} + +ase_awk_map_t* ase_awk_getrunnamedvarmap (ase_awk_run_t* awk) +{ + return &awk->named; +} + +int ase_awk_run (ase_awk_t* awk, + const ase_char_t* main, + ase_awk_runios_t* runios, + ase_awk_runcbs_t* runcbs, + ase_awk_runarg_t* runarg, + void* custom_data) +{ + ase_awk_run_t* run; + int n; + + /* clear the awk error code */ + ase_awk_seterror (awk, ASE_AWK_ENOERR, 0, ASE_NULL, 0); + + /* check if the code has ever been parsed */ + if (awk->tree.nglobals == 0 && + awk->tree.begin == ASE_NULL && + awk->tree.end == ASE_NULL && + awk->tree.chain_size == 0 && + ase_awk_map_getsize(&awk->tree.afns) == 0) + { + /* if not, deny the run */ + ase_awk_seterror (awk, ASE_AWK_ENOPER, 0, ASE_NULL, 0); + return -1; + } + + /* allocate the storage for the run object */ + run = (ase_awk_run_t*) ASE_AWK_MALLOC (awk, ASE_SIZEOF(ase_awk_run_t)); + if (run == ASE_NULL) + { + /* if it fails, the failure is reported thru + * the awk object */ + ase_awk_seterror (awk, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return -1; + } + + /* clear the run object space */ + ase_memset (run, 0, ASE_SIZEOF(ase_awk_run_t)); + + /* initialize the run object */ + if (__init_run (run, awk, runios, custom_data) == -1) + { + ASE_AWK_FREE (awk, run); + return -1; + } + + /* clear the run error */ + run->errnum = ASE_AWK_ENOERR; + run->errlin = 0; + run->errmsg[0] = ASE_T('\0'); + + run->cbs = runcbs; + + /* execute the start callback if it exists */ + if (runcbs != ASE_NULL && runcbs->on_start != ASE_NULL) + { + runcbs->on_start (run, runcbs->custom_data); + } + + /* enter the main run loop */ + n = run_main (run, main, runarg); + if (n == -1) + { + /* if no callback is specified, awk's error number + * is updated with the run's error number */ + if (runcbs == ASE_NULL) + { + awk->errnum = run->errnum; + awk->errlin = run->errlin; + + ase_strxcpy ( + awk->errmsg, ASE_COUNTOF(awk->errmsg), + run->errmsg); + } + else + { + ase_awk_seterror (awk, ASE_AWK_ERUNTIME, 0, ASE_NULL, 0); + } + } + + /* the run loop ended. execute the end callback if it exists */ + if (runcbs != ASE_NULL && runcbs->on_end != ASE_NULL) + { + runcbs->on_end (run, + ((n == -1)? run->errnum: ASE_AWK_ENOERR), + runcbs->custom_data); + + /* when using callbacks, this function always returns 0 + * after the start callbacks has been triggered */ + n = 0; + } + + /* uninitialize the run object */ + __deinit_run (run); + + ASE_AWK_FREE (awk, run); + return n; +} + +int ase_awk_stop (ase_awk_run_t* run) +{ + run->exit_level = EXIT_ABORT; + return 0; +} + +static void __free_namedval (void* run, void* val) +{ + ase_awk_refdownval ((ase_awk_run_t*)run, val); +} + +static int __init_run ( + ase_awk_run_t* run, ase_awk_t* awk, + ase_awk_runios_t* runios, void* custom_data) +{ + run->awk = awk; + run->custom_data = custom_data; + + run->stack = ASE_NULL; + run->stack_top = 0; + run->stack_base = 0; + run->stack_limit = 0; + + run->exit_level = EXIT_NONE; + + run->icache_count = 0; + run->rcache_count = 0; + run->fcache_count = 0; + + run->errnum = ASE_AWK_ENOERR; + run->errlin = 0; + run->errmsg[0] = ASE_T('\0'); + + run->inrec.buf_pos = 0; + run->inrec.buf_len = 0; + run->inrec.flds = ASE_NULL; + run->inrec.nflds = 0; + run->inrec.maxflds = 0; + run->inrec.d0 = ase_awk_val_nil; + if (ase_str_open ( + &run->inrec.line, + DEF_BUF_CAPA, &run->awk->prmfns.mmgr) == ASE_NULL) + { + ase_awk_seterror (awk, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return -1; + } + + if (ase_str_open ( + &run->format.out, 256, &run->awk->prmfns.mmgr) == ASE_NULL) + { + ase_str_close (&run->inrec.line); + ase_awk_seterror (awk, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return -1; + } + + if (ase_str_open ( + &run->format.fmt, 256, &run->awk->prmfns.mmgr) == ASE_NULL) + { + ase_str_close (&run->format.out); + ase_str_close (&run->inrec.line); + ase_awk_seterror (awk, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return -1; + } + + if (ase_awk_map_open (&run->named, + run, DEF_BUF_CAPA, __free_namedval, run->awk) == ASE_NULL) + { + ase_str_close (&run->format.fmt); + ase_str_close (&run->format.out); + ase_str_close (&run->inrec.line); + ase_awk_seterror (awk, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return -1; + } + + run->format.tmp.ptr = (ase_char_t*) + ASE_AWK_MALLOC (run->awk, 4096*ASE_SIZEOF(ase_char_t*)); + if (run->format.tmp.ptr == ASE_NULL) + { + ase_awk_map_close (&run->named); + ase_str_close (&run->format.fmt); + ase_str_close (&run->format.out); + ase_str_close (&run->inrec.line); + ase_awk_seterror (awk, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return -1; + } + run->format.tmp.len = 4096; + run->format.tmp.inc = 4096*2; + + if (run->awk->tree.chain_size > 0) + { + run->pattern_range_state = (ase_byte_t*) ASE_AWK_MALLOC ( + run->awk, run->awk->tree.chain_size*ASE_SIZEOF(ase_byte_t)); + if (run->pattern_range_state == ASE_NULL) + { + ASE_AWK_FREE (run->awk, run->format.tmp.ptr); + ase_awk_map_close (&run->named); + ase_str_close (&run->format.fmt); + ase_str_close (&run->format.out); + ase_str_close (&run->inrec.line); + ase_awk_seterror (awk, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return -1; + } + + ase_memset ( + run->pattern_range_state, 0, + run->awk->tree.chain_size * ASE_SIZEOF(ase_byte_t)); + } + else run->pattern_range_state = ASE_NULL; + + if (runios != ASE_NULL) + { + run->extio.handler[ASE_AWK_EXTIO_PIPE] = runios->pipe; + run->extio.handler[ASE_AWK_EXTIO_COPROC] = runios->coproc; + run->extio.handler[ASE_AWK_EXTIO_FILE] = runios->file; + run->extio.handler[ASE_AWK_EXTIO_CONSOLE] = runios->console; + run->extio.custom_data = runios->custom_data; + run->extio.chain = ASE_NULL; + } + + run->global.rs = ASE_NULL; + run->global.fs = ASE_NULL; + run->global.ignorecase = 0; + + run->depth.max.block = awk->run.depth.max.block; + run->depth.max.expr = awk->run.depth.max.expr; + run->depth.cur.block = 0; + run->depth.cur.expr = 0; + + return 0; +} + +static void __deinit_run (ase_awk_run_t* run) +{ + if (run->pattern_range_state != ASE_NULL) + ASE_AWK_FREE (run->awk, run->pattern_range_state); + + /* close all pending extio's */ + /* TODO: what if this operation fails? */ + ase_awk_clearextio (run); + ASE_ASSERT (run->extio.chain == ASE_NULL); + + if (run->global.rs != ASE_NULL) + { + ASE_AWK_FREE (run->awk, run->global.rs); + run->global.rs = ASE_NULL; + } + if (run->global.fs != ASE_NULL) + { + ASE_AWK_FREE (run->awk, run->global.fs); + run->global.fs = ASE_NULL; + } + + if (run->global.convfmt.ptr != ASE_NULL && + run->global.convfmt.ptr != DEFAULT_CONVFMT) + { + ASE_AWK_FREE (run->awk, run->global.convfmt.ptr); + run->global.convfmt.ptr = ASE_NULL; + run->global.convfmt.len = 0; + } + + if (run->global.ofmt.ptr != ASE_NULL && + run->global.ofmt.ptr != DEFAULT_OFMT) + { + ASE_AWK_FREE (run->awk, run->global.ofmt.ptr); + run->global.ofmt.ptr = ASE_NULL; + run->global.ofmt.len = 0; + } + + if (run->global.ofs.ptr != ASE_NULL && + run->global.ofs.ptr != DEFAULT_OFS) + { + ASE_AWK_FREE (run->awk, run->global.ofs.ptr); + run->global.ofs.ptr = ASE_NULL; + run->global.ofs.len = 0; + } + + if (run->global.ors.ptr != ASE_NULL && + run->global.ors.ptr != DEFAULT_ORS && + run->global.ors.ptr != DEFAULT_ORS_CRLF) + { + ASE_AWK_FREE (run->awk, run->global.ors.ptr); + run->global.ors.ptr = ASE_NULL; + run->global.ors.len = 0; + } + + if (run->global.subsep.ptr != ASE_NULL && + run->global.subsep.ptr != DEFAULT_SUBSEP) + { + ASE_AWK_FREE (run->awk, run->global.subsep.ptr); + run->global.subsep.ptr = ASE_NULL; + run->global.subsep.len = 0; + } + + ASE_AWK_FREE (run->awk, run->format.tmp.ptr); + run->format.tmp.ptr = ASE_NULL; + run->format.tmp.len = 0; + ase_str_close (&run->format.fmt); + ase_str_close (&run->format.out); + + /* destroy input record. ase_awk_clrrec should be called + * before the run stack has been destroyed because it may try + * to change the value to ASE_AWK_GLOBAL_NF. */ + ase_awk_clrrec (run, ase_false); + if (run->inrec.flds != ASE_NULL) + { + ASE_AWK_FREE (run->awk, run->inrec.flds); + run->inrec.flds = ASE_NULL; + run->inrec.maxflds = 0; + } + ase_str_close (&run->inrec.line); + + /* destroy run stack */ + if (run->stack != ASE_NULL) + { + ASE_ASSERT (run->stack_top == 0); + + ASE_AWK_FREE (run->awk, run->stack); + run->stack = ASE_NULL; + run->stack_top = 0; + run->stack_base = 0; + run->stack_limit = 0; + } + + /* destroy named variables */ + ase_awk_map_close (&run->named); + + /* destroy values in free list */ + while (run->icache_count > 0) + { + ase_awk_val_int_t* tmp = run->icache[--run->icache_count]; + ase_awk_freeval (run, (ase_awk_val_t*)tmp, ase_false); + } + + while (run->rcache_count > 0) + { + ase_awk_val_real_t* tmp = run->rcache[--run->rcache_count]; + ase_awk_freeval (run, (ase_awk_val_t*)tmp, ase_false); + } + + while (run->fcache_count > 0) + { + ase_awk_val_ref_t* tmp = run->fcache[--run->fcache_count]; + ase_awk_freeval (run, (ase_awk_val_t*)tmp, ase_false); + } +} + +static int __build_runarg ( + ase_awk_run_t* run, ase_awk_runarg_t* runarg, ase_size_t* nargs) +{ + ase_awk_runarg_t* p; + ase_size_t argc; + ase_awk_val_t* v_argc; + ase_awk_val_t* v_argv; + ase_awk_val_t* v_tmp; + ase_char_t key[ASE_SIZEOF(ase_long_t)*8+2]; + ase_size_t key_len; + + v_argv = ase_awk_makemapval (run); + if (v_argv == ASE_NULL) + { + ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return -1; + } + ase_awk_refupval (run, v_argv); + + if (runarg == ASE_NULL) argc = 0; + else + { + for (argc = 0, p = runarg; p->ptr != ASE_NULL; argc++, p++) + { + v_tmp = ase_awk_makestrval (run, p->ptr, p->len); + if (v_tmp == ASE_NULL) + { + ase_awk_refdownval (run, v_argv); + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return -1; + } + + key_len = ase_awk_longtostr ( + argc, 10, ASE_NULL, key, ASE_COUNTOF(key)); + ASE_ASSERT (key_len != (ase_size_t)-1); + + /* increment reference count of v_tmp in advance as if + * it has successfully been assigned into ARGV. */ + ase_awk_refupval (run, v_tmp); + + if (ase_awk_map_putx ( + ((ase_awk_val_map_t*)v_argv)->map, + key, key_len, v_tmp, ASE_NULL) == -1) + { + /* if the assignment operation fails, decrements + * the reference of v_tmp to free it */ + ase_awk_refdownval (run, v_tmp); + + /* the values previously assigned into the + * map will be freeed when v_argv is freed */ + ase_awk_refdownval (run, v_argv); + + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return -1; + } + } + } + + v_argc = ase_awk_makeintval (run, (ase_long_t)argc); + if (v_argc == ASE_NULL) + { + ase_awk_refdownval (run, v_argv); + ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return -1; + } + + ase_awk_refupval (run, v_argc); + + ASE_ASSERT ( + STACK_GLOBAL(run,ASE_AWK_GLOBAL_ARGC) == ase_awk_val_nil); + + if (ase_awk_setglobal (run, ASE_AWK_GLOBAL_ARGC, v_argc) == -1) + { + ase_awk_refdownval (run, v_argc); + ase_awk_refdownval (run, v_argv); + return -1; + } + + if (ase_awk_setglobal (run, ASE_AWK_GLOBAL_ARGV, v_argv) == -1) + { + /* ARGC is assigned nil when ARGV assignment has failed. + * However, this requires preconditions, as follows: + * 1. __build_runarg should be called in a proper place + * as it is not a generic-purpose routine. + * 2. ARGC should be nil before __build_runarg is called + * If the restoration fails, nothing can salvage it. */ + ase_awk_setglobal (run, ASE_AWK_GLOBAL_ARGC, ase_awk_val_nil); + ase_awk_refdownval (run, v_argc); + ase_awk_refdownval (run, v_argv); + return -1; + } + + ase_awk_refdownval (run, v_argc); + ase_awk_refdownval (run, v_argv); + + *nargs = argc; + return 0; +} + +static void __cleanup_globals (ase_awk_run_t* run) +{ + ase_size_t nglobals = run->awk->tree.nglobals; + while (nglobals > 0) + { + --nglobals; + ase_awk_refdownval (run, STACK_GLOBAL(run,nglobals)); + STACK_GLOBAL (run, nglobals) = ase_awk_val_nil; + } +} + +static int __update_fnr (ase_awk_run_t* run, ase_size_t fnr) +{ + ase_awk_val_t* tmp; + + tmp = ase_awk_makeintval (run, fnr); + if (tmp == ASE_NULL) + { + ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return -1; + } + + ase_awk_refupval (run, tmp); + if (ase_awk_setglobal (run, ASE_AWK_GLOBAL_FNR, tmp) == -1) + { + ase_awk_refdownval (run, tmp); + return -1; + } + + ase_awk_refdownval (run, tmp); + run->global.fnr = fnr; + return 0; +} + +static int __set_globals_to_default (ase_awk_run_t* run) +{ + struct __gtab_t + { + int idx; + const ase_char_t* str; + }; + + struct __gtab_t gtab[] = + { + { ASE_AWK_GLOBAL_CONVFMT, DEFAULT_CONVFMT }, + { ASE_AWK_GLOBAL_FILENAME, ASE_NULL }, + { ASE_AWK_GLOBAL_OFILENAME, ASE_NULL }, + { ASE_AWK_GLOBAL_OFMT, DEFAULT_OFMT }, + { ASE_AWK_GLOBAL_OFS, DEFAULT_OFS }, + { ASE_AWK_GLOBAL_ORS, DEFAULT_ORS }, + { ASE_AWK_GLOBAL_SUBSEP, DEFAULT_SUBSEP }, + }; + + ase_awk_val_t* tmp; + ase_size_t i, j; + + if (run->awk->option & ASE_AWK_CRLF) + { + /* ugly */ + gtab[5].str = DEFAULT_ORS_CRLF; + } + + for (i = 0; i < ASE_COUNTOF(gtab); i++) + { + if (gtab[i].str == ASE_NULL || gtab[i].str[0] == ASE_T('\0')) + { + tmp = ase_awk_val_zls; + } + else + { + tmp = ase_awk_makestrval0 (run, gtab[i].str); + if (tmp == ASE_NULL) + { + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return -1; + } + } + + ase_awk_refupval (run, tmp); + + ASE_ASSERT ( + STACK_GLOBAL(run,gtab[i].idx) == ase_awk_val_nil); + + if (ase_awk_setglobal (run, gtab[i].idx, tmp) == -1) + { + for (j = 0; j < i; j++) + { + ase_awk_setglobal ( + run, gtab[i].idx, ase_awk_val_nil); + } + + ase_awk_refdownval (run, tmp); + return -1; + } + + ase_awk_refdownval (run, tmp); + } + + return 0; +} + +static int run_main ( + ase_awk_run_t* run, const ase_char_t* main, + ase_awk_runarg_t* runarg) +{ + ase_size_t nglobals, nargs, nrunargs, i; + ase_size_t saved_stack_top; + ase_awk_val_t* v; + int n; + + ASE_ASSERT (run->stack_base == 0 && run->stack_top == 0); + + /* secure space for global variables */ + saved_stack_top = run->stack_top; + + nglobals = run->awk->tree.nglobals; + + while (nglobals > 0) + { + --nglobals; + if (__raw_push(run,ase_awk_val_nil) == -1) + { + /* restore the stack_top with the saved value + * instead of calling __raw_pop as many times as + * the successful __raw_push. it is ok because + * the values pushed so far are all ase_awk_val_nil */ + run->stack_top = saved_stack_top; + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return -1; + } + } + + if (ase_awk_setglobal (run, ASE_AWK_GLOBAL_NR, ase_awk_val_zero) == -1) + { + /* it can simply restore the top of the stack this way + * because the values pused onto the stack so far are + * all ase_awk_val_nils */ + run->stack_top = saved_stack_top; + return -1; + } + + if (ase_awk_setglobal (run, ASE_AWK_GLOBAL_NF, ase_awk_val_zero) == -1) + { + /* it can simply restore the top of the stack this way + * because the values pused onto the stack so far are + * all ase_awk_val_nils and ase_awk_val_zeros */ + run->stack_top = saved_stack_top; + return -1; + } + + if (__build_runarg (run, runarg, &nrunargs) == -1) + { + /* it can simply restore the top of the stack this way + * because the values pused onto the stack so far are + * all ase_awk_val_nils and ase_awk_val_zeros and + * __build_runarg doesn't push other values than them + * when it has failed */ + run->stack_top = saved_stack_top; + return -1; + } + + run->exit_level = EXIT_NONE; + + n = __update_fnr (run, 0); + if (n == 0) n = __set_globals_to_default (run); + if (n == 0 && main != ASE_NULL) + { + /* run the given function */ + ase_awk_nde_call_t nde; + + nde.type = ASE_AWK_NDE_AFN; + nde.line = 0; + nde.next = ASE_NULL; + nde.what.afn.name.ptr = (ase_char_t*)main; + nde.what.afn.name.len = ase_strlen(main); + + nde.args = ASE_NULL; + nde.nargs = 0; + + if (runarg != ASE_NULL) + { + if (!(run->awk->option & ASE_AWK_ARGSTOMAIN)) + { + /* if the option is not set, the arguments + * are not passed to the main function as + * parameters */ + nrunargs = 0; + } + + /* prepare to pass the arguments to the main function */ + for (i = nrunargs; i > 0; ) + { + ase_awk_nde_str_t* tmp, * tmp2; + + i--; + tmp = (ase_awk_nde_str_t*) ASE_AWK_MALLOC ( + run->awk, ASE_SIZEOF(*tmp)); + if (tmp == ASE_NULL) + { + tmp = (ase_awk_nde_str_t*)nde.args; + while (tmp != ASE_NULL) + { + tmp2 = (ase_awk_nde_str_t*)tmp->next; + ASE_AWK_FREE (run->awk, tmp->buf); + ASE_AWK_FREE (run->awk, tmp); + tmp = tmp2; + } + __cleanup_globals (run); + run->stack_top = saved_stack_top; + + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return -1; + } + + tmp->type = ASE_AWK_NDE_STR; + tmp->buf = ase_strxdup ( + runarg[i].ptr, runarg[i].len, + &run->awk->prmfns.mmgr); + if (tmp->buf == ASE_NULL) + { + ASE_AWK_FREE (run->awk, tmp); + tmp = (ase_awk_nde_str_t*)nde.args; + while (tmp != ASE_NULL) + { + tmp2 = (ase_awk_nde_str_t*)tmp->next; + ASE_AWK_FREE (run->awk, tmp->buf); + ASE_AWK_FREE (run->awk, tmp); + tmp = tmp2; + } + __cleanup_globals (run); + run->stack_top = saved_stack_top; + + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return -1; + } + + tmp->len = runarg[i].len; + tmp->next = nde.args; + nde.args = (ase_awk_nde_t*)tmp; + nde.nargs++; + } + + ASE_ASSERT (nrunargs == nde.nargs); + } + + v = __eval_afn (run, (ase_awk_nde_t*)&nde); + if (v == ASE_NULL) n = -1; + else + { + ase_awk_refupval (run, v); + + if (run->cbs != ASE_NULL && run->cbs->on_return != ASE_NULL) + { + run->cbs->on_return (run, v, run->cbs->custom_data); + } + + ase_awk_refdownval (run, v); + } + + if (nde.args != ASE_NULL) ase_awk_clrpt (run->awk, nde.args); + } + else if (n == 0) + { + /* no main function is specified. + * run the normal patter blocks including BEGIN and END */ + saved_stack_top = run->stack_top; + + if (__raw_push(run,(void*)run->stack_base) == -1) + { + /* restore the stack top in a cheesy(?) way */ + run->stack_top = saved_stack_top; + /* pops off global variables in a decent way */ + __cleanup_globals (run); + __raw_pop_times (run, run->awk->tree.nglobals); + + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return -1; + } + + if (__raw_push(run,(void*)saved_stack_top) == -1) + { + run->stack_top = saved_stack_top; + __cleanup_globals (run); + __raw_pop_times (run, run->awk->tree.nglobals); + + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return -1; + } + + /* secure space for a return value */ + if (__raw_push(run,ase_awk_val_nil) == -1) + { + run->stack_top = saved_stack_top; + __cleanup_globals (run); + __raw_pop_times (run, run->awk->tree.nglobals); + + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return -1; + } + + /* secure space for nargs */ + if (__raw_push(run,ase_awk_val_nil) == -1) + { + run->stack_top = saved_stack_top; + __cleanup_globals (run); + __raw_pop_times (run, run->awk->tree.nglobals); + + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return -1; + } + + run->stack_base = saved_stack_top; + + /* set nargs to zero */ + nargs = 0; + STACK_NARGS(run) = (void*)nargs; + + /* stack set up properly. ready to exeucte statement blocks */ + if (n == 0 && + run->awk->tree.begin != ASE_NULL && + run->exit_level != EXIT_ABORT) + { + ase_awk_nde_blk_t* blk; + + blk = (ase_awk_nde_blk_t*)run->awk->tree.begin; + ASE_ASSERT (blk->type == ASE_AWK_NDE_BLK); + + run->active_block = blk; + run->exit_level = EXIT_NONE; + if (__run_block (run, blk) == -1) n = -1; + } + + if (n == 0 && + (run->awk->tree.chain != ASE_NULL || + run->awk->tree.end != ASE_NULL) && + run->exit_level != EXIT_ABORT) + { + if (__run_pattern_blocks (run) == -1) n = -1; + } + + if (n == 0 && + run->awk->tree.end != ASE_NULL && + run->exit_level != EXIT_ABORT) + { + ase_awk_nde_blk_t* blk; + + blk = (ase_awk_nde_blk_t*)run->awk->tree.end; + ASE_ASSERT (blk->type == ASE_AWK_NDE_BLK); + + run->active_block = blk; + run->exit_level = EXIT_NONE; + if (__run_block (run, blk) == -1) n = -1; + } + + /* restore stack */ + nargs = (ase_size_t)STACK_NARGS(run); + ASE_ASSERT (nargs == 0); + for (i = 0; i < nargs; i++) + { + ase_awk_refdownval (run, STACK_ARG(run,i)); + } + + v = STACK_RETVAL(run); + if (n == 0) + { + if (run->cbs != ASE_NULL && run->cbs->on_return != ASE_NULL) + { + run->cbs->on_return (run, v, run->cbs->custom_data); + } + } + /* end the life of the global return value */ + ase_awk_refdownval (run, v); + + run->stack_top = + (ase_size_t)run->stack[run->stack_base+1]; + run->stack_base = + (ase_size_t)run->stack[run->stack_base+0]; + } + + /* pops off the global variables */ + nglobals = run->awk->tree.nglobals; + while (nglobals > 0) + { + --nglobals; + ase_awk_refdownval (run, STACK_GLOBAL(run,nglobals)); + __raw_pop (run); + } + + /* reset the exit level */ + run->exit_level = EXIT_NONE; + + return n; +} + +static int __run_pattern_blocks (ase_awk_run_t* run) +{ + int n; + +#define ADJUST_ERROR_LINE(run) \ + if (run->awk->tree.chain != ASE_NULL) \ + { \ + if (run->awk->tree.chain->pattern != ASE_NULL) \ + run->errlin = run->awk->tree.chain->pattern->line; \ + else if (run->awk->tree.chain->action != ASE_NULL) \ + run->errlin = run->awk->tree.chain->action->line; \ + } \ + else if (run->awk->tree.end != ASE_NULL) \ + { \ + run->errlin = run->awk->tree.end->line; \ + } + + run->inrec.buf_pos = 0; + run->inrec.buf_len = 0; + run->inrec.eof = ase_false; + + /* run each pattern block */ + while (run->exit_level != EXIT_GLOBAL && + run->exit_level != EXIT_ABORT) + { + run->exit_level = EXIT_NONE; + + n = __read_record (run); + if (n == -1) + { + ADJUST_ERROR_LINE (run); + return -1; /* error */ + } + if (n == 0) break; /* end of input */ + + if (__update_fnr (run, run->global.fnr+1) == -1) + { + ADJUST_ERROR_LINE (run); + return -1; + } + + if (run->awk->tree.chain != ASE_NULL) + { + if (__run_pattern_block_chain ( + run, run->awk->tree.chain) == -1) return -1; + } + } + +#undef ADJUST_ERROR_LINE + return 0; +} + +static int __run_pattern_block_chain (ase_awk_run_t* run, ase_awk_chain_t* chain) +{ + ase_size_t block_no = 0; + + while (run->exit_level != EXIT_GLOBAL && + run->exit_level != EXIT_ABORT && chain != ASE_NULL) + { + if (run->exit_level == EXIT_NEXT) + { + run->exit_level = EXIT_NONE; + break; + } + + if (__run_pattern_block (run, chain, block_no) == -1) return -1; + + chain = chain->next; + block_no++; + } + + return 0; +} + +static int __run_pattern_block ( + ase_awk_run_t* run, ase_awk_chain_t* chain, ase_size_t block_no) +{ + ase_awk_nde_t* ptn; + ase_awk_nde_blk_t* blk; + + ptn = chain->pattern; + blk = (ase_awk_nde_blk_t*)chain->action; + + if (ptn == ASE_NULL) + { + /* just execute the block */ + run->active_block = blk; + if (__run_block (run, blk) == -1) return -1; + } + else + { + if (ptn->next == ASE_NULL) + { + /* pattern { ... } */ + ase_awk_val_t* v1; + + v1 = __eval_expression (run, ptn); + if (v1 == ASE_NULL) return -1; + + ase_awk_refupval (run, v1); + + if (ase_awk_valtobool (run, v1)) + { + run->active_block = blk; + if (__run_block (run, blk) == -1) + { + ase_awk_refdownval (run, v1); + return -1; + } + } + + ase_awk_refdownval (run, v1); + } + else + { + /* pattern, pattern { ... } */ + ASE_ASSERT (ptn->next->next == ASE_NULL); + ASE_ASSERT (run->pattern_range_state != ASE_NULL); + + if (run->pattern_range_state[block_no] == 0) + { + ase_awk_val_t* v1; + + v1 = __eval_expression (run, ptn); + if (v1 == ASE_NULL) return -1; + ase_awk_refupval (run, v1); + + if (ase_awk_valtobool (run, v1)) + { + run->active_block = blk; + if (__run_block (run, blk) == -1) + { + ase_awk_refdownval (run, v1); + return -1; + } + + run->pattern_range_state[block_no] = 1; + } + + ase_awk_refdownval (run, v1); + } + else if (run->pattern_range_state[block_no] == 1) + { + ase_awk_val_t* v2; + + v2 = __eval_expression (run, ptn->next); + if (v2 == ASE_NULL) return -1; + ase_awk_refupval (run, v2); + + run->active_block = blk; + if (__run_block (run, blk) == -1) + { + ase_awk_refdownval (run, v2); + return -1; + } + + if (ase_awk_valtobool (run, v2)) + run->pattern_range_state[block_no] = 0; + + ase_awk_refdownval (run, v2); + } + } + } + + return 0; +} + +static int __run_block (ase_awk_run_t* run, ase_awk_nde_blk_t* nde) +{ + int n; + + if (run->depth.max.block > 0 && + run->depth.cur.block >= run->depth.max.block) + { + ase_awk_setrunerror ( + run, ASE_AWK_EBLKNST, nde->line, ASE_NULL, 0); + return -1;; + } + + run->depth.cur.block++; + n = __run_block0 (run, nde); + run->depth.cur.block--; + + return n; +} + +static int __run_block0 (ase_awk_run_t* run, ase_awk_nde_blk_t* nde) +{ + ase_awk_nde_t* p; + ase_size_t nlocals; + ase_size_t saved_stack_top; + int n = 0; + + if (nde == ASE_NULL) + { + /* blockless pattern - execute print $0*/ + ase_awk_refupval (run, run->inrec.d0); + + n = ase_awk_writeextio_str (run, + ASE_AWK_OUT_CONSOLE, ASE_T(""), + ASE_STR_BUF(&run->inrec.line), + ASE_STR_LEN(&run->inrec.line)); + if (n == -1) + { + ase_awk_refdownval (run, run->inrec.d0); + + /* adjust the error line */ + run->errlin = nde->line; + + return -1; + } + + n = ase_awk_writeextio_str ( + run, ASE_AWK_OUT_CONSOLE, ASE_T(""), + run->global.ors.ptr, run->global.ors.len); + if (n == -1) + { + ase_awk_refdownval (run, run->inrec.d0); + + /* adjust the error line */ + run->errlin = nde->line; + + return -1; + } + + ase_awk_refdownval (run, run->inrec.d0); + return 0; + } + + ASE_ASSERT (nde->type == ASE_AWK_NDE_BLK); + + p = nde->body; + nlocals = nde->nlocals; + +#ifdef DEBUG_RUN + ase_dprintf ( + ASE_T("securing space for local variables nlocals = %d\n"), + (int)nlocals); +#endif + + saved_stack_top = run->stack_top; + + /* secure space for local variables */ + while (nlocals > 0) + { + --nlocals; + if (__raw_push(run,ase_awk_val_nil) == -1) + { + /* restore stack top */ + run->stack_top = saved_stack_top; + return -1; + } + + /* refupval is not required for ase_awk_val_nil */ + } + +#ifdef DEBUG_RUN + ase_dprintf (ASE_T("executing block statements\n")); +#endif + + while (p != ASE_NULL && run->exit_level == EXIT_NONE) + { + if (__run_statement (run, p) == -1) + { + n = -1; + break; + } + p = p->next; + } + + /* pop off local variables */ +#ifdef DEBUG_RUN + ase_dprintf (ASE_T("popping off local variables\n")); +#endif + nlocals = nde->nlocals; + while (nlocals > 0) + { + --nlocals; + ase_awk_refdownval (run, STACK_LOCAL(run,nlocals)); + __raw_pop (run); + } + + return n; +} + +static int __run_statement (ase_awk_run_t* run, ase_awk_nde_t* nde) +{ + if (run->cbs != ASE_NULL && run->cbs->on_statement != ASE_NULL) + { + run->cbs->on_statement (run, nde->line, run->custom_data); + } + + switch (nde->type) + { + case ASE_AWK_NDE_NULL: + { + /* do nothing */ + break; + } + + case ASE_AWK_NDE_BLK: + { + if (__run_block (run, + (ase_awk_nde_blk_t*)nde) == -1) return -1; + break; + } + + case ASE_AWK_NDE_IF: + { + if (__run_if (run, + (ase_awk_nde_if_t*)nde) == -1) return -1; + break; + } + + case ASE_AWK_NDE_WHILE: + case ASE_AWK_NDE_DOWHILE: + { + if (__run_while (run, + (ase_awk_nde_while_t*)nde) == -1) return -1; + break; + } + + case ASE_AWK_NDE_FOR: + { + if (__run_for (run, + (ase_awk_nde_for_t*)nde) == -1) return -1; + break; + } + + case ASE_AWK_NDE_FOREACH: + { + if (__run_foreach (run, + (ase_awk_nde_foreach_t*)nde) == -1) return -1; + break; + } + + case ASE_AWK_NDE_BREAK: + { + if (__run_break (run, + (ase_awk_nde_break_t*)nde) == -1) return -1; + break; + } + + case ASE_AWK_NDE_CONTINUE: + { + if (__run_continue (run, + (ase_awk_nde_continue_t*)nde) == -1) return -1; + break; + } + + case ASE_AWK_NDE_RETURN: + { + if (__run_return (run, + (ase_awk_nde_return_t*)nde) == -1) return -1; + break; + } + + case ASE_AWK_NDE_EXIT: + { + if (__run_exit (run, + (ase_awk_nde_exit_t*)nde) == -1) return -1; + break; + } + + case ASE_AWK_NDE_NEXT: + { + if (__run_next (run, + (ase_awk_nde_next_t*)nde) == -1) return -1; + break; + } + + case ASE_AWK_NDE_NEXTFILE: + { + if (__run_nextfile (run, + (ase_awk_nde_nextfile_t*)nde) == -1) return -1; + break; + } + + case ASE_AWK_NDE_DELETE: + { + if (__run_delete (run, + (ase_awk_nde_delete_t*)nde) == -1) return -1; + break; + } + + case ASE_AWK_NDE_PRINT: + { + if (__run_print (run, + (ase_awk_nde_print_t*)nde) == -1) return -1; + break; + } + + case ASE_AWK_NDE_PRINTF: + { + if (__run_printf (run, + (ase_awk_nde_print_t*)nde) == -1) return -1; + break; + } + + default: + { + ase_awk_val_t* v; + v = __eval_expression (run, nde); + if (v == ASE_NULL) return -1; + + /* destroy the value if not referenced */ + ase_awk_refupval (run, v); + ase_awk_refdownval (run, v); + + break; + } + } + + return 0; +} + +static int __run_if (ase_awk_run_t* run, ase_awk_nde_if_t* nde) +{ + ase_awk_val_t* test; + int n = 0; + + /* the test expression for the if statement cannot have + * chained expressions. this should not be allowed by the + * parser first of all */ + ASE_ASSERT (nde->test->next == ASE_NULL); + + test = __eval_expression (run, nde->test); + if (test == ASE_NULL) return -1; + + ase_awk_refupval (run, test); + if (ase_awk_valtobool (run, test)) + { + n = __run_statement (run, nde->then_part); + } + else if (nde->else_part != ASE_NULL) + { + n = __run_statement (run, nde->else_part); + } + + ase_awk_refdownval (run, test); /* TODO: is this correct?*/ + return n; +} + +static int __run_while (ase_awk_run_t* run, ase_awk_nde_while_t* nde) +{ + ase_awk_val_t* test; + + if (nde->type == ASE_AWK_NDE_WHILE) + { + /* no chained expressions are allowed for the test + * expression of the while statement */ + ASE_ASSERT (nde->test->next == ASE_NULL); + + while (1) + { + test = __eval_expression (run, nde->test); + if (test == ASE_NULL) return -1; + + ase_awk_refupval (run, test); + + if (ase_awk_valtobool (run, test)) + { + if (__run_statement(run,nde->body) == -1) + { + ase_awk_refdownval (run, test); + return -1; + } + } + else + { + ase_awk_refdownval (run, test); + break; + } + + ase_awk_refdownval (run, test); + + if (run->exit_level == EXIT_BREAK) + { + run->exit_level = EXIT_NONE; + break; + } + else if (run->exit_level == EXIT_CONTINUE) + { + run->exit_level = EXIT_NONE; + } + else if (run->exit_level != EXIT_NONE) break; + } + } + else if (nde->type == ASE_AWK_NDE_DOWHILE) + { + /* no chained expressions are allowed for the test + * expression of the while statement */ + ASE_ASSERT (nde->test->next == ASE_NULL); + + do + { + if (__run_statement(run,nde->body) == -1) return -1; + + if (run->exit_level == EXIT_BREAK) + { + run->exit_level = EXIT_NONE; + break; + } + else if (run->exit_level == EXIT_CONTINUE) + { + run->exit_level = EXIT_NONE; + } + else if (run->exit_level != EXIT_NONE) break; + + test = __eval_expression (run, nde->test); + if (test == ASE_NULL) return -1; + + ase_awk_refupval (run, test); + + if (!ase_awk_valtobool (run, test)) + { + ase_awk_refdownval (run, test); + break; + } + + ase_awk_refdownval (run, test); + } + while (1); + } + + return 0; +} + +static int __run_for (ase_awk_run_t* run, ase_awk_nde_for_t* nde) +{ + ase_awk_val_t* val; + + if (nde->init != ASE_NULL) + { + ASE_ASSERT (nde->init->next == ASE_NULL); + val = __eval_expression(run,nde->init); + if (val == ASE_NULL) return -1; + + ase_awk_refupval (run, val); + ase_awk_refdownval (run, val); + } + + while (1) + { + if (nde->test != ASE_NULL) + { + ase_awk_val_t* test; + + /* no chained expressions for the test expression of + * the for statement are allowed */ + ASE_ASSERT (nde->test->next == ASE_NULL); + + test = __eval_expression (run, nde->test); + if (test == ASE_NULL) return -1; + + ase_awk_refupval (run, test); + if (ase_awk_valtobool (run, test)) + { + if (__run_statement(run,nde->body) == -1) + { + ase_awk_refdownval (run, test); + return -1; + } + } + else + { + ase_awk_refdownval (run, test); + break; + } + + ase_awk_refdownval (run, test); + } + else + { + if (__run_statement(run,nde->body) == -1) return -1; + } + + if (run->exit_level == EXIT_BREAK) + { + run->exit_level = EXIT_NONE; + break; + } + else if (run->exit_level == EXIT_CONTINUE) + { + run->exit_level = EXIT_NONE; + } + else if (run->exit_level != EXIT_NONE) break; + + if (nde->incr != ASE_NULL) + { + ASE_ASSERT (nde->incr->next == ASE_NULL); + val = __eval_expression(run,nde->incr); + if (val == ASE_NULL) return -1; + + ase_awk_refupval (run, val); + ase_awk_refdownval (run, val); + } + } + + return 0; +} + +struct __foreach_walker_t +{ + ase_awk_run_t* run; + ase_awk_nde_t* var; + ase_awk_nde_t* body; +}; + +static int __walk_foreach (ase_awk_pair_t* pair, void* arg) +{ + struct __foreach_walker_t* w = (struct __foreach_walker_t*)arg; + ase_awk_val_t* str; + + str = (ase_awk_val_t*) ase_awk_makestrval ( + w->run, PAIR_KEYPTR(pair), PAIR_KEYLEN(pair)); + if (str == ASE_NULL) + { + ase_awk_setrunerror ( + w->run, ASE_AWK_ENOMEM, w->var->line, ASE_NULL, 0); + return -1; + } + + ase_awk_refupval (w->run, str); + if (__do_assignment (w->run, w->var, str) == ASE_NULL) + { + ase_awk_refdownval (w->run, str); + return -1; + } + + if (__run_statement (w->run, w->body) == -1) + { + ase_awk_refdownval (w->run, str); + return -1; + } + + ase_awk_refdownval (w->run, str); + return 0; +} + +static int __run_foreach (ase_awk_run_t* run, ase_awk_nde_foreach_t* nde) +{ + int n; + ase_awk_nde_exp_t* test; + ase_awk_val_t* rv; + ase_awk_map_t* map; + struct __foreach_walker_t walker; + + test = (ase_awk_nde_exp_t*)nde->test; + ASE_ASSERT ( + test->type == ASE_AWK_NDE_EXP_BIN && + test->opcode == ASE_AWK_BINOP_IN); + + /* chained expressions should not be allowed + * by the parser first of all */ + ASE_ASSERT (test->right->next == ASE_NULL); + + rv = __eval_expression (run, test->right); + if (rv == ASE_NULL) return -1; + + ase_awk_refupval (run, rv); + if (rv->type != ASE_AWK_VAL_MAP) + { + ase_awk_refdownval (run, rv); + + ase_awk_setrunerror ( + run, ASE_AWK_ENOTMAPIN, test->right->line, ASE_NULL, 0); + return -1; + } + map = ((ase_awk_val_map_t*)rv)->map; + + walker.run = run; + walker.var = test->left; + walker.body = nde->body; + n = ase_awk_map_walk (map, __walk_foreach, &walker); + + ase_awk_refdownval (run, rv); + return n; +} + +static int __run_break (ase_awk_run_t* run, ase_awk_nde_break_t* nde) +{ + run->exit_level = EXIT_BREAK; + return 0; +} + +static int __run_continue (ase_awk_run_t* run, ase_awk_nde_continue_t* nde) +{ + run->exit_level = EXIT_CONTINUE; + return 0; +} + +static int __run_return (ase_awk_run_t* run, ase_awk_nde_return_t* nde) +{ + if (nde->val != ASE_NULL) + { + ase_awk_val_t* val; + + /* chained expressions should not be allowed + * by the parser first of all */ + ASE_ASSERT (nde->val->next == ASE_NULL); + + val = __eval_expression (run, nde->val); + if (val == ASE_NULL) return -1; + + ase_awk_refdownval (run, STACK_RETVAL(run)); + STACK_RETVAL(run) = val; + ase_awk_refupval (run, val); /* see __eval_call for the trick */ + } + + run->exit_level = EXIT_FUNCTION; + return 0; +} + +static int __run_exit (ase_awk_run_t* run, ase_awk_nde_exit_t* nde) +{ + if (nde->val != ASE_NULL) + { + ase_awk_val_t* val; + + /* chained expressions should not be allowed + * by the parser first of all */ + ASE_ASSERT (nde->val->next == ASE_NULL); + + val = __eval_expression (run, nde->val); + if (val == ASE_NULL) return -1; + + ase_awk_refdownval (run, STACK_RETVAL_GLOBAL(run)); + STACK_RETVAL_GLOBAL(run) = val; /* global return value */ + + ase_awk_refupval (run, val); + } + + run->exit_level = EXIT_GLOBAL; + return 0; +} + +static int __run_next (ase_awk_run_t* run, ase_awk_nde_next_t* nde) +{ + /* the parser checks if next has been called in the begin/end + * block or whereever inappropriate. so the runtime doesn't + * check that explicitly */ + if (run->active_block == (ase_awk_nde_blk_t*)run->awk->tree.begin) + { + ase_awk_setrunerror ( + run, ASE_AWK_ERNEXTBEG, nde->line, ASE_NULL, 0); + return -1; + } + else if (run->active_block == (ase_awk_nde_blk_t*)run->awk->tree.end) + { + ase_awk_setrunerror ( + run, ASE_AWK_ERNEXTEND, nde->line, ASE_NULL, 0); + return -1; + } + + run->exit_level = EXIT_NEXT; + return 0; +} + +static int __run_nextinfile (ase_awk_run_t* run, ase_awk_nde_nextfile_t* nde) +{ + int n; + + /* normal nextfile statement */ + if (run->active_block == (ase_awk_nde_blk_t*)run->awk->tree.begin) + { + ase_awk_setrunerror ( + run, ASE_AWK_ERNEXTFBEG, nde->line, ASE_NULL, 0); + return -1; + } + else if (run->active_block == (ase_awk_nde_blk_t*)run->awk->tree.end) + { + ase_awk_setrunerror ( + run, ASE_AWK_ERNEXTFEND, nde->line, ASE_NULL, 0); + return -1; + } + + n = ase_awk_nextextio_read (run, ASE_AWK_IN_CONSOLE, ASE_T("")); + if (n == -1) + { + /* adjust the error line */ + run->errlin = nde->line; + return -1; + } + + if (n == 0) + { + /* no more input console */ + run->exit_level = EXIT_GLOBAL; + return 0; + } + + if (__update_fnr (run, 0) == -1) + { + run->errlin = nde->line; + return -1; + } + + run->exit_level = EXIT_NEXT; + return 0; + +} + +static int __run_nextoutfile (ase_awk_run_t* run, ase_awk_nde_nextfile_t* nde) +{ + int n; + + n = ase_awk_nextextio_write (run, ASE_AWK_OUT_CONSOLE, ASE_T("")); + if (n == -1) + { + /* adjust the error line */ + run->errlin = nde->line; + return -1; + } + + if (n == 0) + { + /* TODO: should it terminate the program + * when there is no more output console? */ + /*run->exit_level = EXIT_GLOBAL;*/ + return 0; + } + + return 0; +} + +static int __run_nextfile (ase_awk_run_t* run, ase_awk_nde_nextfile_t* nde) +{ + return (nde->out)? + __run_nextoutfile (run, nde): + __run_nextinfile (run, nde); +} + +static int __run_delete (ase_awk_run_t* run, ase_awk_nde_delete_t* nde) +{ + ase_awk_nde_var_t* var; + + var = (ase_awk_nde_var_t*) nde->var; + + if (var->type == ASE_AWK_NDE_NAMED || + var->type == ASE_AWK_NDE_NAMEDIDX) + { + ase_awk_pair_t* pair; + + ASE_ASSERTX ( + (var->type == ASE_AWK_NDE_NAMED && var->idx == ASE_NULL) || + (var->type == ASE_AWK_NDE_NAMEDIDX && var->idx != ASE_NULL), + "if a named variable has an index part and a named indexed variable doesn't have an index part, the program is definitely wrong"); + + pair = ase_awk_map_get ( + &run->named, var->id.name, var->id.name_len); + if (pair == ASE_NULL) + { + ase_awk_val_t* tmp; + + /* value not set for the named variable. + * create a map and assign it to the variable */ + + tmp = ase_awk_makemapval (run); + if (tmp == ASE_NULL) + { + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, nde->line, + ASE_NULL, 0); + return -1; + } + + if (ase_awk_map_put (&run->named, + var->id.name, var->id.name_len, tmp) == ASE_NULL) + { + ase_awk_refupval (run, tmp); + ase_awk_refdownval (run, tmp); + + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, var->line, + ASE_NULL, 0); + return -1; + } + + /* as this is the assignment, it needs to update + * the reference count of the target value */ + ase_awk_refupval (run, tmp); + } + else + { + ase_awk_val_t* val; + ase_awk_map_t* map; + + val = (ase_awk_val_t*)pair->val; + ASE_ASSERT (val != ASE_NULL); + + if (val->type != ASE_AWK_VAL_MAP) + { + ase_cstr_t errarg; + + errarg.ptr = var->id.name; + errarg.len = var->id.name_len; + + ase_awk_setrunerror ( + run, ASE_AWK_ENOTDEL, var->line, + &errarg, 1); + return -1; + } + + map = ((ase_awk_val_map_t*)val)->map; + if (var->type == ASE_AWK_NDE_NAMEDIDX) + { + ase_char_t* key; + ase_size_t key_len; + ase_awk_val_t* idx; + + ASE_ASSERT (var->idx != ASE_NULL); + + idx = __eval_expression (run, var->idx); + if (idx == ASE_NULL) return -1; + + ase_awk_refupval (run, idx); + key = ase_awk_valtostr ( + run, idx, ASE_AWK_VALTOSTR_CLEAR, + ASE_NULL, &key_len); + ase_awk_refdownval (run, idx); + + if (key == ASE_NULL) + { + /* change the error line */ + run->errlin = var->line; + return -1; + } + + ase_awk_map_remove (map, key, key_len); + ASE_AWK_FREE (run->awk, key); + } + else + { + ase_awk_map_clear (map); + } + } + } + else if (var->type == ASE_AWK_NDE_GLOBAL || + var->type == ASE_AWK_NDE_LOCAL || + var->type == ASE_AWK_NDE_ARG || + var->type == ASE_AWK_NDE_GLOBALIDX || + var->type == ASE_AWK_NDE_LOCALIDX || + var->type == ASE_AWK_NDE_ARGIDX) + { + ase_awk_val_t* val; + + if (var->type == ASE_AWK_NDE_GLOBAL || + var->type == ASE_AWK_NDE_GLOBALIDX) + val = STACK_GLOBAL (run,var->id.idxa); + else if (var->type == ASE_AWK_NDE_LOCAL || + var->type == ASE_AWK_NDE_LOCALIDX) + val = STACK_LOCAL (run,var->id.idxa); + else val = STACK_ARG (run,var->id.idxa); + + ASE_ASSERT (val != ASE_NULL); + + if (val->type == ASE_AWK_VAL_NIL) + { + ase_awk_val_t* tmp; + + /* value not set for the named variable. + * create a map and assign it to the variable */ + + tmp = ase_awk_makemapval (run); + if (tmp == ASE_NULL) + { + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, nde->line, + ASE_NULL, 0); + return -1; + } + + /* no need to reduce the reference count of + * the previous value because it was nil. */ + if (var->type == ASE_AWK_NDE_GLOBAL || + var->type == ASE_AWK_NDE_GLOBALIDX) + { + if (ase_awk_setglobal ( + run, var->id.idxa, tmp) == -1) + { + ase_awk_refupval (run, tmp); + ase_awk_refdownval (run, tmp); + + run->errlin = var->line; + return -1; + } + } + else if (var->type == ASE_AWK_NDE_LOCAL || + var->type == ASE_AWK_NDE_LOCALIDX) + { + STACK_LOCAL(run,var->id.idxa) = tmp; + ase_awk_refupval (run, tmp); + } + else + { + STACK_ARG(run,var->id.idxa) = tmp; + ase_awk_refupval (run, tmp); + } + } + else + { + ase_awk_map_t* map; + + if (val->type != ASE_AWK_VAL_MAP) + { + ase_cstr_t errarg; + + errarg.ptr = var->id.name; + errarg.len = var->id.name_len; + + ase_awk_setrunerror ( + run, ASE_AWK_ENOTDEL, var->line, + &errarg, 1); + return -1; + } + + map = ((ase_awk_val_map_t*)val)->map; + if (var->type == ASE_AWK_NDE_GLOBALIDX || + var->type == ASE_AWK_NDE_LOCALIDX || + var->type == ASE_AWK_NDE_ARGIDX) + { + ase_char_t* key; + ase_size_t key_len; + ase_awk_val_t* idx; + + ASE_ASSERT (var->idx != ASE_NULL); + + idx = __eval_expression (run, var->idx); + if (idx == ASE_NULL) return -1; + + ase_awk_refupval (run, idx); + key = ase_awk_valtostr ( + run, idx, ASE_AWK_VALTOSTR_CLEAR, + ASE_NULL, &key_len); + ase_awk_refdownval (run, idx); + + if (key == ASE_NULL) + { + run->errlin = var->line; + return -1; + } + + ase_awk_map_remove (map, key, key_len); + ASE_AWK_FREE (run->awk, key); + } + else + { + ase_awk_map_clear (map); + } + } + } + else + { + ASE_ASSERTX ( + !"should never happen - wrong target for delete", + "the delete statement cannot be called with other nodes than the variables such as a named variable, a named indexed variable, etc"); + + ase_awk_setrunerror ( + run, ASE_AWK_ERDELETE, var->line, ASE_NULL, 0); + return -1; + } + + return 0; +} + +static int __run_print (ase_awk_run_t* run, ase_awk_nde_print_t* nde) +{ + ase_char_t* out = ASE_NULL; + const ase_char_t* dst; + ase_awk_val_t* v; + int n; + + ASE_ASSERT ( + (nde->out_type == ASE_AWK_OUT_PIPE && nde->out != ASE_NULL) || + (nde->out_type == ASE_AWK_OUT_COPROC && nde->out != ASE_NULL) || + (nde->out_type == ASE_AWK_OUT_FILE && nde->out != ASE_NULL) || + (nde->out_type == ASE_AWK_OUT_FILE_APPEND && nde->out != ASE_NULL) || + (nde->out_type == ASE_AWK_OUT_CONSOLE && nde->out == ASE_NULL)); + + /* check if destination has been specified. */ + if (nde->out != ASE_NULL) + { + ase_size_t len; + + /* if so, resolve the destination name */ + v = __eval_expression (run, nde->out); + if (v == ASE_NULL) return -1; + + ase_awk_refupval (run, v); + out = ase_awk_valtostr ( + run, v, ASE_AWK_VALTOSTR_CLEAR, ASE_NULL, &len); + if (out == ASE_NULL) + { + ase_awk_refdownval (run, v); + + /* change the error line */ + run->errlin = nde->line; + return -1; + } + ase_awk_refdownval (run, v); + + if (len <= 0) + { + /* the destination name is empty */ + ASE_AWK_FREE (run->awk, out); + ase_awk_setrunerror ( + run, ASE_AWK_EIONMEM, nde->line, ASE_NULL, 0); + return -1; + } + + /* it needs to check if the destination name contains + * any invalid characters to the underlying system */ + while (len > 0) + { + if (out[--len] == ASE_T('\0')) + { + /* if so, it skips writing */ + ASE_AWK_FREE (run->awk, out); + ase_awk_setrunerror ( + run, ASE_AWK_EIONMNL, nde->line, + ASE_NULL, 0); + return -1; + } + } + } + + /* transforms the destination to suit the usage with extio */ + dst = (out == ASE_NULL)? ASE_T(""): out; + + /* check if print is followed by any arguments */ + if (nde->args == ASE_NULL) + { + /* if it doesn't have any arguments, print the entire + * input record */ + n = ase_awk_writeextio_str ( + run, nde->out_type, dst, + ASE_STR_BUF(&run->inrec.line), + ASE_STR_LEN(&run->inrec.line)); + if (n <= -1 /*&& run->errnum != ASE_AWK_EIOIMPL*/) + { + if (out != ASE_NULL) + ASE_AWK_FREE (run->awk, out); + + /* adjust the error line */ + run->errlin = nde->line; + return -1; + } + } + else + { + /* if it has any arguments, print the arguments separated by + * the value OFS */ + ase_awk_nde_t* head, * np; + + if (nde->args->type == ASE_AWK_NDE_GRP) + { + /* parenthesized print */ + ASE_ASSERT (nde->args->next == ASE_NULL); + head = ((ase_awk_nde_grp_t*)nde->args)->body; + } + else head = nde->args; + + for (np = head; np != ASE_NULL; np = np->next) + { + if (np != head) + { + n = ase_awk_writeextio_str ( + run, nde->out_type, dst, + run->global.ofs.ptr, + run->global.ofs.len); + if (n <= -1 /*&& run->errnum != ASE_AWK_EIOIMPL*/) + { + if (out != ASE_NULL) + ASE_AWK_FREE (run->awk, out); + + /* adjust the error line */ + run->errlin = nde->line; + return -1; + } + } + + v = __eval_expression (run, np); + if (v == ASE_NULL) + { + if (out != ASE_NULL) + ASE_AWK_FREE (run->awk, out); + return -1; + } + ase_awk_refupval (run, v); + + n = ase_awk_writeextio_val (run, nde->out_type, dst, v); + if (n <= -1 /*&& run->errnum != ASE_AWK_EIOIMPL*/) + { + if (out != ASE_NULL) + ASE_AWK_FREE (run->awk, out); + + ase_awk_refdownval (run, v); + /* adjust the error line */ + run->errlin = nde->line; + return -1; + } + + ase_awk_refdownval (run, v); + } + } + + /* print the value ORS to terminate the operation */ + n = ase_awk_writeextio_str ( + run, nde->out_type, dst, + run->global.ors.ptr, run->global.ors.len); + if (n <= -1 /*&& run->errnum != ASE_AWK_EIOIMPL*/) + { + if (out != ASE_NULL) ASE_AWK_FREE (run->awk, out); + + /* change the error line */ + run->errlin = nde->line; + return -1; + } + + if (out != ASE_NULL) ASE_AWK_FREE (run->awk, out); + +/*skip_write:*/ + return 0; +} + +static int __run_printf (ase_awk_run_t* run, ase_awk_nde_print_t* nde) +{ + ase_char_t* out = ASE_NULL; + const ase_char_t* dst; + ase_awk_val_t* v; + ase_awk_nde_t* head; + int n; + + ASE_ASSERT ( + (nde->out_type == ASE_AWK_OUT_PIPE && nde->out != ASE_NULL) || + (nde->out_type == ASE_AWK_OUT_COPROC && nde->out != ASE_NULL) || + (nde->out_type == ASE_AWK_OUT_FILE && nde->out != ASE_NULL) || + (nde->out_type == ASE_AWK_OUT_FILE_APPEND && nde->out != ASE_NULL) || + (nde->out_type == ASE_AWK_OUT_CONSOLE && nde->out == ASE_NULL)); + + if (nde->out != ASE_NULL) + { + ase_size_t len; + + v = __eval_expression (run, nde->out); + if (v == ASE_NULL) return -1; + + ase_awk_refupval (run, v); + out = ase_awk_valtostr ( + run, v, ASE_AWK_VALTOSTR_CLEAR, ASE_NULL, &len); + if (out == ASE_NULL) + { + ase_awk_refdownval (run, v); + + /* change the error line */ + run->errlin = nde->line; + return -1; + } + ase_awk_refdownval (run, v); + + if (len <= 0) + { + /* the output destination name is empty. */ + ASE_AWK_FREE (run->awk, out); + ase_awk_setrunerror ( + run, ASE_AWK_EIONMEM, nde->line, ASE_NULL, 0); + return -1; + } + + while (len > 0) + { + if (out[--len] == ASE_T('\0')) + { + /* the output destination name contains a null + * character. */ + ASE_AWK_FREE (run->awk, out); + ase_awk_setrunerror ( + run, ASE_AWK_EIONMNL, nde->line, + ASE_NULL, 0); + return -1; + } + } + } + + dst = (out == ASE_NULL)? ASE_T(""): out; + + ASE_ASSERTX (nde->args != ASE_NULL, + "a valid printf statement should have at least one argument. the parser must ensure this."); + + if (nde->args->type == ASE_AWK_NDE_GRP) + { + /* parenthesized print */ + ASE_ASSERT (nde->args->next == ASE_NULL); + head = ((ase_awk_nde_grp_t*)nde->args)->body; + } + else head = nde->args; + + ASE_ASSERTX (head != ASE_NULL, + "a valid printf statement should have at least one argument. the parser must ensure this."); + + v = __eval_expression (run, head); + if (v == ASE_NULL) + { + if (out != ASE_NULL) ASE_AWK_FREE (run->awk, out); + return -1; + } + + ase_awk_refupval (run, v); + if (v->type != ASE_AWK_VAL_STR) + { + /* the remaining arguments are ignored as the format cannot + * contain any % characters */ + n = ase_awk_writeextio_val (run, nde->out_type, dst, v); + if (n <= -1 /*&& run->errnum != ASE_AWK_EIOIMPL*/) + { + if (out != ASE_NULL) ASE_AWK_FREE (run->awk, out); + ase_awk_refdownval (run, v); + + /* change the error line */ + run->errlin = nde->line; + return -1; + } + } + else + { + /* perform the formatted output */ + if (__formatted_output ( + run, nde->out_type, dst, + ((ase_awk_val_str_t*)v)->buf, + ((ase_awk_val_str_t*)v)->len, + head->next) == -1) + { + if (out != ASE_NULL) ASE_AWK_FREE (run->awk, out); + ase_awk_refdownval (run, v); + + /* adjust the error line */ + run->errlin = nde->line; + return -1; + } + } + ase_awk_refdownval (run, v); + + if (out != ASE_NULL) ASE_AWK_FREE (run->awk, out); + +/*skip_write:*/ + return 0; +} + +static int __formatted_output ( + ase_awk_run_t* run, int out_type, const ase_char_t* dst, + const ase_char_t* fmt, ase_size_t fmt_len, ase_awk_nde_t* args) +{ + ase_char_t* ptr; + ase_size_t len; + int n; + + ptr = ase_awk_format (run, + ASE_NULL, ASE_NULL, fmt, fmt_len, 0, args, &len); + if (ptr == ASE_NULL) return -1; + + n = ase_awk_writeextio_str (run, out_type, dst, ptr, len); + if (n <= -1 /*&& run->errnum != ASE_AWK_EIOIMPL*/) return -1; + + return 0; +} + +static ase_awk_val_t* __eval_expression (ase_awk_run_t* run, ase_awk_nde_t* nde) +{ + ase_awk_val_t* v; + int n, errnum; + + v = __eval_expression0 (run, nde); + if (v == ASE_NULL) return ASE_NULL; + + if (v->type == ASE_AWK_VAL_REX) + { + ase_awk_refupval (run, v); + + if (run->inrec.d0->type == ASE_AWK_VAL_NIL) + { + /* the record has never been read. + * probably, this functions has been triggered + * by the statements in the BEGIN block */ + n = ase_awk_isemptyrex ( + run->awk, ((ase_awk_val_rex_t*)v)->code)? 1: 0; + } + else + { + ASE_ASSERTX ( + run->inrec.d0->type == ASE_AWK_VAL_STR, + "the internal value representing $0 should always be of the string type once it has been set/updated. it is nil initially."); + + n = ase_awk_matchrex ( + ((ase_awk_run_t*)run)->awk, + ((ase_awk_val_rex_t*)v)->code, + ((((ase_awk_run_t*)run)->global.ignorecase)? ASE_AWK_REX_IGNORECASE: 0), + ((ase_awk_val_str_t*)run->inrec.d0)->buf, + ((ase_awk_val_str_t*)run->inrec.d0)->len, + ASE_NULL, ASE_NULL, &errnum); + + if (n == -1) + { + ase_awk_refdownval (run, v); + + /* matchrex should never set the error number + * whose message contains a formatting + * character. otherwise, the following way of + * setting the error information may not work */ + ase_awk_setrunerror ( + run, errnum, nde->line, ASE_NULL, 0); + return ASE_NULL; + } + } + + ase_awk_refdownval (run, v); + + v = ase_awk_makeintval (run, (n != 0)); + if (v == ASE_NULL) + { + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, nde->line, ASE_NULL, 0); + return ASE_NULL; + } + } + + return v; +} + +static ase_awk_val_t* __eval_expression0 (ase_awk_run_t* run, ase_awk_nde_t* nde) +{ + static eval_expr_t __eval_func[] = + { + /* the order of functions here should match the order + * of node types declared in tree.h */ + __eval_group, + __eval_assignment, + __eval_binary, + __eval_unary, + __eval_incpre, + __eval_incpst, + __eval_cnd, + __eval_bfn, + __eval_afn, + __eval_int, + __eval_real, + __eval_str, + __eval_rex, + __eval_named, + __eval_global, + __eval_local, + __eval_arg, + __eval_namedidx, + __eval_globalidx, + __eval_localidx, + __eval_argidx, + __eval_pos, + __eval_getline + }; + + ASE_ASSERT (nde->type >= ASE_AWK_NDE_GRP && + (nde->type - ASE_AWK_NDE_GRP) < ASE_COUNTOF(__eval_func)); + + return __eval_func[nde->type-ASE_AWK_NDE_GRP] (run, nde); +} + +static ase_awk_val_t* __eval_group (ase_awk_run_t* run, ase_awk_nde_t* nde) +{ + /* __eval_binop_in evaluates the ASE_AWK_NDE_GRP specially. + * so this function should never be reached. */ + ASE_ASSERT (!"should never happen - NDE_GRP only for in"); + ase_awk_setrunerror (run, ASE_AWK_EINTERN, nde->line, ASE_NULL, 0); + return ASE_NULL; +} + +static ase_awk_val_t* __eval_assignment (ase_awk_run_t* run, ase_awk_nde_t* nde) +{ + ase_awk_val_t* val, * ret; + ase_awk_nde_ass_t* ass = (ase_awk_nde_ass_t*)nde; + + ASE_ASSERT (ass->left != ASE_NULL); + ASE_ASSERT (ass->right != ASE_NULL); + + ASE_ASSERT (ass->right->next == ASE_NULL); + val = __eval_expression (run, ass->right); + if (val == ASE_NULL) return ASE_NULL; + + ase_awk_refupval (run, val); + + if (ass->opcode != ASE_AWK_ASSOP_NONE) + { + ase_awk_val_t* val2, * tmp; + static binop_func_t __binop_func[] = + { + ASE_NULL, /* ASE_AWK_ASSOP_NONE */ + __eval_binop_plus, + __eval_binop_minus, + __eval_binop_mul, + __eval_binop_div, + __eval_binop_idiv, + __eval_binop_mod, + __eval_binop_exp + }; + + ASE_ASSERT (ass->left->next == ASE_NULL); + val2 = __eval_expression (run, ass->left); + if (val2 == ASE_NULL) + { + ase_awk_refdownval (run, val); + return ASE_NULL; + } + + ase_awk_refupval (run, val2); + + ASE_ASSERT (ass->opcode >= 0); + ASE_ASSERT (ass->opcode < ASE_COUNTOF(__binop_func)); + ASE_ASSERT (__binop_func[ass->opcode] != ASE_NULL); + + tmp = __binop_func[ass->opcode] (run, val2, val); + if (tmp == ASE_NULL) + { + ase_awk_refdownval (run, val2); + ase_awk_refdownval (run, val); + return ASE_NULL; + } + + ase_awk_refdownval (run, val2); + ase_awk_refdownval (run, val); + + val = tmp; + ase_awk_refupval (run, val); + } + + ret = __do_assignment (run, ass->left, val); + ase_awk_refdownval (run, val); + + return ret; +} + +static ase_awk_val_t* __do_assignment ( + ase_awk_run_t* run, ase_awk_nde_t* var, ase_awk_val_t* val) +{ + ase_awk_val_t* ret; + + if (val->type == ASE_AWK_VAL_MAP) + { + /* a map cannot be assigned to a variable */ + ase_awk_setrunerror ( + run, ASE_AWK_ENOTASS, var->line, ASE_NULL, 0); + return ASE_NULL; + } + + if (var->type == ASE_AWK_NDE_NAMED || + var->type == ASE_AWK_NDE_GLOBAL || + var->type == ASE_AWK_NDE_LOCAL || + var->type == ASE_AWK_NDE_ARG) + { + ret = __do_assignment_scalar (run, (ase_awk_nde_var_t*)var, val); + } + else if (var->type == ASE_AWK_NDE_NAMEDIDX || + var->type == ASE_AWK_NDE_GLOBALIDX || + var->type == ASE_AWK_NDE_LOCALIDX || + var->type == ASE_AWK_NDE_ARGIDX) + { + ret = __do_assignment_map (run, (ase_awk_nde_var_t*)var, val); + } + else if (var->type == ASE_AWK_NDE_POS) + { + ret = __do_assignment_pos (run, (ase_awk_nde_pos_t*)var, val); + } + else + { + ASE_ASSERT ( + !"should never happen - invalid variable type"); + ase_awk_setrunerror ( + run, ASE_AWK_EINTERN, var->line, ASE_NULL, 0); + return ASE_NULL; + } + + return ret; +} + +static ase_awk_val_t* __do_assignment_scalar ( + ase_awk_run_t* run, ase_awk_nde_var_t* var, ase_awk_val_t* val) +{ + ASE_ASSERT ( + (var->type == ASE_AWK_NDE_NAMED || + var->type == ASE_AWK_NDE_GLOBAL || + var->type == ASE_AWK_NDE_LOCAL || + var->type == ASE_AWK_NDE_ARG) && var->idx == ASE_NULL); + + ASE_ASSERT (val->type != ASE_AWK_VAL_MAP); + + if (var->type == ASE_AWK_NDE_NAMED) + { + ase_awk_pair_t* pair; + int n; + + pair = ase_awk_map_get ( + &run->named, var->id.name, var->id.name_len); + if (pair != ASE_NULL && + ((ase_awk_val_t*)pair->val)->type == ASE_AWK_VAL_MAP) + { + /* once a variable becomes a map, + * it cannot be changed to a scalar variable */ + ase_cstr_t errarg; + + errarg.ptr = var->id.name; + errarg.len = var->id.name_len; + + ase_awk_setrunerror (run, + ASE_AWK_EMAPTOSCALAR, var->line, &errarg, 1); + return ASE_NULL; + } + + n = ase_awk_map_putx (&run->named, + var->id.name, var->id.name_len, val, ASE_NULL); + if (n < 0) + { + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, var->line, ASE_NULL, 0); + return ASE_NULL; + } + + ase_awk_refupval (run, val); + } + else if (var->type == ASE_AWK_NDE_GLOBAL) + { + if (__set_global (run, var->id.idxa, var, val) == -1) + { + return ASE_NULL; + } + } + else if (var->type == ASE_AWK_NDE_LOCAL) + { + ase_awk_val_t* old = STACK_LOCAL(run,var->id.idxa); + if (old->type == ASE_AWK_VAL_MAP) + { + /* once the variable becomes a map, + * it cannot be changed to a scalar variable */ + ase_cstr_t errarg; + + errarg.ptr = var->id.name; + errarg.len = var->id.name_len; + + ase_awk_setrunerror (run, + ASE_AWK_EMAPTOSCALAR, var->line, &errarg, 1); + return ASE_NULL; + } + + ase_awk_refdownval (run, old); + STACK_LOCAL(run,var->id.idxa) = val; + ase_awk_refupval (run, val); + } + else /* if (var->type == ASE_AWK_NDE_ARG) */ + { + ase_awk_val_t* old = STACK_ARG(run,var->id.idxa); + if (old->type == ASE_AWK_VAL_MAP) + { + /* once the variable becomes a map, + * it cannot be changed to a scalar variable */ + ase_cstr_t errarg; + + errarg.ptr = var->id.name; + errarg.len = var->id.name_len; + + ase_awk_setrunerror (run, + ASE_AWK_EMAPTOSCALAR, var->line, &errarg, 1); + return ASE_NULL; + } + + ase_awk_refdownval (run, old); + STACK_ARG(run,var->id.idxa) = val; + ase_awk_refupval (run, val); + } + + return val; +} + +static ase_awk_val_t* __do_assignment_map ( + ase_awk_run_t* run, ase_awk_nde_var_t* var, ase_awk_val_t* val) +{ + ase_awk_val_map_t* map; + ase_char_t* str; + ase_size_t len; + int n; + + ASE_ASSERT ( + (var->type == ASE_AWK_NDE_NAMEDIDX || + var->type == ASE_AWK_NDE_GLOBALIDX || + var->type == ASE_AWK_NDE_LOCALIDX || + var->type == ASE_AWK_NDE_ARGIDX) && var->idx != ASE_NULL); + ASE_ASSERT (val->type != ASE_AWK_VAL_MAP); + + if (var->type == ASE_AWK_NDE_NAMEDIDX) + { + ase_awk_pair_t* pair; + pair = ase_awk_map_get ( + &run->named, var->id.name, var->id.name_len); + map = (pair == ASE_NULL)? + (ase_awk_val_map_t*)ase_awk_val_nil: + (ase_awk_val_map_t*)pair->val; + } + else + { + map = (var->type == ASE_AWK_NDE_GLOBALIDX)? + (ase_awk_val_map_t*)STACK_GLOBAL(run,var->id.idxa): + (var->type == ASE_AWK_NDE_LOCALIDX)? + (ase_awk_val_map_t*)STACK_LOCAL(run,var->id.idxa): + (ase_awk_val_map_t*)STACK_ARG(run,var->id.idxa); + } + + if (map->type == ASE_AWK_VAL_NIL) + { + /* the map is not initialized yet */ + ase_awk_val_t* tmp; + + tmp = ase_awk_makemapval (run); + if (tmp == ASE_NULL) + { + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, var->line, ASE_NULL, 0); + return ASE_NULL; + } + + if (var->type == ASE_AWK_NDE_NAMEDIDX) + { + /* doesn't have to decrease the reference count + * of the previous value here as it is done by + * ase_awk_map_put */ + if (ase_awk_map_put (&run->named, + var->id.name, var->id.name_len, tmp) == ASE_NULL) + { + ase_awk_refupval (run, tmp); + ase_awk_refdownval (run, tmp); + + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, var->line, ASE_NULL, 0); + return ASE_NULL; + } + + ase_awk_refupval (run, tmp); + } + else if (var->type == ASE_AWK_NDE_GLOBALIDX) + { + ase_awk_refupval (run, tmp); + if (ase_awk_setglobal (run, var->id.idxa, tmp) == -1) + { + ase_awk_refdownval (run, tmp); + + /* change error line */ + run->errlin = var->line; + return ASE_NULL; + } + ase_awk_refdownval (run, tmp); + } + else if (var->type == ASE_AWK_NDE_LOCALIDX) + { + ase_awk_refdownval (run, (ase_awk_val_t*)map); + STACK_LOCAL(run,var->id.idxa) = tmp; + ase_awk_refupval (run, tmp); + } + else /* if (var->type == ASE_AWK_NDE_ARGIDX) */ + { + ase_awk_refdownval (run, (ase_awk_val_t*)map); + STACK_ARG(run,var->id.idxa) = tmp; + ase_awk_refupval (run, tmp); + } + + map = (ase_awk_val_map_t*) tmp; + } + else if (map->type != ASE_AWK_VAL_MAP) + { + /* variable assigned is not a map */ + ase_awk_setrunerror ( + run, ASE_AWK_ENOTIDX, var->line, ASE_NULL, 0); + return ASE_NULL; + } + + str = __idxnde_to_str (run, var->idx, &len); + if (str == ASE_NULL) return ASE_NULL; + +#ifdef DEBUG_RUN + ase_dprintf (ASE_T("**** index str=>%s, map->ref=%d, map->type=%d\n"), + str, (int)map->ref, (int)map->type); +#endif + + n = ase_awk_map_putx (map->map, str, len, val, ASE_NULL); + if (n < 0) + { + ASE_AWK_FREE (run->awk, str); + ase_awk_setrunerror (run, ASE_AWK_ENOMEM, var->line, ASE_NULL, 0); + return ASE_NULL; + } + + ASE_AWK_FREE (run->awk, str); + ase_awk_refupval (run, val); + return val; +} + +static ase_awk_val_t* __do_assignment_pos ( + ase_awk_run_t* run, ase_awk_nde_pos_t* pos, ase_awk_val_t* val) +{ + ase_awk_val_t* v; + ase_long_t lv; + ase_real_t rv; + ase_char_t* str; + ase_size_t len; + int n; + + v = __eval_expression (run, pos->val); + if (v == ASE_NULL) return ASE_NULL; + + ase_awk_refupval (run, v); + n = ase_awk_valtonum (run, v, &lv, &rv); + ase_awk_refdownval (run, v); + + if (n == -1) + { + ase_awk_setrunerror ( + run, ASE_AWK_EPOSIDX, pos->line, ASE_NULL, 0); + return ASE_NULL; + } + if (n == 1) lv = (ase_long_t)rv; + if (!IS_VALID_POSIDX(lv)) + { + ase_awk_setrunerror ( + run, ASE_AWK_EPOSIDX, pos->line, ASE_NULL, 0); + return ASE_NULL; + } + + if (val->type == ASE_AWK_VAL_STR) + { + str = ((ase_awk_val_str_t*)val)->buf; + len = ((ase_awk_val_str_t*)val)->len; + } + else + { + str = ase_awk_valtostr ( + run, val, ASE_AWK_VALTOSTR_CLEAR, ASE_NULL, &len); + if (str == ASE_NULL) + { + /* change error line */ + run->errlin = pos->line; + return ASE_NULL; + } + } + + n = ase_awk_setrec (run, (ase_size_t)lv, str, len); + + if (val->type != ASE_AWK_VAL_STR) ASE_AWK_FREE (run->awk, str); + + if (n == -1) return ASE_NULL; + return (lv == 0)? run->inrec.d0: run->inrec.flds[lv-1].val; +} + +static ase_awk_val_t* __eval_binary (ase_awk_run_t* run, ase_awk_nde_t* nde) +{ + static binop_func_t __binop_func[] = + { + /* the order of the functions should be inline with + * the operator declaration in run.h */ + + ASE_NULL, /* __eval_binop_lor */ + ASE_NULL, /* __eval_binop_land */ + ASE_NULL, /* __eval_binop_in */ + + __eval_binop_bor, + __eval_binop_bxor, + __eval_binop_band, + + __eval_binop_eq, + __eval_binop_ne, + __eval_binop_gt, + __eval_binop_ge, + __eval_binop_lt, + __eval_binop_le, + + __eval_binop_lshift, + __eval_binop_rshift, + + __eval_binop_plus, + __eval_binop_minus, + __eval_binop_mul, + __eval_binop_div, + __eval_binop_idiv, + __eval_binop_mod, + __eval_binop_exp, + + __eval_binop_concat, + ASE_NULL, /* __eval_binop_ma */ + ASE_NULL /* __eval_binop_nm */ + }; + + ase_awk_nde_exp_t* exp = (ase_awk_nde_exp_t*)nde; + ase_awk_val_t* left, * right, * res; + + ASE_ASSERT (exp->type == ASE_AWK_NDE_EXP_BIN); + + if (exp->opcode == ASE_AWK_BINOP_LAND) + { + res = __eval_binop_land (run, exp->left, exp->right); + } + else if (exp->opcode == ASE_AWK_BINOP_LOR) + { + res = __eval_binop_lor (run, exp->left, exp->right); + } + else if (exp->opcode == ASE_AWK_BINOP_IN) + { + /* treat the in operator specially */ + res = __eval_binop_in (run, exp->left, exp->right); + } + else if (exp->opcode == ASE_AWK_BINOP_NM) + { + res = __eval_binop_nm (run, exp->left, exp->right); + } + else if (exp->opcode == ASE_AWK_BINOP_MA) + { + res = __eval_binop_ma (run, exp->left, exp->right); + } + else + { + ASE_ASSERT (exp->left->next == ASE_NULL); + left = __eval_expression (run, exp->left); + if (left == ASE_NULL) return ASE_NULL; + + ase_awk_refupval (run, left); + + ASE_ASSERT (exp->right->next == ASE_NULL); + right = __eval_expression (run, exp->right); + if (right == ASE_NULL) + { + ase_awk_refdownval (run, left); + return ASE_NULL; + } + + ase_awk_refupval (run, right); + + ASE_ASSERT (exp->opcode >= 0 && + exp->opcode < ASE_COUNTOF(__binop_func)); + ASE_ASSERT (__binop_func[exp->opcode] != ASE_NULL); + + res = __binop_func[exp->opcode] (run, left, right); + if (res == ASE_NULL) + { + /* change the error line */ + run->errlin = nde->line; + } + + ase_awk_refdownval (run, left); + ase_awk_refdownval (run, right); + } + + return res; +} + +static ase_awk_val_t* __eval_binop_lor ( + ase_awk_run_t* run, ase_awk_nde_t* left, ase_awk_nde_t* right) +{ + /* + ase_awk_val_t* res = ASE_NULL; + + res = ase_awk_makeintval (run, + ase_awk_valtobool(run left) || ase_awk_valtobool(run,right)); + if (res == ASE_NULL) + { + ase_awk_setrunerror (run, ASE_AWK_ENOMEM, left->line, ASE_NULL, 0); + return ASE_NULL; + } + + return res; + */ + + /* short-circuit evaluation required special treatment */ + ase_awk_val_t* lv, * rv, * res; + + ASE_ASSERT (left->next == ASE_NULL); + lv = __eval_expression (run, left); + if (lv == ASE_NULL) return ASE_NULL; + + ase_awk_refupval (run, lv); + if (ase_awk_valtobool (run, lv)) + { + res = ase_awk_val_one; + } + else + { + ASE_ASSERT (right->next == ASE_NULL); + rv = __eval_expression (run, right); + if (rv == ASE_NULL) + { + ase_awk_refdownval (run, lv); + return ASE_NULL; + } + ase_awk_refupval (run, rv); + + res = ase_awk_valtobool(run,rv)? ase_awk_val_one: ase_awk_val_zero; + ase_awk_refdownval (run, rv); + } + + ase_awk_refdownval (run, lv); + + return res; +} + +static ase_awk_val_t* __eval_binop_land ( + ase_awk_run_t* run, ase_awk_nde_t* left, ase_awk_nde_t* right) +{ + /* + ase_awk_val_t* res = ASE_NULL; + + res = ase_awk_makeintval (run, + ase_awk_valtobool(run,left) && ase_awk_valtobool(run,right)); + if (res == ASE_NULL) + { + ase_awk_setrunerror (run, ASE_AWK_ENOMEM, left->line, ASE_NULL, 0); + return ASE_NULL; + } + + return res; + */ + + /* short-circuit evaluation required special treatment */ + ase_awk_val_t* lv, * rv, * res; + + ASE_ASSERT (left->next == ASE_NULL); + lv = __eval_expression (run, left); + if (lv == ASE_NULL) return ASE_NULL; + + ase_awk_refupval (run, lv); + if (!ase_awk_valtobool (run, lv)) + { + res = ase_awk_val_zero; + } + else + { + ASE_ASSERT (right->next == ASE_NULL); + rv = __eval_expression (run, right); + if (rv == ASE_NULL) + { + ase_awk_refdownval (run, lv); + return ASE_NULL; + } + ase_awk_refupval (run, rv); + + res = ase_awk_valtobool(run,rv)? ase_awk_val_one: ase_awk_val_zero; + ase_awk_refdownval (run, rv); + } + + ase_awk_refdownval (run, lv); + + return res; +} + +static ase_awk_val_t* __eval_binop_in ( + ase_awk_run_t* run, ase_awk_nde_t* left, ase_awk_nde_t* right) +{ + ase_awk_val_t* rv; + ase_char_t* str; + ase_size_t len; + + if (right->type != ASE_AWK_NDE_GLOBAL && + right->type != ASE_AWK_NDE_LOCAL && + right->type != ASE_AWK_NDE_ARG && + right->type != ASE_AWK_NDE_NAMED) + { + /* the compiler should have handled this case */ + ASE_ASSERT ( + !"should never happen - in needs a plain variable"); + + ase_awk_setrunerror ( + run, ASE_AWK_EINTERN, right->line, ASE_NULL, 0); + return ASE_NULL; + } + + /* evaluate the left-hand side of the operator */ + str = (left->type == ASE_AWK_NDE_GRP)? + __idxnde_to_str (run, ((ase_awk_nde_grp_t*)left)->body, &len): + __idxnde_to_str (run, left, &len); + if (str == ASE_NULL) return ASE_NULL; + + /* evaluate the right-hand side of the operator */ + ASE_ASSERT (right->next == ASE_NULL); + rv = __eval_expression (run, right); + if (rv == ASE_NULL) + { + ASE_AWK_FREE (run->awk, str); + return ASE_NULL; + } + + ase_awk_refupval (run, rv); + + if (rv->type == ASE_AWK_VAL_NIL) + { + ASE_AWK_FREE (run->awk, str); + ase_awk_refdownval (run, rv); + return ase_awk_val_zero; + } + else if (rv->type == ASE_AWK_VAL_MAP) + { + ase_awk_val_t* res; + ase_awk_map_t* map; + + map = ((ase_awk_val_map_t*)rv)->map; + res = (ase_awk_map_get (map, str, len) == ASE_NULL)? + ase_awk_val_zero: ase_awk_val_one; + + ASE_AWK_FREE (run->awk, str); + ase_awk_refdownval (run, rv); + return res; + } + + /* need a map */ + ASE_AWK_FREE (run->awk, str); + ase_awk_refdownval (run, rv); + + ase_awk_setrunerror ( + run, ASE_AWK_ENOTMAPNILIN, right->line, ASE_NULL, 0); + return ASE_NULL; +} + +static ase_awk_val_t* __eval_binop_bor ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right) +{ + int n1, n2, n3; + ase_long_t l1, l2; + ase_real_t r1, r2; + ase_awk_val_t* res; + + n1 = ase_awk_valtonum (run, left, &l1, &r1); + n2 = ase_awk_valtonum (run, right, &l2, &r2); + + if (n1 == -1 || n2 == -1) + { + ase_awk_setrunerror (run, ASE_AWK_EOPERAND, 0, ASE_NULL, 0); + return ASE_NULL; + } + + n3 = n1 + (n2 << 1); + ASE_ASSERT (n3 >= 0 && n3 <= 3); + res = (n3 == 0)? ase_awk_makeintval(run,(ase_long_t)l1|(ase_long_t)l2): + (n3 == 1)? ase_awk_makeintval(run,(ase_long_t)r1|(ase_long_t)l2): + (n3 == 2)? ase_awk_makeintval(run,(ase_long_t)l1|(ase_long_t)r2): + ase_awk_makeintval(run,(ase_long_t)r1|(ase_long_t)r2); + + if (res == ASE_NULL) + { + ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return ASE_NULL; + } + return res; +} + +static ase_awk_val_t* __eval_binop_bxor ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right) +{ + int n1, n2, n3; + ase_long_t l1, l2; + ase_real_t r1, r2; + ase_awk_val_t* res; + + n1 = ase_awk_valtonum (run, left, &l1, &r1); + n2 = ase_awk_valtonum (run, right, &l2, &r2); + + if (n1 == -1 || n2 == -1) + { + ase_awk_setrunerror (run, ASE_AWK_EOPERAND, 0, ASE_NULL, 0); + return ASE_NULL; + } + + n3 = n1 + (n2 << 1); + ASE_ASSERT (n3 >= 0 && n3 <= 3); + res = (n3 == 0)? ase_awk_makeintval(run,(ase_long_t)l1^(ase_long_t)l2): + (n3 == 1)? ase_awk_makeintval(run,(ase_long_t)r1^(ase_long_t)l2): + (n3 == 2)? ase_awk_makeintval(run,(ase_long_t)l1^(ase_long_t)r2): + ase_awk_makeintval(run,(ase_long_t)r1^(ase_long_t)r2); + + if (res == ASE_NULL) + { + ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return ASE_NULL; + } + return res; +} + +static ase_awk_val_t* __eval_binop_band ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right) +{ + int n1, n2, n3; + ase_long_t l1, l2; + ase_real_t r1, r2; + ase_awk_val_t* res; + + n1 = ase_awk_valtonum (run, left, &l1, &r1); + n2 = ase_awk_valtonum (run, right, &l2, &r2); + + if (n1 == -1 || n2 == -1) + { + ase_awk_setrunerror (run, ASE_AWK_EOPERAND, 0, ASE_NULL, 0); + return ASE_NULL; + } + + n3 = n1 + (n2 << 1); + ASE_ASSERT (n3 >= 0 && n3 <= 3); + res = (n3 == 0)? ase_awk_makeintval(run,(ase_long_t)l1&(ase_long_t)l2): + (n3 == 1)? ase_awk_makeintval(run,(ase_long_t)r1&(ase_long_t)l2): + (n3 == 2)? ase_awk_makeintval(run,(ase_long_t)l1&(ase_long_t)r2): + ase_awk_makeintval(run,(ase_long_t)r1&(ase_long_t)r2); + + if (res == ASE_NULL) + { + ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return ASE_NULL; + } + return res; +} + +static int __cmp_nil_nil ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right) +{ + return 0; +} + +static int __cmp_nil_int ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right) +{ + if (((ase_awk_val_int_t*)right)->val < 0) return 1; + if (((ase_awk_val_int_t*)right)->val > 0) return -1; + return 0; +} + +static int __cmp_nil_real ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right) +{ + if (((ase_awk_val_real_t*)right)->val < 0) return 1; + if (((ase_awk_val_real_t*)right)->val > 0) return -1; + return 0; +} + +static int __cmp_nil_str ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right) +{ + return (((ase_awk_val_str_t*)right)->len == 0)? 0: -1; +} + +static int __cmp_int_nil ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right) +{ + if (((ase_awk_val_int_t*)left)->val > 0) return 1; + if (((ase_awk_val_int_t*)left)->val < 0) return -1; + return 0; +} + +static int __cmp_int_int ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right) +{ + if (((ase_awk_val_int_t*)left)->val > + ((ase_awk_val_int_t*)right)->val) return 1; + if (((ase_awk_val_int_t*)left)->val < + ((ase_awk_val_int_t*)right)->val) return -1; + return 0; +} + +static int __cmp_int_real ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right) +{ + if (((ase_awk_val_int_t*)left)->val > + ((ase_awk_val_real_t*)right)->val) return 1; + if (((ase_awk_val_int_t*)left)->val < + ((ase_awk_val_real_t*)right)->val) return -1; + return 0; +} + +static int __cmp_int_str ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right) +{ + ase_char_t* str; + ase_size_t len; + ase_long_t r; + ase_real_t rr; + int n; + + r = ase_awk_strxtolong (run->awk, + ((ase_awk_val_str_t*)right)->buf, + ((ase_awk_val_str_t*)right)->len, 0, (const ase_char_t**)&str); + if (str == ((ase_awk_val_str_t*)right)->buf + + ((ase_awk_val_str_t*)right)->len) + { + if (((ase_awk_val_int_t*)left)->val > r) return 1; + if (((ase_awk_val_int_t*)left)->val < r) return -1; + return 0; + } +/* TODO: should i do this??? conversion to real and comparision... */ + else if (*str == ASE_T('.') || *str == ASE_T('E') || *str == ASE_T('e')) + { + rr = ase_awk_strxtoreal (run->awk, + ((ase_awk_val_str_t*)right)->buf, + ((ase_awk_val_str_t*)right)->len, + (const ase_char_t**)&str); + if (str == ((ase_awk_val_str_t*)right)->buf + + ((ase_awk_val_str_t*)right)->len) + { + if (((ase_awk_val_int_t*)left)->val > rr) return 1; + if (((ase_awk_val_int_t*)left)->val < rr) return -1; + return 0; + } + } + + str = ase_awk_valtostr ( + run, left, ASE_AWK_VALTOSTR_CLEAR, ASE_NULL, &len); + if (str == ASE_NULL) return CMP_ERROR; + + if (run->global.ignorecase) + { + n = ase_strxncasecmp ( + str, len, + ((ase_awk_val_str_t*)right)->buf, + ((ase_awk_val_str_t*)right)->len, + &run->awk->prmfns.ccls); + } + else + { + n = ase_strxncmp ( + str, len, + ((ase_awk_val_str_t*)right)->buf, + ((ase_awk_val_str_t*)right)->len); + } + + ASE_AWK_FREE (run->awk, str); + return n; +} + +static int __cmp_real_nil ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right) +{ + if (((ase_awk_val_real_t*)left)->val > 0) return 1; + if (((ase_awk_val_real_t*)left)->val < 0) return -1; + return 0; +} + +static int __cmp_real_int ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right) +{ + if (((ase_awk_val_real_t*)left)->val > + ((ase_awk_val_int_t*)right)->val) return 1; + if (((ase_awk_val_real_t*)left)->val < + ((ase_awk_val_int_t*)right)->val) return -1; + return 0; +} + +static int __cmp_real_real ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right) +{ + if (((ase_awk_val_real_t*)left)->val > + ((ase_awk_val_real_t*)right)->val) return 1; + if (((ase_awk_val_real_t*)left)->val < + ((ase_awk_val_real_t*)right)->val) return -1; + return 0; +} + +static int __cmp_real_str ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right) +{ + ase_char_t* str; + ase_size_t len; + ase_real_t rr; + int n; + + rr = ase_awk_strxtoreal (run->awk, + ((ase_awk_val_str_t*)right)->buf, + ((ase_awk_val_str_t*)right)->len, + (const ase_char_t**)&str); + if (str == ((ase_awk_val_str_t*)right)->buf + + ((ase_awk_val_str_t*)right)->len) + { + if (((ase_awk_val_real_t*)left)->val > rr) return 1; + if (((ase_awk_val_real_t*)left)->val < rr) return -1; + return 0; + } + + str = ase_awk_valtostr ( + run, left, ASE_AWK_VALTOSTR_CLEAR, ASE_NULL, &len); + if (str == ASE_NULL) return CMP_ERROR; + + if (run->global.ignorecase) + { + n = ase_strxncasecmp ( + str, len, + ((ase_awk_val_str_t*)right)->buf, + ((ase_awk_val_str_t*)right)->len, + &run->awk->prmfns.ccls); + } + else + { + n = ase_strxncmp ( + str, len, + ((ase_awk_val_str_t*)right)->buf, + ((ase_awk_val_str_t*)right)->len); + } + + ASE_AWK_FREE (run->awk, str); + return n; +} + +static int __cmp_str_nil ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right) +{ + return (((ase_awk_val_str_t*)left)->len == 0)? 0: 1; +} + +static int __cmp_str_int ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right) +{ + return -__cmp_int_str (run, right, left); +} + +static int __cmp_str_real ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right) +{ + return -__cmp_real_str (run, right, left); +} + +static int __cmp_str_str ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right) +{ + int n; + ase_awk_val_str_t* ls, * rs; + + ls = (ase_awk_val_str_t*)left; + rs = (ase_awk_val_str_t*)right; + + if (run->global.ignorecase) + { + n = ase_strxncasecmp ( + ls->buf, ls->len, rs->buf, rs->len, + &run->awk->prmfns.ccls); + } + else + { + n = ase_strxncmp ( + ls->buf, ls->len, rs->buf, rs->len); + } + + return n; +} + +static int __cmp_val ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right) +{ + typedef int (*cmp_val_t) (ase_awk_run_t*, ase_awk_val_t*, ase_awk_val_t*); + + static cmp_val_t func[] = + { + /* this table must be synchronized with + * the ASE_AWK_VAL_XXX values in val.h */ + __cmp_nil_nil, __cmp_nil_int, __cmp_nil_real, __cmp_nil_str, + __cmp_int_nil, __cmp_int_int, __cmp_int_real, __cmp_int_str, + __cmp_real_nil, __cmp_real_int, __cmp_real_real, __cmp_real_str, + __cmp_str_nil, __cmp_str_int, __cmp_str_real, __cmp_str_str, + }; + + if (left->type == ASE_AWK_VAL_MAP || right->type == ASE_AWK_VAL_MAP) + { + /* a map can't be compared againt other values */ + ase_awk_setrunerror (run, ASE_AWK_EOPERAND, 0, ASE_NULL, 0); + return CMP_ERROR; + } + + ASE_ASSERT ( + left->type >= ASE_AWK_VAL_NIL && + left->type <= ASE_AWK_VAL_STR); + ASE_ASSERT ( + right->type >= ASE_AWK_VAL_NIL && + right->type <= ASE_AWK_VAL_STR); + + return func[left->type*4+right->type] (run, left, right); +} + +static ase_awk_val_t* __eval_binop_eq ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right) +{ + int n = __cmp_val (run, left, right); + if (n == CMP_ERROR) return ASE_NULL; + return (n == 0)? ase_awk_val_one: ase_awk_val_zero; +} + +static ase_awk_val_t* __eval_binop_ne ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right) +{ + int n = __cmp_val (run, left, right); + if (n == CMP_ERROR) return ASE_NULL; + return (n != 0)? ase_awk_val_one: ase_awk_val_zero; +} + +static ase_awk_val_t* __eval_binop_gt ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right) +{ + int n = __cmp_val (run, left, right); + if (n == CMP_ERROR) return ASE_NULL; + return (n > 0)? ase_awk_val_one: ase_awk_val_zero; +} + +static ase_awk_val_t* __eval_binop_ge ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right) +{ + int n = __cmp_val (run, left, right); + if (n == CMP_ERROR) return ASE_NULL; + return (n >= 0)? ase_awk_val_one: ase_awk_val_zero; +} + +static ase_awk_val_t* __eval_binop_lt ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right) +{ + int n = __cmp_val (run, left, right); + if (n == CMP_ERROR) return ASE_NULL; + return (n < 0)? ase_awk_val_one: ase_awk_val_zero; +} + +static ase_awk_val_t* __eval_binop_le ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right) +{ + int n = __cmp_val (run, left, right); + if (n == CMP_ERROR) return ASE_NULL; + return (n <= 0)? ase_awk_val_one: ase_awk_val_zero; +} + +static ase_awk_val_t* __eval_binop_lshift ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right) +{ + int n1, n2, n3; + ase_long_t l1, l2; + ase_real_t r1, r2; + ase_awk_val_t* res; + + n1 = ase_awk_valtonum (run, left, &l1, &r1); + n2 = ase_awk_valtonum (run, right, &l2, &r2); + + if (n1 == -1 || n2 == -1) + { + ase_awk_setrunerror (run, ASE_AWK_EOPERAND, 0, ASE_NULL, 0); + return ASE_NULL; + } + + n3 = n1 + (n2 << 1); + if (n3 == 0) + { + res = ase_awk_makeintval ( + run, (ase_long_t)l1<<(ase_long_t)l2); + } + else + { + ase_awk_setrunerror (run, ASE_AWK_EOPERAND, 0, ASE_NULL, 0); + return ASE_NULL; + } + + if (res == ASE_NULL) + { + ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return ASE_NULL; + } + return res; +} + +static ase_awk_val_t* __eval_binop_rshift ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right) +{ + int n1, n2, n3; + ase_long_t l1, l2; + ase_real_t r1, r2; + ase_awk_val_t* res; + + n1 = ase_awk_valtonum (run, left, &l1, &r1); + n2 = ase_awk_valtonum (run, right, &l2, &r2); + + if (n1 == -1 || n2 == -1) + { + ase_awk_setrunerror (run, ASE_AWK_EOPERAND, 0, ASE_NULL, 0); + return ASE_NULL; + } + + n3 = n1 + (n2 << 1); + if (n3 == 0) + { + res = ase_awk_makeintval ( + run, (ase_long_t)l1>>(ase_long_t)l2); + } + else + { + ase_awk_setrunerror (run, ASE_AWK_EOPERAND, 0, ASE_NULL, 0); + return ASE_NULL; + } + + if (res == ASE_NULL) + { + ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return ASE_NULL; + } + return res; +} + +static ase_awk_val_t* __eval_binop_plus ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right) +{ + int n1, n2, n3; + ase_long_t l1, l2; + ase_real_t r1, r2; + ase_awk_val_t* res; + + n1 = ase_awk_valtonum (run, left, &l1, &r1); + n2 = ase_awk_valtonum (run, right, &l2, &r2); + + if (n1 == -1 || n2 == -1) + { + ase_awk_setrunerror (run, ASE_AWK_EOPERAND, 0, ASE_NULL, 0); + return ASE_NULL; + } + /* + n1 n2 n3 + 0 0 = 0 + 1 0 = 1 + 0 1 = 2 + 1 1 = 3 + */ + n3 = n1 + (n2 << 1); + ASE_ASSERT (n3 >= 0 && n3 <= 3); + res = (n3 == 0)? ase_awk_makeintval(run,(ase_long_t)l1+(ase_long_t)l2): + (n3 == 1)? ase_awk_makerealval(run,(ase_real_t)r1+(ase_real_t)l2): + (n3 == 2)? ase_awk_makerealval(run,(ase_real_t)l1+(ase_real_t)r2): + ase_awk_makerealval(run,(ase_real_t)r1+(ase_real_t)r2); + + if (res == ASE_NULL) + { + ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return ASE_NULL; + } + return res; +} + +static ase_awk_val_t* __eval_binop_minus ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right) +{ + int n1, n2, n3; + ase_long_t l1, l2; + ase_real_t r1, r2; + ase_awk_val_t* res; + + n1 = ase_awk_valtonum (run, left, &l1, &r1); + n2 = ase_awk_valtonum (run, right, &l2, &r2); + + if (n1 == -1 || n2 == -1) + { + ase_awk_setrunerror (run, ASE_AWK_EOPERAND, 0, ASE_NULL, 0); + return ASE_NULL; + } + + n3 = n1 + (n2 << 1); + ASE_ASSERT (n3 >= 0 && n3 <= 3); + res = (n3 == 0)? ase_awk_makeintval(run,(ase_long_t)l1-(ase_long_t)l2): + (n3 == 1)? ase_awk_makerealval(run,(ase_real_t)r1-(ase_real_t)l2): + (n3 == 2)? ase_awk_makerealval(run,(ase_real_t)l1-(ase_real_t)r2): + ase_awk_makerealval(run,(ase_real_t)r1-(ase_real_t)r2); + + if (res == ASE_NULL) + { + ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return ASE_NULL; + } + return res; +} + +static ase_awk_val_t* __eval_binop_mul ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right) +{ + int n1, n2, n3; + ase_long_t l1, l2; + ase_real_t r1, r2; + ase_awk_val_t* res; + + n1 = ase_awk_valtonum (run, left, &l1, &r1); + n2 = ase_awk_valtonum (run, right, &l2, &r2); + + if (n1 == -1 || n2 == -1) + { + ase_awk_setrunerror (run, ASE_AWK_EOPERAND, 0, ASE_NULL, 0); + return ASE_NULL; + } + + n3 = n1 + (n2 << 1); + ASE_ASSERT (n3 >= 0 && n3 <= 3); + res = (n3 == 0)? ase_awk_makeintval(run,(ase_long_t)l1*(ase_long_t)l2): + (n3 == 1)? ase_awk_makerealval(run,(ase_real_t)r1*(ase_real_t)l2): + (n3 == 2)? ase_awk_makerealval(run,(ase_real_t)l1*(ase_real_t)r2): + ase_awk_makerealval(run,(ase_real_t)r1*(ase_real_t)r2); + + if (res == ASE_NULL) + { + ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return ASE_NULL; + } + return res; +} + +static ase_awk_val_t* __eval_binop_div ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right) +{ + int n1, n2, n3; + ase_long_t l1, l2; + ase_real_t r1, r2; + ase_awk_val_t* res; + + n1 = ase_awk_valtonum (run, left, &l1, &r1); + n2 = ase_awk_valtonum (run, right, &l2, &r2); + + if (n1 == -1 || n2 == -1) + { + ase_awk_setrunerror (run, ASE_AWK_EOPERAND, 0, ASE_NULL, 0); + return ASE_NULL; + } + + n3 = n1 + (n2 << 1); + if (n3 == 0) + { + if (l2 == 0) + { + ase_awk_setrunerror ( + run, ASE_AWK_EDIVBY0, 0, ASE_NULL, 0); + return ASE_NULL; + } + + if (((ase_long_t)l1 % (ase_long_t)l2) == 0) + { + res = ase_awk_makeintval ( + run, (ase_long_t)l1 / (ase_long_t)l2); + } + else + { + res = ase_awk_makerealval ( + run, (ase_real_t)l1 / (ase_real_t)l2); + } + } + else if (n3 == 1) + { + res = ase_awk_makerealval ( + run, (ase_real_t)r1 / (ase_real_t)l2); + } + else if (n3 == 2) + { + res = ase_awk_makerealval ( + run, (ase_real_t)l1 / (ase_real_t)r2); + } + else + { + ASE_ASSERT (n3 == 3); + res = ase_awk_makerealval ( + run, (ase_real_t)r1 / (ase_real_t)r2); + } + + if (res == ASE_NULL) + { + ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return ASE_NULL; + } + return res; +} + +static ase_awk_val_t* __eval_binop_idiv ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right) +{ + int n1, n2, n3; + ase_long_t l1, l2; + ase_real_t r1, r2, quo; + ase_awk_val_t* res; + + n1 = ase_awk_valtonum (run, left, &l1, &r1); + n2 = ase_awk_valtonum (run, right, &l2, &r2); + + if (n1 == -1 || n2 == -1) + { + ase_awk_setrunerror (run, ASE_AWK_EOPERAND, 0, ASE_NULL, 0); + return ASE_NULL; + } + + n3 = n1 + (n2 << 1); + if (n3 == 0) + { + if (l2 == 0) + { + ase_awk_setrunerror ( + run, ASE_AWK_EDIVBY0, 0, ASE_NULL, 0); + return ASE_NULL; + } + res = ase_awk_makeintval ( + run, (ase_long_t)l1 / (ase_long_t)l2); + } + else if (n3 == 1) + { + quo = (ase_real_t)r1 / (ase_real_t)l2; + res = ase_awk_makeintval (run, (ase_long_t)quo); + } + else if (n3 == 2) + { + quo = (ase_real_t)l1 / (ase_real_t)r2; + res = ase_awk_makeintval (run, (ase_long_t)quo); + } + else + { + ASE_ASSERT (n3 == 3); + + quo = (ase_real_t)r1 / (ase_real_t)r2; + res = ase_awk_makeintval (run, (ase_long_t)quo); + } + + if (res == ASE_NULL) + { + ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return ASE_NULL; + } + return res; +} + +static ase_awk_val_t* __eval_binop_mod ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right) +{ + int n1, n2, n3; + ase_long_t l1, l2; + ase_real_t r1, r2; + ase_awk_val_t* res; + + n1 = ase_awk_valtonum (run, left, &l1, &r1); + n2 = ase_awk_valtonum (run, right, &l2, &r2); + + if (n1 == -1 || n2 == -1) + { + ase_awk_setrunerror (run, ASE_AWK_EOPERAND, 0, ASE_NULL, 0); + return ASE_NULL; + } + + n3 = n1 + (n2 << 1); + if (n3 == 0) + { + if (l2 == 0) + { + ase_awk_setrunerror (run, ASE_AWK_EDIVBY0, 0, ASE_NULL, 0); + return ASE_NULL; + } + res = ase_awk_makeintval ( + run, (ase_long_t)l1 % (ase_long_t)l2); + } + else + { + ase_awk_setrunerror (run, ASE_AWK_EOPERAND, 0, ASE_NULL, 0); + return ASE_NULL; + } + + if (res == ASE_NULL) + { + ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return ASE_NULL; + } + return res; +} + +static ase_awk_val_t* __eval_binop_exp ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right) +{ + int n1, n2, n3; + ase_long_t l1, l2; + ase_real_t r1, r2; + ase_awk_val_t* res; + + ASE_ASSERTX (run->awk->prmfns.misc.pow != ASE_NULL, + "the pow function should be provided when the awk object is created to make the exponentiation work properly."); + + n1 = ase_awk_valtonum (run, left, &l1, &r1); + n2 = ase_awk_valtonum (run, right, &l2, &r2); + + if (n1 == -1 || n2 == -1) + { + ase_awk_setrunerror (run, ASE_AWK_EOPERAND, 0, ASE_NULL, 0); + return ASE_NULL; + } + + n3 = n1 + (n2 << 1); + if (n3 == 0) + { + /* left - int, right - int */ + if (l2 >= 0) + { + ase_long_t v = 1; + while (l2-- > 0) v *= l1; + res = ase_awk_makeintval (run, v); + } + else if (l1 == 0) + { + ase_awk_setrunerror ( + run, ASE_AWK_EDIVBY0, 0, ASE_NULL, 0); + return ASE_NULL; + } + else + { + ase_real_t v = 1.0; + l2 *= -1; + while (l2-- > 0) v /= l1; + res = ase_awk_makerealval (run, v); + } + } + else if (n3 == 1) + { + /* left - real, right - int */ + if (l2 >= 0) + { + ase_real_t v = 1.0; + while (l2-- > 0) v *= r1; + res = ase_awk_makerealval (run, v); + } + else if (r1 == 0.0) + { + ase_awk_setrunerror ( + run, ASE_AWK_EDIVBY0, 0, ASE_NULL, 0); + return ASE_NULL; + } + else + { + ase_real_t v = 1.0; + l2 *= -1; + while (l2-- > 0) v /= r1; + res = ase_awk_makerealval (run, v); + } + } + else if (n3 == 2) + { + /* left - int, right - real */ + res = ase_awk_makerealval (run, + run->awk->prmfns.misc.pow ( + run->awk->prmfns.misc.custom_data, + (ase_real_t)l1,(ase_real_t)r2)); + } + else + { + /* left - real, right - real */ + ASE_ASSERT (n3 == 3); + res = ase_awk_makerealval (run, + run->awk->prmfns.misc.pow( + run->awk->prmfns.misc.custom_data, + (ase_real_t)r1,(ase_real_t)r2)); + } + + if (res == ASE_NULL) + { + ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return ASE_NULL; + } + + return res; +} + +static ase_awk_val_t* __eval_binop_concat ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right) +{ + ase_char_t* strl, * strr; + ase_size_t strl_len, strr_len; + ase_awk_val_t* res; + + strl = ase_awk_valtostr ( + run, left, ASE_AWK_VALTOSTR_CLEAR, ASE_NULL, &strl_len); + if (strl == ASE_NULL) return ASE_NULL; + + strr = ase_awk_valtostr ( + run, right, ASE_AWK_VALTOSTR_CLEAR, ASE_NULL, &strr_len); + if (strr == ASE_NULL) + { + ASE_AWK_FREE (run->awk, strl); + return ASE_NULL; + } + + res = ase_awk_makestrval2 (run, strl, strl_len, strr, strr_len); + if (res == ASE_NULL) + { + ASE_AWK_FREE (run->awk, strl); + ASE_AWK_FREE (run->awk, strr); + + ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return ASE_NULL; + } + + ASE_AWK_FREE (run->awk, strl); + ASE_AWK_FREE (run->awk, strr); + + return res; +} + +static ase_awk_val_t* __eval_binop_ma ( + ase_awk_run_t* run, ase_awk_nde_t* left, ase_awk_nde_t* right) +{ + ase_awk_val_t* lv, * rv, * res; + + ASE_ASSERT (left->next == ASE_NULL); + ASE_ASSERT (right->next == ASE_NULL); + + lv = __eval_expression (run, left); + if (lv == ASE_NULL) + { + return ASE_NULL; + } + + ase_awk_refupval (run, lv); + + rv = __eval_expression0 (run, right); + if (rv == ASE_NULL) + { + ase_awk_refdownval (run, lv); + return ASE_NULL; + } + + ase_awk_refupval (run, rv); + + res = __eval_binop_match0 ( + run, lv, rv, left->line, right->line, 1); + + ase_awk_refdownval (run, lv); + ase_awk_refdownval (run, rv); + + return res; +} + +static ase_awk_val_t* __eval_binop_nm ( + ase_awk_run_t* run, ase_awk_nde_t* left, ase_awk_nde_t* right) +{ + ase_awk_val_t* lv, * rv, * res; + + ASE_ASSERT (left->next == ASE_NULL); + ASE_ASSERT (right->next == ASE_NULL); + + lv = __eval_expression (run, left); + if (lv == ASE_NULL) return ASE_NULL; + + ase_awk_refupval (run, lv); + + rv = __eval_expression0 (run, right); + if (rv == ASE_NULL) + { + ase_awk_refdownval (run, lv); + return ASE_NULL; + } + + ase_awk_refupval (run, rv); + + res = __eval_binop_match0 ( + run, lv, rv, left->line, right->line, 0); + + ase_awk_refdownval (run, lv); + ase_awk_refdownval (run, rv); + + return res; +} + +static ase_awk_val_t* __eval_binop_match0 ( + ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right, + ase_size_t lline, ase_size_t rline, int ret) +{ + ase_awk_val_t* res; + int n, errnum; + ase_char_t* str; + ase_size_t len; + void* rex_code; + + if (right->type == ASE_AWK_VAL_REX) + { + rex_code = ((ase_awk_val_rex_t*)right)->code; + } + else if (right->type == ASE_AWK_VAL_STR) + { + rex_code = ase_awk_buildrex ( + run->awk, + ((ase_awk_val_str_t*)right)->buf, + ((ase_awk_val_str_t*)right)->len, &errnum); + if (rex_code == ASE_NULL) + { + ase_awk_setrunerror (run, errnum, rline, ASE_NULL, 0); + return ASE_NULL; + } + } + else + { + str = ase_awk_valtostr ( + run, right, ASE_AWK_VALTOSTR_CLEAR, ASE_NULL, &len); + if (str == ASE_NULL) return ASE_NULL; + + rex_code = ase_awk_buildrex (run->awk, str, len, &errnum); + if (rex_code == ASE_NULL) + { + ASE_AWK_FREE (run->awk, str); + + ase_awk_setrunerror (run, errnum, rline, ASE_NULL, 0); + return ASE_NULL; + } + + ASE_AWK_FREE (run->awk, str); + } + + if (left->type == ASE_AWK_VAL_STR) + { + n = ase_awk_matchrex ( + run->awk, rex_code, + ((run->global.ignorecase)? ASE_AWK_REX_IGNORECASE: 0), + ((ase_awk_val_str_t*)left)->buf, + ((ase_awk_val_str_t*)left)->len, + ASE_NULL, ASE_NULL, &errnum); + if (n == -1) + { + if (right->type != ASE_AWK_VAL_REX) + ASE_AWK_FREE (run->awk, rex_code); + + ase_awk_setrunerror (run, errnum, lline, ASE_NULL, 0); + return ASE_NULL; + } + + res = ase_awk_makeintval (run, (n == ret)); + if (res == ASE_NULL) + { + if (right->type != ASE_AWK_VAL_REX) + ASE_AWK_FREE (run->awk, rex_code); + + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, lline, ASE_NULL, 0); + return ASE_NULL; + } + } + else + { + str = ase_awk_valtostr ( + run, left, ASE_AWK_VALTOSTR_CLEAR, ASE_NULL, &len); + if (str == ASE_NULL) + { + if (right->type != ASE_AWK_VAL_REX) + ASE_AWK_FREE (run->awk, rex_code); + return ASE_NULL; + } + + n = ase_awk_matchrex ( + run->awk, rex_code, + ((run->global.ignorecase)? ASE_AWK_REX_IGNORECASE: 0), + str, len, ASE_NULL, ASE_NULL, &errnum); + if (n == -1) + { + ASE_AWK_FREE (run->awk, str); + if (right->type != ASE_AWK_VAL_REX) + ASE_AWK_FREE (run->awk, rex_code); + + ase_awk_setrunerror (run, errnum, lline, ASE_NULL, 0); + return ASE_NULL; + } + + res = ase_awk_makeintval (run, (n == ret)); + if (res == ASE_NULL) + { + ASE_AWK_FREE (run->awk, str); + if (right->type != ASE_AWK_VAL_REX) + ASE_AWK_FREE (run->awk, rex_code); + + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, lline, ASE_NULL, 0); + return ASE_NULL; + } + + ASE_AWK_FREE (run->awk, str); + } + + if (right->type != ASE_AWK_VAL_REX) ASE_AWK_FREE (run->awk, rex_code); + return res; +} + +static ase_awk_val_t* __eval_unary (ase_awk_run_t* run, ase_awk_nde_t* nde) +{ + ase_awk_val_t* left, * res = ASE_NULL; + ase_awk_nde_exp_t* exp = (ase_awk_nde_exp_t*)nde; + int n; + ase_long_t l; + ase_real_t r; + + ASE_ASSERT ( + exp->type == ASE_AWK_NDE_EXP_UNR); + ASE_ASSERT ( + exp->left != ASE_NULL && exp->right == ASE_NULL); + ASE_ASSERT ( + exp->opcode == ASE_AWK_UNROP_PLUS || + exp->opcode == ASE_AWK_UNROP_MINUS || + exp->opcode == ASE_AWK_UNROP_NOT || + exp->opcode == ASE_AWK_UNROP_BNOT); + + ASE_ASSERT (exp->left->next == ASE_NULL); + left = __eval_expression (run, exp->left); + if (left == ASE_NULL) return ASE_NULL; + + ase_awk_refupval (run, left); + + if (exp->opcode == ASE_AWK_UNROP_MINUS) + { + n = ase_awk_valtonum (run, left, &l, &r); + if (n == -1) + { + ase_awk_refdownval (run, left); + return ASE_NULL; + } + + res = (n == 0)? ase_awk_makeintval (run, -l): + ase_awk_makerealval (run, -r); + } + else if (exp->opcode == ASE_AWK_UNROP_NOT) + { + if (left->type == ASE_AWK_VAL_STR) + { + res = ase_awk_makeintval ( + run, !(((ase_awk_val_str_t*)left)->len > 0)); + } + else + { + n = ase_awk_valtonum (run, left, &l, &r); + if (n == -1) + { + ase_awk_refdownval (run, left); + return ASE_NULL; + } + + res = (n == 0)? ase_awk_makeintval (run, !l): + ase_awk_makerealval (run, !r); + } + } + else if (exp->opcode == ASE_AWK_UNROP_BNOT) + { + n = ase_awk_valtonum (run, left, &l, &r); + if (n == -1) + { + ase_awk_refdownval (run, left); + return ASE_NULL; + } + + if (n == 1) l = (ase_long_t)r; + res = ase_awk_makeintval (run, ~l); + } + else if (exp->opcode == ASE_AWK_UNROP_PLUS) + { + n = ase_awk_valtonum (run, left, &l, &r); + if (n == -1) + { + ase_awk_refdownval (run, left); + return ASE_NULL; + } + + res = (n == 0)? ase_awk_makeintval (run, l): + ase_awk_makerealval (run, r); + } + + if (res == ASE_NULL) + { + ase_awk_refdownval (run, left); + + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, nde->line, ASE_NULL, 0); + return ASE_NULL; + } + + ase_awk_refdownval (run, left); + return res; +} + +static ase_awk_val_t* __eval_incpre (ase_awk_run_t* run, ase_awk_nde_t* nde) +{ + ase_awk_val_t* left, * res; + ase_awk_nde_exp_t* exp = (ase_awk_nde_exp_t*)nde; + + ASE_ASSERT ( + exp->type == ASE_AWK_NDE_EXP_INCPRE); + ASE_ASSERT ( + exp->left != ASE_NULL && exp->right == ASE_NULL); + + /* this way of checking if the l-value is assignable is + * ugly as it is dependent of the values defined in tree.h. + * but let's keep going this way for the time being. */ + if (exp->left->type < ASE_AWK_NDE_NAMED || + exp->left->type > ASE_AWK_NDE_ARGIDX) + { + ase_awk_setrunerror ( + run, ASE_AWK_EOPERAND, nde->line, ASE_NULL, 0); + return ASE_NULL; + } + + ASE_ASSERT (exp->left->next == ASE_NULL); + left = __eval_expression (run, exp->left); + if (left == ASE_NULL) return ASE_NULL; + + ase_awk_refupval (run, left); + + if (exp->opcode == ASE_AWK_INCOP_PLUS) + { + if (left->type == ASE_AWK_VAL_INT) + { + ase_long_t r = ((ase_awk_val_int_t*)left)->val; + res = ase_awk_makeintval (run, r + 1); + if (res == ASE_NULL) + { + ase_awk_refdownval (run, left); + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, nde->line, + ASE_NULL, 0); + return ASE_NULL; + } + } + else if (left->type == ASE_AWK_VAL_REAL) + { + ase_real_t r = ((ase_awk_val_real_t*)left)->val; + res = ase_awk_makerealval (run, r + 1.0); + if (res == ASE_NULL) + { + ase_awk_refdownval (run, left); + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, nde->line, + ASE_NULL, 0); + return ASE_NULL; + } + } + else + { + ase_long_t v1; + ase_real_t v2; + int n; + + n = ase_awk_valtonum (run, left, &v1, &v2); + if (n == -1) + { + ase_awk_refdownval (run, left); + ase_awk_setrunerror ( + run, ASE_AWK_EOPERAND, nde->line, ASE_NULL, 0); + return ASE_NULL; + } + + if (n == 0) + { + res = ase_awk_makeintval (run, v1 + 1); + } + else /* if (n == 1) */ + { + ASE_ASSERT (n == 1); + res = ase_awk_makerealval (run, v2 + 1.0); + } + + if (res == ASE_NULL) + { + ase_awk_refdownval (run, left); + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, nde->line, + ASE_NULL, 0); + return ASE_NULL; + } + } + } + else if (exp->opcode == ASE_AWK_INCOP_MINUS) + { + if (left->type == ASE_AWK_VAL_INT) + { + ase_long_t r = ((ase_awk_val_int_t*)left)->val; + res = ase_awk_makeintval (run, r - 1); + if (res == ASE_NULL) + { + ase_awk_refdownval (run, left); + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, nde->line, + ASE_NULL, 0); + return ASE_NULL; + } + } + else if (left->type == ASE_AWK_VAL_REAL) + { + ase_real_t r = ((ase_awk_val_real_t*)left)->val; + res = ase_awk_makerealval (run, r - 1.0); + if (res == ASE_NULL) + { + ase_awk_refdownval (run, left); + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, nde->line, + ASE_NULL, 0); + return ASE_NULL; + } + } + else + { + ase_long_t v1; + ase_real_t v2; + int n; + + n = ase_awk_valtonum (run, left, &v1, &v2); + if (n == -1) + { + ase_awk_refdownval (run, left); + ase_awk_setrunerror ( + run, ASE_AWK_EOPERAND, nde->line, + ASE_NULL, 0); + return ASE_NULL; + } + + if (n == 0) + { + res = ase_awk_makeintval (run, v1 - 1); + } + else /* if (n == 1) */ + { + ASE_ASSERT (n == 1); + res = ase_awk_makerealval (run, v2 - 1.0); + } + + if (res == ASE_NULL) + { + ase_awk_refdownval (run, left); + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, nde->line, + ASE_NULL, 0); + return ASE_NULL; + } + } + } + else + { + ASE_ASSERT ( + !"should never happen - invalid opcode"); + ase_awk_refdownval (run, left); + + ase_awk_setrunerror ( + run, ASE_AWK_EINTERN, nde->line, ASE_NULL, 0); + return ASE_NULL; + } + + if (__do_assignment (run, exp->left, res) == ASE_NULL) + { + ase_awk_refdownval (run, left); + return ASE_NULL; + } + + ase_awk_refdownval (run, left); + return res; +} + +static ase_awk_val_t* __eval_incpst (ase_awk_run_t* run, ase_awk_nde_t* nde) +{ + ase_awk_val_t* left, * res, * res2; + ase_awk_nde_exp_t* exp = (ase_awk_nde_exp_t*)nde; + + ASE_ASSERT ( + exp->type == ASE_AWK_NDE_EXP_INCPST); + ASE_ASSERT ( + exp->left != ASE_NULL && exp->right == ASE_NULL); + + /* this way of checking if the l-value is assignable is + * ugly as it is dependent of the values defined in tree.h. + * but let's keep going this way for the time being. */ + if (exp->left->type < ASE_AWK_NDE_NAMED || + exp->left->type > ASE_AWK_NDE_ARGIDX) + { + ase_awk_setrunerror ( + run, ASE_AWK_EOPERAND, nde->line, ASE_NULL, 0); + return ASE_NULL; + } + + ASE_ASSERT (exp->left->next == ASE_NULL); + left = __eval_expression (run, exp->left); + if (left == ASE_NULL) return ASE_NULL; + + ase_awk_refupval (run, left); + + if (exp->opcode == ASE_AWK_INCOP_PLUS) + { + if (left->type == ASE_AWK_VAL_INT) + { + ase_long_t r = ((ase_awk_val_int_t*)left)->val; + res = ase_awk_makeintval (run, r); + if (res == ASE_NULL) + { + ase_awk_refdownval (run, left); + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, nde->line, + ASE_NULL, 0); + return ASE_NULL; + } + + res2 = ase_awk_makeintval (run, r + 1); + if (res2 == ASE_NULL) + { + ase_awk_refdownval (run, left); + ase_awk_freeval (run, res, ase_true); + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, nde->line, + ASE_NULL, 0); + return ASE_NULL; + } + } + else if (left->type == ASE_AWK_VAL_REAL) + { + ase_real_t r = ((ase_awk_val_real_t*)left)->val; + res = ase_awk_makerealval (run, r); + if (res == ASE_NULL) + { + ase_awk_refdownval (run, left); + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, nde->line, + ASE_NULL, 0); + return ASE_NULL; + } + + res2 = ase_awk_makerealval (run, r + 1.0); + if (res2 == ASE_NULL) + { + ase_awk_refdownval (run, left); + ase_awk_freeval (run, res, ase_true); + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, nde->line, + ASE_NULL, 0); + return ASE_NULL; + } + } + else + { + ase_long_t v1; + ase_real_t v2; + int n; + + n = ase_awk_valtonum (run, left, &v1, &v2); + if (n == -1) + { + ase_awk_refdownval (run, left); + ase_awk_setrunerror ( + run, ASE_AWK_EOPERAND, nde->line, + ASE_NULL, 0); + return ASE_NULL; + } + + if (n == 0) + { + res = ase_awk_makeintval (run, v1); + if (res == ASE_NULL) + { + ase_awk_refdownval (run, left); + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, nde->line, + ASE_NULL, 0); + return ASE_NULL; + } + + res2 = ase_awk_makeintval (run, v1 + 1); + if (res2 == ASE_NULL) + { + ase_awk_refdownval (run, left); + ase_awk_freeval (run, res, ase_true); + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, nde->line, + ASE_NULL, 0); + return ASE_NULL; + } + } + else /* if (n == 1) */ + { + ASE_ASSERT (n == 1); + res = ase_awk_makerealval (run, v2); + if (res == ASE_NULL) + { + ase_awk_refdownval (run, left); + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, nde->line, + ASE_NULL, 0); + return ASE_NULL; + } + + res2 = ase_awk_makerealval (run, v2 + 1.0); + if (res2 == ASE_NULL) + { + ase_awk_refdownval (run, left); + ase_awk_freeval (run, res, ase_true); + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, nde->line, + ASE_NULL, 0); + return ASE_NULL; + } + } + } + } + else if (exp->opcode == ASE_AWK_INCOP_MINUS) + { + if (left->type == ASE_AWK_VAL_INT) + { + ase_long_t r = ((ase_awk_val_int_t*)left)->val; + res = ase_awk_makeintval (run, r); + if (res == ASE_NULL) + { + ase_awk_refdownval (run, left); + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, nde->line, + ASE_NULL, 0); + return ASE_NULL; + } + + res2 = ase_awk_makeintval (run, r - 1); + if (res2 == ASE_NULL) + { + ase_awk_refdownval (run, left); + ase_awk_freeval (run, res, ase_true); + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, nde->line, + ASE_NULL, 0); + return ASE_NULL; + } + } + else if (left->type == ASE_AWK_VAL_REAL) + { + ase_real_t r = ((ase_awk_val_real_t*)left)->val; + res = ase_awk_makerealval (run, r); + if (res == ASE_NULL) + { + ase_awk_refdownval (run, left); + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, nde->line, + ASE_NULL, 0); + return ASE_NULL; + } + + res2 = ase_awk_makerealval (run, r - 1.0); + if (res2 == ASE_NULL) + { + ase_awk_refdownval (run, left); + ase_awk_freeval (run, res, ase_true); + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, nde->line, + ASE_NULL, 0); + return ASE_NULL; + } + } + else + { + ase_long_t v1; + ase_real_t v2; + int n; + + n = ase_awk_valtonum (run, left, &v1, &v2); + if (n == -1) + { + ase_awk_refdownval (run, left); + ase_awk_setrunerror ( + run, ASE_AWK_EOPERAND, nde->line, + ASE_NULL, 0); + return ASE_NULL; + } + + if (n == 0) + { + res = ase_awk_makeintval (run, v1); + if (res == ASE_NULL) + { + ase_awk_refdownval (run, left); + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, nde->line, + ASE_NULL, 0); + return ASE_NULL; + } + + res2 = ase_awk_makeintval (run, v1 - 1); + if (res2 == ASE_NULL) + { + ase_awk_refdownval (run, left); + ase_awk_freeval (run, res, ase_true); + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, nde->line, + ASE_NULL, 0); + return ASE_NULL; + } + } + else /* if (n == 1) */ + { + ASE_ASSERT (n == 1); + res = ase_awk_makerealval (run, v2); + if (res == ASE_NULL) + { + ase_awk_refdownval (run, left); + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, nde->line, + ASE_NULL, 0); + return ASE_NULL; + } + + res2 = ase_awk_makerealval (run, v2 - 1.0); + if (res2 == ASE_NULL) + { + ase_awk_refdownval (run, left); + ase_awk_freeval (run, res, ase_true); + + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, nde->line, + ASE_NULL, 0); + return ASE_NULL; + } + } + } + } + else + { + ASE_ASSERT ( + !"should never happen - invalid opcode"); + ase_awk_refdownval (run, left); + + ase_awk_setrunerror ( + run, ASE_AWK_EINTERN, nde->line, ASE_NULL, 0); + return ASE_NULL; + } + + if (__do_assignment (run, exp->left, res2) == ASE_NULL) + { + ase_awk_refdownval (run, left); + return ASE_NULL; + } + + ase_awk_refdownval (run, left); + return res; +} + +static ase_awk_val_t* __eval_cnd (ase_awk_run_t* run, ase_awk_nde_t* nde) +{ + ase_awk_val_t* tv, * v; + ase_awk_nde_cnd_t* cnd = (ase_awk_nde_cnd_t*)nde; + + ASE_ASSERT (cnd->test->next == ASE_NULL); + + tv = __eval_expression (run, cnd->test); + if (tv == ASE_NULL) return ASE_NULL; + + ase_awk_refupval (run, tv); + + ASE_ASSERT ( + cnd->left->next == ASE_NULL && + cnd->right->next == ASE_NULL); + v = (ase_awk_valtobool (run, tv))? + __eval_expression (run, cnd->left): + __eval_expression (run, cnd->right); + + ase_awk_refdownval (run, tv); + return v; +} + +static ase_awk_val_t* __eval_bfn (ase_awk_run_t* run, ase_awk_nde_t* nde) +{ + ase_awk_nde_call_t* call = (ase_awk_nde_call_t*)nde; + + /* built-in function */ + if (call->nargs < call->what.bfn.arg.min) + { + ase_awk_setrunerror ( + run, ASE_AWK_EARGTF, nde->line, ASE_NULL, 0); + return ASE_NULL; + } + + if (call->nargs > call->what.bfn.arg.max) + { + ase_awk_setrunerror ( + run, ASE_AWK_EARGTM, nde->line, ASE_NULL, 0); + return ASE_NULL; + } + + return __eval_call (run, nde, call->what.bfn.arg.spec, ASE_NULL); +} + +static ase_awk_val_t* __eval_afn (ase_awk_run_t* run, ase_awk_nde_t* nde) +{ + ase_awk_nde_call_t* call = (ase_awk_nde_call_t*)nde; + ase_awk_afn_t* afn; + ase_awk_pair_t* pair; + + pair = ase_awk_map_get (&run->awk->tree.afns, + call->what.afn.name.ptr, call->what.afn.name.len); + if (pair == ASE_NULL) + { + ase_cstr_t errarg; + + errarg.ptr = call->what.afn.name.ptr; + errarg.len = call->what.afn.name.len, + + ase_awk_setrunerror (run, + ASE_AWK_EFNNONE, nde->line, &errarg, 1); + return ASE_NULL; + } + + afn = (ase_awk_afn_t*)pair->val; + ASE_ASSERT (afn != ASE_NULL); + + if (call->nargs > afn->nargs) + { + /* TODO: is this correct? what if i want to + * allow arbitarary numbers of arguments? */ + ase_awk_setrunerror ( + run, ASE_AWK_EARGTM, nde->line, ASE_NULL, 0); + return ASE_NULL; + } + + return __eval_call (run, nde, ASE_NULL, afn); +} + + +/* run->stack_base has not been set for this + * stack frame. so the STACK_ARG macro cannot be used as in + * ase_awk_refdownval (run, STACK_ARG(run,nargs));*/ + +#define UNWIND_RUN_STACK(run,nargs) \ + do { \ + while ((nargs) > 0) \ + { \ + --(nargs); \ + ase_awk_refdownval ((run), \ + (run)->stack[(run)->stack_top-1]); \ + __raw_pop (run); \ + } \ + __raw_pop (run); /* nargs */ \ + __raw_pop (run); /* return */ \ + __raw_pop (run); /* prev stack top */ \ + __raw_pop (run); /* prev stack back */ \ + } while (0) + +static ase_awk_val_t* __eval_call ( + ase_awk_run_t* run, ase_awk_nde_t* nde, + const ase_char_t* bfn_arg_spec, ase_awk_afn_t* afn) +{ + ase_awk_nde_call_t* call = (ase_awk_nde_call_t*)nde; + ase_size_t saved_stack_top; + ase_size_t nargs, i; + ase_awk_nde_t* p; + ase_awk_val_t* v; + int n; + + /* + * --------------------- + * localn <- stack top + * --------------------- + * .... + * --------------------- + * local0 local variables are pushed by __run_block + * ===================== + * argn + * --------------------- + * .... + * --------------------- + * arg1 + * --------------------- + * arg0 + * --------------------- + * nargs + * --------------------- + * return value + * --------------------- + * previous stack top + * --------------------- + * previous stack base <- stack base + * ===================== + * 0 (nargs) <- stack top + * --------------------- + * return value + * --------------------- + * previous stack top + * --------------------- + * previous stack base <- stack base + * ===================== + * globaln + * --------------------- + * .... + * --------------------- + * global0 + * --------------------- + */ + + ASE_ASSERT ( + ASE_SIZEOF(void*) >= ASE_SIZEOF(run->stack_top)); + ASE_ASSERT ( + ASE_SIZEOF(void*) >= ASE_SIZEOF(run->stack_base)); + + saved_stack_top = run->stack_top; + +#ifdef DEBUG_RUN + ase_dprintf (ASE_T("setting up function stack frame top=%ld base=%ld\n"), + (long)run->stack_top, (long)run->stack_base); +#endif + if (__raw_push(run,(void*)run->stack_base) == -1) + { + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, nde->line, ASE_NULL, 0); + return ASE_NULL; + } + + if (__raw_push(run,(void*)saved_stack_top) == -1) + { + __raw_pop (run); + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, nde->line, ASE_NULL, 0); + return ASE_NULL; + } + + /* secure space for a return value. */ + if (__raw_push(run,ase_awk_val_nil) == -1) + { + __raw_pop (run); + __raw_pop (run); + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, nde->line, ASE_NULL, 0); + return ASE_NULL; + } + + /* secure space for nargs */ + if (__raw_push(run,ase_awk_val_nil) == -1) + { + __raw_pop (run); + __raw_pop (run); + __raw_pop (run); + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, nde->line, ASE_NULL, 0); + return ASE_NULL; + } + + for (p = call->args, nargs = 0; p != ASE_NULL; p = p->next, nargs++) + { + ASE_ASSERT ( + bfn_arg_spec == ASE_NULL || + (bfn_arg_spec != ASE_NULL && + ase_strlen(bfn_arg_spec) > nargs)); + + if (bfn_arg_spec != ASE_NULL && + bfn_arg_spec[nargs] == ASE_T('r')) + { + ase_awk_val_t** ref; + + if (__get_reference (run, p, &ref) == -1) + { + UNWIND_RUN_STACK (run, nargs); + return ASE_NULL; + } + + /* p->type-ASE_AWK_NDE_NAMED assumes that the + * derived value matches ASE_AWK_VAL_REF_XXX */ + v = ase_awk_makerefval ( + run, p->type-ASE_AWK_NDE_NAMED, ref); + } + else if (bfn_arg_spec != ASE_NULL && + bfn_arg_spec[nargs] == ASE_T('x')) + { + /* a regular expression is passed to + * the function as it is */ + v = __eval_expression0 (run, p); + } + else + { + v = __eval_expression (run, p); + } + if (v == ASE_NULL) + { + UNWIND_RUN_STACK (run, nargs); + return ASE_NULL; + } + + if (__raw_push(run,v) == -1) + { + /* ugly - v needs to be freed if it doesn't have + * any reference. but its reference has not been + * updated yet as it is carried out after the + * successful stack push. so it adds up a reference + * and dereferences it */ + ase_awk_refupval (run, v); + ase_awk_refdownval (run, v); + + UNWIND_RUN_STACK (run, nargs); + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, nde->line, ASE_NULL, 0); + return ASE_NULL; + } + + ase_awk_refupval (run, v); + /*nargs++; p = p->next;*/ + } + + ASE_ASSERT (nargs == call->nargs); + + if (afn != ASE_NULL) + { + /* extra step for normal awk functions */ + + while (nargs < afn->nargs) + { + /* push as many nils as the number of missing actual arguments */ + if (__raw_push(run,ase_awk_val_nil) == -1) + { + UNWIND_RUN_STACK (run, nargs); + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, nde->line, + ASE_NULL, 0); + return ASE_NULL; + } + + nargs++; + } + } + + run->stack_base = saved_stack_top; + STACK_NARGS(run) = (void*)nargs; + +#ifdef DEBUG_RUN + ase_dprintf (ASE_T("running function body\n")); +#endif + + if (afn != ASE_NULL) + { + /* normal awk function */ + ASE_ASSERT (afn->body->type == ASE_AWK_NDE_BLK); + n = __run_block(run,(ase_awk_nde_blk_t*)afn->body); + } + else + { + n = 0; + + /* built-in function */ + ASE_ASSERT ( + call->nargs >= call->what.bfn.arg.min && + call->nargs <= call->what.bfn.arg.max); + + if (call->what.bfn.handler != ASE_NULL) + { + run->errnum = ASE_AWK_ENOERR; + + n = call->what.bfn.handler ( + run, + call->what.bfn.name.ptr, + call->what.bfn.name.len); + + if (n <= -1) + { + if (run->errnum == ASE_AWK_ENOERR) + { + /* the handler has not set the error. + * fix it */ + ase_awk_setrunerror ( + run, ASE_AWK_EBFNIMPL, + nde->line, ASE_NULL, 0); + } + else + { + /* adjust the error line */ + run->errlin = nde->line; + } + + /* correct the return code just in case */ + if (n < -1) n = -1; + } + } + } + + /* refdown args in the run.stack */ + nargs = (ase_size_t)STACK_NARGS(run); +#ifdef DEBUG_RUN + ase_dprintf (ASE_T("block run complete nargs = %d\n"), (int)nargs); +#endif + for (i = 0; i < nargs; i++) + { + ase_awk_refdownval (run, STACK_ARG(run,i)); + } + +#ifdef DEBUG_RUN + ase_dprintf (ASE_T("got return value\n")); +#endif + + /* this trick has been mentioned in __run_return. + * adjust the reference count of the return value. + * the value must not be freed even if the reference count + * is decremented to zero because its reference has been incremented + * in __run_return regardless of its reference count. */ + v = STACK_RETVAL(run); + ase_awk_refdownval_nofree (run, v); + + run->stack_top = (ase_size_t)run->stack[run->stack_base+1]; + run->stack_base = (ase_size_t)run->stack[run->stack_base+0]; + + if (run->exit_level == EXIT_FUNCTION) run->exit_level = EXIT_NONE; + +#ifdef DEBUG_RUN + ase_dprintf (ASE_T("returning from function top=%ld, base=%ld\n"), + (long)run->stack_top, (long)run->stack_base); +#endif + return (n == -1)? ASE_NULL: v; +} + +static int __get_reference ( + ase_awk_run_t* run, ase_awk_nde_t* nde, ase_awk_val_t*** ref) +{ + ase_awk_nde_var_t* tgt = (ase_awk_nde_var_t*)nde; + ase_awk_val_t** tmp; + + /* refer to __eval_indexed for application of a similar concept */ + + if (nde->type == ASE_AWK_NDE_NAMED) + { + ase_awk_pair_t* pair; + + pair = ase_awk_map_get ( + &run->named, tgt->id.name, tgt->id.name_len); + if (pair == ASE_NULL) + { + /* it is bad that the named variable has to be + * created in the function named "__get_refernce". + * would there be any better ways to avoid this? */ + pair = ase_awk_map_put ( + &run->named, tgt->id.name, + tgt->id.name_len, ase_awk_val_nil); + if (pair == ASE_NULL) + { + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, nde->line, + ASE_NULL, 0); + return -1; + } + } + + *ref = (ase_awk_val_t**)&pair->val; + return 0; + } + + if (nde->type == ASE_AWK_NDE_GLOBAL) + { + *ref = (ase_awk_val_t**)&STACK_GLOBAL(run,tgt->id.idxa); + return 0; + } + + if (nde->type == ASE_AWK_NDE_LOCAL) + { + *ref = (ase_awk_val_t**)&STACK_LOCAL(run,tgt->id.idxa); + return 0; + } + + if (nde->type == ASE_AWK_NDE_ARG) + { + *ref = (ase_awk_val_t**)&STACK_ARG(run,tgt->id.idxa); + return 0; + } + + if (nde->type == ASE_AWK_NDE_NAMEDIDX) + { + ase_awk_pair_t* pair; + + pair = ase_awk_map_get ( + &run->named, tgt->id.name, tgt->id.name_len); + if (pair == ASE_NULL) + { + pair = ase_awk_map_put ( + &run->named, tgt->id.name, + tgt->id.name_len, ase_awk_val_nil); + if (pair == ASE_NULL) + { + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, nde->line, + ASE_NULL, 0); + return -1; + } + } + + tmp = __get_reference_indexed ( + run, tgt, (ase_awk_val_t**)&pair->val); + if (tmp == ASE_NULL) return -1; + *ref = tmp; + } + + if (nde->type == ASE_AWK_NDE_GLOBALIDX) + { + tmp = __get_reference_indexed (run, tgt, + (ase_awk_val_t**)&STACK_GLOBAL(run,tgt->id.idxa)); + if (tmp == ASE_NULL) return -1; + *ref = tmp; + } + + if (nde->type == ASE_AWK_NDE_LOCALIDX) + { + tmp = __get_reference_indexed (run, tgt, + (ase_awk_val_t**)&STACK_LOCAL(run,tgt->id.idxa)); + if (tmp == ASE_NULL) return -1; + *ref = tmp; + } + + if (nde->type == ASE_AWK_NDE_ARGIDX) + { + tmp = __get_reference_indexed (run, tgt, + (ase_awk_val_t**)&STACK_ARG(run,tgt->id.idxa)); + if (tmp == ASE_NULL) return -1; + *ref = tmp; + } + + if (nde->type == ASE_AWK_NDE_POS) + { + int n; + ase_long_t lv; + ase_real_t rv; + ase_awk_val_t* v; + + /* the position number is returned for the positional + * variable unlike other reference types. */ + v = __eval_expression (run, ((ase_awk_nde_pos_t*)nde)->val); + if (v == ASE_NULL) return -1; + + ase_awk_refupval (run, v); + n = ase_awk_valtonum (run, v, &lv, &rv); + ase_awk_refdownval (run, v); + + if (n == -1) + { + ase_awk_setrunerror ( + run, ASE_AWK_EPOSIDX, nde->line, ASE_NULL, 0); + return -1; + } + if (n == 1) lv = (ase_long_t)rv; + if (!IS_VALID_POSIDX(lv)) + { + ase_awk_setrunerror ( + run, ASE_AWK_EPOSIDX, nde->line, ASE_NULL, 0); + return -1; + } + + *ref = (ase_awk_val_t**)((ase_size_t)lv); + return 0; + } + + ase_awk_setrunerror (run, ASE_AWK_ENOTREF, nde->line, ASE_NULL, 0); + return -1; +} + +static ase_awk_val_t** __get_reference_indexed ( + ase_awk_run_t* run, ase_awk_nde_var_t* nde, ase_awk_val_t** val) +{ + ase_awk_pair_t* pair; + ase_char_t* str; + ase_size_t len; + + ASE_ASSERT (val != ASE_NULL); + + if ((*val)->type == ASE_AWK_VAL_NIL) + { + ase_awk_val_t* tmp; + + tmp = ase_awk_makemapval (run); + if (tmp == ASE_NULL) + { + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, nde->line, ASE_NULL, 0); + return ASE_NULL; + } + + ase_awk_refdownval (run, *val); + *val = tmp; + ase_awk_refupval (run, (ase_awk_val_t*)*val); + } + else if ((*val)->type != ASE_AWK_VAL_MAP) + { + ase_awk_setrunerror ( + run, ASE_AWK_ENOTMAP, nde->line, ASE_NULL, 0); + return ASE_NULL; + } + + ASE_ASSERT (nde->idx != ASE_NULL); + + str = __idxnde_to_str (run, nde->idx, &len); + if (str == ASE_NULL) return ASE_NULL; + + pair = ase_awk_map_get ((*(ase_awk_val_map_t**)val)->map, str, len); + if (pair == ASE_NULL) + { + pair = ase_awk_map_put ( + (*(ase_awk_val_map_t**)val)->map, + str, len, ase_awk_val_nil); + if (pair == ASE_NULL) + { + ASE_AWK_FREE (run->awk, str); + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, nde->line, ASE_NULL, 0); + return ASE_NULL; + } + + ase_awk_refupval (run, pair->val); + } + + ASE_AWK_FREE (run->awk, str); + return (ase_awk_val_t**)&pair->val; +} + +static ase_awk_val_t* __eval_int (ase_awk_run_t* run, ase_awk_nde_t* nde) +{ + ase_awk_val_t* val; + + val = ase_awk_makeintval (run, ((ase_awk_nde_int_t*)nde)->val); + if (val == ASE_NULL) + { + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, nde->line, ASE_NULL, 0); + return ASE_NULL; + } + ((ase_awk_val_int_t*)val)->nde = (ase_awk_nde_int_t*)nde; + + return val; +} + +static ase_awk_val_t* __eval_real (ase_awk_run_t* run, ase_awk_nde_t* nde) +{ + ase_awk_val_t* val; + + val = ase_awk_makerealval (run, ((ase_awk_nde_real_t*)nde)->val); + if (val == ASE_NULL) + { + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, nde->line, ASE_NULL, 0); + return ASE_NULL; + } + ((ase_awk_val_real_t*)val)->nde = (ase_awk_nde_real_t*)nde; + + return val; +} + +static ase_awk_val_t* __eval_str (ase_awk_run_t* run, ase_awk_nde_t* nde) +{ + ase_awk_val_t* val; + + val = ase_awk_makestrval (run, + ((ase_awk_nde_str_t*)nde)->buf, + ((ase_awk_nde_str_t*)nde)->len); + if (val == ASE_NULL) + { + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, nde->line, ASE_NULL, 0); + return ASE_NULL; + } + + return val; +} + +static ase_awk_val_t* __eval_rex (ase_awk_run_t* run, ase_awk_nde_t* nde) +{ + ase_awk_val_t* val; + + val = ase_awk_makerexval (run, + ((ase_awk_nde_rex_t*)nde)->buf, + ((ase_awk_nde_rex_t*)nde)->len, + ((ase_awk_nde_rex_t*)nde)->code); + if (val == ASE_NULL) + { + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, nde->line, ASE_NULL, 0); + return ASE_NULL; + } + + return val; +} + +static ase_awk_val_t* __eval_named (ase_awk_run_t* run, ase_awk_nde_t* nde) +{ + ase_awk_pair_t* pair; + + pair = ase_awk_map_get (&run->named, + ((ase_awk_nde_var_t*)nde)->id.name, + ((ase_awk_nde_var_t*)nde)->id.name_len); + + return (pair == ASE_NULL)? ase_awk_val_nil: pair->val; +} + +static ase_awk_val_t* __eval_global (ase_awk_run_t* run, ase_awk_nde_t* nde) +{ + return STACK_GLOBAL(run,((ase_awk_nde_var_t*)nde)->id.idxa); +} + +static ase_awk_val_t* __eval_local (ase_awk_run_t* run, ase_awk_nde_t* nde) +{ + return STACK_LOCAL(run,((ase_awk_nde_var_t*)nde)->id.idxa); +} + +static ase_awk_val_t* __eval_arg (ase_awk_run_t* run, ase_awk_nde_t* nde) +{ + return STACK_ARG(run,((ase_awk_nde_var_t*)nde)->id.idxa); +} + +static ase_awk_val_t* __eval_indexed ( + ase_awk_run_t* run, ase_awk_nde_var_t* nde, ase_awk_val_t** val) +{ + ase_awk_pair_t* pair; + ase_char_t* str; + ase_size_t len; + + ASE_ASSERT (val != ASE_NULL); + + if ((*val)->type == ASE_AWK_VAL_NIL) + { + ase_awk_val_t* tmp; + + tmp = ase_awk_makemapval (run); + if (tmp == ASE_NULL) + { + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, nde->line, ASE_NULL, 0); + return ASE_NULL; + } + + ase_awk_refdownval (run, *val); + *val = tmp; + ase_awk_refupval (run, (ase_awk_val_t*)*val); + } + else if ((*val)->type != ASE_AWK_VAL_MAP) + { + ase_awk_setrunerror ( + run, ASE_AWK_ENOTMAP, nde->line, ASE_NULL, 0); + return ASE_NULL; + } + + ASE_ASSERT (nde->idx != ASE_NULL); + + str = __idxnde_to_str (run, nde->idx, &len); + if (str == ASE_NULL) return ASE_NULL; + + pair = ase_awk_map_get ((*(ase_awk_val_map_t**)val)->map, str, len); + ASE_AWK_FREE (run->awk, str); + + return (pair == ASE_NULL)? ase_awk_val_nil: (ase_awk_val_t*)pair->val; +} + +static ase_awk_val_t* __eval_namedidx (ase_awk_run_t* run, ase_awk_nde_t* nde) +{ + ase_awk_nde_var_t* tgt = (ase_awk_nde_var_t*)nde; + ase_awk_pair_t* pair; + + pair = ase_awk_map_get (&run->named, tgt->id.name, tgt->id.name_len); + if (pair == ASE_NULL) + { + pair = ase_awk_map_put (&run->named, + tgt->id.name, tgt->id.name_len, ase_awk_val_nil); + if (pair == ASE_NULL) + { + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, nde->line, ASE_NULL, 0); + return ASE_NULL; + } + + ase_awk_refupval (run, pair->val); + } + + return __eval_indexed (run, tgt, (ase_awk_val_t**)&pair->val); +} + +static ase_awk_val_t* __eval_globalidx (ase_awk_run_t* run, ase_awk_nde_t* nde) +{ + return __eval_indexed (run, (ase_awk_nde_var_t*)nde, + (ase_awk_val_t**)&STACK_GLOBAL(run,((ase_awk_nde_var_t*)nde)->id.idxa)); +} + +static ase_awk_val_t* __eval_localidx (ase_awk_run_t* run, ase_awk_nde_t* nde) +{ + return __eval_indexed (run, (ase_awk_nde_var_t*)nde, + (ase_awk_val_t**)&STACK_LOCAL(run,((ase_awk_nde_var_t*)nde)->id.idxa)); +} + +static ase_awk_val_t* __eval_argidx (ase_awk_run_t* run, ase_awk_nde_t* nde) +{ + return __eval_indexed (run, (ase_awk_nde_var_t*)nde, + (ase_awk_val_t**)&STACK_ARG(run,((ase_awk_nde_var_t*)nde)->id.idxa)); +} + +static ase_awk_val_t* __eval_pos (ase_awk_run_t* run, ase_awk_nde_t* nde) +{ + ase_awk_nde_pos_t* pos = (ase_awk_nde_pos_t*)nde; + ase_awk_val_t* v; + ase_long_t lv; + ase_real_t rv; + int n; + + v = __eval_expression (run, pos->val); + if (v == ASE_NULL) return ASE_NULL; + + ase_awk_refupval (run, v); + n = ase_awk_valtonum (run, v, &lv, &rv); + ase_awk_refdownval (run, v); + if (n == -1) + { + ase_awk_setrunerror ( + run, ASE_AWK_EPOSIDX, nde->line, ASE_NULL, 0); + return ASE_NULL; + } + if (n == 1) lv = (ase_long_t)rv; + + if (lv < 0) + { + ase_awk_setrunerror ( + run, ASE_AWK_EPOSIDX, nde->line, ASE_NULL, 0); + return ASE_NULL; + } + if (lv == 0) v = run->inrec.d0; + else if (lv > 0 && lv <= run->inrec.nflds) + v = run->inrec.flds[lv-1].val; + else v = ase_awk_val_zls; /*ase_awk_val_nil;*/ + + return v; +} + +static ase_awk_val_t* __eval_getline (ase_awk_run_t* run, ase_awk_nde_t* nde) +{ + ase_awk_nde_getline_t* p; + ase_awk_val_t* v, * res; + ase_char_t* in = ASE_NULL; + const ase_char_t* dst; + ase_str_t buf; + int n; + + p = (ase_awk_nde_getline_t*)nde; + + ASE_ASSERT ( + (p->in_type == ASE_AWK_IN_PIPE && p->in != ASE_NULL) || + (p->in_type == ASE_AWK_IN_COPROC && p->in != ASE_NULL) || + (p->in_type == ASE_AWK_IN_FILE && p->in != ASE_NULL) || + (p->in_type == ASE_AWK_IN_CONSOLE && p->in == ASE_NULL)); + + if (p->in != ASE_NULL) + { + ase_size_t len; + + v = __eval_expression (run, p->in); + if (v == ASE_NULL) return ASE_NULL; + + /* TODO: distinction between v->type == ASE_AWK_VAL_STR + * and v->type != ASE_AWK_VAL_STR + * if you use the buffer the v directly when + * v->type == ASE_AWK_VAL_STR, ase_awk_refdownval(v) + * should not be called immediately below */ + ase_awk_refupval (run, v); + in = ase_awk_valtostr ( + run, v, ASE_AWK_VALTOSTR_CLEAR, ASE_NULL, &len); + if (in == ASE_NULL) + { + ase_awk_refdownval (run, v); + return ASE_NULL; + } + ase_awk_refdownval (run, v); + + if (len <= 0) + { + /* the input source name is empty. + * make getline return -1 */ + ASE_AWK_FREE (run->awk, in); + n = -1; + goto skip_read; + } + + while (len > 0) + { + if (in[--len] == ASE_T('\0')) + { + /* the input source name contains a null + * character. make getline return -1 */ + ASE_AWK_FREE (run->awk, in); + n = -1; + goto skip_read; + } + } + } + + dst = (in == ASE_NULL)? ASE_T(""): in; + + /* TODO: optimize the line buffer management */ + if (ase_str_open (&buf, DEF_BUF_CAPA, &run->awk->prmfns.mmgr) == ASE_NULL) + { + if (in != ASE_NULL) ASE_AWK_FREE (run->awk, in); + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, nde->line, ASE_NULL, 0); + return ASE_NULL; + } + + n = ase_awk_readextio (run, p->in_type, dst, &buf); + if (in != ASE_NULL) ASE_AWK_FREE (run->awk, in); + + if (n <= -1) + { + /* make getline return -1 */ + n = -1; + } + + if (n > 0) + { + if (p->var == ASE_NULL) + { + /* set $0 with the input value */ + if (ase_awk_setrec (run, 0, + ASE_STR_BUF(&buf), + ASE_STR_LEN(&buf)) == -1) + { + ase_str_close (&buf); + return ASE_NULL; + } + + ase_str_close (&buf); + } + else + { + ase_awk_val_t* v; + + v = ase_awk_makestrval (run, + ASE_STR_BUF(&buf), ASE_STR_LEN(&buf)); + ase_str_close (&buf); + if (v == ASE_NULL) + { + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, nde->line, + ASE_NULL, 0); + return ASE_NULL; + } + + ase_awk_refupval (run, v); + if (__do_assignment(run, p->var, v) == ASE_NULL) + { + ase_awk_refdownval (run, v); + return ASE_NULL; + } + ase_awk_refdownval (run, v); + } + } + else + { + ase_str_close (&buf); + } + +skip_read: + res = ase_awk_makeintval (run, n); + if (res == ASE_NULL) + { + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, nde->line, ASE_NULL, 0); + return ASE_NULL; + } + + return res; +} + +static int __raw_push (ase_awk_run_t* run, void* val) +{ + if (run->stack_top >= run->stack_limit) + { + void** tmp; + ase_size_t n; + + n = run->stack_limit + STACK_INCREMENT; + + if (run->awk->prmfns.mmgr.realloc != ASE_NULL) + { + tmp = (void**) ASE_AWK_REALLOC ( + run->awk, run->stack, n * ASE_SIZEOF(void*)); + if (tmp == ASE_NULL) return -1; + } + else + { + tmp = (void**) ASE_AWK_MALLOC ( + run->awk, n * ASE_SIZEOF(void*)); + if (tmp == ASE_NULL) return -1; + if (run->stack != ASE_NULL) + { + ase_memcpy ( + tmp, run->stack, + run->stack_limit * ASE_SIZEOF(void*)); + ASE_AWK_FREE (run->awk, run->stack); + } + } + run->stack = tmp; + run->stack_limit = n; + } + + run->stack[run->stack_top++] = val; + return 0; +} + +static void __raw_pop_times (ase_awk_run_t* run, ase_size_t times) +{ + while (times > 0) + { + --times; + __raw_pop (run); + } +} + +static int __read_record (ase_awk_run_t* run) +{ + ase_ssize_t n; + + if (ase_awk_clrrec (run, ase_false) == -1) return -1; + + n = ase_awk_readextio ( + run, ASE_AWK_IN_CONSOLE, ASE_T(""), &run->inrec.line); + if (n <= -1) + { + ase_awk_clrrec (run, ase_false); + return -1; + } + +#ifdef DEBUG_RUN + ase_dprintf (ASE_T("record len = %d str=[%.*s]\n"), + (int)ASE_STR_LEN(&run->inrec.line), + (int)ASE_STR_LEN(&run->inrec.line), + ASE_STR_BUF(&run->inrec.line)); +#endif + if (n == 0) + { + ASE_ASSERT (ASE_STR_LEN(&run->inrec.line) == 0); + return 0; + } + + if (ase_awk_setrec (run, 0, + ASE_STR_BUF(&run->inrec.line), + ASE_STR_LEN(&run->inrec.line)) == -1) return -1; + + return 1; +} + +static int __shorten_record (ase_awk_run_t* run, ase_size_t nflds) +{ + ase_awk_val_t* v; + ase_char_t* ofs_free = ASE_NULL, * ofs; + ase_size_t ofs_len, i; + ase_str_t tmp; + + ASE_ASSERT (nflds <= run->inrec.nflds); + + if (nflds > 1) + { + v = STACK_GLOBAL(run, ASE_AWK_GLOBAL_OFS); + ase_awk_refupval (run, v); + + if (v->type == ASE_AWK_VAL_NIL) + { + /* OFS not set */ + ofs = ASE_T(" "); + ofs_len = 1; + } + else if (v->type == ASE_AWK_VAL_STR) + { + ofs = ((ase_awk_val_str_t*)v)->buf; + ofs_len = ((ase_awk_val_str_t*)v)->len; + } + else + { + ofs = ase_awk_valtostr ( + run, v, ASE_AWK_VALTOSTR_CLEAR, + ASE_NULL, &ofs_len); + if (ofs == ASE_NULL) return -1; + + ofs_free = ofs; + } + } + + if (ase_str_open ( + &tmp, ASE_STR_LEN(&run->inrec.line), + &run->awk->prmfns.mmgr) == ASE_NULL) + { + ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return -1; + } + + for (i = 0; i < nflds; i++) + { + if (i > 0 && ase_str_ncat(&tmp,ofs,ofs_len) == (ase_size_t)-1) + { + if (ofs_free != ASE_NULL) + ASE_AWK_FREE (run->awk, ofs_free); + if (nflds > 1) ase_awk_refdownval (run, v); + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return -1; + } + + if (ase_str_ncat (&tmp, + run->inrec.flds[i].ptr, + run->inrec.flds[i].len) == (ase_size_t)-1) + { + if (ofs_free != ASE_NULL) + ASE_AWK_FREE (run->awk, ofs_free); + if (nflds > 1) ase_awk_refdownval (run, v); + + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return -1; + } + } + + if (ofs_free != ASE_NULL) ASE_AWK_FREE (run->awk, ofs_free); + if (nflds > 1) ase_awk_refdownval (run, v); + + v = (ase_awk_val_t*) ase_awk_makestrval ( + run, ASE_STR_BUF(&tmp), ASE_STR_LEN(&tmp)); + if (v == ASE_NULL) + { + ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return -1; + } + + ase_awk_refdownval (run, run->inrec.d0); + run->inrec.d0 = v; + ase_awk_refupval (run, run->inrec.d0); + + ase_str_swap (&tmp, &run->inrec.line); + ase_str_close (&tmp); + + for (i = nflds; i < run->inrec.nflds; i++) + { + ase_awk_refdownval (run, run->inrec.flds[i].val); + } + + run->inrec.nflds = nflds; + return 0; +} + +static ase_char_t* __idxnde_to_str ( + ase_awk_run_t* run, ase_awk_nde_t* nde, ase_size_t* len) +{ + ase_char_t* str; + ase_awk_val_t* idx; + + ASE_ASSERT (nde != ASE_NULL); + + if (nde->next == ASE_NULL) + { + /* single node index */ + idx = __eval_expression (run, nde); + if (idx == ASE_NULL) return ASE_NULL; + + ase_awk_refupval (run, idx); + + str = ase_awk_valtostr ( + run, idx, ASE_AWK_VALTOSTR_CLEAR, ASE_NULL, len); + if (str == ASE_NULL) + { + ase_awk_refdownval (run, idx); + /* change error line */ + run->errlin = nde->line; + return ASE_NULL; + } + + ase_awk_refdownval (run, idx); + } + else + { + /* multidimensional index */ + ase_str_t idxstr; + + if (ase_str_open ( + &idxstr, + DEF_BUF_CAPA, + &run->awk->prmfns.mmgr) == ASE_NULL) + { + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, nde->line, ASE_NULL, 0); + return ASE_NULL; + } + + while (nde != ASE_NULL) + { + idx = __eval_expression (run, nde); + if (idx == ASE_NULL) + { + ase_str_close (&idxstr); + return ASE_NULL; + } + + ase_awk_refupval (run, idx); + + if (ASE_STR_LEN(&idxstr) > 0 && + ase_str_ncat (&idxstr, + run->global.subsep.ptr, + run->global.subsep.len) == (ase_size_t)-1) + { + ase_awk_refdownval (run, idx); + ase_str_close (&idxstr); + + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, nde->line, + ASE_NULL, 0); + + return ASE_NULL; + } + + if (ase_awk_valtostr ( + run, idx, 0, &idxstr, ASE_NULL) == ASE_NULL) + { + ase_awk_refdownval (run, idx); + ase_str_close (&idxstr); + return ASE_NULL; + } + + ase_awk_refdownval (run, idx); + nde = nde->next; + } + + str = ASE_STR_BUF(&idxstr); + *len = ASE_STR_LEN(&idxstr); + ase_str_forfeit (&idxstr); + } + + return str; +} + +ase_char_t* ase_awk_format ( + ase_awk_run_t* run, ase_str_t* out, ase_str_t* fbu, + const ase_char_t* fmt, ase_size_t fmt_len, + ase_size_t nargs_on_stack, ase_awk_nde_t* args, ase_size_t* len) +{ + ase_size_t i, j; + ase_size_t stack_arg_idx = 1; + ase_awk_val_t* val; + +#define OUT_CHAR(c) \ + do { \ + if (ase_str_ccat (out, (c)) == -1) \ + { \ + ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); \ + return ASE_NULL; \ + } \ + } while (0) + +#define FMT_CHAR(c) \ + do { \ + if (ase_str_ccat (fbu, (c)) == -1) \ + { \ + ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); \ + return ASE_NULL; \ + } \ + } while (0) + +#define GROW(buf) \ + do { \ + if ((buf)->ptr != ASE_NULL) \ + { \ + ASE_AWK_FREE (run->awk, (buf)->ptr); \ + (buf)->ptr = ASE_NULL; \ + } \ + (buf)->len += (buf)->inc; \ + (buf)->ptr = (ase_char_t*)ASE_AWK_MALLOC ( \ + run->awk, (buf)->len * ASE_SIZEOF(ase_char_t)); \ + if ((buf)->ptr == ASE_NULL) (buf)->len = 0; \ + } while (0) + + ASE_ASSERTX (run->format.tmp.ptr != ASE_NULL, + "run->format.tmp.ptr should have been assigned a pointer to a block of memory before this function has been called"); + + if (nargs_on_stack == (ase_size_t)-1) + { + val = (ase_awk_val_t*)args; + nargs_on_stack = 2; + } + else + { + val = ASE_NULL; + } + + if (out == ASE_NULL) out = &run->format.out; + if (fbu == ASE_NULL) fbu = &run->format.fmt; + + ase_str_clear (out); + ase_str_clear (fbu); + + for (i = 0; i < fmt_len; i++) + { + ase_long_t width = -1, prec = -1; + ase_bool_t minus = ase_false; + + if (ASE_STR_LEN(fbu) == 0) + { + if (fmt[i] == ASE_T('%')) FMT_CHAR (fmt[i]); + else OUT_CHAR (fmt[i]); + continue; + } + + while (i < fmt_len && + (fmt[i] == ASE_T(' ') || fmt[i] == ASE_T('#') || + fmt[i] == ASE_T('0') || fmt[i] == ASE_T('+') || + fmt[i] == ASE_T('-'))) + { + if (fmt[i] == ASE_T('-')) minus = ase_true; + FMT_CHAR (fmt[i]); i++; + } + + if (i < fmt_len && fmt[i] == ASE_T('*')) + { + ase_awk_val_t* v; + ase_real_t r; + ase_char_t* p; + int n; + + if (args == ASE_NULL) + { + if (stack_arg_idx >= nargs_on_stack) + { + ase_awk_setrunerror (run, ASE_AWK_EFMTARG, 0, ASE_NULL, 0); + return ASE_NULL; + } + v = ase_awk_getarg (run, stack_arg_idx); + } + else + { + if (val != ASE_NULL) + { + if (stack_arg_idx >= nargs_on_stack) + { + ase_awk_setrunerror (run, ASE_AWK_EFMTARG, 0, ASE_NULL, 0); + return ASE_NULL; + } + v = val; + } + else + { + v = __eval_expression (run, args); + if (v == ASE_NULL) return ASE_NULL; + } + } + + ase_awk_refupval (run, v); + n = ase_awk_valtonum (run, v, &width, &r); + ase_awk_refdownval (run, v); + + if (n == -1) return ASE_NULL; + if (n == 1) width = (ase_long_t)r; + + do + { + n = run->awk->prmfns.misc.sprintf ( + run->awk->prmfns.misc.custom_data, + run->format.tmp.ptr, + run->format.tmp.len, + #if ASE_SIZEOF_LONG_LONG > 0 + ASE_T("%lld"), (long long)width + #elif ASE_SIZEOF___INT64 > 0 + ASE_T("%I64d"), (__int64)width + #elif ASE_SIZEOF_LONG > 0 + ASE_T("%ld"), (long)width + #elif ASE_SIZEOF_INT > 0 + ASE_T("%d"), (int)width + #else + #error unsupported size + #endif + ); + if (n == -1) + { + GROW (&run->format.tmp); + if (run->format.tmp.ptr == ASE_NULL) + { + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, 0, + ASE_NULL, 0); + return ASE_NULL; + } + + continue; + } + + break; + } + while (1); + + p = run->format.tmp.ptr; + while (*p != ASE_T('\0')) + { + FMT_CHAR (*p); + p++; + } + + if (args == ASE_NULL || val != ASE_NULL) stack_arg_idx++; + else args = args->next; + i++; + } + else + { + if (i < fmt_len && ASE_AWK_ISDIGIT(run->awk, fmt[i])) + { + width = 0; + do + { + width = width * 10 + fmt[i] - ASE_T('0'); + FMT_CHAR (fmt[i]); i++; + } + while (i < fmt_len && ASE_AWK_ISDIGIT(run->awk, fmt[i])); + } + } + + if (i < fmt_len && fmt[i] == ASE_T('.')) + { + prec = 0; + FMT_CHAR (fmt[i]); i++; + } + + if (i < fmt_len && fmt[i] == ASE_T('*')) + { + ase_awk_val_t* v; + ase_real_t r; + ase_char_t* p; + int n; + + if (args == ASE_NULL) + { + if (stack_arg_idx >= nargs_on_stack) + { + ase_awk_setrunerror (run, ASE_AWK_EFMTARG, 0, ASE_NULL, 0); + return ASE_NULL; + } + v = ase_awk_getarg (run, stack_arg_idx); + } + else + { + if (val != ASE_NULL) + { + if (stack_arg_idx >= nargs_on_stack) + { + ase_awk_setrunerror (run, ASE_AWK_EFMTARG, 0, ASE_NULL, 0); + return ASE_NULL; + } + v = val; + } + else + { + v = __eval_expression (run, args); + if (v == ASE_NULL) return ASE_NULL; + } + } + + ase_awk_refupval (run, v); + n = ase_awk_valtonum (run, v, &prec, &r); + ase_awk_refdownval (run, v); + + if (n == -1) return ASE_NULL; + if (n == 1) prec = (ase_long_t)r; + + do + { + n = run->awk->prmfns.misc.sprintf ( + run->awk->prmfns.misc.custom_data, + run->format.tmp.ptr, + run->format.tmp.len, + #if ASE_SIZEOF_LONG_LONG > 0 + ASE_T("%lld"), (long long)prec + #elif ASE_SIZEOF___INT64 > 0 + ASE_T("%I64d"), (__int64)prec + #elif ASE_SIZEOF_LONG > 0 + ASE_T("%ld"), (long)prec + #elif ASE_SIZEOF_INT > 0 + ASE_T("%d"), (int)prec + #endif + ); + if (n == -1) + { + GROW (&run->format.tmp); + if (run->format.tmp.ptr == ASE_NULL) + { + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, 0, + ASE_NULL, 0); + return ASE_NULL; + } + + continue; + } + + break; + } + while (1); + + p = run->format.tmp.ptr; + while (*p != ASE_T('\0')) + { + FMT_CHAR (*p); + p++; + } + + if (args == ASE_NULL || val != ASE_NULL) stack_arg_idx++; + else args = args->next; + i++; + } + else + { + if (i < fmt_len && ASE_AWK_ISDIGIT(run->awk, fmt[i])) + { + prec = 0; + do + { + prec = prec * 10 + fmt[i] - ASE_T('0'); + FMT_CHAR (fmt[i]); i++; + } + while (i < fmt_len && ASE_AWK_ISDIGIT(run->awk, fmt[i])); + } + } + + if (i >= fmt_len) break; + + if (fmt[i] == ASE_T('d') || fmt[i] == ASE_T('i') || + fmt[i] == ASE_T('x') || fmt[i] == ASE_T('X') || + fmt[i] == ASE_T('o')) + { + ase_awk_val_t* v; + ase_long_t l; + ase_real_t r; + ase_char_t* p; + int n; + + #if ASE_SIZEOF_LONG_LONG > 0 + FMT_CHAR (ASE_T('l')); + FMT_CHAR (ASE_T('l')); + FMT_CHAR (fmt[i]); + #elif ASE_SIZEOF___INT64 > 0 + FMT_CHAR (ASE_T('I')); + FMT_CHAR (ASE_T('6')); + FMT_CHAR (ASE_T('4')); + FMT_CHAR (fmt[i]); + #elif ASE_SIZEOF_LONG > 0 + FMT_CHAR (ASE_T('l')); + FMT_CHAR (fmt[i]); + #elif ASE_SIZEOF_INT > 0 + FMT_CHAR (fmt[i]); + #else + #error unsupported integer size + #endif + + if (args == ASE_NULL) + { + if (stack_arg_idx >= nargs_on_stack) + { + ase_awk_setrunerror (run, ASE_AWK_EFMTARG, 0, ASE_NULL, 0); + return ASE_NULL; + } + v = ase_awk_getarg (run, stack_arg_idx); + } + else + { + if (val != ASE_NULL) + { + if (stack_arg_idx >= nargs_on_stack) + { + ase_awk_setrunerror (run, ASE_AWK_EFMTARG, 0, ASE_NULL, 0); + return ASE_NULL; + } + v = val; + } + else + { + v = __eval_expression (run, args); + if (v == ASE_NULL) return ASE_NULL; + } + } + + ase_awk_refupval (run, v); + n = ase_awk_valtonum (run, v, &l, &r); + ase_awk_refdownval (run, v); + + if (n == -1) return ASE_NULL; + if (n == 1) l = (ase_long_t)r; + + do + { + n = run->awk->prmfns.misc.sprintf ( + run->awk->prmfns.misc.custom_data, + run->format.tmp.ptr, + run->format.tmp.len, + ASE_STR_BUF(fbu), + #if ASE_SIZEOF_LONG_LONG > 0 + (long long)l + #elif ASE_SIZEOF___INT64 > 0 + (__int64)l + #elif ASE_SIZEOF_LONG > 0 + (long)l + #elif ASE_SIZEOF_INT > 0 + (int)l + #endif + ); + + if (n == -1) + { + GROW (&run->format.tmp); + if (run->format.tmp.ptr == ASE_NULL) + { + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, 0, + ASE_NULL, 0); + return ASE_NULL; + } + + continue; + } + + break; + } + while (1); + + p = run->format.tmp.ptr; + while (*p != ASE_T('\0')) + { + OUT_CHAR (*p); + p++; + } + } + else if (fmt[i] == ASE_T('e') || fmt[i] == ASE_T('E') || + fmt[i] == ASE_T('g') || fmt[i] == ASE_T('G') || + fmt[i] == ASE_T('f')) + { + ase_awk_val_t* v; + ase_long_t l; + ase_real_t r; + ase_char_t* p; + int n; + + FMT_CHAR (ASE_T('L')); + FMT_CHAR (fmt[i]); + + if (args == ASE_NULL) + { + if (stack_arg_idx >= nargs_on_stack) + { + ase_awk_setrunerror (run, ASE_AWK_EFMTARG, 0, ASE_NULL, 0); + return ASE_NULL; + } + v = ase_awk_getarg (run, stack_arg_idx); + } + else + { + if (val != ASE_NULL) + { + if (stack_arg_idx >= nargs_on_stack) + { + ase_awk_setrunerror (run, ASE_AWK_EFMTARG, 0, ASE_NULL, 0); + return ASE_NULL; + } + v = val; + } + else + { + v = __eval_expression (run, args); + if (v == ASE_NULL) return ASE_NULL; + } + } + + ase_awk_refupval (run, v); + n = ase_awk_valtonum (run, v, &l, &r); + ase_awk_refdownval (run, v); + + if (n == -1) return ASE_NULL; + if (n == 0) r = (ase_real_t)l; + + do + { + n = run->awk->prmfns.misc.sprintf ( + run->awk->prmfns.misc.custom_data, + run->format.tmp.ptr, + run->format.tmp.len, + ASE_STR_BUF(fbu), + (long double)r); + + if (n == -1) + { + GROW (&run->format.tmp); + if (run->format.tmp.ptr == ASE_NULL) + { + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return ASE_NULL; + } + + continue; + } + + break; + } + while (1); + + p = run->format.tmp.ptr; + while (*p != ASE_T('\0')) + { + OUT_CHAR (*p); + p++; + } + } + else if (fmt[i] == ASE_T('c')) + { + ase_char_t ch; + ase_size_t ch_len; + ase_awk_val_t* v; + + if (args == ASE_NULL) + { + if (stack_arg_idx >= nargs_on_stack) + { + ase_awk_setrunerror (run, ASE_AWK_EFMTARG, 0, ASE_NULL, 0); + return ASE_NULL; + } + v = ase_awk_getarg (run, stack_arg_idx); + } + else + { + if (val != ASE_NULL) + { + if (stack_arg_idx >= nargs_on_stack) + { + ase_awk_setrunerror (run, ASE_AWK_EFMTARG, 0, ASE_NULL, 0); + return ASE_NULL; + } + v = val; + } + else + { + v = __eval_expression (run, args); + if (v == ASE_NULL) return ASE_NULL; + } + } + + ase_awk_refupval (run, v); + if (v->type == ASE_AWK_VAL_NIL) + { + ch = ASE_T('\0'); + ch_len = 0; + } + else if (v->type == ASE_AWK_VAL_INT) + { + ch = (ase_char_t)((ase_awk_val_int_t*)v)->val; + ch_len = 1; + } + else if (v->type == ASE_AWK_VAL_REAL) + { + ch = (ase_char_t)((ase_awk_val_real_t*)v)->val; + ch_len = 1; + } + else if (v->type == ASE_AWK_VAL_STR) + { + ch_len = ((ase_awk_val_str_t*)v)->len; + if (ch_len > 0) + { + ch = ((ase_awk_val_str_t*)v)->buf[0]; + ch_len = 1; + } + else ch = ASE_T('\0'); + } + else + { + ase_awk_refdownval (run, v); + ase_awk_setrunerror ( + run, ASE_AWK_EVALTYPE, 0, ASE_NULL, 0); + return ASE_NULL; + } + + if (prec == -1 || prec == 0 || prec > ch_len) prec = ch_len; + if (prec > width) width = prec; + + if (!minus) + { + while (width > prec) + { + if (ase_str_ccat (out, ASE_T(' ')) == -1) + { + ase_awk_refdownval (run, v); + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return ASE_NULL; + } + width--; + } + } + + if (prec > 0) + { + if (ase_str_ccat (out, ch) == -1) + { + ase_awk_refdownval (run, v); + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return ASE_NULL; + } + } + + if (minus) + { + while (width > prec) + { + if (ase_str_ccat (out, ASE_T(' ')) == -1) + { + ase_awk_refdownval (run, v); + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return ASE_NULL; + } + width--; + } + } + + ase_awk_refdownval (run, v); + } + else if (fmt[i] == ASE_T('s')) + { + ase_char_t* str, * str_free = ASE_NULL; + ase_size_t str_len, k; + ase_awk_val_t* v; + + if (args == ASE_NULL) + { + if (stack_arg_idx >= nargs_on_stack) + { + ase_awk_setrunerror (run, ASE_AWK_EFMTARG, 0, ASE_NULL, 0); + return ASE_NULL; + } + v = ase_awk_getarg (run, stack_arg_idx); + } + else + { + if (val != ASE_NULL) + { + if (stack_arg_idx >= nargs_on_stack) + { + ase_awk_setrunerror (run, ASE_AWK_EFMTARG, 0, ASE_NULL, 0); + return ASE_NULL; + } + v = val; + } + else + { + v = __eval_expression (run, args); + if (v == ASE_NULL) return ASE_NULL; + } + } + + ase_awk_refupval (run, v); + if (v->type == ASE_AWK_VAL_NIL) + { + str = ASE_T(""); + str_len = 0; + } + else if (v->type == ASE_AWK_VAL_STR) + { + str = ((ase_awk_val_str_t*)v)->buf; + str_len = ((ase_awk_val_str_t*)v)->len; + } + else + { + if (v == val) + { + ase_awk_refdownval (run, v); + ase_awk_setrunerror (run, ASE_AWK_EFMTCNV, 0, ASE_NULL, 0); + return ASE_NULL; + } + + str = ase_awk_valtostr (run, v, + ASE_AWK_VALTOSTR_CLEAR, ASE_NULL, &str_len); + if (str == ASE_NULL) + { + ase_awk_refdownval (run, v); + return ASE_NULL; + } + + str_free = str; + } + + if (prec == -1 || prec > str_len ) prec = str_len; + if (prec > width) width = prec; + + if (!minus) + { + while (width > prec) + { + if (ase_str_ccat (out, ASE_T(' ')) == -1) + { + if (str_free != ASE_NULL) + ASE_AWK_FREE (run->awk, str_free); + ase_awk_refdownval (run, v); + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return ASE_NULL; + } + width--; + } + } + + for (k = 0; k < prec; k++) + { + if (ase_str_ccat (out, str[k]) == -1) + { + if (str_free != ASE_NULL) + ASE_AWK_FREE (run->awk, str_free); + ase_awk_refdownval (run, v); + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return ASE_NULL; + } + } + + if (str_free != ASE_NULL) ASE_AWK_FREE (run->awk, str_free); + + if (minus) + { + while (width > prec) + { + if (ase_str_ccat (out, ASE_T(' ')) == -1) + { + ase_awk_refdownval (run, v); + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return ASE_NULL; + } + width--; + } + } + + ase_awk_refdownval (run, v); + } + else /*if (fmt[i] == ASE_T('%'))*/ + { + for (j = 0; j < ASE_STR_LEN(fbu); j++) + OUT_CHAR (ASE_STR_CHAR(fbu,j)); + OUT_CHAR (fmt[i]); + } + + if (args == ASE_NULL || val != ASE_NULL) stack_arg_idx++; + else args = args->next; + ase_str_clear (fbu); + } + + /* flush uncompleted formatting sequence */ + for (j = 0; j < ASE_STR_LEN(fbu); j++) + OUT_CHAR (ASE_STR_CHAR(fbu,j)); + + *len = ASE_STR_LEN(out); + return ASE_STR_BUF(out); +} + diff --git a/ase/awk/run.h b/ase/awk/run.h new file mode 100644 index 00000000..d620c9ac --- /dev/null +++ b/ase/awk/run.h @@ -0,0 +1,119 @@ +/* + * $Id: run.h,v 1.3 2007/04/30 05:47:33 bacon Exp $ + * + * {License} + */ + +#ifndef _ASE_AWK_RUN_H_ +#define _ASE_AWK_RUN_H_ + +#ifndef _ASE_AWK_AWK_H_ +#error Never include this file directly. Include instead +#endif + +enum ase_awk_assop_type_t +{ + /* if you change this, you have to change __assop_str in tree.c */ + ASE_AWK_ASSOP_NONE, + ASE_AWK_ASSOP_PLUS, /* += */ + ASE_AWK_ASSOP_MINUS, /* -= */ + ASE_AWK_ASSOP_MUL, /* *= */ + ASE_AWK_ASSOP_DIV, /* /= */ + ASE_AWK_ASSOP_IDIV, /* //= */ + ASE_AWK_ASSOP_MOD, /* %= */ + ASE_AWK_ASSOP_EXP /* **= */ +}; + +enum ase_awk_binop_type_t +{ + /* if you change this, you have to change + * __binop_str in tree.c and __binop_func in run.c accordingly. */ + ASE_AWK_BINOP_LOR, + ASE_AWK_BINOP_LAND, + ASE_AWK_BINOP_IN, + + ASE_AWK_BINOP_BOR, + ASE_AWK_BINOP_BXOR, + ASE_AWK_BINOP_BAND, + + ASE_AWK_BINOP_EQ, + ASE_AWK_BINOP_NE, + ASE_AWK_BINOP_GT, + ASE_AWK_BINOP_GE, + ASE_AWK_BINOP_LT, + ASE_AWK_BINOP_LE, + + ASE_AWK_BINOP_LSHIFT, + ASE_AWK_BINOP_RSHIFT, + + ASE_AWK_BINOP_PLUS, + ASE_AWK_BINOP_MINUS, + ASE_AWK_BINOP_MUL, + ASE_AWK_BINOP_DIV, + ASE_AWK_BINOP_IDIV, + ASE_AWK_BINOP_MOD, + ASE_AWK_BINOP_EXP, + + ASE_AWK_BINOP_CONCAT, + ASE_AWK_BINOP_MA, + ASE_AWK_BINOP_NM +}; + +enum ase_awk_unrop_type_t +{ + /* if you change this, you have to change + * __unrop_str in tree.c accordingly. */ + ASE_AWK_UNROP_PLUS, + ASE_AWK_UNROP_MINUS, + ASE_AWK_UNROP_NOT, + ASE_AWK_UNROP_BNOT +}; + +enum ase_awk_incop_type_t +{ + /* if you change this, you have to change + * __incop_str in tree.c accordingly. */ + ASE_AWK_INCOP_PLUS, + ASE_AWK_INCOP_MINUS +}; + +enum ase_awk_global_id_t +{ + /* this table should match __bvtab in parse.c. + * in addition, ase_awk_setglobal also counts + * on the order of these values */ + + ASE_AWK_GLOBAL_ARGC, + ASE_AWK_GLOBAL_ARGV, + ASE_AWK_GLOBAL_CONVFMT, + ASE_AWK_GLOBAL_ENVIRON, + ASE_AWK_GLOBAL_FILENAME, + ASE_AWK_GLOBAL_FNR, + ASE_AWK_GLOBAL_FS, + ASE_AWK_GLOBAL_IGNORECASE, + ASE_AWK_GLOBAL_NF, + ASE_AWK_GLOBAL_NR, + ASE_AWK_GLOBAL_OFILENAME, + ASE_AWK_GLOBAL_OFMT, + ASE_AWK_GLOBAL_OFS, + ASE_AWK_GLOBAL_ORS, + ASE_AWK_GLOBAL_RLENGTH, + ASE_AWK_GLOBAL_RS, + ASE_AWK_GLOBAL_RSTART, + ASE_AWK_GLOBAL_SUBSEP +}; + +#ifdef __cplusplus +extern "C" { +#endif + +ase_char_t* ase_awk_format ( + ase_awk_run_t* run, ase_str_t* out, ase_str_t* fbu, + const ase_char_t* fmt, ase_size_t fmt_len, + ase_size_t nargs_on_stack, ase_awk_nde_t* args, ase_size_t* len); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ase/awk/tab.c b/ase/awk/tab.c new file mode 100644 index 00000000..65b88ecb --- /dev/null +++ b/ase/awk/tab.c @@ -0,0 +1,239 @@ +/* + * $Id: tab.c,v 1.3 2007/04/30 05:47:33 bacon Exp $ + * + * {License} + */ + +#include + +ase_awk_tab_t* ase_awk_tab_open (ase_awk_tab_t* tab, ase_awk_t* awk) +{ + if (tab == ASE_NULL) + { + tab = (ase_awk_tab_t*) ASE_AWK_MALLOC ( + awk, ASE_SIZEOF(ase_awk_tab_t)); + if (tab == ASE_NULL) return ASE_NULL; + tab->__dynamic = ase_true; + } + else tab->__dynamic = ase_false; + + tab->awk = awk; + tab->buf = ASE_NULL; + tab->size = 0; + tab->capa = 0; + + return tab; +} + +void ase_awk_tab_close (ase_awk_tab_t* tab) +{ + ase_awk_tab_clear (tab); + if (tab->buf != ASE_NULL) + { + ASE_AWK_FREE (tab->awk, tab->buf); + tab->buf = ASE_NULL; + tab->capa = 0; + } + + if (tab->__dynamic) ASE_AWK_FREE (tab->awk, tab); +} + +ase_size_t ase_awk_tab_getsize (ase_awk_tab_t* tab) +{ + return tab->size; +} + +ase_size_t ase_awk_tab_getcapa (ase_awk_tab_t* tab) +{ + return tab->capa; +} + +ase_awk_tab_t* ase_awk_tab_setcapa (ase_awk_tab_t* tab, ase_size_t capa) +{ + void* tmp; + + if (tab->size > capa) + { + ase_awk_tab_remove (tab, capa, tab->size - capa); + ASE_ASSERT (tab->size <= capa); + } + + if (capa > 0) + { + if (tab->awk->prmfns.mmgr.realloc != ASE_NULL) + { + tmp = ASE_AWK_REALLOC (tab->awk, + tab->buf, ASE_SIZEOF(*tab->buf) * capa); + if (tmp == ASE_NULL) return ASE_NULL; + } + else + { + tmp = ASE_AWK_MALLOC ( + tab->awk, ASE_SIZEOF(*tab->buf) * capa); + if (tmp == ASE_NULL) return ASE_NULL; + if (tab->buf != ASE_NULL) + { + ase_size_t x; + x = (capa > tab->capa)? tab->capa: capa; + ase_memcpy ( + tmp, tab->buf, + ASE_SIZEOF(*tab->buf) * x); + ASE_AWK_FREE (tab->awk, tab->buf); + } + } + } + else + { + if (tab->buf != ASE_NULL) ASE_AWK_FREE (tab->awk, tab->buf); + tmp = ASE_NULL; + } + + tab->buf = tmp; + tab->capa = capa; + + return tab; +} + +void ase_awk_tab_clear (ase_awk_tab_t* tab) +{ + ase_size_t i; + + for (i = 0; i < tab->size; i++) + { + ASE_AWK_FREE (tab->awk, tab->buf[i].name); + tab->buf[i].name = ASE_NULL; + tab->buf[i].name_len = 0; + } + + tab->size = 0; +} + + +ase_size_t ase_awk_tab_insert ( + ase_awk_tab_t* tab, ase_size_t index, + const ase_char_t* str, ase_size_t len) +{ + ase_size_t i; + ase_char_t* str_dup; + + str_dup = ase_strxdup (str, len, &tab->awk->prmfns.mmgr); + if (str_dup == ASE_NULL) return (ase_size_t)-1; + + if (index >= tab->capa) + { + ase_size_t capa; + + if (tab->capa <= 0) capa = (index + 1); + else + { + do { capa = tab->capa * 2; } while (index >= capa); + } + + if (ase_awk_tab_setcapa(tab,capa) == ASE_NULL) + { + ASE_AWK_FREE (tab->awk, str_dup); + return (ase_size_t)-1; + } + } + + for (i = tab->size; i > index; i--) tab->buf[i] = tab->buf[i-1]; + tab->buf[index].name = str_dup; + tab->buf[index].name_len = len; + + if (index > tab->size) tab->size = index + 1; + else tab->size++; + + return index; +} + +ase_size_t ase_awk_tab_remove ( + ase_awk_tab_t* tab, ase_size_t index, ase_size_t count) +{ + ase_size_t i, j, k; + + if (index >= tab->size) return 0; + if (count > tab->size - index) count = tab->size - index; + + i = index; + j = index + count; + k = index + count; + + while (i < k) + { + ASE_AWK_FREE (tab->awk, tab->buf[i].name); + + if (j >= tab->size) + { + tab->buf[i].name = ASE_NULL; + tab->buf[i].name_len = 0; + i++; + } + else + { + tab->buf[i].name = tab->buf[j].name; + tab->buf[i].name_len = tab->buf[j].name_len; + i++; j++; + } + } + + tab->size -= count; + return count; +} + +ase_size_t ase_awk_tab_add ( + ase_awk_tab_t* tab, const ase_char_t* str, ase_size_t len) +{ + return ase_awk_tab_insert (tab, tab->size, str, len); +} + +ase_size_t ase_awk_tab_find ( + ase_awk_tab_t* tab, ase_size_t index, + const ase_char_t* str, ase_size_t len) +{ + ase_size_t i; + + for (i = index; i < tab->size; i++) + { + if (ase_strxncmp ( + tab->buf[i].name, tab->buf[i].name_len, + str, len) == 0) return i; + } + + return (ase_size_t)-1; +} + +ase_size_t ase_awk_tab_rfind ( + ase_awk_tab_t* tab, ase_size_t index, + const ase_char_t* str, ase_size_t len) +{ + ase_size_t i; + + if (index >= tab->size) return (ase_size_t)-1; + + for (i = index + 1; i-- > 0; ) + { + if (ase_strxncmp ( + tab->buf[i].name, tab->buf[i].name_len, + str, len) == 0) return i; + } + + return (ase_size_t)-1; +} + +ase_size_t ase_awk_tab_rrfind ( + ase_awk_tab_t* tab, ase_size_t index, + const ase_char_t* str, ase_size_t len) +{ + ase_size_t i; + + if (index >= tab->size) return (ase_size_t)-1; + + for (i = tab->size - index; i-- > 0; ) + { + if (ase_strxncmp ( + tab->buf[i].name, tab->buf[i].name_len, + str, len) == 0) return i; + } + + return (ase_size_t)-1; +} diff --git a/ase/awk/tab.h b/ase/awk/tab.h new file mode 100644 index 00000000..bb669605 --- /dev/null +++ b/ase/awk/tab.h @@ -0,0 +1,69 @@ +/* + * $Id: tab.h,v 1.3 2007/04/30 05:47:33 bacon Exp $ + * + * {License} + */ + +#ifndef _ASE_AWK_TAB_H_ +#define _ASE_AWK_TAB_H_ + +#ifndef _ASE_AWK_AWK_H_ +#error Never include this file directly. Include instead +#endif + +/* TODO: you have to turn this into a hash table. + as of now, this is an arrayed table. */ + +typedef struct ase_awk_tab_t ase_awk_tab_t; + +struct ase_awk_tab_t +{ + struct + { + ase_char_t* name; + ase_size_t name_len; + }* buf; + ase_size_t size; + ase_size_t capa; + ase_awk_t* awk; + ase_bool_t __dynamic; +}; + +#ifdef __cplusplus +extern "C" { +#endif + +ase_awk_tab_t* ase_awk_tab_open (ase_awk_tab_t* tab, ase_awk_t* awk); +void ase_awk_tab_close (ase_awk_tab_t* tab); + +ase_size_t ase_awk_tab_getsize (ase_awk_tab_t* tab); +ase_size_t ase_awk_tab_getcapa (ase_awk_tab_t* tab); +ase_awk_tab_t* ase_awk_tab_setcapa (ase_awk_tab_t* tab, ase_size_t capa); + +void ase_awk_tab_clear (ase_awk_tab_t* tab); + +ase_size_t ase_awk_tab_insert ( + ase_awk_tab_t* tab, ase_size_t index, + const ase_char_t* str, ase_size_t len); + +ase_size_t ase_awk_tab_remove ( + ase_awk_tab_t* tab, ase_size_t index, ase_size_t count); + +ase_size_t ase_awk_tab_add ( + ase_awk_tab_t* tab, const ase_char_t* str, ase_size_t len); + +ase_size_t ase_awk_tab_find ( + ase_awk_tab_t* tab, ase_size_t index, + const ase_char_t* str, ase_size_t len); +ase_size_t ase_awk_tab_rfind ( + ase_awk_tab_t* tab, ase_size_t index, + const ase_char_t* str, ase_size_t len); +ase_size_t ase_awk_tab_rrfind ( + ase_awk_tab_t* tab, ase_size_t index, + const ase_char_t* str, ase_size_t len); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ase/awk/tree.c b/ase/awk/tree.c new file mode 100644 index 00000000..5f56b3ef --- /dev/null +++ b/ase/awk/tree.c @@ -0,0 +1,1176 @@ +/* + * $Id: tree.c,v 1.3 2007/04/30 05:47:33 bacon Exp $ + * + * {License} + */ + +#include + +static const ase_char_t* assop_str[] = +{ + ASE_T("="), + ASE_T("+="), + ASE_T("-="), + ASE_T("*="), + ASE_T("/="), + ASE_T("//="), + ASE_T("%="), + ASE_T("**=") +}; + +static const ase_char_t* binop_str[] = +{ + ASE_T("||"), + ASE_T("&&"), + ASE_T("in"), + + ASE_T("|"), + ASE_T("^"), + ASE_T("&"), + + ASE_T("=="), + ASE_T("!="), + ASE_T(">"), + ASE_T(">="), + ASE_T("<"), + ASE_T("<="), + + ASE_T("<<"), + ASE_T(">>"), + + ASE_T("+"), + ASE_T("-"), + ASE_T("*"), + ASE_T("/"), + ASE_T("//"), + ASE_T("%"), + ASE_T("**"), + + ASE_T(" "), + ASE_T("~"), + ASE_T("!~") +}; + +static const ase_char_t* unrop_str[] = +{ + ASE_T("+"), + ASE_T("-"), + ASE_T("!"), + ASE_T("~") +}; + +static const ase_char_t* incop_str[] = +{ + ASE_T("++"), + ASE_T("--"), + ASE_T("++"), + ASE_T("--") +}; + +static const ase_char_t* getline_inop_str[] = +{ + ASE_T("|"), + ASE_T("|&"), + ASE_T("<"), + ASE_T("") +}; + +static const ase_char_t* print_outop_str[] = +{ + ASE_T("|"), + ASE_T("|&"), + ASE_T(">"), + ASE_T(">>"), + ASE_T("") +}; + +#define PUT_SRCSTR(awk,str) \ + do { if (ase_awk_putsrcstr (awk, str) == -1) return -1; } while (0) + +#define PUT_NEWLINE(awk) \ + do { \ + if (awk->option & ASE_AWK_CRLF) PUT_SRCSTR (awk, ASE_T("\r")); \ + PUT_SRCSTR (awk, ASE_T("\n")); \ + } while (0) + +#define PUT_SRCSTRX(awk,str,len) \ + do { if (ase_awk_putsrcstrx (awk, str, len) == -1) return -1; } while (0) + +#define PRINT_TABS(awk,depth) \ + do { if (print_tabs(awk,depth) == -1) return -1; } while (0) + +#define PRINT_EXPRESSION(awk,nde) \ + do { if (print_expression(awk,nde) == -1) return -1; } while (0) + +#define PRINT_EXPRESSION_LIST(awk,nde) \ + do { if (print_expression_list(awk,nde) == -1) return -1; } while (0) + +#define PRINT_STATEMENTS(awk,nde,depth) \ + do { if (print_statements(awk,nde,depth) == -1) return -1; } while (0) + +static int print_tabs (ase_awk_t* awk, int depth); +static int print_expression (ase_awk_t* awk, ase_awk_nde_t* nde); +static int print_expression_list (ase_awk_t* awk, ase_awk_nde_t* tree); +static int print_statements (ase_awk_t* awk, ase_awk_nde_t* tree, int depth); + +static int print_tabs (ase_awk_t* awk, int depth) +{ + while (depth > 0) + { + PUT_SRCSTR (awk, ASE_T("\t")); + depth--; + } + + return 0; +} + +static int print_expression (ase_awk_t* awk, ase_awk_nde_t* nde) +{ + switch (nde->type) + { + case ASE_AWK_NDE_GRP: + { + ase_awk_nde_t* p = ((ase_awk_nde_grp_t*)nde)->body; + + PUT_SRCSTR (awk, ASE_T("(")); + while (p != ASE_NULL) + { + PRINT_EXPRESSION (awk, p); + if (p->next != ASE_NULL) + PUT_SRCSTR (awk, ASE_T(",")); + p = p->next; + } + PUT_SRCSTR (awk, ASE_T(")")); + break; + } + + case ASE_AWK_NDE_ASS: + { + ase_awk_nde_ass_t* px = (ase_awk_nde_ass_t*)nde; + + PRINT_EXPRESSION (awk, px->left); + PUT_SRCSTR (awk, ASE_T(" ")); + PUT_SRCSTR (awk, assop_str[px->opcode]); + PUT_SRCSTR (awk, ASE_T(" ")); + PRINT_EXPRESSION (awk, px->right); + + ASE_ASSERT (px->right->next == ASE_NULL); + break; + } + + case ASE_AWK_NDE_EXP_BIN: + { + ase_awk_nde_exp_t* px = (ase_awk_nde_exp_t*)nde; + + PUT_SRCSTR (awk, ASE_T("(")); + PRINT_EXPRESSION (awk, px->left); + ASE_ASSERT (px->left->next == ASE_NULL); + + PUT_SRCSTR (awk, ASE_T(" ")); + PUT_SRCSTR (awk, binop_str[px->opcode]); + PUT_SRCSTR (awk, ASE_T(" ")); + + if (px->right->type == ASE_AWK_NDE_ASS) + PUT_SRCSTR (awk, ASE_T("(")); + PRINT_EXPRESSION (awk, px->right); + if (px->right->type == ASE_AWK_NDE_ASS) + PUT_SRCSTR (awk, ASE_T(")")); + ASE_ASSERT (px->right->next == ASE_NULL); + PUT_SRCSTR (awk, ASE_T(")")); + break; + } + + case ASE_AWK_NDE_EXP_UNR: + { + ase_awk_nde_exp_t* px = (ase_awk_nde_exp_t*)nde; + ASE_ASSERT (px->right == ASE_NULL); + + PUT_SRCSTR (awk, ASE_T("(")); + PUT_SRCSTR (awk, unrop_str[px->opcode]); + PUT_SRCSTR (awk, ASE_T("(")); + PRINT_EXPRESSION (awk, px->left); + PUT_SRCSTR (awk, ASE_T(")")); + PUT_SRCSTR (awk, ASE_T(")")); + break; + } + + case ASE_AWK_NDE_EXP_INCPRE: + { + ase_awk_nde_exp_t* px = (ase_awk_nde_exp_t*)nde; + ASE_ASSERT (px->right == ASE_NULL); + + PUT_SRCSTR (awk, incop_str[px->opcode]); + PUT_SRCSTR (awk, ASE_T("(")); + PRINT_EXPRESSION (awk, px->left); + PUT_SRCSTR (awk, ASE_T(")")); + break; + } + + case ASE_AWK_NDE_EXP_INCPST: + { + ase_awk_nde_exp_t* px = (ase_awk_nde_exp_t*)nde; + ASE_ASSERT (px->right == ASE_NULL); + + PUT_SRCSTR (awk, ASE_T("(")); + PRINT_EXPRESSION (awk, px->left); + PUT_SRCSTR (awk, ASE_T(")")); + PUT_SRCSTR (awk, incop_str[px->opcode]); + break; + } + + case ASE_AWK_NDE_CND: + { + ase_awk_nde_cnd_t* px = (ase_awk_nde_cnd_t*)nde; + + PUT_SRCSTR (awk, ASE_T("(")); + PRINT_EXPRESSION (awk, px->test); + PUT_SRCSTR (awk, ASE_T(")?")); + + PRINT_EXPRESSION (awk, px->left); + PUT_SRCSTR (awk, ASE_T(":")); + PRINT_EXPRESSION (awk, px->right); + break; + } + + case ASE_AWK_NDE_INT: + { + if (((ase_awk_nde_int_t*)nde)->str == ASE_NULL) + { + ase_size_t n; + + n = ase_awk_longtostr ( + ((ase_awk_nde_int_t*)nde)->val, 10, ASE_NULL, + awk->tmp.fmt, ASE_COUNTOF(awk->tmp.fmt)); + + PUT_SRCSTRX (awk, awk->tmp.fmt, n); + } + else + { + PUT_SRCSTRX (awk, + ((ase_awk_nde_int_t*)nde)->str, + ((ase_awk_nde_int_t*)nde)->len); + } + break; + } + + case ASE_AWK_NDE_REAL: + { + if (((ase_awk_nde_real_t*)nde)->str == ASE_NULL) + { + #if (ASE_SIZEOF_LONG_DOUBLE != 0) + awk->prmfns.misc.sprintf ( + awk->prmfns.misc.custom_data, + awk->tmp.fmt, ASE_COUNTOF(awk->tmp.fmt), ASE_T("%Lf"), + (long double)((ase_awk_nde_real_t*)nde)->val); + #elif (ASE_SIZEOF_DOUBLE != 0) + awk->prmfns.misc.sprintf ( + awk->prmfns.misc.custom_data, + awk->tmp.fmt, ASE_COUNTOF(awk->tmp.fmt), ASE_T("%f"), + (double)((ase_awk_nde_real_t*)nde)->val); + #else + #error unsupported floating-point data type + #endif + PUT_SRCSTR (awk, awk->tmp.fmt); + } + else + { + PUT_SRCSTRX (awk, + ((ase_awk_nde_real_t*)nde)->str, + ((ase_awk_nde_real_t*)nde)->len); + } + break; + } + + case ASE_AWK_NDE_STR: + { + ase_char_t* ptr; + ase_size_t len, i; + + PUT_SRCSTR (awk, ASE_T("\"")); + + ptr = ((ase_awk_nde_str_t*)nde)->buf; + len = ((ase_awk_nde_str_t*)nde)->len; + for (i = 0; i < len; i++) + { + /* TODO: maybe more de-escaping?? */ + if (ptr[i] == ASE_T('\n')) + PUT_SRCSTR (awk, ASE_T("\\n")); + else if (ptr[i] == ASE_T('\r')) + PUT_SRCSTR (awk, ASE_T("\\r")); + else if (ptr[i] == ASE_T('\f')) + PUT_SRCSTR (awk, ASE_T("\\f")); + else if (ptr[i] == ASE_T('\b')) + PUT_SRCSTR (awk, ASE_T("\\b")); + else if (ptr[i] == ASE_T('\v')) + PUT_SRCSTR (awk, ASE_T("\\v")); + else if (ptr[i] == ASE_T('\a')) + PUT_SRCSTR (awk, ASE_T("\\a")); + else if (ptr[i] == ASE_T('\0')) + PUT_SRCSTR (awk, ASE_T("\\0")); + else + PUT_SRCSTRX (awk, &ptr[i], 1); + } + PUT_SRCSTR (awk, ASE_T("\"")); + break; + } + + case ASE_AWK_NDE_REX: + { + PUT_SRCSTR (awk, ASE_T("/")); + PUT_SRCSTRX (awk, + ((ase_awk_nde_rex_t*)nde)->buf, + ((ase_awk_nde_rex_t*)nde)->len); + PUT_SRCSTR (awk, ASE_T("/")); + break; + } + + case ASE_AWK_NDE_ARG: + { + ase_char_t tmp[ASE_SIZEOF(ase_long_t)*8+2]; + ase_size_t n; + ase_awk_nde_var_t* px = (ase_awk_nde_var_t*)nde; + ASE_ASSERT (px->id.idxa != (ase_size_t)-1); + + n = ase_awk_longtostr ( + px->id.idxa, 10, ASE_NULL, tmp, ASE_COUNTOF(tmp)); + + PUT_SRCSTR (awk, ASE_T("__param")); + PUT_SRCSTRX (awk, tmp, n); + + ASE_ASSERT (px->idx == ASE_NULL); + break; + } + + case ASE_AWK_NDE_ARGIDX: + { + ase_size_t n; + ase_awk_nde_var_t* px = (ase_awk_nde_var_t*)nde; + ASE_ASSERT (px->id.idxa != (ase_size_t)-1); + ASE_ASSERT (px->idx != ASE_NULL); + + PUT_SRCSTR (awk, ASE_T("__param")); + n = ase_awk_longtostr ( + px->id.idxa, 10, ASE_NULL, + awk->tmp.fmt, ASE_COUNTOF(awk->tmp.fmt)); + PUT_SRCSTRX (awk, awk->tmp.fmt, n); + PUT_SRCSTR (awk, ASE_T("[")); + PRINT_EXPRESSION_LIST (awk, px->idx); + PUT_SRCSTR (awk, ASE_T("]")); + break; + } + + case ASE_AWK_NDE_NAMED: + { + ase_awk_nde_var_t* px = (ase_awk_nde_var_t*)nde; + ASE_ASSERT (px->id.idxa == (ase_size_t)-1); + ASE_ASSERT (px->idx == ASE_NULL); + + PUT_SRCSTRX (awk, px->id.name, px->id.name_len); + break; + } + + case ASE_AWK_NDE_NAMEDIDX: + { + ase_awk_nde_var_t* px = (ase_awk_nde_var_t*)nde; + ASE_ASSERT (px->id.idxa == (ase_size_t)-1); + ASE_ASSERT (px->idx != ASE_NULL); + + PUT_SRCSTRX (awk, px->id.name, px->id.name_len); + PUT_SRCSTR (awk, ASE_T("[")); + PRINT_EXPRESSION_LIST (awk, px->idx); + PUT_SRCSTR (awk, ASE_T("]")); + break; + } + + case ASE_AWK_NDE_GLOBAL: + { + /*ase_char_t tmp[ASE_SIZEOF(ase_long_t)*8+2]; + ase_size_t n;*/ + ase_awk_nde_var_t* px = (ase_awk_nde_var_t*)nde; + + if (px->id.idxa != (ase_size_t)-1) + { + /* + PUT_SRCSTR (awk, ASE_T("__global")); + n = ase_awk_longtostr ( + px->id.idxa, 10, + ASE_NULL, tmp, ASE_COUNTOF(tmp)); + PUT_SRCSTRX (awk, tmp, n); + */ + PUT_SRCSTRX (awk, px->id.name, px->id.name_len); + } + else + { + PUT_SRCSTRX (awk, px->id.name, px->id.name_len); + } + ASE_ASSERT (px->idx == ASE_NULL); + break; + } + + case ASE_AWK_NDE_GLOBALIDX: + { + /*ase_char_t tmp[ASE_SIZEOF(ase_long_t)*8+2]; + ase_size_t n;*/ + ase_awk_nde_var_t* px = (ase_awk_nde_var_t*)nde; + + if (px->id.idxa != (ase_size_t)-1) + { + /* + PUT_SRCSTR (awk, ASE_T("__global")); + n = ase_awk_longtostr ( + px->id.idxa, 10, + ASE_NULL, tmp, ASE_COUNTOF(tmp)); + PUT_SRCSTRX (awk, tmp, n); + */ + PUT_SRCSTRX (awk, px->id.name, px->id.name_len); + PUT_SRCSTR (awk, ASE_T("[")); + } + else + { + PUT_SRCSTRX (awk, px->id.name, px->id.name_len); + PUT_SRCSTR (awk, ASE_T("[")); + } + ASE_ASSERT (px->idx != ASE_NULL); + PRINT_EXPRESSION_LIST (awk, px->idx); + PUT_SRCSTR (awk, ASE_T("]")); + break; + } + + case ASE_AWK_NDE_LOCAL: + { + ase_size_t n; + ase_awk_nde_var_t* px = (ase_awk_nde_var_t*)nde; + + if (px->id.idxa != (ase_size_t)-1) + { + PUT_SRCSTR (awk, ASE_T("__local")); + n = ase_awk_longtostr ( + px->id.idxa, 10, ASE_NULL, + awk->tmp.fmt, ASE_COUNTOF(awk->tmp.fmt)); + PUT_SRCSTRX (awk, awk->tmp.fmt, n); + } + else + { + PUT_SRCSTRX (awk, px->id.name, px->id.name_len); + } + ASE_ASSERT (px->idx == ASE_NULL); + break; + } + + case ASE_AWK_NDE_LOCALIDX: + { + ase_size_t n; + ase_awk_nde_var_t* px = (ase_awk_nde_var_t*)nde; + + if (px->id.idxa != (ase_size_t)-1) + { + PUT_SRCSTR (awk, ASE_T("__local")); + n = ase_awk_longtostr ( + px->id.idxa, 10, ASE_NULL, + awk->tmp.fmt, ASE_COUNTOF(awk->tmp.fmt)); + PUT_SRCSTRX (awk, awk->tmp.fmt, n); + PUT_SRCSTR (awk, ASE_T("[")); + } + else + { + PUT_SRCSTRX (awk, px->id.name, px->id.name_len); + PUT_SRCSTR (awk, ASE_T("[")); + } + ASE_ASSERT (px->idx != ASE_NULL); + PRINT_EXPRESSION_LIST (awk, px->idx); + PUT_SRCSTR (awk, ASE_T("]")); + break; + } + + case ASE_AWK_NDE_POS: + { + PUT_SRCSTR (awk, ASE_T("$")); + PRINT_EXPRESSION (awk, ((ase_awk_nde_pos_t*)nde)->val); + break; + } + + case ASE_AWK_NDE_BFN: + { + ase_awk_nde_call_t* px = (ase_awk_nde_call_t*)nde; + PUT_SRCSTRX (awk, + px->what.bfn.name.ptr, px->what.bfn.name.len); + PUT_SRCSTR (awk, ASE_T(" (")); + PRINT_EXPRESSION_LIST (awk, px->args); + PUT_SRCSTR (awk, ASE_T(")")); + break; + } + + case ASE_AWK_NDE_AFN: + { + ase_awk_nde_call_t* px = (ase_awk_nde_call_t*)nde; + PUT_SRCSTRX (awk, + px->what.afn.name.ptr, px->what.afn.name.len); + PUT_SRCSTR (awk, ASE_T(" (")); + PRINT_EXPRESSION_LIST (awk, px->args); + PUT_SRCSTR (awk, ASE_T(")")); + break; + } + + case ASE_AWK_NDE_GETLINE: + { + ase_awk_nde_getline_t* px = (ase_awk_nde_getline_t*)nde; + if (px->in != ASE_NULL && + (px->in_type == ASE_AWK_IN_PIPE || + px->in_type == ASE_AWK_IN_COPROC)) + { + PRINT_EXPRESSION (awk, px->in); + PUT_SRCSTR (awk, ASE_T(" ")); + PUT_SRCSTR (awk, getline_inop_str[px->in_type]); + PUT_SRCSTR (awk, ASE_T(" ")); + } + + PUT_SRCSTR (awk, ASE_T("getline")); + if (px->var != ASE_NULL) + { + PUT_SRCSTR (awk, ASE_T(" ")); + PRINT_EXPRESSION (awk, px->var); + } + + if (px->in != ASE_NULL && + px->in_type == ASE_AWK_IN_FILE) + { + PUT_SRCSTR (awk, ASE_T(" ")); + PUT_SRCSTR (awk, getline_inop_str[px->in_type]); + PUT_SRCSTR (awk, ASE_T(" ")); + PRINT_EXPRESSION (awk, px->in); + } + break; + } + + default: + { + return -1; + } + } + + return 0; +} + +static int print_expression_list (ase_awk_t* awk, ase_awk_nde_t* tree) +{ + ase_awk_nde_t* p = tree; + + while (p != ASE_NULL) + { + PRINT_EXPRESSION (awk, p); + p = p->next; + if (p != ASE_NULL) PUT_SRCSTR (awk, ASE_T(",")); + } + + return 0; +} + +static int print_statements (ase_awk_t* awk, ase_awk_nde_t* tree, int depth) +{ + ase_awk_nde_t* p = tree; + ase_size_t i; + + while (p != ASE_NULL) + { + + switch (p->type) + { + case ASE_AWK_NDE_NULL: + { + PRINT_TABS (awk, depth); + PUT_SRCSTR (awk, ASE_T(";")); + PUT_NEWLINE (awk); + break; + } + + case ASE_AWK_NDE_BLK: + { + ase_size_t n; + ase_awk_nde_blk_t* px = (ase_awk_nde_blk_t*)p; + + PRINT_TABS (awk, depth); + PUT_SRCSTR (awk, ASE_T("{")); + PUT_NEWLINE (awk); + + if (px->nlocals > 0) + { + PRINT_TABS (awk, depth + 1); + PUT_SRCSTR (awk, ASE_T("local ")); + + for (i = 0; i < px->nlocals - 1; i++) + { + PUT_SRCSTR (awk, ASE_T("__local")); + n = ase_awk_longtostr ( + i, 10, ASE_NULL, + awk->tmp.fmt, ASE_COUNTOF(awk->tmp.fmt)); + PUT_SRCSTRX (awk, awk->tmp.fmt, n); + PUT_SRCSTR (awk, ASE_T(", ")); + } + + PUT_SRCSTR (awk, ASE_T("__local")); + n = ase_awk_longtostr ( + i, 10, ASE_NULL, + awk->tmp.fmt, ASE_COUNTOF(awk->tmp.fmt)); + PUT_SRCSTRX (awk, awk->tmp.fmt, n); + PUT_SRCSTR (awk, ASE_T(";")); + PUT_NEWLINE (awk); + } + + PRINT_STATEMENTS (awk, px->body, depth + 1); + PRINT_TABS (awk, depth); + PUT_SRCSTR (awk, ASE_T("}")); + PUT_NEWLINE (awk); + break; + } + + case ASE_AWK_NDE_IF: + { + ase_awk_nde_if_t* px = (ase_awk_nde_if_t*)p; + + PRINT_TABS (awk, depth); + PUT_SRCSTR (awk, ASE_T("if (")); + PRINT_EXPRESSION (awk, px->test); + PUT_SRCSTR (awk, ASE_T(")")); + PUT_NEWLINE (awk); + + ASE_ASSERT (px->then_part != ASE_NULL); + if (px->then_part->type == ASE_AWK_NDE_BLK) + PRINT_STATEMENTS (awk, px->then_part, depth); + else + PRINT_STATEMENTS (awk, px->then_part, depth + 1); + + if (px->else_part != ASE_NULL) + { + PRINT_TABS (awk, depth); + PUT_SRCSTR (awk, ASE_T("else")); + PUT_NEWLINE (awk); + if (px->else_part->type == ASE_AWK_NDE_BLK) + PRINT_STATEMENTS (awk, px->else_part, depth); + else + PRINT_STATEMENTS (awk, px->else_part, depth + 1); + } + break; + } + + case ASE_AWK_NDE_WHILE: + { + ase_awk_nde_while_t* px = (ase_awk_nde_while_t*)p; + + PRINT_TABS (awk, depth); + PUT_SRCSTR (awk, ASE_T("while (")); + PRINT_EXPRESSION (awk, px->test); + PUT_SRCSTR (awk, ASE_T(")")); + PUT_NEWLINE (awk); + if (px->body->type == ASE_AWK_NDE_BLK) + { + PRINT_STATEMENTS (awk, px->body, depth); + } + else + { + PRINT_STATEMENTS (awk, px->body, depth + 1); + } + break; + } + + case ASE_AWK_NDE_DOWHILE: + { + ase_awk_nde_while_t* px = (ase_awk_nde_while_t*)p; + + PRINT_TABS (awk, depth); + PUT_SRCSTR (awk, ASE_T("do")); + PUT_NEWLINE (awk); + if (px->body->type == ASE_AWK_NDE_BLK) + { + PRINT_STATEMENTS (awk, px->body, depth); + } + else + { + PRINT_STATEMENTS (awk, px->body, depth + 1); + } + + PRINT_TABS (awk, depth); + PUT_SRCSTR (awk, ASE_T("while (")); + PRINT_EXPRESSION (awk, px->test); + PUT_SRCSTR (awk, ASE_T(");")); + PUT_NEWLINE (awk); + break; + } + + case ASE_AWK_NDE_FOR: + { + ase_awk_nde_for_t* px = (ase_awk_nde_for_t*)p; + + PRINT_TABS (awk, depth); + PUT_SRCSTR (awk, ASE_T("for (")); + if (px->init != ASE_NULL) + { + PRINT_EXPRESSION (awk, px->init); + } + PUT_SRCSTR (awk, ASE_T("; ")); + if (px->test != ASE_NULL) + { + PRINT_EXPRESSION (awk, px->test); + } + PUT_SRCSTR (awk, ASE_T("; ")); + if (px->incr != ASE_NULL) + { + PRINT_EXPRESSION (awk, px->incr); + } + PUT_SRCSTR (awk, ASE_T(")")); + PUT_NEWLINE (awk); + + if (px->body->type == ASE_AWK_NDE_BLK) + { + PRINT_STATEMENTS (awk, px->body, depth); + } + else + { + PRINT_STATEMENTS (awk, px->body, depth + 1); + } + break; + } + + case ASE_AWK_NDE_FOREACH: + { + ase_awk_nde_foreach_t* px = (ase_awk_nde_foreach_t*)p; + + PRINT_TABS (awk, depth); + PUT_SRCSTR (awk, ASE_T("for ")); + PRINT_EXPRESSION (awk, px->test); + PUT_NEWLINE (awk); + if (px->body->type == ASE_AWK_NDE_BLK) + { + PRINT_STATEMENTS (awk, px->body, depth); + } + else + { + PRINT_STATEMENTS (awk, px->body, depth + 1); + } + break; + } + + case ASE_AWK_NDE_BREAK: + { + PRINT_TABS (awk, depth); + PUT_SRCSTR (awk, ASE_T("break;")); + PUT_NEWLINE (awk); + break; + } + + case ASE_AWK_NDE_CONTINUE: + { + PRINT_TABS (awk, depth); + PUT_SRCSTR (awk, ASE_T("continue;")); + PUT_NEWLINE (awk); + break; + } + + case ASE_AWK_NDE_RETURN: + { + PRINT_TABS (awk, depth); + if (((ase_awk_nde_return_t*)p)->val == ASE_NULL) + { + PUT_SRCSTR (awk, ASE_T("return;")); + PUT_NEWLINE (awk); + } + else + { + PUT_SRCSTR (awk, ASE_T("return ")); + ASE_ASSERT (((ase_awk_nde_return_t*)p)->val->next == ASE_NULL); + + PRINT_EXPRESSION (awk, ((ase_awk_nde_return_t*)p)->val); + PUT_SRCSTR (awk, ASE_T(";")); + PUT_NEWLINE (awk); + } + break; + } + + case ASE_AWK_NDE_EXIT: + { + ase_awk_nde_exit_t* px = (ase_awk_nde_exit_t*)p; + PRINT_TABS (awk, depth); + + if (px->val == ASE_NULL) + { + PUT_SRCSTR (awk, ASE_T("exit;")); + PUT_NEWLINE (awk); + } + else + { + PUT_SRCSTR (awk, ASE_T("exit ")); + ASE_ASSERT (px->val->next == ASE_NULL); + PRINT_EXPRESSION (awk, px->val); + PUT_SRCSTR (awk, ASE_T(";")); + PUT_NEWLINE (awk); + } + break; + } + + case ASE_AWK_NDE_NEXT: + { + PRINT_TABS (awk, depth); + PUT_SRCSTR (awk, ASE_T("next;")); + PUT_NEWLINE (awk); + break; + } + + case ASE_AWK_NDE_NEXTFILE: + { + PRINT_TABS (awk, depth); + PUT_SRCSTR (awk, ASE_T("nextfile;")); + PUT_NEWLINE (awk); + break; + } + + case ASE_AWK_NDE_DELETE: + { + PRINT_TABS (awk, depth); + PUT_SRCSTR (awk, ASE_T("delete ")); + ase_awk_prnpt (awk, ((ase_awk_nde_delete_t*)p)->var); + break; + } + + case ASE_AWK_NDE_PRINT: + case ASE_AWK_NDE_PRINTF: + { + ase_awk_nde_print_t* px = (ase_awk_nde_print_t*)p; + + PRINT_TABS (awk, depth); + + if (p->type == ASE_AWK_NDE_PRINT) + PUT_SRCSTR (awk, ASE_T("print")); + else PUT_SRCSTR (awk, ASE_T("printf")); + + if (px->args != ASE_NULL) + { + PUT_SRCSTR (awk, ASE_T(" ")); + PRINT_EXPRESSION_LIST (awk, px->args); + } + + if (px->out != ASE_NULL) + { + PUT_SRCSTR (awk, ASE_T(" ")); + PUT_SRCSTR (awk, print_outop_str[px->out_type]); + PUT_SRCSTR (awk, ASE_T(" ")); + PRINT_EXPRESSION (awk, px->out); + } + + PUT_SRCSTR (awk, ASE_T(";")); + PUT_NEWLINE (awk); + break; + } + + default: + { + PRINT_TABS (awk, depth); + PRINT_EXPRESSION (awk, p); + PUT_SRCSTR (awk, ASE_T(";")); + PUT_NEWLINE (awk); + } + } + + p = p->next; + } + + return 0; +} + +int ase_awk_prnpt (ase_awk_t* awk, ase_awk_nde_t* tree) +{ + return print_statements (awk, tree, 0); +} + +int ase_awk_prnptnpt (ase_awk_t* awk, ase_awk_nde_t* tree) +{ + ase_awk_nde_t* nde = tree; + + while (nde != ASE_NULL) + { + if (print_expression (awk, nde) == -1) return -1; + if (nde->next == ASE_NULL) break; + + PUT_SRCSTR (awk, ASE_T(",")); + nde = nde->next; + } + + return 0; +} + +void ase_awk_clrpt (ase_awk_t* awk, ase_awk_nde_t* tree) +{ + ase_awk_nde_t* p = tree; + ase_awk_nde_t* next; + + while (p != ASE_NULL) + { + next = p->next; + + switch (p->type) + { + case ASE_AWK_NDE_NULL: + { + ASE_AWK_FREE (awk, p); + break; + } + + case ASE_AWK_NDE_BLK: + { + ase_awk_clrpt (awk, ((ase_awk_nde_blk_t*)p)->body); + ASE_AWK_FREE (awk, p); + break; + } + + case ASE_AWK_NDE_IF: + { + ase_awk_nde_if_t* px = (ase_awk_nde_if_t*)p; + ase_awk_clrpt (awk, px->test); + ase_awk_clrpt (awk, px->then_part); + + if (px->else_part != ASE_NULL) + ase_awk_clrpt (awk, px->else_part); + ASE_AWK_FREE (awk, p); + break; + } + + case ASE_AWK_NDE_WHILE: + case ASE_AWK_NDE_DOWHILE: + { + ase_awk_clrpt (awk, ((ase_awk_nde_while_t*)p)->test); + ase_awk_clrpt (awk, ((ase_awk_nde_while_t*)p)->body); + ASE_AWK_FREE (awk, p); + break; + } + + case ASE_AWK_NDE_FOR: + { + ase_awk_nde_for_t* px = (ase_awk_nde_for_t*)p; + + if (px->init != ASE_NULL) + ase_awk_clrpt (awk, px->init); + if (px->test != ASE_NULL) + ase_awk_clrpt (awk, px->test); + if (px->incr != ASE_NULL) + ase_awk_clrpt (awk, px->incr); + ase_awk_clrpt (awk, px->body); + ASE_AWK_FREE (awk, p); + break; + } + + case ASE_AWK_NDE_FOREACH: + { + ase_awk_clrpt (awk, ((ase_awk_nde_foreach_t*)p)->test); + ase_awk_clrpt (awk, ((ase_awk_nde_foreach_t*)p)->body); + ASE_AWK_FREE (awk, p); + break; + } + + case ASE_AWK_NDE_BREAK: + { + ASE_AWK_FREE (awk, p); + break; + } + + case ASE_AWK_NDE_CONTINUE: + { + ASE_AWK_FREE (awk, p); + break; + } + + case ASE_AWK_NDE_RETURN: + { + ase_awk_nde_return_t* px = + (ase_awk_nde_return_t*)p; + if (px->val != ASE_NULL) + ase_awk_clrpt (awk, px->val); + ASE_AWK_FREE (awk, p); + break; + } + + case ASE_AWK_NDE_EXIT: + { + if (((ase_awk_nde_exit_t*)p)->val != ASE_NULL) + ase_awk_clrpt (awk, ((ase_awk_nde_exit_t*)p)->val); + ASE_AWK_FREE (awk, p); + break; + } + + case ASE_AWK_NDE_NEXT: + case ASE_AWK_NDE_NEXTFILE: + { + ASE_AWK_FREE (awk, p); + break; + } + + case ASE_AWK_NDE_DELETE: + { + ase_awk_clrpt (awk, ((ase_awk_nde_delete_t*)p)->var); + ASE_AWK_FREE (awk, p); + break; + } + + case ASE_AWK_NDE_PRINT: + case ASE_AWK_NDE_PRINTF: + { + ase_awk_nde_print_t* px = + (ase_awk_nde_print_t*)p; + if (px->args != ASE_NULL) + ase_awk_clrpt (awk, px->args); + if (px->out != ASE_NULL) + ase_awk_clrpt (awk, px->out); + ASE_AWK_FREE (awk, p); + break; + } + + case ASE_AWK_NDE_GRP: + { + ase_awk_clrpt (awk, ((ase_awk_nde_grp_t*)p)->body); + ASE_AWK_FREE (awk, p); + break; + } + + case ASE_AWK_NDE_ASS: + { + ase_awk_clrpt (awk, ((ase_awk_nde_ass_t*)p)->left); + ase_awk_clrpt (awk, ((ase_awk_nde_ass_t*)p)->right); + ASE_AWK_FREE (awk, p); + break; + } + + case ASE_AWK_NDE_EXP_BIN: + { + ase_awk_nde_exp_t* px = (ase_awk_nde_exp_t*)p; + ASE_ASSERT (px->left->next == ASE_NULL); + ASE_ASSERT (px->right->next == ASE_NULL); + + ase_awk_clrpt (awk, px->left); + ase_awk_clrpt (awk, px->right); + ASE_AWK_FREE (awk, p); + break; + } + + case ASE_AWK_NDE_EXP_UNR: + case ASE_AWK_NDE_EXP_INCPRE: + case ASE_AWK_NDE_EXP_INCPST: + { + ase_awk_nde_exp_t* px = (ase_awk_nde_exp_t*)p; + ASE_ASSERT (px->right == ASE_NULL); + ase_awk_clrpt (awk, px->left); + ASE_AWK_FREE (awk, p); + break; + } + + case ASE_AWK_NDE_CND: + { + ase_awk_clrpt (awk, ((ase_awk_nde_cnd_t*)p)->test); + ase_awk_clrpt (awk, ((ase_awk_nde_cnd_t*)p)->left); + ase_awk_clrpt (awk, ((ase_awk_nde_cnd_t*)p)->right); + ASE_AWK_FREE (awk, p); + break; + } + + case ASE_AWK_NDE_INT: + { + if (((ase_awk_nde_int_t*)p)->str != ASE_NULL) + ASE_AWK_FREE (awk, ((ase_awk_nde_int_t*)p)->str); + ASE_AWK_FREE (awk, p); + break; + } + + case ASE_AWK_NDE_REAL: + { + if (((ase_awk_nde_real_t*)p)->str != ASE_NULL) + ASE_AWK_FREE (awk, ((ase_awk_nde_real_t*)p)->str); + ASE_AWK_FREE (awk, p); + break; + } + + case ASE_AWK_NDE_STR: + { + ASE_AWK_FREE (awk, ((ase_awk_nde_str_t*)p)->buf); + ASE_AWK_FREE (awk, p); + break; + } + + case ASE_AWK_NDE_REX: + { + ASE_AWK_FREE (awk, ((ase_awk_nde_rex_t*)p)->buf); + ASE_AWK_FREE (awk, ((ase_awk_nde_rex_t*)p)->code); + ASE_AWK_FREE (awk, p); + break; + } + + case ASE_AWK_NDE_NAMED: + case ASE_AWK_NDE_GLOBAL: + case ASE_AWK_NDE_LOCAL: + case ASE_AWK_NDE_ARG: + { + ase_awk_nde_var_t* px = (ase_awk_nde_var_t*)p; + ASE_ASSERT (px->idx == ASE_NULL); + if (px->id.name != ASE_NULL) + ASE_AWK_FREE (awk, px->id.name); + ASE_AWK_FREE (awk, p); + break; + } + + case ASE_AWK_NDE_NAMEDIDX: + case ASE_AWK_NDE_GLOBALIDX: + case ASE_AWK_NDE_LOCALIDX: + case ASE_AWK_NDE_ARGIDX: + { + ase_awk_nde_var_t* px = (ase_awk_nde_var_t*)p; + ASE_ASSERT (px->idx != ASE_NULL); + ase_awk_clrpt (awk, px->idx); + if (px->id.name != ASE_NULL) + ASE_AWK_FREE (awk, px->id.name); + ASE_AWK_FREE (awk, p); + break; + } + + case ASE_AWK_NDE_POS: + { + ase_awk_clrpt (awk, ((ase_awk_nde_pos_t*)p)->val); + ASE_AWK_FREE (awk, p); + break; + } + + case ASE_AWK_NDE_BFN: + { + ase_awk_nde_call_t* px = (ase_awk_nde_call_t*)p; + /* ASE_AWK_FREE (awk, px->what.bfn); */ + ase_awk_clrpt (awk, px->args); + ASE_AWK_FREE (awk, p); + break; + } + + case ASE_AWK_NDE_AFN: + { + ase_awk_nde_call_t* px = (ase_awk_nde_call_t*)p; + ASE_AWK_FREE (awk, px->what.afn.name.ptr); + ase_awk_clrpt (awk, px->args); + ASE_AWK_FREE (awk, p); + break; + } + + case ASE_AWK_NDE_GETLINE: + { + ase_awk_nde_getline_t* px = + (ase_awk_nde_getline_t*)p; + if (px->var != ASE_NULL) + ase_awk_clrpt (awk, px->var); + if (px->in != ASE_NULL) + ase_awk_clrpt (awk, px->in); + ASE_AWK_FREE (awk, p); + break; + } + + default: + { + ASE_ASSERT (!"should never happen - invalid node type"); + ASE_AWK_FREE (awk, p); + break; + } + } + + p = next; + } +} diff --git a/ase/awk/tree.h b/ase/awk/tree.h new file mode 100644 index 00000000..15918120 --- /dev/null +++ b/ase/awk/tree.h @@ -0,0 +1,403 @@ +/* + * $Id: tree.h,v 1.3 2007/04/30 05:47:33 bacon Exp $ + * + * {License} + */ + +#ifndef _ASE_AWK_TREE_H_ +#define _ASE_AWK_TREE_H_ + +#ifndef _ASE_AWK_AWK_H_ +#error Never include this file directly. Include instead +#endif + +enum ase_awk_nde_type_t +{ + ASE_AWK_NDE_NULL, + + /* statement */ + ASE_AWK_NDE_BLK, + ASE_AWK_NDE_IF, + ASE_AWK_NDE_WHILE, + ASE_AWK_NDE_DOWHILE, + ASE_AWK_NDE_FOR, + ASE_AWK_NDE_FOREACH, + ASE_AWK_NDE_BREAK, + ASE_AWK_NDE_CONTINUE, + ASE_AWK_NDE_RETURN, + ASE_AWK_NDE_EXIT, + ASE_AWK_NDE_NEXT, + ASE_AWK_NDE_NEXTFILE, + ASE_AWK_NDE_DELETE, + ASE_AWK_NDE_PRINT, + ASE_AWK_NDE_PRINTF, + + /* expression */ + /* if you change the following values including their order, + * you should change __eval_func of __eval_expression + * in run.c accordingly */ + ASE_AWK_NDE_GRP, + ASE_AWK_NDE_ASS, + ASE_AWK_NDE_EXP_BIN, + ASE_AWK_NDE_EXP_UNR, + ASE_AWK_NDE_EXP_INCPRE, + ASE_AWK_NDE_EXP_INCPST, + ASE_AWK_NDE_CND, + ASE_AWK_NDE_BFN, + ASE_AWK_NDE_AFN, + ASE_AWK_NDE_INT, + ASE_AWK_NDE_REAL, + ASE_AWK_NDE_STR, + ASE_AWK_NDE_REX, + + /* keep this order for the following items otherwise, you may have + * to change __eval_incpre and __eval_incpst in run.c as well as + * ASE_AWK_VAL_REF_XXX in val.h */ + ASE_AWK_NDE_NAMED, + ASE_AWK_NDE_GLOBAL, + ASE_AWK_NDE_LOCAL, + ASE_AWK_NDE_ARG, + ASE_AWK_NDE_NAMEDIDX, + ASE_AWK_NDE_GLOBALIDX, + ASE_AWK_NDE_LOCALIDX, + ASE_AWK_NDE_ARGIDX, + ASE_AWK_NDE_POS, + /* ---------------------------------- */ + + ASE_AWK_NDE_GETLINE +}; + +enum ase_awk_in_type_t +{ + /* the order of these values match + * __in_type_map and __in_opt_map in extio.c */ + + ASE_AWK_IN_PIPE, + ASE_AWK_IN_COPROC, + ASE_AWK_IN_FILE, + ASE_AWK_IN_CONSOLE +}; + +enum ase_awk_out_type_t +{ + /* the order of these values match + * __out_type_map and __out_opt_map in extio.c */ + + ASE_AWK_OUT_PIPE, + ASE_AWK_OUT_COPROC, + ASE_AWK_OUT_FILE, + ASE_AWK_OUT_FILE_APPEND, + ASE_AWK_OUT_CONSOLE +}; + +/* afn (awk function defined with the keyword function) */ +typedef struct ase_awk_afn_t ase_awk_afn_t; +typedef struct ase_awk_nde_t ase_awk_nde_t; +typedef struct ase_awk_nde_blk_t ase_awk_nde_blk_t; +typedef struct ase_awk_nde_grp_t ase_awk_nde_grp_t; +typedef struct ase_awk_nde_ass_t ase_awk_nde_ass_t; +typedef struct ase_awk_nde_exp_t ase_awk_nde_exp_t; +typedef struct ase_awk_nde_cnd_t ase_awk_nde_cnd_t; +typedef struct ase_awk_nde_pos_t ase_awk_nde_pos_t; + +#ifndef ASE_AWK_NDE_INT_DEFINED +#define ASE_AWK_NDE_INT_DEFINED +typedef struct ase_awk_nde_int_t ase_awk_nde_int_t; +#endif + +#ifndef ASE_AWK_NDE_REAL_DEFINED +#define ASE_AWK_NDE_REAL_DEFINED +typedef struct ase_awk_nde_real_t ase_awk_nde_real_t; +#endif + +typedef struct ase_awk_nde_str_t ase_awk_nde_str_t; +typedef struct ase_awk_nde_rex_t ase_awk_nde_rex_t; +typedef struct ase_awk_nde_var_t ase_awk_nde_var_t; +typedef struct ase_awk_nde_call_t ase_awk_nde_call_t; +typedef struct ase_awk_nde_getline_t ase_awk_nde_getline_t; + +typedef struct ase_awk_nde_if_t ase_awk_nde_if_t; +typedef struct ase_awk_nde_while_t ase_awk_nde_while_t; +typedef struct ase_awk_nde_for_t ase_awk_nde_for_t; +typedef struct ase_awk_nde_foreach_t ase_awk_nde_foreach_t; +typedef struct ase_awk_nde_break_t ase_awk_nde_break_t; +typedef struct ase_awk_nde_continue_t ase_awk_nde_continue_t; +typedef struct ase_awk_nde_return_t ase_awk_nde_return_t; +typedef struct ase_awk_nde_exit_t ase_awk_nde_exit_t; +typedef struct ase_awk_nde_next_t ase_awk_nde_next_t; +typedef struct ase_awk_nde_nextfile_t ase_awk_nde_nextfile_t; +typedef struct ase_awk_nde_delete_t ase_awk_nde_delete_t; +typedef struct ase_awk_nde_print_t ase_awk_nde_print_t; + +struct ase_awk_afn_t +{ + ase_char_t* name; + ase_size_t name_len; + ase_size_t nargs; + ase_awk_nde_t* body; +}; + +#define ASE_AWK_NDE_HDR \ + int type; \ + ase_size_t line; \ + ase_awk_nde_t* next + +struct ase_awk_nde_t +{ + ASE_AWK_NDE_HDR; +}; + +/* ASE_AWK_NDE_BLK - block statement including top-level blocks */ +struct ase_awk_nde_blk_t +{ + ASE_AWK_NDE_HDR; + ase_size_t nlocals; + ase_awk_nde_t* body; +}; + +/* ASE_AWK_NDE_GRP - expression group */ +struct ase_awk_nde_grp_t +{ + ASE_AWK_NDE_HDR; + ase_awk_nde_t* body; +}; + +/* ASE_AWK_NDE_ASS - assignment */ +struct ase_awk_nde_ass_t +{ + ASE_AWK_NDE_HDR; + int opcode; + ase_awk_nde_t* left; + ase_awk_nde_t* right; +}; + +/* ASE_AWK_NDE_EXP_BIN, ASE_AWK_NDE_EXP_UNR, + * ASE_AWK_NDE_EXP_INCPRE, ASE_AW_NDE_EXP_INCPST */ +struct ase_awk_nde_exp_t +{ + ASE_AWK_NDE_HDR; + int opcode; + ase_awk_nde_t* left; + ase_awk_nde_t* right; /* ASE_NULL for UNR, INCPRE, INCPST */ +}; + +/* ASE_AWK_NDE_CND */ +struct ase_awk_nde_cnd_t +{ + ASE_AWK_NDE_HDR; + ase_awk_nde_t* test; + ase_awk_nde_t* left; + ase_awk_nde_t* right; +}; + +/* ASE_AWK_NDE_POS - positional - $1, $2, $x, etc */ +struct ase_awk_nde_pos_t +{ + ASE_AWK_NDE_HDR; + ase_awk_nde_t* val; +}; + +/* ASE_AWK_NDE_INT */ +struct ase_awk_nde_int_t +{ + ASE_AWK_NDE_HDR; + ase_long_t val; + ase_char_t* str; + ase_size_t len; +}; + +/* ASE_AWK_NDE_REAL */ +struct ase_awk_nde_real_t +{ + ASE_AWK_NDE_HDR; + ase_real_t val; + ase_char_t* str; + ase_size_t len; +}; + +/* ASE_AWK_NDE_STR */ +struct ase_awk_nde_str_t +{ + ASE_AWK_NDE_HDR; + ase_char_t* buf; + ase_size_t len; +}; + +/* ASE_AWK_NDE_REX */ +struct ase_awk_nde_rex_t +{ + ASE_AWK_NDE_HDR; + ase_char_t* buf; + ase_size_t len; + void* code; +}; + +/* ASE_AWK_NDE_NAMED, ASE_AWK_NDE_GLOBAL, + * ASE_AWK_NDE_LOCAL, ASE_AWK_NDE_ARG + * ASE_AWK_NDE_NAMEDIDX, ASE_AWK_NDE_GLOBALIDX, + * ASE_AWK_NDE_LOCALIDX, ASE_AWK_NDE_ARGIDX */ +struct ase_awk_nde_var_t +{ + ASE_AWK_NDE_HDR; + struct + { + ase_char_t* name; + ase_size_t name_len; + ase_size_t idxa; + } id; + ase_awk_nde_t* idx; /* ASE_NULL for non-XXXXIDX */ +}; + +/* ASE_AWK_NDE_BFN, ASE_AWK_NDE_AFN */ +struct ase_awk_nde_call_t +{ + ASE_AWK_NDE_HDR; + union + { + struct + { + struct + { + ase_char_t* ptr; + ase_size_t len; + } name; + } afn; + + /* minimum information of a built-in function + * needed during run-time. */ + struct + { + struct + { + const ase_char_t* ptr; + ase_size_t len; + } name; + + struct + { + ase_size_t min; + ase_size_t max; + const ase_char_t* spec; + } arg; + + int (*handler) ( + ase_awk_run_t*, const ase_char_t*, ase_size_t); + } bfn; + } what; + ase_awk_nde_t* args; + ase_size_t nargs; +}; + +/* ASE_AWK_NDE_GETLINE */ +struct ase_awk_nde_getline_t +{ + ASE_AWK_NDE_HDR; + ase_awk_nde_t* var; + int in_type; /* ASE_AWK_GETLINE_XXX */ + ase_awk_nde_t* in; +}; + +/* ASE_AWK_NDE_IF */ +struct ase_awk_nde_if_t +{ + ASE_AWK_NDE_HDR; + ase_awk_nde_t* test; + ase_awk_nde_t* then_part; + ase_awk_nde_t* else_part; /* optional */ +}; + +/* ASE_AWK_NDE_WHILE, ASE_AWK_NDE_DOWHILE */ +struct ase_awk_nde_while_t +{ + ASE_AWK_NDE_HDR; + ase_awk_nde_t* test; + ase_awk_nde_t* body; +}; + +/* ASE_AWK_NDE_FOR */ +struct ase_awk_nde_for_t +{ + ASE_AWK_NDE_HDR; + ase_awk_nde_t* init; /* optional */ + ase_awk_nde_t* test; /* optional */ + ase_awk_nde_t* incr; /* optional */ + ase_awk_nde_t* body; +}; + +/* ASE_AWK_NDE_FOREACH */ +struct ase_awk_nde_foreach_t +{ + ASE_AWK_NDE_HDR; + ase_awk_nde_t* test; + ase_awk_nde_t* body; +}; + +/* ASE_AWK_NDE_BREAK */ +struct ase_awk_nde_break_t +{ + ASE_AWK_NDE_HDR; +}; + +/* ASE_AWK_NDE_CONTINUE */ +struct ase_awk_nde_continue_t +{ + ASE_AWK_NDE_HDR; +}; + +/* ASE_AWK_NDE_RETURN */ +struct ase_awk_nde_return_t +{ + ASE_AWK_NDE_HDR; + ase_awk_nde_t* val; /* optional (no return code if ASE_NULL) */ +}; + +/* ASE_AWK_NDE_EXIT */ +struct ase_awk_nde_exit_t +{ + ASE_AWK_NDE_HDR; + ase_awk_nde_t* val; /* optional (no exit code if ASE_NULL) */ +}; + +/* ASE_AWK_NDE_NEXT */ +struct ase_awk_nde_next_t +{ + ASE_AWK_NDE_HDR; +}; + +/* ASE_AWK_NDE_NEXTFILE */ +struct ase_awk_nde_nextfile_t +{ + ASE_AWK_NDE_HDR; + int out; +}; + +/* ASE_AWK_NDE_DELETE */ +struct ase_awk_nde_delete_t +{ + ASE_AWK_NDE_HDR; + ase_awk_nde_t* var; +}; + +/* ASE_AWK_NDE_PRINT */ +struct ase_awk_nde_print_t +{ + ASE_AWK_NDE_HDR; + ase_awk_nde_t* args; + int out_type; /* ASE_AWK_OUT_XXX */ + ase_awk_nde_t* out; +}; + +#ifdef __cplusplus +extern "C" { +#endif + +int ase_awk_prnpt (ase_awk_t* awk, ase_awk_nde_t* tree); +int ase_awk_prnptnpt (ase_awk_t* awk, ase_awk_nde_t* tree); + +void ase_awk_clrpt (ase_awk_t* awk, ase_awk_nde_t* tree); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ase/awk/val.c b/ase/awk/val.c new file mode 100644 index 00000000..4b926325 --- /dev/null +++ b/ase/awk/val.c @@ -0,0 +1,839 @@ +/* + * $Id: val.c,v 1.3 2007/04/30 05:47:33 bacon Exp $ + * + * {License} + */ + +#include + +#ifdef DEBUG_VAL +#include +#endif + + +static ase_char_t* str_to_str ( + ase_awk_run_t* run, const ase_char_t* str, ase_size_t str_len, + int opt, ase_str_t* buf, ase_size_t* len); +static ase_char_t* val_int_to_str ( + ase_awk_run_t* run, ase_awk_val_int_t* v, + int opt, ase_str_t* buf, ase_size_t* len); +static ase_char_t* val_real_to_str ( + ase_awk_run_t* run, ase_awk_val_real_t* v, + int opt, ase_str_t* buf, ase_size_t* len); + +static ase_awk_val_nil_t awk_nil = { ASE_AWK_VAL_NIL, 0 }; +static ase_awk_val_str_t awk_zls = { ASE_AWK_VAL_STR, 0, ASE_T(""), 0 }; + +ase_awk_val_t* ase_awk_val_nil = (ase_awk_val_t*)&awk_nil; +ase_awk_val_t* ase_awk_val_zls = (ase_awk_val_t*)&awk_zls; + +static ase_awk_val_int_t awk_int[] = +{ + { ASE_AWK_VAL_INT, 0, -1, ASE_NULL }, + { ASE_AWK_VAL_INT, 0, 0, ASE_NULL }, + { ASE_AWK_VAL_INT, 0, 1, ASE_NULL }, + { ASE_AWK_VAL_INT, 0, 2, ASE_NULL }, + { ASE_AWK_VAL_INT, 0, 3, ASE_NULL }, + { ASE_AWK_VAL_INT, 0, 4, ASE_NULL }, + { ASE_AWK_VAL_INT, 0, 5, ASE_NULL }, + { ASE_AWK_VAL_INT, 0, 6, ASE_NULL }, + { ASE_AWK_VAL_INT, 0, 7, ASE_NULL }, + { ASE_AWK_VAL_INT, 0, 8, ASE_NULL }, + { ASE_AWK_VAL_INT, 0, 9, ASE_NULL }, + { ASE_AWK_VAL_INT, 0, 10, ASE_NULL }, + { ASE_AWK_VAL_INT, 0, 11, ASE_NULL }, + { ASE_AWK_VAL_INT, 0, 12, ASE_NULL }, + { ASE_AWK_VAL_INT, 0, 13, ASE_NULL }, + { ASE_AWK_VAL_INT, 0, 14, ASE_NULL }, + { ASE_AWK_VAL_INT, 0, 15, ASE_NULL }, + { ASE_AWK_VAL_INT, 0, 16, ASE_NULL }, + { ASE_AWK_VAL_INT, 0, 17, ASE_NULL }, + { ASE_AWK_VAL_INT, 0, 18, ASE_NULL }, + { ASE_AWK_VAL_INT, 0, 19, ASE_NULL }, + { ASE_AWK_VAL_INT, 0, 20, ASE_NULL } +}; + +ase_awk_val_t* ase_awk_val_negone = (ase_awk_val_t*)&awk_int[0]; +ase_awk_val_t* ase_awk_val_zero = (ase_awk_val_t*)&awk_int[1]; +ase_awk_val_t* ase_awk_val_one = (ase_awk_val_t*)&awk_int[2]; + +ase_awk_val_t* ase_awk_makeintval (ase_awk_run_t* run, ase_long_t v) +{ + ase_awk_val_int_t* val; + + if (v >= awk_int[0].val && + v <= awk_int[ASE_COUNTOF(awk_int)-1].val) + { + return (ase_awk_val_t*)&awk_int[v-awk_int[0].val]; + } + + if (run->icache_count > 0) + { + val = run->icache[--run->icache_count]; + } + else + { + val = (ase_awk_val_int_t*) ASE_AWK_MALLOC ( + run->awk, ASE_SIZEOF(ase_awk_val_int_t)); + if (val == ASE_NULL) return ASE_NULL; + } + + val->type = ASE_AWK_VAL_INT; + val->ref = 0; + val->val = v; + val->nde = ASE_NULL; + +#ifdef DEBUG_VAL + ase_dprintf (ASE_T("makeintval => %p\n"), val); +#endif + return (ase_awk_val_t*)val; +} + +ase_awk_val_t* ase_awk_makerealval (ase_awk_run_t* run, ase_real_t v) +{ + ase_awk_val_real_t* val; + + if (run->rcache_count > 0) + { + val = run->rcache[--run->rcache_count]; + } + else + { + val = (ase_awk_val_real_t*) ASE_AWK_MALLOC ( + run->awk, ASE_SIZEOF(ase_awk_val_real_t)); + if (val == ASE_NULL) return ASE_NULL; + } + + val->type = ASE_AWK_VAL_REAL; + val->ref = 0; + val->val = v; + val->nde = ASE_NULL; + +#ifdef DEBUG_VAL + ase_dprintf (ASE_T("makerealval => %p\n"), val); +#endif + return (ase_awk_val_t*)val; +} + +ase_awk_val_t* ase_awk_makestrval0 (ase_awk_run_t* run, const ase_char_t* str) +{ + return ase_awk_makestrval (run, str, ase_strlen(str)); +} + +ase_awk_val_t* ase_awk_makestrval ( + ase_awk_run_t* run, const ase_char_t* str, ase_size_t len) +{ + ase_awk_val_str_t* val; + + val = (ase_awk_val_str_t*) ASE_AWK_MALLOC ( + run->awk, ASE_SIZEOF(ase_awk_val_str_t)); + if (val == ASE_NULL) return ASE_NULL; + + val->type = ASE_AWK_VAL_STR; + val->ref = 0; + val->len = len; + val->buf = ase_strxdup (str, len, &run->awk->prmfns.mmgr); + if (val->buf == ASE_NULL) + { + ASE_AWK_FREE (run->awk, val); + return ASE_NULL; + } + +#ifdef DEBUG_VAL + ase_dprintf (ASE_T("makestrval => %p\n"), val); +#endif + return (ase_awk_val_t*)val; +} + +ase_awk_val_t* ase_awk_makestrval_nodup ( + ase_awk_run_t* run, ase_char_t* str, ase_size_t len) +{ + ase_awk_val_str_t* val; + + val = (ase_awk_val_str_t*) ASE_AWK_MALLOC ( + run->awk, ASE_SIZEOF(ase_awk_val_str_t)); + if (val == ASE_NULL) return ASE_NULL; + + val->type = ASE_AWK_VAL_STR; + val->ref = 0; + val->len = len; + val->buf = str; + return (ase_awk_val_t*)val; +} + +ase_awk_val_t* ase_awk_makestrval2 ( + ase_awk_run_t* run, + const ase_char_t* str1, ase_size_t len1, + const ase_char_t* str2, ase_size_t len2) +{ + ase_awk_val_str_t* val; + + val = (ase_awk_val_str_t*) ASE_AWK_MALLOC ( + run->awk, ASE_SIZEOF(ase_awk_val_str_t)); + if (val == ASE_NULL) return ASE_NULL; + + val->type = ASE_AWK_VAL_STR; + val->ref = 0; + val->len = len1 + len2; + val->buf = ase_strxdup2 (str1, len1, str2, len2, &run->awk->prmfns.mmgr); + if (val->buf == ASE_NULL) + { + ASE_AWK_FREE (run->awk, val); + return ASE_NULL; + } + +#ifdef DEBUG_VAL + ase_dprintf (ASE_T("makestrval2 => %p\n"), val); +#endif + return (ase_awk_val_t*)val; +} + +ase_awk_val_t* ase_awk_makerexval ( + ase_awk_run_t* run, const ase_char_t* buf, ase_size_t len, void* code) +{ + ase_awk_val_rex_t* val; + + val = (ase_awk_val_rex_t*) ASE_AWK_MALLOC ( + run->awk, ASE_SIZEOF(ase_awk_val_rex_t)); + if (val == ASE_NULL) return ASE_NULL; + + val->type = ASE_AWK_VAL_REX; + val->ref = 0; + val->len = len; + val->buf = ase_strxdup (buf, len, &run->awk->prmfns.mmgr); + if (val->buf == ASE_NULL) + { + ASE_AWK_FREE (run->awk, val); + return ASE_NULL; + } + + val->code = ASE_AWK_MALLOC (run->awk, ASE_AWK_REX_LEN(code)); + if (val->code == ASE_NULL) + { + ASE_AWK_FREE (run->awk, val->buf); + ASE_AWK_FREE (run->awk, val); + return ASE_NULL; + } + + ase_memcpy (val->code, code, ASE_AWK_REX_LEN(code)); + return (ase_awk_val_t*)val; +} + +static void free_map_val (void* run, void* v) +{ +#ifdef DEBUG_VAL + ase_dprintf (ASE_T("refdown in map free...")); + ase_awk_dprintval (run, v); + ase_dprintf (ASE_T("\n")); +#endif + + ase_awk_refdownval (run, v); +} + +ase_awk_val_t* ase_awk_makemapval (ase_awk_run_t* run) +{ + ase_awk_val_map_t* val; + + val = (ase_awk_val_map_t*) ASE_AWK_MALLOC ( + run->awk, ASE_SIZEOF(ase_awk_val_map_t)); + if (val == ASE_NULL) return ASE_NULL; + + val->type = ASE_AWK_VAL_MAP; + val->ref = 0; + val->map = ase_awk_map_open ( + ASE_NULL, run, 256, free_map_val, run->awk); + if (val->map == ASE_NULL) + { + ASE_AWK_FREE (run->awk, val); + return ASE_NULL; + } + + return (ase_awk_val_t*)val; +} + +ase_awk_val_t* ase_awk_makerefval (ase_awk_run_t* run, int id, ase_awk_val_t** adr) +{ + ase_awk_val_ref_t* val; + + if (run->fcache_count > 0) + { + val = run->fcache[--run->fcache_count]; + } + else + { + val = (ase_awk_val_ref_t*) ASE_AWK_MALLOC ( + run->awk, ASE_SIZEOF(ase_awk_val_ref_t)); + if (val == ASE_NULL) return ASE_NULL; + } + + val->type = ASE_AWK_VAL_REF; + val->ref = 0; + val->id = id; + val->adr = adr; + + return (ase_awk_val_t*)val; +} + +ase_bool_t ase_awk_isbuiltinval (ase_awk_val_t* val) +{ + return val == ASE_NULL || + val == ase_awk_val_nil || + val == ase_awk_val_zls || + val == ase_awk_val_zero || + val == ase_awk_val_one || + (val >= (ase_awk_val_t*)&awk_int[0] && + val <= (ase_awk_val_t*)&awk_int[ASE_COUNTOF(awk_int)-1]); +} + +void ase_awk_freeval (ase_awk_run_t* run, ase_awk_val_t* val, ase_bool_t cache) +{ + if (ase_awk_isbuiltinval(val)) return; + +#ifdef DEBUG_VAL + ase_dprintf (ASE_T("freeing [cache=%d] ... "), cache); + ase_awk_dprintval (run, val); + ase_dprintf (ASE_T("\n")); +#endif + + if (val->type == ASE_AWK_VAL_NIL) + { + ASE_AWK_FREE (run->awk, val); + } + else if (val->type == ASE_AWK_VAL_INT) + { + if (cache == ase_true && + run->icache_count < ASE_COUNTOF(run->icache)) + { + run->icache[run->icache_count++] = + (ase_awk_val_int_t*)val; + } + else ASE_AWK_FREE (run->awk, val); + } + else if (val->type == ASE_AWK_VAL_REAL) + { + if (cache == ase_true && + run->rcache_count < ASE_COUNTOF(run->rcache)) + { + run->rcache[run->rcache_count++] = + (ase_awk_val_real_t*)val; + } + else ASE_AWK_FREE (run->awk, val); + } + else if (val->type == ASE_AWK_VAL_STR) + { + ASE_AWK_FREE (run->awk, ((ase_awk_val_str_t*)val)->buf); + ASE_AWK_FREE (run->awk, val); + } + else if (val->type == ASE_AWK_VAL_REX) + { + ASE_AWK_FREE (run->awk, ((ase_awk_val_rex_t*)val)->buf); + ase_awk_freerex (run->awk, ((ase_awk_val_rex_t*)val)->code); + ASE_AWK_FREE (run->awk, val); + } + else if (val->type == ASE_AWK_VAL_MAP) + { + ase_awk_map_close (((ase_awk_val_map_t*)val)->map); + ASE_AWK_FREE (run->awk, val); + } + else if (val->type == ASE_AWK_VAL_REF) + { + if (cache == ase_true && + run->fcache_count < ASE_COUNTOF(run->fcache)) + { + run->fcache[run->fcache_count++] = + (ase_awk_val_ref_t*)val; + } + else ASE_AWK_FREE (run->awk, val); + } + else + { + ASE_ASSERTX ( + !"should never happen - invalid value type", + "the type of a value should be one of ASE_AWK_VAL_XXX's defined in val.h"); + } +} + +void ase_awk_refupval (ase_awk_run_t* run, ase_awk_val_t* val) +{ + if (ase_awk_isbuiltinval(val)) return; + +#ifdef DEBUG_VAL + ase_dprintf (ASE_T("ref up [ptr=%p] [count=%d] "), val, (int)val->ref); + ase_awk_dprintval (run, val); + ase_dprintf (ASE_T("\n")); +#endif + + val->ref++; +} + +void ase_awk_refdownval (ase_awk_run_t* run, ase_awk_val_t* val) +{ + if (ase_awk_isbuiltinval(val)) return; + +#ifdef DEBUG_VAL + ase_dprintf (ASE_T("ref down [ptr=%p] [count=%d]\n"), val, (int)val->ref); + ase_awk_dprintval (run, val); + ase_dprintf (ASE_T("\n")); +#endif + + ASE_ASSERTX (val->ref > 0, + "the reference count of a value should be greater than zero for it to be decremented. check the source code for any bugs"); + + val->ref--; + if (val->ref <= 0) + { + ase_awk_freeval(run, val, ase_true); + } +} + +void ase_awk_refdownval_nofree (ase_awk_run_t* run, ase_awk_val_t* val) +{ + if (ase_awk_isbuiltinval(val)) return; + + ASE_ASSERTX (val->ref > 0, + "the reference count of a value should be greater than zero for it to be decremented. check the source code for any bugs"); + val->ref--; +} + +ase_bool_t ase_awk_valtobool (ase_awk_run_t* run, ase_awk_val_t* val) +{ + if (val == ASE_NULL) return ase_false; + + switch (val->type) + { + case ASE_AWK_VAL_NIL: + return ase_false; + case ASE_AWK_VAL_INT: + return ((ase_awk_val_int_t*)val)->val != 0; + case ASE_AWK_VAL_REAL: + return ((ase_awk_val_real_t*)val)->val != 0.0; + case ASE_AWK_VAL_STR: + return ((ase_awk_val_str_t*)val)->len > 0; + case ASE_AWK_VAL_REX: /* TODO: is this correct? */ + return ((ase_awk_val_rex_t*)val)->len > 0; + case ASE_AWK_VAL_MAP: + return ase_false; /* TODO: is this correct? */ + case ASE_AWK_VAL_REF: + return ase_false; /* TODO: is this correct? */ + } + + ASE_ASSERTX ( + !"should never happen - invalid value type", + "the type of a value should be one of ASE_AWK_VAL_XXX's defined in val.h"); + return ase_false; +} + +ase_char_t* ase_awk_valtostr ( + ase_awk_run_t* run, ase_awk_val_t* v, + int opt, ase_str_t* buf, ase_size_t* len) +{ + if (v->type == ASE_AWK_VAL_NIL) + { + return str_to_str (run, ASE_T(""), 0, opt, buf, len); + } + + if (v->type == ASE_AWK_VAL_INT) + { + ase_awk_val_int_t* vi = (ase_awk_val_int_t*)v; + + /* + if (vi->nde != ASE_NULL && vi->nde->str != ASE_NULL) + { + return str_to_str ( + run, vi->nde->str, vi->nde->len, + opt, buf, len); + } + else + { + */ + return val_int_to_str (run, vi, opt, buf, len); + /*}*/ + } + + if (v->type == ASE_AWK_VAL_REAL) + { + ase_awk_val_real_t* vr = (ase_awk_val_real_t*)v; + + /* + if (vr->nde != ASE_NULL && vr->nde->str != ASE_NULL) + { + return str_to_str ( + run, vr->nde->str, vr->nde->len, + opt, buf, len); + } + else + {*/ + return val_real_to_str (run, vr, opt, buf, len); + /*}*/ + } + + if (v->type == ASE_AWK_VAL_STR) + { + ase_awk_val_str_t* vs = (ase_awk_val_str_t*)v; + + return str_to_str ( + run, vs->buf, vs->len, opt, buf, len); + } + +#ifdef DEBUG_VAL + ase_dprintf ( + ASE_T("ERROR: WRONG VALUE TYPE [%d] in ase_awk_valtostr\n"), + v->type); +#endif + + ase_awk_setrunerror (run, ASE_AWK_EVALTYPE, 0, ASE_NULL, 0); + return ASE_NULL; +} + +static ase_char_t* str_to_str ( + ase_awk_run_t* run, const ase_char_t* str, ase_size_t str_len, + int opt, ase_str_t* buf, ase_size_t* len) +{ + if (buf == ASE_NULL) + { + ase_char_t* tmp; + tmp = ase_strxdup (str, str_len, &run->awk->prmfns.mmgr); + if (tmp == ASE_NULL) + { + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return ASE_NULL; + } + + if (len != ASE_NULL) *len = str_len; + return tmp; + } + else + { + ase_size_t n; + + if (opt & ASE_AWK_VALTOSTR_CLEAR) ase_str_clear (buf); + n = ase_str_ncat (buf, str, str_len); + if (n == (ase_size_t)-1) + { + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return ASE_NULL; + } + + if (len != ASE_NULL) *len = ASE_STR_LEN(buf); + return ASE_STR_BUF(buf); + } +} + +static ase_char_t* val_int_to_str ( + ase_awk_run_t* run, ase_awk_val_int_t* v, + int opt, ase_str_t* buf, ase_size_t* len) +{ + ase_char_t* tmp; + ase_long_t t; + ase_size_t l = 0; + + t = v->val; + if (t == 0) + { + /* handle zero */ + if (buf == ASE_NULL) + { + tmp = ASE_AWK_MALLOC ( + run->awk, 2 * ASE_SIZEOF(ase_char_t)); + if (tmp == ASE_NULL) + { + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return ASE_NULL; + } + + tmp[0] = ASE_T('0'); + tmp[1] = ASE_T('\0'); + if (len != ASE_NULL) *len = 1; + return tmp; + } + else + { + if (opt & ASE_AWK_VALTOSTR_CLEAR) ase_str_clear (buf); + if (ase_str_cat (buf, ASE_T("0")) == (ase_size_t)-1) + { + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return ASE_NULL; + } + + if (len != ASE_NULL) *len = ASE_STR_LEN(buf); + return ASE_STR_BUF(buf); + } + } + + /* non-zero values */ + if (t < 0) { t = -t; l++; } + while (t > 0) { l++; t /= 10; } + + if (buf == ASE_NULL) + { + tmp = ASE_AWK_MALLOC ( + run->awk, (l + 1) * ASE_SIZEOF(ase_char_t)); + if (tmp == ASE_NULL) + { + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return ASE_NULL; + } + + tmp[l] = ASE_T('\0'); + if (len != ASE_NULL) *len = l; + } + else + { + /* clear the buffer */ + if (opt & ASE_AWK_VALTOSTR_CLEAR) ase_str_clear (buf); + + tmp = ASE_STR_BUF(buf) + ASE_STR_LEN(buf); + + /* extend the buffer */ + if (ase_str_nccat ( + buf, ASE_T(' '), l) == (ase_size_t)-1) + { + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return ASE_NULL; + } + } + + t = v->val; + if (t < 0) t = -t; + + while (t > 0) + { + tmp[--l] = (ase_char_t)(t % 10) + ASE_T('0'); + t /= 10; + } + + if (v->val < 0) tmp[--l] = ASE_T('-'); + + if (buf != ASE_NULL) + { + tmp = ASE_STR_BUF(buf); + if (len != ASE_NULL) *len = ASE_STR_LEN(buf); + } + + return tmp; +} + +static ase_char_t* val_real_to_str ( + ase_awk_run_t* run, ase_awk_val_real_t* v, + int opt, ase_str_t* buf, ase_size_t* len) +{ + ase_char_t* tmp; + ase_size_t tmp_len; + ase_str_t out, fbu; + + if (opt & ASE_AWK_VALTOSTR_PRINT) + { + tmp = run->global.ofmt.ptr; + tmp_len = run->global.ofmt.len; + } + else + { + tmp = run->global.convfmt.ptr; + tmp_len = run->global.convfmt.len; + } + + if (ase_str_open (&out, 256, &run->awk->prmfns.mmgr) == ASE_NULL) + { + ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return ASE_NULL; + } + + if (ase_str_open (&fbu, 256, &run->awk->prmfns.mmgr) == ASE_NULL) + { + ase_str_close (&out); + ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return ASE_NULL; + } + + tmp = ase_awk_format (run, &out, &fbu, tmp, tmp_len, + (ase_size_t)-1, (ase_awk_nde_t*)v, &tmp_len); + if (tmp == ASE_NULL) + { + ase_str_close (&fbu); + ase_str_close (&out); + return ASE_NULL; + } + + if (buf == ASE_NULL) + { + ase_str_close (&fbu); + ase_str_forfeit (&out); + if (len != ASE_NULL) *len = tmp_len; + } + else + { + if (opt & ASE_AWK_VALTOSTR_CLEAR) ase_str_clear (buf); + + if (ase_str_ncat (buf, tmp, tmp_len) == (ase_size_t)-1) + { + ase_str_close (&fbu); + ase_str_close (&out); + ase_awk_setrunerror ( + run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0); + return ASE_NULL; + } + + tmp = ASE_STR_BUF(buf); + if (len != ASE_NULL) *len = ASE_STR_LEN(buf); + + ase_str_close (&fbu); + ase_str_close (&out); + } + + return tmp; +} + +int ase_awk_valtonum ( + ase_awk_run_t* run, ase_awk_val_t* v, ase_long_t* l, ase_real_t* r) +{ + if (v->type == ASE_AWK_VAL_NIL) + { + *l = 0; + return 0; + } + + if (v->type == ASE_AWK_VAL_INT) + { + *l = ((ase_awk_val_int_t*)v)->val; + return 0; /* long */ + } + + if (v->type == ASE_AWK_VAL_REAL) + { + *r = ((ase_awk_val_real_t*)v)->val; + return 1; /* real */ + } + + if (v->type == ASE_AWK_VAL_STR) + { + return ase_awk_strtonum (run, + ((ase_awk_val_str_t*)v)->buf, + ((ase_awk_val_str_t*)v)->len, l, r); + +#if 0 + const ase_char_t* endptr; + + *l = ase_awk_strxtolong (run->awk, + ((ase_awk_val_str_t*)v)->buf, + ((ase_awk_val_str_t*)v)->len, 0, &endptr); + if (*endptr == ASE_T('.') || + *endptr == ASE_T('E') || + *endptr == ASE_T('e')) + { + *r = ase_awk_strxtoreal (run->awk, + ((ase_awk_val_str_t*)v)->buf, + ((ase_awk_val_str_t*)v)->len, ASE_NULL); +/* TODO: need to check if it is a valid number using endptr for strxtoreal? */ + return 1; /* real */ + } +/* TODO: do should i handle strings ending with invalid number characters like "123xx" or "dkdkdkd"? */ + return 0; /* long */ +#endif + } + +#ifdef DEBUG_VAL + ase_dprintf ( + ASE_T("ERROR: WRONG VALUE TYPE [%d] in ase_awk_valtonum\n"), + v->type); +#endif + + ase_awk_setrunerror (run, ASE_AWK_EVALTYPE, 0, ASE_NULL, 0); + return -1; /* error */ +} + +int ase_awk_strtonum ( + ase_awk_run_t* run, const ase_char_t* ptr, ase_size_t len, + ase_long_t* l, ase_real_t* r) +{ + const ase_char_t* endptr; + + *l = ase_awk_strxtolong (run->awk, ptr, len, 0, &endptr); + if (*endptr == ASE_T('.') || + *endptr == ASE_T('E') || + *endptr == ASE_T('e')) + { + *r = ase_awk_strxtoreal (run->awk, ptr, len, ASE_NULL); +/* TODO: need to check if it is a valid number using endptr for strxtoreal? */ + return 1; /* real */ + } +/* TODO: do should i handle strings ending with invalid number characters like "123xx" or "dkdkdkd"? */ + return 0; /* long */ + +} + +#define DPRINTF run->awk->prmfns.misc.dprintf +#define DCUSTOM run->awk->prmfns.misc.custom_data + +static int print_pair (ase_awk_pair_t* pair, void* arg) +{ + ase_awk_run_t* run = (ase_awk_run_t*)arg; + + DPRINTF (DCUSTOM, ASE_T(" %s=>"), pair->key); + ase_awk_dprintval ((ase_awk_run_t*)arg, pair->val); + DPRINTF (DCUSTOM, ASE_T(" ")); + return 0; +} + +void ase_awk_dprintval (ase_awk_run_t* run, ase_awk_val_t* val) +{ + /* TODO: better value printing ... */ + + switch (val->type) + { + case ASE_AWK_VAL_NIL: + DPRINTF (DCUSTOM, ASE_T("nil")); + break; + + case ASE_AWK_VAL_INT: + #if ASE_SIZEOF_LONG_LONG > 0 + DPRINTF (DCUSTOM, ASE_T("%lld"), + (long long)((ase_awk_val_int_t*)val)->val); + #elif ASE_SIZEOF___INT64 > 0 + DPRINTF (DCUSTOM, ASE_T("%I64d"), + (__int64)((ase_awk_val_int_t*)val)->val); + #elif ASE_SIZEOF_LONG > 0 + DPRINTF (DCUSTOM, ASE_T("%ld"), + (long)((ase_awk_val_int_t*)val)->val); + #elif ASE_SIZEOF_INT > 0 + DPRINTF (DCUSTOM, ASE_T("%d"), + (int)((ase_awk_val_int_t*)val)->val); + #else + #error unsupported size + #endif + break; + + case ASE_AWK_VAL_REAL: + DPRINTF (DCUSTOM, ASE_T("%Lf"), + (long double)((ase_awk_val_real_t*)val)->val); + break; + + case ASE_AWK_VAL_STR: + DPRINTF (DCUSTOM, ASE_T("%s"), ((ase_awk_val_str_t*)val)->buf); + break; + + case ASE_AWK_VAL_REX: + DPRINTF (DCUSTOM, ASE_T("REX[%s]"), ((ase_awk_val_rex_t*)val)->buf); + break; + + case ASE_AWK_VAL_MAP: + DPRINTF (DCUSTOM, ASE_T("MAP[")); + ase_awk_map_walk (((ase_awk_val_map_t*)val)->map, print_pair, run); + DPRINTF (DCUSTOM, ASE_T("]")); + break; + + case ASE_AWK_VAL_REF: + DPRINTF (DCUSTOM, ASE_T("REF[id=%d,val="), ((ase_awk_val_ref_t*)val)->id); + ase_awk_dprintval (run, *((ase_awk_val_ref_t*)val)->adr); + DPRINTF (DCUSTOM, ASE_T("]")); + break; + + default: + DPRINTF (DCUSTOM, ASE_T("**** INTERNAL ERROR - INVALID VALUE TYPE ****\n")); + } +} diff --git a/ase/awk/val.h b/ase/awk/val.h new file mode 100644 index 00000000..1ee8693f --- /dev/null +++ b/ase/awk/val.h @@ -0,0 +1,206 @@ +/* + * $Id: val.h,v 1.3 2007/04/30 05:48:37 bacon Exp $ + * + * {License} + */ + +#ifndef _ASE_AWK_VAL_H_ +#define _ASE_AWK_VAL_H_ + +#ifndef _ASE_AWK_AWK_H_ +#error Include first +#endif + +#include +#include + +enum ase_awk_val_type_t +{ + /* the values between ASE_AWK_VAL_NIL and ASE_AWK_VAL_STR inclusive + * must be synchronized with an internal table of the __cmp_val + * function in run.c */ + ASE_AWK_VAL_NIL = 0, + ASE_AWK_VAL_INT = 1, + ASE_AWK_VAL_REAL = 2, + ASE_AWK_VAL_STR = 3, + + ASE_AWK_VAL_REX = 4, + ASE_AWK_VAL_MAP = 5, + ASE_AWK_VAL_REF = 6 +}; + +enum ase_awk_val_ref_id_t +{ + /* keep these items in the same order as corresponding items + * in tree.h */ + ASE_AWK_VAL_REF_NAMED, + ASE_AWK_VAL_REF_GLOBAL, + ASE_AWK_VAL_REF_LOCAL, + ASE_AWK_VAL_REF_ARG, + ASE_AWK_VAL_REF_NAMEDIDX, + ASE_AWK_VAL_REF_GLOBALIDX, + ASE_AWK_VAL_REF_LOCALIDX, + ASE_AWK_VAL_REF_ARGIDX, + ASE_AWK_VAL_REF_POS +}; + +enum ase_awk_valtostr_opt_t +{ + ASE_AWK_VALTOSTR_CLEAR = (1 << 0), + ASE_AWK_VALTOSTR_PRINT = (1 << 1) +}; + +typedef struct ase_awk_val_nil_t ase_awk_val_nil_t; +typedef struct ase_awk_val_int_t ase_awk_val_int_t; +typedef struct ase_awk_val_real_t ase_awk_val_real_t; +typedef struct ase_awk_val_str_t ase_awk_val_str_t; +typedef struct ase_awk_val_rex_t ase_awk_val_rex_t; +typedef struct ase_awk_val_map_t ase_awk_val_map_t; +typedef struct ase_awk_val_ref_t ase_awk_val_ref_t; + +#if ASE_SIZEOF_INT == 2 +#define ASE_AWK_VAL_HDR \ + unsigned int type: 3; \ + unsigned int ref: 13 +#else +#define ASE_AWK_VAL_HDR \ + unsigned int type: 3; \ + unsigned int ref: 29 +#endif + +#ifndef ASE_AWK_NDE_INT_DEFINED +#define ASE_AWK_NDE_INT_DEFINED +typedef struct ase_awk_nde_int_t ase_awk_nde_int_t; +#endif + +#ifndef ASE_AWK_NDE_REAL_DEFINED +#define ASE_AWK_NDE_REAL_DEFINED +typedef struct ase_awk_nde_real_t ase_awk_nde_real_t; +#endif + + +struct ase_awk_val_t +{ + ASE_AWK_VAL_HDR; +}; + +/* ASE_AWK_VAL_NIL */ +struct ase_awk_val_nil_t +{ + ASE_AWK_VAL_HDR; +}; + +/* ASE_AWK_VAL_INT */ +struct ase_awk_val_int_t +{ + ASE_AWK_VAL_HDR; + ase_long_t val; + ase_awk_nde_int_t* nde; +}; + +/* ASE_AWK_VAL_REAL */ +struct ase_awk_val_real_t +{ + ASE_AWK_VAL_HDR; + ase_real_t val; + ase_awk_nde_real_t* nde; +}; + +/* ASE_AWK_VAL_STR */ +struct ase_awk_val_str_t +{ + ASE_AWK_VAL_HDR; + ase_char_t* buf; + ase_size_t len; +}; + +/* ASE_AWK_VAL_REX */ +struct ase_awk_val_rex_t +{ + ASE_AWK_VAL_HDR; + ase_char_t* buf; + ase_size_t len; + void* code; +}; + +/* ASE_AWK_VAL_MAP */ +struct ase_awk_val_map_t +{ + ASE_AWK_VAL_HDR; + + /* TODO: make val_map to array if the indices used are all + * integers switch to map dynamically once the + * non-integral index is seen. + */ + ase_awk_map_t* map; +}; + +/* ASE_AWK_VAL_REF */ +struct ase_awk_val_ref_t +{ + ASE_AWK_VAL_HDR; + + int id; + /* if id is ASE_AWK_VAL_REF_POS, adr holds an index of the + * positional variable. Otherwise, adr points to the value + * directly. */ + ase_awk_val_t** adr; +}; + +#ifdef __cplusplus +extern "C" { +#endif + +extern ase_awk_val_t* ase_awk_val_nil; +extern ase_awk_val_t* ase_awk_val_zls; +extern ase_awk_val_t* ase_awk_val_negone; +extern ase_awk_val_t* ase_awk_val_zero; +extern ase_awk_val_t* ase_awk_val_one; + +ase_awk_val_t* ase_awk_makeintval (ase_awk_run_t* run, ase_long_t v); +ase_awk_val_t* ase_awk_makerealval (ase_awk_run_t* run, ase_real_t v); + +ase_awk_val_t* ase_awk_makestrval0 ( + ase_awk_run_t* run, const ase_char_t* str); +ase_awk_val_t* ase_awk_makestrval ( + ase_awk_run_t* run, const ase_char_t* str, ase_size_t len); +ase_awk_val_t* ase_awk_makestrval_nodup ( + ase_awk_run_t* run, ase_char_t* str, ase_size_t len); +ase_awk_val_t* ase_awk_makestrval2 ( + ase_awk_run_t* run, + const ase_char_t* str1, ase_size_t len1, + const ase_char_t* str2, ase_size_t len2); + +ase_awk_val_t* ase_awk_makerexval ( + ase_awk_run_t* run, const ase_char_t* buf, ase_size_t len, void* code); +ase_awk_val_t* ase_awk_makemapval (ase_awk_run_t* run); +ase_awk_val_t* ase_awk_makerefval ( + ase_awk_run_t* run, int id, ase_awk_val_t** adr); + +ase_bool_t ase_awk_isbuiltinval (ase_awk_val_t* val); + +void ase_awk_freeval (ase_awk_run_t* run, ase_awk_val_t* val, ase_bool_t cache); +void ase_awk_refupval (ase_awk_run_t* run, ase_awk_val_t* val); +void ase_awk_refdownval (ase_awk_run_t* run, ase_awk_val_t* val); +void ase_awk_refdownval_nofree (ase_awk_run_t* run, ase_awk_val_t* val); + +ase_bool_t ase_awk_valtobool ( + ase_awk_run_t* run, ase_awk_val_t* val); + +ase_char_t* ase_awk_valtostr ( + ase_awk_run_t* run, ase_awk_val_t* val, + int opt, ase_str_t* buf, ase_size_t* len); + +int ase_awk_valtonum ( + ase_awk_run_t* run, ase_awk_val_t* v, ase_long_t* l, ase_real_t* r); +int ase_awk_strtonum ( + ase_awk_run_t* run, const ase_char_t* ptr, ase_size_t len, + ase_long_t* l, ase_real_t* r); + +void ase_awk_dprintval (ase_awk_run_t* run, ase_awk_val_t* val); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ase/build.xml b/ase/build.xml new file mode 100644 index 00000000..0d94f248 --- /dev/null +++ b/ase/build.xml @@ -0,0 +1,73 @@ + + + + + + ANT build script for ASE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ase/cmn/asecmn.dsp b/ase/cmn/asecmn.dsp new file mode 100644 index 00000000..a39dd245 --- /dev/null +++ b/ase/cmn/asecmn.dsp @@ -0,0 +1,124 @@ +# Microsoft Developer Studio Project File - Name="asecmn" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=asecmn - Win32 Release +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "asecmn.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "asecmn.mak" CFG="asecmn - Win32 Release" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "asecmn - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "asecmn - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "asecmn - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "../release/lib" +# PROP Intermediate_Dir "release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +MTL=midl.exe +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "_USRDLL" /Yu"stdafx.h" /FD /c +# ADD CPP /nologo /MT /Za /W3 /GX /O2 /I "../.." /D "NDEBUG" /D "WIN32" /D "_UNICODE" /FD /c +# SUBTRACT CPP /YX /Yc /Yu +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo + +!ELSEIF "$(CFG)" == "asecmn - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "../debug/lib" +# PROP Intermediate_Dir "debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +MTL=midl.exe +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_UNICODE" /D "_USRDLL" /Yu"stdafx.h" /FD /GZ /c +# ADD CPP /nologo /MTd /Za /W3 /Gm /GX /ZI /Od /I "../.." /D "_DEBUG" /D "WIN32" /D "_UNICODE" /FD /GZ /c +# SUBTRACT CPP /YX /Yc /Yu +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo + +!ENDIF + +# Begin Target + +# Name "asecmn - Win32 Release" +# Name "asecmn - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\mem.c +# End Source File +# Begin Source File + +SOURCE=.\misc.c +# End Source File +# Begin Source File + +SOURCE=.\str.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\mem.h +# End Source File +# Begin Source File + +SOURCE=.\str.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/ase/cmn/asecmn.vcproj b/ase/cmn/asecmn.vcproj new file mode 100644 index 00000000..9bb4ed41 --- /dev/null +++ b/ase/cmn/asecmn.vcproj @@ -0,0 +1,263 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ase/cmn/conf_msw.h b/ase/cmn/conf_msw.h new file mode 100644 index 00000000..6347a072 --- /dev/null +++ b/ase/cmn/conf_msw.h @@ -0,0 +1,64 @@ +/* + * $Id: conf_msw.h,v 1.3 2007/04/30 05:55:36 bacon Exp $ + * + * {License} + */ + +/* +Macro Meaning +_WIN64 A 64-bit platform. +_WIN32 A 32-bit platform. This value is also defined by the 64-bit + compiler for backward compatibility. +_WIN16 A 16-bit platform + +The following macros are specific to the architecture. + +Macro Meaning +_M_IA64 Intel Itanium Processor Family +_M_IX86 x86 platform +_M_X64 x64 platform +*/ + +#define ASE_ENDIAN_LITTLE + +#define ASE_SIZEOF_CHAR 1 +#define ASE_SIZEOF_SHORT 2 +#define ASE_SIZEOF_INT 4 + +/*#ifdef _WIN64 + #define ASE_SIZEOF_LONG 8 +#else*/ + #define ASE_SIZEOF_LONG 4 +/*#endif*/ + +#ifdef __POCC__ + /* pelles c with no microsoft extension */ + #define ASE_SIZEOF_LONG_LONG 8 + + #define ASE_SIZEOF___INT8 0 + #define ASE_SIZEOF___INT16 0 + #define ASE_SIZEOF___INT32 0 + #define ASE_SIZEOF___INT64 0 + #define ASE_SIZEOF___INT96 0 + #define ASE_SIZEOF___INT128 0 +#else + #define ASE_SIZEOF_LONG_LONG 0 + + #define ASE_SIZEOF___INT8 1 + #define ASE_SIZEOF___INT16 2 + #define ASE_SIZEOF___INT32 4 + #define ASE_SIZEOF___INT64 8 + #define ASE_SIZEOF___INT96 0 + #define ASE_SIZEOF___INT128 0 +#endif + +#ifdef _WIN64 + #define ASE_SIZEOF_VOID_P 8 +#else + #define ASE_SIZEOF_VOID_P 4 +#endif + +#define ASE_SIZEOF_FLOAT 4 +#define ASE_SIZEOF_DOUBLE 8 +#define ASE_SIZEOF_LONG_DOUBLE 16 +#define ASE_SIZEOF_WCHAR_T 2 diff --git a/ase/cmn/conf_unx.h.in b/ase/cmn/conf_unx.h.in new file mode 100644 index 00000000..5bc9adb8 --- /dev/null +++ b/ase/cmn/conf_unx.h.in @@ -0,0 +1,44 @@ +/* + * $Id: conf_unx.h.in,v 1.3 2007/04/30 05:55:36 bacon Exp $ + * + * {License} + */ + +/* Big Endian */ +#undef ASE_ENDIAN_BIG + +/* Little Endian */ +#undef ASE_ENDIAN_LITTLE + +/* Unknown Endian */ +#undef ASE_ENDIAN_UNKNOWN + +/* long long */ +#undef ASE_HAVE_LONG_LONG + +/* long double */ +#undef ASE_HAVE_LONG_DOUBLE + +/* data type size */ +#define ASE_SIZEOF_CHAR 0 +#define ASE_SIZEOF_SHORT 0 +#define ASE_SIZEOF_INT 0 +#define ASE_SIZEOF_LONG 0 +#define ASE_SIZEOF_LONG_LONG 0 +#define ASE_SIZEOF___INT8 0 +#define ASE_SIZEOF___INT16 0 +#define ASE_SIZEOF___INT32 0 +#define ASE_SIZEOF___INT64 0 +#define ASE_SIZEOF___INT128 0 +#define ASE_SIZEOF_VOID_P 0 +#define ASE_SIZEOF_FLOAT 0 +#define ASE_SIZEOF_DOUBLE 0 +#define ASE_SIZEOF_LONG_DOUBLE 0 +#define ASE_SIZEOF_WCHAR_T 0 + +/* char is wchar */ +#undef ASE_CHAR_IS_WCHAR + +/* char is mchar */ +#undef ASE_CHAR_IS_MCHAR + diff --git a/ase/cmn/conf_vms.h b/ase/cmn/conf_vms.h new file mode 100644 index 00000000..02c0f40d --- /dev/null +++ b/ase/cmn/conf_vms.h @@ -0,0 +1,90 @@ +/* + * $Id: conf_vms.h,v 1.3 2007/04/30 05:55:36 bacon Exp $ + * + * {License} + */ + +/* all of vax, alpha, ia64 are in the little endian. */ +#define ASE_ENDIAN_LITTLE + +/* + * Refer to the chapter 3 of the following URL for the data sizes. + * http://h71000.www7.hp.com/commercial/c/docs/6180profile.html + */ + +#define ASE_SIZEOF_CHAR 1 +#define ASE_SIZEOF_SHORT 2 +#define ASE_SIZEOF_INT 4 +#define ASE_SIZEOF_LONG 4 + +#if defined(vax) || defined(__vax) + #define ASE_SIZEOF_LONG_LONG 0 +#elif defined(alpha) || defined(__alpha) + #define ASE_SIZEOF_LONG_LONG 8 +#elif defined(ia64) || defined(__ia64) + #define ASE_SIZEOF_LONG_LONG 8 +#else + #define ASE_SIZEOF_LONG_LONG 0 +#endif + +#define ASE_SIZEOF___INT8 1 +#define ASE_SIZEOF___INT16 2 +#define ASE_SIZEOF___INT32 4 + +#if defined(vax) || defined(__vax) + #define ASE_SIZEOF___INT64 0 +#elif defined(alpha) || defined(__alpha) + #define ASE_SIZEOF___INT64 8 +#elif defined(ia64) || defined(__ia64) + #define ASE_SIZEOF___INT64 8 +#else + #define ASE_SIZEOF___INT64 0 +#endif + +#define ASE_SIZEOF___INT96 0 +#define ASE_SIZEOF___INT128 0 + +#if defined(vax) || defined(__vax) + #define ASE_SIZEOF_VOID_P 4 +#elif defined(alpha) || defined(__alpha) + #if __INITIAL_POINTER_SIZE==64 + #pragma pointer_size 64 + #define ASE_SIZEOF_VOID_P 8 + #elif __INITIAL_POINTER_SIZE==32 + #pragma pointer_size 32 + #define ASE_SIZEOF_VOID_P 4 + #elif __INITIAL_POINTER_SIZE==0 + #define ASE_SIZEOF_VOID_P 4 + #else + #error "unsupported initial pointer size" + #endif +#elif defined(ia64) || defined(__ia64) + #if __INITIAL_POINTER_SIZE==64 + #pragma pointer_size 64 + #define ASE_SIZEOF_VOID_P 8 + #elif __INITIAL_POINTER_SIZE==32 + #pragma pointer_size 32 + #define ASE_SIZEOF_VOID_P 4 + #elif __INITIAL_POINTER_SIZE==0 + #define ASE_SIZEOF_VOID_P 4 + #else + #error "unsupported initial pointer size" + #endif +#else + #error "unsupported architecture" +#endif + +#define ASE_SIZEOF_FLOAT 4 +#define ASE_SIZEOF_DOUBLE 8 + +#if defined(vax) || defined(__vax) + #define ASE_SIZEOF_LONG_DOUBLE 8 +#elif defined(alpha) || defined(__alpha) + #define ASE_SIZEOF_LONG_DOUBLE 16 +#elif defined(ia64) || defined(__ia64) + #define ASE_SIZEOF_LONG_DOUBLE 16 +#else + #define ASE_SIZEOF_LONG_DOUBLE 0 +#endif + +#define ASE_SIZEOF_WCHAR_T 4 diff --git a/ase/cmn/descrip.mms b/ase/cmn/descrip.mms new file mode 100644 index 00000000..09fd3271 --- /dev/null +++ b/ase/cmn/descrip.mms @@ -0,0 +1,17 @@ +# +# OpenVMS MMS/MMK +# + +objects = mem.obj,str.obj,misc.obj + +CFLAGS = /include="../.." +#CFLAGS = /pointer_size=long /include="../.." +LIBRFLAGS = + +asecmn.olb : $(objects) + $(LIBR)/create $(MMS$TARGET) $(objects) +# $(LIBR)/replace $(LIBRFLAGS) $(MMS$TARGET),$(objects) + +mem.obj depends_on mem.c +str.obj depends_on str.c +misc.obj depends_on misc.c diff --git a/ase/cmn/macros.h b/ase/cmn/macros.h new file mode 100644 index 00000000..113e7efc --- /dev/null +++ b/ase/cmn/macros.h @@ -0,0 +1,139 @@ +/* + * $Id: macros.h,v 1.3 2007/04/30 05:55:36 bacon Exp $ + * + * {License} + */ + +#ifndef _ASE_MACROS_H_ +#define _ASE_MACROS_H_ + +#include + +#ifdef __cplusplus + /*#define ASE_NULL ((ase_uint_t)0)*/ + #define ASE_NULL (0) +#else + #define ASE_NULL ((void*)0) +#endif + +#define ASE_CHAR_EOF ((ase_cint_t)-1) + +#define ASE_SIZEOF(n) (sizeof(n)) +#define ASE_COUNTOF(n) (sizeof(n)/sizeof(n[0])) +#define ASE_OFFSETOF(type,member) ((ase_size_t)&((type*)0)->member) + +#define ASE_TYPE_IS_SIGNED(type) (((type)0) > ((type)-1)) +#define ASE_TYPE_IS_UNSIGNED(type) (((type)0) < ((type)-1)) + +#define ASE_TYPE_SIGNED_MAX(type) \ + ((type)~((type)1 << (ASE_SIZEOF(type) * 8 - 1))) +#define ASE_TYPE_UNSIGNED_MAX(type) ((type)(~(type)0)) + +#define ASE_TYPE_SIGNED_MIN(type) \ + ((type)((type)1 << (ASE_SIZEOF(type) * 8 - 1))) +#define ASE_TYPE_UNSIGNED_MIN(type) ((type)0) + +#define ASE_TYPE_MAX(type) \ + ((ASE_TYPE_IS_SIGNED(type)? ASE_TYPE_SIGNED_MAX(type): ASE_TYPE_UNSIGNED_MAX(type))) +#define ASE_TYPE_MIN(type) \ + ((ASE_TYPE_IS_SIGNED(type)? ASE_TYPE_SIGNED_MIN(type): ASE_TYPE_UNSIGNED_MIN(type))) + +#define ASE_IS_POWOF2(x) (((x) & ((x) - 1)) == 0) + +#define ASE_SWAP(x,y,original_type,casting_type) \ + do { \ + x = (original_type)((casting_type)(x) ^ (casting_type)(y)); \ + y = (original_type)((casting_type)(y) ^ (casting_type)(x)); \ + x = (original_type)((casting_type)(x) ^ (casting_type)(y)); \ + } while (0) + +#define ASE_ABS(x) ((x) < 0? -(x): (x)) + +#define ASE_LOOP_CONTINUE(id) goto __loop_ ## id ## _begin__; +#define ASE_LOOP_BREAK(id) goto __loop_ ## id ## _end__; +#define ASE_LOOP_BEGIN(id) __loop_ ## id ## _begin__: { +#define ASE_LOOP_END(id) ASE_LOOP_CONTINUE(id) } __loop_ ## id ## _end__:; + +#define ASE_REPEAT(n,blk) \ + do { \ + ase_size_t __ase_repeat_x1__ = (ase_size_t)(n); \ + ase_size_t __ase_repeat_x2__ = __ase_repeat_x1__ >> 4; \ + __ase_repeat_x1__ &= 15; \ + while (__ase_repeat_x1__-- > 0) { blk; } \ + while (__ase_repeat_x2__-- > 0) { \ + blk; blk; blk; blk; blk; blk; blk; blk; \ + blk; blk; blk; blk; blk; blk; blk; blk; \ + } \ + } while (0); + +#define ASE_MQ_I(val) #val +#define ASE_MQ(val) ASE_MQ_I(val) +#define ASE_MC(ch) ((ase_mchar_t)ch) +#define ASE_MS(str) ((const ase_mchar_t*)str) +#define ASE_MT(txt) (txt) + +#define ASE_WQ_I(val) (L ## #val) +#define ASE_WQ(val) ASE_WQ_I(val) +#define ASE_WC(ch) ((ase_wchar_t)L ## ch) +#define ASE_WS(str) ((const ase_wchar_t*)L ## str) +#define ASE_WT(txt) (L ## txt) + +#if defined(ASE_CHAR_IS_MCHAR) + #define ASE_C(ch) ASE_MC(ch) + #define ASE_S(str) ASE_MS(str) + #define ASE_T(txt) ASE_MT(txt) +#else + #define ASE_C(ch) ASE_WC(ch) + #define ASE_S(str) ASE_WS(str) + #define ASE_T(txt) ASE_WT(txt) +#endif + +#if defined(__GNUC__) + #define ASE_BEGIN_PACKED_STRUCT(x) struct x { + #define ASE_END_PACKED_STRUCT() } __attribute__((packed)); +#else + #define ASE_BEGIN_PACKED_STRUCT(x) struct x { + #define ASE_END_PACKED_STRUCT() }; +#endif + +#ifdef NDEBUG + #define ASE_ASSERT(expr) ((void)0) + #define ASE_ASSERTX(expr,desc) ((void)0) +#else + #ifdef __cplusplus + extern "C" { + #endif + void ase_assert_abort (void); + void ase_assert_printf (const ase_char_t* fmt, ...); + int ase_assert_failed ( + const ase_char_t* expr, const ase_char_t* desc, + const ase_char_t* file, ase_size_t line); + #ifdef __cplusplus + } + #endif + + #define ASE_ASSERT(expr) (void)((expr) || \ + (ase_assert_failed (ASE_T(#expr), ASE_NULL, ASE_T(__FILE__), __LINE__), 0)) + #define ASE_ASSERTX(expr,desc) (void)((expr) || \ + (ase_assert_failed (ASE_T(#expr), ASE_T(desc), ASE_T(__FILE__), __LINE__), 0)) +#endif + +#define ASE_MALLOC(mmgr,size) (mmgr)->malloc((mmgr)->custom_data, size) +#define ASE_REALLOC(mmgr,ptr,size) (mmgr)->realloc((mmgr)->custom_data, ptr, size) +#define ASE_FREE(mmgr,ptr) (mmgr)->free((mmgr)->custom_data, ptr) + +#define ASE_ISUPPER(ccls,c) (ccls)->is_upper((ccls)->custom_data,c) +#define ASE_ISLOWER(ccls,c) (ccls)->is_lower((ccls)->custom_data,c) +#define ASE_ISALPHA(ccls,c) (ccls)->is_alpha((ccls)->custom_data,c) +#define ASE_ISDIGIT(ccls,c) (ccls)->is_digit((ccls)->custom_data,c) +#define ASE_ISXDIGIT(ccls,c) (ccls)->is_xdigit((ccls)->custom_data,c) +#define ASE_ISALNUM(ccls,c) (ccls)->is_alnum((ccls)->custom_data,c) +#define ASE_ISSPACE(ccls,c) (ccls)->is_space((ccls)->custom_data,c) +#define ASE_ISPRINT(ccls,c) (ccls)->is_print((ccls)->custom_data,c) +#define ASE_ISGRAPH(ccls,c) (ccls)->is_graph((ccls)->custom_data,c) +#define ASE_ISCNTRL(ccls,c) (ccls)->is_cntrl((ccls)->custom_data,c) +#define ASE_ISPUNCT(ccls,c) (ccls)->is_punct((ccls)->custom_data,c) +#define ASE_TOUPPER(ccls,c) (ccls)->to_upper((ccls)->custom_data,c) +#define ASE_TOLOWER(ccls,c) (ccls)->to_lower((ccls)->custom_data,c) + +#endif diff --git a/ase/cmn/makefile.in b/ase/cmn/makefile.in new file mode 100644 index 00000000..fde161b4 --- /dev/null +++ b/ase/cmn/makefile.in @@ -0,0 +1,49 @@ +# +# $Id: makefile.in,v 1.3 2007/04/30 05:55:36 bacon Exp $ +# + +NAME = asecmn + +CC = @CC@ +AR = ar +MAKE = @MAKE@ +RANLIB = @RANLIB@ +CFLAGS = @CFLAGS@ -I@abs_top_builddir@/.. +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ +MODE = @BUILDMODE@ + +OUT_DIR = ../$(MODE)/lib +OUT_FILE = $(OUT_DIR)/lib$(NAME).a + +TMP_DIR = $(MODE) + +OBJ_FILES = \ + $(TMP_DIR)/mem.o \ + $(TMP_DIR)/str.o \ + $(TMP_DIR)/misc.o + +lib: $(OUT_FILE) + +$(OUT_FILE): $(TMP_DIR) $(OBJ_FILES) $(OUT_DIR) + $(AR) cr $(OUT_FILE) $(OBJ_FILES) + if [ "$(RANLIB)" = "ranlib" ]; then ranlib $(OUT_FILE); fi + +$(TMP_DIR)/mem.o: mem.c + $(CC) $(CFLAGS) -o $@ -c mem.c + +$(TMP_DIR)/str.o: str.c + $(CC) $(CFLAGS) -o $@ -c str.c + +$(TMP_DIR)/misc.o: misc.c + $(CC) $(CFLAGS) -o $@ -c misc.c + +$(OUT_DIR): + mkdir -p $(OUT_DIR) + +$(TMP_DIR): + mkdir -p $(TMP_DIR) + +clean: + rm -rf $(OUT_FILE) $(OBJ_FILES) + diff --git a/ase/cmn/makefile.msw.bcc b/ase/cmn/makefile.msw.bcc new file mode 100644 index 00000000..8aee0bbb --- /dev/null +++ b/ase/cmn/makefile.msw.bcc @@ -0,0 +1,29 @@ +OUT = asecmn + +C_SRCS = mem.c str.c misc.c +C_OBJS = $(C_SRCS:.c=.obj) + +CC = bcc32 +LD = ilink32 +AR = tlib +JAVAC = javac + +CFLAGS = -O2 -WM -WU -RT- -w -q -I../.. -DNDEBUG +LDFLAGS = -Tpd -ap -Gn -c -q +STARTUP = c0d32w.obj +LIBS = import32.lib cw32mt.lib + +all: lib + +lib: $(C_OBJS) + $(AR) $(OUT).lib @&&! ++-$(**: = &^ ++-) +! + +clean: + -del $(OBJS) $(OUT).lib *.obj + +.SUFFIXES: .c .obj +.c.obj: + $(CC) $(CFLAGS) -c $< diff --git a/ase/cmn/makefile.msw.cl b/ase/cmn/makefile.msw.cl new file mode 100644 index 00000000..d211a011 --- /dev/null +++ b/ase/cmn/makefile.msw.cl @@ -0,0 +1,23 @@ +OUT = asecmn + +C_SRCS = mem.c str.c misc.c +C_OBJS = $(C_SRCS:.c=.obj) + +CC = cl +LD = link + +CFLAGS = /nologo /O2 /MT /W3 /GR- /GS- /Za -I../.. + +all: lib + +lib: $(C_OBJS) + $(LD) /lib @<< +/nologo /out:$(OUT).lib $(C_OBJS) +<< + +clean: + del $(OBJS) $(OUT).lib *.obj + +.SUFFIXES: .c .obj +.c.obj: + $(CC) $(CFLAGS) /c $< diff --git a/ase/cmn/mem.c b/ase/cmn/mem.c new file mode 100644 index 00000000..bdc02157 --- /dev/null +++ b/ase/cmn/mem.c @@ -0,0 +1,52 @@ +/* + * $Id: mem.c,v 1.3 2007/04/30 05:55:36 bacon Exp $ + * + * {License} + */ + +#include + +void* ase_memcpy (void* dst, const void* src, ase_size_t n) +{ + void* p = dst; + void* e = (ase_byte_t*)dst + n; + + while (dst < e) + { + *(ase_byte_t*)dst = *(ase_byte_t*)src; + dst = (ase_byte_t*)dst + 1; + src = (ase_byte_t*)src + 1; + } + + return p; +} + +void* ase_memset (void* dst, int val, ase_size_t n) +{ + void* p = dst; + void* e = (ase_byte_t*)p + n; + + while (p < e) + { + *(ase_byte_t*)p = (ase_byte_t)val; + p = (ase_byte_t*)p + 1; + } + + return dst; +} + +int ase_memcmp (const void* s1, const void* s2, ase_size_t n) +{ + const void* e; + + if (n == 0) return 0; + + e = (const ase_byte_t*)s1 + n - 1; + while (s1 < e && *(ase_byte_t*)s1 == *(ase_byte_t*)s2) + { + s1 = (ase_byte_t*)s1 + 1; + s2 = (ase_byte_t*)s2 + 1; + } + + return *((ase_byte_t*)s1) - *((ase_byte_t*)s2); +} diff --git a/ase/cmn/mem.h b/ase/cmn/mem.h new file mode 100644 index 00000000..f4a5f15c --- /dev/null +++ b/ase/cmn/mem.h @@ -0,0 +1,25 @@ +/* + * $Id: mem.h,v 1.3 2007/04/30 05:55:36 bacon Exp $ + * + * {License} + */ + +#ifndef _ASE_CMN_MEM_H_ +#define _ASE_CMN_MEM_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +void* ase_memcpy (void* dst, const void* src, ase_size_t n); +void* ase_memset (void* dst, int val, ase_size_t n); +int ase_memcmp (const void* s1, const void* s2, ase_size_t n); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ase/cmn/misc.c b/ase/cmn/misc.c new file mode 100644 index 00000000..f2ab1445 --- /dev/null +++ b/ase/cmn/misc.c @@ -0,0 +1,34 @@ +/* + * $Id: misc.c,v 1.3 2007/04/30 05:55:36 bacon Exp $ + * + * {License} + */ + +#include +#include + +#ifndef NDEBUG +int ase_assert_failed ( + const ase_char_t* expr, const ase_char_t* desc, + const ase_char_t* file, ase_size_t line) +{ + if (desc == ASE_NULL) + { + ase_assert_printf ( + ASE_T("ASSERTION FAILURE AT FILE %s LINE %lu\n%s\n"), + file, (unsigned long)line, expr); + } + else + { + ase_assert_printf ( + ASE_T("ASSERTION FAILURE AT FILE %s LINE %lu\n%s\n\nDESCRIPTION:\n%s\n"), + file, (unsigned long)line, expr, desc); + + } + + ase_assert_abort (); + return 0; +} + +#endif + diff --git a/ase/cmn/pack.h b/ase/cmn/pack.h new file mode 100644 index 00000000..2e7c0fb2 --- /dev/null +++ b/ase/cmn/pack.h @@ -0,0 +1,17 @@ +/* + * $Id: pack.h,v 1.3 2007/04/30 05:55:36 bacon Exp $ + * + * {License} + */ + +#if defined(__GNUC__) + #pragma pack(1) +#elif defined(__HP_aCC) || defined(__HP_cc) + #pragma PACK 1 +#elif defined(_MSC_VER) || defined(__BORLANDC__) + #pragma pack(push,1) +#elif defined(__DECC) + #pragma pack(push,1) +#else + #pragma pack(1) +#endif diff --git a/ase/cmn/str.c b/ase/cmn/str.c new file mode 100644 index 00000000..801656a4 --- /dev/null +++ b/ase/cmn/str.c @@ -0,0 +1,385 @@ +/* + * $Id: str.c,v 1.3 2007/04/30 05:55:36 bacon Exp $ + * + * {License} + */ + +#include +#include + +ase_size_t ase_strlen (const ase_char_t* str) +{ + const ase_char_t* p = str; + while (*p != ASE_T('\0')) p++; + return p - str; +} + +ase_size_t ase_strcpy (ase_char_t* buf, const ase_char_t* str) +{ + ase_char_t* org = buf; + while ((*buf++ = *str++) != ASE_T('\0')); + return buf - org - 1; +} + +ase_size_t ase_strxcpy ( + ase_char_t* buf, ase_size_t bsz, const ase_char_t* str) +{ + ase_char_t* p, * p2; + + p = buf; p2 = buf + bsz - 1; + + while (p < p2) + { + if (*str == ASE_T('\0')) break; + *p++ = *str++; + } + + if (bsz > 0) *p = ASE_T('\0'); + return p - buf; +} + +ase_size_t ase_strncpy ( + ase_char_t* buf, const ase_char_t* str, ase_size_t len) +{ + const ase_char_t* end = str + len; + while (str < end) *buf++ = *str++; + *buf = ASE_T('\0'); + return len; +} + +ase_size_t ase_strxncpy ( + ase_char_t* buf, ase_size_t bsz, const ase_char_t* str, ase_size_t len) +{ + ase_size_t n; + + if (bsz <= 0) return 0; + if ((n = bsz - 1) > len) n = len; + ase_memcpy (buf, str, n * ASE_SIZEOF(ase_char_t)); + buf[n] = ASE_T('\0'); + + return n; +} + +ase_size_t ase_strxncat ( + ase_char_t* buf, ase_size_t bsz, const ase_char_t* str, ase_size_t len) +{ + ase_char_t* p, * p2; + const ase_char_t* end; + ase_size_t blen; + + blen = ase_strlen(buf); + if (blen >= bsz) return blen; /* something wrong */ + + p = buf + blen; + p2 = buf + bsz - 1; + + end = str + len; + + while (p < p2) + { + if (str >= end) break; + *p++ = *str++; + } + + if (bsz > 0) *p = ASE_T('\0'); + return p - buf; +} + +int ase_strcmp (const ase_char_t* s1, const ase_char_t* s2) +{ + while (*s1 == *s2) + { + if (*s1 == ASE_C('\0')) return 0; + s1++, s2++; + } + + return (*s1 > *s2)? 1: -1; +} + +int ase_strxncmp ( + const ase_char_t* s1, ase_size_t len1, + const ase_char_t* s2, ase_size_t len2) +{ + ase_char_t c1, c2; + const ase_char_t* end1 = s1 + len1; + const ase_char_t* end2 = s2 + len2; + + while (s1 < end1) + { + c1 = *s1; + if (s2 < end2) + { + c2 = *s2; + if (c1 > c2) return 1; + if (c1 < c2) return -1; + } + else return 1; + s1++; s2++; + } + + return (s2 < end2)? -1: 0; +} + +int ase_strcasecmp ( + const ase_char_t* s1, const ase_char_t* s2, ase_ccls_t* ccls) +{ + while (ASE_TOUPPER(ccls,*s1) == ASE_TOUPPER(ccls,*s2)) + { + if (*s1 == ASE_C('\0')) return 0; + s1++, s2++; + } + + return (ASE_TOUPPER(ccls,*s1) > ASE_TOUPPER(ccls,*s2))? 1: -1; +} + +int ase_strxncasecmp ( + const ase_char_t* s1, ase_size_t len1, + const ase_char_t* s2, ase_size_t len2, ase_ccls_t* ccls) +{ + ase_char_t c1, c2; + const ase_char_t* end1 = s1 + len1; + const ase_char_t* end2 = s2 + len2; + + while (s1 < end1) + { + c1 = ASE_TOUPPER (ccls, *s1); + if (s2 < end2) + { + c2 = ASE_TOUPPER (ccls, *s2); + if (c1 > c2) return 1; + if (c1 < c2) return -1; + } + else return 1; + s1++; s2++; + } + + return (s2 < end2)? -1: 0; +} + +ase_char_t* ase_strdup (const ase_char_t* str, ase_mmgr_t* mmgr) +{ + ase_char_t* tmp; + + tmp = (ase_char_t*) ASE_MALLOC ( + mmgr, (ase_strlen(str)+1)*ASE_SIZEOF(ase_char_t)); + if (tmp == ASE_NULL) return ASE_NULL; + + ase_strcpy (tmp, str); + return tmp; +} + +ase_char_t* ase_strxdup ( + const ase_char_t* str, ase_size_t len, ase_mmgr_t* mmgr) +{ + ase_char_t* tmp; + + tmp = (ase_char_t*) ASE_MALLOC ( + mmgr, (len+1)*ASE_SIZEOF(ase_char_t)); + if (tmp == ASE_NULL) return ASE_NULL; + + ase_strncpy (tmp, str, len); + return tmp; +} + +ase_char_t* ase_strxdup2 ( + const ase_char_t* str1, ase_size_t len1, + const ase_char_t* str2, ase_size_t len2, ase_mmgr_t* mmgr) +{ + ase_char_t* tmp; + + tmp = (ase_char_t*) ASE_MALLOC ( + mmgr, (len1+len2+1) * ASE_SIZEOF(ase_char_t)); + if (tmp == ASE_NULL) return ASE_NULL; + + ase_strncpy (tmp, str1, len1); + ase_strncpy (tmp + len1, str2, len2); + return tmp; +} + +ase_char_t* ase_strxnstr ( + const ase_char_t* str, ase_size_t strsz, + const ase_char_t* sub, ase_size_t subsz) +{ + const ase_char_t* end, * subp; + + if (subsz == 0) return (ase_char_t*)str; + if (strsz < subsz) return ASE_NULL; + + end = str + strsz - subsz; + subp = sub + subsz; + + while (str <= end) + { + const ase_char_t* x = str; + const ase_char_t* y = sub; + + while (ase_true) + { + if (y >= subp) return (ase_char_t*)str; + if (*x != *y) break; + x++; y++; + } + + str++; + } + + return ASE_NULL; +} + +ase_str_t* ase_str_open (ase_str_t* str, ase_size_t capa, ase_mmgr_t* mmgr) +{ + if (str == ASE_NULL) + { + str = (ase_str_t*) + ASE_MALLOC (mmgr, ASE_SIZEOF(ase_str_t)); + if (str == ASE_NULL) return ASE_NULL; + str->__dynamic = ase_true; + } + else str->__dynamic = ase_false; + + str->mmgr = mmgr; + str->buf = (ase_char_t*) ASE_MALLOC ( + mmgr, ASE_SIZEOF(ase_char_t) * (capa + 1)); + if (str->buf == ASE_NULL) + { + if (str->__dynamic) ASE_FREE (mmgr, str); + return ASE_NULL; + } + + str->size = 0; + str->capa = capa; + str->buf[0] = ASE_T('\0'); + + return str; +} + +void ase_str_close (ase_str_t* str) +{ + ASE_FREE (str->mmgr, str->buf); + if (str->__dynamic) ASE_FREE (str->mmgr, str); +} + +void ase_str_clear (ase_str_t* str) +{ + str->size = 0; + str->buf[0] = ASE_T('\0'); +} + +void ase_str_forfeit (ase_str_t* str) +{ + if (str->__dynamic) ASE_FREE (str->mmgr, str); +} + +void ase_str_swap (ase_str_t* str, ase_str_t* str1) +{ + ase_str_t tmp; + + tmp.buf = str->buf; + tmp.size = str->size; + tmp.capa = str->capa; + tmp.mmgr = str->mmgr; + + str->buf = str1->buf; + str->size = str1->size; + str->capa = str1->capa; + str->mmgr = str1->mmgr; + + str1->buf = tmp.buf; + str1->size = tmp.size; + str1->capa = tmp.capa; + str1->mmgr = tmp.mmgr; +} + +ase_size_t ase_str_cpy (ase_str_t* str, const ase_char_t* s) +{ + /* TODO: improve it */ + return ase_str_ncpy (str, s, ase_strlen(s)); +} + +ase_size_t ase_str_ncpy (ase_str_t* str, const ase_char_t* s, ase_size_t len) +{ + ase_char_t* buf; + + if (len > str->capa) + { + buf = (ase_char_t*) ASE_MALLOC ( + str->mmgr, ASE_SIZEOF(ase_char_t) * (len + 1)); + if (buf == ASE_NULL) return (ase_size_t)-1; + + ASE_FREE (str->mmgr, str->buf); + str->capa = len; + str->buf = buf; + } + + str->size = ase_strncpy (str->buf, s, len); + str->buf[str->size] = ASE_T('\0'); + return str->size; +} + +ase_size_t ase_str_cat (ase_str_t* str, const ase_char_t* s) +{ + /* TODO: improve it */ + return ase_str_ncat (str, s, ase_strlen(s)); +} + +ase_size_t ase_str_ncat (ase_str_t* str, const ase_char_t* s, ase_size_t len) +{ + if (len > str->capa - str->size) + { + ase_char_t* tmp; + ase_size_t capa; + + capa = str->size + len; + + /* double the capa if necessary for concatenation */ + if (capa < str->capa * 2) capa = str->capa * 2; + + if (str->mmgr->realloc != ASE_NULL) + { + tmp = (ase_char_t*) ASE_REALLOC ( + str->mmgr, str->buf, + ASE_SIZEOF(ase_char_t) * (capa + 1)); + if (tmp == ASE_NULL) return (ase_size_t)-1; + } + else + { + tmp = (ase_char_t*) ASE_MALLOC ( + str->mmgr, ASE_SIZEOF(ase_char_t)*(capa+1)); + if (tmp == ASE_NULL) return (ase_size_t)-1; + if (str->buf != ASE_NULL) + { + ase_memcpy (tmp, str->buf, + ASE_SIZEOF(ase_char_t)*(str->capa+1)); + ASE_FREE (str->mmgr, str->buf); + } + } + + str->capa = capa; + str->buf = tmp; + } + + str->size += ase_strncpy (&str->buf[str->size], s, len); + str->buf[str->size] = ASE_T('\0'); + return str->size; +} + +ase_size_t ase_str_ccat (ase_str_t* str, ase_char_t c) +{ + return ase_str_ncat (str, &c, 1); +} + +ase_size_t ase_str_nccat (ase_str_t* str, ase_char_t c, ase_size_t len) +{ + while (len > 0) + { + if (ase_str_ncat (str, &c, 1) == (ase_size_t)-1) + { + return (ase_size_t)-1; + } + + len--; + } + return str->size; +} + + diff --git a/ase/cmn/str.h b/ase/cmn/str.h new file mode 100644 index 00000000..59abde99 --- /dev/null +++ b/ase/cmn/str.h @@ -0,0 +1,88 @@ +/* + * $Id: str.h,v 1.3 2007/04/30 05:55:36 bacon Exp $ + * + * {License} + */ + +#ifndef _ASE_CMN_STR_H_ +#define _ASE_CMN_STR_H_ + +#include +#include + +#define ASE_STR_LEN(x) ((x)->size) +#define ASE_STR_SIZE(x) ((x)->size + 1) +#define ASE_STR_CAPA(x) ((x)->capa) +#define ASE_STR_BUF(x) ((x)->buf) +#define ASE_STR_CHAR(x,idx) ((x)->buf[idx]) + +typedef struct ase_str_t ase_str_t; + +struct ase_str_t +{ + ase_char_t* buf; + ase_size_t size; + ase_size_t capa; + ase_mmgr_t* mmgr; + ase_bool_t __dynamic; +}; + +#ifdef __cplusplus +extern "C" { +#endif + +ase_size_t ase_strlen (const ase_char_t* str); + +ase_size_t ase_strcpy ( + ase_char_t* buf, const ase_char_t* str); +ase_size_t ase_strxcpy ( + ase_char_t* buf, ase_size_t bsz, const ase_char_t* str); +ase_size_t ase_strncpy ( + ase_char_t* buf, const ase_char_t* str, ase_size_t len); +ase_size_t ase_strxncpy ( + ase_char_t* buf, ase_size_t bsz, const ase_char_t* str, ase_size_t len); + +ase_size_t ase_strxncat ( + ase_char_t* buf, ase_size_t bsz, const ase_char_t* str, ase_size_t len); + +int ase_strcmp (const ase_char_t* s1, const ase_char_t* s2); +int ase_strxncmp ( + const ase_char_t* s1, ase_size_t len1, + const ase_char_t* s2, ase_size_t len2); +int ase_strcasecmp ( + const ase_char_t* s1, const ase_char_t* s2, ase_ccls_t* ccls); +int ase_strxncasecmp ( + const ase_char_t* s1, ase_size_t len1, + const ase_char_t* s2, ase_size_t len2, ase_ccls_t* ccls); + +ase_char_t* ase_strdup (const ase_char_t* str, ase_mmgr_t* mmgr); +ase_char_t* ase_strxdup ( + const ase_char_t* str, ase_size_t len, ase_mmgr_t* mmgr); +ase_char_t* ase_strxdup2 ( + const ase_char_t* str1, ase_size_t len1, + const ase_char_t* str2, ase_size_t len2, ase_mmgr_t* mmgr); + +ase_char_t* ase_strxnstr ( + const ase_char_t* str, ase_size_t strsz, + const ase_char_t* sub, ase_size_t subsz); + +ase_str_t* ase_str_open (ase_str_t* str, ase_size_t capa, ase_mmgr_t* mmgr); +void ase_str_close (ase_str_t* str); +void ase_str_clear (ase_str_t* str); + +void ase_str_forfeit (ase_str_t* str); +void ase_str_swap (ase_str_t* str, ase_str_t* str2); + +ase_size_t ase_str_cpy (ase_str_t* str, const ase_char_t* s); +ase_size_t ase_str_ncpy (ase_str_t* str, const ase_char_t* s, ase_size_t len); + +ase_size_t ase_str_cat (ase_str_t* str, const ase_char_t* s); +ase_size_t ase_str_ncat (ase_str_t* str, const ase_char_t* s, ase_size_t len); +ase_size_t ase_str_ccat (ase_str_t* str, ase_char_t c); +ase_size_t ase_str_nccat (ase_str_t* str, ase_char_t c, ase_size_t len); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ase/cmn/types.h b/ase/cmn/types.h new file mode 100644 index 00000000..d01636c8 --- /dev/null +++ b/ase/cmn/types.h @@ -0,0 +1,276 @@ +/* + * $Id: types.h,v 1.3 2007/04/30 05:55:36 bacon Exp $ + * + * {License} + */ + +#ifndef _ASE_TYPES_H_ +#define _ASE_TYPES_H_ + +#if defined(_WIN32) + #include +#elif defined(vms) || defined(__vms) + #include +#elif defined(__unix__) || defined(__unix) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || (defined(__APPLE__) && defined(__MACH__)) + #if !defined(__unix__) + #define __unix__ + #endif + #if !defined(__unix) + #define __unix + #endif + #include +#else + #error unsupported operating system +#endif + +/* boolean type */ +typedef int ase_bool_t; +#define ase_true (0 == 0) +#define ase_false (0 != 0) + +/* tri-state type */ +typedef int ase_tri_t; +#define ase_alive 1 +#define ase_zombie 0 +#define ase_dead -1 + +/* integer that can hold a pointer */ +#if ASE_SIZEOF_VOID_P == ASE_SIZEOF_INT + typedef int ase_int_t; + typedef unsigned int ase_uint_t; +#elif ASE_SIZEOF_VOID_P == ASE_SIZEOF_LONG + typedef long ase_int_t; + typedef unsigned long ase_uint_t; +#elif ASE_SIZEOF_VOID_P == ASE_SIZEOF_LONG_LONG + typedef long long ase_int_t; + typedef unsigned long long ase_uint_t; +#elif ASE_SIZEOF_VOID_P == ASE_SIZEOF___INT32 + typedef __int32 ase_int_t; + typedef unsigned __int32 ase_uint_t; +#elif ASE_SIZEOF_VOID_P == ASE_SIZEOF___INT64 + typedef __int64 ase_int_t; + typedef unsigned __int64 ase_uint_t; +#else + #error unsupported pointer size +#endif + + +/* the largest integer supported by the system */ +#if ASE_SIZEOF_LONG_LONG != 0 + typedef long long ase_long_t; + typedef unsigned long long ase_ulong_t; +#elif ASE_SIZEOF___INT64 != 0 + typedef __int64 ase_long_t; + typedef unsigned __int64 ase_ulong_t; +#else + typedef long ase_long_t; + typedef unsigned long ase_ulong_t; +#endif + +/* integers of specific size */ +#if ASE_SIZEOF_CHAR == 1 + typedef char ase_int8_t; + typedef unsigned char ase_uint8_t; +#elif ASE_SIZEOF___INT8 == 1 + typedef __int8 ase_int8_t; + typedef unsigned __int8 ase_uint8_t; +#endif + +#if ASE_SIZEOF_SHORT == 2 + typedef short ase_int16_t; + typedef unsigned short ase_uint16_t; +#elif ASE_SIZEOF___INT16 == 2 + typedef __int16 ase_int16_t; + typedef unsigned __int16 ase_uint16_t; +#endif + +#if ASE_SIZEOF_INT == 4 + typedef int ase_int32_t; + typedef unsigned int ase_uint32_t; +#elif ASE_SIZEOF_LONG == 4 + typedef long ase_int32_t; + typedef unsigned long ase_uint32_t; +#elif ASE_SIZEOF___INT32 == 4 + typedef __int32 ase_int32_t; + typedef unsigned __int32 ase_uint32_t; +#endif + +#if ASE_SIZEOF_INT == 8 + #define ASE_HAVE_INT64_T + #define ASE_HAVE_UINT64_T + typedef int ase_int64_t; + typedef unsigned int ase_uint64_t; +#elif ASE_SIZEOF_LONG == 8 + #define ASE_HAVE_INT64_T + #define ASE_HAVE_UINT64_T + typedef long ase_int64_t; + typedef unsigned long ase_uint64_t; +#elif ASE_SIZEOF_LONG_LONG == 8 + #define ASE_HAVE_INT64_T + #define ASE_HAVE_UINT64_T + typedef long long ase_int64_t; + typedef unsigned long long ase_uint64_t; +#elif ASE_SIZEOF___INT64 == 8 + #define ASE_HAVE_INT64_T + #define ASE_HAVE_UINT64_T + typedef __int64 ase_int64_t; + typedef unsigned __int64 ase_uint64_t; +#endif + +#if ASE_SIZEOF_INT == 16 + #define ASE_HAVE_INT128_T + #define ASE_HAVE_UINT128_T + typedef int ase_int128_t; + typedef unsigned int ase_uint128_t; +#elif ASE_SIZEOF_LONG == 16 + #define ASE_HAVE_INT128_T + #define ASE_HAVE_UINT128_T + typedef long ase_int128_t; + typedef unsigned long ase_uint128_t; +#elif ASE_SIZEOF_LONG_LONG == 16 + #define ASE_HAVE_INT128_T + #define ASE_HAVE_UINT128_T + typedef long long ase_int128_t; + typedef unsigned long long ase_uint128_t; +#elif ASE_SIZEOF___INT128 == 16 + #define ASE_HAVE_INT128_T + #define ASE_HAVE_UINT128_T + typedef __int128 ase_int128_t; + typedef unsigned __int128 ase_uint128_t; +#endif + +/* miscellaneous integral types */ +typedef ase_uint8_t ase_byte_t; +typedef ase_uint_t ase_size_t; +typedef ase_int_t ase_ssize_t; +typedef ase_uint_t ase_word_t; + +/* floating-point number */ +#if defined(__FreeBSD__) + /* TODO: check if the support for long double is complete. + * if so, use long double for ase_real_t */ + #define ASE_SIZEOF_REAL ASE_SIZEOF_DOUBLE + typedef double ase_real_t; +#elif ASE_SIZEOF_LONG_DOUBLE > ASE_SIZEOF_DOUBLE + #define ASE_SIZEOF_REAL ASE_SIZEOF_LONG_DOUBLE + typedef long double ase_real_t; +#else + #define ASE_SIZEOF_REAL ASE_SIZEOF_DOUBLE + typedef double ase_real_t; +#endif + +/* character types */ +typedef char ase_mchar_t; +typedef int ase_mcint_t; + +#if defined(__cplusplus) + /* C++ */ + typedef wchar_t ase_wchar_t; + typedef wchar_t ase_wcint_t; + + /* all the way down from here for C */ +#elif (ASE_SIZEOF_WCHAR_T == 2) || (ASE_SIZEOF_WCHAR_T == 0) + typedef unsigned short ase_wchar_t; + typedef unsigned short ase_wcint_t; +#elif (ASE_SIZEOF_WCHAR_T == 4) + #if defined(vms) || defined(__vms) + typedef unsigned int ase_wchar_t; + typedef int ase_wcint_t; + #elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) + typedef int ase_wchar_t; + typedef int ase_wcint_t; + #elif (defined(sun) || defined(__sun)) && defined(_LP64) + typedef int ase_wchar_t; + typedef int ase_wcint_t; + #elif defined(__APPLE__) && defined(__MACH__) + typedef int ase_wchar_t; + typedef int ase_wcint_t; + #elif defined(hpux) || defined(__hpux) + typedef unsigned int ase_wchar_t; + typedef int ase_wcint_t; + #elif ASE_SIZEOF_LONG == 4 + typedef long ase_wchar_t; + typedef long ase_wcint_t; + #else + typedef int ase_wchar_t; + typedef int ase_wcint_t; + #endif +#else + #error unsupported size of wchar_t +#endif + +#if defined(_WIN32) && (defined(UNICODE)||defined(_UNICODE)) + #define ASE_CHAR_IS_WCHAR + typedef ase_wchar_t ase_char_t; + typedef ase_wcint_t ase_cint_t; +#else + #if defined(ASE_CHAR_IS_MCHAR) + typedef ase_mchar_t ase_char_t; + typedef ase_mcint_t ase_cint_t; + #elif defined(ASE_CHAR_IS_WCHAR) + typedef ase_wchar_t ase_char_t; + typedef ase_wcint_t ase_cint_t; + #elif defined(_MBCS) + #define ASE_CHAR_IS_MCHAR + typedef ase_mchar_t ase_char_t; + typedef ase_mcint_t ase_cint_t; + #else + #define ASE_CHAR_IS_WCHAR + typedef ase_wchar_t ase_char_t; + typedef ase_wcint_t ase_cint_t; + #endif +#endif + +#if defined(ASE_CHAR_IS_WCHAR) && defined(_WIN32) + #ifndef UNICODE + #define UNICODE + #endif + #ifndef _UNICODE + #define _UNICODE + #endif +#endif + +typedef struct ase_cstr_t ase_cstr_t; +typedef struct ase_mmgr_t ase_mmgr_t; +typedef struct ase_ccls_t ase_ccls_t; + +typedef void* (*ase_malloc_t) (void* custom, ase_size_t n); +typedef void* (*ase_realloc_t) (void* custom, void* ptr, ase_size_t n); +typedef void (*ase_free_t) (void* custom, void* ptr); + +typedef ase_bool_t (*ase_isccls_t) (void* custom, ase_cint_t c); +typedef ase_cint_t (*ase_toccls_t) (void* custom, ase_cint_t c); + +struct ase_cstr_t +{ + const ase_char_t* ptr; + ase_size_t len; +}; + +struct ase_mmgr_t +{ + ase_malloc_t malloc; + ase_realloc_t realloc; + ase_free_t free; + void* custom_data; +}; + +struct ase_ccls_t +{ + ase_isccls_t is_upper; + ase_isccls_t is_lower; + ase_isccls_t is_alpha; + ase_isccls_t is_digit; + ase_isccls_t is_xdigit; + ase_isccls_t is_alnum; + ase_isccls_t is_space; + ase_isccls_t is_print; + ase_isccls_t is_graph; + ase_isccls_t is_cntrl; + ase_isccls_t is_punct; + ase_toccls_t to_upper; + ase_toccls_t to_lower; + void* custom_data; +}; + +#endif diff --git a/ase/cmn/unpack.h b/ase/cmn/unpack.h new file mode 100644 index 00000000..98a553ec --- /dev/null +++ b/ase/cmn/unpack.h @@ -0,0 +1,17 @@ +/* + * $Id: unpack.h,v 1.3 2007/04/30 05:55:36 bacon Exp $ + * + * {License} + */ + +#if defined(__GNUC__) + #pragma pack() +#elif defined(__HP_aCC) || defined(__HP_cc) + #pragma PACK +#elif defined(_MSC_VER) || defined(__BORLANDC__) + #pragma pack(pop) +#elif defined(__DECC) + #pragma pack(pop) +#else + #pragma pack() +#endif diff --git a/ase/com/Awk.cpp b/ase/com/Awk.cpp new file mode 100644 index 00000000..95c1285f --- /dev/null +++ b/ase/com/Awk.cpp @@ -0,0 +1,1395 @@ +/* + * $Id: Awk.cpp,v 1.3 2007/04/30 06:04:43 bacon Exp $ + * + * {License} + */ + +#include "stdafx.h" +#include "asecom.h" +#include "Awk.h" +#include "AwkExtio.h" +#include "Buffer.h" +#include +#include +#include +#include +#include + +#include +#include +#include + +#ifdef _MSC_VER +#pragma warning (disable: 4996) +#endif + +#define DBGOUT(x) do { if (debug) OutputDebugString (x); } while(0) +#define DBGOUT2(awk,x) do { if (awk->debug) OutputDebugString (x); } while(0) + +STDMETHODIMP CAwk::InterfaceSupportsErrorInfo(REFIID riid) +{ + static const IID* arr[] = + { + &IID_IAwk, + }; + + for (int i=0;inext; + free (bfn_list->name.ptr); + free (bfn_list); + bfn_list = next; + } + + if (entry_point != NULL) SysFreeString (entry_point); + + if (write_extio_buf != NULL) write_extio_buf->Release (); + if (write_src_buf != NULL) write_src_buf->Release (); + if (read_src_buf != NULL) read_src_buf->Release (); + + if (handle != NULL) + { + ase_awk_close (handle); + handle = NULL; + DBGOUT (_T("closed awk")); + } +} + +#ifndef NDEBUG +void ase_assert_abort (void) +{ + abort (); +} + +void ase_assert_printf (const ase_char_t* fmt, ...) +{ + va_list ap; + int n; + ase_char_t buf[1024]; + + va_start (ap, fmt); + n = _vsntprintf (buf, ASE_COUNTOF(buf), fmt, ap); + if (n < 0) buf[ASE_COUNTOF(buf)-1] = ASE_T('\0'); + + MessageBox (NULL, buf, ASE_T("Assertion Failure"), MB_OK|MB_ICONERROR); + va_end (ap); +} +#endif + +static void* custom_awk_malloc (void* custom, ase_size_t n) +{ + return malloc (n); +} + +static void* custom_awk_realloc (void* custom, void* ptr, ase_size_t n) +{ + return realloc (ptr, n); +} + +static void custom_awk_free (void* custom, void* ptr) +{ + free (ptr); +} + +ase_bool_t custom_awk_isupper (void* custom, ase_cint_t c) +{ + return ase_isupper (c); +} + +ase_bool_t custom_awk_islower (void* custom, ase_cint_t c) +{ + return ase_islower (c); +} + +ase_bool_t custom_awk_isalpha (void* custom, ase_cint_t c) +{ + return ase_isalpha (c); +} + +ase_bool_t custom_awk_isdigit (void* custom, ase_cint_t c) +{ + return ase_isdigit (c); +} + +ase_bool_t custom_awk_isxdigit (void* custom, ase_cint_t c) +{ + return ase_isxdigit (c); +} + +ase_bool_t custom_awk_isalnum (void* custom, ase_cint_t c) +{ + return ase_isalnum (c); +} + +ase_bool_t custom_awk_isspace (void* custom, ase_cint_t c) +{ + return ase_isspace (c); +} + +ase_bool_t custom_awk_isprint (void* custom, ase_cint_t c) +{ + return ase_isprint (c); +} + +ase_bool_t custom_awk_isgraph (void* custom, ase_cint_t c) +{ + return ase_isgraph (c); +} + +ase_bool_t custom_awk_iscntrl (void* custom, ase_cint_t c) +{ + return ase_iscntrl (c); +} + +ase_bool_t custom_awk_ispunct (void* custom, ase_cint_t c) +{ + return ase_ispunct (c); +} + +ase_cint_t custom_awk_toupper (void* custom, ase_cint_t c) +{ + return ase_toupper (c); +} + +ase_cint_t custom_awk_tolower (void* custom, ase_cint_t c) +{ + return ase_tolower (c); +} + +static ase_real_t custom_awk_pow (void* custom, ase_real_t x, ase_real_t y) +{ + return pow (x, y); +} + + +static int custom_awk_sprintf ( + void* custom, ase_char_t* buf, ase_size_t size, + const ase_char_t* fmt, ...) +{ + int n; + + va_list ap; + va_start (ap, fmt); + n = ase_vsprintf (buf, size, fmt, ap); + va_end (ap); + + return n; +} + +static void custom_awk_dprintf (void* custom, const ase_char_t* fmt, ...) +{ + va_list ap; + va_start (ap, fmt); + _vftprintf (stderr, fmt, ap); + va_end (ap); +} + +static ase_ssize_t __read_source ( + int cmd, void* arg, ase_char_t* data, ase_size_t count) +{ + CAwk* awk = (CAwk*)arg; + + if (cmd == ASE_AWK_IO_OPEN) + { + return (ase_ssize_t)awk->Fire_OpenSource (AWK_SOURCE_READ); + } + else if (cmd == ASE_AWK_IO_CLOSE) + { + return (ase_ssize_t)awk->Fire_CloseSource (AWK_SOURCE_READ); + } + else if (cmd == ASE_AWK_IO_READ) + { + if (awk->read_src_buf == NULL) + { + HRESULT hr = CoCreateInstance ( + CLSID_Buffer, NULL, CLSCTX_ALL, + IID_IBuffer, (void**)&awk->read_src_buf); + if (FAILED(hr)) + { + DBGOUT2 (awk, _T("cannot create source input buffer")); + return -1; + } + + awk->read_src_pos = 0; + awk->read_src_len = 0; + } + + CBuffer* tmp = (CBuffer*)awk->read_src_buf; + + if (awk->read_src_pos >= awk->read_src_len) + { + INT n = awk->Fire_ReadSource (awk->read_src_buf); + if (n <= 0) return (ase_ssize_t)n; + + if (SysStringLen(tmp->str) < (UINT)n) return -1; + awk->read_src_pos = 0; + awk->read_src_len = n; + } + + ASE_ASSERT (awk->read_src_pos < awk->read_src_len); + + BSTR str = tmp->str; + INT left = awk->read_src_len - awk->read_src_pos; + if (left > (ase_ssize_t)count) + { + memcpy (data, + ((TCHAR*)str)+awk->read_src_pos, + count * ASE_SIZEOF(ase_char_t)); + awk->read_src_pos += count; + return count; + } + else + { + memcpy (data, + ((TCHAR*)str)+awk->read_src_pos, + left * ASE_SIZEOF(ase_char_t)); + awk->read_src_pos = 0; + awk->read_src_len = 0; + return (ase_ssize_t)left; + } + } + + return -1; +} + +static ase_ssize_t __write_source ( + int cmd, void* arg, ase_char_t* data, ase_size_t count) +{ + CAwk* awk = (CAwk*)arg; + + if (cmd == ASE_AWK_IO_OPEN) + { + return (ase_ssize_t)awk->Fire_OpenSource (AWK_SOURCE_WRITE); + } + else if (cmd == ASE_AWK_IO_CLOSE) + { + return (ase_ssize_t)awk->Fire_CloseSource (AWK_SOURCE_WRITE); + } + else if (cmd == ASE_AWK_IO_WRITE) + { + HRESULT hr; + + if (awk->write_src_buf == NULL) + { + hr = CoCreateInstance ( + CLSID_Buffer, NULL, CLSCTX_ALL, + IID_IBuffer, (void**)&awk->write_src_buf); + if (FAILED(hr)) + { + DBGOUT2 (awk, _T("cannot create source output buffer")); + return -1; + } + } + + CBuffer* tmp = (CBuffer*)awk->write_src_buf; + if (tmp->PutValue (data, count) == FALSE) + { + DBGOUT2 (awk, _T("cannot set source output buffer")); + return -1; + } + + INT n = awk->Fire_WriteSource (awk->write_src_buf); + if (n > (INT)count) return -1; + return (ase_ssize_t)n; + } + + return -1; +} + +static int __handle_bfn ( + ase_awk_run_t* run, const ase_char_t* fnm, ase_size_t fnl) +{ + CAwk* awk = (CAwk*)ase_awk_getruncustomdata (run); + long nargs = (long)ase_awk_getnargs (run); + ase_awk_val_t* v; + + SAFEARRAY* aa; + SAFEARRAYBOUND bound[1]; + + bound[0].lLbound = 0; + bound[0].cElements = nargs; + + aa = SafeArrayCreate (VT_VARIANT, ASE_COUNTOF(bound), bound); + if (aa == NULL) + { + ase_char_t buf[128]; + _sntprintf (buf, ASE_COUNTOF(buf), + _T("out of memory in creating argument array for '%.*s'"), + fnl, fnm); + //TODO: ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, buf); + return -1; + } + + for (long i = 0; i < nargs; i++) + { + VARIANT arg; + + VariantInit (&arg); + + v = ase_awk_getarg (run, i); + + if (v->type == ASE_AWK_VAL_INT) + { + if (awk->use_longlong) + { + arg.vt = VT_I8; + arg.llVal = ((ase_awk_val_int_t*)v)->val; + } + else + { + arg.vt = VT_I4; + arg.lVal = (LONG)((ase_awk_val_int_t*)v)->val; + } + } + else if (v->type == ASE_AWK_VAL_REAL) + { + arg.vt = VT_R8; + arg.dblVal = ((ase_awk_val_real_t*)v)->val; + } + else if (v->type == ASE_AWK_VAL_STR) + { + BSTR tmp = SysAllocStringLen ( + ((ase_awk_val_str_t*)v)->buf, + ((ase_awk_val_str_t*)v)->len); + + if (arg.bstrVal == NULL) + { + VariantClear (&arg); + SafeArrayDestroy (aa); + + ase_char_t buf[128]; + _sntprintf (buf, ASE_COUNTOF(buf), + _T("out of memory in handling '%.*s'"), + fnl, fnm); + //TODO: ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, buf); + return -1; + } + + arg.vt = VT_BSTR; + arg.bstrVal = tmp; + } + else if (v->type == ASE_AWK_VAL_NIL) + { + arg.vt = VT_NULL; + } + + HRESULT hr = SafeArrayPutElement (aa, &i, &arg); + if (hr != S_OK) + { + VariantClear (&arg); + SafeArrayDestroy (aa); + + ase_char_t buf[128]; + _sntprintf (buf, ASE_COUNTOF(buf), + _T("out of memory in handling '%.*s'"), + fnl, fnm); + //TODO: ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, buf); + return -1; + } + + VariantClear (&arg); + } + + BSTR name = SysAllocStringLen (fnm, fnl); + if (name == NULL) + { + SafeArrayDestroy (aa); + + ase_char_t buf[128]; + _sntprintf (buf, ASE_COUNTOF(buf), + _T("out of memory in handling '%.*s'"), + fnl, fnm); + //TODO: ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, buf); + + return -1; + } + + ase_awk_val_t* ret; + int n = awk->Fire_HandleFunction (run, name, aa, &ret); + if (n == 1) + { + ase_char_t buf[128]; + _sntprintf (buf, ASE_COUNTOF(buf), + _T("out of memory in handling '%.*s'"), + fnl, fnm); + //TODO: ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, buf); + return -1; + } + else if (n == 2) + { + ase_char_t buf[128]; + _sntprintf (buf, ASE_COUNTOF(buf), + _T("no handler for '%.*s'"), + fnl, fnm); + //TODO: ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, buf); + return -1; + } + else if (n == 3) + { + ase_char_t buf[128]; + _sntprintf (buf, ASE_COUNTOF(buf), + _T("return value not supported for '%.*s'"), + fnl, fnm); + //TODO: ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, buf); + return -1; + } + + /* name and aa are destroyed in HandleFunction */ + //SafeArrayDestroy (aa); + //SysFreeString (name); + + ase_awk_setretval (run, ret); + return 0; +} + +HRESULT CAwk::Parse (VARIANT_BOOL* ret) +{ + if (handle == NULL) + { + ase_awk_prmfns_t prmfns; + + memset (&prmfns, 0, sizeof(prmfns)); + + prmfns.mmgr.malloc = custom_awk_malloc; + prmfns.mmgr.realloc = custom_awk_realloc; + prmfns.mmgr.free = custom_awk_free; + + prmfns.ccls.is_upper = custom_awk_isupper; + prmfns.ccls.is_lower = custom_awk_islower; + prmfns.ccls.is_alpha = custom_awk_isalpha; + prmfns.ccls.is_digit = custom_awk_isdigit; + prmfns.ccls.is_xdigit = custom_awk_isxdigit; + prmfns.ccls.is_alnum = custom_awk_isalnum; + prmfns.ccls.is_space = custom_awk_isspace; + prmfns.ccls.is_print = custom_awk_isprint; + prmfns.ccls.is_graph = custom_awk_isgraph; + prmfns.ccls.is_cntrl = custom_awk_iscntrl; + prmfns.ccls.is_punct = custom_awk_ispunct; + prmfns.ccls.to_upper = custom_awk_toupper; + prmfns.ccls.to_lower = custom_awk_tolower; + + prmfns.misc.pow = custom_awk_pow; + prmfns.misc.sprintf = custom_awk_sprintf; + prmfns.misc.dprintf = custom_awk_dprintf; + + handle = ase_awk_open (&prmfns, NULL); + if (handle == NULL) + { + errlin = 0; + ase_strxcpy ( + errmsg, ASE_COUNTOF(errmsg), + ase_awk_geterrstr(NULL, ASE_AWK_ENOMEM)); + + *ret = VARIANT_FALSE; + + DBGOUT (_T("cannot open awk")); + return S_OK; + } + else DBGOUT (_T("opened awk successfully")); + + ase_awk_setoption (handle, option); + + ase_awk_setmaxdepth (handle, + ASE_AWK_DEPTH_BLOCK_PARSE, max_depth.block.parse); + ase_awk_setmaxdepth (handle, + ASE_AWK_DEPTH_BLOCK_RUN, max_depth.block.run); + ase_awk_setmaxdepth (handle, + ASE_AWK_DEPTH_EXPR_PARSE, max_depth.expr.parse); + ase_awk_setmaxdepth (handle, + ASE_AWK_DEPTH_EXPR_RUN, max_depth.expr.run); + ase_awk_setmaxdepth (handle, + ASE_AWK_DEPTH_REX_BUILD, max_depth.rex.build); + ase_awk_setmaxdepth (handle, + ASE_AWK_DEPTH_REX_MATCH, max_depth.rex.match); + } + + ase_awk_clrbfn (handle); + + for (bfn_t* bfn = bfn_list; bfn != NULL; bfn = bfn->next) + { + if (ase_awk_addbfn ( + handle, bfn->name.ptr, bfn->name.len, 0, + bfn->min_args, bfn->max_args, NULL, + __handle_bfn) == NULL) + { + const ase_char_t* msg; + + DBGOUT (_T("cannot add the builtin function")); + + ase_awk_geterror (handle, &errnum, &errlin, &msg); + ase_strxcpy (errmsg, ASE_COUNTOF(errmsg), msg); + + *ret = VARIANT_FALSE; + return S_OK; + } + } + + ase_awk_srcios_t srcios; + + srcios.in = __read_source; + srcios.out = __write_source; + srcios.custom_data = this; + + if (ase_awk_parse (handle, &srcios) == -1) + { + const ase_char_t* msg; + + ase_awk_geterror (handle, &errnum, &errlin, &msg); + ase_strxcpy (errmsg, ASE_COUNTOF(errmsg), msg); + + DBGOUT (_T("cannot parse the source code")); + + *ret = VARIANT_FALSE; + return S_OK; + } + else DBGOUT (_T("parsed the source code successfully")); + + *ret = VARIANT_TRUE; + return S_OK; +} + +static ase_ssize_t __process_extio ( + int cmd, void* arg, ase_char_t* data, ase_size_t size) +{ + ase_awk_extio_t* epa = (ase_awk_extio_t*)arg; + CAwk* awk = (CAwk*)epa->custom_data; + + if (cmd == ASE_AWK_IO_OPEN) + { + IAwkExtio* extio; + CAwkExtio* extio2; + IBuffer* read_buf; + + HRESULT hr = CoCreateInstance ( + CLSID_AwkExtio, NULL, CLSCTX_ALL, + IID_IAwkExtio, (void**)&extio); + if (FAILED(hr)) + { + DBGOUT2 (awk, _T("cannot create extio")); + return -1; + } + + hr = CoCreateInstance ( + CLSID_Buffer, NULL, CLSCTX_ALL, + IID_IBuffer, (void**)&read_buf); + if (FAILED(hr)) + { + DBGOUT2 (awk, _T("cannot create extio input buffer")); + extio->Release (); + return -1; + } + + extio2 = (CAwkExtio*)extio; + if (extio2->PutName (epa->name) == FALSE) + { + read_buf->Release (); + extio->Release (); + DBGOUT2 (awk, _T("cannot set the name of the extio input buffer")); + return -1; + } + extio2->type = (AwkExtioType)(epa->type & 0xFF); + extio2->mode = (AwkExtioMode)(epa->mode); + + read_buf->AddRef (); + extio2->read_buf = read_buf; + extio2->read_buf_pos = 0; + extio2->read_buf_len = 0; + + INT n = awk->Fire_OpenExtio (extio); + if (n >= 0) + { + extio->AddRef (); + epa->handle = extio; + } + + read_buf->Release (); + extio->Release (); + return n; + } + else if (cmd == ASE_AWK_IO_CLOSE) + { + IAwkExtio* extio; + CAwkExtio* extio2; + + extio = (IAwkExtio*)epa->handle; + extio2 = (CAwkExtio*)extio; + + ASE_ASSERT (extio != NULL); + + INT n = awk->Fire_CloseExtio (extio); + if (n >= 0) + { + extio2->read_buf->Release(); + extio->Release(); + epa->handle = NULL; + } + + return n; + } + else if (cmd == ASE_AWK_IO_READ) + { + IAwkExtio* extio; + CAwkExtio* extio2; + + extio = (IAwkExtio*)epa->handle; + extio2 = (CAwkExtio*)extio; + + ASE_ASSERT (extio != NULL); + + CBuffer* tmp = (CBuffer*)extio2->read_buf; + if (extio2->read_buf_pos >= extio2->read_buf_len) + { + INT n = awk->Fire_ReadExtio (extio, extio2->read_buf); + if (n <= 0) return (ase_ssize_t)n; + + if (SysStringLen(tmp->str) < (UINT)n) return -1; + extio2->read_buf_pos = 0; + extio2->read_buf_len = n; + } + + ASE_ASSERT (extio2->read_buf_pos < extio2->read_buf_len); + + BSTR str = tmp->str; + INT left = extio2->read_buf_len - extio2->read_buf_pos; + if (left > (ase_ssize_t)size) + { + memcpy (data, + ((TCHAR*)str)+extio2->read_buf_pos, + size * ASE_SIZEOF(ase_char_t)); + extio2->read_buf_pos += size; + return size; + } + else + { + memcpy (data, + ((TCHAR*)str)+extio2->read_buf_pos, + left * ASE_SIZEOF(ase_char_t)); + extio2->read_buf_pos = 0; + extio2->read_buf_len = 0; + return (ase_ssize_t)left; + } + } + else if (cmd == ASE_AWK_IO_WRITE) + { + HRESULT hr; + IAwkExtio* extio = (IAwkExtio*)epa->handle; + ASE_ASSERT (extio != NULL); + + if (awk->write_extio_buf == NULL) + { + hr = CoCreateInstance ( + CLSID_Buffer, NULL, CLSCTX_ALL, + IID_IBuffer, (void**)&awk->write_extio_buf); + if (FAILED(hr)) + { + DBGOUT2 (awk, _T("cannot create extio output buffer")); + return -1; + } + } + + CBuffer* tmp = (CBuffer*)awk->write_extio_buf; + if (tmp->PutValue (data, size) == FALSE) return -1; + + INT n = awk->Fire_WriteExtio (extio, awk->write_extio_buf); + if (n > (INT)size) return -1; + return (ase_ssize_t)n; + } + else if (cmd == ASE_AWK_IO_FLUSH) + { + IAwkExtio* extio = (IAwkExtio*)epa->handle; + ASE_ASSERT (extio != NULL); + return awk->Fire_FlushExtio (extio); + } + else if (cmd == ASE_AWK_IO_NEXT) + { + IAwkExtio* extio = (IAwkExtio*)epa->handle; + ASE_ASSERT (extio != NULL); + return awk->Fire_NextExtio (extio); + } + + return -1; +} + +HRESULT CAwk::Run (VARIANT argarray, VARIANT_BOOL* ret) +{ + const ase_char_t* entry = NULL; + ase_awk_runarg_t* runarg; + long nrunargs; + + if (handle == NULL) + { + errnum = ASE_AWK_EINTERN; + errlin = 0; + _tcscpy (errmsg, _T("parse not called yet")); + + *ret = VARIANT_FALSE; + return S_OK; + } + + ase_awk_runios_t runios; + runios.pipe = NULL; + runios.coproc = NULL; + runios.file = __process_extio; + runios.console = __process_extio; + runios.custom_data = this; + + if (entry_point != NULL && + SysStringLen(entry_point) > 0) entry = entry_point; + + if (argarray.vt == VT_EMPTY || argarray.vt == VT_NULL) + { + /* no run-time argument specified */ + runarg = NULL; + } + else if (argarray.vt == (VT_ARRAY|VT_BSTR)) + { + SAFEARRAY* sa = argarray.parray; + UINT dim = SafeArrayGetDim (sa); + if (dim != 1) + { + /* arguments should not be multi-dimensional */ + errnum = ASE_AWK_EINTERN; + errlin = 0; + _tcscpy (errmsg, _T("multi-dimensional run-time argument array not allowed")); + + *ret = VARIANT_FALSE; + return S_OK; + } + + long lbound, ubound; + SafeArrayGetLBound (sa, 1, &lbound); + SafeArrayGetUBound (sa, 1, &ubound); + + nrunargs = ubound - lbound + 1; + runarg = (ase_awk_runarg_t*) malloc (sizeof(*runarg) * (nrunargs+1)); + if (runarg == NULL) + { + errnum = ASE_AWK_ENOMEM; + errlin = 0; + ase_strxcpy ( + errmsg, ASE_COUNTOF(errmsg), + ase_awk_geterrstr(NULL, errnum)); + + *ret = VARIANT_FALSE; + return S_OK; + } + + long i, j; + for (i = lbound, j = 0; i <= ubound; i++, j++) + { + BSTR bstr; + HRESULT hr = SafeArrayGetElement (sa, &i, (void**)&bstr); + if (FAILED(hr)) + { + errnum = ASE_AWK_EINTERN; + errlin = 0; + _tcscpy (errmsg, _T("cannot get run-time argument array element")); + + for (long i = 0; i < j; i++) SysFreeString (runarg[i].ptr); + free (runarg); + + *ret = VARIANT_FALSE; + return S_OK; + } + + runarg[j].ptr = bstr; + runarg[j].len = SysStringLen (bstr); + } + + runarg[j].ptr = NULL; + runarg[j].len = 0; + } + else + { + errnum = ASE_AWK_EINTERN; + errlin = 0; + _tcscpy (errmsg, _T("invalid arguments")); + + *ret = VARIANT_FALSE; + return S_OK; + } + + if (ase_awk_run (handle, entry, &runios, NULL, runarg, this) == -1) + { + const ase_char_t* msg; + + ase_awk_geterror (handle, &errnum, &errlin, &msg); + ase_strxcpy (errmsg, ASE_COUNTOF(errmsg), msg); + + DBGOUT (_T("cannot run the program")); + + if (runarg != NULL) + { + for (long j = 0; j < nrunargs; j++) SysFreeString (runarg[j].ptr); + free (runarg); + } + + *ret = VARIANT_FALSE; + return S_OK; + } + else DBGOUT (_T("run the program successfully")); + + + if (runarg != NULL) + { + for (long j = 0; j < nrunargs; j++) SysFreeString (runarg[j].ptr); + free (runarg); + } + + *ret = VARIANT_TRUE; + return S_OK; +} + +STDMETHODIMP CAwk::AddFunction ( + BSTR name, int minArgs, int maxArgs, VARIANT_BOOL* ret) +{ + bfn_t* bfn; + size_t name_len = SysStringLen(name); + + for (bfn = bfn_list; bfn != NULL; bfn = bfn->next) + { + if (ase_strxncmp ( + bfn->name.ptr, bfn->name.len, + name, name_len) == 0) + { + errnum = ASE_AWK_EEXIST; + errlin = 0; + _sntprintf ( + errmsg, ASE_COUNTOF(errmsg), + _T("'%.*s' added already"), + bfn->name.len, bfn->name.ptr); + + *ret = VARIANT_FALSE; + return S_OK; + } + } + + bfn = (bfn_t*)malloc (sizeof(bfn_t)); + if (bfn == NULL) + { + errnum = ASE_AWK_ENOMEM; + errlin = 0; + ase_strxcpy ( + errmsg, ASE_COUNTOF(errmsg), + ase_awk_geterrstr(NULL, errnum)); + + *ret = VARIANT_FALSE; + return S_OK; + } + + bfn->name.len = name_len; + bfn->name.ptr = (TCHAR*)malloc (bfn->name.len * sizeof(TCHAR)); + if (bfn->name.ptr == NULL) + { + free (bfn); + + errnum = ASE_AWK_ENOMEM; + errlin = 0; + ase_strxcpy ( + errmsg, ASE_COUNTOF(errmsg), + ase_awk_geterrstr(NULL, errnum)); + + *ret = VARIANT_FALSE; + return S_OK; + } + memcpy (bfn->name.ptr, name, sizeof(TCHAR) * bfn->name.len); + + bfn->min_args = minArgs; + bfn->max_args = maxArgs; + bfn->next = bfn_list; + bfn_list = bfn; + + *ret = VARIANT_TRUE; + return S_OK; +} + +STDMETHODIMP CAwk::DeleteFunction (BSTR name, VARIANT_BOOL* ret) +{ + size_t name_len = SysStringLen(name); + bfn_t* bfn, * next, * prev = NULL; + + for (bfn = bfn_list; bfn != NULL; bfn = next) + { + next = bfn->next; + + if (ase_strxncmp ( + bfn->name.ptr, bfn->name.len, + name, name_len) == 0) + { + free (bfn->name.ptr); + free (bfn); + + if (prev == NULL) bfn_list = next; + else prev->next = next; + + *ret = VARIANT_TRUE; + return S_OK; + } + + prev = bfn; + } + + errnum = ASE_AWK_ENOENT; + errlin = 0; + ase_strxcpy ( + errmsg, ASE_COUNTOF(errmsg), + ase_awk_geterrstr(NULL, errnum)); + + *ret = VARIANT_FALSE; + return S_OK; +} + +STDMETHODIMP CAwk::get_ErrorCode(int *pVal) +{ + *pVal = errnum; + return S_OK; +} + +STDMETHODIMP CAwk::get_ErrorLine(int *pVal) +{ + *pVal = errlin; + return S_OK; +} + +STDMETHODIMP CAwk::get_ErrorMessage(BSTR *pVal) +{ + BSTR tmp = SysAllocStringLen (errmsg, _tcslen(errmsg)); + if (tmp == NULL) return E_OUTOFMEMORY; + *pVal = tmp; + return S_OK; +} + +STDMETHODIMP CAwk::get_ImplicitVariable(VARIANT_BOOL *pVal) +{ + if (handle != NULL) option = ase_awk_getoption (handle); + *pVal = (option & ASE_AWK_IMPLICIT) == 1; + return S_OK; +} + +STDMETHODIMP CAwk::put_ImplicitVariable(VARIANT_BOOL newVal) +{ + if (newVal) option = option | ASE_AWK_IMPLICIT; + else option = option & ~ASE_AWK_IMPLICIT; + if (handle != NULL) ase_awk_setoption (handle, option); + return S_OK; +} + +STDMETHODIMP CAwk::get_ExplicitVariable(VARIANT_BOOL *pVal) +{ + if (handle != NULL) option = ase_awk_getoption (handle); + *pVal = (option & ASE_AWK_EXPLICIT) == 1; + return S_OK; +} + +STDMETHODIMP CAwk::put_ExplicitVariable(VARIANT_BOOL newVal) +{ + if (newVal) option = option | ASE_AWK_EXPLICIT; + else option = option & ~ASE_AWK_EXPLICIT; + if (handle != NULL) ase_awk_setoption (handle, option); + return S_OK; +} + +STDMETHODIMP CAwk::get_UniqueFunction(VARIANT_BOOL *pVal) +{ + if (handle != NULL) option = ase_awk_getoption (handle); + *pVal = (option & ASE_AWK_UNIQUEFN) == 1; + return S_OK; +} + +STDMETHODIMP CAwk::put_UniqueFunction(VARIANT_BOOL newVal) +{ + if (newVal) option = option | ASE_AWK_UNIQUEFN; + else option = option & ~ASE_AWK_UNIQUEFN; + if (handle != NULL) ase_awk_setoption (handle, option); + return S_OK; +} + +STDMETHODIMP CAwk::get_VariableShading(VARIANT_BOOL *pVal) +{ + if (handle != NULL) option = ase_awk_getoption (handle); + *pVal = (option & ASE_AWK_SHADING) == 1; + return S_OK; +} + +STDMETHODIMP CAwk::put_VariableShading(VARIANT_BOOL newVal) +{ + if (newVal) option = option | ASE_AWK_SHADING; + else option = option & ~ASE_AWK_SHADING; + if (handle != NULL) ase_awk_setoption (handle, option); + return S_OK; +} + +STDMETHODIMP CAwk::get_ShiftOperators(VARIANT_BOOL *pVal) +{ + if (handle != NULL) option = ase_awk_getoption (handle); + *pVal = (option & ASE_AWK_SHIFT) == 1; + return S_OK; +} + +STDMETHODIMP CAwk::put_ShiftOperators(VARIANT_BOOL newVal) +{ + if (newVal) option = option | ASE_AWK_SHIFT; + else option = option & ~ASE_AWK_SHIFT; + if (handle != NULL) ase_awk_setoption (handle, option); + return S_OK; +} + +STDMETHODIMP CAwk::get_IdivOperator(VARIANT_BOOL *pVal) +{ + if (handle != NULL) option = ase_awk_getoption (handle); + *pVal = (option & ASE_AWK_IDIV) == 1; + return S_OK; +} + +STDMETHODIMP CAwk::put_IdivOperator(VARIANT_BOOL newVal) +{ + if (newVal) option = option | ASE_AWK_IDIV; + else option = option & ~ASE_AWK_IDIV; + if (handle != NULL) ase_awk_setoption (handle, option); + return S_OK; +} + +STDMETHODIMP CAwk::get_ConcatString(VARIANT_BOOL *pVal) +{ + if (handle != NULL) option = ase_awk_getoption (handle); + *pVal = (option & ASE_AWK_STRCONCAT) == 1; + return S_OK; +} + +STDMETHODIMP CAwk::put_ConcatString(VARIANT_BOOL newVal) +{ + if (newVal) option = option | ASE_AWK_STRCONCAT; + else option = option & ~ASE_AWK_STRCONCAT; + if (handle != NULL) ase_awk_setoption (handle, option); + return S_OK; +} + +STDMETHODIMP CAwk::get_SupportExtio(VARIANT_BOOL *pVal) +{ + if (handle != NULL) option = ase_awk_getoption (handle); + *pVal = (option & ASE_AWK_EXTIO) == 1; + return S_OK; +} + +STDMETHODIMP CAwk::put_SupportExtio(VARIANT_BOOL newVal) +{ + if (newVal) option = option | ASE_AWK_EXTIO; + else option = option & ~ASE_AWK_EXTIO; + if (handle != NULL) ase_awk_setoption (handle, option); + return S_OK; +} + +STDMETHODIMP CAwk::get_SupportBlockless(VARIANT_BOOL *pVal) +{ + if (handle != NULL) option = ase_awk_getoption (handle); + *pVal = (option & ASE_AWK_BLOCKLESS) == 1; + return S_OK; +} + +STDMETHODIMP CAwk::put_SupportBlockless(VARIANT_BOOL newVal) +{ + if (newVal) option = option | ASE_AWK_BLOCKLESS; + else option = option & ~ASE_AWK_BLOCKLESS; + if (handle != NULL) ase_awk_setoption (handle, option); + return S_OK; +} + +STDMETHODIMP CAwk::get_StringBaseOne(VARIANT_BOOL *pVal) +{ + if (handle != NULL) option = ase_awk_getoption (handle); + *pVal = (option & ASE_AWK_STRBASEONE) == 1; + return S_OK; +} + +STDMETHODIMP CAwk::put_StringBaseOne(VARIANT_BOOL newVal) +{ + if (newVal) option = option | ASE_AWK_STRBASEONE; + else option = option & ~ASE_AWK_STRBASEONE; + if (handle != NULL) ase_awk_setoption (handle, option); + return S_OK; +} + +STDMETHODIMP CAwk::get_StripSpaces(VARIANT_BOOL *pVal) +{ + if (handle != NULL) option = ase_awk_getoption (handle); + *pVal = (option & ASE_AWK_STRIPSPACES) == 1; + return S_OK; +} + +STDMETHODIMP CAwk::put_StripSpaces(VARIANT_BOOL newVal) +{ + if (newVal) option = option | ASE_AWK_STRIPSPACES; + else option = option & ~ASE_AWK_STRIPSPACES; + if (handle != NULL) ase_awk_setoption (handle, option); + return S_OK; +} + +STDMETHODIMP CAwk::get_Nextofile(VARIANT_BOOL *pVal) +{ + if (handle != NULL) option = ase_awk_getoption (handle); + *pVal = (option & ASE_AWK_NEXTOFILE) == 1; + return S_OK; +} + +STDMETHODIMP CAwk::put_Nextofile(VARIANT_BOOL newVal) +{ + if (newVal) option = option | ASE_AWK_NEXTOFILE; + else option = option & ~ASE_AWK_NEXTOFILE; + if (handle != NULL) ase_awk_setoption (handle, option); + return S_OK; +} + +STDMETHODIMP CAwk::get_UseCrlf(VARIANT_BOOL *pVal) +{ + if (handle != NULL) option = ase_awk_getoption (handle); + *pVal = (option & ASE_AWK_CRLF) == 1; + return S_OK; +} + +STDMETHODIMP CAwk::put_UseCrlf(VARIANT_BOOL newVal) +{ + if (newVal) option = option | ASE_AWK_CRLF; + else option = option & ~ASE_AWK_CRLF; + if (handle != NULL) ase_awk_setoption (handle, option); + return S_OK; +} + +STDMETHODIMP CAwk::get_ArgumentsToEntryPoint(VARIANT_BOOL *pVal) +{ + if (handle != NULL) option = ase_awk_getoption (handle); + *pVal = (option & ASE_AWK_ARGSTOMAIN) == 1; + return S_OK; +} + +STDMETHODIMP CAwk::put_ArgumentsToEntryPoint(VARIANT_BOOL newVal) +{ + if (newVal) option = option | ASE_AWK_ARGSTOMAIN; + else option = option & ~ASE_AWK_ARGSTOMAIN; + if (handle != NULL) ase_awk_setoption (handle, option); + return S_OK; +} + +STDMETHODIMP CAwk::get_MaxDepthForBlockParse(int *pVal) +{ + if (handle != NULL) + { + max_depth.block.parse = + ase_awk_getmaxdepth (handle, ASE_AWK_DEPTH_BLOCK_PARSE); + } + *pVal = max_depth.block.parse; + return S_OK; +} + +STDMETHODIMP CAwk::put_MaxDepthForBlockParse(int newVal) +{ + max_depth.block.parse = newVal; + if (handle != NULL) + { + ase_awk_setmaxdepth (handle, + ASE_AWK_DEPTH_BLOCK_PARSE, max_depth.block.parse); + } + return S_OK; +} + +STDMETHODIMP CAwk::get_MaxDepthForBlockRun(int *pVal) +{ + if (handle != NULL) + { + max_depth.block.run = + ase_awk_getmaxdepth (handle, ASE_AWK_DEPTH_BLOCK_RUN); + } + *pVal = max_depth.block.run; + return S_OK; +} + +STDMETHODIMP CAwk::put_MaxDepthForBlockRun(int newVal) +{ + max_depth.block.run = newVal; + if (handle != NULL) + { + ase_awk_setmaxdepth (handle, + ASE_AWK_DEPTH_BLOCK_RUN, max_depth.block.run); + } + return S_OK; +} + +STDMETHODIMP CAwk::get_MaxDepthForExprParse(int *pVal) +{ + if (handle != NULL) + { + max_depth.expr.parse = + ase_awk_getmaxdepth (handle, ASE_AWK_DEPTH_EXPR_PARSE); + } + *pVal = max_depth.expr.parse; + return S_OK; +} + +STDMETHODIMP CAwk::put_MaxDepthForExprParse(int newVal) +{ + max_depth.expr.parse = newVal; + if (handle != NULL) + { + ase_awk_setmaxdepth (handle, + ASE_AWK_DEPTH_EXPR_PARSE, max_depth.expr.parse); + } + return S_OK; +} + +STDMETHODIMP CAwk::get_MaxDepthForExprRun(int *pVal) +{ + if (handle != NULL) + { + max_depth.expr.run = + ase_awk_getmaxdepth (handle, ASE_AWK_DEPTH_EXPR_RUN); + } + *pVal = max_depth.expr.run; + return S_OK; +} + +STDMETHODIMP CAwk::put_MaxDepthForExprRun(int newVal) +{ + max_depth.expr.run = newVal; + if (handle != NULL) + { + ase_awk_setmaxdepth (handle, + ASE_AWK_DEPTH_EXPR_RUN, max_depth.expr.run); + } + return S_OK; +} + +STDMETHODIMP CAwk::get_MaxDepthForRexBuild(int *pVal) +{ + if (handle != NULL) + { + max_depth.rex.build = + ase_awk_getmaxdepth (handle, ASE_AWK_DEPTH_REX_BUILD); + } + *pVal = max_depth.rex.build; + return S_OK; +} + +STDMETHODIMP CAwk::put_MaxDepthForRexBuild(int newVal) +{ + max_depth.rex.build = newVal; + if (handle != NULL) + { + ase_awk_setmaxdepth (handle, + ASE_AWK_DEPTH_REX_BUILD, max_depth.rex.build); + } + return S_OK; +} + +STDMETHODIMP CAwk::get_MaxDepthForRexMatch(int *pVal) +{ + if (handle != NULL) + { + max_depth.rex.match = + ase_awk_getmaxdepth (handle, ASE_AWK_DEPTH_REX_MATCH); + } + *pVal = max_depth.rex.match; + return S_OK; +} + +STDMETHODIMP CAwk::put_MaxDepthForRexMatch(int newVal) +{ + max_depth.rex.match = newVal; + if (handle != NULL) + { + ase_awk_setmaxdepth (handle, + ASE_AWK_DEPTH_REX_MATCH, max_depth.rex.match); + } + return S_OK; +} + +STDMETHODIMP CAwk::get_EntryPoint(BSTR *pVal) +{ + if (entry_point == NULL) *pVal = NULL; + else + { + BSTR tmp = SysAllocStringLen ( + entry_point, SysStringLen(entry_point)); + if (tmp == NULL) return E_OUTOFMEMORY; + *pVal = tmp; + } + + return S_OK; +} + +STDMETHODIMP CAwk::put_EntryPoint(BSTR newVal) +{ + if (entry_point != NULL) SysFreeString (entry_point); + if (newVal == NULL) entry_point = newVal; + else + { + entry_point = SysAllocStringLen (newVal, SysStringLen(newVal)); + if (entry_point == NULL) return E_OUTOFMEMORY; + } + + return S_OK; +} + +STDMETHODIMP CAwk::get_Debug(VARIANT_BOOL *pVal) +{ + *pVal = debug; + return S_OK; +} + +STDMETHODIMP CAwk::put_Debug(VARIANT_BOOL newVal) +{ + debug = newVal; + return S_OK; +} + +STDMETHODIMP CAwk::get_UseLongLong(VARIANT_BOOL *pVal) +{ + *pVal = use_longlong; + return S_OK; +} + +STDMETHODIMP CAwk::put_UseLongLong(VARIANT_BOOL newVal) +{ + use_longlong = newVal; + return S_OK; +} diff --git a/ase/com/Awk.h b/ase/com/Awk.h new file mode 100644 index 00000000..26d0914b --- /dev/null +++ b/ase/com/Awk.h @@ -0,0 +1,171 @@ +/* + * $Id: Awk.h,v 1.3 2007/04/30 06:04:43 bacon Exp $ + * + * {License} + */ + +#ifndef _ASE_COM_AWK_H_ +#define _ASE_COM_AWK_H_ + +#if _MSC_VER > 1000 +#pragma once +#endif + +#include "resource.h" +#include "asecom.h" +#include +#include +#include "awk_cp.h" + +///////////////////////////////////////////////////////////////////////////// +// CAwk + +class CAwk : + public IDispatchImpl, + public ISupportErrorInfo, + /*public CComObjectRoot,*/ + public CComObjectRootEx, + public CComCoClass, + public IConnectionPointContainerImpl, + public IProvideClassInfo2Impl<&CLSID_Awk, &DIID_IAwkEvents, &LIBID_ASECOM>, + public CProxyIAwkEvents< CAwk > + +{ +public: + ase_awk_t* handle; + int option; + int errnum; + ase_size_t errlin; + ase_char_t errmsg[256]; + + struct + { + struct + { + int parse; + int run; + } block; + struct + { + int parse; + int run; + } expr; + struct + { + int build; + int match; + } rex; + } max_depth; + + IBuffer* read_src_buf; + IBuffer* write_src_buf; + ase_size_t read_src_pos; + ase_size_t read_src_len; + + IBuffer* write_extio_buf; + + struct bfn_t + { + struct + { + TCHAR* ptr; + size_t len; + } name; + size_t min_args; + size_t max_args; + struct bfn_t* next; + } * bfn_list; + + BSTR entry_point; + VARIANT_BOOL debug; + VARIANT_BOOL use_longlong; +public: + CAwk(); + ~CAwk (); + +BEGIN_COM_MAP(CAwk) + COM_INTERFACE_ENTRY(IDispatch) + COM_INTERFACE_ENTRY(IAwk) + COM_INTERFACE_ENTRY(ISupportErrorInfo) + COM_INTERFACE_ENTRY_IMPL(IConnectionPointContainer) + COM_INTERFACE_ENTRY(IProvideClassInfo) + COM_INTERFACE_ENTRY(IProvideClassInfo2) +END_COM_MAP() + +BEGIN_CONNECTION_POINT_MAP(CAwk) +CONNECTION_POINT_ENTRY(DIID_IAwkEvents) +END_CONNECTION_POINT_MAP() + +//DECLARE_NOT_AGGREGATABLE(CAwk) +// Remove the comment from the line above if you don't want your object to +// support aggregation. + +DECLARE_REGISTRY_RESOURCEID(IDR_AWK) +// ISupportsErrorInfo + STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid); + +// IAwk +public: + STDMETHOD(get_UseLongLong)(/*[out, retval]*/ VARIANT_BOOL *pVal); + STDMETHOD(put_UseLongLong)(/*[in]*/ VARIANT_BOOL newVal); + STDMETHOD(get_Debug)(/*[out, retval]*/ VARIANT_BOOL *pVal); + STDMETHOD(put_Debug)(/*[in]*/ VARIANT_BOOL newVal); + STDMETHOD(get_EntryPoint)(/*[out, retval]*/ BSTR *pVal); + STDMETHOD(put_EntryPoint)(/*[in]*/ BSTR newVal); + STDMETHOD(get_MaxDepthForRexMatch)(/*[out, retval]*/ int *pVal); + STDMETHOD(put_MaxDepthForRexMatch)(/*[in]*/ int newVal); + STDMETHOD(get_MaxDepthForRexBuild)(/*[out, retval]*/ int *pVal); + STDMETHOD(put_MaxDepthForRexBuild)(/*[in]*/ int newVal); + STDMETHOD(get_MaxDepthForExprRun)(/*[out, retval]*/ int *pVal); + STDMETHOD(put_MaxDepthForExprRun)(/*[in]*/ int newVal); + STDMETHOD(get_MaxDepthForExprParse)(/*[out, retval]*/ int *pVal); + STDMETHOD(put_MaxDepthForExprParse)(/*[in]*/ int newVal); + STDMETHOD(get_MaxDepthForBlockRun)(/*[out, retval]*/ int *pVal); + STDMETHOD(put_MaxDepthForBlockRun)(/*[in]*/ int newVal); + STDMETHOD(get_MaxDepthForBlockParse)(/*[out, retval]*/ int *pVal); + STDMETHOD(put_MaxDepthForBlockParse)(/*[in]*/ int newVal); + STDMETHOD(get_ArgumentsToEntryPoint)(/*[out, retval]*/ VARIANT_BOOL *pVal); + STDMETHOD(put_ArgumentsToEntryPoint)(/*[in]*/ VARIANT_BOOL newVal); + STDMETHOD(get_UseCrlf)(/*[out, retval]*/ VARIANT_BOOL *pVal); + STDMETHOD(put_UseCrlf)(/*[in]*/ VARIANT_BOOL newVal); + STDMETHOD(get_Nextofile)(/*[out, retval]*/ VARIANT_BOOL *pVal); + STDMETHOD(put_Nextofile)(/*[in]*/ VARIANT_BOOL newVal); + STDMETHOD(get_StripSpaces)(/*[out, retval]*/ VARIANT_BOOL *pVal); + STDMETHOD(put_StripSpaces)(/*[in]*/ VARIANT_BOOL newVal); + STDMETHOD(get_StringBaseOne)(/*[out, retval]*/ VARIANT_BOOL *pVal); + STDMETHOD(put_StringBaseOne)(/*[in]*/ VARIANT_BOOL newVal); + STDMETHOD(get_SupportBlockless)(/*[out, retval]*/ VARIANT_BOOL *pVal); + STDMETHOD(put_SupportBlockless)(/*[in]*/ VARIANT_BOOL newVal); + STDMETHOD(get_SupportExtio)(/*[out, retval]*/ VARIANT_BOOL *pVal); + STDMETHOD(put_SupportExtio)(/*[in]*/ VARIANT_BOOL newVal); + STDMETHOD(get_ConcatString)(/*[out, retval]*/ VARIANT_BOOL *pVal); + STDMETHOD(put_ConcatString)(/*[in]*/ VARIANT_BOOL newVal); + STDMETHOD(get_IdivOperator)(/*[out, retval]*/ VARIANT_BOOL *pVal); + STDMETHOD(put_IdivOperator)(/*[in]*/ VARIANT_BOOL newVal); + STDMETHOD(get_ShiftOperators)(/*[out, retval]*/ VARIANT_BOOL *pVal); + STDMETHOD(put_ShiftOperators)(/*[in]*/ VARIANT_BOOL newVal); + STDMETHOD(get_VariableShading)(/*[out, retval]*/ VARIANT_BOOL *pVal); + STDMETHOD(put_VariableShading)(/*[in]*/ VARIANT_BOOL newVal); + STDMETHOD(get_UniqueFunction)(/*[out, retval]*/ VARIANT_BOOL *pVal); + STDMETHOD(put_UniqueFunction)(/*[in]*/ VARIANT_BOOL newVal); + STDMETHOD(get_ExplicitVariable)(/*[out, retval]*/ VARIANT_BOOL *pVal); + STDMETHOD(put_ExplicitVariable)(/*[in]*/ VARIANT_BOOL newVal); + STDMETHOD(get_ImplicitVariable)(/*[out, retval]*/ VARIANT_BOOL *pVal); + STDMETHOD(put_ImplicitVariable)(/*[in]*/ VARIANT_BOOL newVal); + STDMETHOD(get_ErrorMessage)(/*[out, retval]*/ BSTR *pVal); + STDMETHOD(get_ErrorLine)(/*[out, retval]*/ int *pVal); + STDMETHOD(get_ErrorCode)(/*[out, retval]*/ int *pVal); + + + HRESULT __stdcall DeleteFunction ( + /*[in]*/ BSTR name, /*[out, retval]*/ VARIANT_BOOL* ret); + HRESULT __stdcall AddFunction ( + /*[in]*/ BSTR name, /*[in]*/ int minArgs, + /*[in]*/ int maxArgs, /*[out, retval]*/ VARIANT_BOOL* ret); + + HRESULT __stdcall Parse (/*[out, retval]*/ VARIANT_BOOL* ret); + HRESULT __stdcall Run ( + /*[in]*/ VARIANT argarray, /*[out, retval]*/ VARIANT_BOOL* ret); +}; + +#endif diff --git a/ase/com/Awk.rgs b/ase/com/Awk.rgs new file mode 100644 index 00000000..14991e89 --- /dev/null +++ b/ase/com/Awk.rgs @@ -0,0 +1,25 @@ +HKCR +{ + ASE.Awk.1 = s 'ASE Awk Class' + { + CLSID = s '{AD863B53-F5EC-45C3-8B1C-6AC678227DC8}' + } + ASE.Awk = s 'ASE Awk Class' + { + CLSID = s '{AD863B53-F5EC-45C3-8B1C-6AC678227DC8}' + } + NoRemove CLSID + { + ForceRemove {AD863B53-F5EC-45C3-8B1C-6AC678227DC8} = s 'ASE Awk Class' + { + ProgID = s 'ASE.Awk.1' + VersionIndependentProgID = s 'ASE.Awk' + ForceRemove 'Programmable' + InprocServer32 = s '%MODULE%' + { + val ThreadingModel = s 'Apartment' + } + 'TypeLib' = s '{F9C69806-16A1-4162-998A-876B33C470BF}' + } + } +} diff --git a/ase/com/AwkExtio.cpp b/ase/com/AwkExtio.cpp new file mode 100644 index 00000000..03157f22 --- /dev/null +++ b/ase/com/AwkExtio.cpp @@ -0,0 +1,70 @@ +/* + * $Id: AwkExtio.cpp,v 1.3 2007/04/30 06:04:43 bacon Exp $ + * + * {License} + */ + +#include "stdafx.h" +#include "asecom.h" +#include "AwkExtio.h" + +#include +///////////////////////////////////////////////////////////////////////////// +// CAwkExtio + +CAwkExtio::CAwkExtio (): name (NULL) +{ + VariantInit (&handle); +} + +CAwkExtio::~CAwkExtio () +{ + if (name != NULL) SysFreeString (name); + VariantClear (&handle); +} + +STDMETHODIMP CAwkExtio::get_Name (BSTR *pVal) +{ + if (name == NULL) *pVal = name; + else + { + BSTR tmp = SysAllocStringLen (name, SysStringLen(name)); + if (tmp == NULL) return E_OUTOFMEMORY; + *pVal = tmp; + } + + return S_OK; +} + +BOOL CAwkExtio::PutName (const TCHAR* val) +{ + if (name != NULL) SysFreeString (name); + name = SysAllocString (val); + return (name == NULL)? FALSE: TRUE; +} + +STDMETHODIMP CAwkExtio::get_Type(AwkExtioType *pVal) +{ + *pVal = type; + return S_OK; +} + +STDMETHODIMP CAwkExtio::get_Mode(AwkExtioMode *pVal) +{ + *pVal = mode; + return S_OK; +} + +STDMETHODIMP CAwkExtio::get_Handle (VARIANT *pVal) +{ + VariantClear (pVal); + VariantCopy (pVal, &handle); + return S_OK; +} + +STDMETHODIMP CAwkExtio::put_Handle (VARIANT newVal) +{ + VariantClear (&handle); + VariantCopy (&handle, &newVal); + return S_OK; +} diff --git a/ase/com/AwkExtio.h b/ase/com/AwkExtio.h new file mode 100644 index 00000000..718639ba --- /dev/null +++ b/ase/com/AwkExtio.h @@ -0,0 +1,53 @@ +/* + * $Id: AwkExtio.h,v 1.3 2007/04/30 06:04:43 bacon Exp $ + * + * {License} + */ + +#ifndef _ASE_COM_AWKEXTIO_H_ +#define _ASE_COM_AWKEXTIO_H_ + +#include "resource.h" +#include + +///////////////////////////////////////////////////////////////////////////// +// CAwkExtio +class ATL_NO_VTABLE CAwkExtio : + public CComObjectRootEx, + public CComCoClass, + public IDispatchImpl +{ +public: + BSTR name; + AwkExtioType type; + AwkExtioMode mode; + VARIANT handle; + + IBuffer* read_buf; + ase_size_t read_buf_pos; + ase_size_t read_buf_len; + + BOOL PutName (const TCHAR* val); + + CAwkExtio (); + ~CAwkExtio (); + +DECLARE_REGISTRY_RESOURCEID(IDR_AWKEXTIO) + +DECLARE_PROTECT_FINAL_CONSTRUCT() + +BEGIN_COM_MAP(CAwkExtio) + COM_INTERFACE_ENTRY(IAwkExtio) + COM_INTERFACE_ENTRY(IDispatch) +END_COM_MAP() + +// IAwkExtio +public: + STDMETHOD(get_Handle)(/*[out, retval]*/ VARIANT *pVal); + STDMETHOD(put_Handle)(/*[in]*/ VARIANT newVal); + STDMETHOD(get_Mode)(/*[out, retval]*/ AwkExtioMode *pVal); + STDMETHOD(get_Type)(/*[out, retval]*/ AwkExtioType *pVal); + STDMETHOD(get_Name)(/*[out, retval]*/ BSTR *pVal); +}; + +#endif //__AWKEXTIO_H_ diff --git a/ase/com/AwkExtio.rgs b/ase/com/AwkExtio.rgs new file mode 100644 index 00000000..25dd5757 --- /dev/null +++ b/ase/com/AwkExtio.rgs @@ -0,0 +1,26 @@ +HKCR +{ + ASE.AwkExtio.1 = s 'ASE AwkExtio Class' + { + CLSID = s '{F52F065A-5FD4-4F4D-AFEA-F5E446B16383}' + } + ASE.AwkExtio = s 'ASE AwkExtio Class' + { + CLSID = s '{F52F065A-5FD4-4F4D-AFEA-F5E446B16383}' + CurVer = s 'ASE.AwkExtio.1' + } + NoRemove CLSID + { + ForceRemove {F52F065A-5FD4-4F4D-AFEA-F5E446B16383} = s 'ASE AwkExtio Class' + { + ProgID = s 'ASE.AwkExtio.1' + VersionIndependentProgID = s 'ASE.AwkExtio' + ForceRemove 'Programmable' + InprocServer32 = s '%MODULE%' + { + val ThreadingModel = s 'Apartment' + } + 'TypeLib' = s '{F9C69806-16A1-4162-998A-876B33C470BF}' + } + } +} diff --git a/ase/com/Buffer.cpp b/ase/com/Buffer.cpp new file mode 100644 index 00000000..96d45639 --- /dev/null +++ b/ase/com/Buffer.cpp @@ -0,0 +1,51 @@ +/* + * $Id: Buffer.cpp,v 1.3 2007/04/30 06:04:43 bacon Exp $ + * + * {License} + */ + +#include "stdafx.h" +#include "Buffer.h" + +CBuffer::CBuffer () +{ + str = NULL; +} + +CBuffer::~CBuffer () +{ + if (str != NULL) SysFreeString (str); +} + +STDMETHODIMP CBuffer::get_Value (BSTR *pVal) +{ + if (str == NULL) *pVal = NULL; + else + { + BSTR tmp = SysAllocStringLen(str, SysStringLen(str)); + if (tmp == NULL) return E_OUTOFMEMORY; + *pVal = tmp; + } + + return S_OK; +} + +STDMETHODIMP CBuffer::put_Value (BSTR newVal) +{ + if (str != NULL) SysFreeString (str); + if (newVal == NULL) str = newVal; + else + { + str = SysAllocStringLen (newVal, SysStringLen(newVal)); + if (str == NULL) return E_OUTOFMEMORY; + } + + return S_OK; +} + +BOOL CBuffer::PutValue (const TCHAR* val, SIZE_T len) +{ + if (str != NULL) SysFreeString (str); + str = SysAllocStringLen (val, len); + return (str == NULL)? FALSE: TRUE; +} diff --git a/ase/com/Buffer.h b/ase/com/Buffer.h new file mode 100644 index 00000000..f3a85555 --- /dev/null +++ b/ase/com/Buffer.h @@ -0,0 +1,40 @@ +/* + * $Id: Buffer.h,v 1.3 2007/04/30 06:04:43 bacon Exp $ + * + * {License} + */ + +#ifndef _ASE_COM_BUFFER_H_ +#define _ASE_COM_BUFFER_H_ + +#include "resource.h" +#include "asecom.h" + +class ATL_NO_VTABLE CBuffer : + public CComObjectRootEx, + public CComCoClass, + public IDispatchImpl +{ +public: + BSTR str; + BOOL PutValue (const TCHAR* val, SIZE_T len); + +public: + CBuffer (); + ~CBuffer (); + +DECLARE_REGISTRY_RESOURCEID(IDR_BUFFER) + +DECLARE_PROTECT_FINAL_CONSTRUCT() + +BEGIN_COM_MAP(CBuffer) + COM_INTERFACE_ENTRY(IBuffer) + COM_INTERFACE_ENTRY(IDispatch) +END_COM_MAP() + +public: + STDMETHOD(get_Value)(/*[out, retval]*/ BSTR *pVal); + STDMETHOD(put_Value)(/*[in]*/ BSTR newVal); +}; + +#endif diff --git a/ase/com/Buffer.rgs b/ase/com/Buffer.rgs new file mode 100644 index 00000000..e4ffa37e --- /dev/null +++ b/ase/com/Buffer.rgs @@ -0,0 +1,26 @@ +HKCR +{ + ASE.Buffer.1 = s 'ASE Buffer Class' + { + CLSID = s '{866B79A7-7628-4808-8AE7-784BE2491C80}' + } + ASE.Buffer = s 'ASE Buffer Class' + { + CLSID = s '{866B79A7-7628-4808-8AE7-784BE2491C80}' + CurVer = s 'ASE.Buffer.1' + } + NoRemove CLSID + { + ForceRemove {866B79A7-7628-4808-8AE7-784BE2491C80} = s 'ASE Buffer Class' + { + ProgID = s 'ASE.Buffer.1' + VersionIndependentProgID = s 'ASE.Buffer' + ForceRemove 'Programmable' + InprocServer32 = s '%MODULE%' + { + val ThreadingModel = s 'Apartment' + } + 'TypeLib' = s '{F9C69806-16A1-4162-998A-876B33C470BF}' + } + } +} diff --git a/ase/com/asecom.cpp b/ase/com/asecom.cpp new file mode 100644 index 00000000..d7ba21a3 --- /dev/null +++ b/ase/com/asecom.cpp @@ -0,0 +1,78 @@ +/* + * $Id: asecom.cpp,v 1.3 2007/04/30 06:04:43 bacon Exp $ + * + * {License} + */ + +// Note: Proxy/Stub Information +// To build a separate proxy/stub DLL, +// run nmake -f aseps.mk in the project directory. + +#include "stdafx.h" +#include "resource.h" +#include +#include "asecom.h" + +#include "asecom_i.c" +#include "Awk.h" +#include "Buffer.h" +#include "AwkExtio.h" + +CComModule _Module; + +BEGIN_OBJECT_MAP(ObjectMap) +OBJECT_ENTRY(CLSID_Awk, CAwk) +OBJECT_ENTRY(CLSID_Buffer, CBuffer) +OBJECT_ENTRY(CLSID_AwkExtio, CAwkExtio) +END_OBJECT_MAP() + +///////////////////////////////////////////////////////////////////////////// +// DLL Entry Point + +extern "C" +BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/) +{ + if (dwReason == DLL_PROCESS_ATTACH) + { + _Module.Init(ObjectMap, hInstance, &LIBID_ASECOM); + DisableThreadLibraryCalls(hInstance); + } + else if (dwReason == DLL_PROCESS_DETACH) + _Module.Term(); + return TRUE; // ok +} + +///////////////////////////////////////////////////////////////////////////// +// Used to determine whether the DLL can be unloaded by OLE + +STDAPI DllCanUnloadNow(void) +{ + return (_Module.GetLockCount()==0) ? S_OK : S_FALSE; +} + +///////////////////////////////////////////////////////////////////////////// +// Returns a class factory to create an object of the requested type + +STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv) +{ + return _Module.GetClassObject(rclsid, riid, ppv); +} + +///////////////////////////////////////////////////////////////////////////// +// DllRegisterServer - Adds entries to the system registry + +STDAPI DllRegisterServer(void) +{ + // registers object, typelib and all interfaces in typelib + return _Module.RegisterServer(TRUE); +} + +///////////////////////////////////////////////////////////////////////////// +// DllUnregisterServer - Removes entries from the system registry + +STDAPI DllUnregisterServer(void) +{ + return _Module.UnregisterServer(TRUE); +} + + diff --git a/ase/com/asecom.def b/ase/com/asecom.def new file mode 100644 index 00000000..66d3ab70 --- /dev/null +++ b/ase/com/asecom.def @@ -0,0 +1,9 @@ +; ase.def : Declares the module parameters. + +LIBRARY "asecom.dll" + +EXPORTS + DllCanUnloadNow @1 PRIVATE + DllGetClassObject @2 PRIVATE + DllRegisterServer @3 PRIVATE + DllUnregisterServer @4 PRIVATE diff --git a/ase/com/asecom.dsp b/ase/com/asecom.dsp new file mode 100644 index 00000000..ece491be --- /dev/null +++ b/ase/com/asecom.dsp @@ -0,0 +1,207 @@ +# Microsoft Developer Studio Project File - Name="asecom" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=asecom - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "asecom.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "asecom.mak" CFG="asecom - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "asecom - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "asecom - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "asecom - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "../debug/lib" +# PROP Intermediate_Dir "debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_USRDLL" /D "_UNICODE" /Yu"stdafx.h" /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /ZI /Od /I "../.." /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_USRDLL" /D "_UNICODE" /FR /Yu"stdafx.h" /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo /o"debug/asecom.bsc" +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 aseawk.lib asecmn.lib aseutl.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /implib:"debug/asecom.lib" /pdbtype:sept /libpath:"$(OutDir)" +# Begin Custom Build - Performing registration +IntDir=.\debug +OutDir=.\../debug/lib +TargetPath=\projects\ase\debug\lib\asecom.dll +InputPath=\projects\ase\debug\lib\asecom.dll +SOURCE="$(InputPath)" + +"$(IntDir)\regsvr32.trg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + copy .\asecom.tlb "$(OUTDIR)\asecom.tlb" + if "%OS%"=="" goto NOTNT + if not "%OS%"=="Windows_NT" goto NOTNT + regsvr32 /s /c "$(TargetPath)" + echo regsvr32 exec. time > "$(IntDir)\regsvr32.trg" + goto end + :NOTNT + echo Warning : Cannot register DLL on Windows 95 + :end + +# End Custom Build + +!ELSEIF "$(CFG)" == "asecom - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "../release/lib" +# PROP Intermediate_Dir "release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D "_UNICODE" /D "_ATL_STATIC_REGISTRY" /D "_ATL_MIN_CRT" /Yu"stdafx.h" /FD /c +# ADD CPP /nologo /MT /W3 /O1 /I "../.." /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D "_UNICODE" /D "_ATL_STATIC_REGISTRY" /Yu"stdafx.h" /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo /o"release/awk.bsc" +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 +# ADD LINK32 aseawk.lib asecmn.lib aseutl.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 /implib:"release/asecom.lib" /libpath:"$(OutDir)" +# Begin Custom Build - Performing registration +IntDir=.\release +OutDir=.\../release/lib +TargetPath=\projects\ase\release\lib\asecom.dll +InputPath=\projects\ase\release\lib\asecom.dll +SOURCE="$(InputPath)" + +"$(IntDir)\regsvr32.trg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + copy .\asecom.tlb "$(OUTDIR)\asecom.tlb" + if "%OS%"=="" goto NOTNT + if not "%OS%"=="Windows_NT" goto NOTNT + regsvr32 /s /c "$(TargetPath)" + echo regsvr32 exec. time > "$(IntDir)\regsvr32.trg" + goto end + :NOTNT + echo Warning : Cannot register DLL on Windows 95 + :end + +# End Custom Build + +!ENDIF + +# Begin Target + +# Name "asecom - Win32 Debug" +# Name "asecom - Win32 Release" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\asecom.cpp +# End Source File +# Begin Source File + +SOURCE=.\asecom.def +# End Source File +# Begin Source File + +SOURCE=.\asecom.idl +# ADD MTL /tlb ".\asecom.tlb" /h "asecom.h" /iid "asecom_i.c" /Oicf +# End Source File +# Begin Source File + +SOURCE=.\asecom.rc +# End Source File +# Begin Source File + +SOURCE=.\Awk.cpp +# End Source File +# Begin Source File + +SOURCE=.\AwkExtio.cpp +# End Source File +# Begin Source File + +SOURCE=.\Buffer.cpp +# End Source File +# Begin Source File + +SOURCE=.\stdafx.cpp +# ADD CPP /Yc"stdafx.h" +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\Awk.h +# End Source File +# Begin Source File + +SOURCE=.\awk_cp.h +# End Source File +# Begin Source File + +SOURCE=.\AwkExtio.h +# End Source File +# Begin Source File + +SOURCE=.\Buffer.h +# End Source File +# Begin Source File + +SOURCE=.\resource.h +# End Source File +# Begin Source File + +SOURCE=.\stdafx.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# Begin Source File + +SOURCE=.\Awk.rgs +# End Source File +# Begin Source File + +SOURCE=.\AwkExtio.rgs +# End Source File +# Begin Source File + +SOURCE=.\Buffer.rgs +# End Source File +# End Group +# End Target +# End Project diff --git a/ase/com/asecom.idl b/ase/com/asecom.idl new file mode 100644 index 00000000..7b25cf45 --- /dev/null +++ b/ase/com/asecom.idl @@ -0,0 +1,318 @@ +/* + * $Id: asecom.idl,v 1.3 2007/04/30 06:04:43 bacon Exp $ + */ + +import "oaidl.idl"; +import "ocidl.idl"; + +/* IAwk */ +[ + object, + uuid(05BC1C9F-7C4E-4F77-B186-2E0FD26C0641), + dual, + helpstring("ASE Awk Interface"), + pointer_default(unique) +] +interface IAwk : IDispatch +{ + [id(1), helpstring("method Parse")] + HRESULT Parse([out,retval] VARIANT_BOOL* ret); + + [id(2), helpstring("method Run")] + HRESULT Run([in] VARIANT argarray, [out,retval] VARIANT_BOOL* ret); + + [id(3), helpstring("method AddFunction")] + HRESULT AddFunction([in] BSTR name, [in] int minArgs, [in] int maxArgs, [out,retval] VARIANT_BOOL* ret); + + [id(4), helpstring("method DeleteFunction")] + HRESULT DeleteFunction([in] BSTR name, [out,retval] VARIANT_BOOL* ret); + + [propget, id(5), helpstring("property ErrorCode")] + HRESULT ErrorCode([out,retval] int *pVal); + + [propget, id(6), helpstring("property ErrorLine")] + HRESULT ErrorLine([out,retval] int *pVal); + + [propget, id(7), helpstring("property ErrorMessage")] + HRESULT ErrorMessage([out,retval] BSTR *pVal); + + [propget, id(8), helpstring("property ImplicitVariable")] + HRESULT ImplicitVariable([out,retval] VARIANT_BOOL *pVal); + [propput, id(8), helpstring("property ImplicitVariable")] + HRESULT ImplicitVariable([in] VARIANT_BOOL newVal); + + [propget, id(9), helpstring("property ExplicitVariable")] + HRESULT ExplicitVariable([out,retval] VARIANT_BOOL *pVal); + [propput, id(9), helpstring("property ExplicitVariable")] + HRESULT ExplicitVariable([in] VARIANT_BOOL newVal); + + [propget, id(10), helpstring("property UniqueFunction")] + HRESULT UniqueFunction([out,retval] VARIANT_BOOL *pVal); + [propput, id(10), helpstring("property UniqueFunction")] + HRESULT UniqueFunction([in] VARIANT_BOOL newVal); + + [propget, id(11), helpstring("property VariableShading")] + HRESULT VariableShading([out,retval] VARIANT_BOOL *pVal); + [propput, id(11), helpstring("property VariableShading")] + HRESULT VariableShading([in] VARIANT_BOOL newVal); + + [propget, id(12), helpstring("property ShiftOperators")] + HRESULT ShiftOperators([out,retval] VARIANT_BOOL *pVal); + [propput, id(12), helpstring("property ShiftOperators")] + HRESULT ShiftOperators([in] VARIANT_BOOL newVal); + + [propget, id(13), helpstring("property IdivOperator")] + HRESULT IdivOperator([out,retval] VARIANT_BOOL *pVal); + [propput, id(13), helpstring("property IdivOperator")] + HRESULT IdivOperator([in] VARIANT_BOOL newVal); + + [propget, id(14), helpstring("property ConcatString")] + HRESULT ConcatString([out,retval] VARIANT_BOOL *pVal); + [propput, id(14), helpstring("property ConcatString")] + HRESULT ConcatString([in] VARIANT_BOOL newVal); + + [propget, id(15), helpstring("property SupportExtio")] + HRESULT SupportExtio([out,retval] VARIANT_BOOL *pVal); + [propput, id(15), helpstring("property SupportExtio")] + HRESULT SupportExtio([in] VARIANT_BOOL newVal); + + [propget, id(16), helpstring("property SupportBlockless")] + HRESULT SupportBlockless([out,retval] VARIANT_BOOL *pVal); + [propput, id(16), helpstring("property SupportBlockless")] + HRESULT SupportBlockless([in] VARIANT_BOOL newVal); + + [propget, id(17), helpstring("property StringBaseOne")] + HRESULT StringBaseOne([out,retval] VARIANT_BOOL *pVal); + [propput, id(17), helpstring("property StringBaseOne")] + HRESULT StringBaseOne([in] VARIANT_BOOL newVal); + + [propget, id(18), helpstring("property StripSpaces")] + HRESULT StripSpaces([out,retval] VARIANT_BOOL *pVal); + [propput, id(18), helpstring("property StripSpaces")] + HRESULT StripSpaces([in] VARIANT_BOOL newVal); + + [propget, id(19), helpstring("property Nextofile")] + HRESULT Nextofile([out,retval] VARIANT_BOOL *pVal); + [propput, id(19), helpstring("property Nextofile")] + HRESULT Nextofile([in] VARIANT_BOOL newVal); + + [propget, id(20), helpstring("property UseCrlf")] + HRESULT UseCrlf([out,retval] VARIANT_BOOL *pVal); + [propput, id(20), helpstring("property UseCrlf")] + HRESULT UseCrlf([in] VARIANT_BOOL newVal); + + [propget, id(21), helpstring("property ArgumentsToEntryPoint")] + HRESULT ArgumentsToEntryPoint([out,retval] VARIANT_BOOL *pVal); + [propput, id(21), helpstring("property ArgumentsToEntryPoint")] + HRESULT ArgumentsToEntryPoint([in] VARIANT_BOOL newVal); + + [propget, id(22), helpstring("property MaxDepthForBlockParse")] + HRESULT MaxDepthForBlockParse([out,retval] int *pVal); + [propput, id(22), helpstring("property MaxDepthForBlockParse")] + HRESULT MaxDepthForBlockParse([in] int newVal); + + [propget, id(23), helpstring("property MaxDepthForBlockRun")] + HRESULT MaxDepthForBlockRun([out,retval] int *pVal); + [propput, id(23), helpstring("property MaxDepthForBlockRun")] + HRESULT MaxDepthForBlockRun([in] int newVal); + + [propget, id(24), helpstring("property MaxDepthForExprParse")] + HRESULT MaxDepthForExprParse([out,retval] int *pVal); + [propput, id(24), helpstring("property MaxDepthForExprParse")] + HRESULT MaxDepthForExprParse([in] int newVal); + + [propget, id(25), helpstring("property MaxDepthForExprRun")] + HRESULT MaxDepthForExprRun([out,retval] int *pVal); + [propput, id(25), helpstring("property MaxDepthForExprRun")] + HRESULT MaxDepthForExprRun([in] int newVal); + + [propget, id(26), helpstring("property MaxDepthForRexBuild")] + HRESULT MaxDepthForRexBuild([out,retval] int *pVal); + [propput, id(26), helpstring("property MaxDepthForRexBuild")] + HRESULT MaxDepthForRexBuild([in] int newVal); + + [propget, id(27), helpstring("property MaxDepthForRexMatch")] + HRESULT MaxDepthForRexMatch([out,retval] int *pVal); + [propput, id(27), helpstring("property MaxDepthForRexMatch")] + HRESULT MaxDepthForRexMatch([in] int newVal); + + [propget, id(28), helpstring("property EntryPoint")] + HRESULT EntryPoint([out,retval] BSTR *pVal); + [propput, id(28), helpstring("property EntryPoint")] + HRESULT EntryPoint([in] BSTR newVal); + + [propget, id(29), helpstring("property Debug")] + HRESULT Debug([out,retval] VARIANT_BOOL *pVal); + [propput, id(29), helpstring("property Debug")] + HRESULT Debug([in] VARIANT_BOOL newVal); + + [propget, id(30), helpstring("property UseLongLong")] + HRESULT UseLongLong([out,retval] VARIANT_BOOL *pVal); + [propput, id(30), helpstring("property UseLongLong")] + HRESULT UseLongLong([in] VARIANT_BOOL newVal); +}; + +/* ASECOM */ +[ + uuid(F9C69806-16A1-4162-998A-876B33C470BF), + version(1.0), + helpstring("ASECOM 1.0 Type Library") +] +library ASECOM +{ + importlib("stdole32.tlb"); + importlib("stdole2.tlb"); + + [helpstring("Awk source mode")] + typedef [v1_enum] enum AwkSourceMode + { + AWK_SOURCE_READ = 0, + AWK_SOURCE_WRITE = 1 + } AwkSourceMode; + + [helpstring("AwkExtio type")] + typedef [v1_enum] enum AwkExtioType + { + AWK_EXTIO_PIPE = 0, + AWK_EXTIO_COPROC = 1, + AWK_EXTIO_FILE = 2, + AWK_EXTIO_CONSOLE = 3 + } AwkExtioType; + + [helpstring("AwkExtio mode")] + typedef [v1_enum] enum AwkExtioMode + { + AWK_EXTIO_PIPE_READ = 0, + AWK_EXTIO_PIPE_WRITE = 1, + + AWK_EXTIO_COPROC_READ = 0, + AWK_EXTIO_COPROC_WRITE = 1, + AWK_EXTIO_COPROC_RDWR = 2, + + AWK_EXTIO_FILE_READ = 0, + AWK_EXTIO_FILE_WRITE = 1, + AWK_EXTIO_FILE_APPEND = 2, + + AWK_EXTIO_CONSOLE_READ = 0, + AWK_EXTIO_CONSOLE_WRITE = 1 + } AwkExtioMode; + + /* IBuffer */ + [ + object, + uuid(AD5EA986-37E9-410E-A78E-21799104293A), + dual, + helpstring("IBuffer Interface"), + pointer_default(unique) + ] + interface IBuffer : IDispatch + { + [propget, id(1), helpstring("property Value")] + HRESULT Value([out,retval] BSTR *pVal); + + [propput, id(1), helpstring("property Value")] + HRESULT Value([in] BSTR newVal); + }; + + /* IAwkExtio */ + [ + object, + uuid(BE0B91FF-9944-4DFC-A55B-1FE14E24AFEE), + dual, + helpstring("IAwkExtio Interface"), + pointer_default(unique) + ] + interface IAwkExtio : IDispatch + { + [propget, id(1), helpstring("property Name")] + HRESULT Name([out,retval] BSTR *pVal); + + [propget, id(2), helpstring("property Type")] + HRESULT Type([out,retval] AwkExtioType *pVal); + + [propget, id(3), helpstring("property Mode")] + HRESULT Mode([out,retval] AwkExtioMode *pVal); + + [propget, id(4), helpstring("property Handle")] + HRESULT Handle([out,retval] VARIANT *pVal); + [propput, id(4), helpstring("property Handle")] + HRESULT Handle([in] VARIANT newVal); + }; + + /* IAwkEvents */ + [ + uuid(1351DC8F-10AD-4C40-A2FA-9A2E89C27AC8), + helpstring("ASE Awk Events Interface") + ] + dispinterface IAwkEvents + { + properties: + methods: + [id(1), helpstring("open the source code")] + HRESULT OpenSource([in] AwkSourceMode mode, [out,retval] int* ret); + + [id(2), helpstring("close the source code")] + HRESULT CloseSource([in] AwkSourceMode mode, [out,retval] int* ret); + + [id(3), helpstring("read the source code")] + HRESULT ReadSource([in] IBuffer* buf, [out,retval] int* ret); + + [id(4), helpstring("write the source code")] + HRESULT WriteSource([in] IBuffer* buf, [out,retval] int* ret); + + [id(5), helpstring("method OpenExtio")] + HRESULT OpenExtio([in] IAwkExtio* extio, [out,retval] int* ret); + + [id(6), helpstring("method CloseExtio")] + HRESULT CloseExtio([in] IAwkExtio* extio, [out,retval] int* ret); + + [id(7), helpstring("method ReadExtio")] + HRESULT ReadExtio([in] IAwkExtio* extio, [in] IBuffer* buf, [out,retval] int* ret); + + [id(8), helpstring("method WriteExtio")] + HRESULT WriteExtio([in] IAwkExtio* extio, [in] IBuffer* buf, [out,retval] int* ret); + + [id(9), helpstring("method FlushExtio")] + HRESULT FlushExtio([in] IAwkExtio* extio, [out,retval] int* ret); + + [id(10), helpstring("method NextExtio")] + HRESULT NextExtio([in] IAwkExtio* extio, [out,retval] int* ret); + + [id(11), helpstring("method HandleFunction")] + HRESULT HandleFunction([in] BSTR name, [in] VARIANT argarray, [out,retval] VARIANT* ret); + + /*[id(12), helpstring("method OnClose")] + HRESULT OnClose([out,retval] int* ret);*/ + }; + + /* Awk */ + [ + uuid(AD863B53-F5EC-45C3-8B1C-6AC678227DC8), + helpstring("ASE Awk Class") + ] + coclass Awk + { + [default] interface IAwk; + [default,source] dispinterface IAwkEvents; + }; + + /* AwkExtio */ + [ + uuid(F52F065A-5FD4-4F4D-AFEA-F5E446B16383), + helpstring("ASE AwkExtio Class") + ] + coclass AwkExtio + { + [default] interface IAwkExtio; + }; + + /* Buffer */ + [ + uuid(866B79A7-7628-4808-8AE7-784BE2491C80), + helpstring("ASE Buffer Class") + ] + coclass Buffer + { + [default] interface IBuffer; + }; +}; diff --git a/ase/com/asecom.rc b/ase/com/asecom.rc new file mode 100644 index 00000000..440179cb --- /dev/null +++ b/ase/com/asecom.rc @@ -0,0 +1,121 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "1 TYPELIB ""asecom.tlb""\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,0 + PRODUCTVERSION 1,0,0,0 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "ASE.COM" + VALUE "FileVersion", "1, 0, 0, 0" + VALUE "InternalName", "ASECOM" + VALUE "LegalCopyright", "Hyung-Hwan Chung. All rights reserved" + VALUE "OriginalFilename", "asecom.dll" + VALUE "ProductName", "ASE.COM" + VALUE "ProductVersion", "1, 0, 0, 0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// REGISTRY +// + +IDR_AWK REGISTRY "Awk.rgs" +IDR_AWKEXTIO REGISTRY "AwkExtio.rgs" +IDR_BUFFER REGISTRY "Buffer.rgs" + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE +BEGIN + IDS_PROJNAME "ASE COM Project" +END + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// +1 TYPELIB "asecom.tlb" + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/ase/com/asecom.vcproj b/ase/com/asecom.vcproj new file mode 100644 index 00000000..e32687c5 --- /dev/null +++ b/ase/com/asecom.vcproj @@ -0,0 +1,441 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ase/com/aseps.def b/ase/com/aseps.def new file mode 100644 index 00000000..291123a5 --- /dev/null +++ b/ase/com/aseps.def @@ -0,0 +1,11 @@ + +LIBRARY "asePS" + +DESCRIPTION 'Proxy/Stub DLL' + +EXPORTS + DllGetClassObject @1 PRIVATE + DllCanUnloadNow @2 PRIVATE + GetProxyDllInfo @3 PRIVATE + DllRegisterServer @4 PRIVATE + DllUnregisterServer @5 PRIVATE diff --git a/ase/com/aseps.mk b/ase/com/aseps.mk new file mode 100644 index 00000000..5093ad12 --- /dev/null +++ b/ase/com/aseps.mk @@ -0,0 +1,16 @@ + +aseps.dll: dlldata.obj ase_p.obj ase_i.obj + link /dll /out:aseps.dll /def:aseps.def /entry:DllMain dlldata.obj ase_p.obj ase_i.obj \ + kernel32.lib rpcndr.lib rpcns4.lib rpcrt4.lib oleaut32.lib uuid.lib \ + +.c.obj: + cl /c /Ox /DWIN32 /D_WIN32_WINNT=0x0400 /DREGISTER_PROXY_DLL \ + $< + +clean: + @del aseps.dll + @del aseps.lib + @del aseps.exp + @del dlldata.obj + @del ase_p.obj + @del ase_i.obj diff --git a/ase/com/awk_cp.h b/ase/com/awk_cp.h new file mode 100644 index 00000000..8842e87d --- /dev/null +++ b/ase/com/awk_cp.h @@ -0,0 +1,637 @@ +/* + * $Id: awk_cp.h,v 1.3 2007/04/30 06:04:43 bacon Exp $ + * + * {License} + */ + +#ifndef _AWK_CP_H_ +#define _AWK_CP_H_ + +template +class CProxyIAwkEvents: + public IConnectionPointImpl +{ +public: + INT Fire_OpenSource(INT mode) + { + T* pT = static_cast(this); + int i, nconns = m_vec.GetSize(); + CComVariant args[1], ret; + + for (i = 0; i < nconns; i++) + { + pT->Lock(); + CComPtr sp = m_vec.GetAt(i); + pT->Unlock(); + + IDispatch* pDispatch = + reinterpret_cast(sp.p); + if (pDispatch == NULL) continue; + + VariantClear (&ret); + VariantClear (&args[0]); + + args[0] = mode; + + DISPPARAMS disp = { args, NULL, 1, 0 }; + HRESULT hr = pDispatch->Invoke ( + 0x1, IID_NULL, LOCALE_USER_DEFAULT, + DISPATCH_METHOD, &disp, &ret, NULL, NULL); + if (FAILED(hr)) continue; + + if (ret.vt == VT_EMPTY) + { + /* probably, the handler has not been implemeted*/ + continue; + } + + hr = ret.ChangeType (VT_I4); + if (FAILED(hr)) + { + /* TODO: set the error code properly... */ + /* invalid value returned... */ + return -1; + } + + return ret.lVal; + } + + return -1; + } + + INT Fire_CloseSource(INT mode) + { + T* pT = static_cast(this); + int i, nconns = m_vec.GetSize(); + CComVariant args[1], ret; + + for (i = 0; i < nconns; i++) + { + pT->Lock(); + CComPtr sp = m_vec.GetAt(i); + pT->Unlock(); + + IDispatch* pDispatch = + reinterpret_cast(sp.p); + if (pDispatch == NULL) continue; + + VariantClear (&ret); + VariantClear (&args[0]); + + args[0] = mode; + + DISPPARAMS disp = { args, NULL, 1, 0 }; + HRESULT hr = pDispatch->Invoke ( + 0x2, IID_NULL, LOCALE_USER_DEFAULT, + DISPATCH_METHOD, &disp, &ret, NULL, NULL); + if (FAILED(hr)) continue; + + if (ret.vt == VT_EMPTY) + { + /* probably, the handler has not been implemeted*/ + continue; + } + + hr = ret.ChangeType (VT_I4); + if (FAILED(hr)) + { + /* TODO: set the error code properly... */ + /* invalid value returned... */ + return -1; + } + + return ret.lVal; + } + + return -1; + } + + INT Fire_ReadSource (IBuffer* buf) + { + T* pT = static_cast(this); + int i, nconns = m_vec.GetSize(); + CComVariant args[1], ret; + + for (i = 0; i < nconns; i++) + { + pT->Lock(); + CComPtr sp = m_vec.GetAt(i); + pT->Unlock(); + + IDispatch* pDispatch = + reinterpret_cast(sp.p); + if (pDispatch == NULL) continue; + + VariantClear (&ret); + VariantClear (&args[0]); + + args[0] = (IUnknown*)buf; + + DISPPARAMS disp = { args, NULL, 1, 0 }; + HRESULT hr = pDispatch->Invoke ( + 0x3, IID_NULL, LOCALE_USER_DEFAULT, + DISPATCH_METHOD, &disp, &ret, NULL, NULL); + if (FAILED(hr)) + { + continue; + } + + if (ret.vt == VT_EMPTY) + { + /* probably, the handler has not been implemeted*/ + continue; + } + + hr = ret.ChangeType (VT_I4); + if (FAILED(hr)) + { + /* TODO: set the error code properly... */ + /* invalid value returned... */ + return -1; + } + + return ret.lVal; + } + + /* no event handler attached for the source code read. */ + /* TODO: set error code ... */ + return -1; + } + + INT Fire_WriteSource (IBuffer* buf) + { + T* pT = static_cast(this); + int i, nconns = m_vec.GetSize(); + CComVariant args[1], ret; + + for (i = 0; i < nconns; i++) + { + pT->Lock(); + CComPtr sp = m_vec.GetAt(i); + pT->Unlock(); + + IDispatch* pDispatch = + reinterpret_cast(sp.p); + if (pDispatch == NULL) continue; + + VariantClear (&ret); + VariantClear (&args[0]); + + args[0] = (IUnknown*)buf; + + DISPPARAMS disp = { args, NULL, 1, 0 }; + HRESULT hr = pDispatch->Invoke ( + 0x4, IID_NULL, LOCALE_USER_DEFAULT, + DISPATCH_METHOD, &disp, &ret, NULL, NULL); + if (FAILED(hr)) + { + continue; + } + + if (ret.vt == VT_EMPTY) + { + /* probably, the handler has not been implemeted*/ + continue; + } + + hr = ret.ChangeType (VT_I4); + if (FAILED(hr)) + { + /* TODO: set the error code properly... */ + /* invalid value returned... */ + return -1; + } + + return ret.lVal; + } + + /* no event handler attached for the source code write. + * make the operation succeed by returning the reqested + * data length. */ + CComBSTR bstr; + buf->get_Value (&bstr); + return bstr.Length(); + } + + INT Fire_OpenExtio (IAwkExtio* extio) + { + T* pT = static_cast(this); + int i, nconns = m_vec.GetSize(); + CComVariant args[1], ret; + + for (i = 0; i < nconns; i++) + { + pT->Lock(); + CComPtr sp = m_vec.GetAt(i); + pT->Unlock(); + + IDispatch* pDispatch = + reinterpret_cast(sp.p); + if (pDispatch == NULL) continue; + + VariantClear (&ret); + VariantClear (&args[0]); + + args[0] = (IUnknown*)extio; + + DISPPARAMS disp = { args, NULL, 1, 0 }; + HRESULT hr = pDispatch->Invoke ( + 0x5, IID_NULL, LOCALE_USER_DEFAULT, + DISPATCH_METHOD, &disp, &ret, NULL, NULL); + if (FAILED(hr)) continue; + + if (ret.vt == VT_EMPTY) + { + /* probably, the handler has not been implemeted*/ + continue; + } + + hr = ret.ChangeType (VT_I4); + if (FAILED(hr)) + { + /* TODO: set the error code properly... */ + /* invalid value returned... */ + return -1; + } + + return ret.lVal; + } + + return -1; + } + + INT Fire_CloseExtio (IAwkExtio* extio) + { + T* pT = static_cast(this); + int i, nconns = m_vec.GetSize(); + CComVariant args[1], ret; + + for (i = 0; i < nconns; i++) + { + pT->Lock(); + CComPtr sp = m_vec.GetAt(i); + pT->Unlock(); + + IDispatch* pDispatch = + reinterpret_cast(sp.p); + if (pDispatch == NULL) continue; + + VariantClear (&ret); + VariantClear (&args[0]); + + args[0] = (IUnknown*)extio; + + DISPPARAMS disp = { args, NULL, 1, 0 }; + HRESULT hr = pDispatch->Invoke ( + 0x6, IID_NULL, LOCALE_USER_DEFAULT, + DISPATCH_METHOD, &disp, &ret, NULL, NULL); + if (FAILED(hr)) continue; + + if (ret.vt == VT_EMPTY) + { + /* probably, the handler has not been implemeted*/ + continue; + } + + hr = ret.ChangeType (VT_I4); + if (FAILED(hr)) + { + /* TODO: set the error code properly... */ + /* invalid value returned... */ + return -1; + } + + return ret.lVal; + } + + return -1; + } + + INT Fire_ReadExtio (IAwkExtio* extio, IBuffer* buf) + { + T* pT = static_cast(this); + int i, nconns = m_vec.GetSize(); + CComVariant args[2], ret; + + for (i = 0; i < nconns; i++) + { + pT->Lock(); + CComPtr sp = m_vec.GetAt(i); + pT->Unlock(); + + IDispatch* pDispatch = + reinterpret_cast(sp.p); + if (pDispatch == NULL) continue; + + VariantClear (&ret); + VariantClear (&args[0]); + VariantClear (&args[1]); + + args[1] = (IUnknown*)extio; + args[0] = (IUnknown*)buf; + + DISPPARAMS disp = { args, NULL, 2, 0 }; + HRESULT hr = pDispatch->Invoke ( + 0x7, IID_NULL, LOCALE_USER_DEFAULT, + DISPATCH_METHOD, &disp, &ret, NULL, NULL); + if (FAILED(hr)) + { + continue; + } + + if (ret.vt == VT_EMPTY) + { + /* probably, the handler has not been implemeted*/ + continue; + } + + hr = ret.ChangeType (VT_I4); + if (FAILED(hr)) + { + /* TODO: set the error code properly... */ + /* invalid value returned... */ + return -1; + } + + return ret.lVal; + } + + return -1; + } + + INT Fire_WriteExtio (IAwkExtio* extio, IBuffer* buf) + { + T* pT = static_cast(this); + int i, nconns = m_vec.GetSize(); + CComVariant args[2], ret; + + for (i = 0; i < nconns; i++) + { + pT->Lock(); + CComPtr sp = m_vec.GetAt(i); + pT->Unlock(); + + IDispatch* pDispatch = + reinterpret_cast(sp.p); + if (pDispatch == NULL) continue; + + VariantClear (&ret); + VariantClear (&args[0]); + VariantClear (&args[1]); + + args[1] = (IUnknown*)extio; + args[0] = (IUnknown*)buf; + + DISPPARAMS disp = { args, NULL, 2, 0 }; + HRESULT hr = pDispatch->Invoke ( + 0x8, IID_NULL, LOCALE_USER_DEFAULT, + DISPATCH_METHOD, &disp, &ret, NULL, NULL); + if (FAILED(hr)) + { + continue; + } + + if (ret.vt == VT_EMPTY) + { + /* probably, the handler has not been implemeted*/ + continue; + } + + hr = ret.ChangeType (VT_I4); + if (FAILED(hr)) + { + /* TODO: set the error code properly... */ + /* invalid value returned... */ + return -1; + } + + return ret.lVal; + } + + return -1; + } + + + INT Fire_FlushExtio (IAwkExtio* extio) + { + T* pT = static_cast(this); + int i, nconns = m_vec.GetSize(); + CComVariant args[1], ret; + + for (i = 0; i < nconns; i++) + { + pT->Lock(); + CComPtr sp = m_vec.GetAt(i); + pT->Unlock(); + + IDispatch* pDispatch = + reinterpret_cast(sp.p); + if (pDispatch == NULL) continue; + + VariantClear (&ret); + VariantClear (&args[0]); + + args[0] = (IUnknown*)extio; + + DISPPARAMS disp = { args, NULL, 1, 0 }; + HRESULT hr = pDispatch->Invoke ( + 0x9, IID_NULL, LOCALE_USER_DEFAULT, + DISPATCH_METHOD, &disp, &ret, NULL, NULL); + if (FAILED(hr)) continue; + + if (ret.vt == VT_EMPTY) + { + /* probably, the handler has not been implemeted*/ + continue; + } + + hr = ret.ChangeType (VT_I4); + if (FAILED(hr)) + { + /* TODO: set the error code properly... */ + /* invalid value returned... */ + return -1; + } + + return ret.lVal; + } + + return -1; + } + + INT Fire_NextExtio (IAwkExtio* extio) + { + T* pT = static_cast(this); + int i, nconns = m_vec.GetSize(); + CComVariant args[1], ret; + + for (i = 0; i < nconns; i++) + { + pT->Lock(); + CComPtr sp = m_vec.GetAt(i); + pT->Unlock(); + + IDispatch* pDispatch = + reinterpret_cast(sp.p); + if (pDispatch == NULL) continue; + + VariantClear (&ret); + VariantClear (&args[0]); + + args[0] = (IUnknown*)extio; + + DISPPARAMS disp = { args, NULL, 1, 0 }; + HRESULT hr = pDispatch->Invoke ( + 0xA, IID_NULL, LOCALE_USER_DEFAULT, + DISPATCH_METHOD, &disp, &ret, NULL, NULL); + if (FAILED(hr)) continue; + + if (ret.vt == VT_EMPTY) + { + /* probably, the handler has not been implemeted*/ + continue; + } + + hr = ret.ChangeType (VT_I4); + if (FAILED(hr)) + { + /* TODO: set the error code properly... */ + /* invalid value returned... */ + return -1; + } + + return ret.lVal; + } + + return -1; + } + + int Fire_HandleFunction ( + ase_awk_run_t* run, BSTR name, SAFEARRAY* argarray, ase_awk_val_t** retv) + { + T* pT = static_cast(this); + int i, nconns = m_vec.GetSize(); + CComVariant ret; + VARIANT args[2]; + ase_awk_val_t* v; + + VariantInit (&args[0]); + VariantInit (&args[1]); + + args[1].vt = VT_BSTR; + args[1].bstrVal = name; + + args[0].vt = VT_ARRAY | VT_VARIANT; + args[0].parray = argarray; + + for (i = 0; i < nconns; i++) + { + pT->Lock(); + CComPtr sp = m_vec.GetAt(i); + pT->Unlock(); + + IDispatch* pDispatch = + reinterpret_cast(sp.p); + if (pDispatch == NULL) continue; + + VariantClear (&ret); + + DISPPARAMS disp = { args, NULL, 2, 0 }; + HRESULT hr = pDispatch->Invoke ( + 0xB, IID_NULL, LOCALE_USER_DEFAULT, + DISPATCH_METHOD, &disp, &ret, NULL, NULL); + if (FAILED(hr)) continue; + + if (ret.vt == VT_EMPTY) + { + /* probably, the handler has not been implemeted*/ + continue; + } + + VariantClear (&args[1]); + VariantClear (&args[0]); + + if (ret.vt == VT_I1) + v = ase_awk_makeintval (run, ret.cVal); + else if (ret.vt == VT_I2) + v = ase_awk_makeintval (run, ret.iVal); + else if (ret.vt == VT_I4) + v = ase_awk_makeintval (run, ret.lVal); + else if (ret.vt == VT_I8) + v = ase_awk_makeintval (run, ret.llVal); + else if (ret.vt == VT_UI1) + v = ase_awk_makeintval (run, ret.bVal); + else if (ret.vt == VT_UI2) + v = ase_awk_makeintval (run, ret.uiVal); + else if (ret.vt == VT_UI4) + v = ase_awk_makeintval (run, ret.ulVal); + else if (ret.vt == VT_UI8) + v = ase_awk_makeintval (run, ret.ullVal); + else if (ret.vt == VT_INT) + v = ase_awk_makeintval (run, ret.intVal); + else if (ret.vt == VT_UINT) + v = ase_awk_makeintval (run, ret.uintVal); + else if (ret.vt == VT_BOOL) + v = ase_awk_makeintval (run, ((ret.boolVal == 0)? 0: 1)); + else if (ret.vt == VT_R4) + v = ase_awk_makerealval (run, ret.fltVal); + else if (ret.vt == VT_R8) + v = ase_awk_makerealval (run, ret.dblVal); + else if (ret.vt == VT_BSTR) + v = ase_awk_makestrval (run, ret.bstrVal, SysStringLen(ret.bstrVal)); + else if (ret.vt == VT_NULL) + + v = ase_awk_val_nil; + else return 3; /* wrong return value */ + + if (v == ASE_NULL) return 1; /* out of memory */ + + *retv = v; + return 0; /* success */ + } + + VariantClear (&args[1]); + VariantClear (&args[0]); + return 2; /* no proper handler */ + } + + INT Fire_OnClose () + { + T* pT = static_cast(this); + int i, nconns = m_vec.GetSize(); + CComVariant ret; + + for (i = 0; i < nconns; i++) + { + pT->Lock(); + CComPtr sp = m_vec.GetAt(i); + pT->Unlock(); + + IDispatch* pDispatch = reinterpret_cast(sp.p); + if (pDispatch == NULL) continue; + + VariantClear (&ret); + + HRESULT hr = pDispatch->Invoke( + 0xC, IID_NULL, LOCALE_USER_DEFAULT, + DISPATCH_METHOD, NULL, &ret, NULL, NULL); + + if (FAILED(hr)) continue; + if (ret.vt == VT_EMPTY) continue; + + hr = ret.ChangeType (VT_I4); + if (FAILED(hr)) + { + /* TODO: set the error code properly... */ + /* invalid value returned... */ + return -1; + } + + return ret.lVal; + } + + return -1; + } +}; + +#endif diff --git a/ase/com/resource.h b/ase/com/resource.h new file mode 100644 index 00000000..77c83f7a --- /dev/null +++ b/ase/com/resource.h @@ -0,0 +1,19 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by asecom.rc +// +#define IDS_PROJNAME 100 +#define IDR_AWK 101 +#define IDR_AWKEXTIO 102 +#define IDR_BUFFER 103 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 201 +#define _APS_NEXT_COMMAND_VALUE 32768 +#define _APS_NEXT_CONTROL_VALUE 201 +#define _APS_NEXT_SYMED_VALUE 105 +#endif +#endif diff --git a/ase/com/stdafx.cpp b/ase/com/stdafx.cpp new file mode 100644 index 00000000..f12bb427 --- /dev/null +++ b/ase/com/stdafx.cpp @@ -0,0 +1,18 @@ +/* + * $Id: stdafx.cpp,v 1.3 2007/04/30 06:04:43 bacon Exp $ + * + * {License} + */ + +// stdafx.cpp : source file that includes just the standard includes +// stdafx.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + +#ifdef _ATL_STATIC_REGISTRY +#include +#include +#endif + +#include diff --git a/ase/com/stdafx.h b/ase/com/stdafx.h new file mode 100644 index 00000000..90a5db85 --- /dev/null +++ b/ase/com/stdafx.h @@ -0,0 +1,29 @@ +/* + * $Id: stdafx.h,v 1.3 2007/04/30 06:04:43 bacon Exp $ + * + * {License} + */ + +#ifndef _ASE_COM_STDAFX_H_ +#define _ASE_COM_STDAFX_H_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#define STRICT +#ifndef _WIN32_WINNT +#define _WIN32_WINNT 0x0400 +#endif +#define _ATL_APARTMENT_THREADED + +#include +//You may derive a class from CComModule and use it if you want to override +//something, but do not change the name of _Module +extern CComModule _Module; +#include + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif diff --git a/ase/config/config.guess b/ase/config/config.guess new file mode 100755 index 00000000..2fc3acce --- /dev/null +++ b/ase/config/config.guess @@ -0,0 +1,1411 @@ +#! /bin/sh +# Attempt to guess a canonical system name. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002, 2003 Free Software Foundation, Inc. + +timestamp='2003-06-17' + +# This file 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. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Originally written by Per Bothner . +# Please send patches to . Submit a context +# diff and a properly formatted ChangeLog entry. +# +# This script attempts to guess a canonical system name similar to +# config.sub. If it succeeds, it prints the system name on stdout, and +# exits with 0. Otherwise, it exits with 1. +# +# The plan is that this can be called by configure scripts if you +# don't specify an explicit build system type. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] + +Output the configuration name of the system \`$me' is run on. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.guess ($timestamp) + +Originally written by Per Bothner. +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit 0 ;; + --version | -v ) + echo "$version" ; exit 0 ;; + --help | --h* | -h ) + echo "$usage"; exit 0 ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" >&2 + exit 1 ;; + * ) + break ;; + esac +done + +if test $# != 0; then + echo "$me: too many arguments$help" >&2 + exit 1 +fi + +trap 'exit 1' 1 2 15 + +# CC_FOR_BUILD -- compiler used by this script. Note that the use of a +# compiler to aid in system detection is discouraged as it requires +# temporary files to be created and, as you can see below, it is a +# headache to deal with in a portable fashion. + +# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still +# use `HOST_CC' if defined, but it is deprecated. + +# Portable tmp directory creation inspired by the Autoconf team. + +set_cc_for_build=' +trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; +trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; +: ${TMPDIR=/tmp} ; + { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || + { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || + { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; +dummy=$tmp/dummy ; +tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; +case $CC_FOR_BUILD,$HOST_CC,$CC in + ,,) echo "int x;" > $dummy.c ; + for c in cc gcc c89 c99 ; do + if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then + CC_FOR_BUILD="$c"; break ; + fi ; + done ; + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found ; + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; +esac ;' + +# This is needed to find uname on a Pyramid OSx when run in the BSD universe. +# (ghazi@noc.rutgers.edu 1994-08-24) +if (test -f /.attbin/uname) >/dev/null 2>&1 ; then + PATH=$PATH:/.attbin ; export PATH +fi + +UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown +UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown + +## for Red Hat Linux +if test -f /etc/redhat-release ; then + VENDOR=redhat ; +else + VENDOR= ; +fi + +# Note: order is significant - the case branches are not exclusive. + +case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in + *:NetBSD:*:*) + # NetBSD (nbsd) targets should (where applicable) match one or + # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, + # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently + # switched to ELF, *-*-netbsd* would select the old + # object file format. This provides both forward + # compatibility and a consistent mechanism for selecting the + # object file format. + # + # Note: NetBSD doesn't particularly care about the vendor + # portion of the name. We always set it to "unknown". + sysctl="sysctl -n hw.machine_arch" + UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ + /usr/sbin/$sysctl 2>/dev/null || echo unknown)` + case "${UNAME_MACHINE_ARCH}" in + armeb) machine=armeb-unknown ;; + arm*) machine=arm-unknown ;; + sh3el) machine=shl-unknown ;; + sh3eb) machine=sh-unknown ;; + *) machine=${UNAME_MACHINE_ARCH}-unknown ;; + esac + # The Operating System including object format, if it has switched + # to ELF recently, or will in the future. + case "${UNAME_MACHINE_ARCH}" in + arm*|i386|m68k|ns32k|sh3*|sparc|vax) + eval $set_cc_for_build + if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep __ELF__ >/dev/null + then + # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). + # Return netbsd for either. FIX? + os=netbsd + else + os=netbsdelf + fi + ;; + *) + os=netbsd + ;; + esac + # The OS release + # Debian GNU/NetBSD machines have a different userland, and + # thus, need a distinct triplet. However, they do not need + # kernel version information, so it can be replaced with a + # suitable tag, in the style of linux-gnu. + case "${UNAME_VERSION}" in + Debian*) + release='-gnu' + ;; + *) + release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + ;; + esac + # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: + # contains redundant information, the shorter form: + # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. + echo "${machine}-${os}${release}" + exit 0 ;; + amiga:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + arc:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + hp300:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mac68k:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + macppc:OpenBSD:*:*) + echo powerpc-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvme68k:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvme88k:OpenBSD:*:*) + echo m88k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvmeppc:OpenBSD:*:*) + echo powerpc-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + pmax:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + sgi:OpenBSD:*:*) + echo mipseb-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + sun3:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + wgrisc:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + *:OpenBSD:*:*) + echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + alpha:OSF1:*:*) + if test $UNAME_RELEASE = "V4.0"; then + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` + fi + # According to Compaq, /usr/sbin/psrinfo has been available on + # OSF/1 and Tru64 systems produced since 1995. I hope that + # covers most systems running today. This code pipes the CPU + # types through head -n 1, so we only detect the type of CPU 0. + ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` + case "$ALPHA_CPU_TYPE" in + "EV4 (21064)") + UNAME_MACHINE="alpha" ;; + "EV4.5 (21064)") + UNAME_MACHINE="alpha" ;; + "LCA4 (21066/21068)") + UNAME_MACHINE="alpha" ;; + "EV5 (21164)") + UNAME_MACHINE="alphaev5" ;; + "EV5.6 (21164A)") + UNAME_MACHINE="alphaev56" ;; + "EV5.6 (21164PC)") + UNAME_MACHINE="alphapca56" ;; + "EV5.7 (21164PC)") + UNAME_MACHINE="alphapca57" ;; + "EV6 (21264)") + UNAME_MACHINE="alphaev6" ;; + "EV6.7 (21264A)") + UNAME_MACHINE="alphaev67" ;; + "EV6.8CB (21264C)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8AL (21264B)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8CX (21264D)") + UNAME_MACHINE="alphaev68" ;; + "EV6.9A (21264/EV69A)") + UNAME_MACHINE="alphaev69" ;; + "EV7 (21364)") + UNAME_MACHINE="alphaev7" ;; + "EV7.9 (21364A)") + UNAME_MACHINE="alphaev79" ;; + esac + # A Vn.n version is a released version. + # A Tn.n version is a released field test version. + # A Xn.n version is an unreleased experimental baselevel. + # 1.2 uses "1.2" for uname -r. + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + exit 0 ;; + Alpha*:OpenVMS:*:*) + echo alpha-hp-vms + exit 0 ;; + Alpha\ *:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # Should we change UNAME_MACHINE based on the output of uname instead + # of the specific Alpha model? + echo alpha-pc-interix + exit 0 ;; + 21064:Windows_NT:50:3) + echo alpha-dec-winnt3.5 + exit 0 ;; + Amiga*:UNIX_System_V:4.0:*) + echo m68k-unknown-sysv4 + exit 0;; + *:[Aa]miga[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-amigaos + exit 0 ;; + *:[Mm]orph[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-morphos + exit 0 ;; + *:OS/390:*:*) + echo i370-ibm-openedition + exit 0 ;; + arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) + echo arm-acorn-riscix${UNAME_RELEASE} + exit 0;; + SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) + echo hppa1.1-hitachi-hiuxmpp + exit 0;; + Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) + # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. + if test "`(/bin/universe) 2>/dev/null`" = att ; then + echo pyramid-pyramid-sysv3 + else + echo pyramid-pyramid-bsd + fi + exit 0 ;; + NILE*:*:*:dcosx) + echo pyramid-pyramid-svr4 + exit 0 ;; + DRS?6000:unix:4.0:6*) + echo sparc-icl-nx6 + exit 0 ;; + DRS?6000:UNIX_SV:4.2*:7*) + case `/usr/bin/uname -p` in + sparc) echo sparc-icl-nx7 && exit 0 ;; + esac ;; + sun4H:SunOS:5.*:*) + echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) + echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + i86pc:SunOS:5.*:*) + echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + sun4*:SunOS:6*:*) + # According to config.sub, this is the proper way to canonicalize + # SunOS6. Hard to guess exactly what SunOS6 will be like, but + # it's likely to be more like Solaris than SunOS4. + echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + sun4*:SunOS:*:*) + case "`/usr/bin/arch -k`" in + Series*|S4*) + UNAME_RELEASE=`uname -v` + ;; + esac + # Japanese Language versions have a version number like `4.1.3-JL'. + echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + exit 0 ;; + sun3*:SunOS:*:*) + echo m68k-sun-sunos${UNAME_RELEASE} + exit 0 ;; + sun*:*:4.2BSD:*) + UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 + case "`/bin/arch`" in + sun3) + echo m68k-sun-sunos${UNAME_RELEASE} + ;; + sun4) + echo sparc-sun-sunos${UNAME_RELEASE} + ;; + esac + exit 0 ;; + aushp:SunOS:*:*) + echo sparc-auspex-sunos${UNAME_RELEASE} + exit 0 ;; + # The situation for MiNT is a little confusing. The machine name + # can be virtually everything (everything which is not + # "atarist" or "atariste" at least should have a processor + # > m68000). The system name ranges from "MiNT" over "FreeMiNT" + # to the lowercase version "mint" (or "freemint"). Finally + # the system name "TOS" denotes a system which is actually not + # MiNT. But MiNT is downward compatible to TOS, so this should + # be no problem. + atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit 0 ;; + atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit 0 ;; + *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit 0 ;; + milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) + echo m68k-milan-mint${UNAME_RELEASE} + exit 0 ;; + hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) + echo m68k-hades-mint${UNAME_RELEASE} + exit 0 ;; + *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) + echo m68k-unknown-mint${UNAME_RELEASE} + exit 0 ;; + powerpc:machten:*:*) + echo powerpc-apple-machten${UNAME_RELEASE} + exit 0 ;; + RISC*:Mach:*:*) + echo mips-dec-mach_bsd4.3 + exit 0 ;; + RISC*:ULTRIX:*:*) + echo mips-dec-ultrix${UNAME_RELEASE} + exit 0 ;; + VAX*:ULTRIX*:*:*) + echo vax-dec-ultrix${UNAME_RELEASE} + exit 0 ;; + 2020:CLIX:*:* | 2430:CLIX:*:*) + echo clipper-intergraph-clix${UNAME_RELEASE} + exit 0 ;; + mips:*:*:UMIPS | mips:*:*:RISCos) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c +#ifdef __cplusplus +#include /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif + #if defined (host_mips) && defined (MIPSEB) + #if defined (SYSTYPE_SYSV) + printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_SVR4) + printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) + printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + #endif + #endif + exit (-1); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c \ + && $dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ + && exit 0 + echo mips-mips-riscos${UNAME_RELEASE} + exit 0 ;; + Motorola:PowerMAX_OS:*:*) + echo powerpc-motorola-powermax + exit 0 ;; + Motorola:*:4.3:PL8-*) + echo powerpc-harris-powermax + exit 0 ;; + Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) + echo powerpc-harris-powermax + exit 0 ;; + Night_Hawk:Power_UNIX:*:*) + echo powerpc-harris-powerunix + exit 0 ;; + m88k:CX/UX:7*:*) + echo m88k-harris-cxux7 + exit 0 ;; + m88k:*:4*:R4*) + echo m88k-motorola-sysv4 + exit 0 ;; + m88k:*:3*:R3*) + echo m88k-motorola-sysv3 + exit 0 ;; + AViiON:dgux:*:*) + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + then + if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ + [ ${TARGET_BINARY_INTERFACE}x = x ] + then + echo m88k-dg-dgux${UNAME_RELEASE} + else + echo m88k-dg-dguxbcs${UNAME_RELEASE} + fi + else + echo i586-dg-dgux${UNAME_RELEASE} + fi + exit 0 ;; + M88*:DolphinOS:*:*) # DolphinOS (SVR3) + echo m88k-dolphin-sysv3 + exit 0 ;; + M88*:*:R3*:*) + # Delta 88k system running SVR3 + echo m88k-motorola-sysv3 + exit 0 ;; + XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) + echo m88k-tektronix-sysv3 + exit 0 ;; + Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) + echo m68k-tektronix-bsd + exit 0 ;; + *:IRIX*:*:*) + echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + exit 0 ;; + ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. + echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id + exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + i*86:AIX:*:*) + echo i386-ibm-aix + exit 0 ;; + ia64:AIX:*:*) + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} + exit 0 ;; + *:AIX:2:3) + if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + + main() + { + if (!__power_pc()) + exit(1); + puts("powerpc-ibm-aix3.2.5"); + exit(0); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0 + echo rs6000-ibm-aix3.2.5 + elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then + echo rs6000-ibm-aix3.2.4 + else + echo rs6000-ibm-aix3.2 + fi + exit 0 ;; + *:AIX:*:[45]) + IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` + if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then + IBM_ARCH=rs6000 + else + IBM_ARCH=powerpc + fi + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${IBM_ARCH}-ibm-aix${IBM_REV} + exit 0 ;; + *:AIX:*:*) + echo rs6000-ibm-aix + exit 0 ;; + ibmrt:4.4BSD:*|romp-ibm:BSD:*) + echo romp-ibm-bsd4.4 + exit 0 ;; + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and + echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + exit 0 ;; # report: romp-ibm BSD 4.3 + *:BOSX:*:*) + echo rs6000-bull-bosx + exit 0 ;; + DPX/2?00:B.O.S.:*:*) + echo m68k-bull-sysv3 + exit 0 ;; + 9000/[34]??:4.3bsd:1.*:*) + echo m68k-hp-bsd + exit 0 ;; + hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) + echo m68k-hp-bsd4.4 + exit 0 ;; + 9000/[34678]??:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + case "${UNAME_MACHINE}" in + 9000/31? ) HP_ARCH=m68000 ;; + 9000/[34]?? ) HP_ARCH=m68k ;; + 9000/[678][0-9][0-9]) + if [ -x /usr/bin/getconf ]; then + sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case "${sc_cpu_version}" in + 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 + 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case "${sc_kernel_bits}" in + 32) HP_ARCH="hppa2.0n" ;; + 64) HP_ARCH="hppa2.0w" ;; + '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 + esac ;; + esac + fi + if [ "${HP_ARCH}" = "" ]; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + + #define _HPUX_SOURCE + #include + #include + + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); + + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } +EOF + (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + test -z "$HP_ARCH" && HP_ARCH=hppa + fi ;; + esac + if [ ${HP_ARCH} = "hppa2.0w" ] + then + # avoid double evaluation of $set_cc_for_build + test -n "$CC_FOR_BUILD" || eval $set_cc_for_build + if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E -) | grep __LP64__ >/dev/null + then + HP_ARCH="hppa2.0w" + else + HP_ARCH="hppa64" + fi + fi + echo ${HP_ARCH}-hp-hpux${HPUX_REV} + exit 0 ;; + ia64:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux${HPUX_REV} + exit 0 ;; + 3050*:HI-UX:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + int + main () + { + long cpu = sysconf (_SC_CPU_VERSION); + /* The order matters, because CPU_IS_HP_MC68K erroneously returns + true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct + results, however. */ + if (CPU_IS_PA_RISC (cpu)) + { + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; + case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; + default: puts ("hppa-hitachi-hiuxwe2"); break; + } + } + else if (CPU_IS_HP_MC68K (cpu)) + puts ("m68k-hitachi-hiuxwe2"); + else puts ("unknown-hitachi-hiuxwe2"); + exit (0); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0 + echo unknown-hitachi-hiuxwe2 + exit 0 ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + echo hppa1.1-hp-bsd + exit 0 ;; + 9000/8??:4.3bsd:*:*) + echo hppa1.0-hp-bsd + exit 0 ;; + *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) + echo hppa1.0-hp-mpeix + exit 0 ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + echo hppa1.1-hp-osf + exit 0 ;; + hp8??:OSF1:*:*) + echo hppa1.0-hp-osf + exit 0 ;; + i*86:OSF1:*:*) + if [ -x /usr/sbin/sysversion ] ; then + echo ${UNAME_MACHINE}-unknown-osf1mk + else + echo ${UNAME_MACHINE}-unknown-osf1 + fi + exit 0 ;; + parisc*:Lites*:*:*) + echo hppa1.1-hp-lites + exit 0 ;; + C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) + echo c1-convex-bsd + exit 0 ;; + C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit 0 ;; + C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) + echo c34-convex-bsd + exit 0 ;; + C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) + echo c38-convex-bsd + exit 0 ;; + C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) + echo c4-convex-bsd + exit 0 ;; + CRAY*Y-MP:*:*:*) + echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*[A-Z]90:*:*:*) + echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ + -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ + -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*TS:*:*:*) + echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*T3E:*:*:*) + echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*SV1:*:*:*) + echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + *:UNICOS/mp:*:*) + echo nv1-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) + FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit 0 ;; + i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) + echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + exit 0 ;; + sparc*:BSD/OS:*:*) + echo sparc-unknown-bsdi${UNAME_RELEASE} + exit 0 ;; + *:BSD/OS:*:*) + echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} + exit 0 ;; + *:FreeBSD:*:*|*:GNU/FreeBSD:*:*) + # Determine whether the default compiler uses glibc. + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + #if __GLIBC__ >= 2 + LIBC=gnu + #else + LIBC= + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` + echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`${LIBC:+-$LIBC} + exit 0 ;; + i*:CYGWIN*:*) + echo ${UNAME_MACHINE}-pc-cygwin + exit 0 ;; + i*:MINGW*:*) + echo ${UNAME_MACHINE}-pc-mingw32 + exit 0 ;; + i*:PW*:*) + echo ${UNAME_MACHINE}-pc-pw32 + exit 0 ;; + x86:Interix*:[34]*) + echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//' + exit 0 ;; + [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) + echo i${UNAME_MACHINE}-pc-mks + exit 0 ;; + i*:Windows_NT*:* | Pentium*:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we + # UNAME_MACHINE based on the output of uname instead of i386? + echo i586-pc-interix + exit 0 ;; + i*:UWIN*:*) + echo ${UNAME_MACHINE}-pc-uwin + exit 0 ;; + p*:CYGWIN*:*) + echo powerpcle-unknown-cygwin + exit 0 ;; + prep*:SunOS:5.*:*) + echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + *:GNU:*:*) + echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + exit 0 ;; + i*86:Minix:*:*) + echo ${UNAME_MACHINE}-pc-minix + exit 0 ;; + arm*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + cris:Linux:*:*) + echo cris-axis-linux-gnu + exit 0 ;; + ia64:Linux:*:*) + echo ${UNAME_MACHINE}-${VENDOR:-unknown}-linux-gnu + exit 0 ;; + m68*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + mips:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef mips + #undef mipsel + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=mipsel + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=mips + #else + CPU= + #endif + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` + test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0 + ;; + mips64:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef mips64 + #undef mips64el + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=mips64el + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=mips64 + #else + CPU= + #endif + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` + test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0 + ;; + ppc:Linux:*:*) + echo powerpc-${VENDOR:-unknown}-linux-gnu + exit 0 ;; + ppc64:Linux:*:*) + echo powerpc64-${VENDOR:-unknown}-linux-gnu + exit 0 ;; + alpha:Linux:*:*) + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + EV5) UNAME_MACHINE=alphaev5 ;; + EV56) UNAME_MACHINE=alphaev56 ;; + PCA56) UNAME_MACHINE=alphapca56 ;; + PCA57) UNAME_MACHINE=alphapca56 ;; + EV6) UNAME_MACHINE=alphaev6 ;; + EV67) UNAME_MACHINE=alphaev67 ;; + EV68*) UNAME_MACHINE=alphaev68 ;; + esac + objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null + if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi + echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} + exit 0 ;; + parisc:Linux:*:* | hppa:Linux:*:*) + # Look for CPU level + case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in + PA7*) echo hppa1.1-unknown-linux-gnu ;; + PA8*) echo hppa2.0-unknown-linux-gnu ;; + *) echo hppa-unknown-linux-gnu ;; + esac + exit 0 ;; + parisc64:Linux:*:* | hppa64:Linux:*:*) + echo hppa64-unknown-linux-gnu + exit 0 ;; + s390:Linux:*:* | s390x:Linux:*:*) + echo ${UNAME_MACHINE}-${VENDOR:-ibm}-linux-gnu + exit 0 ;; + sh64*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + sh*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + sparc:Linux:*:* | sparc64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + x86_64:Linux:*:*) + echo x86_64-${VENDOR:-unknown}-linux-gnu + exit 0 ;; + i*86:Linux:*:*) + # The BFD linker knows what the default object file format is, so + # first see if it will tell us. cd to the root directory to prevent + # problems with other programs or directories called `ld' in the path. + # Set LC_ALL=C to ensure ld outputs messages in English. + ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ + | sed -ne '/supported targets:/!d + s/[ ][ ]*/ /g + s/.*supported targets: *// + s/ .*// + p'` + case "$ld_supported_targets" in + elf32-i386) + TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" + ;; + a.out-i386-linux) + echo "${UNAME_MACHINE}-pc-linux-gnuaout" + exit 0 ;; + coff-i386) + echo "${UNAME_MACHINE}-pc-linux-gnucoff" + exit 0 ;; + "") + # Either a pre-BFD a.out linker (linux-gnuoldld) or + # one that does not give us useful --help. + echo "${UNAME_MACHINE}-pc-linux-gnuoldld" + exit 0 ;; + esac + # Determine whether the default compiler is a.out or elf + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + #ifdef __ELF__ + # ifdef __GLIBC__ + # if __GLIBC__ >= 2 + LIBC=gnu + # else + LIBC=gnulibc1 + # endif + # else + LIBC=gnulibc1 + # endif + #else + #ifdef __INTEL_COMPILER + LIBC=gnu + #else + LIBC=gnuaout + #endif + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` + test x"${LIBC}" != x && echo "${UNAME_MACHINE}-${VENDOR:-pc}-linux-${LIBC}" && exit 0 + test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0 + ;; + i*86:DYNIX/ptx:4*:*) + # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. + # earlier versions are messed up and put the nodename in both + # sysname and nodename. + echo i386-sequent-sysv4 + exit 0 ;; + i*86:UNIX_SV:4.2MP:2.*) + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, + # I just have to hope. -- rms. + # Use sysv4.2uw... so that sysv4* matches it. + echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + exit 0 ;; + i*86:OS/2:*:*) + # If we were able to find `uname', then EMX Unix compatibility + # is probably installed. + echo ${UNAME_MACHINE}-pc-os2-emx + exit 0 ;; + i*86:XTS-300:*:STOP) + echo ${UNAME_MACHINE}-unknown-stop + exit 0 ;; + i*86:atheos:*:*) + echo ${UNAME_MACHINE}-unknown-atheos + exit 0 ;; + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) + echo i386-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + i*86:*DOS:*:*) + echo ${UNAME_MACHINE}-pc-msdosdjgpp + exit 0 ;; + i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) + UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then + echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} + else + echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + fi + exit 0 ;; + i*86:*:5:[78]*) + case `/bin/uname -X | grep "^Machine"` in + *486*) UNAME_MACHINE=i486 ;; + *Pentium) UNAME_MACHINE=i586 ;; + *Pent*|*Celeron) UNAME_MACHINE=i686 ;; + esac + echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + exit 0 ;; + i*86:*:3.2:*) + if test -f /usr/options/cb.name; then + UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then + UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` + (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ + && UNAME_MACHINE=i586 + (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ + && UNAME_MACHINE=i686 + (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ + && UNAME_MACHINE=i686 + echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + else + echo ${UNAME_MACHINE}-pc-sysv32 + fi + exit 0 ;; + pc:*:*:*) + # Left here for compatibility: + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i386. + echo i386-pc-msdosdjgpp + exit 0 ;; + Intel:Mach:3*:*) + echo i386-pc-mach3 + exit 0 ;; + paragon:*:*:*) + echo i860-intel-osf1 + exit 0 ;; + i860:*:4.*:*) # i860-SVR4 + if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then + echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + else # Add other i860-SVR4 vendors below as they are discovered. + echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + fi + exit 0 ;; + mini*:CTIX:SYS*5:*) + # "miniframe" + echo m68010-convergent-sysv + exit 0 ;; + mc68k:UNIX:SYSTEM5:3.51m) + echo m68k-convergent-sysv + exit 0 ;; + M680?0:D-NIX:5.3:*) + echo m68k-diab-dnix + exit 0 ;; + M68*:*:R3V[567]*:*) + test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; + 3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0) + OS_REL='' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && echo i486-ncr-sysv4.3${OS_REL} && exit 0 + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; + 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && echo i486-ncr-sysv4 && exit 0 ;; + m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) + echo m68k-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + mc68030:UNIX_System_V:4.*:*) + echo m68k-atari-sysv4 + exit 0 ;; + TSUNAMI:LynxOS:2.*:*) + echo sparc-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + rs6000:LynxOS:2.*:*) + echo rs6000-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) + echo powerpc-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + SM[BE]S:UNIX_SV:*:*) + echo mips-dde-sysv${UNAME_RELEASE} + exit 0 ;; + RM*:ReliantUNIX-*:*:*) + echo mips-sni-sysv4 + exit 0 ;; + RM*:SINIX-*:*:*) + echo mips-sni-sysv4 + exit 0 ;; + *:SINIX-*:*:*) + if uname -p 2>/dev/null >/dev/null ; then + UNAME_MACHINE=`(uname -p) 2>/dev/null` + echo ${UNAME_MACHINE}-sni-sysv4 + else + echo ns32k-sni-sysv + fi + exit 0 ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says + echo i586-unisys-sysv4 + exit 0 ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes . + # How about differentiating between stratus architectures? -djm + echo hppa1.1-stratus-sysv4 + exit 0 ;; + *:*:*:FTX*) + # From seanf@swdc.stratus.com. + echo i860-stratus-sysv4 + exit 0 ;; + *:VOS:*:*) + # From Paul.Green@stratus.com. + echo hppa1.1-stratus-vos + exit 0 ;; + mc68*:A/UX:*:*) + echo m68k-apple-aux${UNAME_RELEASE} + exit 0 ;; + news*:NEWS-OS:6*:*) + echo mips-sony-newsos6 + exit 0 ;; + R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) + if [ -d /usr/nec ]; then + echo mips-nec-sysv${UNAME_RELEASE} + else + echo mips-unknown-sysv${UNAME_RELEASE} + fi + exit 0 ;; + BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. + echo powerpc-be-beos + exit 0 ;; + BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. + echo powerpc-apple-beos + exit 0 ;; + BePC:BeOS:*:*) # BeOS running on Intel PC compatible. + echo i586-pc-beos + exit 0 ;; + SX-4:SUPER-UX:*:*) + echo sx4-nec-superux${UNAME_RELEASE} + exit 0 ;; + SX-5:SUPER-UX:*:*) + echo sx5-nec-superux${UNAME_RELEASE} + exit 0 ;; + SX-6:SUPER-UX:*:*) + echo sx6-nec-superux${UNAME_RELEASE} + exit 0 ;; + Power*:Rhapsody:*:*) + echo powerpc-apple-rhapsody${UNAME_RELEASE} + exit 0 ;; + *:Rhapsody:*:*) + echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} + exit 0 ;; + *:Darwin:*:*) + case `uname -p` in + *86) UNAME_PROCESSOR=i686 ;; + powerpc) UNAME_PROCESSOR=powerpc ;; + esac + echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} + exit 0 ;; + *:procnto*:*:* | *:QNX:[0123456789]*:*) + UNAME_PROCESSOR=`uname -p` + if test "$UNAME_PROCESSOR" = "x86"; then + UNAME_PROCESSOR=i386 + UNAME_MACHINE=pc + fi + echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} + exit 0 ;; + *:QNX:*:4*) + echo i386-pc-qnx + exit 0 ;; + NSR-[DGKLNPTVW]:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk${UNAME_RELEASE} + exit 0 ;; + *:NonStop-UX:*:*) + echo mips-compaq-nonstopux + exit 0 ;; + BS2000:POSIX*:*:*) + echo bs2000-siemens-sysv + exit 0 ;; + DS/*:UNIX_System_V:*:*) + echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} + exit 0 ;; + *:Plan9:*:*) + # "uname -m" is not consistent, so use $cputype instead. 386 + # is converted to i386 for consistency with other x86 + # operating systems. + if test "$cputype" = "386"; then + UNAME_MACHINE=i386 + else + UNAME_MACHINE="$cputype" + fi + echo ${UNAME_MACHINE}-unknown-plan9 + exit 0 ;; + *:TOPS-10:*:*) + echo pdp10-unknown-tops10 + exit 0 ;; + *:TENEX:*:*) + echo pdp10-unknown-tenex + exit 0 ;; + KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) + echo pdp10-dec-tops20 + exit 0 ;; + XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) + echo pdp10-xkl-tops20 + exit 0 ;; + *:TOPS-20:*:*) + echo pdp10-unknown-tops20 + exit 0 ;; + *:ITS:*:*) + echo pdp10-unknown-its + exit 0 ;; + SEI:*:*:SEIUX) + echo mips-sei-seiux${UNAME_RELEASE} + exit 0 ;; +esac + +#echo '(No uname command or uname output not recognized.)' 1>&2 +#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 + +eval $set_cc_for_build +cat >$dummy.c < +# include +#endif +main () +{ +#if defined (sony) +#if defined (MIPSEB) + /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, + I don't know.... */ + printf ("mips-sony-bsd\n"); exit (0); +#else +#include + printf ("m68k-sony-newsos%s\n", +#ifdef NEWSOS4 + "4" +#else + "" +#endif + ); exit (0); +#endif +#endif + +#if defined (__arm) && defined (__acorn) && defined (__unix) + printf ("arm-acorn-riscix"); exit (0); +#endif + +#if defined (hp300) && !defined (hpux) + printf ("m68k-hp-bsd\n"); exit (0); +#endif + +#if defined (NeXT) +#if !defined (__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; + if (version < 4) + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + else + printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); + exit (0); +#endif + +#if defined (MULTIMAX) || defined (n16) +#if defined (UMAXV) + printf ("ns32k-encore-sysv\n"); exit (0); +#else +#if defined (CMU) + printf ("ns32k-encore-mach\n"); exit (0); +#else + printf ("ns32k-encore-bsd\n"); exit (0); +#endif +#endif +#endif + +#if defined (__386BSD__) + printf ("i386-pc-bsd\n"); exit (0); +#endif + +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); +#endif +#if defined (ns32000) + printf ("ns32k-sequent-dynix\n"); exit (0); +#endif +#endif + +#if defined (_SEQUENT_) + struct utsname un; + + uname(&un); + + if (strncmp(un.version, "V2", 2) == 0) { + printf ("i386-sequent-ptx2\n"); exit (0); + } + if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ + printf ("i386-sequent-ptx1\n"); exit (0); + } + printf ("i386-sequent-ptx\n"); exit (0); + +#endif + +#if defined (vax) +# if !defined (ultrix) +# include +# if defined (BSD) +# if BSD == 43 + printf ("vax-dec-bsd4.3\n"); exit (0); +# else +# if BSD == 199006 + printf ("vax-dec-bsd4.3reno\n"); exit (0); +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# endif +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# else + printf ("vax-dec-ultrix\n"); exit (0); +# endif +#endif + +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + + exit (1); +} +EOF + +$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && $dummy && exit 0 + +# Apollos put the system type in the environment. + +test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } + +# Convex versions that predate uname can use getsysinfo(1) + +if [ -x /usr/convex/getsysinfo ] +then + case `getsysinfo -f cpu_type` in + c1*) + echo c1-convex-bsd + exit 0 ;; + c2*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit 0 ;; + c34*) + echo c34-convex-bsd + exit 0 ;; + c38*) + echo c38-convex-bsd + exit 0 ;; + c4*) + echo c4-convex-bsd + exit 0 ;; + esac +fi + +cat >&2 < in order to provide the needed +information to handle your system. + +config.guess timestamp = $timestamp + +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null` + +hostinfo = `(hostinfo) 2>/dev/null` +/bin/universe = `(/bin/universe) 2>/dev/null` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` +/bin/arch = `(/bin/arch) 2>/dev/null` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` + +UNAME_MACHINE = ${UNAME_MACHINE} +UNAME_RELEASE = ${UNAME_RELEASE} +UNAME_SYSTEM = ${UNAME_SYSTEM} +UNAME_VERSION = ${UNAME_VERSION} +EOF + +exit 1 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/ase/config/config.sub b/ase/config/config.sub new file mode 100755 index 00000000..7cee3d6e --- /dev/null +++ b/ase/config/config.sub @@ -0,0 +1,1500 @@ +#! /bin/sh +# Configuration validation subroutine script. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002, 2003 Free Software Foundation, Inc. + +timestamp='2003-06-18' + +# This file is (in principle) common to ALL GNU software. +# The presence of a machine in this file suggests that SOME GNU software +# can handle that machine. It does not imply ALL GNU software can. +# +# This file 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. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Please send patches to . Submit a context +# diff and a properly formatted ChangeLog entry. +# +# Configuration subroutine to validate and canonicalize a configuration type. +# Supply the specified configuration type as an argument. +# If it is invalid, we print an error message on stderr and exit with code 1. +# Otherwise, we print the canonical config type on stdout and succeed. + +# This file is supposed to be the same for all GNU packages +# and recognize all the CPU types, system types and aliases +# that are meaningful with *any* GNU software. +# Each package is responsible for reporting which valid configurations +# it does not support. The user should be able to distinguish +# a failure to support a valid configuration from a meaningless +# configuration. + +# The goal of this file is to map all the various variations of a given +# machine specification into a single specification in the form: +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or in some cases, the newer four-part form: +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# It is wrong to echo any other type of specification. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] CPU-MFR-OPSYS + $0 [OPTION] ALIAS + +Canonicalize a configuration name. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.sub ($timestamp) + +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit 0 ;; + --version | -v ) + echo "$version" ; exit 0 ;; + --help | --h* | -h ) + echo "$usage"; exit 0 ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" + exit 1 ;; + + *local*) + # First pass through any local machine types. + echo $1 + exit 0;; + + * ) + break ;; + esac +done + +case $# in + 0) echo "$me: missing argument$help" >&2 + exit 1;; + 1) ;; + *) echo "$me: too many arguments$help" >&2 + exit 1;; +esac + +# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). +# Here we must recognize all the valid KERNEL-OS combinations. +maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` +case $maybe_os in + nto-qnx* | linux-gnu* | freebsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*) + os=-$maybe_os + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` + ;; + *) + basic_machine=`echo $1 | sed 's/-[^-]*$//'` + if [ $basic_machine != $1 ] + then os=`echo $1 | sed 's/.*-/-/'` + else os=; fi + ;; +esac + +### Let's recognize common machines as not being operating systems so +### that things like config.sub decstation-3100 work. We also +### recognize some manufacturers as not being operating systems, so we +### can provide default operating systems below. +case $os in + -sun*os*) + # Prevent following clause from handling this invalid input. + ;; + -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ + -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ + -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ + -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ + -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ + -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ + -apple | -axis) + os= + basic_machine=$1 + ;; + -sim | -cisco | -oki | -wec | -winbond) + os= + basic_machine=$1 + ;; + -scout) + ;; + -wrs) + os=-vxworks + basic_machine=$1 + ;; + -chorusos*) + os=-chorusos + basic_machine=$1 + ;; + -chorusrdb) + os=-chorusrdb + basic_machine=$1 + ;; + -hiux*) + os=-hiuxwe2 + ;; + -sco5) + os=-sco3.2v5 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco4) + os=-sco3.2v4 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2.[4-9]*) + os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2v[4-9]*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco*) + os=-sco3.2v2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -udk*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -isc) + os=-isc2.2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -clix*) + basic_machine=clipper-intergraph + ;; + -isc*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -lynx*) + os=-lynxos + ;; + -ptx*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + ;; + -windowsnt*) + os=`echo $os | sed -e 's/windowsnt/winnt/'` + ;; + -psos*) + os=-psos + ;; + -mint | -mint[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; +esac + +# Decode aliases for certain CPU-COMPANY combinations. +case $basic_machine in + # Recognize the basic CPU types without company name. + # Some are omitted here because they have special meanings below. + 1750a | 580 \ + | a29k \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ + | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ + | c4x | clipper \ + | d10v | d30v | dlx | dsp16xx \ + | fr30 | frv \ + | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | i370 | i860 | i960 | ia64 \ + | ip2k \ + | m32r | m68000 | m68k | m88k | mcore \ + | mips | mipsbe | mipseb | mipsel | mipsle \ + | mips16 \ + | mips64 | mips64el \ + | mips64vr | mips64vrel \ + | mips64orion | mips64orionel \ + | mips64vr4100 | mips64vr4100el \ + | mips64vr4300 | mips64vr4300el \ + | mips64vr5000 | mips64vr5000el \ + | mipsisa32 | mipsisa32el \ + | mipsisa32r2 | mipsisa32r2el \ + | mipsisa64 | mipsisa64el \ + | mipsisa64sb1 | mipsisa64sb1el \ + | mipsisa64sr71k | mipsisa64sr71kel \ + | mipstx39 | mipstx39el \ + | mn10200 | mn10300 \ + | msp430 \ + | ns16k | ns32k \ + | openrisc | or32 \ + | pdp10 | pdp11 | pj | pjl \ + | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ + | pyramid \ + | s390 | s390x \ + | sh | sh[1234] | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \ + | sh64 | sh64le \ + | sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv9 | sparcv9b \ + | strongarm \ + | tahoe | thumb | tic4x | tic80 | tron \ + | v850 | v850e \ + | we32k \ + | x86 | xscale | xstormy16 | xtensa \ + | z8k) + basic_machine=$basic_machine-unknown + ;; + m6811 | m68hc11 | m6812 | m68hc12) + # Motorola 68HC11/12. + basic_machine=$basic_machine-unknown + os=-none + ;; + m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) + ;; + + # We use `pc' rather than `unknown' + # because (1) that's what they normally are, and + # (2) the word "unknown" tends to confuse beginning users. + i*86 | x86_64) + basic_machine=$basic_machine-pc + ;; + # Object if more than one company name word. + *-*-*) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; + # Recognize the basic CPU types with company name. + 580-* \ + | a29k-* \ + | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ + | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ + | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ + | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ + | avr-* \ + | bs2000-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ + | clipper-* | cydra-* \ + | d10v-* | d30v-* | dlx-* \ + | elxsi-* \ + | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \ + | h8300-* | h8500-* \ + | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ + | i*86-* | i860-* | i960-* | ia64-* \ + | ip2k-* \ + | m32r-* \ + | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ + | m88110-* | m88k-* | mcore-* \ + | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ + | mips16-* \ + | mips64-* | mips64el-* \ + | mips64vr-* | mips64vrel-* \ + | mips64orion-* | mips64orionel-* \ + | mips64vr4100-* | mips64vr4100el-* \ + | mips64vr4300-* | mips64vr4300el-* \ + | mips64vr5000-* | mips64vr5000el-* \ + | mipsisa32-* | mipsisa32el-* \ + | mipsisa32r2-* | mipsisa32r2el-* \ + | mipsisa64-* | mipsisa64el-* \ + | mipsisa64sb1-* | mipsisa64sb1el-* \ + | mipsisa64sr71k-* | mipsisa64sr71kel-* \ + | mipstx39-* | mipstx39el-* \ + | msp430-* \ + | none-* | np1-* | nv1-* | ns16k-* | ns32k-* \ + | orion-* \ + | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ + | pyramid-* \ + | romp-* | rs6000-* \ + | s390-* | s390x-* \ + | sh-* | sh[1234]-* | sh[23]e-* | sh[34]eb-* | shbe-* \ + | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ + | sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \ + | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \ + | tahoe-* | thumb-* \ + | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ + | tron-* \ + | v850-* | v850e-* | vax-* \ + | we32k-* \ + | x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \ + | xtensa-* \ + | ymp-* \ + | z8k-*) + ;; + # Recognize the various machine names and aliases which stand + # for a CPU type and a company and sometimes even an OS. + 386bsd) + basic_machine=i386-unknown + os=-bsd + ;; + 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) + basic_machine=m68000-att + ;; + 3b*) + basic_machine=we32k-att + ;; + a29khif) + basic_machine=a29k-amd + os=-udi + ;; + adobe68k) + basic_machine=m68010-adobe + os=-scout + ;; + alliant | fx80) + basic_machine=fx80-alliant + ;; + altos | altos3068) + basic_machine=m68k-altos + ;; + am29k) + basic_machine=a29k-none + os=-bsd + ;; + amd64) + basic_machine=x86_64-pc + ;; + amdahl) + basic_machine=580-amdahl + os=-sysv + ;; + amiga | amiga-*) + basic_machine=m68k-unknown + ;; + amigaos | amigados) + basic_machine=m68k-unknown + os=-amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + os=-sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + os=-sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + os=-bsd + ;; + aux) + basic_machine=m68k-apple + os=-aux + ;; + balance) + basic_machine=ns32k-sequent + os=-dynix + ;; + c90) + basic_machine=c90-cray + os=-unicos + ;; + convex-c1) + basic_machine=c1-convex + os=-bsd + ;; + convex-c2) + basic_machine=c2-convex + os=-bsd + ;; + convex-c32) + basic_machine=c32-convex + os=-bsd + ;; + convex-c34) + basic_machine=c34-convex + os=-bsd + ;; + convex-c38) + basic_machine=c38-convex + os=-bsd + ;; + cray | j90) + basic_machine=j90-cray + os=-unicos + ;; + crds | unos) + basic_machine=m68k-crds + ;; + cris | cris-* | etrax*) + basic_machine=cris-axis + ;; + da30 | da30-*) + basic_machine=m68k-da30 + ;; + decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) + basic_machine=mips-dec + ;; + decsystem10* | dec10*) + basic_machine=pdp10-dec + os=-tops10 + ;; + decsystem20* | dec20*) + basic_machine=pdp10-dec + os=-tops20 + ;; + delta | 3300 | motorola-3300 | motorola-delta \ + | 3300-motorola | delta-motorola) + basic_machine=m68k-motorola + ;; + delta88) + basic_machine=m88k-motorola + os=-sysv3 + ;; + dpx20 | dpx20-*) + basic_machine=rs6000-bull + os=-bosx + ;; + dpx2* | dpx2*-bull) + basic_machine=m68k-bull + os=-sysv3 + ;; + ebmon29k) + basic_machine=a29k-amd + os=-ebmon + ;; + elxsi) + basic_machine=elxsi-elxsi + os=-bsd + ;; + encore | umax | mmax) + basic_machine=ns32k-encore + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + os=-ose + ;; + fx2800) + basic_machine=i860-alliant + ;; + genix) + basic_machine=ns32k-ns + ;; + gmicro) + basic_machine=tron-gmicro + os=-sysv + ;; + go32) + basic_machine=i386-pc + os=-go32 + ;; + h3050r* | hiux*) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + h8300hms) + basic_machine=h8300-hitachi + os=-hms + ;; + h8300xray) + basic_machine=h8300-hitachi + os=-xray + ;; + h8500hms) + basic_machine=h8500-hitachi + os=-hms + ;; + harris) + basic_machine=m88k-harris + os=-sysv3 + ;; + hp300-*) + basic_machine=m68k-hp + ;; + hp300bsd) + basic_machine=m68k-hp + os=-bsd + ;; + hp300hpux) + basic_machine=m68k-hp + os=-hpux + ;; + hp3k9[0-9][0-9] | hp9[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) + basic_machine=m68000-hp + ;; + hp9k3[2-9][0-9]) + basic_machine=m68k-hp + ;; + hp9k6[0-9][0-9] | hp6[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k7[0-79][0-9] | hp7[0-79][0-9]) + basic_machine=hppa1.1-hp + ;; + hp9k78[0-9] | hp78[0-9]) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][13679] | hp8[0-9][13679]) + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][0-9] | hp8[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hppa-next) + os=-nextstep3 + ;; + hppaosf) + basic_machine=hppa1.1-hp + os=-osf + ;; + hppro) + basic_machine=hppa1.1-hp + os=-proelf + ;; + i370-ibm* | ibm*) + basic_machine=i370-ibm + ;; +# I'm not sure what "Sysv32" means. Should this be sysv3.2? + i*86v32) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv32 + ;; + i*86v4*) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv4 + ;; + i*86v) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv + ;; + i*86sol2) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-solaris2 + ;; + i386mach) + basic_machine=i386-mach + os=-mach + ;; + i386-vsta | vsta) + basic_machine=i386-unknown + os=-vsta + ;; + iris | iris4d) + basic_machine=mips-sgi + case $os in + -irix*) + ;; + *) + os=-irix4 + ;; + esac + ;; + isi68 | isi) + basic_machine=m68k-isi + os=-sysv + ;; + m88k-omron*) + basic_machine=m88k-omron + ;; + magnum | m3230) + basic_machine=mips-mips + os=-sysv + ;; + merlin) + basic_machine=ns32k-utek + os=-sysv + ;; + mingw32) + basic_machine=i386-pc + os=-mingw32 + ;; + miniframe) + basic_machine=m68000-convergent + ;; + *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; + mips3*-*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` + ;; + mips3*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown + ;; + mmix*) + basic_machine=mmix-knuth + os=-mmixware + ;; + monitor) + basic_machine=m68k-rom68k + os=-coff + ;; + morphos) + basic_machine=powerpc-unknown + os=-morphos + ;; + msdos) + basic_machine=i386-pc + os=-msdos + ;; + mvs) + basic_machine=i370-ibm + os=-mvs + ;; + ncr3000) + basic_machine=i486-ncr + os=-sysv4 + ;; + netbsd386) + basic_machine=i386-unknown + os=-netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + os=-linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + os=-newsos + ;; + news1000) + basic_machine=m68030-sony + os=-newsos + ;; + news-3600 | risc-news) + basic_machine=mips-sony + os=-newsos + ;; + necv70) + basic_machine=v70-nec + os=-sysv + ;; + next | m*-next ) + basic_machine=m68k-next + case $os in + -nextstep* ) + ;; + -ns2*) + os=-nextstep2 + ;; + *) + os=-nextstep3 + ;; + esac + ;; + nh3000) + basic_machine=m68k-harris + os=-cxux + ;; + nh[45]000) + basic_machine=m88k-harris + os=-cxux + ;; + nindy960) + basic_machine=i960-intel + os=-nindy + ;; + mon960) + basic_machine=i960-intel + os=-mon960 + ;; + nonstopux) + basic_machine=mips-compaq + os=-nonstopux + ;; + np1) + basic_machine=np1-gould + ;; + nv1) + basic_machine=nv1-cray + os=-unicosmp + ;; + nsr-tandem) + basic_machine=nsr-tandem + ;; + op50n-* | op60c-*) + basic_machine=hppa1.1-oki + os=-proelf + ;; + or32 | or32-*) + basic_machine=or32-unknown + os=-coff + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + os=-ose + ;; + os68k) + basic_machine=m68k-none + os=-os68k + ;; + pa-hitachi) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + paragon) + basic_machine=i860-intel + os=-osf + ;; + pbd) + basic_machine=sparc-tti + ;; + pbb) + basic_machine=m68k-tti + ;; + pc532 | pc532-*) + basic_machine=ns32k-pc532 + ;; + pentium | p5 | k5 | k6 | nexgen | viac3) + basic_machine=i586-pc + ;; + pentiumpro | p6 | 6x86 | athlon | athlon_*) + basic_machine=i686-pc + ;; + pentiumii | pentium2 | pentiumiii | pentium3) + basic_machine=i686-pc + ;; + pentium4) + basic_machine=i786-pc + ;; + pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) + basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumpro-* | p6-* | 6x86-* | athlon-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentium4-*) + basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pn) + basic_machine=pn-gould + ;; + power) basic_machine=power-ibm + ;; + ppc) basic_machine=powerpc-unknown + ;; + ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppcle | powerpclittle | ppc-le | powerpc-little) + basic_machine=powerpcle-unknown + ;; + ppcle-* | powerpclittle-*) + basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64) basic_machine=powerpc64-unknown + ;; + ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64le | powerpc64little | ppc64-le | powerpc64-little) + basic_machine=powerpc64le-unknown + ;; + ppc64le-* | powerpc64little-*) + basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ps2) + basic_machine=i386-ibm + ;; + pw32) + basic_machine=i586-unknown + os=-pw32 + ;; + rom68k) + basic_machine=m68k-rom68k + os=-coff + ;; + rm[46]00) + basic_machine=mips-siemens + ;; + rtpc | rtpc-*) + basic_machine=romp-ibm + ;; + sa29200) + basic_machine=a29k-amd + os=-udi + ;; + sb1) + basic_machine=mipsisa64sb1-unknown + ;; + sb1el) + basic_machine=mipsisa64sb1el-unknown + ;; + sei) + basic_machine=mips-sei + os=-seiux + ;; + sequent) + basic_machine=i386-sequent + ;; + sh) + basic_machine=sh-hitachi + os=-hms + ;; + sh64) + basic_machine=sh64-unknown + ;; + sparclite-wrs | simso-wrs) + basic_machine=sparclite-wrs + os=-vxworks + ;; + sps7) + basic_machine=m68k-bull + os=-sysv2 + ;; + spur) + basic_machine=spur-unknown + ;; + st2000) + basic_machine=m68k-tandem + ;; + stratus) + basic_machine=i860-stratus + os=-sysv4 + ;; + sun2) + basic_machine=m68000-sun + ;; + sun2os3) + basic_machine=m68000-sun + os=-sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + os=-sunos4 + ;; + sun3os3) + basic_machine=m68k-sun + os=-sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + os=-sunos4 + ;; + sun4os3) + basic_machine=sparc-sun + os=-sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + os=-sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + os=-solaris2 + ;; + sun3 | sun3-*) + basic_machine=m68k-sun + ;; + sun4) + basic_machine=sparc-sun + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + ;; + sv1) + basic_machine=sv1-cray + os=-unicos + ;; + symmetry) + basic_machine=i386-sequent + os=-dynix + ;; + t3e) + basic_machine=alphaev5-cray + os=-unicos + ;; + t90) + basic_machine=t90-cray + os=-unicos + ;; + tic54x | c54x*) + basic_machine=tic54x-unknown + os=-coff + ;; + tic55x | c55x*) + basic_machine=tic55x-unknown + os=-coff + ;; + tic6x | c6x*) + basic_machine=tic6x-unknown + os=-coff + ;; + tx39) + basic_machine=mipstx39-unknown + ;; + tx39el) + basic_machine=mipstx39el-unknown + ;; + toad1) + basic_machine=pdp10-xkl + os=-tops20 + ;; + tower | tower-32) + basic_machine=m68k-ncr + ;; + udi29k) + basic_machine=a29k-amd + os=-udi + ;; + ultra3) + basic_machine=a29k-nyu + os=-sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + os=-none + ;; + vaxv) + basic_machine=vax-dec + os=-sysv + ;; + vms) + basic_machine=vax-dec + os=-vms + ;; + vpp*|vx|vx-*) + basic_machine=f301-fujitsu + ;; + vxworks960) + basic_machine=i960-wrs + os=-vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + os=-vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + os=-vxworks + ;; + w65*) + basic_machine=w65-wdc + os=-none + ;; + w89k-*) + basic_machine=hppa1.1-winbond + os=-proelf + ;; + xps | xps100) + basic_machine=xps100-honeywell + ;; + ymp) + basic_machine=ymp-cray + os=-unicos + ;; + z8k-*-coff) + basic_machine=z8k-unknown + os=-sim + ;; + none) + basic_machine=none-none + os=-none + ;; + +# Here we handle the default manufacturer of certain CPU types. It is in +# some cases the only manufacturer, in others, it is the most popular. + w89k) + basic_machine=hppa1.1-winbond + ;; + op50n) + basic_machine=hppa1.1-oki + ;; + op60c) + basic_machine=hppa1.1-oki + ;; + romp) + basic_machine=romp-ibm + ;; + rs6000) + basic_machine=rs6000-ibm + ;; + vax) + basic_machine=vax-dec + ;; + pdp10) + # there are many clones, so DEC is not a safe bet + basic_machine=pdp10-unknown + ;; + pdp11) + basic_machine=pdp11-dec + ;; + we32k) + basic_machine=we32k-att + ;; + sh3 | sh4 | sh[34]eb | sh[1234]le | sh[23]ele) + basic_machine=sh-unknown + ;; + sh64) + basic_machine=sh64-unknown + ;; + sparc | sparcv9 | sparcv9b) + basic_machine=sparc-sun + ;; + cydra) + basic_machine=cydra-cydrome + ;; + orion) + basic_machine=orion-highlevel + ;; + orion105) + basic_machine=clipper-highlevel + ;; + mac | mpw | mac-mpw) + basic_machine=m68k-apple + ;; + pmac | pmac-mpw) + basic_machine=powerpc-apple + ;; + *-unknown) + # Make sure to match an already-canonicalized machine name. + ;; + *) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; +esac + +# Here we canonicalize certain aliases for manufacturers. +case $basic_machine in + *-digital*) + basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` + ;; + *-commodore*) + basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + ;; + *) + ;; +esac + +# Decode manufacturer-specific aliases for certain operating systems. + +if [ x"$os" != x"" ] +then +case $os in + # First match some system type aliases + # that might get confused with valid system types. + # -solaris* is a basic system type, with this one exception. + -solaris1 | -solaris1.*) + os=`echo $os | sed -e 's|solaris1|sunos4|'` + ;; + -solaris) + os=-solaris2 + ;; + -svr4*) + os=-sysv4 + ;; + -unixware*) + os=-sysv4.2uw + ;; + -gnu/linux*) + os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` + ;; + # First accept the basic system types. + # The portable systems comes first. + # Each alternative MUST END IN A *, to match a version number. + # -sysv* is not here because it comes later, after sysvr4. + -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \ + | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ + | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ + | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ + | -chorusos* | -chorusrdb* \ + | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \ + | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ + | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ + | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ + | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ + | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ + | -powermax* | -dnix* | -nx6 | -nx7 | -sei*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + -qnx*) + case $basic_machine in + x86-* | i*86-*) + ;; + *) + os=-nto$os + ;; + esac + ;; + -nto-qnx*) + ;; + -nto*) + os=`echo $os | sed -e 's|nto|nto-qnx|'` + ;; + -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ + | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ + | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) + ;; + -mac*) + os=`echo $os | sed -e 's|mac|macos|'` + ;; + -linux*) + os=`echo $os | sed -e 's|linux|linux-gnu|'` + ;; + -sunos5*) + os=`echo $os | sed -e 's|sunos5|solaris2|'` + ;; + -sunos6*) + os=`echo $os | sed -e 's|sunos6|solaris3|'` + ;; + -opened*) + os=-openedition + ;; + -wince*) + os=-wince + ;; + -osfrose*) + os=-osfrose + ;; + -osf*) + os=-osf + ;; + -utek*) + os=-bsd + ;; + -dynix*) + os=-bsd + ;; + -acis*) + os=-aos + ;; + -atheos*) + os=-atheos + ;; + -386bsd) + os=-bsd + ;; + -ctix* | -uts*) + os=-sysv + ;; + -nova*) + os=-rtmk-nova + ;; + -ns2 ) + os=-nextstep2 + ;; + -nsk*) + os=-nsk + ;; + # Preserve the version number of sinix5. + -sinix5.*) + os=`echo $os | sed -e 's|sinix|sysv|'` + ;; + -sinix*) + os=-sysv4 + ;; + -triton*) + os=-sysv3 + ;; + -oss*) + os=-sysv3 + ;; + -svr4) + os=-sysv4 + ;; + -svr3) + os=-sysv3 + ;; + -sysvr4) + os=-sysv4 + ;; + # This must come after -sysvr4. + -sysv*) + ;; + -ose*) + os=-ose + ;; + -es1800*) + os=-ose + ;; + -xenix) + os=-xenix + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + os=-mint + ;; + -aros*) + os=-aros + ;; + -kaos*) + os=-kaos + ;; + -none) + ;; + *) + # Get rid of the `-' at the beginning of $os. + os=`echo $os | sed 's/[^-]*-//'` + echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 + exit 1 + ;; +esac +else + +# Here we handle the default operating systems that come with various machines. +# The value should be what the vendor currently ships out the door with their +# machine or put another way, the most popular os provided with the machine. + +# Note that if you're going to try to match "-MANUFACTURER" here (say, +# "-sun"), then you have to tell the case statement up towards the top +# that MANUFACTURER isn't an operating system. Otherwise, code above +# will signal an error saying that MANUFACTURER isn't an operating +# system, and we'll never get to this point. + +case $basic_machine in + *-acorn) + os=-riscix1.2 + ;; + arm*-rebel) + os=-linux + ;; + arm*-semi) + os=-aout + ;; + c4x-* | tic4x-*) + os=-coff + ;; + # This must come before the *-dec entry. + pdp10-*) + os=-tops20 + ;; + pdp11-*) + os=-none + ;; + *-dec | vax-*) + os=-ultrix4.2 + ;; + m68*-apollo) + os=-domain + ;; + i386-sun) + os=-sunos4.0.2 + ;; + m68000-sun) + os=-sunos3 + # This also exists in the configure program, but was not the + # default. + # os=-sunos4 + ;; + m68*-cisco) + os=-aout + ;; + mips*-cisco) + os=-elf + ;; + mips*-*) + os=-elf + ;; + or32-*) + os=-coff + ;; + *-tti) # must be before sparc entry or we get the wrong os. + os=-sysv3 + ;; + sparc-* | *-sun) + os=-sunos4.1.1 + ;; + *-be) + os=-beos + ;; + *-ibm) + os=-aix + ;; + *-wec) + os=-proelf + ;; + *-winbond) + os=-proelf + ;; + *-oki) + os=-proelf + ;; + *-hp) + os=-hpux + ;; + *-hitachi) + os=-hiux + ;; + i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) + os=-sysv + ;; + *-cbm) + os=-amigaos + ;; + *-dg) + os=-dgux + ;; + *-dolphin) + os=-sysv3 + ;; + m68k-ccur) + os=-rtu + ;; + m88k-omron*) + os=-luna + ;; + *-next ) + os=-nextstep + ;; + *-sequent) + os=-ptx + ;; + *-crds) + os=-unos + ;; + *-ns) + os=-genix + ;; + i370-*) + os=-mvs + ;; + *-next) + os=-nextstep3 + ;; + *-gould) + os=-sysv + ;; + *-highlevel) + os=-bsd + ;; + *-encore) + os=-bsd + ;; + *-sgi) + os=-irix + ;; + *-siemens) + os=-sysv4 + ;; + *-masscomp) + os=-rtu + ;; + f30[01]-fujitsu | f700-fujitsu) + os=-uxpv + ;; + *-rom68k) + os=-coff + ;; + *-*bug) + os=-coff + ;; + *-apple) + os=-macos + ;; + *-atari*) + os=-mint + ;; + *) + os=-none + ;; +esac +fi + +# Here we handle the case where we know the os, and the CPU type, but not the +# manufacturer. We pick the logical manufacturer. +vendor=unknown +case $basic_machine in + *-unknown) + case $os in + -riscix*) + vendor=acorn + ;; + -sunos*) + vendor=sun + ;; + -aix*) + vendor=ibm + ;; + -beos*) + vendor=be + ;; + -hpux*) + vendor=hp + ;; + -mpeix*) + vendor=hp + ;; + -hiux*) + vendor=hitachi + ;; + -unos*) + vendor=crds + ;; + -dgux*) + vendor=dg + ;; + -luna*) + vendor=omron + ;; + -genix*) + vendor=ns + ;; + -mvs* | -opened*) + vendor=ibm + ;; + -ptx*) + vendor=sequent + ;; + -vxsim* | -vxworks* | -windiss*) + vendor=wrs + ;; + -aux*) + vendor=apple + ;; + -hms*) + vendor=hitachi + ;; + -mpw* | -macos*) + vendor=apple + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + vendor=atari + ;; + -vos*) + vendor=stratus + ;; + esac + basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` + ;; +esac + +echo $basic_machine$os +exit 0 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/ase/config/install-sh b/ase/config/install-sh new file mode 100755 index 00000000..77bc3814 --- /dev/null +++ b/ase/config/install-sh @@ -0,0 +1,316 @@ +#!/bin/sh +# install - install a program, script, or datafile + +scriptversion=2004-02-15.20 + +# This originates from X11R5 (mit/util/scripts/install.sh), which was +# later released in X11R6 (xc/config/util/install.sh) with the +# following copyright and license. +# +# Copyright (C) 1994 X Consortium +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- +# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +# Except as contained in this notice, the name of the X Consortium shall not +# be used in advertising or otherwise to promote the sale, use or other deal- +# ings in this Software without prior written authorization from the X Consor- +# tium. +# +# +# FSF changes to this file are in the public domain. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# `make' implicit rules from creating a file called install from it +# when there is no Makefile. +# +# This script is compatible with the BSD install script, but was written +# from scratch. It can only install one file at a time, a restriction +# shared with many OS's install programs. + +# set DOITPROG to echo to test this script + +# Don't use :- since 4.3BSD and earlier shells don't like it. +doit="${DOITPROG-}" + +# put in absolute paths if you don't have them in your path; or use env. vars. + +mvprog="${MVPROG-mv}" +cpprog="${CPPROG-cp}" +chmodprog="${CHMODPROG-chmod}" +chownprog="${CHOWNPROG-chown}" +chgrpprog="${CHGRPPROG-chgrp}" +stripprog="${STRIPPROG-strip}" +rmprog="${RMPROG-rm}" +mkdirprog="${MKDIRPROG-mkdir}" + +transformbasename= +transform_arg= +instcmd="$mvprog" +chmodcmd="$chmodprog 0755" +chowncmd= +chgrpcmd= +stripcmd= +rmcmd="$rmprog -f" +mvcmd="$mvprog" +src= +dst= +dir_arg= + +usage="Usage: $0 [OPTION]... SRCFILE DSTFILE + or: $0 [OPTION]... SRCFILES... DIRECTORY + or: $0 -d DIRECTORIES... + +In the first form, install SRCFILE to DSTFILE, removing SRCFILE by default. +In the second, create the directory path DIR. + +Options: +-b=TRANSFORMBASENAME +-c copy source (using $cpprog) instead of moving (using $mvprog). +-d create directories instead of installing files. +-g GROUP $chgrp installed files to GROUP. +-m MODE $chmod installed files to MODE. +-o USER $chown installed files to USER. +-s strip installed files (using $stripprog). +-t=TRANSFORM +--help display this help and exit. +--version display version info and exit. + +Environment variables override the default commands: + CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG +" + +while test -n "$1"; do + case $1 in + -b=*) transformbasename=`echo $1 | sed 's/-b=//'` + shift + continue;; + + -c) instcmd=$cpprog + shift + continue;; + + -d) dir_arg=true + shift + continue;; + + -g) chgrpcmd="$chgrpprog $2" + shift + shift + continue;; + + --help) echo "$usage"; exit 0;; + + -m) chmodcmd="$chmodprog $2" + shift + shift + continue;; + + -o) chowncmd="$chownprog $2" + shift + shift + continue;; + + -s) stripcmd=$stripprog + shift + continue;; + + -t=*) transformarg=`echo $1 | sed 's/-t=//'` + shift + continue;; + + --version) echo "$0 $scriptversion"; exit 0;; + + *) # When -d is used, all remaining arguments are directories to create. + test -n "$dir_arg" && break + # Otherwise, the last argument is the destination. Remove it from $@. + for arg + do + if test -n "$dstarg"; then + # $@ is not empty: it contains at least $arg. + set fnord "$@" "$dstarg" + shift # fnord + fi + shift # arg + dstarg=$arg + done + break;; + esac +done + +if test -z "$1"; then + if test -z "$dir_arg"; then + echo "$0: no input file specified." >&2 + exit 1 + fi + # It's OK to call `install-sh -d' without argument. + # This can happen when creating conditional directories. + exit 0 +fi + +for src +do + # Protect names starting with `-'. + case $src in + -*) src=./$src ;; + esac + + if test -n "$dir_arg"; then + dst=$src + src= + + if test -d "$dst"; then + instcmd=: + chmodcmd= + else + instcmd=$mkdirprog + fi + else + # Waiting for this to be detected by the "$instcmd $src $dsttmp" command + # might cause directories to be created, which would be especially bad + # if $src (and thus $dsttmp) contains '*'. + if test ! -f "$src" && test ! -d "$src"; then + echo "$0: $src does not exist." >&2 + exit 1 + fi + + if test -z "$dstarg"; then + echo "$0: no destination specified." >&2 + exit 1 + fi + + dst=$dstarg + # Protect names starting with `-'. + case $dst in + -*) dst=./$dst ;; + esac + + # If destination is a directory, append the input filename; won't work + # if double slashes aren't ignored. + if test -d "$dst"; then + dst=$dst/`basename "$src"` + fi + fi + + # This sed command emulates the dirname command. + dstdir=`echo "$dst" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` + + # Make sure that the destination directory exists. + + # Skip lots of stat calls in the usual case. + if test ! -d "$dstdir"; then + defaultIFS=' + ' + IFS="${IFS-$defaultIFS}" + + oIFS=$IFS + # Some sh's can't handle IFS=/ for some reason. + IFS='%' + set - `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'` + IFS=$oIFS + + pathcomp= + + while test $# -ne 0 ; do + pathcomp=$pathcomp$1 + shift + if test ! -d "$pathcomp"; then + $mkdirprog "$pathcomp" || lasterr=$? + # mkdir can fail with a `File exist' error in case several + # install-sh are creating the directory concurrently. This + # is OK. + test ! -d "$pathcomp" && { (exit ${lasterr-1}); exit; } + fi + pathcomp=$pathcomp/ + done + fi + + if test -n "$dir_arg"; then + $doit $instcmd "$dst" \ + && { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \ + && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \ + && { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \ + && { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; } + + else + # If we're going to rename the final executable, determine the name now. + if test -z "$transformarg"; then + dstfile=`basename "$dst"` + else + dstfile=`basename "$dst" $transformbasename \ + | sed $transformarg`$transformbasename + fi + + # don't allow the sed command to completely eliminate the filename. + test -z "$dstfile" && dstfile=`basename "$dst"` + + # Make a couple of temp file names in the proper directory. + dsttmp=$dstdir/_inst.$$_ + rmtmp=$dstdir/_rm.$$_ + + # Trap to clean up those temp files at exit. + trap 'status=$?; rm -f "$dsttmp" "$rmtmp" && exit $status' 0 + trap '(exit $?); exit' 1 2 13 15 + + # Move or copy the file name to the temp name + $doit $instcmd "$src" "$dsttmp" && + + # and set any options; do chmod last to preserve setuid bits. + # + # If any of these fail, we abort the whole thing. If we want to + # ignore errors from any of these, just make sure not to ignore + # errors from the above "$doit $instcmd $src $dsttmp" command. + # + { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \ + && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \ + && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \ + && { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } && + + # Now remove or move aside any old file at destination location. We + # try this two ways since rm can't unlink itself on some systems and + # the destination file might be busy for other reasons. In this case, + # the final cleanup might fail but the new file should still install + # successfully. + { + if test -f "$dstdir/$dstfile"; then + $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \ + || $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \ + || { + echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2 + (exit 1); exit + } + else + : + fi + } && + + # Now rename the file to the real destination. + $doit $mvcmd "$dsttmp" "$dstdir/$dstfile" + fi || { (exit 1); exit; } +done + +# The final little trick to "correctly" pass the exit status to the exit trap. +{ + (exit 0); exit +} + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-end: "$" +# End: diff --git a/ase/config/ltmain.sh b/ase/config/ltmain.sh new file mode 100644 index 00000000..23f82e3b --- /dev/null +++ b/ase/config/ltmain.sh @@ -0,0 +1,6425 @@ +# ltmain.sh - Provide generalized library-building support services. +# NOTE: Changing this file will not affect anything until you rerun configure. +# +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004 +# Free Software Foundation, Inc. +# Originally by Gordon Matzigkeit , 1996 +# +# 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. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +basename="s,^.*/,,g" + +# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh +# is ksh but when the shell is invoked as "sh" and the current value of +# the _XPG environment variable is not equal to 1 (one), the special +# positional parameter $0, within a function call, is the name of the +# function. +progpath="$0" + +# RH: define SED for historic ltconfig's generated by Libtool 1.3 +[ -z "$SED" ] && SED=sed + +# The name of this program: +progname=`echo "$progpath" | $SED $basename` +modename="$progname" + +# Global variables: +EXIT_SUCCESS=0 +EXIT_FAILURE=1 + +PROGRAM=ltmain.sh +PACKAGE=libtool +VERSION=1.5.6 +TIMESTAMP=" (1.1220.2.95 2004/04/11 05:50:42)" + + +# Check that we have a working $echo. +if test "X$1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift +elif test "X$1" = X--fallback-echo; then + # Avoid inline document here, it may be left over + : +elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then + # Yippee, $echo works! + : +else + # Restart under the correct shell, and then maybe $echo will work. + exec $SHELL "$progpath" --no-reexec ${1+"$@"} +fi + +if test "X$1" = X--fallback-echo; then + # used as fallback echo + shift + cat <&2 + $echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 + exit $EXIT_FAILURE +fi + +# Global variables. +mode=$default_mode +nonopt= +prev= +prevopt= +run= +show="$echo" +show_help= +execute_dlfiles= +lo2o="s/\\.lo\$/.${objext}/" +o2lo="s/\\.${objext}\$/.lo/" + +##################################### +# Shell function definitions: +# This seems to be the best place for them + +# func_win32_libid arg +# return the library type of file 'arg' +# +# Need a lot of goo to handle *both* DLLs and import libs +# Has to be a shell function in order to 'eat' the argument +# that is supplied when $file_magic_command is called. +func_win32_libid () { + win32_libid_type="unknown" + win32_fileres=`file -L $1 2>/dev/null` + case $win32_fileres in + *ar\ archive\ import\ library*) # definitely import + win32_libid_type="x86 archive import" + ;; + *ar\ archive*) # could be an import, or static + if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \ + $EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then + win32_nmres=`eval $NM -f posix -A $1 | \ + sed -n -e '1,100{/ I /{x;/import/!{s/^/import/;h;p;};x;};}'` + if test "X$win32_nmres" = "Ximport" ; then + win32_libid_type="x86 archive import" + else + win32_libid_type="x86 archive static" + fi + fi + ;; + *DLL*) + win32_libid_type="x86 DLL" + ;; + *executable*) # but shell scripts are "executable" too... + case $win32_fileres in + *MS\ Windows\ PE\ Intel*) + win32_libid_type="x86 DLL" + ;; + esac + ;; + esac + $echo $win32_libid_type +} + + +# func_infer_tag arg +# Infer tagged configuration to use if any are available and +# if one wasn't chosen via the "--tag" command line option. +# Only attempt this if the compiler in the base compile +# command doesn't match the default compiler. +# arg is usually of the form 'gcc ...' +func_infer_tag () { + if test -n "$available_tags" && test -z "$tagname"; then + CC_quoted= + for arg in $CC; do + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + arg="\"$arg\"" + ;; + esac + CC_quoted="$CC_quoted $arg" + done + case $@ in + # Blanks in the command may have been stripped by the calling shell, + # but not from the CC environment variable when configure was run. + " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) ;; + # Blanks at the start of $base_compile will cause this to fail + # if we don't check for them as well. + *) + for z in $available_tags; do + if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then + # Evaluate the configuration. + eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" + CC_quoted= + for arg in $CC; do + # Double-quote args containing other shell metacharacters. + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + arg="\"$arg\"" + ;; + esac + CC_quoted="$CC_quoted $arg" + done + case "$@ " in + " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) + # The compiler in the base compile command matches + # the one in the tagged configuration. + # Assume this is the tagged configuration we want. + tagname=$z + break + ;; + esac + fi + done + # If $tagname still isn't set, then no tagged configuration + # was found and let the user know that the "--tag" command + # line option must be used. + if test -z "$tagname"; then + $echo "$modename: unable to infer tagged configuration" + $echo "$modename: specify a tag with \`--tag'" 1>&2 + exit $EXIT_FAILURE +# else +# $echo "$modename: using $tagname tagged configuration" + fi + ;; + esac + fi +} +# End of Shell function definitions +##################################### + +# Darwin sucks +eval std_shrext=\"$shrext_cmds\" + +# Parse our command line options once, thoroughly. +while test "$#" -gt 0 +do + arg="$1" + shift + + case $arg in + -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;; + *) optarg= ;; + esac + + # If the previous option needs an argument, assign it. + if test -n "$prev"; then + case $prev in + execute_dlfiles) + execute_dlfiles="$execute_dlfiles $arg" + ;; + tag) + tagname="$arg" + preserve_args="${preserve_args}=$arg" + + # Check whether tagname contains only valid characters + case $tagname in + *[!-_A-Za-z0-9,/]*) + $echo "$progname: invalid tag name: $tagname" 1>&2 + exit $EXIT_FAILURE + ;; + esac + + case $tagname in + CC) + # Don't test for the "default" C tag, as we know, it's there, but + # not specially marked. + ;; + *) + if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$progpath" > /dev/null; then + taglist="$taglist $tagname" + # Evaluate the configuration. + eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^# ### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $progpath`" + else + $echo "$progname: ignoring unknown tag $tagname" 1>&2 + fi + ;; + esac + ;; + *) + eval "$prev=\$arg" + ;; + esac + + prev= + prevopt= + continue + fi + + # Have we seen a non-optional argument yet? + case $arg in + --help) + show_help=yes + ;; + + --version) + $echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP" + $echo + $echo "Copyright (C) 2003 Free Software Foundation, Inc." + $echo "This is free software; see the source for copying conditions. There is NO" + $echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + exit $EXIT_SUCCESS + ;; + + --config) + ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $progpath + # Now print the configurations for the tags. + for tagname in $taglist; do + ${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$progpath" + done + exit $EXIT_SUCCESS + ;; + + --debug) + $echo "$progname: enabling shell trace mode" + set -x + preserve_args="$preserve_args $arg" + ;; + + --dry-run | -n) + run=: + ;; + + --features) + $echo "host: $host" + if test "$build_libtool_libs" = yes; then + $echo "enable shared libraries" + else + $echo "disable shared libraries" + fi + if test "$build_old_libs" = yes; then + $echo "enable static libraries" + else + $echo "disable static libraries" + fi + exit $EXIT_SUCCESS + ;; + + --finish) mode="finish" ;; + + --mode) prevopt="--mode" prev=mode ;; + --mode=*) mode="$optarg" ;; + + --preserve-dup-deps) duplicate_deps="yes" ;; + + --quiet | --silent) + show=: + preserve_args="$preserve_args $arg" + ;; + + --tag) prevopt="--tag" prev=tag ;; + --tag=*) + set tag "$optarg" ${1+"$@"} + shift + prev=tag + preserve_args="$preserve_args --tag" + ;; + + -dlopen) + prevopt="-dlopen" + prev=execute_dlfiles + ;; + + -*) + $echo "$modename: unrecognized option \`$arg'" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + ;; + + *) + nonopt="$arg" + break + ;; + esac +done + +if test -n "$prevopt"; then + $echo "$modename: option \`$prevopt' requires an argument" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE +fi + +# If this variable is set in any of the actions, the command in it +# will be execed at the end. This prevents here-documents from being +# left over by shells. +exec_cmd= + +if test -z "$show_help"; then + + # Infer the operation mode. + if test -z "$mode"; then + $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2 + $echo "*** Future versions of Libtool will require -mode=MODE be specified." 1>&2 + case $nonopt in + *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*) + mode=link + for arg + do + case $arg in + -c) + mode=compile + break + ;; + esac + done + ;; + *db | *dbx | *strace | *truss) + mode=execute + ;; + *install*|cp|mv) + mode=install + ;; + *rm) + mode=uninstall + ;; + *) + # If we have no mode, but dlfiles were specified, then do execute mode. + test -n "$execute_dlfiles" && mode=execute + + # Just use the default operation mode. + if test -z "$mode"; then + if test -n "$nonopt"; then + $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2 + else + $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2 + fi + fi + ;; + esac + fi + + # Only execute mode is allowed to have -dlopen flags. + if test -n "$execute_dlfiles" && test "$mode" != execute; then + $echo "$modename: unrecognized option \`-dlopen'" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + # Change the help message to a mode-specific one. + generic_help="$help" + help="Try \`$modename --help --mode=$mode' for more information." + + # These modes are in order of execution frequency so that they run quickly. + case $mode in + # libtool compile mode + compile) + modename="$modename: compile" + # Get the compilation command and the source file. + base_compile= + srcfile="$nonopt" # always keep a non-empty value in "srcfile" + suppress_opt=yes + suppress_output= + arg_mode=normal + libobj= + later= + + for arg + do + case "$arg_mode" in + arg ) + # do not "continue". Instead, add this to base_compile + lastarg="$arg" + arg_mode=normal + ;; + + target ) + libobj="$arg" + arg_mode=normal + continue + ;; + + normal ) + # Accept any command-line options. + case $arg in + -o) + if test -n "$libobj" ; then + $echo "$modename: you cannot specify \`-o' more than once" 1>&2 + exit $EXIT_FAILURE + fi + arg_mode=target + continue + ;; + + -static | -prefer-pic | -prefer-non-pic) + later="$later $arg" + continue + ;; + + -no-suppress) + suppress_opt=no + continue + ;; + + -Xcompiler) + arg_mode=arg # the next one goes into the "base_compile" arg list + continue # The current "srcfile" will either be retained or + ;; # replaced later. I would guess that would be a bug. + + -Wc,*) + args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"` + lastarg= + save_ifs="$IFS"; IFS=',' + for arg in $args; do + IFS="$save_ifs" + + # Double-quote args containing other shell metacharacters. + # Many Bourne shells cannot handle close brackets correctly + # in scan sets, so we specify it separately. + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + arg="\"$arg\"" + ;; + esac + lastarg="$lastarg $arg" + done + IFS="$save_ifs" + lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"` + + # Add the arguments to base_compile. + base_compile="$base_compile $lastarg" + continue + ;; + + * ) + # Accept the current argument as the source file. + # The previous "srcfile" becomes the current argument. + # + lastarg="$srcfile" + srcfile="$arg" + ;; + esac # case $arg + ;; + esac # case $arg_mode + + # Aesthetically quote the previous argument. + lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"` + + case $lastarg in + # Double-quote args containing other shell metacharacters. + # Many Bourne shells cannot handle close brackets correctly + # in scan sets, so we specify it separately. + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + lastarg="\"$lastarg\"" + ;; + esac + + base_compile="$base_compile $lastarg" + done # for arg + + case $arg_mode in + arg) + $echo "$modename: you must specify an argument for -Xcompile" + exit $EXIT_FAILURE + ;; + target) + $echo "$modename: you must specify a target with \`-o'" 1>&2 + exit $EXIT_FAILURE + ;; + *) + # Get the name of the library object. + [ -z "$libobj" ] && libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'` + ;; + esac + + # Recognize several different file suffixes. + # If the user specifies -o file.o, it is replaced with file.lo + xform='[cCFSifmso]' + case $libobj in + *.ada) xform=ada ;; + *.adb) xform=adb ;; + *.ads) xform=ads ;; + *.asm) xform=asm ;; + *.c++) xform=c++ ;; + *.cc) xform=cc ;; + *.ii) xform=ii ;; + *.class) xform=class ;; + *.cpp) xform=cpp ;; + *.cxx) xform=cxx ;; + *.f90) xform=f90 ;; + *.for) xform=for ;; + *.java) xform=java ;; + esac + + libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"` + + case $libobj in + *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;; + *) + $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2 + exit $EXIT_FAILURE + ;; + esac + + func_infer_tag $base_compile + + for arg in $later; do + case $arg in + -static) + build_old_libs=yes + continue + ;; + + -prefer-pic) + pic_mode=yes + continue + ;; + + -prefer-non-pic) + pic_mode=no + continue + ;; + esac + done + + objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'` + xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$obj"; then + xdir= + else + xdir=$xdir/ + fi + lobj=${xdir}$objdir/$objname + + if test -z "$base_compile"; then + $echo "$modename: you must specify a compilation command" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + # Delete any leftover library objects. + if test "$build_old_libs" = yes; then + removelist="$obj $lobj $libobj ${libobj}T" + else + removelist="$lobj $libobj ${libobj}T" + fi + + $run $rm $removelist + trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15 + + # On Cygwin there's no "real" PIC flag so we must build both object types + case $host_os in + cygwin* | mingw* | pw32* | os2*) + pic_mode=default + ;; + esac + if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then + # non-PIC code in shared libraries is not supported + pic_mode=default + fi + + # Calculate the filename of the output object if compiler does + # not support -o with -c + if test "$compiler_c_o" = no; then + output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext} + lockfile="$output_obj.lock" + removelist="$removelist $output_obj $lockfile" + trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15 + else + output_obj= + need_locks=no + lockfile= + fi + + # Lock this critical section if it is needed + # We use this script file to make the link, it avoids creating a new file + if test "$need_locks" = yes; then + until $run ln "$progpath" "$lockfile" 2>/dev/null; do + $show "Waiting for $lockfile to be removed" + sleep 2 + done + elif test "$need_locks" = warn; then + if test -f "$lockfile"; then + $echo "\ +*** ERROR, $lockfile exists and contains: +`cat $lockfile 2>/dev/null` + +This indicates that another process is trying to use the same +temporary object file, and libtool could not work around it because +your compiler does not support \`-c' and \`-o' together. If you +repeat this compilation, it may succeed, by chance, but you had better +avoid parallel builds (make -j) in this platform, or get a better +compiler." + + $run $rm $removelist + exit $EXIT_FAILURE + fi + $echo $srcfile > "$lockfile" + fi + + if test -n "$fix_srcfile_path"; then + eval srcfile=\"$fix_srcfile_path\" + fi + + $run $rm "$libobj" "${libobj}T" + + # Create a libtool object file (analogous to a ".la" file), + # but don't create it if we're doing a dry run. + test -z "$run" && cat > ${libobj}T </dev/null`" != "X$srcfile"; then + $echo "\ +*** ERROR, $lockfile contains: +`cat $lockfile 2>/dev/null` + +but it should contain: +$srcfile + +This indicates that another process is trying to use the same +temporary object file, and libtool could not work around it because +your compiler does not support \`-c' and \`-o' together. If you +repeat this compilation, it may succeed, by chance, but you had better +avoid parallel builds (make -j) in this platform, or get a better +compiler." + + $run $rm $removelist + exit $EXIT_FAILURE + fi + + # Just move the object if needed, then go on to compile the next one + if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then + $show "$mv $output_obj $lobj" + if $run $mv $output_obj $lobj; then : + else + error=$? + $run $rm $removelist + exit $error + fi + fi + + # Append the name of the PIC object to the libtool object file. + test -z "$run" && cat >> ${libobj}T <> ${libobj}T </dev/null`" != "X$srcfile"; then + $echo "\ +*** ERROR, $lockfile contains: +`cat $lockfile 2>/dev/null` + +but it should contain: +$srcfile + +This indicates that another process is trying to use the same +temporary object file, and libtool could not work around it because +your compiler does not support \`-c' and \`-o' together. If you +repeat this compilation, it may succeed, by chance, but you had better +avoid parallel builds (make -j) in this platform, or get a better +compiler." + + $run $rm $removelist + exit $EXIT_FAILURE + fi + + # Just move the object if needed + if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then + $show "$mv $output_obj $obj" + if $run $mv $output_obj $obj; then : + else + error=$? + $run $rm $removelist + exit $error + fi + fi + + # Append the name of the non-PIC object the libtool object file. + # Only append if the libtool object file exists. + test -z "$run" && cat >> ${libobj}T <> ${libobj}T <&2 + fi + if test -n "$link_static_flag"; then + dlopen_self=$dlopen_self_static + fi + else + if test -z "$pic_flag" && test -n "$link_static_flag"; then + dlopen_self=$dlopen_self_static + fi + fi + build_libtool_libs=no + build_old_libs=yes + prefer_static_libs=yes + break + ;; + esac + done + + # See if our shared archives depend on static archives. + test -n "$old_archive_from_new_cmds" && build_old_libs=yes + + # Go through the arguments, transforming them on the way. + while test "$#" -gt 0; do + arg="$1" + shift + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + qarg=\"`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`\" ### testsuite: skip nested quoting test + ;; + *) qarg=$arg ;; + esac + libtool_args="$libtool_args $qarg" + + # If the previous option needs an argument, assign it. + if test -n "$prev"; then + case $prev in + output) + compile_command="$compile_command @OUTPUT@" + finalize_command="$finalize_command @OUTPUT@" + ;; + esac + + case $prev in + dlfiles|dlprefiles) + if test "$preload" = no; then + # Add the symbol object into the linking commands. + compile_command="$compile_command @SYMFILE@" + finalize_command="$finalize_command @SYMFILE@" + preload=yes + fi + case $arg in + *.la | *.lo) ;; # We handle these cases below. + force) + if test "$dlself" = no; then + dlself=needless + export_dynamic=yes + fi + prev= + continue + ;; + self) + if test "$prev" = dlprefiles; then + dlself=yes + elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then + dlself=yes + else + dlself=needless + export_dynamic=yes + fi + prev= + continue + ;; + *) + if test "$prev" = dlfiles; then + dlfiles="$dlfiles $arg" + else + dlprefiles="$dlprefiles $arg" + fi + prev= + continue + ;; + esac + ;; + expsyms) + export_symbols="$arg" + if test ! -f "$arg"; then + $echo "$modename: symbol file \`$arg' does not exist" + exit $EXIT_FAILURE + fi + prev= + continue + ;; + expsyms_regex) + export_symbols_regex="$arg" + prev= + continue + ;; + inst_prefix) + inst_prefix_dir="$arg" + prev= + continue + ;; + precious_regex) + precious_files_regex="$arg" + prev= + continue + ;; + release) + release="-$arg" + prev= + continue + ;; + objectlist) + if test -f "$arg"; then + save_arg=$arg + moreargs= + for fil in `cat $save_arg` + do +# moreargs="$moreargs $fil" + arg=$fil + # A libtool-controlled object. + + # Check to see that this really is a libtool object. + if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + pic_object= + non_pic_object= + + # Read the .lo file + # If there is no directory component, then add one. + case $arg in + */* | *\\*) . $arg ;; + *) . ./$arg ;; + esac + + if test -z "$pic_object" || \ + test -z "$non_pic_object" || + test "$pic_object" = none && \ + test "$non_pic_object" = none; then + $echo "$modename: cannot find name of object for \`$arg'" 1>&2 + exit $EXIT_FAILURE + fi + + # Extract subdirectory from the argument. + xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$arg"; then + xdir= + else + xdir="$xdir/" + fi + + if test "$pic_object" != none; then + # Prepend the subdirectory the object is found in. + pic_object="$xdir$pic_object" + + if test "$prev" = dlfiles; then + if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then + dlfiles="$dlfiles $pic_object" + prev= + continue + else + # If libtool objects are unsupported, then we need to preload. + prev=dlprefiles + fi + fi + + # CHECK ME: I think I busted this. -Ossama + if test "$prev" = dlprefiles; then + # Preload the old-style object. + dlprefiles="$dlprefiles $pic_object" + prev= + fi + + # A PIC object. + libobjs="$libobjs $pic_object" + arg="$pic_object" + fi + + # Non-PIC object. + if test "$non_pic_object" != none; then + # Prepend the subdirectory the object is found in. + non_pic_object="$xdir$non_pic_object" + + # A standard non-PIC object + non_pic_objects="$non_pic_objects $non_pic_object" + if test -z "$pic_object" || test "$pic_object" = none ; then + arg="$non_pic_object" + fi + fi + else + # Only an error if not doing a dry-run. + if test -z "$run"; then + $echo "$modename: \`$arg' is not a valid libtool object" 1>&2 + exit $EXIT_FAILURE + else + # Dry-run case. + + # Extract subdirectory from the argument. + xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$arg"; then + xdir= + else + xdir="$xdir/" + fi + + pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"` + non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"` + libobjs="$libobjs $pic_object" + non_pic_objects="$non_pic_objects $non_pic_object" + fi + fi + done + else + $echo "$modename: link input file \`$save_arg' does not exist" + exit $EXIT_FAILURE + fi + arg=$save_arg + prev= + continue + ;; + rpath | xrpath) + # We need an absolute path. + case $arg in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + $echo "$modename: only absolute run-paths are allowed" 1>&2 + exit $EXIT_FAILURE + ;; + esac + if test "$prev" = rpath; then + case "$rpath " in + *" $arg "*) ;; + *) rpath="$rpath $arg" ;; + esac + else + case "$xrpath " in + *" $arg "*) ;; + *) xrpath="$xrpath $arg" ;; + esac + fi + prev= + continue + ;; + xcompiler) + compiler_flags="$compiler_flags $qarg" + prev= + compile_command="$compile_command $qarg" + finalize_command="$finalize_command $qarg" + continue + ;; + xlinker) + linker_flags="$linker_flags $qarg" + compiler_flags="$compiler_flags $wl$qarg" + prev= + compile_command="$compile_command $wl$qarg" + finalize_command="$finalize_command $wl$qarg" + continue + ;; + xcclinker) + linker_flags="$linker_flags $qarg" + compiler_flags="$compiler_flags $qarg" + prev= + compile_command="$compile_command $qarg" + finalize_command="$finalize_command $qarg" + continue + ;; + shrext) + shrext_cmds="$arg" + prev= + continue + ;; + *) + eval "$prev=\"\$arg\"" + prev= + continue + ;; + esac + fi # test -n "$prev" + + prevarg="$arg" + + case $arg in + -all-static) + if test -n "$link_static_flag"; then + compile_command="$compile_command $link_static_flag" + finalize_command="$finalize_command $link_static_flag" + fi + continue + ;; + + -allow-undefined) + # FIXME: remove this flag sometime in the future. + $echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2 + continue + ;; + + -avoid-version) + avoid_version=yes + continue + ;; + + -dlopen) + prev=dlfiles + continue + ;; + + -dlpreopen) + prev=dlprefiles + continue + ;; + + -export-dynamic) + export_dynamic=yes + continue + ;; + + -export-symbols | -export-symbols-regex) + if test -n "$export_symbols" || test -n "$export_symbols_regex"; then + $echo "$modename: more than one -exported-symbols argument is not allowed" + exit $EXIT_FAILURE + fi + if test "X$arg" = "X-export-symbols"; then + prev=expsyms + else + prev=expsyms_regex + fi + continue + ;; + + -inst-prefix-dir) + prev=inst_prefix + continue + ;; + + # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* + # so, if we see these flags be careful not to treat them like -L + -L[A-Z][A-Z]*:*) + case $with_gcc/$host in + no/*-*-irix* | /*-*-irix*) + compile_command="$compile_command $arg" + finalize_command="$finalize_command $arg" + ;; + esac + continue + ;; + + -L*) + dir=`$echo "X$arg" | $Xsed -e 's/^-L//'` + # We need an absolute path. + case $dir in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + absdir=`cd "$dir" && pwd` + if test -z "$absdir"; then + $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2 + exit $EXIT_FAILURE + fi + dir="$absdir" + ;; + esac + case "$deplibs " in + *" -L$dir "*) ;; + *) + deplibs="$deplibs -L$dir" + lib_search_path="$lib_search_path $dir" + ;; + esac + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) + case :$dllsearchpath: in + *":$dir:"*) ;; + *) dllsearchpath="$dllsearchpath:$dir";; + esac + ;; + esac + continue + ;; + + -l*) + if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then + case $host in + *-*-cygwin* | *-*-pw32* | *-*-beos*) + # These systems don't actually have a C or math library (as such) + continue + ;; + *-*-mingw* | *-*-os2*) + # These systems don't actually have a C library (as such) + test "X$arg" = "X-lc" && continue + ;; + *-*-openbsd* | *-*-freebsd*) + # Do not include libc due to us having libc/libc_r. + test "X$arg" = "X-lc" && continue + ;; + *-*-rhapsody* | *-*-darwin1.[012]) + # Rhapsody C and math libraries are in the System framework + deplibs="$deplibs -framework System" + continue + esac + elif test "X$arg" = "X-lc_r"; then + case $host in + *-*-openbsd* | *-*-freebsd*) + # Do not include libc_r directly, use -pthread flag. + continue + ;; + esac + fi + deplibs="$deplibs $arg" + continue + ;; + + -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe) + deplibs="$deplibs $arg" + continue + ;; + + -module) + module=yes + continue + ;; + + # gcc -m* arguments should be passed to the linker via $compiler_flags + # in order to pass architecture information to the linker + # (e.g. 32 vs 64-bit). This may also be accomplished via -Wl,-mfoo + # but this is not reliable with gcc because gcc may use -mfoo to + # select a different linker, different libraries, etc, while + # -Wl,-mfoo simply passes -mfoo to the linker. + -m*) + # Unknown arguments in both finalize_command and compile_command need + # to be aesthetically quoted because they are evaled later. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + arg="\"$arg\"" + ;; + esac + compile_command="$compile_command $arg" + finalize_command="$finalize_command $arg" + if test "$with_gcc" = "yes" ; then + compiler_flags="$compiler_flags $arg" + fi + continue + ;; + + -shrext) + prev=shrext + continue + ;; + + -no-fast-install) + fast_install=no + continue + ;; + + -no-install) + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) + # The PATH hackery in wrapper scripts is required on Windows + # in order for the loader to find any dlls it needs. + $echo "$modename: warning: \`-no-install' is ignored for $host" 1>&2 + $echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2 + fast_install=no + ;; + *) no_install=yes ;; + esac + continue + ;; + + -no-undefined) + allow_undefined=no + continue + ;; + + -objectlist) + prev=objectlist + continue + ;; + + -o) prev=output ;; + + -precious-files-regex) + prev=precious_regex + continue + ;; + + -release) + prev=release + continue + ;; + + -rpath) + prev=rpath + continue + ;; + + -R) + prev=xrpath + continue + ;; + + -R*) + dir=`$echo "X$arg" | $Xsed -e 's/^-R//'` + # We need an absolute path. + case $dir in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + $echo "$modename: only absolute run-paths are allowed" 1>&2 + exit $EXIT_FAILURE + ;; + esac + case "$xrpath " in + *" $dir "*) ;; + *) xrpath="$xrpath $dir" ;; + esac + continue + ;; + + -static) + # The effects of -static are defined in a previous loop. + # We used to do the same as -all-static on platforms that + # didn't have a PIC flag, but the assumption that the effects + # would be equivalent was wrong. It would break on at least + # Digital Unix and AIX. + continue + ;; + + -thread-safe) + thread_safe=yes + continue + ;; + + -version-info) + prev=vinfo + continue + ;; + -version-number) + prev=vinfo + vinfo_number=yes + continue + ;; + + -Wc,*) + args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'` + arg= + save_ifs="$IFS"; IFS=',' + for flag in $args; do + IFS="$save_ifs" + case $flag in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + flag="\"$flag\"" + ;; + esac + arg="$arg $wl$flag" + compiler_flags="$compiler_flags $flag" + done + IFS="$save_ifs" + arg=`$echo "X$arg" | $Xsed -e "s/^ //"` + ;; + + -Wl,*) + args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wl,//'` + arg= + save_ifs="$IFS"; IFS=',' + for flag in $args; do + IFS="$save_ifs" + case $flag in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + flag="\"$flag\"" + ;; + esac + arg="$arg $wl$flag" + compiler_flags="$compiler_flags $wl$flag" + linker_flags="$linker_flags $flag" + done + IFS="$save_ifs" + arg=`$echo "X$arg" | $Xsed -e "s/^ //"` + ;; + + -Xcompiler) + prev=xcompiler + continue + ;; + + -Xlinker) + prev=xlinker + continue + ;; + + -XCClinker) + prev=xcclinker + continue + ;; + + # Some other compiler flag. + -* | +*) + # Unknown arguments in both finalize_command and compile_command need + # to be aesthetically quoted because they are evaled later. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + arg="\"$arg\"" + ;; + esac + ;; + + *.$objext) + # A standard object. + objs="$objs $arg" + ;; + + *.lo) + # A libtool-controlled object. + + # Check to see that this really is a libtool object. + if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + pic_object= + non_pic_object= + + # Read the .lo file + # If there is no directory component, then add one. + case $arg in + */* | *\\*) . $arg ;; + *) . ./$arg ;; + esac + + if test -z "$pic_object" || \ + test -z "$non_pic_object" || + test "$pic_object" = none && \ + test "$non_pic_object" = none; then + $echo "$modename: cannot find name of object for \`$arg'" 1>&2 + exit $EXIT_FAILURE + fi + + # Extract subdirectory from the argument. + xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$arg"; then + xdir= + else + xdir="$xdir/" + fi + + if test "$pic_object" != none; then + # Prepend the subdirectory the object is found in. + pic_object="$xdir$pic_object" + + if test "$prev" = dlfiles; then + if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then + dlfiles="$dlfiles $pic_object" + prev= + continue + else + # If libtool objects are unsupported, then we need to preload. + prev=dlprefiles + fi + fi + + # CHECK ME: I think I busted this. -Ossama + if test "$prev" = dlprefiles; then + # Preload the old-style object. + dlprefiles="$dlprefiles $pic_object" + prev= + fi + + # A PIC object. + libobjs="$libobjs $pic_object" + arg="$pic_object" + fi + + # Non-PIC object. + if test "$non_pic_object" != none; then + # Prepend the subdirectory the object is found in. + non_pic_object="$xdir$non_pic_object" + + # A standard non-PIC object + non_pic_objects="$non_pic_objects $non_pic_object" + if test -z "$pic_object" || test "$pic_object" = none ; then + arg="$non_pic_object" + fi + fi + else + # Only an error if not doing a dry-run. + if test -z "$run"; then + $echo "$modename: \`$arg' is not a valid libtool object" 1>&2 + exit $EXIT_FAILURE + else + # Dry-run case. + + # Extract subdirectory from the argument. + xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$arg"; then + xdir= + else + xdir="$xdir/" + fi + + pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"` + non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"` + libobjs="$libobjs $pic_object" + non_pic_objects="$non_pic_objects $non_pic_object" + fi + fi + ;; + + *.$libext) + # An archive. + deplibs="$deplibs $arg" + old_deplibs="$old_deplibs $arg" + continue + ;; + + *.la) + # A libtool-controlled library. + + if test "$prev" = dlfiles; then + # This library was specified with -dlopen. + dlfiles="$dlfiles $arg" + prev= + elif test "$prev" = dlprefiles; then + # The library was specified with -dlpreopen. + dlprefiles="$dlprefiles $arg" + prev= + else + deplibs="$deplibs $arg" + fi + continue + ;; + + # Some other compiler argument. + *) + # Unknown arguments in both finalize_command and compile_command need + # to be aesthetically quoted because they are evaled later. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + arg="\"$arg\"" + ;; + esac + ;; + esac # arg + + # Now actually substitute the argument into the commands. + if test -n "$arg"; then + compile_command="$compile_command $arg" + finalize_command="$finalize_command $arg" + fi + done # argument parsing loop + + if test -n "$prev"; then + $echo "$modename: the \`$prevarg' option requires an argument" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then + eval arg=\"$export_dynamic_flag_spec\" + compile_command="$compile_command $arg" + finalize_command="$finalize_command $arg" + fi + + oldlibs= + # calculate the name of the file, without its directory + outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'` + libobjs_save="$libobjs" + + if test -n "$shlibpath_var"; then + # get the directories listed in $shlibpath_var + eval shlib_search_path=\`\$echo \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\` + else + shlib_search_path= + fi + eval sys_lib_search_path=\"$sys_lib_search_path_spec\" + eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" + + output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'` + if test "X$output_objdir" = "X$output"; then + output_objdir="$objdir" + else + output_objdir="$output_objdir/$objdir" + fi + # Create the object directory. + if test ! -d "$output_objdir"; then + $show "$mkdir $output_objdir" + $run $mkdir $output_objdir + status=$? + if test "$status" -ne 0 && test ! -d "$output_objdir"; then + exit $status + fi + fi + + # Determine the type of output + case $output in + "") + $echo "$modename: you must specify an output file" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + ;; + *.$libext) linkmode=oldlib ;; + *.lo | *.$objext) linkmode=obj ;; + *.la) linkmode=lib ;; + *) linkmode=prog ;; # Anything else should be a program. + esac + + case $host in + *cygwin* | *mingw* | *pw32*) + # don't eliminate duplications in $postdeps and $predeps + duplicate_compiler_generated_deps=yes + ;; + *) + duplicate_compiler_generated_deps=$duplicate_deps + ;; + esac + specialdeplibs= + + libs= + # Find all interdependent deplibs by searching for libraries + # that are linked more than once (e.g. -la -lb -la) + for deplib in $deplibs; do + if test "X$duplicate_deps" = "Xyes" ; then + case "$libs " in + *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; + esac + fi + libs="$libs $deplib" + done + + if test "$linkmode" = lib; then + libs="$predeps $libs $compiler_lib_search_path $postdeps" + + # Compute libraries that are listed more than once in $predeps + # $postdeps and mark them as special (i.e., whose duplicates are + # not to be eliminated). + pre_post_deps= + if test "X$duplicate_compiler_generated_deps" = "Xyes" ; then + for pre_post_dep in $predeps $postdeps; do + case "$pre_post_deps " in + *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;; + esac + pre_post_deps="$pre_post_deps $pre_post_dep" + done + fi + pre_post_deps= + fi + + deplibs= + newdependency_libs= + newlib_search_path= + need_relink=no # whether we're linking any uninstalled libtool libraries + notinst_deplibs= # not-installed libtool libraries + notinst_path= # paths that contain not-installed libtool libraries + case $linkmode in + lib) + passes="conv link" + for file in $dlfiles $dlprefiles; do + case $file in + *.la) ;; + *) + $echo "$modename: libraries can \`-dlopen' only libtool libraries: $file" 1>&2 + exit $EXIT_FAILURE + ;; + esac + done + ;; + prog) + compile_deplibs= + finalize_deplibs= + alldeplibs=no + newdlfiles= + newdlprefiles= + passes="conv scan dlopen dlpreopen link" + ;; + *) passes="conv" + ;; + esac + for pass in $passes; do + if test "$linkmode,$pass" = "lib,link" || + test "$linkmode,$pass" = "prog,scan"; then + libs="$deplibs" + deplibs= + fi + if test "$linkmode" = prog; then + case $pass in + dlopen) libs="$dlfiles" ;; + dlpreopen) libs="$dlprefiles" ;; + link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; + esac + fi + if test "$pass" = dlopen; then + # Collect dlpreopened libraries + save_deplibs="$deplibs" + deplibs= + fi + for deplib in $libs; do + lib= + found=no + case $deplib in + -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe) + if test "$linkmode,$pass" = "prog,link"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + deplibs="$deplib $deplibs" + fi + continue + ;; + -l*) + if test "$linkmode" != lib && test "$linkmode" != prog; then + $echo "$modename: warning: \`-l' is ignored for archives/objects" 1>&2 + continue + fi + if test "$pass" = conv; then + deplibs="$deplib $deplibs" + continue + fi + name=`$echo "X$deplib" | $Xsed -e 's/^-l//'` + for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; do + for search_ext in .la $std_shrext .so .a; do + # Search the libtool library + lib="$searchdir/lib${name}${search_ext}" + if test -f "$lib"; then + if test "$search_ext" = ".la"; then + found=yes + else + found=no + fi + break 2 + fi + done + done + if test "$found" != yes; then + # deplib doesn't seem to be a libtool library + if test "$linkmode,$pass" = "prog,link"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + deplibs="$deplib $deplibs" + test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" + fi + continue + else # deplib is a libtool library + # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, + # We need to do some special things here, and not later. + if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then + case " $predeps $postdeps " in + *" $deplib "*) + if (${SED} -e '2q' $lib | + grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + library_names= + old_library= + case $lib in + */* | *\\*) . $lib ;; + *) . ./$lib ;; + esac + for l in $old_library $library_names; do + ll="$l" + done + if test "X$ll" = "X$old_library" ; then # only static version available + found=no + ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'` + test "X$ladir" = "X$lib" && ladir="." + lib=$ladir/$old_library + if test "$linkmode,$pass" = "prog,link"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + deplibs="$deplib $deplibs" + test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" + fi + continue + fi + fi + ;; + *) ;; + esac + fi + fi + ;; # -l + -L*) + case $linkmode in + lib) + deplibs="$deplib $deplibs" + test "$pass" = conv && continue + newdependency_libs="$deplib $newdependency_libs" + newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'` + ;; + prog) + if test "$pass" = conv; then + deplibs="$deplib $deplibs" + continue + fi + if test "$pass" = scan; then + deplibs="$deplib $deplibs" + else + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + fi + newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'` + ;; + *) + $echo "$modename: warning: \`-L' is ignored for archives/objects" 1>&2 + ;; + esac # linkmode + continue + ;; # -L + -R*) + if test "$pass" = link; then + dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'` + # Make sure the xrpath contains only unique directories. + case "$xrpath " in + *" $dir "*) ;; + *) xrpath="$xrpath $dir" ;; + esac + fi + deplibs="$deplib $deplibs" + continue + ;; + *.la) lib="$deplib" ;; + *.$libext) + if test "$pass" = conv; then + deplibs="$deplib $deplibs" + continue + fi + case $linkmode in + lib) + if test "$deplibs_check_method" != pass_all; then + $echo + $echo "*** Warning: Trying to link with static lib archive $deplib." + $echo "*** I have the capability to make that library automatically link in when" + $echo "*** you link to this library. But I can only do this if you have a" + $echo "*** shared version of the library, which you do not appear to have" + $echo "*** because the file extensions .$libext of this argument makes me believe" + $echo "*** that it is just a static archive that I should not used here." + else + $echo + $echo "*** Warning: Linking the shared library $output against the" + $echo "*** static library $deplib is not portable!" + deplibs="$deplib $deplibs" + fi + continue + ;; + prog) + if test "$pass" != link; then + deplibs="$deplib $deplibs" + else + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + fi + continue + ;; + esac # linkmode + ;; # *.$libext + *.lo | *.$objext) + if test "$pass" = conv; then + deplibs="$deplib $deplibs" + elif test "$linkmode" = prog; then + if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then + # If there is no dlopen support or we're linking statically, + # we need to preload. + newdlprefiles="$newdlprefiles $deplib" + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + newdlfiles="$newdlfiles $deplib" + fi + fi + continue + ;; + %DEPLIBS%) + alldeplibs=yes + continue + ;; + esac # case $deplib + if test "$found" = yes || test -f "$lib"; then : + else + $echo "$modename: cannot find the library \`$lib'" 1>&2 + exit $EXIT_FAILURE + fi + + # Check to see that this really is a libtool archive. + if (${SED} -e '2q' $lib | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : + else + $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 + exit $EXIT_FAILURE + fi + + ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'` + test "X$ladir" = "X$lib" && ladir="." + + dlname= + dlopen= + dlpreopen= + libdir= + library_names= + old_library= + # If the library was installed with an old release of libtool, + # it will not redefine variables installed, or shouldnotlink + installed=yes + shouldnotlink=no + + # Read the .la file + case $lib in + */* | *\\*) . $lib ;; + *) . ./$lib ;; + esac + + if test "$linkmode,$pass" = "lib,link" || + test "$linkmode,$pass" = "prog,scan" || + { test "$linkmode" != prog && test "$linkmode" != lib; }; then + test -n "$dlopen" && dlfiles="$dlfiles $dlopen" + test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen" + fi + + if test "$pass" = conv; then + # Only check for convenience libraries + deplibs="$lib $deplibs" + if test -z "$libdir"; then + if test -z "$old_library"; then + $echo "$modename: cannot find name of link library for \`$lib'" 1>&2 + exit $EXIT_FAILURE + fi + # It is a libtool convenience library, so add in its objects. + convenience="$convenience $ladir/$objdir/$old_library" + old_convenience="$old_convenience $ladir/$objdir/$old_library" + tmp_libs= + for deplib in $dependency_libs; do + deplibs="$deplib $deplibs" + if test "X$duplicate_deps" = "Xyes" ; then + case "$tmp_libs " in + *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; + esac + fi + tmp_libs="$tmp_libs $deplib" + done + elif test "$linkmode" != prog && test "$linkmode" != lib; then + $echo "$modename: \`$lib' is not a convenience library" 1>&2 + exit $EXIT_FAILURE + fi + continue + fi # $pass = conv + + + # Get the name of the library we link against. + linklib= + for l in $old_library $library_names; do + linklib="$l" + done + if test -z "$linklib"; then + $echo "$modename: cannot find name of link library for \`$lib'" 1>&2 + exit $EXIT_FAILURE + fi + + # This library was specified with -dlopen. + if test "$pass" = dlopen; then + if test -z "$libdir"; then + $echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2 + exit $EXIT_FAILURE + fi + if test -z "$dlname" || + test "$dlopen_support" != yes || + test "$build_libtool_libs" = no; then + # If there is no dlname, no dlopen support or we're linking + # statically, we need to preload. We also need to preload any + # dependent libraries so libltdl's deplib preloader doesn't + # bomb out in the load deplibs phase. + dlprefiles="$dlprefiles $lib $dependency_libs" + else + newdlfiles="$newdlfiles $lib" + fi + continue + fi # $pass = dlopen + + # We need an absolute path. + case $ladir in + [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; + *) + abs_ladir=`cd "$ladir" && pwd` + if test -z "$abs_ladir"; then + $echo "$modename: warning: cannot determine absolute directory name of \`$ladir'" 1>&2 + $echo "$modename: passing it literally to the linker, although it might fail" 1>&2 + abs_ladir="$ladir" + fi + ;; + esac + laname=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` + + # Find the relevant object directory and library name. + if test "X$installed" = Xyes; then + if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then + $echo "$modename: warning: library \`$lib' was moved." 1>&2 + dir="$ladir" + absdir="$abs_ladir" + libdir="$abs_ladir" + else + dir="$libdir" + absdir="$libdir" + fi + else + dir="$ladir/$objdir" + absdir="$abs_ladir/$objdir" + # Remove this search path later + notinst_path="$notinst_path $abs_ladir" + fi # $installed = yes + name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'` + + # This library was specified with -dlpreopen. + if test "$pass" = dlpreopen; then + if test -z "$libdir"; then + $echo "$modename: cannot -dlpreopen a convenience library: \`$lib'" 1>&2 + exit $EXIT_FAILURE + fi + # Prefer using a static library (so that no silly _DYNAMIC symbols + # are required to link). + if test -n "$old_library"; then + newdlprefiles="$newdlprefiles $dir/$old_library" + # Otherwise, use the dlname, so that lt_dlopen finds it. + elif test -n "$dlname"; then + newdlprefiles="$newdlprefiles $dir/$dlname" + else + newdlprefiles="$newdlprefiles $dir/$linklib" + fi + fi # $pass = dlpreopen + + if test -z "$libdir"; then + # Link the convenience library + if test "$linkmode" = lib; then + deplibs="$dir/$old_library $deplibs" + elif test "$linkmode,$pass" = "prog,link"; then + compile_deplibs="$dir/$old_library $compile_deplibs" + finalize_deplibs="$dir/$old_library $finalize_deplibs" + else + deplibs="$lib $deplibs" # used for prog,scan pass + fi + continue + fi + + + if test "$linkmode" = prog && test "$pass" != link; then + newlib_search_path="$newlib_search_path $ladir" + deplibs="$lib $deplibs" + + linkalldeplibs=no + if test "$link_all_deplibs" != no || test -z "$library_names" || + test "$build_libtool_libs" = no; then + linkalldeplibs=yes + fi + + tmp_libs= + for deplib in $dependency_libs; do + case $deplib in + -L*) newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test + esac + # Need to link against all dependency_libs? + if test "$linkalldeplibs" = yes; then + deplibs="$deplib $deplibs" + else + # Need to hardcode shared library paths + # or/and link against static libraries + newdependency_libs="$deplib $newdependency_libs" + fi + if test "X$duplicate_deps" = "Xyes" ; then + case "$tmp_libs " in + *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; + esac + fi + tmp_libs="$tmp_libs $deplib" + done # for deplib + continue + fi # $linkmode = prog... + + if test "$linkmode,$pass" = "prog,link"; then + if test -n "$library_names" && + { test "$prefer_static_libs" = no || test -z "$old_library"; }; then + # We need to hardcode the library path + if test -n "$shlibpath_var"; then + # Make sure the rpath contains only unique directories. + case "$temp_rpath " in + *" $dir "*) ;; + *" $absdir "*) ;; + *) temp_rpath="$temp_rpath $dir" ;; + esac + fi + + # Hardcode the library path. + # Skip directories that are in the system default run-time + # search path. + case " $sys_lib_dlsearch_path " in + *" $absdir "*) ;; + *) + case "$compile_rpath " in + *" $absdir "*) ;; + *) compile_rpath="$compile_rpath $absdir" + esac + ;; + esac + case " $sys_lib_dlsearch_path " in + *" $libdir "*) ;; + *) + case "$finalize_rpath " in + *" $libdir "*) ;; + *) finalize_rpath="$finalize_rpath $libdir" + esac + ;; + esac + fi # $linkmode,$pass = prog,link... + + if test "$alldeplibs" = yes && + { test "$deplibs_check_method" = pass_all || + { test "$build_libtool_libs" = yes && + test -n "$library_names"; }; }; then + # We only need to search for static libraries + continue + fi + fi + + link_static=no # Whether the deplib will be linked statically + if test -n "$library_names" && + { test "$prefer_static_libs" = no || test -z "$old_library"; }; then + if test "$installed" = no; then + notinst_deplibs="$notinst_deplibs $lib" + need_relink=yes + fi + # This is a shared library + + # Warn about portability, can't link against -module's on + # some systems (darwin) + if test "$shouldnotlink" = yes && test "$pass" = link ; then + $echo + if test "$linkmode" = prog; then + $echo "*** Warning: Linking the executable $output against the loadable module" + else + $echo "*** Warning: Linking the shared library $output against the loadable module" + fi + $echo "*** $linklib is not portable!" + fi + if test "$linkmode" = lib && + test "$hardcode_into_libs" = yes; then + # Hardcode the library path. + # Skip directories that are in the system default run-time + # search path. + case " $sys_lib_dlsearch_path " in + *" $absdir "*) ;; + *) + case "$compile_rpath " in + *" $absdir "*) ;; + *) compile_rpath="$compile_rpath $absdir" + esac + ;; + esac + case " $sys_lib_dlsearch_path " in + *" $libdir "*) ;; + *) + case "$finalize_rpath " in + *" $libdir "*) ;; + *) finalize_rpath="$finalize_rpath $libdir" + esac + ;; + esac + fi + + if test -n "$old_archive_from_expsyms_cmds"; then + # figure out the soname + set dummy $library_names + realname="$2" + shift; shift + libname=`eval \\$echo \"$libname_spec\"` + # use dlname if we got it. it's perfectly good, no? + if test -n "$dlname"; then + soname="$dlname" + elif test -n "$soname_spec"; then + # bleh windows + case $host in + *cygwin* | mingw*) + major=`expr $current - $age` + versuffix="-$major" + ;; + esac + eval soname=\"$soname_spec\" + else + soname="$realname" + fi + + # Make a new name for the extract_expsyms_cmds to use + soroot="$soname" + soname=`$echo $soroot | ${SED} -e 's/^.*\///'` + newlib="libimp-`$echo $soname | ${SED} 's/^lib//;s/\.dll$//'`.a" + + # If the library has no export list, then create one now + if test -f "$output_objdir/$soname-def"; then : + else + $show "extracting exported symbol list from \`$soname'" + save_ifs="$IFS"; IFS='~' + cmds=$extract_expsyms_cmds + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + fi + + # Create $newlib + if test -f "$output_objdir/$newlib"; then :; else + $show "generating import library for \`$soname'" + save_ifs="$IFS"; IFS='~' + cmds=$old_archive_from_expsyms_cmds + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + fi + # make sure the library variables are pointing to the new library + dir=$output_objdir + linklib=$newlib + fi # test -n "$old_archive_from_expsyms_cmds" + + if test "$linkmode" = prog || test "$mode" != relink; then + add_shlibpath= + add_dir= + add= + lib_linked=yes + case $hardcode_action in + immediate | unsupported) + if test "$hardcode_direct" = no; then + add="$dir/$linklib" + case $host in + *-*-sco3.2v5* ) add_dir="-L$dir" ;; + *-*-darwin* ) + # if the lib is a module then we can not link against + # it, someone is ignoring the new warnings I added + if /usr/bin/file -L $add 2> /dev/null | $EGREP "bundle" >/dev/null ; then + $echo "** Warning, lib $linklib is a module, not a shared library" + if test -z "$old_library" ; then + $echo + $echo "** And there doesn't seem to be a static archive available" + $echo "** The link will probably fail, sorry" + else + add="$dir/$old_library" + fi + fi + esac + elif test "$hardcode_minus_L" = no; then + case $host in + *-*-sunos*) add_shlibpath="$dir" ;; + esac + add_dir="-L$dir" + add="-l$name" + elif test "$hardcode_shlibpath_var" = no; then + add_shlibpath="$dir" + add="-l$name" + else + lib_linked=no + fi + ;; + relink) + if test "$hardcode_direct" = yes; then + add="$dir/$linklib" + elif test "$hardcode_minus_L" = yes; then + add_dir="-L$dir" + # Try looking first in the location we're being installed to. + if test -n "$inst_prefix_dir"; then + case "$libdir" in + [\\/]*) + add_dir="$add_dir -L$inst_prefix_dir$libdir" + ;; + esac + fi + add="-l$name" + elif test "$hardcode_shlibpath_var" = yes; then + add_shlibpath="$dir" + add="-l$name" + else + lib_linked=no + fi + ;; + *) lib_linked=no ;; + esac + + if test "$lib_linked" != yes; then + $echo "$modename: configuration error: unsupported hardcode properties" + exit $EXIT_FAILURE + fi + + if test -n "$add_shlibpath"; then + case :$compile_shlibpath: in + *":$add_shlibpath:"*) ;; + *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;; + esac + fi + if test "$linkmode" = prog; then + test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" + test -n "$add" && compile_deplibs="$add $compile_deplibs" + else + test -n "$add_dir" && deplibs="$add_dir $deplibs" + test -n "$add" && deplibs="$add $deplibs" + if test "$hardcode_direct" != yes && \ + test "$hardcode_minus_L" != yes && \ + test "$hardcode_shlibpath_var" = yes; then + case :$finalize_shlibpath: in + *":$libdir:"*) ;; + *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; + esac + fi + fi + fi + + if test "$linkmode" = prog || test "$mode" = relink; then + add_shlibpath= + add_dir= + add= + # Finalize command for both is simple: just hardcode it. + if test "$hardcode_direct" = yes; then + add="$libdir/$linklib" + elif test "$hardcode_minus_L" = yes; then + add_dir="-L$libdir" + add="-l$name" + elif test "$hardcode_shlibpath_var" = yes; then + case :$finalize_shlibpath: in + *":$libdir:"*) ;; + *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; + esac + add="-l$name" + elif test "$hardcode_automatic" = yes; then + if test -n "$inst_prefix_dir" && + test -f "$inst_prefix_dir$libdir/$linklib" ; then + add="$inst_prefix_dir$libdir/$linklib" + else + add="$libdir/$linklib" + fi + else + # We cannot seem to hardcode it, guess we'll fake it. + add_dir="-L$libdir" + # Try looking first in the location we're being installed to. + if test -n "$inst_prefix_dir"; then + case "$libdir" in + [\\/]*) + add_dir="$add_dir -L$inst_prefix_dir$libdir" + ;; + esac + fi + add="-l$name" + fi + + if test "$linkmode" = prog; then + test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" + test -n "$add" && finalize_deplibs="$add $finalize_deplibs" + else + test -n "$add_dir" && deplibs="$add_dir $deplibs" + test -n "$add" && deplibs="$add $deplibs" + fi + fi + elif test "$linkmode" = prog; then + # Here we assume that one of hardcode_direct or hardcode_minus_L + # is not unsupported. This is valid on all known static and + # shared platforms. + if test "$hardcode_direct" != unsupported; then + test -n "$old_library" && linklib="$old_library" + compile_deplibs="$dir/$linklib $compile_deplibs" + finalize_deplibs="$dir/$linklib $finalize_deplibs" + else + compile_deplibs="-l$name -L$dir $compile_deplibs" + finalize_deplibs="-l$name -L$dir $finalize_deplibs" + fi + elif test "$build_libtool_libs" = yes; then + # Not a shared library + if test "$deplibs_check_method" != pass_all; then + # We're trying link a shared library against a static one + # but the system doesn't support it. + + # Just print a warning and add the library to dependency_libs so + # that the program can be linked against the static library. + $echo + $echo "*** Warning: This system can not link to static lib archive $lib." + $echo "*** I have the capability to make that library automatically link in when" + $echo "*** you link to this library. But I can only do this if you have a" + $echo "*** shared version of the library, which you do not appear to have." + if test "$module" = yes; then + $echo "*** But as you try to build a module library, libtool will still create " + $echo "*** a static module, that should work as long as the dlopening application" + $echo "*** is linked with the -dlopen flag to resolve symbols at runtime." + if test -z "$global_symbol_pipe"; then + $echo + $echo "*** However, this would only work if libtool was able to extract symbol" + $echo "*** lists from a program, using \`nm' or equivalent, but libtool could" + $echo "*** not find such a program. So, this module is probably useless." + $echo "*** \`nm' from GNU binutils and a full rebuild may help." + fi + if test "$build_old_libs" = no; then + build_libtool_libs=module + build_old_libs=yes + else + build_libtool_libs=no + fi + fi + else + convenience="$convenience $dir/$old_library" + old_convenience="$old_convenience $dir/$old_library" + deplibs="$dir/$old_library $deplibs" + link_static=yes + fi + fi # link shared/static library? + + if test "$linkmode" = lib; then + if test -n "$dependency_libs" && + { test "$hardcode_into_libs" != yes || + test "$build_old_libs" = yes || + test "$link_static" = yes; }; then + # Extract -R from dependency_libs + temp_deplibs= + for libdir in $dependency_libs; do + case $libdir in + -R*) temp_xrpath=`$echo "X$libdir" | $Xsed -e 's/^-R//'` + case " $xrpath " in + *" $temp_xrpath "*) ;; + *) xrpath="$xrpath $temp_xrpath";; + esac;; + *) temp_deplibs="$temp_deplibs $libdir";; + esac + done + dependency_libs="$temp_deplibs" + fi + + newlib_search_path="$newlib_search_path $absdir" + # Link against this library + test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" + # ... and its dependency_libs + tmp_libs= + for deplib in $dependency_libs; do + newdependency_libs="$deplib $newdependency_libs" + if test "X$duplicate_deps" = "Xyes" ; then + case "$tmp_libs " in + *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; + esac + fi + tmp_libs="$tmp_libs $deplib" + done + + if test "$link_all_deplibs" != no; then + # Add the search paths of all dependency libraries + for deplib in $dependency_libs; do + case $deplib in + -L*) path="$deplib" ;; + *.la) + dir=`$echo "X$deplib" | $Xsed -e 's%/[^/]*$%%'` + test "X$dir" = "X$deplib" && dir="." + # We need an absolute path. + case $dir in + [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; + *) + absdir=`cd "$dir" && pwd` + if test -z "$absdir"; then + $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2 + absdir="$dir" + fi + ;; + esac + if grep "^installed=no" $deplib > /dev/null; then + path="$absdir/$objdir" + else + eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` + if test -z "$libdir"; then + $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2 + exit $EXIT_FAILURE + fi + if test "$absdir" != "$libdir"; then + $echo "$modename: warning: \`$deplib' seems to be moved" 1>&2 + fi + path="$absdir" + fi + depdepl= + case $host in + *-*-darwin*) + # we do not want to link against static libs, + # but need to link against shared + eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` + if test -n "$deplibrary_names" ; then + for tmp in $deplibrary_names ; do + depdepl=$tmp + done + if test -f "$path/$depdepl" ; then + depdepl="$path/$depdepl" + fi + # do not add paths which are already there + case " $newlib_search_path " in + *" $path "*) ;; + *) newlib_search_path="$newlib_search_path $path";; + esac + fi + path="" + ;; + *) + path="-L$path" + ;; + esac + ;; + -l*) + case $host in + *-*-darwin*) + # Again, we only want to link against shared libraries + eval tmp_libs=`$echo "X$deplib" | $Xsed -e "s,^\-l,,"` + for tmp in $newlib_search_path ; do + if test -f "$tmp/lib$tmp_libs.dylib" ; then + eval depdepl="$tmp/lib$tmp_libs.dylib" + break + fi + done + path="" + ;; + *) continue ;; + esac + ;; + *) continue ;; + esac + case " $deplibs " in + *" $depdepl "*) ;; + *) deplibs="$depdepl $deplibs" ;; + esac + case " $deplibs " in + *" $path "*) ;; + *) deplibs="$deplibs $path" ;; + esac + done + fi # link_all_deplibs != no + fi # linkmode = lib + done # for deplib in $libs + dependency_libs="$newdependency_libs" + if test "$pass" = dlpreopen; then + # Link the dlpreopened libraries before other libraries + for deplib in $save_deplibs; do + deplibs="$deplib $deplibs" + done + fi + if test "$pass" != dlopen; then + if test "$pass" != conv; then + # Make sure lib_search_path contains only unique directories. + lib_search_path= + for dir in $newlib_search_path; do + case "$lib_search_path " in + *" $dir "*) ;; + *) lib_search_path="$lib_search_path $dir" ;; + esac + done + newlib_search_path= + fi + + if test "$linkmode,$pass" != "prog,link"; then + vars="deplibs" + else + vars="compile_deplibs finalize_deplibs" + fi + for var in $vars dependency_libs; do + # Add libraries to $var in reverse order + eval tmp_libs=\"\$$var\" + new_libs= + for deplib in $tmp_libs; do + # FIXME: Pedantically, this is the right thing to do, so + # that some nasty dependency loop isn't accidentally + # broken: + #new_libs="$deplib $new_libs" + # Pragmatically, this seems to cause very few problems in + # practice: + case $deplib in + -L*) new_libs="$deplib $new_libs" ;; + -R*) ;; + *) + # And here is the reason: when a library appears more + # than once as an explicit dependence of a library, or + # is implicitly linked in more than once by the + # compiler, it is considered special, and multiple + # occurrences thereof are not removed. Compare this + # with having the same library being listed as a + # dependency of multiple other libraries: in this case, + # we know (pedantically, we assume) the library does not + # need to be listed more than once, so we keep only the + # last copy. This is not always right, but it is rare + # enough that we require users that really mean to play + # such unportable linking tricks to link the library + # using -Wl,-lname, so that libtool does not consider it + # for duplicate removal. + case " $specialdeplibs " in + *" $deplib "*) new_libs="$deplib $new_libs" ;; + *) + case " $new_libs " in + *" $deplib "*) ;; + *) new_libs="$deplib $new_libs" ;; + esac + ;; + esac + ;; + esac + done + tmp_libs= + for deplib in $new_libs; do + case $deplib in + -L*) + case " $tmp_libs " in + *" $deplib "*) ;; + *) tmp_libs="$tmp_libs $deplib" ;; + esac + ;; + *) tmp_libs="$tmp_libs $deplib" ;; + esac + done + eval $var=\"$tmp_libs\" + done # for var + fi + # Last step: remove runtime libs from dependency_libs + # (they stay in deplibs) + tmp_libs= + for i in $dependency_libs ; do + case " $predeps $postdeps $compiler_lib_search_path " in + *" $i "*) + i="" + ;; + esac + if test -n "$i" ; then + tmp_libs="$tmp_libs $i" + fi + done + dependency_libs=$tmp_libs + done # for pass + if test "$linkmode" = prog; then + dlfiles="$newdlfiles" + dlprefiles="$newdlprefiles" + fi + + case $linkmode in + oldlib) + if test -n "$deplibs"; then + $echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2 + fi + + if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then + $echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2 + fi + + if test -n "$rpath"; then + $echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2 + fi + + if test -n "$xrpath"; then + $echo "$modename: warning: \`-R' is ignored for archives" 1>&2 + fi + + if test -n "$vinfo"; then + $echo "$modename: warning: \`-version-info/-version-number' is ignored for archives" 1>&2 + fi + + if test -n "$release"; then + $echo "$modename: warning: \`-release' is ignored for archives" 1>&2 + fi + + if test -n "$export_symbols" || test -n "$export_symbols_regex"; then + $echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2 + fi + + # Now set the variables for building old libraries. + build_libtool_libs=no + oldlibs="$output" + objs="$objs$old_deplibs" + ;; + + lib) + # Make sure we only generate libraries of the form `libNAME.la'. + case $outputname in + lib*) + name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'` + eval shared_ext=\"$shrext_cmds\" + eval libname=\"$libname_spec\" + ;; + *) + if test "$module" = no; then + $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + if test "$need_lib_prefix" != no; then + # Add the "lib" prefix for modules if required + name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'` + eval shared_ext=\"$shrext_cmds\" + eval libname=\"$libname_spec\" + else + libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'` + fi + ;; + esac + + if test -n "$objs"; then + if test "$deplibs_check_method" != pass_all; then + $echo "$modename: cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 2>&1 + exit $EXIT_FAILURE + else + $echo + $echo "*** Warning: Linking the shared library $output against the non-libtool" + $echo "*** objects $objs is not portable!" + libobjs="$libobjs $objs" + fi + fi + + if test "$dlself" != no; then + $echo "$modename: warning: \`-dlopen self' is ignored for libtool libraries" 1>&2 + fi + + set dummy $rpath + if test "$#" -gt 2; then + $echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2 + fi + install_libdir="$2" + + oldlibs= + if test -z "$rpath"; then + if test "$build_libtool_libs" = yes; then + # Building a libtool convenience library. + # Some compilers have problems with a `.al' extension so + # convenience libraries should have the same extension an + # archive normally would. + oldlibs="$output_objdir/$libname.$libext $oldlibs" + build_libtool_libs=convenience + build_old_libs=yes + fi + + if test -n "$vinfo"; then + $echo "$modename: warning: \`-version-info/-version-number' is ignored for convenience libraries" 1>&2 + fi + + if test -n "$release"; then + $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2 + fi + else + + # Parse the version information argument. + save_ifs="$IFS"; IFS=':' + set dummy $vinfo 0 0 0 + IFS="$save_ifs" + + if test -n "$8"; then + $echo "$modename: too many parameters to \`-version-info'" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + # convert absolute version numbers to libtool ages + # this retains compatibility with .la files and attempts + # to make the code below a bit more comprehensible + + case $vinfo_number in + yes) + number_major="$2" + number_minor="$3" + number_revision="$4" + # + # There are really only two kinds -- those that + # use the current revision as the major version + # and those that subtract age and use age as + # a minor version. But, then there is irix + # which has an extra 1 added just for fun + # + case $version_type in + darwin|linux|osf|windows) + current=`expr $number_major + $number_minor` + age="$number_minor" + revision="$number_revision" + ;; + freebsd-aout|freebsd-elf|sunos) + current="$number_major" + revision="$number_minor" + age="0" + ;; + irix|nonstopux) + current=`expr $number_major + $number_minor - 1` + age="$number_minor" + revision="$number_minor" + ;; + esac + ;; + no) + current="$2" + revision="$3" + age="$4" + ;; + esac + + # Check that each of the things are valid numbers. + case $current in + [0-9]*) ;; + *) + $echo "$modename: CURRENT \`$current' is not a nonnegative integer" 1>&2 + $echo "$modename: \`$vinfo' is not valid version information" 1>&2 + exit $EXIT_FAILURE + ;; + esac + + case $revision in + [0-9]*) ;; + *) + $echo "$modename: REVISION \`$revision' is not a nonnegative integer" 1>&2 + $echo "$modename: \`$vinfo' is not valid version information" 1>&2 + exit $EXIT_FAILURE + ;; + esac + + case $age in + [0-9]*) ;; + *) + $echo "$modename: AGE \`$age' is not a nonnegative integer" 1>&2 + $echo "$modename: \`$vinfo' is not valid version information" 1>&2 + exit $EXIT_FAILURE + ;; + esac + + if test "$age" -gt "$current"; then + $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2 + $echo "$modename: \`$vinfo' is not valid version information" 1>&2 + exit $EXIT_FAILURE + fi + + # Calculate the version variables. + major= + versuffix= + verstring= + case $version_type in + none) ;; + + darwin) + # Like Linux, but with the current version available in + # verstring for coding it into the library header + major=.`expr $current - $age` + versuffix="$major.$age.$revision" + # Darwin ld doesn't like 0 for these options... + minor_current=`expr $current + 1` + verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" + ;; + + freebsd-aout) + major=".$current" + versuffix=".$current.$revision"; + ;; + + freebsd-elf) + major=".$current" + versuffix=".$current"; + ;; + + irix | nonstopux) + major=`expr $current - $age + 1` + + case $version_type in + nonstopux) verstring_prefix=nonstopux ;; + *) verstring_prefix=sgi ;; + esac + verstring="$verstring_prefix$major.$revision" + + # Add in all the interfaces that we are compatible with. + loop=$revision + while test "$loop" -ne 0; do + iface=`expr $revision - $loop` + loop=`expr $loop - 1` + verstring="$verstring_prefix$major.$iface:$verstring" + done + + # Before this point, $major must not contain `.'. + major=.$major + versuffix="$major.$revision" + ;; + + linux) + major=.`expr $current - $age` + versuffix="$major.$age.$revision" + ;; + + osf) + major=.`expr $current - $age` + versuffix=".$current.$age.$revision" + verstring="$current.$age.$revision" + + # Add in all the interfaces that we are compatible with. + loop=$age + while test "$loop" -ne 0; do + iface=`expr $current - $loop` + loop=`expr $loop - 1` + verstring="$verstring:${iface}.0" + done + + # Make executables depend on our current version. + verstring="$verstring:${current}.0" + ;; + + sunos) + major=".$current" + versuffix=".$current.$revision" + ;; + + windows) + # Use '-' rather than '.', since we only want one + # extension on DOS 8.3 filesystems. + major=`expr $current - $age` + versuffix="-$major" + ;; + + *) + $echo "$modename: unknown library version type \`$version_type'" 1>&2 + $echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 + exit $EXIT_FAILURE + ;; + esac + + # Clear the version info if we defaulted, and they specified a release. + if test -z "$vinfo" && test -n "$release"; then + major= + case $version_type in + darwin) + # we can't check for "0.0" in archive_cmds due to quoting + # problems, so we reset it completely + verstring= + ;; + *) + verstring="0.0" + ;; + esac + if test "$need_version" = no; then + versuffix= + else + versuffix=".0.0" + fi + fi + + # Remove version info from name if versioning should be avoided + if test "$avoid_version" = yes && test "$need_version" = no; then + major= + versuffix= + verstring="" + fi + + # Check to see if the archive will have undefined symbols. + if test "$allow_undefined" = yes; then + if test "$allow_undefined_flag" = unsupported; then + $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2 + build_libtool_libs=no + build_old_libs=yes + fi + else + # Don't allow undefined symbols. + allow_undefined_flag="$no_undefined_flag" + fi + fi + + if test "$mode" != relink; then + # Remove our outputs, but don't remove object files since they + # may have been created when compiling PIC objects. + removelist= + tempremovelist=`$echo "$output_objdir/*"` + for p in $tempremovelist; do + case $p in + *.$objext) + ;; + $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) + if test "X$precious_files_regex" != "X"; then + if echo $p | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 + then + continue + fi + fi + removelist="$removelist $p" + ;; + *) ;; + esac + done + if test -n "$removelist"; then + $show "${rm}r $removelist" + $run ${rm}r $removelist + fi + fi + + # Now set the variables for building old libraries. + if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then + oldlibs="$oldlibs $output_objdir/$libname.$libext" + + # Transform .lo files to .o files. + oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP` + fi + + # Eliminate all temporary directories. + for path in $notinst_path; do + lib_search_path=`$echo "$lib_search_path " | ${SED} -e 's% $path % %g'` + deplibs=`$echo "$deplibs " | ${SED} -e 's% -L$path % %g'` + dependency_libs=`$echo "$dependency_libs " | ${SED} -e 's% -L$path % %g'` + done + + if test -n "$xrpath"; then + # If the user specified any rpath flags, then add them. + temp_xrpath= + for libdir in $xrpath; do + temp_xrpath="$temp_xrpath -R$libdir" + case "$finalize_rpath " in + *" $libdir "*) ;; + *) finalize_rpath="$finalize_rpath $libdir" ;; + esac + done + if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then + dependency_libs="$temp_xrpath $dependency_libs" + fi + fi + + # Make sure dlfiles contains only unique files that won't be dlpreopened + old_dlfiles="$dlfiles" + dlfiles= + for lib in $old_dlfiles; do + case " $dlprefiles $dlfiles " in + *" $lib "*) ;; + *) dlfiles="$dlfiles $lib" ;; + esac + done + + # Make sure dlprefiles contains only unique files + old_dlprefiles="$dlprefiles" + dlprefiles= + for lib in $old_dlprefiles; do + case "$dlprefiles " in + *" $lib "*) ;; + *) dlprefiles="$dlprefiles $lib" ;; + esac + done + + if test "$build_libtool_libs" = yes; then + if test -n "$rpath"; then + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*) + # these systems don't actually have a c library (as such)! + ;; + *-*-rhapsody* | *-*-darwin1.[012]) + # Rhapsody C library is in the System framework + deplibs="$deplibs -framework System" + ;; + *-*-netbsd*) + # Don't link with libc until the a.out ld.so is fixed. + ;; + *-*-openbsd* | *-*-freebsd*) + # Do not include libc due to us having libc/libc_r. + test "X$arg" = "X-lc" && continue + ;; + *) + # Add libc to deplibs on all other systems if necessary. + if test "$build_libtool_need_lc" = "yes"; then + deplibs="$deplibs -lc" + fi + ;; + esac + fi + + # Transform deplibs into only deplibs that can be linked in shared. + name_save=$name + libname_save=$libname + release_save=$release + versuffix_save=$versuffix + major_save=$major + # I'm not sure if I'm treating the release correctly. I think + # release should show up in the -l (ie -lgmp5) so we don't want to + # add it in twice. Is that correct? + release="" + versuffix="" + major="" + newdeplibs= + droppeddeps=no + case $deplibs_check_method in + pass_all) + # Don't check for shared/static. Everything works. + # This might be a little naive. We might want to check + # whether the library exists or not. But this is on + # osf3 & osf4 and I'm not really sure... Just + # implementing what was already the behavior. + newdeplibs=$deplibs + ;; + test_compile) + # This code stresses the "libraries are programs" paradigm to its + # limits. Maybe even breaks it. We compile a program, linking it + # against the deplibs as a proxy for the library. Then we can check + # whether they linked in statically or dynamically with ldd. + $rm conftest.c + cat > conftest.c </dev/null` + for potent_lib in $potential_libs; do + # Follow soft links. + if ls -lLd "$potent_lib" 2>/dev/null \ + | grep " -> " >/dev/null; then + continue + fi + # The statement above tries to avoid entering an + # endless loop below, in case of cyclic links. + # We might still enter an endless loop, since a link + # loop can be closed while we follow links, + # but so what? + potlib="$potent_lib" + while test -h "$potlib" 2>/dev/null; do + potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` + case $potliblink in + [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; + *) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";; + esac + done + if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \ + | ${SED} 10q \ + | $EGREP "$file_magic_regex" > /dev/null; then + newdeplibs="$newdeplibs $a_deplib" + a_deplib="" + break 2 + fi + done + done + fi + if test -n "$a_deplib" ; then + droppeddeps=yes + $echo + $echo "*** Warning: linker path does not have real file for library $a_deplib." + $echo "*** I have the capability to make that library automatically link in when" + $echo "*** you link to this library. But I can only do this if you have a" + $echo "*** shared version of the library, which you do not appear to have" + $echo "*** because I did check the linker path looking for a file starting" + if test -z "$potlib" ; then + $echo "*** with $libname but no candidates were found. (...for file magic test)" + else + $echo "*** with $libname and none of the candidates passed a file format test" + $echo "*** using a file magic. Last file checked: $potlib" + fi + fi + else + # Add a -L argument. + newdeplibs="$newdeplibs $a_deplib" + fi + done # Gone through all deplibs. + ;; + match_pattern*) + set dummy $deplibs_check_method + match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"` + for a_deplib in $deplibs; do + name="`expr $a_deplib : '-l\(.*\)'`" + # If $name is empty we are operating on a -L argument. + if test -n "$name" && test "$name" != "0"; then + if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then + case " $predeps $postdeps " in + *" $a_deplib "*) + newdeplibs="$newdeplibs $a_deplib" + a_deplib="" + ;; + esac + fi + if test -n "$a_deplib" ; then + libname=`eval \\$echo \"$libname_spec\"` + for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do + potential_libs=`ls $i/$libname[.-]* 2>/dev/null` + for potent_lib in $potential_libs; do + potlib="$potent_lib" # see symlink-check above in file_magic test + if eval $echo \"$potent_lib\" 2>/dev/null \ + | ${SED} 10q \ + | $EGREP "$match_pattern_regex" > /dev/null; then + newdeplibs="$newdeplibs $a_deplib" + a_deplib="" + break 2 + fi + done + done + fi + if test -n "$a_deplib" ; then + droppeddeps=yes + $echo + $echo "*** Warning: linker path does not have real file for library $a_deplib." + $echo "*** I have the capability to make that library automatically link in when" + $echo "*** you link to this library. But I can only do this if you have a" + $echo "*** shared version of the library, which you do not appear to have" + $echo "*** because I did check the linker path looking for a file starting" + if test -z "$potlib" ; then + $echo "*** with $libname but no candidates were found. (...for regex pattern test)" + else + $echo "*** with $libname and none of the candidates passed a file format test" + $echo "*** using a regex pattern. Last file checked: $potlib" + fi + fi + else + # Add a -L argument. + newdeplibs="$newdeplibs $a_deplib" + fi + done # Gone through all deplibs. + ;; + none | unknown | *) + newdeplibs="" + tmp_deplibs=`$echo "X $deplibs" | $Xsed -e 's/ -lc$//' \ + -e 's/ -[LR][^ ]*//g'` + if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then + for i in $predeps $postdeps ; do + # can't use Xsed below, because $i might contain '/' + tmp_deplibs=`$echo "X $tmp_deplibs" | ${SED} -e "1s,^X,," -e "s,$i,,"` + done + fi + if $echo "X $tmp_deplibs" | $Xsed -e 's/[ ]//g' \ + | grep . >/dev/null; then + $echo + if test "X$deplibs_check_method" = "Xnone"; then + $echo "*** Warning: inter-library dependencies are not supported in this platform." + else + $echo "*** Warning: inter-library dependencies are not known to be supported." + fi + $echo "*** All declared inter-library dependencies are being dropped." + droppeddeps=yes + fi + ;; + esac + versuffix=$versuffix_save + major=$major_save + release=$release_save + libname=$libname_save + name=$name_save + + case $host in + *-*-rhapsody* | *-*-darwin1.[012]) + # On Rhapsody replace the C library is the System framework + newdeplibs=`$echo "X $newdeplibs" | $Xsed -e 's/ -lc / -framework System /'` + ;; + esac + + if test "$droppeddeps" = yes; then + if test "$module" = yes; then + $echo + $echo "*** Warning: libtool could not satisfy all declared inter-library" + $echo "*** dependencies of module $libname. Therefore, libtool will create" + $echo "*** a static module, that should work as long as the dlopening" + $echo "*** application is linked with the -dlopen flag." + if test -z "$global_symbol_pipe"; then + $echo + $echo "*** However, this would only work if libtool was able to extract symbol" + $echo "*** lists from a program, using \`nm' or equivalent, but libtool could" + $echo "*** not find such a program. So, this module is probably useless." + $echo "*** \`nm' from GNU binutils and a full rebuild may help." + fi + if test "$build_old_libs" = no; then + oldlibs="$output_objdir/$libname.$libext" + build_libtool_libs=module + build_old_libs=yes + else + build_libtool_libs=no + fi + else + $echo "*** The inter-library dependencies that have been dropped here will be" + $echo "*** automatically added whenever a program is linked with this library" + $echo "*** or is declared to -dlopen it." + + if test "$allow_undefined" = no; then + $echo + $echo "*** Since this library must not contain undefined symbols," + $echo "*** because either the platform does not support them or" + $echo "*** it was explicitly requested with -no-undefined," + $echo "*** libtool will only create a static version of it." + if test "$build_old_libs" = no; then + oldlibs="$output_objdir/$libname.$libext" + build_libtool_libs=module + build_old_libs=yes + else + build_libtool_libs=no + fi + fi + fi + fi + # Done checking deplibs! + deplibs=$newdeplibs + fi + + # All the library-specific variables (install_libdir is set above). + library_names= + old_library= + dlname= + + # Test again, we may have decided not to build it any more + if test "$build_libtool_libs" = yes; then + if test "$hardcode_into_libs" = yes; then + # Hardcode the library paths + hardcode_libdirs= + dep_rpath= + rpath="$finalize_rpath" + test "$mode" != relink && rpath="$compile_rpath$rpath" + for libdir in $rpath; do + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then + hardcode_libdirs="$libdir" + else + # Just accumulate the unique libdirs. + case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" + ;; + esac + fi + else + eval flag=\"$hardcode_libdir_flag_spec\" + dep_rpath="$dep_rpath $flag" + fi + elif test -n "$runpath_var"; then + case "$perm_rpath " in + *" $libdir "*) ;; + *) perm_rpath="$perm_rpath $libdir" ;; + esac + fi + done + # Substitute the hardcoded libdirs into the rpath. + if test -n "$hardcode_libdir_separator" && + test -n "$hardcode_libdirs"; then + libdir="$hardcode_libdirs" + if test -n "$hardcode_libdir_flag_spec_ld"; then + eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\" + else + eval dep_rpath=\"$hardcode_libdir_flag_spec\" + fi + fi + if test -n "$runpath_var" && test -n "$perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $perm_rpath; do + rpath="$rpath$dir:" + done + eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" + fi + test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" + fi + + shlibpath="$finalize_shlibpath" + test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath" + if test -n "$shlibpath"; then + eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" + fi + + # Get the real and link names of the library. + eval shared_ext=\"$shrext_cmds\" + eval library_names=\"$library_names_spec\" + set dummy $library_names + realname="$2" + shift; shift + + if test -n "$soname_spec"; then + eval soname=\"$soname_spec\" + else + soname="$realname" + fi + if test -z "$dlname"; then + dlname=$soname + fi + + lib="$output_objdir/$realname" + for link + do + linknames="$linknames $link" + done + + # Use standard objects if they are pic + test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + + # Prepare the list of exported symbols + if test -z "$export_symbols"; then + if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then + $show "generating symbol list for \`$libname.la'" + export_symbols="$output_objdir/$libname.exp" + $run $rm $export_symbols + cmds=$export_symbols_cmds + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + if len=`expr "X$cmd" : ".*"` && + test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then + $show "$cmd" + $run eval "$cmd" || exit $? + skipped_export=false + else + # The command line is too long to execute in one step. + $show "using reloadable object file for export list..." + skipped_export=: + fi + done + IFS="$save_ifs" + if test -n "$export_symbols_regex"; then + $show "$EGREP -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\"" + $run eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' + $show "$mv \"${export_symbols}T\" \"$export_symbols\"" + $run eval '$mv "${export_symbols}T" "$export_symbols"' + fi + fi + fi + + if test -n "$export_symbols" && test -n "$include_expsyms"; then + $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"' + fi + + tmp_deplibs= + for test_deplib in $deplibs; do + case " $convenience " in + *" $test_deplib "*) ;; + *) + tmp_deplibs="$tmp_deplibs $test_deplib" + ;; + esac + done + deplibs="$tmp_deplibs" + + if test -n "$convenience"; then + if test -n "$whole_archive_flag_spec"; then + save_libobjs=$libobjs + eval libobjs=\"\$libobjs $whole_archive_flag_spec\" + else + gentop="$output_objdir/${outputname}x" + $show "${rm}r $gentop" + $run ${rm}r "$gentop" + $show "$mkdir $gentop" + $run $mkdir "$gentop" + status=$? + if test "$status" -ne 0 && test ! -d "$gentop"; then + exit $status + fi + generated="$generated $gentop" + + for xlib in $convenience; do + # Extract the objects. + case $xlib in + [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;; + *) xabs=`pwd`"/$xlib" ;; + esac + xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'` + xdir="$gentop/$xlib" + + $show "${rm}r $xdir" + $run ${rm}r "$xdir" + $show "$mkdir $xdir" + $run $mkdir "$xdir" + status=$? + if test "$status" -ne 0 && test ! -d "$xdir"; then + exit $status + fi + # We will extract separately just the conflicting names and we will no + # longer touch any unique names. It is faster to leave these extract + # automatically by $AR in one run. + $show "(cd $xdir && $AR x $xabs)" + $run eval "(cd \$xdir && $AR x \$xabs)" || exit $? + if ($AR t "$xabs" | sort | sort -uc >/dev/null 2>&1); then + : + else + $echo "$modename: warning: object name conflicts; renaming object files" 1>&2 + $echo "$modename: warning: to ensure that they will not overwrite" 1>&2 + $AR t "$xabs" | sort | uniq -cd | while read -r count name + do + i=1 + while test "$i" -le "$count" + do + # Put our $i before any first dot (extension) + # Never overwrite any file + name_to="$name" + while test "X$name_to" = "X$name" || test -f "$xdir/$name_to" + do + name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"` + done + $show "(cd $xdir && $AR xN $i $xabs '$name' && $mv '$name' '$name_to')" + $run eval "(cd \$xdir && $AR xN $i \$xabs '$name' && $mv '$name' '$name_to')" || exit $? + i=`expr $i + 1` + done + done + fi + + libobjs="$libobjs "`find $xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP` + done + fi + fi + + if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then + eval flag=\"$thread_safe_flag_spec\" + linker_flags="$linker_flags $flag" + fi + + # Make a backup of the uninstalled library when relinking + if test "$mode" = relink; then + $run eval '(cd $output_objdir && $rm ${realname}U && $mv $realname ${realname}U)' || exit $? + fi + + # Do each of the archive commands. + if test "$module" = yes && test -n "$module_cmds" ; then + if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then + eval test_cmds=\"$module_expsym_cmds\" + cmds=$module_expsym_cmds + else + eval test_cmds=\"$module_cmds\" + cmds=$module_cmds + fi + else + if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then + eval test_cmds=\"$archive_expsym_cmds\" + cmds=$archive_expsym_cmds + else + eval test_cmds=\"$archive_cmds\" + cmds=$archive_cmds + fi + fi + + if test "X$skipped_export" != "X:" && len=`expr "X$test_cmds" : ".*"` && + test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then + : + else + # The command line is too long to link in one step, link piecewise. + $echo "creating reloadable object files..." + + # Save the value of $output and $libobjs because we want to + # use them later. If we have whole_archive_flag_spec, we + # want to use save_libobjs as it was before + # whole_archive_flag_spec was expanded, because we can't + # assume the linker understands whole_archive_flag_spec. + # This may have to be revisited, in case too many + # convenience libraries get linked in and end up exceeding + # the spec. + if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then + save_libobjs=$libobjs + fi + save_output=$output + + # Clear the reloadable object creation command queue and + # initialize k to one. + test_cmds= + concat_cmds= + objlist= + delfiles= + last_robj= + k=1 + output=$output_objdir/$save_output-${k}.$objext + # Loop over the list of objects to be linked. + for obj in $save_libobjs + do + eval test_cmds=\"$reload_cmds $objlist $last_robj\" + if test "X$objlist" = X || + { len=`expr "X$test_cmds" : ".*"` && + test "$len" -le "$max_cmd_len"; }; then + objlist="$objlist $obj" + else + # The command $test_cmds is almost too long, add a + # command to the queue. + if test "$k" -eq 1 ; then + # The first file doesn't have a previous command to add. + eval concat_cmds=\"$reload_cmds $objlist $last_robj\" + else + # All subsequent reloadable object files will link in + # the last one created. + eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj\" + fi + last_robj=$output_objdir/$save_output-${k}.$objext + k=`expr $k + 1` + output=$output_objdir/$save_output-${k}.$objext + objlist=$obj + len=1 + fi + done + # Handle the remaining objects by creating one last + # reloadable object file. All subsequent reloadable object + # files will link in the last one created. + test -z "$concat_cmds" || concat_cmds=$concat_cmds~ + eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\" + + if ${skipped_export-false}; then + $show "generating symbol list for \`$libname.la'" + export_symbols="$output_objdir/$libname.exp" + $run $rm $export_symbols + libobjs=$output + # Append the command to create the export file. + eval concat_cmds=\"\$concat_cmds~$export_symbols_cmds\" + fi + + # Set up a command to remove the reloadale object files + # after they are used. + i=0 + while test "$i" -lt "$k" + do + i=`expr $i + 1` + delfiles="$delfiles $output_objdir/$save_output-${i}.$objext" + done + + $echo "creating a temporary reloadable object file: $output" + + # Loop through the commands generated above and execute them. + save_ifs="$IFS"; IFS='~' + for cmd in $concat_cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + + libobjs=$output + # Restore the value of output. + output=$save_output + + if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then + eval libobjs=\"\$libobjs $whole_archive_flag_spec\" + fi + # Expand the library linking commands again to reset the + # value of $libobjs for piecewise linking. + + # Do each of the archive commands. + if test "$module" = yes && test -n "$module_cmds" ; then + if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then + cmds=$module_expsym_cmds + else + cmds=$module_cmds + fi + else + if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then + cmds=$archive_expsym_cmds + else + cmds=$archive_cmds + fi + fi + + # Append the command to remove the reloadable object files + # to the just-reset $cmds. + eval cmds=\"\$cmds~\$rm $delfiles\" + fi + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + + # Restore the uninstalled library and exit + if test "$mode" = relink; then + $run eval '(cd $output_objdir && $rm ${realname}T && $mv $realname ${realname}T && $mv "$realname"U $realname)' || exit $? + exit $EXIT_SUCCESS + fi + + # Create links to the real library. + for linkname in $linknames; do + if test "$realname" != "$linkname"; then + $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)" + $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $? + fi + done + + # If -module or -export-dynamic was specified, set the dlname. + if test "$module" = yes || test "$export_dynamic" = yes; then + # On all known operating systems, these are identical. + dlname="$soname" + fi + fi + ;; + + obj) + if test -n "$deplibs"; then + $echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2 + fi + + if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then + $echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2 + fi + + if test -n "$rpath"; then + $echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2 + fi + + if test -n "$xrpath"; then + $echo "$modename: warning: \`-R' is ignored for objects" 1>&2 + fi + + if test -n "$vinfo"; then + $echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2 + fi + + if test -n "$release"; then + $echo "$modename: warning: \`-release' is ignored for objects" 1>&2 + fi + + case $output in + *.lo) + if test -n "$objs$old_deplibs"; then + $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2 + exit $EXIT_FAILURE + fi + libobj="$output" + obj=`$echo "X$output" | $Xsed -e "$lo2o"` + ;; + *) + libobj= + obj="$output" + ;; + esac + + # Delete the old objects. + $run $rm $obj $libobj + + # Objects from convenience libraries. This assumes + # single-version convenience libraries. Whenever we create + # different ones for PIC/non-PIC, this we'll have to duplicate + # the extraction. + reload_conv_objs= + gentop= + # reload_cmds runs $LD directly, so let us get rid of + # -Wl from whole_archive_flag_spec + wl= + + if test -n "$convenience"; then + if test -n "$whole_archive_flag_spec"; then + eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\" + else + gentop="$output_objdir/${obj}x" + $show "${rm}r $gentop" + $run ${rm}r "$gentop" + $show "$mkdir $gentop" + $run $mkdir "$gentop" + status=$? + if test "$status" -ne 0 && test ! -d "$gentop"; then + exit $status + fi + generated="$generated $gentop" + + for xlib in $convenience; do + # Extract the objects. + case $xlib in + [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;; + *) xabs=`pwd`"/$xlib" ;; + esac + xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'` + xdir="$gentop/$xlib" + + $show "${rm}r $xdir" + $run ${rm}r "$xdir" + $show "$mkdir $xdir" + $run $mkdir "$xdir" + status=$? + if test "$status" -ne 0 && test ! -d "$xdir"; then + exit $status + fi + # We will extract separately just the conflicting names and we will no + # longer touch any unique names. It is faster to leave these extract + # automatically by $AR in one run. + $show "(cd $xdir && $AR x $xabs)" + $run eval "(cd \$xdir && $AR x \$xabs)" || exit $? + if ($AR t "$xabs" | sort | sort -uc >/dev/null 2>&1); then + : + else + $echo "$modename: warning: object name conflicts; renaming object files" 1>&2 + $echo "$modename: warning: to ensure that they will not overwrite" 1>&2 + $AR t "$xabs" | sort | uniq -cd | while read -r count name + do + i=1 + while test "$i" -le "$count" + do + # Put our $i before any first dot (extension) + # Never overwrite any file + name_to="$name" + while test "X$name_to" = "X$name" || test -f "$xdir/$name_to" + do + name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"` + done + $show "(cd $xdir && $AR xN $i $xabs '$name' && $mv '$name' '$name_to')" + $run eval "(cd \$xdir && $AR xN $i \$xabs '$name' && $mv '$name' '$name_to')" || exit $? + i=`expr $i + 1` + done + done + fi + + reload_conv_objs="$reload_objs "`find $xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP` + done + fi + fi + + # Create the old-style object. + reload_objs="$objs$old_deplibs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test + + output="$obj" + cmds=$reload_cmds + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + + # Exit if we aren't doing a library object file. + if test -z "$libobj"; then + if test -n "$gentop"; then + $show "${rm}r $gentop" + $run ${rm}r $gentop + fi + + exit $EXIT_SUCCESS + fi + + if test "$build_libtool_libs" != yes; then + if test -n "$gentop"; then + $show "${rm}r $gentop" + $run ${rm}r $gentop + fi + + # Create an invalid libtool object if no PIC, so that we don't + # accidentally link it into a program. + # $show "echo timestamp > $libobj" + # $run eval "echo timestamp > $libobj" || exit $? + exit $EXIT_SUCCESS + fi + + if test -n "$pic_flag" || test "$pic_mode" != default; then + # Only do commands if we really have different PIC objects. + reload_objs="$libobjs $reload_conv_objs" + output="$libobj" + cmds=$reload_cmds + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + fi + + if test -n "$gentop"; then + $show "${rm}r $gentop" + $run ${rm}r $gentop + fi + + exit $EXIT_SUCCESS + ;; + + prog) + case $host in + *cygwin*) output=`$echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;; + esac + if test -n "$vinfo"; then + $echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2 + fi + + if test -n "$release"; then + $echo "$modename: warning: \`-release' is ignored for programs" 1>&2 + fi + + if test "$preload" = yes; then + if test "$dlopen_support" = unknown && test "$dlopen_self" = unknown && + test "$dlopen_self_static" = unknown; then + $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support." + fi + fi + + case $host in + *-*-rhapsody* | *-*-darwin1.[012]) + # On Rhapsody replace the C library is the System framework + compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'` + finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'` + ;; + esac + + case $host in + *darwin*) + # Don't allow lazy linking, it breaks C++ global constructors + if test "$tagname" = CXX ; then + compile_command="$compile_command ${wl}-bind_at_load" + finalize_command="$finalize_command ${wl}-bind_at_load" + fi + ;; + esac + + compile_command="$compile_command $compile_deplibs" + finalize_command="$finalize_command $finalize_deplibs" + + if test -n "$rpath$xrpath"; then + # If the user specified any rpath flags, then add them. + for libdir in $rpath $xrpath; do + # This is the magic to use -rpath. + case "$finalize_rpath " in + *" $libdir "*) ;; + *) finalize_rpath="$finalize_rpath $libdir" ;; + esac + done + fi + + # Now hardcode the library paths + rpath= + hardcode_libdirs= + for libdir in $compile_rpath $finalize_rpath; do + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then + hardcode_libdirs="$libdir" + else + # Just accumulate the unique libdirs. + case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" + ;; + esac + fi + else + eval flag=\"$hardcode_libdir_flag_spec\" + rpath="$rpath $flag" + fi + elif test -n "$runpath_var"; then + case "$perm_rpath " in + *" $libdir "*) ;; + *) perm_rpath="$perm_rpath $libdir" ;; + esac + fi + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) + case :$dllsearchpath: in + *":$libdir:"*) ;; + *) dllsearchpath="$dllsearchpath:$libdir";; + esac + ;; + esac + done + # Substitute the hardcoded libdirs into the rpath. + if test -n "$hardcode_libdir_separator" && + test -n "$hardcode_libdirs"; then + libdir="$hardcode_libdirs" + eval rpath=\" $hardcode_libdir_flag_spec\" + fi + compile_rpath="$rpath" + + rpath= + hardcode_libdirs= + for libdir in $finalize_rpath; do + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then + hardcode_libdirs="$libdir" + else + # Just accumulate the unique libdirs. + case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" + ;; + esac + fi + else + eval flag=\"$hardcode_libdir_flag_spec\" + rpath="$rpath $flag" + fi + elif test -n "$runpath_var"; then + case "$finalize_perm_rpath " in + *" $libdir "*) ;; + *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;; + esac + fi + done + # Substitute the hardcoded libdirs into the rpath. + if test -n "$hardcode_libdir_separator" && + test -n "$hardcode_libdirs"; then + libdir="$hardcode_libdirs" + eval rpath=\" $hardcode_libdir_flag_spec\" + fi + finalize_rpath="$rpath" + + if test -n "$libobjs" && test "$build_old_libs" = yes; then + # Transform all the library objects into standard objects. + compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + fi + + dlsyms= + if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then + if test -n "$NM" && test -n "$global_symbol_pipe"; then + dlsyms="${outputname}S.c" + else + $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2 + fi + fi + + if test -n "$dlsyms"; then + case $dlsyms in + "") ;; + *.c) + # Discover the nlist of each of the dlfiles. + nlist="$output_objdir/${outputname}.nm" + + $show "$rm $nlist ${nlist}S ${nlist}T" + $run $rm "$nlist" "${nlist}S" "${nlist}T" + + # Parse the name list into a source file. + $show "creating $output_objdir/$dlsyms" + + test -z "$run" && $echo > "$output_objdir/$dlsyms" "\ +/* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */ +/* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */ + +#ifdef __cplusplus +extern \"C\" { +#endif + +/* Prevent the only kind of declaration conflicts we can make. */ +#define lt_preloaded_symbols some_other_symbol + +/* External symbol declarations for the compiler. */\ +" + + if test "$dlself" = yes; then + $show "generating symbol list for \`$output'" + + test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist" + + # Add our own program objects to the symbol list. + progfiles=`$echo "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + for arg in $progfiles; do + $show "extracting global C symbols from \`$arg'" + $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'" + done + + if test -n "$exclude_expsyms"; then + $run eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' + $run eval '$mv "$nlist"T "$nlist"' + fi + + if test -n "$export_symbols_regex"; then + $run eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' + $run eval '$mv "$nlist"T "$nlist"' + fi + + # Prepare the list of exported symbols + if test -z "$export_symbols"; then + export_symbols="$output_objdir/$output.exp" + $run $rm $export_symbols + $run eval "${SED} -n -e '/^: @PROGRAM@$/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' + else + $run eval "${SED} -e 's/\([][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$output.exp"' + $run eval 'grep -f "$output_objdir/$output.exp" < "$nlist" > "$nlist"T' + $run eval 'mv "$nlist"T "$nlist"' + fi + fi + + for arg in $dlprefiles; do + $show "extracting global C symbols from \`$arg'" + name=`$echo "$arg" | ${SED} -e 's%^.*/%%'` + $run eval '$echo ": $name " >> "$nlist"' + $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'" + done + + if test -z "$run"; then + # Make sure we have at least an empty file. + test -f "$nlist" || : > "$nlist" + + if test -n "$exclude_expsyms"; then + $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T + $mv "$nlist"T "$nlist" + fi + + # Try sorting and uniquifying the output. + if grep -v "^: " < "$nlist" | + if sort -k 3 /dev/null 2>&1; then + sort -k 3 + else + sort +2 + fi | + uniq > "$nlist"S; then + : + else + grep -v "^: " < "$nlist" > "$nlist"S + fi + + if test -f "$nlist"S; then + eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"' + else + $echo '/* NONE */' >> "$output_objdir/$dlsyms" + fi + + $echo >> "$output_objdir/$dlsyms" "\ + +#undef lt_preloaded_symbols + +#if defined (__STDC__) && __STDC__ +# define lt_ptr void * +#else +# define lt_ptr char * +# define const +#endif + +/* The mapping between symbol names and symbols. */ +const struct { + const char *name; + lt_ptr address; +} +lt_preloaded_symbols[] = +{\ +" + + eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$dlsyms" + + $echo >> "$output_objdir/$dlsyms" "\ + {0, (lt_ptr) 0} +}; + +/* This works around a problem in FreeBSD linker */ +#ifdef FREEBSD_WORKAROUND +static const void *lt_preloaded_setup() { + return lt_preloaded_symbols; +} +#endif + +#ifdef __cplusplus +} +#endif\ +" + fi + + pic_flag_for_symtable= + case $host in + # compiling the symbol table file with pic_flag works around + # a FreeBSD bug that causes programs to crash when -lm is + # linked before any other PIC object. But we must not use + # pic_flag when linking with -static. The problem exists in + # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. + *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) + case "$compile_command " in + *" -static "*) ;; + *) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND";; + esac;; + *-*-hpux*) + case "$compile_command " in + *" -static "*) ;; + *) pic_flag_for_symtable=" $pic_flag";; + esac + esac + + # Now compile the dynamic symbol file. + $show "(cd $output_objdir && $LTCC -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")" + $run eval '(cd $output_objdir && $LTCC -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $? + + # Clean up the generated files. + $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T" + $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T" + + # Transform the symbol file into the correct name. + compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"` + finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"` + ;; + *) + $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2 + exit $EXIT_FAILURE + ;; + esac + else + # We keep going just in case the user didn't refer to + # lt_preloaded_symbols. The linker will fail if global_symbol_pipe + # really was required. + + # Nullify the symbol file. + compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"` + finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"` + fi + + if test "$need_relink" = no || test "$build_libtool_libs" != yes; then + # Replace the output file specification. + compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` + link_command="$compile_command$compile_rpath" + + # We have no uninstalled library dependencies, so finalize right now. + $show "$link_command" + $run eval "$link_command" + status=$? + + # Delete the generated files. + if test -n "$dlsyms"; then + $show "$rm $output_objdir/${outputname}S.${objext}" + $run $rm "$output_objdir/${outputname}S.${objext}" + fi + + exit $status + fi + + if test -n "$shlibpath_var"; then + # We should set the shlibpath_var + rpath= + for dir in $temp_rpath; do + case $dir in + [\\/]* | [A-Za-z]:[\\/]*) + # Absolute path. + rpath="$rpath$dir:" + ;; + *) + # Relative path: add a thisdir entry. + rpath="$rpath\$thisdir/$dir:" + ;; + esac + done + temp_rpath="$rpath" + fi + + if test -n "$compile_shlibpath$finalize_shlibpath"; then + compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" + fi + if test -n "$finalize_shlibpath"; then + finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" + fi + + compile_var= + finalize_var= + if test -n "$runpath_var"; then + if test -n "$perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $perm_rpath; do + rpath="$rpath$dir:" + done + compile_var="$runpath_var=\"$rpath\$$runpath_var\" " + fi + if test -n "$finalize_perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $finalize_perm_rpath; do + rpath="$rpath$dir:" + done + finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " + fi + fi + + if test "$no_install" = yes; then + # We don't need to create a wrapper script. + link_command="$compile_var$compile_command$compile_rpath" + # Replace the output file specification. + link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` + # Delete the old output file. + $run $rm $output + # Link the executable and exit + $show "$link_command" + $run eval "$link_command" || exit $? + exit $EXIT_SUCCESS + fi + + if test "$hardcode_action" = relink; then + # Fast installation is not supported + link_command="$compile_var$compile_command$compile_rpath" + relink_command="$finalize_var$finalize_command$finalize_rpath" + + $echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2 + $echo "$modename: \`$output' will be relinked during installation" 1>&2 + else + if test "$fast_install" != no; then + link_command="$finalize_var$compile_command$finalize_rpath" + if test "$fast_install" = yes; then + relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'` + else + # fast_install is set to needless + relink_command= + fi + else + link_command="$compile_var$compile_command$compile_rpath" + relink_command="$finalize_var$finalize_command$finalize_rpath" + fi + fi + + # Replace the output file specification. + link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` + + # Delete the old output files. + $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname + + $show "$link_command" + $run eval "$link_command" || exit $? + + # Now create the wrapper script. + $show "creating $output" + + # Quote the relink command for shipping. + if test -n "$relink_command"; then + # Preserve any variables that may affect compiler behavior + for var in $variables_saved_for_relink; do + if eval test -z \"\${$var+set}\"; then + relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command" + elif eval var_value=\$$var; test -z "$var_value"; then + relink_command="$var=; export $var; $relink_command" + else + var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"` + relink_command="$var=\"$var_value\"; export $var; $relink_command" + fi + done + relink_command="(cd `pwd`; $relink_command)" + relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"` + fi + + # Quote $echo for shipping. + if test "X$echo" = "X$SHELL $progpath --fallback-echo"; then + case $progpath in + [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";; + *) qecho="$SHELL `pwd`/$progpath --fallback-echo";; + esac + qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"` + else + qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"` + fi + + # Only actually do things if our run command is non-null. + if test -z "$run"; then + # win32 will think the script is a binary if it has + # a .exe suffix, so we strip it off here. + case $output in + *.exe) output=`$echo $output|${SED} 's,.exe$,,'` ;; + esac + # test for cygwin because mv fails w/o .exe extensions + case $host in + *cygwin*) + exeext=.exe + outputname=`$echo $outputname|${SED} 's,.exe$,,'` ;; + *) exeext= ;; + esac + case $host in + *cygwin* | *mingw* ) + cwrappersource=`$echo ${objdir}/lt-${output}.c` + cwrapper=`$echo ${output}.exe` + $rm $cwrappersource $cwrapper + trap "$rm $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 + + cat > $cwrappersource <> $cwrappersource<<"EOF" +#include +#include +#include +#include +#include +#include + +#if defined(PATH_MAX) +# define LT_PATHMAX PATH_MAX +#elif defined(MAXPATHLEN) +# define LT_PATHMAX MAXPATHLEN +#else +# define LT_PATHMAX 1024 +#endif + +#ifndef DIR_SEPARATOR +#define DIR_SEPARATOR '/' +#endif + +#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ + defined (__OS2__) +#define HAVE_DOS_BASED_FILE_SYSTEM +#ifndef DIR_SEPARATOR_2 +#define DIR_SEPARATOR_2 '\\' +#endif +#endif + +#ifndef DIR_SEPARATOR_2 +# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) +#else /* DIR_SEPARATOR_2 */ +# define IS_DIR_SEPARATOR(ch) \ + (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) +#endif /* DIR_SEPARATOR_2 */ + +#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) +#define XFREE(stale) do { \ + if (stale) { free ((void *) stale); stale = 0; } \ +} while (0) + +const char *program_name = NULL; + +void * xmalloc (size_t num); +char * xstrdup (const char *string); +char * basename (const char *name); +char * fnqualify(const char *path); +char * strendzap(char *str, const char *pat); +void lt_fatal (const char *message, ...); + +int +main (int argc, char *argv[]) +{ + char **newargz; + int i; + + program_name = (char *) xstrdup ((char *) basename (argv[0])); + newargz = XMALLOC(char *, argc+2); +EOF + + cat >> $cwrappersource <> $cwrappersource <<"EOF" + newargz[1] = fnqualify(argv[0]); + /* we know the script has the same name, without the .exe */ + /* so make sure newargz[1] doesn't end in .exe */ + strendzap(newargz[1],".exe"); + for (i = 1; i < argc; i++) + newargz[i+1] = xstrdup(argv[i]); + newargz[argc+1] = NULL; +EOF + + cat >> $cwrappersource <> $cwrappersource <<"EOF" +} + +void * +xmalloc (size_t num) +{ + void * p = (void *) malloc (num); + if (!p) + lt_fatal ("Memory exhausted"); + + return p; +} + +char * +xstrdup (const char *string) +{ + return string ? strcpy ((char *) xmalloc (strlen (string) + 1), string) : NULL +; +} + +char * +basename (const char *name) +{ + const char *base; + +#if defined (HAVE_DOS_BASED_FILE_SYSTEM) + /* Skip over the disk name in MSDOS pathnames. */ + if (isalpha (name[0]) && name[1] == ':') + name += 2; +#endif + + for (base = name; *name; name++) + if (IS_DIR_SEPARATOR (*name)) + base = name + 1; + return (char *) base; +} + +char * +fnqualify(const char *path) +{ + size_t size; + char *p; + char tmp[LT_PATHMAX + 1]; + + assert(path != NULL); + + /* Is it qualified already? */ +#if defined (HAVE_DOS_BASED_FILE_SYSTEM) + if (isalpha (path[0]) && path[1] == ':') + return xstrdup (path); +#endif + if (IS_DIR_SEPARATOR (path[0])) + return xstrdup (path); + + /* prepend the current directory */ + /* doesn't handle '~' */ + if (getcwd (tmp, LT_PATHMAX) == NULL) + lt_fatal ("getcwd failed"); + size = strlen(tmp) + 1 + strlen(path) + 1; /* +2 for '/' and '\0' */ + p = XMALLOC(char, size); + sprintf(p, "%s%c%s", tmp, DIR_SEPARATOR, path); + return p; +} + +char * +strendzap(char *str, const char *pat) +{ + size_t len, patlen; + + assert(str != NULL); + assert(pat != NULL); + + len = strlen(str); + patlen = strlen(pat); + + if (patlen <= len) + { + str += len - patlen; + if (strcmp(str, pat) == 0) + *str = '\0'; + } + return str; +} + +static void +lt_error_core (int exit_status, const char * mode, + const char * message, va_list ap) +{ + fprintf (stderr, "%s: %s: ", program_name, mode); + vfprintf (stderr, message, ap); + fprintf (stderr, ".\n"); + + if (exit_status >= 0) + exit (exit_status); +} + +void +lt_fatal (const char *message, ...) +{ + va_list ap; + va_start (ap, message); + lt_error_core (EXIT_FAILURE, "FATAL", message, ap); + va_end (ap); +} +EOF + # we should really use a build-platform specific compiler + # here, but OTOH, the wrappers (shell script and this C one) + # are only useful if you want to execute the "real" binary. + # Since the "real" binary is built for $host, then this + # wrapper might as well be built for $host, too. + $run $LTCC -s -o $cwrapper $cwrappersource + ;; + esac + $rm $output + trap "$rm $output; exit $EXIT_FAILURE" 1 2 15 + + $echo > $output "\ +#! $SHELL + +# $output - temporary wrapper script for $objdir/$outputname +# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP +# +# The $output program cannot be directly executed until all the libtool +# libraries that it depends on are installed. +# +# This wrapper script should never be moved out of the build directory. +# If it is, it will not operate correctly. + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed='${SED} -e 1s/^X//' +sed_quote_subst='$sed_quote_subst' + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +if test \"\${CDPATH+set}\" = set; then CDPATH=:; export CDPATH; fi + +relink_command=\"$relink_command\" + +# This environment variable determines our operation mode. +if test \"\$libtool_install_magic\" = \"$magic\"; then + # install mode needs the following variable: + notinst_deplibs='$notinst_deplibs' +else + # When we are sourced in execute mode, \$file and \$echo are already set. + if test \"\$libtool_execute_magic\" != \"$magic\"; then + echo=\"$qecho\" + file=\"\$0\" + # Make sure echo works. + if test \"X\$1\" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift + elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then + # Yippee, \$echo works! + : + else + # Restart under the correct shell, and then maybe \$echo will work. + exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"} + fi + fi\ +" + $echo >> $output "\ + + # Find the directory that this script lives in. + thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\` + test \"x\$thisdir\" = \"x\$file\" && thisdir=. + + # Follow symbolic links until we get to the real thisdir. + file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\` + while test -n \"\$file\"; do + destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\` + + # If there was a directory component, then change thisdir. + if test \"x\$destdir\" != \"x\$file\"; then + case \"\$destdir\" in + [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; + *) thisdir=\"\$thisdir/\$destdir\" ;; + esac + fi + + file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\` + file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\` + done + + # Try to get the absolute directory name. + absdir=\`cd \"\$thisdir\" && pwd\` + test -n \"\$absdir\" && thisdir=\"\$absdir\" +" + + if test "$fast_install" = yes; then + $echo >> $output "\ + program=lt-'$outputname'$exeext + progdir=\"\$thisdir/$objdir\" + + if test ! -f \"\$progdir/\$program\" || \\ + { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ + test \"X\$file\" != \"X\$progdir/\$program\"; }; then + + file=\"\$\$-\$program\" + + if test ! -d \"\$progdir\"; then + $mkdir \"\$progdir\" + else + $rm \"\$progdir/\$file\" + fi" + + $echo >> $output "\ + + # relink executable if necessary + if test -n \"\$relink_command\"; then + if relink_command_output=\`eval \$relink_command 2>&1\`; then : + else + $echo \"\$relink_command_output\" >&2 + $rm \"\$progdir/\$file\" + exit $EXIT_FAILURE + fi + fi + + $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || + { $rm \"\$progdir/\$program\"; + $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; } + $rm \"\$progdir/\$file\" + fi" + else + $echo >> $output "\ + program='$outputname' + progdir=\"\$thisdir/$objdir\" +" + fi + + $echo >> $output "\ + + if test -f \"\$progdir/\$program\"; then" + + # Export our shlibpath_var if we have one. + if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then + $echo >> $output "\ + # Add our own library path to $shlibpath_var + $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" + + # Some systems cannot cope with colon-terminated $shlibpath_var + # The second colon is a workaround for a bug in BeOS R4 sed + $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\` + + export $shlibpath_var +" + fi + + # fixup the dll searchpath if we need to. + if test -n "$dllsearchpath"; then + $echo >> $output "\ + # Add the dll search path components to the executable PATH + PATH=$dllsearchpath:\$PATH +" + fi + + $echo >> $output "\ + if test \"\$libtool_execute_magic\" != \"$magic\"; then + # Run the actual program with our arguments. +" + case $host in + # Backslashes separate directories on plain windows + *-*-mingw | *-*-os2*) + $echo >> $output "\ + exec \$progdir\\\\\$program \${1+\"\$@\"} +" + ;; + + *) + $echo >> $output "\ + exec \$progdir/\$program \${1+\"\$@\"} +" + ;; + esac + $echo >> $output "\ + \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\" + exit $EXIT_FAILURE + fi + else + # The program doesn't exist. + \$echo \"\$0: error: \$progdir/\$program does not exist\" 1>&2 + \$echo \"This script is just a wrapper for \$program.\" 1>&2 + $echo \"See the $PACKAGE documentation for more information.\" 1>&2 + exit $EXIT_FAILURE + fi +fi\ +" + chmod +x $output + fi + exit $EXIT_SUCCESS + ;; + esac + + # See if we need to build an old-fashioned archive. + for oldlib in $oldlibs; do + + if test "$build_libtool_libs" = convenience; then + oldobjs="$libobjs_save" + addlibs="$convenience" + build_libtool_libs=no + else + if test "$build_libtool_libs" = module; then + oldobjs="$libobjs_save" + build_libtool_libs=no + else + oldobjs="$old_deplibs $non_pic_objects" + fi + addlibs="$old_convenience" + fi + + if test -n "$addlibs"; then + gentop="$output_objdir/${outputname}x" + $show "${rm}r $gentop" + $run ${rm}r "$gentop" + $show "$mkdir $gentop" + $run $mkdir "$gentop" + status=$? + if test "$status" -ne 0 && test ! -d "$gentop"; then + exit $status + fi + generated="$generated $gentop" + + # Add in members from convenience archives. + for xlib in $addlibs; do + # Extract the objects. + case $xlib in + [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;; + *) xabs=`pwd`"/$xlib" ;; + esac + xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'` + xdir="$gentop/$xlib" + + $show "${rm}r $xdir" + $run ${rm}r "$xdir" + $show "$mkdir $xdir" + $run $mkdir "$xdir" + status=$? + if test "$status" -ne 0 && test ! -d "$xdir"; then + exit $status + fi + # We will extract separately just the conflicting names and we will no + # longer touch any unique names. It is faster to leave these extract + # automatically by $AR in one run. + $show "(cd $xdir && $AR x $xabs)" + $run eval "(cd \$xdir && $AR x \$xabs)" || exit $? + if ($AR t "$xabs" | sort | sort -uc >/dev/null 2>&1); then + : + else + $echo "$modename: warning: object name conflicts; renaming object files" 1>&2 + $echo "$modename: warning: to ensure that they will not overwrite" 1>&2 + $AR t "$xabs" | sort | uniq -cd | while read -r count name + do + i=1 + while test "$i" -le "$count" + do + # Put our $i before any first dot (extension) + # Never overwrite any file + name_to="$name" + while test "X$name_to" = "X$name" || test -f "$xdir/$name_to" + do + name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"` + done + $show "(cd $xdir && $AR xN $i $xabs '$name' && $mv '$name' '$name_to')" + $run eval "(cd \$xdir && $AR xN $i \$xabs '$name' && $mv '$name' '$name_to')" || exit $? + i=`expr $i + 1` + done + done + fi + + oldobjs="$oldobjs "`find $xdir -name \*.${objext} -print -o -name \*.lo -print | $NL2SP` + done + fi + + # Do each command in the archive commands. + if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then + cmds=$old_archive_from_new_cmds + else + eval cmds=\"$old_archive_cmds\" + + if len=`expr "X$cmds" : ".*"` && + test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then + cmds=$old_archive_cmds + else + # the command line is too long to link in one step, link in parts + $echo "using piecewise archive linking..." + save_RANLIB=$RANLIB + RANLIB=: + objlist= + concat_cmds= + save_oldobjs=$oldobjs + # GNU ar 2.10+ was changed to match POSIX; thus no paths are + # encoded into archives. This makes 'ar r' malfunction in + # this piecewise linking case whenever conflicting object + # names appear in distinct ar calls; check, warn and compensate. + if (for obj in $save_oldobjs + do + $echo "X$obj" | $Xsed -e 's%^.*/%%' + done | sort | sort -uc >/dev/null 2>&1); then + : + else + $echo "$modename: warning: object name conflicts; overriding AR_FLAGS to 'cq'" 1>&2 + $echo "$modename: warning: to ensure that POSIX-compatible ar will work" 1>&2 + AR_FLAGS=cq + fi + # Is there a better way of finding the last object in the list? + for obj in $save_oldobjs + do + last_oldobj=$obj + done + for obj in $save_oldobjs + do + oldobjs="$objlist $obj" + objlist="$objlist $obj" + eval test_cmds=\"$old_archive_cmds\" + if len=`expr "X$test_cmds" : ".*"` && + test "$len" -le "$max_cmd_len"; then + : + else + # the above command should be used before it gets too long + oldobjs=$objlist + if test "$obj" = "$last_oldobj" ; then + RANLIB=$save_RANLIB + fi + test -z "$concat_cmds" || concat_cmds=$concat_cmds~ + eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" + objlist= + fi + done + RANLIB=$save_RANLIB + oldobjs=$objlist + if test "X$oldobjs" = "X" ; then + eval cmds=\"\$concat_cmds\" + else + eval cmds=\"\$concat_cmds~\$old_archive_cmds\" + fi + fi + fi + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + eval cmd=\"$cmd\" + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + done + + if test -n "$generated"; then + $show "${rm}r$generated" + $run ${rm}r$generated + fi + + # Now create the libtool archive. + case $output in + *.la) + old_library= + test "$build_old_libs" = yes && old_library="$libname.$libext" + $show "creating $output" + + # Preserve any variables that may affect compiler behavior + for var in $variables_saved_for_relink; do + if eval test -z \"\${$var+set}\"; then + relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command" + elif eval var_value=\$$var; test -z "$var_value"; then + relink_command="$var=; export $var; $relink_command" + else + var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"` + relink_command="$var=\"$var_value\"; export $var; $relink_command" + fi + done + # Quote the link command for shipping. + relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" + relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"` + if test "$hardcode_automatic" = yes ; then + relink_command= + fi + + + # Only create the output if not a dry run. + if test -z "$run"; then + for installed in no yes; do + if test "$installed" = yes; then + if test -z "$install_libdir"; then + break + fi + output="$output_objdir/$outputname"i + # Replace all uninstalled libtool libraries with the installed ones + newdependency_libs= + for deplib in $dependency_libs; do + case $deplib in + *.la) + name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'` + eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` + if test -z "$libdir"; then + $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2 + exit $EXIT_FAILURE + fi + newdependency_libs="$newdependency_libs $libdir/$name" + ;; + *) newdependency_libs="$newdependency_libs $deplib" ;; + esac + done + dependency_libs="$newdependency_libs" + newdlfiles= + for lib in $dlfiles; do + name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` + eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` + if test -z "$libdir"; then + $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 + exit $EXIT_FAILURE + fi + newdlfiles="$newdlfiles $libdir/$name" + done + dlfiles="$newdlfiles" + newdlprefiles= + for lib in $dlprefiles; do + name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` + eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` + if test -z "$libdir"; then + $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 + exit $EXIT_FAILURE + fi + newdlprefiles="$newdlprefiles $libdir/$name" + done + dlprefiles="$newdlprefiles" + else + newdlfiles= + for lib in $dlfiles; do + case $lib in + [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; + *) abs=`pwd`"/$lib" ;; + esac + newdlfiles="$newdlfiles $abs" + done + dlfiles="$newdlfiles" + newdlprefiles= + for lib in $dlprefiles; do + case $lib in + [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; + *) abs=`pwd`"/$lib" ;; + esac + newdlprefiles="$newdlprefiles $abs" + done + dlprefiles="$newdlprefiles" + fi + $rm $output + # place dlname in correct position for cygwin + tdlname=$dlname + case $host,$output,$installed,$module,$dlname in + *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;; + esac + $echo > $output "\ +# $outputname - a libtool library file +# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# The name that we can dlopen(3). +dlname='$tdlname' + +# Names of this library. +library_names='$library_names' + +# The name of the static archive. +old_library='$old_library' + +# Libraries that this one depends upon. +dependency_libs='$dependency_libs' + +# Version information for $libname. +current=$current +age=$age +revision=$revision + +# Is this an already installed library? +installed=$installed + +# Should we warn about portability when linking against -modules? +shouldnotlink=$module + +# Files to dlopen/dlpreopen +dlopen='$dlfiles' +dlpreopen='$dlprefiles' + +# Directory that this library needs to be installed in: +libdir='$install_libdir'" + if test "$installed" = no && test "$need_relink" = yes; then + $echo >> $output "\ +relink_command=\"$relink_command\"" + fi + done + fi + + # Do a symbolic link so that the libtool archive can be found in + # LD_LIBRARY_PATH before the program is installed. + $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)" + $run eval '(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)' || exit $? + ;; + esac + exit $EXIT_SUCCESS + ;; + + # libtool install mode + install) + modename="$modename: install" + + # There may be an optional sh(1) argument at the beginning of + # install_prog (especially on Windows NT). + if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || + # Allow the use of GNU shtool's install command. + $echo "X$nonopt" | $Xsed | grep shtool > /dev/null; then + # Aesthetically quote it. + arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"` + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + arg="\"$arg\"" + ;; + esac + install_prog="$arg " + arg="$1" + shift + else + install_prog= + arg="$nonopt" + fi + + # The real first argument should be the name of the installation program. + # Aesthetically quote it. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + arg="\"$arg\"" + ;; + esac + install_prog="$install_prog$arg" + + # We need to accept at least all the BSD install flags. + dest= + files= + opts= + prev= + install_type= + isdir=no + stripme= + for arg + do + if test -n "$dest"; then + files="$files $dest" + dest="$arg" + continue + fi + + case $arg in + -d) isdir=yes ;; + -f) prev="-f" ;; + -g) prev="-g" ;; + -m) prev="-m" ;; + -o) prev="-o" ;; + -s) + stripme=" -s" + continue + ;; + -*) ;; + + *) + # If the previous option needed an argument, then skip it. + if test -n "$prev"; then + prev= + else + dest="$arg" + continue + fi + ;; + esac + + # Aesthetically quote the argument. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + arg="\"$arg\"" + ;; + esac + install_prog="$install_prog $arg" + done + + if test -z "$install_prog"; then + $echo "$modename: you must specify an install program" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + if test -n "$prev"; then + $echo "$modename: the \`$prev' option requires an argument" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + if test -z "$files"; then + if test -z "$dest"; then + $echo "$modename: no file or destination specified" 1>&2 + else + $echo "$modename: you must specify a destination" 1>&2 + fi + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + # Strip any trailing slash from the destination. + dest=`$echo "X$dest" | $Xsed -e 's%/$%%'` + + # Check to see that the destination is a directory. + test -d "$dest" && isdir=yes + if test "$isdir" = yes; then + destdir="$dest" + destname= + else + destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'` + test "X$destdir" = "X$dest" && destdir=. + destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'` + + # Not a directory, so check to see that there is only one file specified. + set dummy $files + if test "$#" -gt 2; then + $echo "$modename: \`$dest' is not a directory" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + fi + case $destdir in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + for file in $files; do + case $file in + *.lo) ;; + *) + $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + ;; + esac + done + ;; + esac + + # This variable tells wrapper scripts just to set variables rather + # than running their programs. + libtool_install_magic="$magic" + + staticlibs= + future_libdirs= + current_libdirs= + for file in $files; do + + # Do each installation. + case $file in + *.$libext) + # Do the static libraries later. + staticlibs="$staticlibs $file" + ;; + + *.la) + # Check to see that this really is a libtool archive. + if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : + else + $echo "$modename: \`$file' is not a valid libtool archive" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + library_names= + old_library= + relink_command= + # If there is no directory component, then add one. + case $file in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + # Add the libdir to current_libdirs if it is the destination. + if test "X$destdir" = "X$libdir"; then + case "$current_libdirs " in + *" $libdir "*) ;; + *) current_libdirs="$current_libdirs $libdir" ;; + esac + else + # Note the libdir as a future libdir. + case "$future_libdirs " in + *" $libdir "*) ;; + *) future_libdirs="$future_libdirs $libdir" ;; + esac + fi + + dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/ + test "X$dir" = "X$file/" && dir= + dir="$dir$objdir" + + if test -n "$relink_command"; then + # Determine the prefix the user has applied to our future dir. + inst_prefix_dir=`$echo "$destdir" | $SED "s%$libdir\$%%"` + + # Don't allow the user to place us outside of our expected + # location b/c this prevents finding dependent libraries that + # are installed to the same prefix. + # At present, this check doesn't affect windows .dll's that + # are installed into $libdir/../bin (currently, that works fine) + # but it's something to keep an eye on. + if test "$inst_prefix_dir" = "$destdir"; then + $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2 + exit $EXIT_FAILURE + fi + + if test -n "$inst_prefix_dir"; then + # Stick the inst_prefix_dir data into the link command. + relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` + else + relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%%"` + fi + + $echo "$modename: warning: relinking \`$file'" 1>&2 + $show "$relink_command" + if $run eval "$relink_command"; then : + else + $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2 + exit $EXIT_FAILURE + fi + fi + + # See the names of the shared library. + set dummy $library_names + if test -n "$2"; then + realname="$2" + shift + shift + + srcname="$realname" + test -n "$relink_command" && srcname="$realname"T + + # Install the shared library and build the symlinks. + $show "$install_prog $dir/$srcname $destdir/$realname" + $run eval "$install_prog $dir/$srcname $destdir/$realname" || exit $? + if test -n "$stripme" && test -n "$striplib"; then + $show "$striplib $destdir/$realname" + $run eval "$striplib $destdir/$realname" || exit $? + fi + + if test "$#" -gt 0; then + # Delete the old symlinks, and create new ones. + for linkname + do + if test "$linkname" != "$realname"; then + $show "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)" + $run eval "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)" + fi + done + fi + + # Do each command in the postinstall commands. + lib="$destdir/$realname" + cmds=$postinstall_cmds + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + fi + + # Install the pseudo-library for information purposes. + name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + instname="$dir/$name"i + $show "$install_prog $instname $destdir/$name" + $run eval "$install_prog $instname $destdir/$name" || exit $? + + # Maybe install the static library, too. + test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library" + ;; + + *.lo) + # Install (i.e. copy) a libtool object. + + # Figure out destination file name, if it wasn't already specified. + if test -n "$destname"; then + destfile="$destdir/$destname" + else + destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + destfile="$destdir/$destfile" + fi + + # Deduce the name of the destination old-style object file. + case $destfile in + *.lo) + staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"` + ;; + *.$objext) + staticdest="$destfile" + destfile= + ;; + *) + $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + ;; + esac + + # Install the libtool object if requested. + if test -n "$destfile"; then + $show "$install_prog $file $destfile" + $run eval "$install_prog $file $destfile" || exit $? + fi + + # Install the old object if enabled. + if test "$build_old_libs" = yes; then + # Deduce the name of the old-style object file. + staticobj=`$echo "X$file" | $Xsed -e "$lo2o"` + + $show "$install_prog $staticobj $staticdest" + $run eval "$install_prog \$staticobj \$staticdest" || exit $? + fi + exit $EXIT_SUCCESS + ;; + + *) + # Figure out destination file name, if it wasn't already specified. + if test -n "$destname"; then + destfile="$destdir/$destname" + else + destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + destfile="$destdir/$destfile" + fi + + # If the file is missing, and there is a .exe on the end, strip it + # because it is most likely a libtool script we actually want to + # install + stripped_ext="" + case $file in + *.exe) + if test ! -f "$file"; then + file=`$echo $file|${SED} 's,.exe$,,'` + stripped_ext=".exe" + fi + ;; + esac + + # Do a test to see if this is really a libtool program. + case $host in + *cygwin*|*mingw*) + wrapper=`$echo $file | ${SED} -e 's,.exe$,,'` + ;; + *) + wrapper=$file + ;; + esac + if (${SED} -e '4q' $wrapper | grep "^# Generated by .*$PACKAGE")>/dev/null 2>&1; then + notinst_deplibs= + relink_command= + + # To insure that "foo" is sourced, and not "foo.exe", + # finese the cygwin/MSYS system by explicitly sourcing "foo." + # which disallows the automatic-append-.exe behavior. + case $build in + *cygwin* | *mingw*) wrapperdot=${wrapper}. ;; + *) wrapperdot=${wrapper} ;; + esac + # If there is no directory component, then add one. + case $file in + */* | *\\*) . ${wrapperdot} ;; + *) . ./${wrapperdot} ;; + esac + + # Check the variables that should have been set. + if test -z "$notinst_deplibs"; then + $echo "$modename: invalid libtool wrapper script \`$wrapper'" 1>&2 + exit $EXIT_FAILURE + fi + + finalize=yes + for lib in $notinst_deplibs; do + # Check to see that each library is installed. + libdir= + if test -f "$lib"; then + # If there is no directory component, then add one. + case $lib in + */* | *\\*) . $lib ;; + *) . ./$lib ;; + esac + fi + libfile="$libdir/"`$echo "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test + if test -n "$libdir" && test ! -f "$libfile"; then + $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2 + finalize=no + fi + done + + relink_command= + # To insure that "foo" is sourced, and not "foo.exe", + # finese the cygwin/MSYS system by explicitly sourcing "foo." + # which disallows the automatic-append-.exe behavior. + case $build in + *cygwin* | *mingw*) wrapperdot=${wrapper}. ;; + *) wrapperdot=${wrapper} ;; + esac + # If there is no directory component, then add one. + case $file in + */* | *\\*) . ${wrapperdot} ;; + *) . ./${wrapperdot} ;; + esac + + outputname= + if test "$fast_install" = no && test -n "$relink_command"; then + if test "$finalize" = yes && test -z "$run"; then + tmpdir="/tmp" + test -n "$TMPDIR" && tmpdir="$TMPDIR" + tmpdir="$tmpdir/libtool-$$" + save_umask=`umask` + umask 0077 + if $mkdir "$tmpdir"; then + umask $save_umask + else + umask $save_umask + $echo "$modename: error: cannot create temporary directory \`$tmpdir'" 1>&2 + continue + fi + file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'` + outputname="$tmpdir/$file" + # Replace the output file specification. + relink_command=`$echo "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'` + + $show "$relink_command" + if $run eval "$relink_command"; then : + else + $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2 + ${rm}r "$tmpdir" + continue + fi + file="$outputname" + else + $echo "$modename: warning: cannot relink \`$file'" 1>&2 + fi + else + # Install the binary that we compiled earlier. + file=`$echo "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"` + fi + fi + + # remove .exe since cygwin /usr/bin/install will append another + # one anyways + case $install_prog,$host in + */usr/bin/install*,*cygwin*) + case $file:$destfile in + *.exe:*.exe) + # this is ok + ;; + *.exe:*) + destfile=$destfile.exe + ;; + *:*.exe) + destfile=`$echo $destfile | ${SED} -e 's,.exe$,,'` + ;; + esac + ;; + esac + $show "$install_prog$stripme $file $destfile" + $run eval "$install_prog\$stripme \$file \$destfile" || exit $? + test -n "$outputname" && ${rm}r "$tmpdir" + ;; + esac + done + + for file in $staticlibs; do + name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + + # Set up the ranlib parameters. + oldlib="$destdir/$name" + + $show "$install_prog $file $oldlib" + $run eval "$install_prog \$file \$oldlib" || exit $? + + if test -n "$stripme" && test -n "$old_striplib"; then + $show "$old_striplib $oldlib" + $run eval "$old_striplib $oldlib" || exit $? + fi + + # Do each command in the postinstall commands. + cmds=$old_postinstall_cmds + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + done + + if test -n "$future_libdirs"; then + $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2 + fi + + if test -n "$current_libdirs"; then + # Maybe just do a dry run. + test -n "$run" && current_libdirs=" -n$current_libdirs" + exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' + else + exit $EXIT_SUCCESS + fi + ;; + + # libtool finish mode + finish) + modename="$modename: finish" + libdirs="$nonopt" + admincmds= + + if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then + for dir + do + libdirs="$libdirs $dir" + done + + for libdir in $libdirs; do + if test -n "$finish_cmds"; then + # Do each command in the finish commands. + cmds=$finish_cmds + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" || admincmds="$admincmds + $cmd" + done + IFS="$save_ifs" + fi + if test -n "$finish_eval"; then + # Do the single finish_eval. + eval cmds=\"$finish_eval\" + $run eval "$cmds" || admincmds="$admincmds + $cmds" + fi + done + fi + + # Exit here if they wanted silent mode. + test "$show" = : && exit $EXIT_SUCCESS + + $echo "----------------------------------------------------------------------" + $echo "Libraries have been installed in:" + for libdir in $libdirs; do + $echo " $libdir" + done + $echo + $echo "If you ever happen to want to link against installed libraries" + $echo "in a given directory, LIBDIR, you must either use libtool, and" + $echo "specify the full pathname of the library, or use the \`-LLIBDIR'" + $echo "flag during linking and do at least one of the following:" + if test -n "$shlibpath_var"; then + $echo " - add LIBDIR to the \`$shlibpath_var' environment variable" + $echo " during execution" + fi + if test -n "$runpath_var"; then + $echo " - add LIBDIR to the \`$runpath_var' environment variable" + $echo " during linking" + fi + if test -n "$hardcode_libdir_flag_spec"; then + libdir=LIBDIR + eval flag=\"$hardcode_libdir_flag_spec\" + + $echo " - use the \`$flag' linker flag" + fi + if test -n "$admincmds"; then + $echo " - have your system administrator run these commands:$admincmds" + fi + if test -f /etc/ld.so.conf; then + $echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" + fi + $echo + $echo "See any operating system documentation about shared libraries for" + $echo "more information, such as the ld(1) and ld.so(8) manual pages." + $echo "----------------------------------------------------------------------" + exit $EXIT_SUCCESS + ;; + + # libtool execute mode + execute) + modename="$modename: execute" + + # The first argument is the command name. + cmd="$nonopt" + if test -z "$cmd"; then + $echo "$modename: you must specify a COMMAND" 1>&2 + $echo "$help" + exit $EXIT_FAILURE + fi + + # Handle -dlopen flags immediately. + for file in $execute_dlfiles; do + if test ! -f "$file"; then + $echo "$modename: \`$file' is not a file" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + dir= + case $file in + *.la) + # Check to see that this really is a libtool archive. + if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : + else + $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + # Read the libtool library. + dlname= + library_names= + + # If there is no directory component, then add one. + case $file in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + # Skip this library if it cannot be dlopened. + if test -z "$dlname"; then + # Warn if it was a shared library. + test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'" + continue + fi + + dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + test "X$dir" = "X$file" && dir=. + + if test -f "$dir/$objdir/$dlname"; then + dir="$dir/$objdir" + else + $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2 + exit $EXIT_FAILURE + fi + ;; + + *.lo) + # Just add the directory containing the .lo file. + dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + test "X$dir" = "X$file" && dir=. + ;; + + *) + $echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2 + continue + ;; + esac + + # Get the absolute pathname. + absdir=`cd "$dir" && pwd` + test -n "$absdir" && dir="$absdir" + + # Now add the directory to shlibpath_var. + if eval "test -z \"\$$shlibpath_var\""; then + eval "$shlibpath_var=\"\$dir\"" + else + eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" + fi + done + + # This variable tells wrapper scripts just to set shlibpath_var + # rather than running their programs. + libtool_execute_magic="$magic" + + # Check if any of the arguments is a wrapper script. + args= + for file + do + case $file in + -*) ;; + *) + # Do a test to see if this is really a libtool program. + if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + # If there is no directory component, then add one. + case $file in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + # Transform arg to wrapped name. + file="$progdir/$program" + fi + ;; + esac + # Quote arguments (to preserve shell metacharacters). + file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"` + args="$args \"$file\"" + done + + if test -z "$run"; then + if test -n "$shlibpath_var"; then + # Export the shlibpath_var. + eval "export $shlibpath_var" + fi + + # Restore saved environment variables + if test "${save_LC_ALL+set}" = set; then + LC_ALL="$save_LC_ALL"; export LC_ALL + fi + if test "${save_LANG+set}" = set; then + LANG="$save_LANG"; export LANG + fi + + # Now prepare to actually exec the command. + exec_cmd="\$cmd$args" + else + # Display what would be done. + if test -n "$shlibpath_var"; then + eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\"" + $echo "export $shlibpath_var" + fi + $echo "$cmd$args" + exit $EXIT_SUCCESS + fi + ;; + + # libtool clean and uninstall mode + clean | uninstall) + modename="$modename: $mode" + rm="$nonopt" + files= + rmforce= + exit_status=0 + + # This variable tells wrapper scripts just to set variables rather + # than running their programs. + libtool_install_magic="$magic" + + for arg + do + case $arg in + -f) rm="$rm $arg"; rmforce=yes ;; + -*) rm="$rm $arg" ;; + *) files="$files $arg" ;; + esac + done + + if test -z "$rm"; then + $echo "$modename: you must specify an RM program" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + rmdirs= + + origobjdir="$objdir" + for file in $files; do + dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + if test "X$dir" = "X$file"; then + dir=. + objdir="$origobjdir" + else + objdir="$dir/$origobjdir" + fi + name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + test "$mode" = uninstall && objdir="$dir" + + # Remember objdir for removal later, being careful to avoid duplicates + if test "$mode" = clean; then + case " $rmdirs " in + *" $objdir "*) ;; + *) rmdirs="$rmdirs $objdir" ;; + esac + fi + + # Don't error if the file doesn't exist and rm -f was used. + if (test -L "$file") >/dev/null 2>&1 \ + || (test -h "$file") >/dev/null 2>&1 \ + || test -f "$file"; then + : + elif test -d "$file"; then + exit_status=1 + continue + elif test "$rmforce" = yes; then + continue + fi + + rmfiles="$file" + + case $name in + *.la) + # Possibly a libtool archive, so verify it. + if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + . $dir/$name + + # Delete the libtool libraries and symlinks. + for n in $library_names; do + rmfiles="$rmfiles $objdir/$n" + done + test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library" + test "$mode" = clean && rmfiles="$rmfiles $objdir/$name $objdir/${name}i" + + if test "$mode" = uninstall; then + if test -n "$library_names"; then + # Do each command in the postuninstall commands. + cmds=$postuninstall_cmds + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" + if test "$?" -ne 0 && test "$rmforce" != yes; then + exit_status=1 + fi + done + IFS="$save_ifs" + fi + + if test -n "$old_library"; then + # Do each command in the old_postuninstall commands. + cmds=$old_postuninstall_cmds + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" + if test "$?" -ne 0 && test "$rmforce" != yes; then + exit_status=1 + fi + done + IFS="$save_ifs" + fi + # FIXME: should reinstall the best remaining shared library. + fi + fi + ;; + + *.lo) + # Possibly a libtool object, so verify it. + if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + + # Read the .lo file + . $dir/$name + + # Add PIC object to the list of files to remove. + if test -n "$pic_object" \ + && test "$pic_object" != none; then + rmfiles="$rmfiles $dir/$pic_object" + fi + + # Add non-PIC object to the list of files to remove. + if test -n "$non_pic_object" \ + && test "$non_pic_object" != none; then + rmfiles="$rmfiles $dir/$non_pic_object" + fi + fi + ;; + + *) + if test "$mode" = clean ; then + noexename=$name + case $file in + *.exe) + file=`$echo $file|${SED} 's,.exe$,,'` + noexename=`$echo $name|${SED} 's,.exe$,,'` + # $file with .exe has already been added to rmfiles, + # add $file without .exe + rmfiles="$rmfiles $file" + ;; + esac + # Do a test to see if this is a libtool program. + if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + relink_command= + . $dir/$noexename + + # note $name still contains .exe if it was in $file originally + # as does the version of $file that was added into $rmfiles + rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}" + if test "$fast_install" = yes && test -n "$relink_command"; then + rmfiles="$rmfiles $objdir/lt-$name" + fi + if test "X$noexename" != "X$name" ; then + rmfiles="$rmfiles $objdir/lt-${noexename}.c" + fi + fi + fi + ;; + esac + $show "$rm $rmfiles" + $run $rm $rmfiles || exit_status=1 + done + objdir="$origobjdir" + + # Try to remove the ${objdir}s in the directories where we deleted files + for dir in $rmdirs; do + if test -d "$dir"; then + $show "rmdir $dir" + $run rmdir $dir >/dev/null 2>&1 + fi + done + + exit $exit_status + ;; + + "") + $echo "$modename: you must specify a MODE" 1>&2 + $echo "$generic_help" 1>&2 + exit $EXIT_FAILURE + ;; + esac + + if test -z "$exec_cmd"; then + $echo "$modename: invalid operation mode \`$mode'" 1>&2 + $echo "$generic_help" 1>&2 + exit $EXIT_FAILURE + fi +fi # test -z "$show_help" + +if test -n "$exec_cmd"; then + eval exec $exec_cmd + exit $EXIT_FAILURE +fi + +# We need to display help for each of the modes. +case $mode in +"") $echo \ +"Usage: $modename [OPTION]... [MODE-ARG]... + +Provide generalized library-building support services. + + --config show all configuration variables + --debug enable verbose shell tracing +-n, --dry-run display commands without modifying any files + --features display basic configuration information and exit + --finish same as \`--mode=finish' + --help display this help message and exit + --mode=MODE use operation mode MODE [default=inferred from MODE-ARGS] + --quiet same as \`--silent' + --silent don't print informational messages + --tag=TAG use configuration variables from tag TAG + --version print version information + +MODE must be one of the following: + + clean remove files from the build directory + compile compile a source file into a libtool object + execute automatically set library path, then run a program + finish complete the installation of libtool libraries + install install libraries or executables + link create a library or an executable + uninstall remove libraries from an installed directory + +MODE-ARGS vary depending on the MODE. Try \`$modename --help --mode=MODE' for +a more detailed description of MODE. + +Report bugs to ." + exit $EXIT_SUCCESS + ;; + +clean) + $echo \ +"Usage: $modename [OPTION]... --mode=clean RM [RM-OPTION]... FILE... + +Remove files from the build directory. + +RM is the name of the program to use to delete files associated with each FILE +(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed +to RM. + +If FILE is a libtool library, object or program, all the files associated +with it are deleted. Otherwise, only FILE itself is deleted using RM." + ;; + +compile) + $echo \ +"Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE + +Compile a source file into a libtool library object. + +This mode accepts the following additional options: + + -o OUTPUT-FILE set the output file name to OUTPUT-FILE + -prefer-pic try to building PIC objects only + -prefer-non-pic try to building non-PIC objects only + -static always build a \`.o' file suitable for static linking + +COMPILE-COMMAND is a command to be used in creating a \`standard' object file +from the given SOURCEFILE. + +The output file name is determined by removing the directory component from +SOURCEFILE, then substituting the C source code suffix \`.c' with the +library object suffix, \`.lo'." + ;; + +execute) + $echo \ +"Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]... + +Automatically set library path, then run a program. + +This mode accepts the following additional options: + + -dlopen FILE add the directory containing FILE to the library path + +This mode sets the library path environment variable according to \`-dlopen' +flags. + +If any of the ARGS are libtool executable wrappers, then they are translated +into their corresponding uninstalled binary, and any of their required library +directories are added to the library path. + +Then, COMMAND is executed, with ARGS as arguments." + ;; + +finish) + $echo \ +"Usage: $modename [OPTION]... --mode=finish [LIBDIR]... + +Complete the installation of libtool libraries. + +Each LIBDIR is a directory that contains libtool libraries. + +The commands that this mode executes may require superuser privileges. Use +the \`--dry-run' option if you just want to see what would be executed." + ;; + +install) + $echo \ +"Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND... + +Install executables or libraries. + +INSTALL-COMMAND is the installation command. The first component should be +either the \`install' or \`cp' program. + +The rest of the components are interpreted as arguments to that command (only +BSD-compatible install options are recognized)." + ;; + +link) + $echo \ +"Usage: $modename [OPTION]... --mode=link LINK-COMMAND... + +Link object files or libraries together to form another library, or to +create an executable program. + +LINK-COMMAND is a command using the C compiler that you would use to create +a program from several object files. + +The following components of LINK-COMMAND are treated specially: + + -all-static do not do any dynamic linking at all + -avoid-version do not add a version suffix if possible + -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime + -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols + -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) + -export-symbols SYMFILE + try to export only the symbols listed in SYMFILE + -export-symbols-regex REGEX + try to export only the symbols matching REGEX + -LLIBDIR search LIBDIR for required installed libraries + -lNAME OUTPUT-FILE requires the installed library libNAME + -module build a library that can dlopened + -no-fast-install disable the fast-install mode + -no-install link a not-installable executable + -no-undefined declare that a library does not refer to external symbols + -o OUTPUT-FILE create OUTPUT-FILE from the specified objects + -objectlist FILE Use a list of object files found in FILE to specify objects + -precious-files-regex REGEX + don't remove output files matching REGEX + -release RELEASE specify package release information + -rpath LIBDIR the created library will eventually be installed in LIBDIR + -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries + -static do not do any dynamic linking of libtool libraries + -version-info CURRENT[:REVISION[:AGE]] + specify library version info [each variable defaults to 0] + +All other options (arguments beginning with \`-') are ignored. + +Every other argument is treated as a filename. Files ending in \`.la' are +treated as uninstalled libtool libraries, other files are standard or library +object files. + +If the OUTPUT-FILE ends in \`.la', then a libtool library is created, +only library objects (\`.lo' files) may be specified, and \`-rpath' is +required, except when creating a convenience library. + +If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created +using \`ar' and \`ranlib', or on Windows using \`lib'. + +If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file +is created, otherwise an executable program is created." + ;; + +uninstall) + $echo \ +"Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... + +Remove libraries from an installation directory. + +RM is the name of the program to use to delete files associated with each FILE +(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed +to RM. + +If FILE is a libtool library, all the files associated with it are deleted. +Otherwise, only FILE itself is deleted using RM." + ;; + +*) + $echo "$modename: invalid operation mode \`$mode'" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + ;; +esac + +$echo +$echo "Try \`$modename --help' for more information about other modes." + +exit $EXIT_SUCCESS + +# The TAGs below are defined such that we never get into a situation +# in which we disable both kinds of libraries. Given conflicting +# choices, we go for a static library, that is the most portable, +# since we can't tell whether shared libraries were disabled because +# the user asked for that or because the platform doesn't support +# them. This is particularly important on AIX, because we don't +# support having both static and shared libraries enabled at the same +# time on that platform, so we default to a shared-only configuration. +# If a disable-shared tag is given, we'll fallback to a static-only +# configuration. But we'll never go from static-only to shared-only. + +# ### BEGIN LIBTOOL TAG CONFIG: disable-shared +build_libtool_libs=no +build_old_libs=yes +# ### END LIBTOOL TAG CONFIG: disable-shared + +# ### BEGIN LIBTOOL TAG CONFIG: disable-static +build_old_libs=`case $build_libtool_libs in yes) $echo no;; *) $echo yes;; esac` +# ### END LIBTOOL TAG CONFIG: disable-static + +# Local Variables: +# mode:shell-script +# sh-indentation:2 +# End: diff --git a/ase/configure b/ase/configure new file mode 100755 index 00000000..cecd6ad5 --- /dev/null +++ b/ase/configure @@ -0,0 +1,27053 @@ +#! /bin/sh +# From configure.ac Revision: 1.87 . +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.59 for ase deb-0.1.0. +# +# Copyright (C) 2003 Free Software Foundation, Inc. +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' +elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then + set -o posix +fi +DUALCASE=1; export DUALCASE # for MKS sh + +# Support unset when possible. +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + + +# Work around bugs in pre-3.0 UWIN ksh. +$as_unset ENV MAIL MAILPATH +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME +do + if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + $as_unset $as_var + fi +done + +# Required to use basename. +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + + +# Name of the executable. +as_me=`$as_basename "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)$' \| \ + . : '\(.\)' 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } + /^X\/\(\/\/\)$/{ s//\1/; q; } + /^X\/\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + + +# PATH needs CR, and LINENO needs CR and PATH. +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" || { + # Find who we are. Look in the path if we contain no path at all + # relative or not. + case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done + + ;; + esac + # We did not find ourselves, most probably we were run as `sh COMMAND' + # in which case we are not to be found in the path. + if test "x$as_myself" = x; then + as_myself=$0 + fi + if test ! -f "$as_myself"; then + { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2 + { (exit 1); exit 1; }; } + fi + case $CONFIG_SHELL in + '') + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for as_base in sh bash ksh sh5; do + case $as_dir in + /*) + if ("$as_dir/$as_base" -c ' + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then + $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } + $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } + CONFIG_SHELL=$as_dir/$as_base + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$0" ${1+"$@"} + fi;; + esac + done +done +;; + esac + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line before each line; the second 'sed' does the real + # work. The second script uses 'N' to pair each line-number line + # with the numbered line, and appends trailing '-' during + # substitution so that $LINENO is not a special case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) + sed '=' <$as_myself | + sed ' + N + s,$,-, + : loop + s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, + t loop + s,-$,, + s,^['$as_cr_digits']*\n,, + ' >$as_me.lineno && + chmod +x $as_me.lineno || + { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 + { (exit 1); exit 1; }; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensible to this). + . ./$as_me.lineno + # Exit status is that of the last command. + exit +} + + +case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in + *c*,-n*) ECHO_N= ECHO_C=' +' ECHO_T=' ' ;; + *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; + *) ECHO_N= ECHO_C='\c' ECHO_T= ;; +esac + +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + # We could just check for DJGPP; but this test a) works b) is more generic + # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). + if test -f conf$$.exe; then + # Don't use ln at all; we don't have any links + as_ln_s='cp -p' + else + as_ln_s='ln -s' + fi +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.file + +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +as_executable_p="test -f" + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +# IFS +# We need space, tab and new line, in precisely that order. +as_nl=' +' +IFS=" $as_nl" + +# CDPATH. +$as_unset CDPATH + + + +# Check that we are running under the correct shell. +SHELL=${CONFIG_SHELL-/bin/sh} + +case X$ECHO in +X*--fallback-echo) + # Remove one level of quotation (which was required for Make). + ECHO=`echo "$ECHO" | sed 's,\\\\\$\\$0,'$0','` + ;; +esac + +echo=${ECHO-echo} +if test "X$1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift +elif test "X$1" = X--fallback-echo; then + # Avoid inline document here, it may be left over + : +elif test "X`($echo '\t') 2>/dev/null`" = 'X\t' ; then + # Yippee, $echo works! + : +else + # Restart under the correct shell. + exec $SHELL "$0" --no-reexec ${1+"$@"} +fi + +if test "X$1" = X--fallback-echo; then + # used as fallback echo + shift + cat </dev/null && + echo_test_string="`eval $cmd`" && + (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null + then + break + fi + done +fi + +if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + : +else + # The Solaris, AIX, and Digital Unix default echo programs unquote + # backslashes. This makes it impossible to quote backslashes using + # echo "$something" | sed 's/\\/\\\\/g' + # + # So, first we look for a working echo in the user's PATH. + + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for dir in $PATH /usr/ucb; do + IFS="$lt_save_ifs" + if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && + test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + echo="$dir/echo" + break + fi + done + IFS="$lt_save_ifs" + + if test "X$echo" = Xecho; then + # We didn't find a better echo, so look for alternatives. + if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`(print -r "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + # This shell has a builtin print -r that does the trick. + echo='print -r' + elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) && + test "X$CONFIG_SHELL" != X/bin/ksh; then + # If we have ksh, try running configure again with it. + ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} + export ORIGINAL_CONFIG_SHELL + CONFIG_SHELL=/bin/ksh + export CONFIG_SHELL + exec $CONFIG_SHELL "$0" --no-reexec ${1+"$@"} + else + # Try using printf. + echo='printf %s\n' + if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + # Cool, printf works + : + elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` && + test "X$echo_testing_string" = 'X\t' && + echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL + export CONFIG_SHELL + SHELL="$CONFIG_SHELL" + export SHELL + echo="$CONFIG_SHELL $0 --fallback-echo" + elif echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` && + test "X$echo_testing_string" = 'X\t' && + echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + echo="$CONFIG_SHELL $0 --fallback-echo" + else + # maybe with a smaller string... + prev=: + + for cmd in 'echo test' 'sed 2q "$0"' 'sed 10q "$0"' 'sed 20q "$0"' 'sed 50q "$0"'; do + if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null + then + break + fi + prev="$cmd" + done + + if test "$prev" != 'sed 50q "$0"'; then + echo_test_string=`eval $prev` + export echo_test_string + exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "$0" ${1+"$@"} + else + # Oops. We lost completely, so just stick with echo. + echo=echo + fi + fi + fi + fi +fi +fi + +# Copy echo and quote the copy suitably for passing to libtool from +# the Makefile, instead of quoting the original, which is used later. +ECHO=$echo +if test "X$ECHO" = "X$CONFIG_SHELL $0 --fallback-echo"; then + ECHO="$CONFIG_SHELL \\\$\$0 --fallback-echo" +fi + + + + +tagnames=${tagnames+${tagnames},}CXX + +tagnames=${tagnames+${tagnames},}F77 + +# Name of the host. +# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +exec 6>&1 + +# +# Initializations. +# +ac_default_prefix=/usr/local +ac_config_libobj_dir=. +cross_compiling=no +subdirs= +MFLAGS= +MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} + +# Maximum number of lines to put in a shell here document. +# This variable seems obsolete. It should probably be removed, and +# only ac_max_sed_lines should be used. +: ${ac_max_here_lines=38} + +# Identity of this package. +PACKAGE_NAME='ase' +PACKAGE_TARNAME='ase' +PACKAGE_VERSION='deb-0.1.0' +PACKAGE_STRING='ase deb-0.1.0' +PACKAGE_BUGREPORT='' + +# Factoring default headers for most tests. +ac_includes_default="\ +#include +#if HAVE_SYS_TYPES_H +# include +#endif +#if HAVE_SYS_STAT_H +# include +#endif +#if STDC_HEADERS +# include +# include +#else +# if HAVE_STDLIB_H +# include +# endif +#endif +#if HAVE_STRING_H +# if !STDC_HEADERS && HAVE_MEMORY_H +# include +# endif +# include +#endif +#if HAVE_STRINGS_H +# include +#endif +#if HAVE_INTTYPES_H +# include +#else +# if HAVE_STDINT_H +# include +# endif +#endif +#if HAVE_UNISTD_H +# include +#endif" + +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT build build_cpu build_vendor build_os host host_cpu host_vendor host_os EGREP LN_S ECHO AR ac_ct_AR RANLIB ac_ct_RANLIB STRIP ac_ct_STRIP CPP CXX CXXFLAGS ac_ct_CXX CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL LIBTOOL_DEPS BUILDMODE JAVAC_PATH JAR_PATH CFLAGS_JNI JAVAC JAR JNI LIBOBJS LTLIBOBJS' +ac_subst_files='' + +# Initialize some variables set by options. +ac_init_help= +ac_init_version=false +# The variables have the same names as the options, with +# dashes changed to underlines. +cache_file=/dev/null +exec_prefix=NONE +no_create= +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +verbose= +x_includes=NONE +x_libraries=NONE + +# Installation directory options. +# These are left unexpanded so users can "make install exec_prefix=/foo" +# and all the variables that are supposed to be based on exec_prefix +# by default will actually change. +# Use braces instead of parens because sh, perl, etc. also accept them. +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datadir='${prefix}/share' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +libdir='${exec_prefix}/lib' +includedir='${prefix}/include' +oldincludedir='/usr/include' +infodir='${prefix}/info' +mandir='${prefix}/man' + +ac_prev= +for ac_option +do + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval "$ac_prev=\$ac_option" + ac_prev= + continue + fi + + ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'` + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case $ac_option in + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir=$ac_optarg ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build_alias ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build_alias=$ac_optarg ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file=$ac_optarg ;; + + --config-cache | -C) + cache_file=config.cache ;; + + -datadir | --datadir | --datadi | --datad | --data | --dat | --da) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ + | --da=*) + datadir=$ac_optarg ;; + + -disable-* | --disable-*) + ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/-/_/g'` + eval "enable_$ac_feature=no" ;; + + -enable-* | --enable-*) + ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/-/_/g'` + case $ac_option in + *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; + *) ac_optarg=yes ;; + esac + eval "enable_$ac_feature='$ac_optarg'" ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix=$ac_optarg ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he | -h) + ac_init_help=long ;; + -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) + ac_init_help=recursive ;; + -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) + ac_init_help=short ;; + + -host | --host | --hos | --ho) + ac_prev=host_alias ;; + -host=* | --host=* | --hos=* | --ho=*) + host_alias=$ac_optarg ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir=$ac_optarg ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir=$ac_optarg ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir=$ac_optarg ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir=$ac_optarg ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst \ + | --locals | --local | --loca | --loc | --lo) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* \ + | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) + localstatedir=$ac_optarg ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir=$ac_optarg ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c | -n) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir=$ac_optarg ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix=$ac_optarg ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix=$ac_optarg ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix=$ac_optarg ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name=$ac_optarg ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir=$ac_optarg ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir=$ac_optarg ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site=$ac_optarg ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir=$ac_optarg ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir=$ac_optarg ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target_alias ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target_alias=$ac_optarg ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers | -V) + ac_init_version=: ;; + + -with-* | --with-*) + ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package| sed 's/-/_/g'` + case $ac_option in + *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; + *) ac_optarg=yes ;; + esac + eval "with_$ac_package='$ac_optarg'" ;; + + -without-* | --without-*) + ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package | sed 's/-/_/g'` + eval "with_$ac_package=no" ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes=$ac_optarg ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries=$ac_optarg ;; + + -*) { echo "$as_me: error: unrecognized option: $ac_option +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; } + ;; + + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 + { (exit 1); exit 1; }; } + ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` + eval "$ac_envvar='$ac_optarg'" + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} + ;; + + esac +done + +if test -n "$ac_prev"; then + ac_option=--`echo $ac_prev | sed 's/_/-/g'` + { echo "$as_me: error: missing argument to $ac_option" >&2 + { (exit 1); exit 1; }; } +fi + +# Be sure to have absolute paths. +for ac_var in exec_prefix prefix +do + eval ac_val=$`echo $ac_var` + case $ac_val in + [\\/$]* | ?:[\\/]* | NONE | '' ) ;; + *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; };; + esac +done + +# Be sure to have absolute paths. +for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \ + localstatedir libdir includedir oldincludedir infodir mandir +do + eval ac_val=$`echo $ac_var` + case $ac_val in + [\\/$]* | ?:[\\/]* ) ;; + *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; };; + esac +done + +# There might be people who depend on the old broken behavior: `$host' +# used to hold the argument of --host etc. +# FIXME: To remove some day. +build=$build_alias +host=$host_alias +target=$target_alias + +# FIXME: To remove some day. +if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + cross_compiling=maybe + echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. + If a cross compiler is detected then cross compile mode will be used." >&2 + elif test "x$build_alias" != "x$host_alias"; then + cross_compiling=yes + fi +fi + +ac_tool_prefix= +test -n "$host_alias" && ac_tool_prefix=$host_alias- + +test "$silent" = yes && exec 6>/dev/null + + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then its parent. + ac_confdir=`(dirname "$0") 2>/dev/null || +$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$0" : 'X\(//\)[^/]' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$0" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + srcdir=$ac_confdir + if test ! -r $srcdir/$ac_unique_file; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r $srcdir/$ac_unique_file; then + if test "$ac_srcdir_defaulted" = yes; then + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2 + { (exit 1); exit 1; }; } + else + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 + { (exit 1); exit 1; }; } + fi +fi +(cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null || + { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2 + { (exit 1); exit 1; }; } +srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'` +ac_env_build_alias_set=${build_alias+set} +ac_env_build_alias_value=$build_alias +ac_cv_env_build_alias_set=${build_alias+set} +ac_cv_env_build_alias_value=$build_alias +ac_env_host_alias_set=${host_alias+set} +ac_env_host_alias_value=$host_alias +ac_cv_env_host_alias_set=${host_alias+set} +ac_cv_env_host_alias_value=$host_alias +ac_env_target_alias_set=${target_alias+set} +ac_env_target_alias_value=$target_alias +ac_cv_env_target_alias_set=${target_alias+set} +ac_cv_env_target_alias_value=$target_alias +ac_env_CC_set=${CC+set} +ac_env_CC_value=$CC +ac_cv_env_CC_set=${CC+set} +ac_cv_env_CC_value=$CC +ac_env_CFLAGS_set=${CFLAGS+set} +ac_env_CFLAGS_value=$CFLAGS +ac_cv_env_CFLAGS_set=${CFLAGS+set} +ac_cv_env_CFLAGS_value=$CFLAGS +ac_env_LDFLAGS_set=${LDFLAGS+set} +ac_env_LDFLAGS_value=$LDFLAGS +ac_cv_env_LDFLAGS_set=${LDFLAGS+set} +ac_cv_env_LDFLAGS_value=$LDFLAGS +ac_env_CPPFLAGS_set=${CPPFLAGS+set} +ac_env_CPPFLAGS_value=$CPPFLAGS +ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set} +ac_cv_env_CPPFLAGS_value=$CPPFLAGS +ac_env_CPP_set=${CPP+set} +ac_env_CPP_value=$CPP +ac_cv_env_CPP_set=${CPP+set} +ac_cv_env_CPP_value=$CPP +ac_env_CXX_set=${CXX+set} +ac_env_CXX_value=$CXX +ac_cv_env_CXX_set=${CXX+set} +ac_cv_env_CXX_value=$CXX +ac_env_CXXFLAGS_set=${CXXFLAGS+set} +ac_env_CXXFLAGS_value=$CXXFLAGS +ac_cv_env_CXXFLAGS_set=${CXXFLAGS+set} +ac_cv_env_CXXFLAGS_value=$CXXFLAGS +ac_env_CXXCPP_set=${CXXCPP+set} +ac_env_CXXCPP_value=$CXXCPP +ac_cv_env_CXXCPP_set=${CXXCPP+set} +ac_cv_env_CXXCPP_value=$CXXCPP +ac_env_F77_set=${F77+set} +ac_env_F77_value=$F77 +ac_cv_env_F77_set=${F77+set} +ac_cv_env_F77_value=$F77 +ac_env_FFLAGS_set=${FFLAGS+set} +ac_env_FFLAGS_value=$FFLAGS +ac_cv_env_FFLAGS_set=${FFLAGS+set} +ac_cv_env_FFLAGS_value=$FFLAGS + +# +# Report the --help message. +# +if test "$ac_init_help" = "long"; then + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat <<_ACEOF +\`configure' configures ase deb-0.1.0 to adapt to many kinds of systems. + +Usage: $0 [OPTION]... [VAR=VALUE]... + +To assign environment variables (e.g., CC, CFLAGS...), specify them as +VAR=VALUE. See below for descriptions of some of the useful variables. + +Defaults for the options are specified in brackets. + +Configuration: + -h, --help display this help and exit + --help=short display options specific to this package + --help=recursive display the short help of all the included packages + -V, --version display version information and exit + -q, --quiet, --silent do not print \`checking...' messages + --cache-file=FILE cache test results in FILE [disabled] + -C, --config-cache alias for \`--cache-file=config.cache' + -n, --no-create do not create output files + --srcdir=DIR find the sources in DIR [configure dir or \`..'] + +_ACEOF + + cat <<_ACEOF +Installation directories: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [PREFIX] + +By default, \`make install' will install all the files in +\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify +an installation prefix other than \`$ac_default_prefix' using \`--prefix', +for instance \`--prefix=\$HOME'. + +For better control, use the options below. + +Fine tuning of the installation directories: + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --datadir=DIR read-only architecture-independent data [PREFIX/share] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --infodir=DIR info documentation [PREFIX/info] + --mandir=DIR man documentation [PREFIX/man] +_ACEOF + + cat <<\_ACEOF + +System types: + --build=BUILD configure for building on BUILD [guessed] + --host=HOST cross-compile to build programs to run on HOST [BUILD] +_ACEOF +fi + +if test -n "$ac_init_help"; then + case $ac_init_help in + short | recursive ) echo "Configuration of ase deb-0.1.0:";; + esac + cat <<\_ACEOF + +Optional Features: + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --enable-shared[=PKGS] + build shared libraries [default=yes] + --enable-static[=PKGS] + build static libraries [default=yes] + --enable-fast-install[=PKGS] + optimize for fast installation [default=yes] + --disable-libtool-lock avoid locking (might break parallel builds) + --enable-wchar use wchar_t a default charater type when enabled + (default. yes) + --enable-debug build the library in the debug mode (default. no) + --enable-reentrant define _REENTRANT (default. yes) + +Optional Packages: + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --with-gnu-ld assume the C compiler uses GNU ld [default=no] + --with-pic try to use only PIC/non-PIC objects [default=use + both] + --with-tags[=TAGS] + include additional configurations [automatic] + +Some influential environment variables: + CC C compiler command + CFLAGS C compiler flags + LDFLAGS linker flags, e.g. -L if you have libraries in a + nonstandard directory + CPPFLAGS C/C++ preprocessor flags, e.g. -I if you have + headers in a nonstandard directory + CPP C preprocessor + CXX C++ compiler command + CXXFLAGS C++ compiler flags + CXXCPP C++ preprocessor + F77 Fortran 77 compiler command + FFLAGS Fortran 77 compiler flags + +Use these variables to override the choices made by `configure' or to help +it to find libraries and programs with nonstandard names/locations. + +_ACEOF +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + ac_popdir=`pwd` + for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue + test -d $ac_dir || continue + ac_builddir=. + +if test "$ac_dir" != .; then + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A "../" for each directory in $ac_dir_suffix. + ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` +else + ac_dir_suffix= ac_top_builddir= +fi + +case $srcdir in + .) # No --srcdir option. We are building in place. + ac_srcdir=. + if test -z "$ac_top_builddir"; then + ac_top_srcdir=. + else + ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` + fi ;; + [\\/]* | ?:[\\/]* ) # Absolute path. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir ;; + *) # Relative path. + ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_builddir$srcdir ;; +esac + +# Do not use `cd foo && pwd` to compute absolute paths, because +# the directories may not exist. +case `pwd` in +.) ac_abs_builddir="$ac_dir";; +*) + case "$ac_dir" in + .) ac_abs_builddir=`pwd`;; + [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; + *) ac_abs_builddir=`pwd`/"$ac_dir";; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_builddir=${ac_top_builddir}.;; +*) + case ${ac_top_builddir}. in + .) ac_abs_top_builddir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; + *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_srcdir=$ac_srcdir;; +*) + case $ac_srcdir in + .) ac_abs_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; + *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_srcdir=$ac_top_srcdir;; +*) + case $ac_top_srcdir in + .) ac_abs_top_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; + *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; + esac;; +esac + + cd $ac_dir + # Check for guested configure; otherwise get Cygnus style configure. + if test -f $ac_srcdir/configure.gnu; then + echo + $SHELL $ac_srcdir/configure.gnu --help=recursive + elif test -f $ac_srcdir/configure; then + echo + $SHELL $ac_srcdir/configure --help=recursive + elif test -f $ac_srcdir/configure.ac || + test -f $ac_srcdir/configure.in; then + echo + $ac_configure --help + else + echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi + cd $ac_popdir + done +fi + +test -n "$ac_init_help" && exit 0 +if $ac_init_version; then + cat <<\_ACEOF +ase configure deb-0.1.0 +generated by GNU Autoconf 2.59 + +Copyright (C) 2003 Free Software Foundation, Inc. +This configure script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it. +_ACEOF + exit 0 +fi +exec 5>config.log +cat >&5 <<_ACEOF +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by ase $as_me deb-0.1.0, which was +generated by GNU Autoconf 2.59. Invocation command line was + + $ $0 $@ + +_ACEOF +{ +cat <<_ASUNAME +## --------- ## +## Platform. ## +## --------- ## + +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + +/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` +hostinfo = `(hostinfo) 2>/dev/null || echo unknown` +/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` +/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` + +_ASUNAME + +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + echo "PATH: $as_dir" +done + +} >&5 + +cat >&5 <<_ACEOF + + +## ----------- ## +## Core tests. ## +## ----------- ## + +_ACEOF + + +# Keep a trace of the command line. +# Strip out --no-create and --no-recursion so they do not pile up. +# Strip out --silent because we don't want to record it for future runs. +# Also quote any args containing shell meta-characters. +# Make two passes to allow for proper duplicate-argument suppression. +ac_configure_args= +ac_configure_args0= +ac_configure_args1= +ac_sep= +ac_must_keep_next=false +for ac_pass in 1 2 +do + for ac_arg + do + case $ac_arg in + -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + continue ;; + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) + ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + case $ac_pass in + 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; + 2) + ac_configure_args1="$ac_configure_args1 '$ac_arg'" + if test $ac_must_keep_next = true; then + ac_must_keep_next=false # Got value, back to normal. + else + case $ac_arg in + *=* | --config-cache | -C | -disable-* | --disable-* \ + | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ + | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ + | -with-* | --with-* | -without-* | --without-* | --x) + case "$ac_configure_args0 " in + "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; + esac + ;; + -* ) ac_must_keep_next=true ;; + esac + fi + ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'" + # Get rid of the leading space. + ac_sep=" " + ;; + esac + done +done +$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } +$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } + +# When interrupted or exit'd, cleanup temporary files, and complete +# config.log. We remove comments because anyway the quotes in there +# would cause problems or look ugly. +# WARNING: Be sure not to use single quotes in there, as some shells, +# such as our DU 5.0 friend, will then `close' the trap. +trap 'exit_status=$? + # Save into config.log some information that might help in debugging. + { + echo + + cat <<\_ASBOX +## ---------------- ## +## Cache variables. ## +## ---------------- ## +_ASBOX + echo + # The following way of writing the cache mishandles newlines in values, +{ + (set) 2>&1 | + case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in + *ac_space=\ *) + sed -n \ + "s/'"'"'/'"'"'\\\\'"'"''"'"'/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p" + ;; + *) + sed -n \ + "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + ;; + esac; +} + echo + + cat <<\_ASBOX +## ----------------- ## +## Output variables. ## +## ----------------- ## +_ASBOX + echo + for ac_var in $ac_subst_vars + do + eval ac_val=$`echo $ac_var` + echo "$ac_var='"'"'$ac_val'"'"'" + done | sort + echo + + if test -n "$ac_subst_files"; then + cat <<\_ASBOX +## ------------- ## +## Output files. ## +## ------------- ## +_ASBOX + echo + for ac_var in $ac_subst_files + do + eval ac_val=$`echo $ac_var` + echo "$ac_var='"'"'$ac_val'"'"'" + done | sort + echo + fi + + if test -s confdefs.h; then + cat <<\_ASBOX +## ----------- ## +## confdefs.h. ## +## ----------- ## +_ASBOX + echo + sed "/^$/d" confdefs.h | sort + echo + fi + test "$ac_signal" != 0 && + echo "$as_me: caught signal $ac_signal" + echo "$as_me: exit $exit_status" + } >&5 + rm -f core *.core && + rm -rf conftest* confdefs* conf$$* $ac_clean_files && + exit $exit_status + ' 0 +for ac_signal in 1 2 13 15; do + trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal +done +ac_signal=0 + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -rf conftest* confdefs.h +# AIX cpp loses on an empty file, so make sure it contains at least a newline. +echo >confdefs.h + +# Predefined preprocessor variables. + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_NAME "$PACKAGE_NAME" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_TARNAME "$PACKAGE_TARNAME" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_VERSION "$PACKAGE_VERSION" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_STRING "$PACKAGE_STRING" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" +_ACEOF + + +# Let the site file select an alternate cache file if it wants to. +# Prefer explicitly selected file to automatically selected ones. +if test -z "$CONFIG_SITE"; then + if test "x$prefix" != xNONE; then + CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" + else + CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" + fi +fi +for ac_site_file in $CONFIG_SITE; do + if test -r "$ac_site_file"; then + { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 +echo "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 + . "$ac_site_file" + fi +done + +if test -r "$cache_file"; then + # Some versions of bash will fail to source /dev/null (special + # files actually), so we avoid doing that. + if test -f "$cache_file"; then + { echo "$as_me:$LINENO: loading cache $cache_file" >&5 +echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . $cache_file;; + *) . ./$cache_file;; + esac + fi +else + { echo "$as_me:$LINENO: creating cache $cache_file" >&5 +echo "$as_me: creating cache $cache_file" >&6;} + >$cache_file +fi + +# Check that the precious variables saved in the cache have kept the same +# value. +ac_cache_corrupted=false +for ac_var in `(set) 2>&1 | + sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do + eval ac_old_set=\$ac_cv_env_${ac_var}_set + eval ac_new_set=\$ac_env_${ac_var}_set + eval ac_old_val="\$ac_cv_env_${ac_var}_value" + eval ac_new_val="\$ac_env_${ac_var}_value" + case $ac_old_set,$ac_new_set in + set,) + { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 +echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,);; + *) + if test "x$ac_old_val" != "x$ac_new_val"; then + { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 +echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 +echo "$as_me: former value: $ac_old_val" >&2;} + { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 +echo "$as_me: current value: $ac_new_val" >&2;} + ac_cache_corrupted=: + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) + ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *) ac_arg=$ac_var=$ac_new_val ;; + esac + case " $ac_configure_args " in + *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. + *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; + esac + fi +done +if $ac_cache_corrupted; then + { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 +echo "$as_me: error: changes in the environment can compromise the build" >&2;} + { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 +echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} + { (exit 1); exit 1; }; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ac_config_headers="$ac_config_headers cmn/conf_unx.h" + +ac_aux_dir= +for ac_dir in config $srcdir/config; do + if test -f $ac_dir/install-sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f $ac_dir/install.sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + elif test -f $ac_dir/shtool; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/shtool install -c" + break + fi +done +if test -z "$ac_aux_dir"; then + { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in config $srcdir/config" >&5 +echo "$as_me: error: cannot find install-sh or install.sh in config $srcdir/config" >&2;} + { (exit 1); exit 1; }; } +fi +ac_config_guess="$SHELL $ac_aux_dir/config.guess" +ac_config_sub="$SHELL $ac_aux_dir/config.sub" +ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure. + + +# Checks for programs. +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="gcc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + CC=$ac_ct_CC +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + CC=$ac_ct_CC +else + CC="$ac_cv_prog_CC" +fi + +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$ac_ct_CC" && break +done + + CC=$ac_ct_CC +fi + +fi + + +test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&5 +echo "$as_me: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } + +# Provide some information about the compiler. +echo "$as_me:$LINENO:" \ + "checking for C compiler version" >&5 +ac_compiler=`set X $ac_compile; echo $2` +{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 + (eval $ac_compiler --version &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5 + (eval $ac_compiler -v &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5 + (eval $ac_compiler -V &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.exe b.out" +# Try to create an executable without -o first, disregard a.out. +# It will help us diagnose broken compilers, and finding out an intuition +# of exeext. +echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 +echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6 +ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` +if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5 + (eval $ac_link_default) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # Find the output, starting from the most likely. This scheme is +# not robust to junk in `.', hence go to wildcards (a.*) only as a last +# resort. + +# Be careful to initialize this variable, since it used to be cached. +# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile. +ac_cv_exeext= +# b.out is created by i960 compilers. +for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out +do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) + ;; + conftest.$ac_ext ) + # This is the source file. + ;; + [ab].out ) + # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + # FIXME: I believe we export ac_cv_exeext for Libtool, + # but it would be cool to find out if it's true. Does anybody + # maintain Libtool? --akim. + export ac_cv_exeext + break;; + * ) + break;; + esac +done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { echo "$as_me:$LINENO: error: C compiler cannot create executables +See \`config.log' for more details." >&5 +echo "$as_me: error: C compiler cannot create executables +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; } +fi + +ac_exeext=$ac_cv_exeext +echo "$as_me:$LINENO: result: $ac_file" >&5 +echo "${ECHO_T}$ac_file" >&6 + +# Check the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +echo "$as_me:$LINENO: checking whether the C compiler works" >&5 +echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6 +# FIXME: These cross compiler hacks should be removed for Autoconf 3.0 +# If not cross compiling, check that we can run a simple program. +if test "$cross_compiling" != yes; then + if { ac_try='./$ac_file' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { echo "$as_me:$LINENO: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } + fi + fi +fi +echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + +rm -f a.out a.exe conftest$ac_cv_exeext b.out +ac_clean_files=$ac_clean_files_save +# Check the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 +echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6 +echo "$as_me:$LINENO: result: $cross_compiling" >&5 +echo "${ECHO_T}$cross_compiling" >&6 + +echo "$as_me:$LINENO: checking for suffix of executables" >&5 +echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6 +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # If both `conftest.exe' and `conftest' are `present' (well, observable) +# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will +# work properly (i.e., refer to `conftest.exe'), while it won't with +# `rm'. +for ac_file in conftest.exe conftest conftest.*; do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + export ac_cv_exeext + break;; + * ) break;; + esac +done +else + { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest$ac_cv_exeext +echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 +echo "${ECHO_T}$ac_cv_exeext" >&6 + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +echo "$as_me:$LINENO: checking for suffix of object files" >&5 +echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6 +if test "${ac_cv_objext+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 +echo "${ECHO_T}$ac_cv_objext" >&6 +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 +echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6 +if test "${ac_cv_c_compiler_gnu+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_compiler_gnu=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_compiler_gnu=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 +echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6 +GCC=`test $ac_compiler_gnu = yes && echo yes` +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +CFLAGS="-g" +echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 +echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6 +if test "${ac_cv_prog_cc_g+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_cc_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_prog_cc_g=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_g" >&6 +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5 +echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6 +if test "${ac_cv_prog_cc_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_prog_cc_stdc=no +ac_save_CC=$CC +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include +#include +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std1 is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std1. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +# Don't try gcc -ansi; that turns off useful extensions and +# breaks some systems' header files. +# AIX -qlanglvl=ansi +# Ultrix and OSF/1 -std1 +# HP-UX 10.20 and later -Ae +# HP-UX older versions -Aa -D_HPUX_SOURCE +# SVR4 -Xc -D__EXTENSIONS__ +for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_cc_stdc=$ac_arg +break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext +done +rm -f conftest.$ac_ext conftest.$ac_objext +CC=$ac_save_CC + +fi + +case "x$ac_cv_prog_cc_stdc" in + x|xno) + echo "$as_me:$LINENO: result: none needed" >&5 +echo "${ECHO_T}none needed" >&6 ;; + *) + echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6 + CC="$CC $ac_cv_prog_cc_stdc" ;; +esac + +# Some people use a C++ compiler to compile C. Since we use `exit', +# in C++ we need to declare it. In case someone uses the same compiler +# for both compiling C and C++ we need to have the C++ compiler decide +# the declaration of exit, since it's the most demanding environment. +cat >conftest.$ac_ext <<_ACEOF +#ifndef __cplusplus + choke me +#endif +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + for ac_declaration in \ + '' \ + 'extern "C" void std::exit (int) throw (); using std::exit;' \ + 'extern "C" void std::exit (int); using std::exit;' \ + 'extern "C" void exit (int) throw ();' \ + 'extern "C" void exit (int);' \ + 'void exit (int);' +do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_declaration +#include +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +continue +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_declaration +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +done +rm -f conftest* +if test -n "$ac_declaration"; then + echo '#ifdef __cplusplus' >>confdefs.h + echo $ac_declaration >>confdefs.h + echo '#endif' >>confdefs.h +fi + +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +#AC_PROG_RANLIB +# Check whether --enable-shared or --disable-shared was given. +if test "${enable_shared+set}" = set; then + enableval="$enable_shared" + p=${PACKAGE-default} + case $enableval in + yes) enable_shared=yes ;; + no) enable_shared=no ;; + *) + enable_shared=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_shared=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac +else + enable_shared=yes +fi; + +# Check whether --enable-static or --disable-static was given. +if test "${enable_static+set}" = set; then + enableval="$enable_static" + p=${PACKAGE-default} + case $enableval in + yes) enable_static=yes ;; + no) enable_static=no ;; + *) + enable_static=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_static=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac +else + enable_static=yes +fi; + +# Check whether --enable-fast-install or --disable-fast-install was given. +if test "${enable_fast_install+set}" = set; then + enableval="$enable_fast_install" + p=${PACKAGE-default} + case $enableval in + yes) enable_fast_install=yes ;; + no) enable_fast_install=no ;; + *) + enable_fast_install=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_fast_install=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac +else + enable_fast_install=yes +fi; + +# Make sure we can run config.sub. +$ac_config_sub sun4 >/dev/null 2>&1 || + { { echo "$as_me:$LINENO: error: cannot run $ac_config_sub" >&5 +echo "$as_me: error: cannot run $ac_config_sub" >&2;} + { (exit 1); exit 1; }; } + +echo "$as_me:$LINENO: checking build system type" >&5 +echo $ECHO_N "checking build system type... $ECHO_C" >&6 +if test "${ac_cv_build+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_build_alias=$build_alias +test -z "$ac_cv_build_alias" && + ac_cv_build_alias=`$ac_config_guess` +test -z "$ac_cv_build_alias" && + { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5 +echo "$as_me: error: cannot guess build type; you must specify one" >&2;} + { (exit 1); exit 1; }; } +ac_cv_build=`$ac_config_sub $ac_cv_build_alias` || + { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_build_alias failed" >&5 +echo "$as_me: error: $ac_config_sub $ac_cv_build_alias failed" >&2;} + { (exit 1); exit 1; }; } + +fi +echo "$as_me:$LINENO: result: $ac_cv_build" >&5 +echo "${ECHO_T}$ac_cv_build" >&6 +build=$ac_cv_build +build_cpu=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +build_vendor=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +build_os=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` + + +echo "$as_me:$LINENO: checking host system type" >&5 +echo $ECHO_N "checking host system type... $ECHO_C" >&6 +if test "${ac_cv_host+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_host_alias=$host_alias +test -z "$ac_cv_host_alias" && + ac_cv_host_alias=$ac_cv_build_alias +ac_cv_host=`$ac_config_sub $ac_cv_host_alias` || + { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_host_alias failed" >&5 +echo "$as_me: error: $ac_config_sub $ac_cv_host_alias failed" >&2;} + { (exit 1); exit 1; }; } + +fi +echo "$as_me:$LINENO: result: $ac_cv_host" >&5 +echo "${ECHO_T}$ac_cv_host" >&6 +host=$ac_cv_host +host_cpu=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +host_vendor=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` + + +echo "$as_me:$LINENO: checking for a sed that does not truncate output" >&5 +echo $ECHO_N "checking for a sed that does not truncate output... $ECHO_C" >&6 +if test "${lt_cv_path_SED+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # Loop through the user's path and test for sed and gsed. +# Then use that list of sed's as ones to test for truncation. +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for lt_ac_prog in sed gsed; do + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then + lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" + fi + done + done +done +lt_ac_max=0 +lt_ac_count=0 +# Add /usr/xpg4/bin/sed as it is typically found on Solaris +# along with /bin/sed that truncates output. +for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do + test ! -f $lt_ac_sed && break + cat /dev/null > conftest.in + lt_ac_count=0 + echo $ECHO_N "0123456789$ECHO_C" >conftest.in + # Check for GNU sed and select it if it is found. + if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then + lt_cv_path_SED=$lt_ac_sed + break + fi + while true; do + cat conftest.in conftest.in >conftest.tmp + mv conftest.tmp conftest.in + cp conftest.in conftest.nl + echo >>conftest.nl + $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break + cmp -s conftest.out conftest.nl || break + # 10000 chars as input seems more than enough + test $lt_ac_count -gt 10 && break + lt_ac_count=`expr $lt_ac_count + 1` + if test $lt_ac_count -gt $lt_ac_max; then + lt_ac_max=$lt_ac_count + lt_cv_path_SED=$lt_ac_sed + fi + done +done +SED=$lt_cv_path_SED + +fi + +echo "$as_me:$LINENO: result: $SED" >&5 +echo "${ECHO_T}$SED" >&6 + +echo "$as_me:$LINENO: checking for egrep" >&5 +echo $ECHO_N "checking for egrep... $ECHO_C" >&6 +if test "${ac_cv_prog_egrep+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if echo a | (grep -E '(a|b)') >/dev/null 2>&1 + then ac_cv_prog_egrep='grep -E' + else ac_cv_prog_egrep='egrep' + fi +fi +echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5 +echo "${ECHO_T}$ac_cv_prog_egrep" >&6 + EGREP=$ac_cv_prog_egrep + + + +# Check whether --with-gnu-ld or --without-gnu-ld was given. +if test "${with_gnu_ld+set}" = set; then + withval="$with_gnu_ld" + test "$withval" = no || with_gnu_ld=yes +else + with_gnu_ld=no +fi; +ac_prog=ld +if test "$GCC" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + echo "$as_me:$LINENO: checking for ld used by $CC" >&5 +echo $ECHO_N "checking for ld used by $CC... $ECHO_C" >&6 + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return which upsets mingw + ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $ac_prog in + # Accept absolute paths. + [\\/]* | ?:[\\/]*) + re_direlt='/[^/][^/]*/\.\./' + # Canonicalize the pathname of ld + ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'` + while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do + ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + echo "$as_me:$LINENO: checking for GNU ld" >&5 +echo $ECHO_N "checking for GNU ld... $ECHO_C" >&6 +else + echo "$as_me:$LINENO: checking for non-GNU ld" >&5 +echo $ECHO_N "checking for non-GNU ld... $ECHO_C" >&6 +fi +if test "${lt_cv_path_LD+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -z "$LD"; then + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + lt_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some GNU ld's only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + case `"$lt_cv_path_LD" -v 2>&1 &5 +echo "${ECHO_T}$LD" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi +test -z "$LD" && { { echo "$as_me:$LINENO: error: no acceptable ld found in \$PATH" >&5 +echo "$as_me: error: no acceptable ld found in \$PATH" >&2;} + { (exit 1); exit 1; }; } +echo "$as_me:$LINENO: checking if the linker ($LD) is GNU ld" >&5 +echo $ECHO_N "checking if the linker ($LD) is GNU ld... $ECHO_C" >&6 +if test "${lt_cv_prog_gnu_ld+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # I'd rather use --version here, but apparently some GNU ld's only accept -v. +case `$LD -v 2>&1 &5 +echo "${ECHO_T}$lt_cv_prog_gnu_ld" >&6 +with_gnu_ld=$lt_cv_prog_gnu_ld + + +echo "$as_me:$LINENO: checking for $LD option to reload object files" >&5 +echo $ECHO_N "checking for $LD option to reload object files... $ECHO_C" >&6 +if test "${lt_cv_ld_reload_flag+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + lt_cv_ld_reload_flag='-r' +fi +echo "$as_me:$LINENO: result: $lt_cv_ld_reload_flag" >&5 +echo "${ECHO_T}$lt_cv_ld_reload_flag" >&6 +reload_flag=$lt_cv_ld_reload_flag +case $reload_flag in +"" | " "*) ;; +*) reload_flag=" $reload_flag" ;; +esac +reload_cmds='$LD$reload_flag -o $output$reload_objs' + +echo "$as_me:$LINENO: checking for BSD-compatible nm" >&5 +echo $ECHO_N "checking for BSD-compatible nm... $ECHO_C" >&6 +if test "${lt_cv_path_NM+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$NM"; then + # Let the user override the test. + lt_cv_path_NM="$NM" +else + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + tmp_nm="$ac_dir/${ac_tool_prefix}nm" + if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then + # Check to see if the nm accepts a BSD-compat flag. + # Adding the `sed 1q' prevents false positives on HP-UX, which says: + # nm: unknown option "B" ignored + # Tru64's nm complains that /dev/null is an invalid object file + case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in + */dev/null* | *'Invalid file or object type'*) + lt_cv_path_NM="$tmp_nm -B" + break + ;; + *) + case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in + */dev/null*) + lt_cv_path_NM="$tmp_nm -p" + break + ;; + *) + lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but + continue # so that we can try to find one that supports BSD flags + ;; + esac + esac + fi + done + IFS="$lt_save_ifs" + test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm +fi +fi +echo "$as_me:$LINENO: result: $lt_cv_path_NM" >&5 +echo "${ECHO_T}$lt_cv_path_NM" >&6 +NM="$lt_cv_path_NM" + +echo "$as_me:$LINENO: checking whether ln -s works" >&5 +echo $ECHO_N "checking whether ln -s works... $ECHO_C" >&6 +LN_S=$as_ln_s +if test "$LN_S" = "ln -s"; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 +else + echo "$as_me:$LINENO: result: no, using $LN_S" >&5 +echo "${ECHO_T}no, using $LN_S" >&6 +fi + +echo "$as_me:$LINENO: checking how to recognise dependent libraries" >&5 +echo $ECHO_N "checking how to recognise dependent libraries... $ECHO_C" >&6 +if test "${lt_cv_deplibs_check_method+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + lt_cv_file_magic_cmd='$MAGIC_CMD' +lt_cv_file_magic_test_file= +lt_cv_deplibs_check_method='unknown' +# Need to set the preceding variable on all platforms that support +# interlibrary dependencies. +# 'none' -- dependencies not supported. +# `unknown' -- same as none, but documents that we really don't know. +# 'pass_all' -- all dependencies passed with no checks. +# 'test_compile' -- check by making test program. +# 'file_magic [[regex]]' -- check by looking for files in library path +# which responds to the $file_magic_cmd with a given extended regex. +# If you have `file' or equivalent on your system and you're not sure +# whether `pass_all' will *always* work, you probably want this one. + +case $host_os in +aix4* | aix5*) + lt_cv_deplibs_check_method=pass_all + ;; + +beos*) + lt_cv_deplibs_check_method=pass_all + ;; + +bsdi4*) + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' + lt_cv_file_magic_cmd='/usr/bin/file -L' + lt_cv_file_magic_test_file=/shlib/libc.so + ;; + +cygwin*) + # func_win32_libid is a shell function defined in ltmain.sh + lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' + lt_cv_file_magic_cmd='func_win32_libid' + ;; + +mingw* | pw32*) + # Base MSYS/MinGW do not provide the 'file' command needed by + # func_win32_libid shell function, so use a weaker test based on 'objdump'. + lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?' + lt_cv_file_magic_cmd='$OBJDUMP -f' + ;; + +darwin* | rhapsody*) + lt_cv_deplibs_check_method=pass_all + ;; + +freebsd* | kfreebsd*-gnu) + if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then + case $host_cpu in + i*86 ) + # Not sure whether the presence of OpenBSD here was a mistake. + # Let's accept both of them until this is cleared up. + lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD)/i[3-9]86 (compact )?demand paged shared library' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` + ;; + esac + else + lt_cv_deplibs_check_method=pass_all + fi + ;; + +gnu*) + lt_cv_deplibs_check_method=pass_all + ;; + +hpux10.20* | hpux11*) + lt_cv_file_magic_cmd=/usr/bin/file + case "$host_cpu" in + ia64*) + lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64' + lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so + ;; + hppa*64*) + lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]' + lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl + ;; + *) + lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library' + lt_cv_file_magic_test_file=/usr/lib/libc.sl + ;; + esac + ;; + +irix5* | irix6* | nonstopux*) + case $LD in + *-32|*"-32 ") libmagic=32-bit;; + *-n32|*"-n32 ") libmagic=N32;; + *-64|*"-64 ") libmagic=64-bit;; + *) libmagic=never-match;; + esac + lt_cv_deplibs_check_method=pass_all + ;; + +# This must be Linux ELF. +linux*) + case $host_cpu in + alpha*|hppa*|i*86|ia64*|m68*|mips*|powerpc*|sparc*|s390*|sh*|x86_64*) + lt_cv_deplibs_check_method=pass_all ;; + *) + # glibc up to 2.1.1 does not perform some relocations on ARM + # this will be overridden with pass_all, but let us keep it just in case + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' ;; + esac + lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so` + lt_cv_deplibs_check_method=pass_all + ;; + +netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' + else + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$' + fi + ;; + +newos6*) + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=/usr/lib/libnls.so + ;; + +nto-qnx*) + lt_cv_deplibs_check_method=unknown + ;; + +openbsd*) + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB shared object' + else + lt_cv_deplibs_check_method='file_magic OpenBSD.* shared library' + fi + ;; + +osf3* | osf4* | osf5*) + lt_cv_deplibs_check_method=pass_all + ;; + +sco3.2v5*) + lt_cv_deplibs_check_method=pass_all + ;; + +solaris*) + lt_cv_deplibs_check_method=pass_all + ;; + +sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + case $host_vendor in + motorola) + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]' + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` + ;; + ncr) + lt_cv_deplibs_check_method=pass_all + ;; + sequent) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' + ;; + sni) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib" + lt_cv_file_magic_test_file=/lib/libc.so + ;; + siemens) + lt_cv_deplibs_check_method=pass_all + ;; + esac + ;; + +sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[78]* | unixware7* | sysv4*uw2*) + lt_cv_deplibs_check_method=pass_all + ;; +esac + +fi +echo "$as_me:$LINENO: result: $lt_cv_deplibs_check_method" >&5 +echo "${ECHO_T}$lt_cv_deplibs_check_method" >&6 +file_magic_cmd=$lt_cv_file_magic_cmd +deplibs_check_method=$lt_cv_deplibs_check_method +test -z "$deplibs_check_method" && deplibs_check_method=unknown + + + + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# Allow CC to be a program name with arguments. +compiler=$CC + + +# Check whether --enable-libtool-lock or --disable-libtool-lock was given. +if test "${enable_libtool_lock+set}" = set; then + enableval="$enable_libtool_lock" + +fi; +test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes + +# Some flags need to be propagated to the compiler or linker for good +# libtool support. +case $host in +ia64-*-hpux*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + case `/usr/bin/file conftest.$ac_objext` in + *ELF-32*) + HPUX_IA64_MODE="32" + ;; + *ELF-64*) + HPUX_IA64_MODE="64" + ;; + esac + fi + rm -rf conftest* + ;; +*-*-irix6*) + # Find out which ABI we are using. + echo '#line 3075 "configure"' > conftest.$ac_ext + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + if test "$lt_cv_prog_gnu_ld" = yes; then + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -melf32bsmip" + ;; + *N32*) + LD="${LD-ld} -melf32bmipn32" + ;; + *64-bit*) + LD="${LD-ld} -melf64bmip" + ;; + esac + else + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -32" + ;; + *N32*) + LD="${LD-ld} -n32" + ;; + *64-bit*) + LD="${LD-ld} -64" + ;; + esac + fi + fi + rm -rf conftest* + ;; + +x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + case "`/usr/bin/file conftest.o`" in + *32-bit*) + case $host in + x86_64-*linux*) + LD="${LD-ld} -m elf_i386" + ;; + ppc64-*linux*|powerpc64-*linux*) + LD="${LD-ld} -m elf32ppclinux" + ;; + s390x-*linux*) + LD="${LD-ld} -m elf_s390" + ;; + sparc64-*linux*) + LD="${LD-ld} -m elf32_sparc" + ;; + esac + ;; + *64-bit*) + case $host in + x86_64-*linux*) + LD="${LD-ld} -m elf_x86_64" + ;; + ppc*-*linux*|powerpc*-*linux*) + LD="${LD-ld} -m elf64ppc" + ;; + s390*-*linux*) + LD="${LD-ld} -m elf64_s390" + ;; + sparc*-*linux*) + LD="${LD-ld} -m elf64_sparc" + ;; + esac + ;; + esac + fi + rm -rf conftest* + ;; + +*-*-sco3.2v5*) + # On SCO OpenServer 5, we need -belf to get full-featured binaries. + SAVE_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -belf" + echo "$as_me:$LINENO: checking whether the C compiler needs -belf" >&5 +echo $ECHO_N "checking whether the C compiler needs -belf... $ECHO_C" >&6 +if test "${lt_cv_cc_needs_belf+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + lt_cv_cc_needs_belf=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +lt_cv_cc_needs_belf=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +fi +echo "$as_me:$LINENO: result: $lt_cv_cc_needs_belf" >&5 +echo "${ECHO_T}$lt_cv_cc_needs_belf" >&6 + if test x"$lt_cv_cc_needs_belf" != x"yes"; then + # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf + CFLAGS="$SAVE_CFLAGS" + fi + ;; + +esac + +need_locks="$enable_libtool_lock" + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 +echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6 +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if test "${ac_cv_prog_CPP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether non-existent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +echo "$as_me:$LINENO: result: $CPP" >&5 +echo "${ECHO_T}$CPP" >&6 +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether non-existent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + : +else + { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&5 +echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +echo "$as_me:$LINENO: checking for ANSI C header files" >&5 +echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 +if test "${ac_cv_header_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_header_stdc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_header_stdc=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then + : +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then + : +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then + : +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + exit(2); + exit (0); +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_header_stdc=no +fi +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 +echo "${ECHO_T}$ac_cv_header_stdc" >&6 +if test $ac_cv_header_stdc = yes; then + +cat >>confdefs.h <<\_ACEOF +#define STDC_HEADERS 1 +_ACEOF + +fi + +# On IRIX 5.3, sys/types and inttypes.h are conflicting. + + + + + + + + + +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_Header=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_Header=no" +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + +for ac_header in dlfcn.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_header_compiler=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + ( + cat <<\_ASBOX +## ------------------------------ ## +## Report this to the ase lists. ## +## ------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + +ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu +if test -n "$ac_tool_prefix"; then + for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CXX+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CXX"; then + ac_cv_prog_CXX="$CXX" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +CXX=$ac_cv_prog_CXX +if test -n "$CXX"; then + echo "$as_me:$LINENO: result: $CXX" >&5 +echo "${ECHO_T}$CXX" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$CXX" && break + done +fi +if test -z "$CXX"; then + ac_ct_CXX=$CXX + for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CXX"; then + ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CXX="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CXX=$ac_cv_prog_ac_ct_CXX +if test -n "$ac_ct_CXX"; then + echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5 +echo "${ECHO_T}$ac_ct_CXX" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$ac_ct_CXX" && break +done +test -n "$ac_ct_CXX" || ac_ct_CXX="g++" + + CXX=$ac_ct_CXX +fi + + +# Provide some information about the compiler. +echo "$as_me:$LINENO:" \ + "checking for C++ compiler version" >&5 +ac_compiler=`set X $ac_compile; echo $2` +{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 + (eval $ac_compiler --version &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5 + (eval $ac_compiler -v &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5 + (eval $ac_compiler -V &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + +echo "$as_me:$LINENO: checking whether we are using the GNU C++ compiler" >&5 +echo $ECHO_N "checking whether we are using the GNU C++ compiler... $ECHO_C" >&6 +if test "${ac_cv_cxx_compiler_gnu+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_compiler_gnu=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_compiler_gnu=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_cxx_compiler_gnu=$ac_compiler_gnu + +fi +echo "$as_me:$LINENO: result: $ac_cv_cxx_compiler_gnu" >&5 +echo "${ECHO_T}$ac_cv_cxx_compiler_gnu" >&6 +GXX=`test $ac_compiler_gnu = yes && echo yes` +ac_test_CXXFLAGS=${CXXFLAGS+set} +ac_save_CXXFLAGS=$CXXFLAGS +CXXFLAGS="-g" +echo "$as_me:$LINENO: checking whether $CXX accepts -g" >&5 +echo $ECHO_N "checking whether $CXX accepts -g... $ECHO_C" >&6 +if test "${ac_cv_prog_cxx_g+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_cxx_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_prog_cxx_g=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_prog_cxx_g" >&5 +echo "${ECHO_T}$ac_cv_prog_cxx_g" >&6 +if test "$ac_test_CXXFLAGS" = set; then + CXXFLAGS=$ac_save_CXXFLAGS +elif test $ac_cv_prog_cxx_g = yes; then + if test "$GXX" = yes; then + CXXFLAGS="-g -O2" + else + CXXFLAGS="-g" + fi +else + if test "$GXX" = yes; then + CXXFLAGS="-O2" + else + CXXFLAGS= + fi +fi +for ac_declaration in \ + '' \ + 'extern "C" void std::exit (int) throw (); using std::exit;' \ + 'extern "C" void std::exit (int); using std::exit;' \ + 'extern "C" void exit (int) throw ();' \ + 'extern "C" void exit (int);' \ + 'void exit (int);' +do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_declaration +#include +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +continue +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_declaration +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +done +rm -f conftest* +if test -n "$ac_declaration"; then + echo '#ifdef __cplusplus' >>confdefs.h + echo $ac_declaration >>confdefs.h + echo '#endif' >>confdefs.h +fi + +ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + +ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu +echo "$as_me:$LINENO: checking how to run the C++ preprocessor" >&5 +echo $ECHO_N "checking how to run the C++ preprocessor... $ECHO_C" >&6 +if test -z "$CXXCPP"; then + if test "${ac_cv_prog_CXXCPP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # Double quotes because CXXCPP needs to be expanded + for CXXCPP in "$CXX -E" "/lib/cpp" + do + ac_preproc_ok=false +for ac_cxx_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_cxx_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether non-existent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_cxx_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + break +fi + + done + ac_cv_prog_CXXCPP=$CXXCPP + +fi + CXXCPP=$ac_cv_prog_CXXCPP +else + ac_cv_prog_CXXCPP=$CXXCPP +fi +echo "$as_me:$LINENO: result: $CXXCPP" >&5 +echo "${ECHO_T}$CXXCPP" >&6 +ac_preproc_ok=false +for ac_cxx_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_cxx_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether non-existent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_cxx_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + : +else + { { echo "$as_me:$LINENO: error: C++ preprocessor \"$CXXCPP\" fails sanity check +See \`config.log' for more details." >&5 +echo "$as_me: error: C++ preprocessor \"$CXXCPP\" fails sanity check +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + +ac_ext=f +ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5' +ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_f77_compiler_gnu +if test -n "$ac_tool_prefix"; then + for ac_prog in g77 f77 xlf frt pgf77 fort77 fl32 af77 f90 xlf90 pgf90 epcf90 f95 fort xlf95 ifc efc pgf95 lf95 gfortran + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_F77+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$F77"; then + ac_cv_prog_F77="$F77" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_F77="$ac_tool_prefix$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +F77=$ac_cv_prog_F77 +if test -n "$F77"; then + echo "$as_me:$LINENO: result: $F77" >&5 +echo "${ECHO_T}$F77" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$F77" && break + done +fi +if test -z "$F77"; then + ac_ct_F77=$F77 + for ac_prog in g77 f77 xlf frt pgf77 fort77 fl32 af77 f90 xlf90 pgf90 epcf90 f95 fort xlf95 ifc efc pgf95 lf95 gfortran +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_F77+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_F77"; then + ac_cv_prog_ac_ct_F77="$ac_ct_F77" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_F77="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_F77=$ac_cv_prog_ac_ct_F77 +if test -n "$ac_ct_F77"; then + echo "$as_me:$LINENO: result: $ac_ct_F77" >&5 +echo "${ECHO_T}$ac_ct_F77" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$ac_ct_F77" && break +done + + F77=$ac_ct_F77 +fi + + +# Provide some information about the compiler. +echo "$as_me:4538:" \ + "checking for Fortran 77 compiler version" >&5 +ac_compiler=`set X $ac_compile; echo $2` +{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 + (eval $ac_compiler --version &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5 + (eval $ac_compiler -v &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5 + (eval $ac_compiler -V &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +rm -f a.out + +# If we don't use `.F' as extension, the preprocessor is not run on the +# input file. (Note that this only needs to work for GNU compilers.) +ac_save_ext=$ac_ext +ac_ext=F +echo "$as_me:$LINENO: checking whether we are using the GNU Fortran 77 compiler" >&5 +echo $ECHO_N "checking whether we are using the GNU Fortran 77 compiler... $ECHO_C" >&6 +if test "${ac_cv_f77_compiler_gnu+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF + program main +#ifndef __GNUC__ + choke me +#endif + + end +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_f77_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_compiler_gnu=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_compiler_gnu=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_f77_compiler_gnu=$ac_compiler_gnu + +fi +echo "$as_me:$LINENO: result: $ac_cv_f77_compiler_gnu" >&5 +echo "${ECHO_T}$ac_cv_f77_compiler_gnu" >&6 +ac_ext=$ac_save_ext +ac_test_FFLAGS=${FFLAGS+set} +ac_save_FFLAGS=$FFLAGS +FFLAGS= +echo "$as_me:$LINENO: checking whether $F77 accepts -g" >&5 +echo $ECHO_N "checking whether $F77 accepts -g... $ECHO_C" >&6 +if test "${ac_cv_prog_f77_g+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + FFLAGS=-g +cat >conftest.$ac_ext <<_ACEOF + program main + + end +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_f77_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_f77_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_prog_f77_g=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +echo "$as_me:$LINENO: result: $ac_cv_prog_f77_g" >&5 +echo "${ECHO_T}$ac_cv_prog_f77_g" >&6 +if test "$ac_test_FFLAGS" = set; then + FFLAGS=$ac_save_FFLAGS +elif test $ac_cv_prog_f77_g = yes; then + if test "x$ac_cv_f77_compiler_gnu" = xyes; then + FFLAGS="-g -O2" + else + FFLAGS="-g" + fi +else + if test "x$ac_cv_f77_compiler_gnu" = xyes; then + FFLAGS="-O2" + else + FFLAGS= + fi +fi + +G77=`test $ac_compiler_gnu = yes && echo yes` +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + +# Autoconf 2.13's AC_OBJEXT and AC_EXEEXT macros only works for C compilers! + +# find the maximum length of command line arguments +echo "$as_me:$LINENO: checking the maximum length of command line arguments" >&5 +echo $ECHO_N "checking the maximum length of command line arguments... $ECHO_C" >&6 +if test "${lt_cv_sys_max_cmd_len+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + i=0 + teststring="ABCD" + + case $build_os in + msdosdjgpp*) + # On DJGPP, this test can blow up pretty badly due to problems in libc + # (any single argument exceeding 2000 bytes causes a buffer overrun + # during glob expansion). Even if it were fixed, the result of this + # check would be larger than it should be. + lt_cv_sys_max_cmd_len=12288; # 12K is about right + ;; + + gnu*) + # Under GNU Hurd, this test is not required because there is + # no limit to the length of command line arguments. + # Libtool will interpret -1 as no limit whatsoever + lt_cv_sys_max_cmd_len=-1; + ;; + + cygwin* | mingw*) + # On Win9x/ME, this test blows up -- it succeeds, but takes + # about 5 minutes as the teststring grows exponentially. + # Worse, since 9x/ME are not pre-emptively multitasking, + # you end up with a "frozen" computer, even though with patience + # the test eventually succeeds (with a max line length of 256k). + # Instead, let's just punt: use the minimum linelength reported by + # all of the supported platforms: 8192 (on NT/2K/XP). + lt_cv_sys_max_cmd_len=8192; + ;; + + amigaos*) + # On AmigaOS with pdksh, this test takes hours, literally. + # So we just punt and use a minimum line length of 8192. + lt_cv_sys_max_cmd_len=8192; + ;; + + *) + # If test is not a shell built-in, we'll probably end up computing a + # maximum length that is only half of the actual maximum length, but + # we can't tell. + while (test "X"`$CONFIG_SHELL $0 --fallback-echo "X$teststring" 2>/dev/null` \ + = "XX$teststring") >/dev/null 2>&1 && + new_result=`expr "X$teststring" : ".*" 2>&1` && + lt_cv_sys_max_cmd_len=$new_result && + test $i != 17 # 1/2 MB should be enough + do + i=`expr $i + 1` + teststring=$teststring$teststring + done + teststring= + # Add a significant safety factor because C++ compilers can tack on massive + # amounts of additional arguments before passing them to the linker. + # It appears as though 1/2 is a usable value. + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` + ;; + esac + +fi + +if test -n $lt_cv_sys_max_cmd_len ; then + echo "$as_me:$LINENO: result: $lt_cv_sys_max_cmd_len" >&5 +echo "${ECHO_T}$lt_cv_sys_max_cmd_len" >&6 +else + echo "$as_me:$LINENO: result: none" >&5 +echo "${ECHO_T}none" >&6 +fi + + + + +# Check for command to grab the raw symbol name followed by C symbol from nm. +echo "$as_me:$LINENO: checking command to parse $NM output from $compiler object" >&5 +echo $ECHO_N "checking command to parse $NM output from $compiler object... $ECHO_C" >&6 +if test "${lt_cv_sys_global_symbol_pipe+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + +# These are sane defaults that work on at least a few old systems. +# [They come from Ultrix. What could be older than Ultrix?!! ;)] + +# Character class describing NM global symbol codes. +symcode='[BCDEGRST]' + +# Regexp to match symbols that can be accessed directly from C. +sympat='\([_A-Za-z][_A-Za-z0-9]*\)' + +# Transform the above into a raw symbol and a C symbol. +symxfrm='\1 \2\3 \3' + +# Transform an extracted symbol line into a proper C declaration +lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern int \1;/p'" + +# Transform an extracted symbol line into symbol name and symbol address +lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode \([^ ]*\) \([^ ]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" + +# Define system-specific variables. +case $host_os in +aix*) + symcode='[BCDT]' + ;; +cygwin* | mingw* | pw32*) + symcode='[ABCDGISTW]' + ;; +hpux*) # Its linker distinguishes data from code symbols + if test "$host_cpu" = ia64; then + symcode='[ABCDEGRST]' + fi + lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" + lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" + ;; +irix* | nonstopux*) + symcode='[BCDEGRST]' + ;; +osf*) + symcode='[BCDEGQRST]' + ;; +solaris* | sysv5*) + symcode='[BDRT]' + ;; +sysv4) + symcode='[DFNSTU]' + ;; +esac + +# Handle CRLF in mingw tool chain +opt_cr= +case $build_os in +mingw*) + opt_cr=`echo 'x\{0,1\}' | tr x '\015'` # option cr in regexp + ;; +esac + +# If we're using GNU nm, then use its standard symbol codes. +case `$NM -V 2>&1` in +*GNU* | *'with BFD'*) + symcode='[ABCDGIRSTW]' ;; +esac + +# Try without a prefix undercore, then with it. +for ac_symprfx in "" "_"; do + + # Write the raw and C identifiers. + lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*\($ac_symprfx\)$sympat$opt_cr$/$symxfrm/p'" + + # Check to see that the pipe works correctly. + pipe_works=no + + rm -f conftest* + cat > conftest.$ac_ext <&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # Now try to grab the symbols. + nlist=conftest.nm + if { (eval echo "$as_me:$LINENO: \"$NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist\"") >&5 + (eval $NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && test -s "$nlist"; then + # Try sorting and uniquifying the output. + if sort "$nlist" | uniq > "$nlist"T; then + mv -f "$nlist"T "$nlist" + else + rm -f "$nlist"T + fi + + # Make sure that we snagged all the symbols we need. + if grep ' nm_test_var$' "$nlist" >/dev/null; then + if grep ' nm_test_func$' "$nlist" >/dev/null; then + cat < conftest.$ac_ext +#ifdef __cplusplus +extern "C" { +#endif + +EOF + # Now generate the symbol file. + eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | grep -v main >> conftest.$ac_ext' + + cat <> conftest.$ac_ext +#if defined (__STDC__) && __STDC__ +# define lt_ptr_t void * +#else +# define lt_ptr_t char * +# define const +#endif + +/* The mapping between symbol names and symbols. */ +const struct { + const char *name; + lt_ptr_t address; +} +lt_preloaded_symbols[] = +{ +EOF + $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (lt_ptr_t) \&\2},/" < "$nlist" | grep -v main >> conftest.$ac_ext + cat <<\EOF >> conftest.$ac_ext + {0, (lt_ptr_t) 0} +}; + +#ifdef __cplusplus +} +#endif +EOF + # Now try linking the two files. + mv conftest.$ac_objext conftstm.$ac_objext + lt_save_LIBS="$LIBS" + lt_save_CFLAGS="$CFLAGS" + LIBS="conftstm.$ac_objext" + CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag" + if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && test -s conftest${ac_exeext}; then + pipe_works=yes + fi + LIBS="$lt_save_LIBS" + CFLAGS="$lt_save_CFLAGS" + else + echo "cannot find nm_test_func in $nlist" >&5 + fi + else + echo "cannot find nm_test_var in $nlist" >&5 + fi + else + echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5 + fi + else + echo "$progname: failed program was:" >&5 + cat conftest.$ac_ext >&5 + fi + rm -f conftest* conftst* + + # Do not use the global_symbol_pipe unless it works. + if test "$pipe_works" = yes; then + break + else + lt_cv_sys_global_symbol_pipe= + fi +done + +fi + +if test -z "$lt_cv_sys_global_symbol_pipe"; then + lt_cv_sys_global_symbol_to_cdecl= +fi +if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then + echo "$as_me:$LINENO: result: failed" >&5 +echo "${ECHO_T}failed" >&6 +else + echo "$as_me:$LINENO: result: ok" >&5 +echo "${ECHO_T}ok" >&6 +fi + +echo "$as_me:$LINENO: checking for objdir" >&5 +echo $ECHO_N "checking for objdir... $ECHO_C" >&6 +if test "${lt_cv_objdir+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + rm -f .libs 2>/dev/null +mkdir .libs 2>/dev/null +if test -d .libs; then + lt_cv_objdir=.libs +else + # MS-DOS does not allow filenames that begin with a dot. + lt_cv_objdir=_libs +fi +rmdir .libs 2>/dev/null +fi +echo "$as_me:$LINENO: result: $lt_cv_objdir" >&5 +echo "${ECHO_T}$lt_cv_objdir" >&6 +objdir=$lt_cv_objdir + + + + + +case $host_os in +aix3*) + # AIX sometimes has problems with the GCC collect2 program. For some + # reason, if we set the COLLECT_NAMES environment variable, the problems + # vanish in a puff of smoke. + if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES + fi + ;; +esac + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed='sed -e s/^X//' +sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g' + +# Same as above, but do not quote variable references. +double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g' + +# Sed substitution to delay expansion of an escaped shell variable in a +# double_quote_subst'ed string. +delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' + +# Sed substitution to avoid accidental globbing in evaled expressions +no_glob_subst='s/\*/\\\*/g' + +# Constants: +rm="rm -f" + +# Global variables: +default_ofile=libtool +can_build_shared=yes + +# All known linkers require a `.a' archive for static linking (except M$VC, +# which needs '.lib'). +libext=a +ltmain="$ac_aux_dir/ltmain.sh" +ofile="$default_ofile" +with_gnu_ld="$lt_cv_prog_gnu_ld" + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. +set dummy ${ac_tool_prefix}ar; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_AR+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$AR"; then + ac_cv_prog_AR="$AR" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_AR="${ac_tool_prefix}ar" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +AR=$ac_cv_prog_AR +if test -n "$AR"; then + echo "$as_me:$LINENO: result: $AR" >&5 +echo "${ECHO_T}$AR" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_AR"; then + ac_ct_AR=$AR + # Extract the first word of "ar", so it can be a program name with args. +set dummy ar; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_AR+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_AR"; then + ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_AR="ar" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + + test -z "$ac_cv_prog_ac_ct_AR" && ac_cv_prog_ac_ct_AR="false" +fi +fi +ac_ct_AR=$ac_cv_prog_ac_ct_AR +if test -n "$ac_ct_AR"; then + echo "$as_me:$LINENO: result: $ac_ct_AR" >&5 +echo "${ECHO_T}$ac_ct_AR" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + AR=$ac_ct_AR +else + AR="$ac_cv_prog_AR" +fi + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. +set dummy ${ac_tool_prefix}ranlib; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_RANLIB+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +RANLIB=$ac_cv_prog_RANLIB +if test -n "$RANLIB"; then + echo "$as_me:$LINENO: result: $RANLIB" >&5 +echo "${ECHO_T}$RANLIB" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_RANLIB"; then + ac_ct_RANLIB=$RANLIB + # Extract the first word of "ranlib", so it can be a program name with args. +set dummy ranlib; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_RANLIB"; then + ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_RANLIB="ranlib" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + + test -z "$ac_cv_prog_ac_ct_RANLIB" && ac_cv_prog_ac_ct_RANLIB=":" +fi +fi +ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB +if test -n "$ac_ct_RANLIB"; then + echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5 +echo "${ECHO_T}$ac_ct_RANLIB" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + RANLIB=$ac_ct_RANLIB +else + RANLIB="$ac_cv_prog_RANLIB" +fi + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. +set dummy ${ac_tool_prefix}strip; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_STRIP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$STRIP"; then + ac_cv_prog_STRIP="$STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_STRIP="${ac_tool_prefix}strip" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +STRIP=$ac_cv_prog_STRIP +if test -n "$STRIP"; then + echo "$as_me:$LINENO: result: $STRIP" >&5 +echo "${ECHO_T}$STRIP" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_STRIP"; then + ac_ct_STRIP=$STRIP + # Extract the first word of "strip", so it can be a program name with args. +set dummy strip; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_STRIP"; then + ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_STRIP="strip" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + + test -z "$ac_cv_prog_ac_ct_STRIP" && ac_cv_prog_ac_ct_STRIP=":" +fi +fi +ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP +if test -n "$ac_ct_STRIP"; then + echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5 +echo "${ECHO_T}$ac_ct_STRIP" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + STRIP=$ac_ct_STRIP +else + STRIP="$ac_cv_prog_STRIP" +fi + + +old_CC="$CC" +old_CFLAGS="$CFLAGS" + +# Set sane defaults for various variables +test -z "$AR" && AR=ar +test -z "$AR_FLAGS" && AR_FLAGS=cru +test -z "$AS" && AS=as +test -z "$CC" && CC=cc +test -z "$LTCC" && LTCC=$CC +test -z "$DLLTOOL" && DLLTOOL=dlltool +test -z "$LD" && LD=ld +test -z "$LN_S" && LN_S="ln -s" +test -z "$MAGIC_CMD" && MAGIC_CMD=file +test -z "$NM" && NM=nm +test -z "$SED" && SED=sed +test -z "$OBJDUMP" && OBJDUMP=objdump +test -z "$RANLIB" && RANLIB=: +test -z "$STRIP" && STRIP=: +test -z "$ac_objext" && ac_objext=o + +# Determine commands to create old-style static archives. +old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs' +old_postinstall_cmds='chmod 644 $oldlib' +old_postuninstall_cmds= + +if test -n "$RANLIB"; then + case $host_os in + openbsd*) + old_postinstall_cmds="\$RANLIB -t \$oldlib~$old_postinstall_cmds" + ;; + *) + old_postinstall_cmds="\$RANLIB \$oldlib~$old_postinstall_cmds" + ;; + esac + old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" +fi + +# Only perform the check for file, if the check method requires it +case $deplibs_check_method in +file_magic*) + if test "$file_magic_cmd" = '$MAGIC_CMD'; then + echo "$as_me:$LINENO: checking for ${ac_tool_prefix}file" >&5 +echo $ECHO_N "checking for ${ac_tool_prefix}file... $ECHO_C" >&6 +if test "${lt_cv_path_MAGIC_CMD+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $MAGIC_CMD in +[\\/*] | ?:[\\/]*) + lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. + ;; +*) + lt_save_MAGIC_CMD="$MAGIC_CMD" + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" + for ac_dir in $ac_dummy; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/${ac_tool_prefix}file; then + lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file" + if test -n "$file_magic_test_file"; then + case $deplibs_check_method in + "file_magic "*) + file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`" + MAGIC_CMD="$lt_cv_path_MAGIC_CMD" + if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | + $EGREP "$file_magic_regex" > /dev/null; then + : + else + cat <&2 + +*** Warning: the command libtool uses to detect shared libraries, +*** $file_magic_cmd, produces output that libtool cannot recognize. +*** The result is that libtool may fail to recognize shared libraries +*** as such. This will affect the creation of libtool libraries that +*** depend on shared libraries, but programs linked with such libtool +*** libraries will work regardless of this problem. Nevertheless, you +*** may want to report the problem to your system manager and/or to +*** bug-libtool@gnu.org + +EOF + fi ;; + esac + fi + break + fi + done + IFS="$lt_save_ifs" + MAGIC_CMD="$lt_save_MAGIC_CMD" + ;; +esac +fi + +MAGIC_CMD="$lt_cv_path_MAGIC_CMD" +if test -n "$MAGIC_CMD"; then + echo "$as_me:$LINENO: result: $MAGIC_CMD" >&5 +echo "${ECHO_T}$MAGIC_CMD" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +if test -z "$lt_cv_path_MAGIC_CMD"; then + if test -n "$ac_tool_prefix"; then + echo "$as_me:$LINENO: checking for file" >&5 +echo $ECHO_N "checking for file... $ECHO_C" >&6 +if test "${lt_cv_path_MAGIC_CMD+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $MAGIC_CMD in +[\\/*] | ?:[\\/]*) + lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. + ;; +*) + lt_save_MAGIC_CMD="$MAGIC_CMD" + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" + for ac_dir in $ac_dummy; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/file; then + lt_cv_path_MAGIC_CMD="$ac_dir/file" + if test -n "$file_magic_test_file"; then + case $deplibs_check_method in + "file_magic "*) + file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`" + MAGIC_CMD="$lt_cv_path_MAGIC_CMD" + if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | + $EGREP "$file_magic_regex" > /dev/null; then + : + else + cat <&2 + +*** Warning: the command libtool uses to detect shared libraries, +*** $file_magic_cmd, produces output that libtool cannot recognize. +*** The result is that libtool may fail to recognize shared libraries +*** as such. This will affect the creation of libtool libraries that +*** depend on shared libraries, but programs linked with such libtool +*** libraries will work regardless of this problem. Nevertheless, you +*** may want to report the problem to your system manager and/or to +*** bug-libtool@gnu.org + +EOF + fi ;; + esac + fi + break + fi + done + IFS="$lt_save_ifs" + MAGIC_CMD="$lt_save_MAGIC_CMD" + ;; +esac +fi + +MAGIC_CMD="$lt_cv_path_MAGIC_CMD" +if test -n "$MAGIC_CMD"; then + echo "$as_me:$LINENO: result: $MAGIC_CMD" >&5 +echo "${ECHO_T}$MAGIC_CMD" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + else + MAGIC_CMD=: + fi +fi + + fi + ;; +esac + +enable_dlopen=no +enable_win32_dll=no + +# Check whether --enable-libtool-lock or --disable-libtool-lock was given. +if test "${enable_libtool_lock+set}" = set; then + enableval="$enable_libtool_lock" + +fi; +test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes + + +# Check whether --with-pic or --without-pic was given. +if test "${with_pic+set}" = set; then + withval="$with_pic" + pic_mode="$withval" +else + pic_mode=default +fi; +test -z "$pic_mode" && pic_mode=default + +# Use C for the default configuration in the libtool script +tagname= +lt_save_CC="$CC" +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +# Source file extension for C test sources. +ac_ext=c + +# Object file extension for compiled C test sources. +objext=o +objext=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="int some_variable = 0;\n" + +# Code to be used in simple link tests +lt_simple_link_test_code='int main(){return(0);}\n' + + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# Allow CC to be a program name with arguments. +compiler=$CC + + +# +# Check for any special shared library compilation flags. +# +lt_prog_cc_shlib= +if test "$GCC" = no; then + case $host_os in + sco3.2v5*) + lt_prog_cc_shlib='-belf' + ;; + esac +fi +if test -n "$lt_prog_cc_shlib"; then + { echo "$as_me:$LINENO: WARNING: \`$CC' requires \`$lt_prog_cc_shlib' to build shared libraries" >&5 +echo "$as_me: WARNING: \`$CC' requires \`$lt_prog_cc_shlib' to build shared libraries" >&2;} + if echo "$old_CC $old_CFLAGS " | grep "[ ]$lt_prog_cc_shlib[ ]" >/dev/null; then : + else + { echo "$as_me:$LINENO: WARNING: add \`$lt_prog_cc_shlib' to the CC or CFLAGS env variable and reconfigure" >&5 +echo "$as_me: WARNING: add \`$lt_prog_cc_shlib' to the CC or CFLAGS env variable and reconfigure" >&2;} + lt_cv_prog_cc_can_build_shared=no + fi +fi + + +# +# Check to make sure the static flag actually works. +# +echo "$as_me:$LINENO: checking if $compiler static flag $lt_prog_compiler_static works" >&5 +echo $ECHO_N "checking if $compiler static flag $lt_prog_compiler_static works... $ECHO_C" >&6 +if test "${lt_prog_compiler_static_works+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + lt_prog_compiler_static_works=no + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS $lt_prog_compiler_static" + printf "$lt_simple_link_test_code" > conftest.$ac_ext + if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + # Append any errors to the config.log. + cat conftest.err 1>&5 + else + lt_prog_compiler_static_works=yes + fi + fi + $rm conftest* + LDFLAGS="$save_LDFLAGS" + +fi +echo "$as_me:$LINENO: result: $lt_prog_compiler_static_works" >&5 +echo "${ECHO_T}$lt_prog_compiler_static_works" >&6 + +if test x"$lt_prog_compiler_static_works" = xyes; then + : +else + lt_prog_compiler_static= +fi + + + + +lt_prog_compiler_no_builtin_flag= + +if test "$GCC" = yes; then + lt_prog_compiler_no_builtin_flag=' -fno-builtin' + + +echo "$as_me:$LINENO: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 +echo $ECHO_N "checking if $compiler supports -fno-rtti -fno-exceptions... $ECHO_C" >&6 +if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + lt_cv_prog_compiler_rtti_exceptions=no + ac_outfile=conftest.$ac_objext + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="-fno-rtti -fno-exceptions" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:5572: $lt_compile\"" >&5) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&5 + echo "$as_me:5576: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + if test ! -s conftest.err; then + lt_cv_prog_compiler_rtti_exceptions=yes + fi + fi + $rm conftest* + +fi +echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 +echo "${ECHO_T}$lt_cv_prog_compiler_rtti_exceptions" >&6 + +if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then + lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions" +else + : +fi + +fi + +lt_prog_compiler_wl= +lt_prog_compiler_pic= +lt_prog_compiler_static= + +echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5 +echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6 + + if test "$GCC" = yes; then + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_static='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static='-Bstatic' + fi + ;; + + amigaos*) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the `-m68020' flag to GCC prevents building anything better, + # like `-m68040'. + lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4' + ;; + + beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + + mingw* | pw32* | os2*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + lt_prog_compiler_pic='-DDLL_EXPORT' + ;; + + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + lt_prog_compiler_pic='-fno-common' + ;; + + msdosdjgpp*) + # Just because we use GCC doesn't mean we suddenly get shared libraries + # on systems that don't support them. + lt_prog_compiler_can_build_shared=no + enable_shared=no + ;; + + sysv4*MP*) + if test -d /usr/nec; then + lt_prog_compiler_pic=-Kconform_pic + fi + ;; + + hpux*) + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case "$host_cpu" in + hppa*64*|ia64*) + # +Z the default + ;; + *) + lt_prog_compiler_pic='-fPIC' + ;; + esac + ;; + + *) + lt_prog_compiler_pic='-fPIC' + ;; + esac + else + # PORTME Check for flag to pass linker flags through the system compiler. + case $host_os in + aix*) + lt_prog_compiler_wl='-Wl,' + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static='-Bstatic' + else + lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp' + fi + ;; + + mingw* | pw32* | os2*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + lt_prog_compiler_pic='-DDLL_EXPORT' + ;; + + hpux9* | hpux10* | hpux11*) + lt_prog_compiler_wl='-Wl,' + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case "$host_cpu" in + hppa*64*|ia64*) + # +Z the default + ;; + *) + lt_prog_compiler_pic='+Z' + ;; + esac + # Is there a better lt_prog_compiler_static that works with the bundled CC? + lt_prog_compiler_static='${wl}-a ${wl}archive' + ;; + + irix5* | irix6* | nonstopux*) + lt_prog_compiler_wl='-Wl,' + # PIC (with -KPIC) is the default. + lt_prog_compiler_static='-non_shared' + ;; + + newsos6) + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + ;; + + linux*) + case $CC in + icc* | ecc*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-static' + ;; + ccc*) + lt_prog_compiler_wl='-Wl,' + # All Alpha code is PIC. + lt_prog_compiler_static='-non_shared' + ;; + esac + ;; + + osf3* | osf4* | osf5*) + lt_prog_compiler_wl='-Wl,' + # All OSF/1 code is PIC. + lt_prog_compiler_static='-non_shared' + ;; + + sco3.2v5*) + lt_prog_compiler_pic='-Kpic' + lt_prog_compiler_static='-dn' + ;; + + solaris*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + ;; + + sunos4*) + lt_prog_compiler_wl='-Qoption ld ' + lt_prog_compiler_pic='-PIC' + lt_prog_compiler_static='-Bstatic' + ;; + + sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + ;; + + sysv4*MP*) + if test -d /usr/nec ;then + lt_prog_compiler_pic='-Kconform_pic' + lt_prog_compiler_static='-Bstatic' + fi + ;; + + uts4*) + lt_prog_compiler_pic='-pic' + lt_prog_compiler_static='-Bstatic' + ;; + + *) + lt_prog_compiler_can_build_shared=no + ;; + esac + fi + +echo "$as_me:$LINENO: result: $lt_prog_compiler_pic" >&5 +echo "${ECHO_T}$lt_prog_compiler_pic" >&6 + +# +# Check to make sure the PIC flag actually works. +# +if test -n "$lt_prog_compiler_pic"; then + +echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5 +echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic works... $ECHO_C" >&6 +if test "${lt_prog_compiler_pic_works+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + lt_prog_compiler_pic_works=no + ac_outfile=conftest.$ac_objext + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="$lt_prog_compiler_pic -DPIC" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:5805: $lt_compile\"" >&5) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&5 + echo "$as_me:5809: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + if test ! -s conftest.err; then + lt_prog_compiler_pic_works=yes + fi + fi + $rm conftest* + +fi +echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works" >&5 +echo "${ECHO_T}$lt_prog_compiler_pic_works" >&6 + +if test x"$lt_prog_compiler_pic_works" = xyes; then + case $lt_prog_compiler_pic in + "" | " "*) ;; + *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;; + esac +else + lt_prog_compiler_pic= + lt_prog_compiler_can_build_shared=no +fi + +fi +case "$host_os" in + # For platforms which do not support PIC, -DPIC is meaningless: + *djgpp*) + lt_prog_compiler_pic= + ;; + *) + lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC" + ;; +esac + +echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5 +echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6 +if test "${lt_cv_prog_compiler_c_o+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + lt_cv_prog_compiler_c_o=no + $rm -r conftest 2>/dev/null + mkdir conftest + cd conftest + mkdir out + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + + lt_compiler_flag="-o out/conftest2.$ac_objext" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:5865: $lt_compile\"" >&5) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&5 + echo "$as_me:5869: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + if test ! -s out/conftest.err; then + lt_cv_prog_compiler_c_o=yes + fi + fi + chmod u+w . + $rm conftest* + # SGI C++ compiler will create directory out/ii_files/ for + # template instantiation + test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files + $rm out/* && rmdir out + cd .. + rmdir conftest + $rm conftest* + +fi +echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o" >&5 +echo "${ECHO_T}$lt_cv_prog_compiler_c_o" >&6 + + +hard_links="nottested" +if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then + # do not overwrite the value of need_locks provided by the user + echo "$as_me:$LINENO: checking if we can lock with hard links" >&5 +echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6 + hard_links=yes + $rm conftest* + ln conftest.a conftest.b 2>/dev/null && hard_links=no + touch conftest.a + ln conftest.a conftest.b 2>&5 || hard_links=no + ln conftest.a conftest.b 2>/dev/null && hard_links=no + echo "$as_me:$LINENO: result: $hard_links" >&5 +echo "${ECHO_T}$hard_links" >&6 + if test "$hard_links" = no; then + { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 +echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} + need_locks=warn + fi +else + need_locks=no +fi + +echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5 +echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6 + + runpath_var= + allow_undefined_flag= + enable_shared_with_static_runtimes=no + archive_cmds= + archive_expsym_cmds= + old_archive_From_new_cmds= + old_archive_from_expsyms_cmds= + export_dynamic_flag_spec= + whole_archive_flag_spec= + thread_safe_flag_spec= + hardcode_libdir_flag_spec= + hardcode_libdir_flag_spec_ld= + hardcode_libdir_separator= + hardcode_direct=no + hardcode_minus_L=no + hardcode_shlibpath_var=unsupported + link_all_deplibs=unknown + hardcode_automatic=no + module_cmds= + module_expsym_cmds= + always_export_symbols=no + export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + # include_expsyms should be a list of space-separated symbols to be *always* + # included in the symbol list + include_expsyms= + # exclude_expsyms can be an extended regexp of symbols to exclude + # it will be wrapped by ` (' and `)$', so one must not match beginning or + # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', + # as well as any symbol that contains `d'. + exclude_expsyms="_GLOBAL_OFFSET_TABLE_" + # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out + # platforms (ab)use it in PIC code, but their linkers get confused if + # the symbol is explicitly referenced. Since portable code cannot + # rely on this symbol name, it's probably fine to never include it in + # preloaded symbol tables. + extract_expsyms_cmds= + + case $host_os in + cygwin* | mingw* | pw32*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + if test "$GCC" != yes; then + with_gnu_ld=no + fi + ;; + openbsd*) + with_gnu_ld=no + ;; + esac + + ld_shlibs=yes + if test "$with_gnu_ld" = yes; then + # If archive_cmds runs LD, not CC, wlarc should be empty + wlarc='${wl}' + + # See if GNU ld supports shared libraries. + case $host_os in + aix3* | aix4* | aix5*) + # On AIX/PPC, the GNU linker is very broken + if test "$host_cpu" != ia64; then + ld_shlibs=no + cat <&2 + +*** Warning: the GNU linker, at least up to release 2.9.1, is reported +*** to be unable to reliably create shared libraries on AIX. +*** Therefore, libtool is disabling shared libraries support. If you +*** really care for shared libraries, you may want to modify your PATH +*** so that a non-GNU linker is found, and then restart. + +EOF + fi + ;; + + amigaos*) + archive_cmds='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + + # Samuel A. Falvo II reports + # that the semantics of dynamic libraries on AmigaOS, at least up + # to version 4, is to share data among multiple programs linked + # with the same dynamic library. Since this doesn't match the + # behavior of shared libraries on other platforms, we can't use + # them. + ld_shlibs=no + ;; + + beos*) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + allow_undefined_flag=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + else + ld_shlibs=no + fi + ;; + + cygwin* | mingw* | pw32*) + # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless, + # as there is no search path for DLLs. + hardcode_libdir_flag_spec='-L$libdir' + allow_undefined_flag=unsupported + always_export_symbols=no + enable_shared_with_static_runtimes=yes + export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols' + + if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib' + # If the export-symbols file already is a .def file (1st line + # is EXPORTS), use it as is; otherwise, prepend... + archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib' + else + ld_shlibs=no + fi + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' + wlarc= + else + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + fi + ;; + + solaris* | sysv5*) + if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then + ld_shlibs=no + cat <&2 + +*** Warning: The releases 2.8.* of the GNU linker cannot reliably +*** create shared libraries on Solaris systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.9.1 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +EOF + elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs=no + fi + ;; + + sunos4*) + archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' + wlarc= + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + linux*) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + tmp_archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_cmds="$tmp_archive_cmds" + supports_anon_versioning=no + case `$LD -v 2>/dev/null` in + *\ 01.* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 + *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... + *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... + *\ 2.11.*) ;; # other 2.11 versions + *) supports_anon_versioning=yes ;; + esac + if test $supports_anon_versioning = yes; then + archive_expsym_cmds='$echo "{ global:" > $output_objdir/$libname.ver~ +cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ +$echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' + else + archive_expsym_cmds="$tmp_archive_cmds" + fi + else + ld_shlibs=no + fi + ;; + + *) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs=no + fi + ;; + esac + + if test "$ld_shlibs" = yes; then + runpath_var=LD_RUN_PATH + hardcode_libdir_flag_spec='${wl}--rpath ${wl}$libdir' + export_dynamic_flag_spec='${wl}--export-dynamic' + # ancient GNU ld didn't support --whole-archive et. al. + if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then + whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + whole_archive_flag_spec= + fi + fi + else + # PORTME fill in a description of your system's linker (not GNU ld) + case $host_os in + aix3*) + allow_undefined_flag=unsupported + always_export_symbols=yes + archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + hardcode_minus_L=yes + if test "$GCC" = yes && test -z "$link_static_flag"; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + hardcode_direct=unsupported + fi + ;; + + aix4* | aix5*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag="" + else + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to AIX nm, but means don't demangle with GNU nm + if $NM -V 2>&1 | grep 'GNU' > /dev/null; then + export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' + else + export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' + fi + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[23]|aix4.[23].*|aix5*) + for ld_flag in $LDFLAGS; do + if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then + aix_use_runtimelinking=yes + break + fi + done + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + archive_cmds='' + hardcode_direct=yes + hardcode_libdir_separator=':' + link_all_deplibs=yes + + if test "$GCC" = yes; then + case $host_os in aix4.012|aix4.012.*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && \ + strings "$collect2name" | grep resolve_lib_name >/dev/null + then + # We have reworked collect2 + hardcode_direct=yes + else + # We have old collect2 + hardcode_direct=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + hardcode_minus_L=yes + hardcode_libdir_flag_spec='-L$libdir' + hardcode_libdir_separator= + fi + esac + shared_flag='-shared' + else + # not using gcc + if test "$host_cpu" = ia64; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test "$aix_use_runtimelinking" = yes; then + shared_flag='${wl}-G' + else + shared_flag='${wl}-bM:SRE' + fi + fi + fi + + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to export. + always_export_symbols=yes + if test "$aix_use_runtimelinking" = yes; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + allow_undefined_flag='-berok' + # Determine the default libpath from the value encoded in an empty executable. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'`; fi +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi + + hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" + archive_expsym_cmds="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag" + else + if test "$host_cpu" = ia64; then + hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' + allow_undefined_flag="-z nodefs" + archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an empty executable. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'`; fi +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi + + hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + no_undefined_flag=' ${wl}-bernotok' + allow_undefined_flag=' ${wl}-berok' + # -bexpall does not export symbols beginning with underscore (_) + always_export_symbols=yes + # Exported symbols can be pulled into shared objects from archives + whole_archive_flag_spec=' ' + archive_cmds_need_lc=yes + # This is similar to how AIX traditionally builds it's shared libraries. + archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' + fi + fi + ;; + + amigaos*) + archive_cmds='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + # see comment about different semantics on the GNU ld section + ld_shlibs=no + ;; + + bsdi4*) + export_dynamic_flag_spec=-rdynamic + ;; + + cygwin* | mingw* | pw32*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + hardcode_libdir_flag_spec=' ' + allow_undefined_flag=unsupported + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=".dll" + # FIXME: Setting linknames here is a bad hack. + archive_cmds='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames=' + # The linker will automatically build a .lib file if we build a DLL. + old_archive_From_new_cmds='true' + # FIXME: Should let the user specify the lib program. + old_archive_cmds='lib /OUT:$oldlib$oldobjs$old_deplibs' + fix_srcfile_path='`cygpath -w "$srcfile"`' + enable_shared_with_static_runtimes=yes + ;; + + darwin* | rhapsody*) + if test "$GXX" = yes ; then + archive_cmds_need_lc=no + case "$host_os" in + rhapsody* | darwin1.[012]) + allow_undefined_flag='-undefined suppress' + ;; + *) # Darwin 1.3 on + if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then + allow_undefined_flag='-flat_namespace -undefined suppress' + else + case ${MACOSX_DEPLOYMENT_TARGET} in + 10.[012]) + allow_undefined_flag='-flat_namespace -undefined suppress' + ;; + 10.*) + allow_undefined_flag='-undefined dynamic_lookup' + ;; + esac + fi + ;; + esac + lt_int_apple_cc_single_mod=no + output_verbose_link_cmd='echo' + if $CC -dumpspecs 2>&1 | grep 'single_module' >/dev/null ; then + lt_int_apple_cc_single_mod=yes + fi + if test "X$lt_int_apple_cc_single_mod" = Xyes ; then + archive_cmds='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring' + else + archive_cmds='$CC -r ${wl}-bind_at_load -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring' + fi + module_cmds='$CC ${wl}-bind_at_load $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' + # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's + if test "X$lt_int_apple_cc_single_mod" = Xyes ; then + archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + else + archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r ${wl}-bind_at_load -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + fi + module_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + hardcode_direct=no + hardcode_automatic=yes + hardcode_shlibpath_var=unsupported + whole_archive_flag_spec='-all_load $convenience' + link_all_deplibs=yes + else + ld_shlibs=no + fi + ;; + + dgux*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_shlibpath_var=no + ;; + + freebsd1*) + ld_shlibs=no + ;; + + # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor + # support. Future versions do this automatically, but an explicit c++rt0.o + # does not break anything, and helps significantly (at the cost of a little + # extra space). + freebsd2.2*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + # Unfortunately, older versions of FreeBSD 2 do not have this feature. + freebsd2*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=yes + hardcode_minus_L=yes + hardcode_shlibpath_var=no + ;; + + # FreeBSD 3 and greater uses gcc -shared to do shared libraries. + freebsd* | kfreebsd*-gnu) + archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + hpux9*) + if test "$GCC" = yes; then + archive_cmds='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + else + archive_cmds='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + fi + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_direct=yes + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + export_dynamic_flag_spec='${wl}-E' + ;; + + hpux10* | hpux11*) + if test "$GCC" = yes -a "$with_gnu_ld" = no; then + case "$host_cpu" in + hppa*64*|ia64*) + archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + else + case "$host_cpu" in + hppa*64*|ia64*) + archive_cmds='$LD -b +h $soname -o $lib $libobjs $deplibs $linker_flags' + ;; + *) + archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' + ;; + esac + fi + if test "$with_gnu_ld" = no; then + case "$host_cpu" in + hppa*64*) + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_flag_spec_ld='+b $libdir' + hardcode_libdir_separator=: + hardcode_direct=no + hardcode_shlibpath_var=no + ;; + ia64*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_direct=no + hardcode_shlibpath_var=no + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + ;; + *) + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_direct=yes + export_dynamic_flag_spec='${wl}-E' + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + ;; + esac + fi + ;; + + irix5* | irix6* | nonstopux*) + if test "$GCC" = yes; then + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + hardcode_libdir_flag_spec_ld='-rpath $libdir' + fi + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + link_all_deplibs=yes + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out + else + archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF + fi + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + newsos6) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=yes + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_shlibpath_var=no + ;; + + openbsd*) + hardcode_direct=yes + hardcode_shlibpath_var=no + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + export_dynamic_flag_spec='${wl}-E' + else + case $host_os in + openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec='-R$libdir' + ;; + *) + archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + ;; + esac + fi + ;; + + os2*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + allow_undefined_flag=unsupported + archive_cmds='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' + old_archive_From_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' + ;; + + osf3*) + if test "$GCC" = yes; then + allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + allow_undefined_flag=' -expect_unresolved \*' + archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + fi + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + + osf4* | osf5*) # as osf3* with the addition of -msym flag + if test "$GCC" = yes; then + allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + else + allow_undefined_flag=' -expect_unresolved \*' + archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~ + $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib~$rm $lib.exp' + + # Both c and cxx compiler support -rpath directly + hardcode_libdir_flag_spec='-rpath $libdir' + fi + hardcode_libdir_separator=: + ;; + + sco3.2v5*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var=no + export_dynamic_flag_spec='${wl}-Bexport' + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + ;; + + solaris*) + no_undefined_flag=' -z text' + if test "$GCC" = yes; then + archive_cmds='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp' + else + archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' + archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' + fi + hardcode_libdir_flag_spec='-R$libdir' + hardcode_shlibpath_var=no + case $host_os in + solaris2.[0-5] | solaris2.[0-5].*) ;; + *) # Supported since Solaris 2.6 (maybe 2.5.1?) + whole_archive_flag_spec='-z allextract$convenience -z defaultextract' ;; + esac + link_all_deplibs=yes + ;; + + sunos4*) + if test "x$host_vendor" = xsequent; then + # Use $CC to link under sequent, because it throws in some extra .o + # files that make .init and .fini sections work. + archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' + fi + hardcode_libdir_flag_spec='-L$libdir' + hardcode_direct=yes + hardcode_minus_L=yes + hardcode_shlibpath_var=no + ;; + + sysv4) + case $host_vendor in + sni) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=yes # is this really true??? + ;; + siemens) + ## LD is ld it makes a PLAMLIB + ## CC just makes a GrossModule. + archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' + reload_cmds='$CC -r -o $output$reload_objs' + hardcode_direct=no + ;; + motorola) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=no #Motorola manual says yes, but my tests say they lie + ;; + esac + runpath_var='LD_RUN_PATH' + hardcode_shlibpath_var=no + ;; + + sysv4.3*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var=no + export_dynamic_flag_spec='-Bexport' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var=no + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + ld_shlibs=yes + fi + ;; + + sysv4.2uw2*) + archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=yes + hardcode_minus_L=no + hardcode_shlibpath_var=no + hardcode_runpath_var=yes + runpath_var=LD_RUN_PATH + ;; + + sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[78]* | unixware7*) + no_undefined_flag='${wl}-z ${wl}text' + if test "$GCC" = yes; then + archive_cmds='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds='$CC -G ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + runpath_var='LD_RUN_PATH' + hardcode_shlibpath_var=no + ;; + + sysv5*) + no_undefined_flag=' -z text' + # $CC -shared without GNU ld will not create a library from C++ + # object files and a static libstdc++, better avoid it by now + archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' + archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' + hardcode_libdir_flag_spec= + hardcode_shlibpath_var=no + runpath_var='LD_RUN_PATH' + ;; + + uts4*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_shlibpath_var=no + ;; + + *) + ld_shlibs=no + ;; + esac + fi + +echo "$as_me:$LINENO: result: $ld_shlibs" >&5 +echo "${ECHO_T}$ld_shlibs" >&6 +test "$ld_shlibs" = no && can_build_shared=no + +variables_saved_for_relink="PATH $shlibpath_var $runpath_var" +if test "$GCC" = yes; then + variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" +fi + +# +# Do we need to explicitly link libc? +# +case "x$archive_cmds_need_lc" in +x|xyes) + # Assume -lc should be added + archive_cmds_need_lc=yes + + if test "$enable_shared" = yes && test "$GCC" = yes; then + case $archive_cmds in + *'~'*) + # FIXME: we may have to deal with multi-command sequences. + ;; + '$CC '*) + # Test whether the compiler implicitly links with -lc since on some + # systems, -lgcc has to come before -lc. If gcc already passes -lc + # to ld, don't add -lc before -lgcc. + echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5 +echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6 + $rm conftest* + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } 2>conftest.err; then + soname=conftest + lib=conftest + libobjs=conftest.$ac_objext + deplibs= + wl=$lt_prog_compiler_wl + compiler_flags=-v + linker_flags=-v + verstring= + output_objdir=. + libname=conftest + lt_save_allow_undefined_flag=$allow_undefined_flag + allow_undefined_flag= + if { (eval echo "$as_me:$LINENO: \"$archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5 + (eval $archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + then + archive_cmds_need_lc=no + else + archive_cmds_need_lc=yes + fi + allow_undefined_flag=$lt_save_allow_undefined_flag + else + cat conftest.err 1>&5 + fi + $rm conftest* + echo "$as_me:$LINENO: result: $archive_cmds_need_lc" >&5 +echo "${ECHO_T}$archive_cmds_need_lc" >&6 + ;; + esac + fi + ;; +esac + +echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5 +echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6 +library_names_spec= +libname_spec='lib$name' +soname_spec= +shrext_cmds=".so" +postinstall_cmds= +postuninstall_cmds= +finish_cmds= +finish_eval= +shlibpath_var= +shlibpath_overrides_runpath=unknown +version_type=none +dynamic_linker="$host_os ld.so" +sys_lib_dlsearch_path_spec="/lib /usr/lib" +if test "$GCC" = yes; then + sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then + # if the path contains ";" then we assume it to be the separator + # otherwise default to the standard path separator (i.e. ":") - it is + # assumed that no part of a normal pathname contains ";" but that should + # okay in the real world where ";" in dirpaths is itself problematic. + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi +else + sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" +fi +need_lib_prefix=unknown +hardcode_into_libs=no + +# when you set need_version to no, make sure it does not cause -set_version +# flags to be left without arguments +need_version=unknown + +case $host_os in +aix3*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' + shlibpath_var=LIBPATH + + # AIX 3 has no versioning support, so we append a major version to the name. + soname_spec='${libname}${release}${shared_ext}$major' + ;; + +aix4* | aix5*) + version_type=linux + need_lib_prefix=no + need_version=no + hardcode_into_libs=yes + if test "$host_cpu" = ia64; then + # AIX 5 supports IA64 + library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + else + # With GCC up to 2.95.x, collect2 would create an import file + # for dependence libraries. The import file would start with + # the line `#! .'. This would cause the generated library to + # depend on `.', always an invalid library. This was fixed in + # development snapshots of GCC prior to 3.0. + case $host_os in + aix4 | aix4.[01] | aix4.[01].*) + if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' + echo ' yes ' + echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then + : + else + can_build_shared=no + fi + ;; + esac + # AIX (on Power*) has no versioning support, so currently we can not hardcode correct + # soname into executable. Probably we can add versioning support to + # collect2, so additional links can be useful in future. + if test "$aix_use_runtimelinking" = yes; then + # If using run time linking (on AIX 4.2 or later) use lib.so + # instead of lib.a to let people know that these are not + # typical AIX shared libraries. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + else + # We preserve .a as extension for shared libraries through AIX4.2 + # and later when we are not doing run time linking. + library_names_spec='${libname}${release}.a $libname.a' + soname_spec='${libname}${release}${shared_ext}$major' + fi + shlibpath_var=LIBPATH + fi + ;; + +amigaos*) + library_names_spec='$libname.ixlibrary $libname.a' + # Create ${libname}_ixlibrary.a entries in /sys/libs. + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' + ;; + +beos*) + library_names_spec='${libname}${shared_ext}' + dynamic_linker="$host_os ld.so" + shlibpath_var=LIBRARY_PATH + ;; + +bsdi4*) + version_type=linux + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" + sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" + # the default ld.so.conf also contains /usr/contrib/lib and + # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow + # libtool to hard-code these into programs + ;; + +cygwin* | mingw* | pw32*) + version_type=windows + shrext_cmds=".dll" + need_version=no + need_lib_prefix=no + + case $GCC,$host_os in + yes,cygwin* | yes,mingw* | yes,pw32*) + library_names_spec='$libname.dll.a' + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \${file}`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $rm \$dlpath' + shlibpath_overrides_runpath=yes + + case $host_os in + cygwin*) + # Cygwin DLLs use 'cyg' prefix rather than 'lib' + soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" + ;; + mingw*) + # MinGW DLLs use traditional 'lib' prefix + soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then + # It is most probably a Windows format PATH printed by + # mingw gcc, but we are running on Cygwin. Gcc prints its search + # path with ; separators, and with drive letters. We can handle the + # drive letters (cygwin fileutils understands them), so leave them, + # especially as we might pass files found there to a mingw objdump, + # which wouldn't understand a cygwinified path. Ahh. + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + ;; + pw32*) + # pw32 DLLs use 'pw' prefix rather than 'lib' + library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/./-/g'`${versuffix}${shared_ext}' + ;; + esac + ;; + + *) + library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' + ;; + esac + dynamic_linker='Win32 ld.exe' + # FIXME: first we should search . and the directory the executable is in + shlibpath_var=PATH + ;; + +darwin* | rhapsody*) + dynamic_linker="$host_os dyld" + version_type=darwin + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext' + soname_spec='${libname}${release}${major}$shared_ext' + shlibpath_overrides_runpath=yes + shlibpath_var=DYLD_LIBRARY_PATH + shrext_cmds='$(test .$module = .yes && echo .so || echo .dylib)' + # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same. + if test "$GCC" = yes; then + sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"` + else + sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib' + fi + sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' + ;; + +dgux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +freebsd1*) + dynamic_linker=no + ;; + +kfreebsd*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='GNU ld.so' + ;; + +freebsd*) + objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout` + version_type=freebsd-$objformat + case $version_type in + freebsd-elf*) + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + need_version=no + need_lib_prefix=no + ;; + freebsd-*) + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' + need_version=yes + ;; + esac + shlibpath_var=LD_LIBRARY_PATH + case $host_os in + freebsd2*) + shlibpath_overrides_runpath=yes + ;; + freebsd3.01* | freebsdelf3.01*) + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + *) # from 3.2 on + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + esac + ;; + +gnu*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + hardcode_into_libs=yes + ;; + +hpux9* | hpux10* | hpux11*) + # Give a soname corresponding to the major version so that dld.sl refuses to + # link against other versions. + version_type=sunos + need_lib_prefix=no + need_version=no + case "$host_cpu" in + ia64*) + shrext_cmds='.so' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.so" + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + if test "X$HPUX_IA64_MODE" = X32; then + sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" + else + sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" + fi + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + hppa*64*) + shrext_cmds='.sl' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.sl" + shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + *) + shrext_cmds='.sl' + dynamic_linker="$host_os dld.sl" + shlibpath_var=SHLIB_PATH + shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + ;; + esac + # HP-UX runs *really* slowly unless shared libraries are mode 555. + postinstall_cmds='chmod 555 $lib' + ;; + +irix5* | irix6* | nonstopux*) + case $host_os in + nonstopux*) version_type=nonstopux ;; + *) + if test "$lt_cv_prog_gnu_ld" = yes; then + version_type=linux + else + version_type=irix + fi ;; + esac + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' + case $host_os in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in # libtool.m4 will add one of these switches to LD + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") + libsuff= shlibsuff= libmagic=32-bit;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") + libsuff=32 shlibsuff=N32 libmagic=N32;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") + libsuff=64 shlibsuff=64 libmagic=64-bit;; + *) libsuff= shlibsuff= libmagic=never-match;; + esac + ;; + esac + shlibpath_var=LD_LIBRARY${shlibsuff}_PATH + shlibpath_overrides_runpath=no + sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" + sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" + hardcode_into_libs=yes + ;; + +# No shared lib support for Linux oldld, aout, or coff. +linux*oldld* | linux*aout* | linux*coff*) + dynamic_linker=no + ;; + +# This must be Linux ELF. +linux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + # find out which ABI we are using + libsuff= + case "$host_cpu" in + x86_64*|s390x*|powerpc64*) + echo '#line 7199 "configure"' > conftest.$ac_ext + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + case `/usr/bin/file conftest.$ac_objext` in + *64-bit*) + libsuff=64 + sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}" + ;; + esac + fi + rm -rf conftest* + ;; + esac + + # Append ld.so.conf contents to the search path + if test -f /etc/ld.so.conf; then + lt_ld_extra=`$SED -e 's/:,\t/ /g;s/=^=*$//;s/=^= * / /g' /etc/ld.so.conf | tr '\n' ' '` + sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra" + fi + + # We used to test for /lib/ld.so.1 and disable shared libraries on + # powerpc, because MkLinux only supported shared libraries with the + # GNU dynamic linker. Since this was broken with cross compilers, + # most powerpc-linux boxes support dynamic linking these days and + # people can always --disable-shared, the test was removed, and we + # assume the GNU/Linux dynamic linker is in use. + dynamic_linker='GNU/Linux ld.so' + ;; + +knetbsd*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='GNU ld.so' + ;; + +netbsd*) + version_type=sunos + need_lib_prefix=no + need_version=no + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + dynamic_linker='NetBSD (a.out) ld.so' + else + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='NetBSD ld.elf_so' + fi + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + +newsos6) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +nto-qnx*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +openbsd*) + version_type=sunos + need_lib_prefix=no + need_version=yes + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + case $host_os in + openbsd2.[89] | openbsd2.[89].*) + shlibpath_overrides_runpath=no + ;; + *) + shlibpath_overrides_runpath=yes + ;; + esac + else + shlibpath_overrides_runpath=yes + fi + ;; + +os2*) + libname_spec='$name' + shrext_cmds=".dll" + need_lib_prefix=no + library_names_spec='$libname${shared_ext} $libname.a' + dynamic_linker='OS/2 ld.exe' + shlibpath_var=LIBPATH + ;; + +osf3* | osf4* | osf5*) + version_type=osf + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" + sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" + ;; + +sco3.2v5*) + version_type=osf + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + ;; + +solaris*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + # ldd complains unless libraries are executable + postinstall_cmds='chmod +x $lib' + ;; + +sunos4*) + version_type=sunos + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + if test "$with_gnu_ld" = yes; then + need_lib_prefix=no + fi + need_version=yes + ;; + +sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + case $host_vendor in + sni) + shlibpath_overrides_runpath=no + need_lib_prefix=no + export_dynamic_flag_spec='${wl}-Blargedynsym' + runpath_var=LD_RUN_PATH + ;; + siemens) + need_lib_prefix=no + ;; + motorola) + need_lib_prefix=no + need_version=no + shlibpath_overrides_runpath=no + sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' + ;; + esac + ;; + +sysv4*MP*) + if test -d /usr/nec ;then + version_type=linux + library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' + soname_spec='$libname${shared_ext}.$major' + shlibpath_var=LD_LIBRARY_PATH + fi + ;; + +uts4*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +*) + dynamic_linker=no + ;; +esac +echo "$as_me:$LINENO: result: $dynamic_linker" >&5 +echo "${ECHO_T}$dynamic_linker" >&6 +test "$dynamic_linker" = no && can_build_shared=no + +echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5 +echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6 +hardcode_action= +if test -n "$hardcode_libdir_flag_spec" || \ + test -n "$runpath_var " || \ + test "X$hardcode_automatic"="Xyes" ; then + + # We can hardcode non-existant directories. + if test "$hardcode_direct" != no && + # If the only mechanism to avoid hardcoding is shlibpath_var, we + # have to relink, otherwise we might link with an installed library + # when we should be linking with a yet-to-be-installed one + ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, )" != no && + test "$hardcode_minus_L" != no; then + # Linking always hardcodes the temporary library directory. + hardcode_action=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + hardcode_action=immediate + fi +else + # We cannot hardcode anything, or else we can only hardcode existing + # directories. + hardcode_action=unsupported +fi +echo "$as_me:$LINENO: result: $hardcode_action" >&5 +echo "${ECHO_T}$hardcode_action" >&6 + +if test "$hardcode_action" = relink; then + # Fast installation is not supported + enable_fast_install=no +elif test "$shlibpath_overrides_runpath" = yes || + test "$enable_shared" = no; then + # Fast installation is not necessary + enable_fast_install=needless +fi + +striplib= +old_striplib= +echo "$as_me:$LINENO: checking whether stripping libraries is possible" >&5 +echo $ECHO_N "checking whether stripping libraries is possible... $ECHO_C" >&6 +if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then + test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" + test -z "$striplib" && striplib="$STRIP --strip-unneeded" + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 +else +# FIXME - insert some real tests, host_os isn't really good enough + case $host_os in + darwin*) + if test -n "$STRIP" ; then + striplib="$STRIP -x" + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + ;; + *) + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + ;; + esac +fi + +if test "x$enable_dlopen" != xyes; then + enable_dlopen=unknown + enable_dlopen_self=unknown + enable_dlopen_self_static=unknown +else + lt_cv_dlopen=no + lt_cv_dlopen_libs= + + case $host_os in + beos*) + lt_cv_dlopen="load_add_on" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ;; + + mingw* | pw32*) + lt_cv_dlopen="LoadLibrary" + lt_cv_dlopen_libs= + ;; + + cygwin*) + lt_cv_dlopen="dlopen" + lt_cv_dlopen_libs= + ;; + + darwin*) + # if libdl is installed we need to link against it + echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5 +echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6 +if test "${ac_cv_lib_dl_dlopen+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldl $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char dlopen (); +int +main () +{ +dlopen (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_dl_dlopen=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_dl_dlopen=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5 +echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6 +if test $ac_cv_lib_dl_dlopen = yes; then + lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" +else + + lt_cv_dlopen="dyld" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + +fi + + ;; + + *) + echo "$as_me:$LINENO: checking for shl_load" >&5 +echo $ECHO_N "checking for shl_load... $ECHO_C" >&6 +if test "${ac_cv_func_shl_load+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define shl_load to an innocuous variant, in case declares shl_load. + For example, HP-UX 11i declares gettimeofday. */ +#define shl_load innocuous_shl_load + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char shl_load (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef shl_load + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char shl_load (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_shl_load) || defined (__stub___shl_load) +choke me +#else +char (*f) () = shl_load; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != shl_load; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_shl_load=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_func_shl_load=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_func_shl_load" >&5 +echo "${ECHO_T}$ac_cv_func_shl_load" >&6 +if test $ac_cv_func_shl_load = yes; then + lt_cv_dlopen="shl_load" +else + echo "$as_me:$LINENO: checking for shl_load in -ldld" >&5 +echo $ECHO_N "checking for shl_load in -ldld... $ECHO_C" >&6 +if test "${ac_cv_lib_dld_shl_load+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldld $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char shl_load (); +int +main () +{ +shl_load (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_dld_shl_load=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_dld_shl_load=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_dld_shl_load" >&5 +echo "${ECHO_T}$ac_cv_lib_dld_shl_load" >&6 +if test $ac_cv_lib_dld_shl_load = yes; then + lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld" +else + echo "$as_me:$LINENO: checking for dlopen" >&5 +echo $ECHO_N "checking for dlopen... $ECHO_C" >&6 +if test "${ac_cv_func_dlopen+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define dlopen to an innocuous variant, in case declares dlopen. + For example, HP-UX 11i declares gettimeofday. */ +#define dlopen innocuous_dlopen + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char dlopen (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef dlopen + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char dlopen (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_dlopen) || defined (__stub___dlopen) +choke me +#else +char (*f) () = dlopen; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != dlopen; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_dlopen=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_func_dlopen=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_func_dlopen" >&5 +echo "${ECHO_T}$ac_cv_func_dlopen" >&6 +if test $ac_cv_func_dlopen = yes; then + lt_cv_dlopen="dlopen" +else + echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5 +echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6 +if test "${ac_cv_lib_dl_dlopen+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldl $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char dlopen (); +int +main () +{ +dlopen (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_dl_dlopen=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_dl_dlopen=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5 +echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6 +if test $ac_cv_lib_dl_dlopen = yes; then + lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" +else + echo "$as_me:$LINENO: checking for dlopen in -lsvld" >&5 +echo $ECHO_N "checking for dlopen in -lsvld... $ECHO_C" >&6 +if test "${ac_cv_lib_svld_dlopen+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lsvld $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char dlopen (); +int +main () +{ +dlopen (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_svld_dlopen=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_svld_dlopen=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_svld_dlopen" >&5 +echo "${ECHO_T}$ac_cv_lib_svld_dlopen" >&6 +if test $ac_cv_lib_svld_dlopen = yes; then + lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld" +else + echo "$as_me:$LINENO: checking for dld_link in -ldld" >&5 +echo $ECHO_N "checking for dld_link in -ldld... $ECHO_C" >&6 +if test "${ac_cv_lib_dld_dld_link+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldld $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char dld_link (); +int +main () +{ +dld_link (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_dld_dld_link=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_dld_dld_link=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_dld_dld_link" >&5 +echo "${ECHO_T}$ac_cv_lib_dld_dld_link" >&6 +if test $ac_cv_lib_dld_dld_link = yes; then + lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld" +fi + + +fi + + +fi + + +fi + + +fi + + +fi + + ;; + esac + + if test "x$lt_cv_dlopen" != xno; then + enable_dlopen=yes + else + enable_dlopen=no + fi + + case $lt_cv_dlopen in + dlopen) + save_CPPFLAGS="$CPPFLAGS" + test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" + + save_LDFLAGS="$LDFLAGS" + eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" + + save_LIBS="$LIBS" + LIBS="$lt_cv_dlopen_libs $LIBS" + + echo "$as_me:$LINENO: checking whether a program can dlopen itself" >&5 +echo $ECHO_N "checking whether a program can dlopen itself... $ECHO_C" >&6 +if test "${lt_cv_dlopen_self+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$cross_compiling" = yes; then : + lt_cv_dlopen_self=cross +else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext < +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LT_DLGLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LT_DLGLOBAL DL_GLOBAL +# else +# define LT_DLGLOBAL 0 +# endif +#endif + +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LT_DLLAZY_OR_NOW +# ifdef RTLD_LAZY +# define LT_DLLAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LT_DLLAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LT_DLLAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LT_DLLAZY_OR_NOW DL_NOW +# else +# define LT_DLLAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +#ifdef __cplusplus +extern "C" void exit (int); +#endif + +void fnord() { int i=42;} +int main () +{ + void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); + int status = $lt_dlunknown; + + if (self) + { + if (dlsym (self,"fnord")) status = $lt_dlno_uscore; + else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + /* dlclose (self); */ + } + + exit (status); +} +EOF + if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then + (./conftest; exit; ) 2>/dev/null + lt_status=$? + case x$lt_status in + x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; + x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; + x$lt_unknown|x*) lt_cv_dlopen_self=no ;; + esac + else : + # compilation failed + lt_cv_dlopen_self=no + fi +fi +rm -fr conftest* + + +fi +echo "$as_me:$LINENO: result: $lt_cv_dlopen_self" >&5 +echo "${ECHO_T}$lt_cv_dlopen_self" >&6 + + if test "x$lt_cv_dlopen_self" = xyes; then + LDFLAGS="$LDFLAGS $link_static_flag" + echo "$as_me:$LINENO: checking whether a statically linked program can dlopen itself" >&5 +echo $ECHO_N "checking whether a statically linked program can dlopen itself... $ECHO_C" >&6 +if test "${lt_cv_dlopen_self_static+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$cross_compiling" = yes; then : + lt_cv_dlopen_self_static=cross +else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext < +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LT_DLGLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LT_DLGLOBAL DL_GLOBAL +# else +# define LT_DLGLOBAL 0 +# endif +#endif + +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LT_DLLAZY_OR_NOW +# ifdef RTLD_LAZY +# define LT_DLLAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LT_DLLAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LT_DLLAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LT_DLLAZY_OR_NOW DL_NOW +# else +# define LT_DLLAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +#ifdef __cplusplus +extern "C" void exit (int); +#endif + +void fnord() { int i=42;} +int main () +{ + void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); + int status = $lt_dlunknown; + + if (self) + { + if (dlsym (self,"fnord")) status = $lt_dlno_uscore; + else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + /* dlclose (self); */ + } + + exit (status); +} +EOF + if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then + (./conftest; exit; ) 2>/dev/null + lt_status=$? + case x$lt_status in + x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; + x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; + x$lt_unknown|x*) lt_cv_dlopen_self_static=no ;; + esac + else : + # compilation failed + lt_cv_dlopen_self_static=no + fi +fi +rm -fr conftest* + + +fi +echo "$as_me:$LINENO: result: $lt_cv_dlopen_self_static" >&5 +echo "${ECHO_T}$lt_cv_dlopen_self_static" >&6 + fi + + CPPFLAGS="$save_CPPFLAGS" + LDFLAGS="$save_LDFLAGS" + LIBS="$save_LIBS" + ;; + esac + + case $lt_cv_dlopen_self in + yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; + *) enable_dlopen_self=unknown ;; + esac + + case $lt_cv_dlopen_self_static in + yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; + *) enable_dlopen_self_static=unknown ;; + esac +fi + + +# Report which librarie types wil actually be built +echo "$as_me:$LINENO: checking if libtool supports shared libraries" >&5 +echo $ECHO_N "checking if libtool supports shared libraries... $ECHO_C" >&6 +echo "$as_me:$LINENO: result: $can_build_shared" >&5 +echo "${ECHO_T}$can_build_shared" >&6 + +echo "$as_me:$LINENO: checking whether to build shared libraries" >&5 +echo $ECHO_N "checking whether to build shared libraries... $ECHO_C" >&6 +test "$can_build_shared" = "no" && enable_shared=no + +# On AIX, shared libraries and static libraries use the same namespace, and +# are all built from PIC. +case "$host_os" in +aix3*) + test "$enable_shared" = yes && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + +aix4* | aix5*) + if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then + test "$enable_shared" = yes && enable_static=no + fi + ;; + darwin* | rhapsody*) + if test "$GCC" = yes; then + archive_cmds_need_lc=no + case "$host_os" in + rhapsody* | darwin1.[012]) + allow_undefined_flag='-undefined suppress' + ;; + *) # Darwin 1.3 on + if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then + allow_undefined_flag='-flat_namespace -undefined suppress' + else + case ${MACOSX_DEPLOYMENT_TARGET} in + 10.[012]) + allow_undefined_flag='-flat_namespace -undefined suppress' + ;; + 10.*) + allow_undefined_flag='-undefined dynamic_lookup' + ;; + esac + fi + ;; + esac + output_verbose_link_cmd='echo' + archive_cmds='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs$compiler_flags -install_name $rpath/$soname $verstring' + module_cmds='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' + # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's + archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs$compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + module_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + hardcode_direct=no + hardcode_automatic=yes + hardcode_shlibpath_var=unsupported + whole_archive_flag_spec='-all_load $convenience' + link_all_deplibs=yes + else + ld_shlibs=no + fi + ;; +esac +echo "$as_me:$LINENO: result: $enable_shared" >&5 +echo "${ECHO_T}$enable_shared" >&6 + +echo "$as_me:$LINENO: checking whether to build static libraries" >&5 +echo $ECHO_N "checking whether to build static libraries... $ECHO_C" >&6 +# Make sure either enable_shared or enable_static is yes. +test "$enable_shared" = yes || enable_static=yes +echo "$as_me:$LINENO: result: $enable_static" >&5 +echo "${ECHO_T}$enable_static" >&6 + +# The else clause should only fire when bootstrapping the +# libtool distribution, otherwise you forgot to ship ltmain.sh +# with your package, and you will get complaints that there are +# no rules to generate ltmain.sh. +if test -f "$ltmain"; then + # See if we are running on zsh, and set the options which allow our commands through + # without removal of \ escapes. + if test -n "${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST + fi + # Now quote all the things that may contain metacharacters while being + # careful not to overquote the AC_SUBSTed values. We take copies of the + # variables and quote the copies for generation of the libtool script. + for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC NM \ + SED SHELL STRIP \ + libname_spec library_names_spec soname_spec extract_expsyms_cmds \ + old_striplib striplib file_magic_cmd finish_cmds finish_eval \ + deplibs_check_method reload_flag reload_cmds need_locks \ + lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \ + lt_cv_sys_global_symbol_to_c_name_address \ + sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ + old_postinstall_cmds old_postuninstall_cmds \ + compiler \ + CC \ + LD \ + lt_prog_compiler_wl \ + lt_prog_compiler_pic \ + lt_prog_compiler_static \ + lt_prog_compiler_no_builtin_flag \ + export_dynamic_flag_spec \ + thread_safe_flag_spec \ + whole_archive_flag_spec \ + enable_shared_with_static_runtimes \ + old_archive_cmds \ + old_archive_from_new_cmds \ + predep_objects \ + postdep_objects \ + predeps \ + postdeps \ + compiler_lib_search_path \ + archive_cmds \ + archive_expsym_cmds \ + postinstall_cmds \ + postuninstall_cmds \ + old_archive_from_expsyms_cmds \ + allow_undefined_flag \ + no_undefined_flag \ + export_symbols_cmds \ + hardcode_libdir_flag_spec \ + hardcode_libdir_flag_spec_ld \ + hardcode_libdir_separator \ + hardcode_automatic \ + module_cmds \ + module_expsym_cmds \ + lt_cv_prog_compiler_c_o \ + exclude_expsyms \ + include_expsyms; do + + case $var in + old_archive_cmds | \ + old_archive_from_new_cmds | \ + archive_cmds | \ + archive_expsym_cmds | \ + module_cmds | \ + module_expsym_cmds | \ + old_archive_from_expsyms_cmds | \ + export_symbols_cmds | \ + extract_expsyms_cmds | reload_cmds | finish_cmds | \ + postinstall_cmds | postuninstall_cmds | \ + old_postinstall_cmds | old_postuninstall_cmds | \ + sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) + # Double-quote double-evaled strings. + eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" + ;; + *) + eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" + ;; + esac + done + + case $lt_echo in + *'\$0 --fallback-echo"') + lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'` + ;; + esac + +cfgfile="${ofile}T" + trap "$rm \"$cfgfile\"; exit 1" 1 2 15 + $rm -f "$cfgfile" + { echo "$as_me:$LINENO: creating $ofile" >&5 +echo "$as_me: creating $ofile" >&6;} + + cat <<__EOF__ >> "$cfgfile" +#! $SHELL + +# `$echo "$cfgfile" | sed 's%^.*/%%'` - Provide generalized library-building support services. +# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP) +# NOTE: Changes made to this file will be lost: look at ltmain.sh. +# +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 +# Free Software Foundation, Inc. +# +# This file is part of GNU Libtool: +# Originally by Gordon Matzigkeit , 1996 +# +# 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. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# A sed program that does not truncate output. +SED=$lt_SED + +# Sed that helps us avoid accidentally triggering echo(1) options like -n. +Xsed="$SED -e s/^X//" + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +if test "X\${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi + +# The names of the tagged configurations supported by this script. +available_tags= + +# ### BEGIN LIBTOOL CONFIG + +# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: + +# Shell to use when invoking shell scripts. +SHELL=$lt_SHELL + +# Whether or not to build shared libraries. +build_libtool_libs=$enable_shared + +# Whether or not to build static libraries. +build_old_libs=$enable_static + +# Whether or not to add -lc for building shared libraries. +build_libtool_need_lc=$archive_cmds_need_lc + +# Whether or not to disallow shared libs when runtime libs are static +allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes + +# Whether or not to optimize for fast installation. +fast_install=$enable_fast_install + +# The host system. +host_alias=$host_alias +host=$host + +# An echo program that does not interpret backslashes. +echo=$lt_echo + +# The archiver. +AR=$lt_AR +AR_FLAGS=$lt_AR_FLAGS + +# A C compiler. +LTCC=$lt_LTCC + +# A language-specific compiler. +CC=$lt_compiler + +# Is the compiler the GNU C compiler? +with_gcc=$GCC + +# An ERE matcher. +EGREP=$lt_EGREP + +# The linker used to build libraries. +LD=$lt_LD + +# Whether we need hard or soft links. +LN_S=$lt_LN_S + +# A BSD-compatible nm program. +NM=$lt_NM + +# A symbol stripping program +STRIP=$lt_STRIP + +# Used to examine libraries when file_magic_cmd begins "file" +MAGIC_CMD=$MAGIC_CMD + +# Used on cygwin: DLL creation program. +DLLTOOL="$DLLTOOL" + +# Used on cygwin: object dumper. +OBJDUMP="$OBJDUMP" + +# Used on cygwin: assembler. +AS="$AS" + +# The name of the directory that contains temporary libtool files. +objdir=$objdir + +# How to create reloadable object files. +reload_flag=$lt_reload_flag +reload_cmds=$lt_reload_cmds + +# How to pass a linker flag through the compiler. +wl=$lt_lt_prog_compiler_wl + +# Object file suffix (normally "o"). +objext="$ac_objext" + +# Old archive suffix (normally "a"). +libext="$libext" + +# Shared library suffix (normally ".so"). +shrext_cmds='$shrext_cmds' + +# Executable file suffix (normally ""). +exeext="$exeext" + +# Additional compiler flags for building library objects. +pic_flag=$lt_lt_prog_compiler_pic +pic_mode=$pic_mode + +# What is the maximum length of a command? +max_cmd_len=$lt_cv_sys_max_cmd_len + +# Does compiler simultaneously support -c and -o options? +compiler_c_o=$lt_lt_cv_prog_compiler_c_o + +# Must we lock files when doing compilation ? +need_locks=$lt_need_locks + +# Do we need the lib prefix for modules? +need_lib_prefix=$need_lib_prefix + +# Do we need a version for libraries? +need_version=$need_version + +# Whether dlopen is supported. +dlopen_support=$enable_dlopen + +# Whether dlopen of programs is supported. +dlopen_self=$enable_dlopen_self + +# Whether dlopen of statically linked programs is supported. +dlopen_self_static=$enable_dlopen_self_static + +# Compiler flag to prevent dynamic linking. +link_static_flag=$lt_lt_prog_compiler_static + +# Compiler flag to turn off builtin functions. +no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag + +# Compiler flag to allow reflexive dlopens. +export_dynamic_flag_spec=$lt_export_dynamic_flag_spec + +# Compiler flag to generate shared objects directly from archives. +whole_archive_flag_spec=$lt_whole_archive_flag_spec + +# Compiler flag to generate thread-safe objects. +thread_safe_flag_spec=$lt_thread_safe_flag_spec + +# Library versioning type. +version_type=$version_type + +# Format of library name prefix. +libname_spec=$lt_libname_spec + +# List of archive names. First name is the real one, the rest are links. +# The last name is the one that the linker finds with -lNAME. +library_names_spec=$lt_library_names_spec + +# The coded name of the library, if different from the real name. +soname_spec=$lt_soname_spec + +# Commands used to build and install an old-style archive. +RANLIB=$lt_RANLIB +old_archive_cmds=$lt_old_archive_cmds +old_postinstall_cmds=$lt_old_postinstall_cmds +old_postuninstall_cmds=$lt_old_postuninstall_cmds + +# Create an old-style archive from a shared archive. +old_archive_from_new_cmds=$lt_old_archive_from_new_cmds + +# Create a temporary old-style archive to link instead of a shared archive. +old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds + +# Commands used to build and install a shared archive. +archive_cmds=$lt_archive_cmds +archive_expsym_cmds=$lt_archive_expsym_cmds +postinstall_cmds=$lt_postinstall_cmds +postuninstall_cmds=$lt_postuninstall_cmds + +# Commands used to build a loadable module (assumed same as above if empty) +module_cmds=$lt_module_cmds +module_expsym_cmds=$lt_module_expsym_cmds + +# Commands to strip libraries. +old_striplib=$lt_old_striplib +striplib=$lt_striplib + +# Dependencies to place before the objects being linked to create a +# shared library. +predep_objects=$lt_predep_objects + +# Dependencies to place after the objects being linked to create a +# shared library. +postdep_objects=$lt_postdep_objects + +# Dependencies to place before the objects being linked to create a +# shared library. +predeps=$lt_predeps + +# Dependencies to place after the objects being linked to create a +# shared library. +postdeps=$lt_postdeps + +# The library search path used internally by the compiler when linking +# a shared library. +compiler_lib_search_path=$lt_compiler_lib_search_path + +# Method to check whether dependent libraries are shared objects. +deplibs_check_method=$lt_deplibs_check_method + +# Command to use when deplibs_check_method == file_magic. +file_magic_cmd=$lt_file_magic_cmd + +# Flag that allows shared libraries with undefined symbols to be built. +allow_undefined_flag=$lt_allow_undefined_flag + +# Flag that forces no undefined symbols. +no_undefined_flag=$lt_no_undefined_flag + +# Commands used to finish a libtool library installation in a directory. +finish_cmds=$lt_finish_cmds + +# Same as above, but a single script fragment to be evaled but not shown. +finish_eval=$lt_finish_eval + +# Take the output of nm and produce a listing of raw symbols and C names. +global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe + +# Transform the output of nm in a proper C declaration +global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl + +# Transform the output of nm in a C name address pair +global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address + +# This is the shared library runtime path variable. +runpath_var=$runpath_var + +# This is the shared library path variable. +shlibpath_var=$shlibpath_var + +# Is shlibpath searched before the hard-coded library search path? +shlibpath_overrides_runpath=$shlibpath_overrides_runpath + +# How to hardcode a shared library path into an executable. +hardcode_action=$hardcode_action + +# Whether we should hardcode library paths into libraries. +hardcode_into_libs=$hardcode_into_libs + +# Flag to hardcode \$libdir into a binary during linking. +# This must work even if \$libdir does not exist. +hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec + +# If ld is used when linking, flag to hardcode \$libdir into +# a binary during linking. This must work even if \$libdir does +# not exist. +hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld + +# Whether we need a single -rpath flag with a separated argument. +hardcode_libdir_separator=$lt_hardcode_libdir_separator + +# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the +# resulting binary. +hardcode_direct=$hardcode_direct + +# Set to yes if using the -LDIR flag during linking hardcodes DIR into the +# resulting binary. +hardcode_minus_L=$hardcode_minus_L + +# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into +# the resulting binary. +hardcode_shlibpath_var=$hardcode_shlibpath_var + +# Set to yes if building a shared library automatically hardcodes DIR into the library +# and all subsequent libraries and executables linked against it. +hardcode_automatic=$hardcode_automatic + +# Variables whose values should be saved in libtool wrapper scripts and +# restored at relink time. +variables_saved_for_relink="$variables_saved_for_relink" + +# Whether libtool must link a program against all its dependency libraries. +link_all_deplibs=$link_all_deplibs + +# Compile-time system search path for libraries +sys_lib_search_path_spec=$lt_sys_lib_search_path_spec + +# Run-time system search path for libraries +sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec + +# Fix the shell variable \$srcfile for the compiler. +fix_srcfile_path="$fix_srcfile_path" + +# Set to yes if exported symbols are required. +always_export_symbols=$always_export_symbols + +# The commands to list exported symbols. +export_symbols_cmds=$lt_export_symbols_cmds + +# The commands to extract the exported symbol list from a shared archive. +extract_expsyms_cmds=$lt_extract_expsyms_cmds + +# Symbols that should not be listed in the preloaded symbols. +exclude_expsyms=$lt_exclude_expsyms + +# Symbols that must always be exported. +include_expsyms=$lt_include_expsyms + +# ### END LIBTOOL CONFIG + +__EOF__ + + + case $host_os in + aix3*) + cat <<\EOF >> "$cfgfile" + +# AIX sometimes has problems with the GCC collect2 program. For some +# reason, if we set the COLLECT_NAMES environment variable, the problems +# vanish in a puff of smoke. +if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES +fi +EOF + ;; + esac + + # We use sed instead of cat because bash on DJGPP gets confused if + # if finds mixed CR/LF and LF-only lines. Since sed operates in + # text mode, it properly converts lines to CR/LF. This bash problem + # is reportedly fixed, but why not run on old versions too? + sed '$q' "$ltmain" >> "$cfgfile" || (rm -f "$cfgfile"; exit 1) + + mv -f "$cfgfile" "$ofile" || \ + (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") + chmod +x "$ofile" + +else + # If there is no Makefile yet, we rely on a make rule to execute + # `config.status --recheck' to rerun these tests and create the + # libtool script then. + ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'` + if test -f "$ltmain_in"; then + test -f Makefile && make "$ltmain" + fi +fi + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +CC="$lt_save_CC" + + +# Check whether --with-tags or --without-tags was given. +if test "${with_tags+set}" = set; then + withval="$with_tags" + tagnames="$withval" +fi; + +if test -f "$ltmain" && test -n "$tagnames"; then + if test ! -f "${ofile}"; then + { echo "$as_me:$LINENO: WARNING: output file \`$ofile' does not exist" >&5 +echo "$as_me: WARNING: output file \`$ofile' does not exist" >&2;} + fi + + if test -z "$LTCC"; then + eval "`$SHELL ${ofile} --config | grep '^LTCC='`" + if test -z "$LTCC"; then + { echo "$as_me:$LINENO: WARNING: output file \`$ofile' does not look like a libtool script" >&5 +echo "$as_me: WARNING: output file \`$ofile' does not look like a libtool script" >&2;} + else + { echo "$as_me:$LINENO: WARNING: using \`LTCC=$LTCC', extracted from \`$ofile'" >&5 +echo "$as_me: WARNING: using \`LTCC=$LTCC', extracted from \`$ofile'" >&2;} + fi + fi + + # Extract list of available tagged configurations in $ofile. + # Note that this assumes the entire list is on one line. + available_tags=`grep "^available_tags=" "${ofile}" | $SED -e 's/available_tags=\(.*$\)/\1/' -e 's/\"//g'` + + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for tagname in $tagnames; do + IFS="$lt_save_ifs" + # Check whether tagname contains only valid characters + case `$echo "X$tagname" | $Xsed -e 's:[-_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,/]::g'` in + "") ;; + *) { { echo "$as_me:$LINENO: error: invalid tag name: $tagname" >&5 +echo "$as_me: error: invalid tag name: $tagname" >&2;} + { (exit 1); exit 1; }; } + ;; + esac + + if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "${ofile}" > /dev/null + then + { { echo "$as_me:$LINENO: error: tag name \"$tagname\" already exists" >&5 +echo "$as_me: error: tag name \"$tagname\" already exists" >&2;} + { (exit 1); exit 1; }; } + fi + + # Update the list of available tags. + if test -n "$tagname"; then + echo appending configuration tag \"$tagname\" to $ofile + + case $tagname in + CXX) + if test -n "$CXX" && test "X$CXX" != "Xno"; then + ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + + + +archive_cmds_need_lc_CXX=no +allow_undefined_flag_CXX= +always_export_symbols_CXX=no +archive_expsym_cmds_CXX= +export_dynamic_flag_spec_CXX= +hardcode_direct_CXX=no +hardcode_libdir_flag_spec_CXX= +hardcode_libdir_flag_spec_ld_CXX= +hardcode_libdir_separator_CXX= +hardcode_minus_L_CXX=no +hardcode_automatic_CXX=no +module_cmds_CXX= +module_expsym_cmds_CXX= +link_all_deplibs_CXX=unknown +old_archive_cmds_CXX=$old_archive_cmds +no_undefined_flag_CXX= +whole_archive_flag_spec_CXX= +enable_shared_with_static_runtimes_CXX=no + +# Dependencies to place before and after the object being linked: +predep_objects_CXX= +postdep_objects_CXX= +predeps_CXX= +postdeps_CXX= +compiler_lib_search_path_CXX= + +# Source file extension for C++ test sources. +ac_ext=cc + +# Object file extension for compiled C++ test sources. +objext=o +objext_CXX=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="int some_variable = 0;\n" + +# Code to be used in simple link tests +lt_simple_link_test_code='int main(int, char *) { return(0); }\n' + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# Allow CC to be a program name with arguments. +compiler=$CC + + +# Allow CC to be a program name with arguments. +lt_save_CC=$CC +lt_save_LD=$LD +lt_save_GCC=$GCC +GCC=$GXX +lt_save_with_gnu_ld=$with_gnu_ld +lt_save_path_LD=$lt_cv_path_LD +if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then + lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx +else + unset lt_cv_prog_gnu_ld +fi +if test -n "${lt_cv_path_LDCXX+set}"; then + lt_cv_path_LD=$lt_cv_path_LDCXX +else + unset lt_cv_path_LD +fi +test -z "${LDCXX+set}" || LD=$LDCXX +CC=${CXX-"c++"} +compiler=$CC +compiler_CXX=$CC +cc_basename=`$echo X"$compiler" | $Xsed -e 's%^.*/%%'` + +# We don't want -fno-exception wen compiling C++ code, so set the +# no_builtin_flag separately +if test "$GXX" = yes; then + lt_prog_compiler_no_builtin_flag_CXX=' -fno-builtin' +else + lt_prog_compiler_no_builtin_flag_CXX= +fi + +if test "$GXX" = yes; then + # Set up default GNU C++ configuration + + +# Check whether --with-gnu-ld or --without-gnu-ld was given. +if test "${with_gnu_ld+set}" = set; then + withval="$with_gnu_ld" + test "$withval" = no || with_gnu_ld=yes +else + with_gnu_ld=no +fi; +ac_prog=ld +if test "$GCC" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + echo "$as_me:$LINENO: checking for ld used by $CC" >&5 +echo $ECHO_N "checking for ld used by $CC... $ECHO_C" >&6 + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return which upsets mingw + ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $ac_prog in + # Accept absolute paths. + [\\/]* | ?:[\\/]*) + re_direlt='/[^/][^/]*/\.\./' + # Canonicalize the pathname of ld + ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'` + while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do + ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + echo "$as_me:$LINENO: checking for GNU ld" >&5 +echo $ECHO_N "checking for GNU ld... $ECHO_C" >&6 +else + echo "$as_me:$LINENO: checking for non-GNU ld" >&5 +echo $ECHO_N "checking for non-GNU ld... $ECHO_C" >&6 +fi +if test "${lt_cv_path_LD+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -z "$LD"; then + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + lt_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some GNU ld's only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + case `"$lt_cv_path_LD" -v 2>&1 &5 +echo "${ECHO_T}$LD" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi +test -z "$LD" && { { echo "$as_me:$LINENO: error: no acceptable ld found in \$PATH" >&5 +echo "$as_me: error: no acceptable ld found in \$PATH" >&2;} + { (exit 1); exit 1; }; } +echo "$as_me:$LINENO: checking if the linker ($LD) is GNU ld" >&5 +echo $ECHO_N "checking if the linker ($LD) is GNU ld... $ECHO_C" >&6 +if test "${lt_cv_prog_gnu_ld+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # I'd rather use --version here, but apparently some GNU ld's only accept -v. +case `$LD -v 2>&1 &5 +echo "${ECHO_T}$lt_cv_prog_gnu_ld" >&6 +with_gnu_ld=$lt_cv_prog_gnu_ld + + + + # Check if GNU C++ uses GNU ld as the underlying linker, since the + # archiving commands below assume that GNU ld is being used. + if test "$with_gnu_ld" = yes; then + archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + + hardcode_libdir_flag_spec_CXX='${wl}--rpath ${wl}$libdir' + export_dynamic_flag_spec_CXX='${wl}--export-dynamic' + + # If archive_cmds runs LD, not CC, wlarc should be empty + # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to + # investigate it a little bit more. (MM) + wlarc='${wl}' + + # ancient GNU ld didn't support --whole-archive et. al. + if eval "`$CC -print-prog-name=ld` --help 2>&1" | \ + grep 'no-whole-archive' > /dev/null; then + whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + whole_archive_flag_spec_CXX= + fi + else + with_gnu_ld=no + wlarc= + + # A generic and very simple default shared library creation + # command for GNU C++ for the case where it uses the native + # linker, instead of GNU ld. If possible, this setting should + # overridden to take advantage of the native linker features on + # the platform it is being used on. + archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' + fi + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"' + +else + GXX=no + with_gnu_ld=no + wlarc= +fi + +# PORTME: fill in a description of your system's C++ link characteristics +echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5 +echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6 +ld_shlibs_CXX=yes +case $host_os in + aix3*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + aix4* | aix5*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag="" + else + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[23]|aix4.[23].*|aix5*) + for ld_flag in $LDFLAGS; do + case $ld_flag in + *-brtl*) + aix_use_runtimelinking=yes + break + ;; + esac + done + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + archive_cmds_CXX='' + hardcode_direct_CXX=yes + hardcode_libdir_separator_CXX=':' + link_all_deplibs_CXX=yes + + if test "$GXX" = yes; then + case $host_os in aix4.012|aix4.012.*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && \ + strings "$collect2name" | grep resolve_lib_name >/dev/null + then + # We have reworked collect2 + hardcode_direct_CXX=yes + else + # We have old collect2 + hardcode_direct_CXX=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + hardcode_minus_L_CXX=yes + hardcode_libdir_flag_spec_CXX='-L$libdir' + hardcode_libdir_separator_CXX= + fi + esac + shared_flag='-shared' + else + # not using gcc + if test "$host_cpu" = ia64; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test "$aix_use_runtimelinking" = yes; then + shared_flag='${wl}-G' + else + shared_flag='${wl}-bM:SRE' + fi + fi + fi + + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to export. + always_export_symbols_CXX=yes + if test "$aix_use_runtimelinking" = yes; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + allow_undefined_flag_CXX='-berok' + # Determine the default libpath from the value encoded in an empty executable. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'`; fi +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi + + hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath" + + archive_expsym_cmds_CXX="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag" + else + if test "$host_cpu" = ia64; then + hardcode_libdir_flag_spec_CXX='${wl}-R $libdir:/usr/lib:/lib' + allow_undefined_flag_CXX="-z nodefs" + archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an empty executable. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'`; fi +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi + + hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + no_undefined_flag_CXX=' ${wl}-bernotok' + allow_undefined_flag_CXX=' ${wl}-berok' + # -bexpall does not export symbols beginning with underscore (_) + always_export_symbols_CXX=yes + # Exported symbols can be pulled into shared objects from archives + whole_archive_flag_spec_CXX=' ' + archive_cmds_need_lc_CXX=yes + # This is similar to how AIX traditionally builds it's shared libraries. + archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' + fi + fi + ;; + chorus*) + case $cc_basename in + *) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + esac + ;; + + cygwin* | mingw* | pw32*) + # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, CXX) is actually meaningless, + # as there is no search path for DLLs. + hardcode_libdir_flag_spec_CXX='-L$libdir' + allow_undefined_flag_CXX=unsupported + always_export_symbols_CXX=no + enable_shared_with_static_runtimes_CXX=yes + + if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then + archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib' + # If the export-symbols file already is a .def file (1st line + # is EXPORTS), use it as is; otherwise, prepend... + archive_expsym_cmds_CXX='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib' + else + ld_shlibs_CXX=no + fi + ;; + + darwin* | rhapsody*) + if test "$GXX" = yes; then + archive_cmds_need_lc_CXX=no + case "$host_os" in + rhapsody* | darwin1.[012]) + allow_undefined_flag_CXX='-undefined suppress' + ;; + *) # Darwin 1.3 on + if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then + allow_undefined_flag_CXX='-flat_namespace -undefined suppress' + else + case ${MACOSX_DEPLOYMENT_TARGET} in + 10.[012]) + allow_undefined_flag_CXX='-flat_namespace -undefined suppress' + ;; + 10.*) + allow_undefined_flag_CXX='-undefined dynamic_lookup' + ;; + esac + fi + ;; + esac + lt_int_apple_cc_single_mod=no + output_verbose_link_cmd='echo' + if $CC -dumpspecs 2>&1 | grep 'single_module' >/dev/null ; then + lt_int_apple_cc_single_mod=yes + fi + if test "X$lt_int_apple_cc_single_mod" = Xyes ; then + archive_cmds_CXX='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring' + else + archive_cmds_CXX='$CC -r ${wl}-bind_at_load -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring' + fi + module_cmds_CXX='$CC ${wl}-bind_at_load $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' + + # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's + if test "X$lt_int_apple_cc_single_mod" = Xyes ; then + archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + else + archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r ${wl}-bind_at_load -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + fi + module_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + hardcode_direct_CXX=no + hardcode_automatic_CXX=yes + hardcode_shlibpath_var_CXX=unsupported + whole_archive_flag_spec_CXX='-all_load $convenience' + link_all_deplibs_CXX=yes + else + ld_shlibs_CXX=no + fi + ;; + + dgux*) + case $cc_basename in + ec++) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + ghcx) + # Green Hills C++ Compiler + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + *) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + esac + ;; + freebsd12*) + # C++ shared libraries reported to be fairly broken before switch to ELF + ld_shlibs_CXX=no + ;; + freebsd-elf*) + archive_cmds_need_lc_CXX=no + ;; + freebsd* | kfreebsd*-gnu) + # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF + # conventions + ld_shlibs_CXX=yes + ;; + gnu*) + ;; + hpux9*) + hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir' + hardcode_libdir_separator_CXX=: + export_dynamic_flag_spec_CXX='${wl}-E' + hardcode_direct_CXX=yes + hardcode_minus_L_CXX=yes # Not in the search PATH, + # but as the default + # location of the library. + + case $cc_basename in + CC) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + aCC) + archive_cmds_CXX='$rm $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + *) + if test "$GXX" = yes; then + archive_cmds_CXX='$rm $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + else + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + fi + ;; + esac + ;; + hpux10*|hpux11*) + if test $with_gnu_ld = no; then + case "$host_cpu" in + hppa*64*) + hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir' + hardcode_libdir_flag_spec_ld_CXX='+b $libdir' + hardcode_libdir_separator_CXX=: + ;; + ia64*) + hardcode_libdir_flag_spec_CXX='-L$libdir' + ;; + *) + hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir' + hardcode_libdir_separator_CXX=: + export_dynamic_flag_spec_CXX='${wl}-E' + ;; + esac + fi + case "$host_cpu" in + hppa*64*) + hardcode_direct_CXX=no + hardcode_shlibpath_var_CXX=no + ;; + ia64*) + hardcode_direct_CXX=no + hardcode_shlibpath_var_CXX=no + hardcode_minus_L_CXX=yes # Not in the search PATH, + # but as the default + # location of the library. + ;; + *) + hardcode_direct_CXX=yes + hardcode_minus_L_CXX=yes # Not in the search PATH, + # but as the default + # location of the library. + ;; + esac + + case $cc_basename in + CC) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + aCC) + case "$host_cpu" in + hppa*64*|ia64*) + archive_cmds_CXX='$LD -b +h $soname -o $lib $linker_flags $libobjs $deplibs' + ;; + *) + archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + esac + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + *) + if test "$GXX" = yes; then + if test $with_gnu_ld = no; then + case "$host_cpu" in + ia64*|hppa*64*) + archive_cmds_CXX='$LD -b +h $soname -o $lib $linker_flags $libobjs $deplibs' + ;; + *) + archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + esac + fi + else + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + fi + ;; + esac + ;; + irix5* | irix6*) + case $cc_basename in + CC) + # SGI C++ + archive_cmds_CXX='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib' + + # Archives containing C++ object files must be created using + # "CC -ar", where "CC" is the IRIX C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + old_archive_cmds_CXX='$CC -ar -WR,-u -o $oldlib $oldobjs' + ;; + *) + if test "$GXX" = yes; then + if test "$with_gnu_ld" = no; then + archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib' + else + archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` -o $lib' + fi + fi + link_all_deplibs_CXX=yes + ;; + esac + hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator_CXX=: + ;; + linux*) + case $cc_basename in + KCC) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + archive_expsym_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | grep "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + + hardcode_libdir_flag_spec_CXX='${wl}--rpath,$libdir' + export_dynamic_flag_spec_CXX='${wl}--export-dynamic' + + # Archives containing C++ object files must be created using + # "CC -Bstatic", where "CC" is the KAI C++ compiler. + old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs' + ;; + icpc) + # Intel C++ + with_gnu_ld=yes + archive_cmds_need_lc_CXX=no + archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' + export_dynamic_flag_spec_CXX='${wl}--export-dynamic' + whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive' + ;; + cxx) + # Compaq C++ + archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' + + runpath_var=LD_RUN_PATH + hardcode_libdir_flag_spec_CXX='-rpath $libdir' + hardcode_libdir_separator_CXX=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + esac + ;; + lynxos*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + m88k*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + mvs*) + case $cc_basename in + cxx) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + *) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + esac + ;; + netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + archive_cmds_CXX='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' + wlarc= + hardcode_libdir_flag_spec_CXX='-R$libdir' + hardcode_direct_CXX=yes + hardcode_shlibpath_var_CXX=no + fi + # Workaround some broken pre-1.5 toolchains + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' + ;; + osf3*) + case $cc_basename in + KCC) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + + hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' + hardcode_libdir_separator_CXX=: + + # Archives containing C++ object files must be created using + # "CC -Bstatic", where "CC" is the KAI C++ compiler. + old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs' + + ;; + RCC) + # Rational C++ 2.4.1 + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + cxx) + allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${objdir}/so_locations -o $lib' + + hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator_CXX=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + *) + if test "$GXX" = yes && test "$with_gnu_ld" = no; then + allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib' + + hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator_CXX=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"' + + else + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + fi + ;; + esac + ;; + osf4* | osf5*) + case $cc_basename in + KCC) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + + hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' + hardcode_libdir_separator_CXX=: + + # Archives containing C++ object files must be created using + # the KAI C++ compiler. + old_archive_cmds_CXX='$CC -o $oldlib $oldobjs' + ;; + RCC) + # Rational C++ 2.4.1 + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + cxx) + allow_undefined_flag_CXX=' -expect_unresolved \*' + archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib' + archive_expsym_cmds_CXX='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ + echo "-hidden">> $lib.exp~ + $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname -Wl,-input -Wl,$lib.exp `test -n "$verstring" && echo -set_version $verstring` -update_registry $objdir/so_locations -o $lib~ + $rm $lib.exp' + + hardcode_libdir_flag_spec_CXX='-rpath $libdir' + hardcode_libdir_separator_CXX=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + *) + if test "$GXX" = yes && test "$with_gnu_ld" = no; then + allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib' + + hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator_CXX=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"' + + else + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + fi + ;; + esac + ;; + psos*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + sco*) + archive_cmds_need_lc_CXX=no + case $cc_basename in + CC) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + *) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + esac + ;; + sunos4*) + case $cc_basename in + CC) + # Sun C++ 4.x + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + lcc) + # Lucid + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + *) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + esac + ;; + solaris*) + case $cc_basename in + CC) + # Sun C++ 4.2, 5.x and Centerline C++ + no_undefined_flag_CXX=' -zdefs' + archive_cmds_CXX='$CC -G${allow_undefined_flag} -nolib -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + archive_expsym_cmds_CXX='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $CC -G${allow_undefined_flag} -nolib ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' + + hardcode_libdir_flag_spec_CXX='-R$libdir' + hardcode_shlibpath_var_CXX=no + case $host_os in + solaris2.0-5 | solaris2.0-5.*) ;; + *) + # The C++ compiler is used as linker so we must use $wl + # flag to pass the commands to the underlying system + # linker. + # Supported since Solaris 2.6 (maybe 2.5.1?) + whole_archive_flag_spec_CXX='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' + ;; + esac + link_all_deplibs_CXX=yes + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -G $CFLAGS -v conftest.$objext 2>&1 | grep "\-[LR]"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + + # Archives containing C++ object files must be created using + # "CC -xar", where "CC" is the Sun C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs' + ;; + gcx) + # Green Hills C++ Compiler + archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + + # The C++ compiler must be used to create the archive. + old_archive_cmds_CXX='$CC $LDFLAGS -archive -o $oldlib $oldobjs' + ;; + *) + # GNU C++ compiler with Solaris linker + if test "$GXX" = yes && test "$with_gnu_ld" = no; then + no_undefined_flag_CXX=' ${wl}-z ${wl}defs' + if $CC --version | grep -v '^2\.7' > /dev/null; then + archive_cmds_CXX='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + archive_expsym_cmds_CXX='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd="$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\"" + else + # g++ 2.7 appears to require `-G' NOT `-shared' on this + # platform. + archive_cmds_CXX='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + archive_expsym_cmds_CXX='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd="$CC -G $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\"" + fi + + hardcode_libdir_flag_spec_CXX='${wl}-R $wl$libdir' + fi + ;; + esac + ;; + sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[78]* | unixware7*) + archive_cmds_need_lc_CXX=no + ;; + tandem*) + case $cc_basename in + NCC) + # NonStop-UX NCC 3.20 + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + *) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + esac + ;; + vxworks*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + *) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; +esac +echo "$as_me:$LINENO: result: $ld_shlibs_CXX" >&5 +echo "${ECHO_T}$ld_shlibs_CXX" >&6 +test "$ld_shlibs_CXX" = no && can_build_shared=no + +GCC_CXX="$GXX" +LD_CXX="$LD" + + +cat > conftest.$ac_ext <&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # Parse the compiler output and extract the necessary + # objects, libraries and library flags. + + # Sentinel used to keep track of whether or not we are before + # the conftest object file. + pre_test_object_deps_done=no + + # The `*' in the case matches for architectures that use `case' in + # $output_verbose_cmd can trigger glob expansion during the loop + # eval without this substitution. + output_verbose_link_cmd="`$echo \"X$output_verbose_link_cmd\" | $Xsed -e \"$no_glob_subst\"`" + + for p in `eval $output_verbose_link_cmd`; do + case $p in + + -L* | -R* | -l*) + # Some compilers place space between "-{L,R}" and the path. + # Remove the space. + if test $p = "-L" \ + || test $p = "-R"; then + prev=$p + continue + else + prev= + fi + + if test "$pre_test_object_deps_done" = no; then + case $p in + -L* | -R*) + # Internal compiler library paths should come after those + # provided the user. The postdeps already come after the + # user supplied libs so there is no need to process them. + if test -z "$compiler_lib_search_path_CXX"; then + compiler_lib_search_path_CXX="${prev}${p}" + else + compiler_lib_search_path_CXX="${compiler_lib_search_path_CXX} ${prev}${p}" + fi + ;; + # The "-l" case would never come before the object being + # linked, so don't bother handling this case. + esac + else + if test -z "$postdeps_CXX"; then + postdeps_CXX="${prev}${p}" + else + postdeps_CXX="${postdeps_CXX} ${prev}${p}" + fi + fi + ;; + + *.$objext) + # This assumes that the test object file only shows up + # once in the compiler output. + if test "$p" = "conftest.$objext"; then + pre_test_object_deps_done=yes + continue + fi + + if test "$pre_test_object_deps_done" = no; then + if test -z "$predep_objects_CXX"; then + predep_objects_CXX="$p" + else + predep_objects_CXX="$predep_objects_CXX $p" + fi + else + if test -z "$postdep_objects_CXX"; then + postdep_objects_CXX="$p" + else + postdep_objects_CXX="$postdep_objects_CXX $p" + fi + fi + ;; + + *) ;; # Ignore the rest. + + esac + done + + # Clean up. + rm -f a.out a.exe +else + echo "libtool.m4: error: problem compiling CXX test program" +fi + +$rm -f confest.$objext + +case " $postdeps_CXX " in +*" -lc "*) archive_cmds_need_lc_CXX=no ;; +esac + +lt_prog_compiler_wl_CXX= +lt_prog_compiler_pic_CXX= +lt_prog_compiler_static_CXX= + +echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5 +echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6 + + # C++ specific cases for pic, static, wl, etc. + if test "$GXX" = yes; then + lt_prog_compiler_wl_CXX='-Wl,' + lt_prog_compiler_static_CXX='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static_CXX='-Bstatic' + fi + ;; + amigaos*) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the `-m68020' flag to GCC prevents building anything better, + # like `-m68040'. + lt_prog_compiler_pic_CXX='-m68020 -resident32 -malways-restore-a4' + ;; + beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + mingw* | os2* | pw32*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + lt_prog_compiler_pic_CXX='-DDLL_EXPORT' + ;; + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + lt_prog_compiler_pic_CXX='-fno-common' + ;; + *djgpp*) + # DJGPP does not support shared libraries at all + lt_prog_compiler_pic_CXX= + ;; + sysv4*MP*) + if test -d /usr/nec; then + lt_prog_compiler_pic_CXX=-Kconform_pic + fi + ;; + hpux*) + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case "$host_cpu" in + hppa*64*|ia64*) + ;; + *) + lt_prog_compiler_pic_CXX='-fPIC' + ;; + esac + ;; + *) + lt_prog_compiler_pic_CXX='-fPIC' + ;; + esac + else + case $host_os in + aix4* | aix5*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static_CXX='-Bstatic' + else + lt_prog_compiler_static_CXX='-bnso -bI:/lib/syscalls.exp' + fi + ;; + chorus*) + case $cc_basename in + cxch68) + # Green Hills C++ Compiler + # _LT_AC_TAGVAR(lt_prog_compiler_static, CXX)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" + ;; + esac + ;; + dgux*) + case $cc_basename in + ec++) + lt_prog_compiler_pic_CXX='-KPIC' + ;; + ghcx) + # Green Hills C++ Compiler + lt_prog_compiler_pic_CXX='-pic' + ;; + *) + ;; + esac + ;; + freebsd* | kfreebsd*-gnu) + # FreeBSD uses GNU C++ + ;; + hpux9* | hpux10* | hpux11*) + case $cc_basename in + CC) + lt_prog_compiler_wl_CXX='-Wl,' + lt_prog_compiler_static_CXX="${ac_cv_prog_cc_wl}-a ${ac_cv_prog_cc_wl}archive" + if test "$host_cpu" != ia64; then + lt_prog_compiler_pic_CXX='+Z' + fi + ;; + aCC) + lt_prog_compiler_wl_CXX='-Wl,' + lt_prog_compiler_static_CXX="${ac_cv_prog_cc_wl}-a ${ac_cv_prog_cc_wl}archive" + case "$host_cpu" in + hppa*64*|ia64*) + # +Z the default + ;; + *) + lt_prog_compiler_pic_CXX='+Z' + ;; + esac + ;; + *) + ;; + esac + ;; + irix5* | irix6* | nonstopux*) + case $cc_basename in + CC) + lt_prog_compiler_wl_CXX='-Wl,' + lt_prog_compiler_static_CXX='-non_shared' + # CC pic flag -KPIC is the default. + ;; + *) + ;; + esac + ;; + linux*) + case $cc_basename in + KCC) + # KAI C++ Compiler + lt_prog_compiler_wl_CXX='--backend -Wl,' + lt_prog_compiler_pic_CXX='-fPIC' + ;; + icpc) + # Intel C++ + lt_prog_compiler_wl_CXX='-Wl,' + lt_prog_compiler_pic_CXX='-KPIC' + lt_prog_compiler_static_CXX='-static' + ;; + cxx) + # Compaq C++ + # Make sure the PIC flag is empty. It appears that all Alpha + # Linux and Compaq Tru64 Unix objects are PIC. + lt_prog_compiler_pic_CXX= + lt_prog_compiler_static_CXX='-non_shared' + ;; + *) + ;; + esac + ;; + lynxos*) + ;; + m88k*) + ;; + mvs*) + case $cc_basename in + cxx) + lt_prog_compiler_pic_CXX='-W c,exportall' + ;; + *) + ;; + esac + ;; + netbsd*) + ;; + osf3* | osf4* | osf5*) + case $cc_basename in + KCC) + lt_prog_compiler_wl_CXX='--backend -Wl,' + ;; + RCC) + # Rational C++ 2.4.1 + lt_prog_compiler_pic_CXX='-pic' + ;; + cxx) + # Digital/Compaq C++ + lt_prog_compiler_wl_CXX='-Wl,' + # Make sure the PIC flag is empty. It appears that all Alpha + # Linux and Compaq Tru64 Unix objects are PIC. + lt_prog_compiler_pic_CXX= + lt_prog_compiler_static_CXX='-non_shared' + ;; + *) + ;; + esac + ;; + psos*) + ;; + sco*) + case $cc_basename in + CC) + lt_prog_compiler_pic_CXX='-fPIC' + ;; + *) + ;; + esac + ;; + solaris*) + case $cc_basename in + CC) + # Sun C++ 4.2, 5.x and Centerline C++ + lt_prog_compiler_pic_CXX='-KPIC' + lt_prog_compiler_static_CXX='-Bstatic' + lt_prog_compiler_wl_CXX='-Qoption ld ' + ;; + gcx) + # Green Hills C++ Compiler + lt_prog_compiler_pic_CXX='-PIC' + ;; + *) + ;; + esac + ;; + sunos4*) + case $cc_basename in + CC) + # Sun C++ 4.x + lt_prog_compiler_pic_CXX='-pic' + lt_prog_compiler_static_CXX='-Bstatic' + ;; + lcc) + # Lucid + lt_prog_compiler_pic_CXX='-pic' + ;; + *) + ;; + esac + ;; + tandem*) + case $cc_basename in + NCC) + # NonStop-UX NCC 3.20 + lt_prog_compiler_pic_CXX='-KPIC' + ;; + *) + ;; + esac + ;; + unixware*) + ;; + vxworks*) + ;; + *) + lt_prog_compiler_can_build_shared_CXX=no + ;; + esac + fi + +echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_CXX" >&5 +echo "${ECHO_T}$lt_prog_compiler_pic_CXX" >&6 + +# +# Check to make sure the PIC flag actually works. +# +if test -n "$lt_prog_compiler_pic_CXX"; then + +echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works" >&5 +echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works... $ECHO_C" >&6 +if test "${lt_prog_compiler_pic_works_CXX+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + lt_prog_compiler_pic_works_CXX=no + ac_outfile=conftest.$ac_objext + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="$lt_prog_compiler_pic_CXX -DPIC" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:10347: $lt_compile\"" >&5) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&5 + echo "$as_me:10351: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + if test ! -s conftest.err; then + lt_prog_compiler_pic_works_CXX=yes + fi + fi + $rm conftest* + +fi +echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works_CXX" >&5 +echo "${ECHO_T}$lt_prog_compiler_pic_works_CXX" >&6 + +if test x"$lt_prog_compiler_pic_works_CXX" = xyes; then + case $lt_prog_compiler_pic_CXX in + "" | " "*) ;; + *) lt_prog_compiler_pic_CXX=" $lt_prog_compiler_pic_CXX" ;; + esac +else + lt_prog_compiler_pic_CXX= + lt_prog_compiler_can_build_shared_CXX=no +fi + +fi +case "$host_os" in + # For platforms which do not support PIC, -DPIC is meaningless: + *djgpp*) + lt_prog_compiler_pic_CXX= + ;; + *) + lt_prog_compiler_pic_CXX="$lt_prog_compiler_pic_CXX -DPIC" + ;; +esac + +echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5 +echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6 +if test "${lt_cv_prog_compiler_c_o_CXX+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + lt_cv_prog_compiler_c_o_CXX=no + $rm -r conftest 2>/dev/null + mkdir conftest + cd conftest + mkdir out + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + + lt_compiler_flag="-o out/conftest2.$ac_objext" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:10407: $lt_compile\"" >&5) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&5 + echo "$as_me:10411: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + if test ! -s out/conftest.err; then + lt_cv_prog_compiler_c_o_CXX=yes + fi + fi + chmod u+w . + $rm conftest* + # SGI C++ compiler will create directory out/ii_files/ for + # template instantiation + test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files + $rm out/* && rmdir out + cd .. + rmdir conftest + $rm conftest* + +fi +echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_CXX" >&5 +echo "${ECHO_T}$lt_cv_prog_compiler_c_o_CXX" >&6 + + +hard_links="nottested" +if test "$lt_cv_prog_compiler_c_o_CXX" = no && test "$need_locks" != no; then + # do not overwrite the value of need_locks provided by the user + echo "$as_me:$LINENO: checking if we can lock with hard links" >&5 +echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6 + hard_links=yes + $rm conftest* + ln conftest.a conftest.b 2>/dev/null && hard_links=no + touch conftest.a + ln conftest.a conftest.b 2>&5 || hard_links=no + ln conftest.a conftest.b 2>/dev/null && hard_links=no + echo "$as_me:$LINENO: result: $hard_links" >&5 +echo "${ECHO_T}$hard_links" >&6 + if test "$hard_links" = no; then + { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 +echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} + need_locks=warn + fi +else + need_locks=no +fi + +echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5 +echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6 + + export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + case $host_os in + aix4* | aix5*) + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to AIX nm, but means don't demangle with GNU nm + if $NM -V 2>&1 | grep 'GNU' > /dev/null; then + export_symbols_cmds_CXX='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' + else + export_symbols_cmds_CXX='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' + fi + ;; + pw32*) + export_symbols_cmds_CXX="$ltdll_cmds" + ;; + cygwin* | mingw*) + export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols' + ;; + *) + export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + ;; + esac + +echo "$as_me:$LINENO: result: $ld_shlibs_CXX" >&5 +echo "${ECHO_T}$ld_shlibs_CXX" >&6 +test "$ld_shlibs_CXX" = no && can_build_shared=no + +variables_saved_for_relink="PATH $shlibpath_var $runpath_var" +if test "$GCC" = yes; then + variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" +fi + +# +# Do we need to explicitly link libc? +# +case "x$archive_cmds_need_lc_CXX" in +x|xyes) + # Assume -lc should be added + archive_cmds_need_lc_CXX=yes + + if test "$enable_shared" = yes && test "$GCC" = yes; then + case $archive_cmds_CXX in + *'~'*) + # FIXME: we may have to deal with multi-command sequences. + ;; + '$CC '*) + # Test whether the compiler implicitly links with -lc since on some + # systems, -lgcc has to come before -lc. If gcc already passes -lc + # to ld, don't add -lc before -lgcc. + echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5 +echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6 + $rm conftest* + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } 2>conftest.err; then + soname=conftest + lib=conftest + libobjs=conftest.$ac_objext + deplibs= + wl=$lt_prog_compiler_wl_CXX + compiler_flags=-v + linker_flags=-v + verstring= + output_objdir=. + libname=conftest + lt_save_allow_undefined_flag=$allow_undefined_flag_CXX + allow_undefined_flag_CXX= + if { (eval echo "$as_me:$LINENO: \"$archive_cmds_CXX 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5 + (eval $archive_cmds_CXX 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + then + archive_cmds_need_lc_CXX=no + else + archive_cmds_need_lc_CXX=yes + fi + allow_undefined_flag_CXX=$lt_save_allow_undefined_flag + else + cat conftest.err 1>&5 + fi + $rm conftest* + echo "$as_me:$LINENO: result: $archive_cmds_need_lc_CXX" >&5 +echo "${ECHO_T}$archive_cmds_need_lc_CXX" >&6 + ;; + esac + fi + ;; +esac + +echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5 +echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6 +library_names_spec= +libname_spec='lib$name' +soname_spec= +shrext_cmds=".so" +postinstall_cmds= +postuninstall_cmds= +finish_cmds= +finish_eval= +shlibpath_var= +shlibpath_overrides_runpath=unknown +version_type=none +dynamic_linker="$host_os ld.so" +sys_lib_dlsearch_path_spec="/lib /usr/lib" +if test "$GCC" = yes; then + sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then + # if the path contains ";" then we assume it to be the separator + # otherwise default to the standard path separator (i.e. ":") - it is + # assumed that no part of a normal pathname contains ";" but that should + # okay in the real world where ";" in dirpaths is itself problematic. + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi +else + sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" +fi +need_lib_prefix=unknown +hardcode_into_libs=no + +# when you set need_version to no, make sure it does not cause -set_version +# flags to be left without arguments +need_version=unknown + +case $host_os in +aix3*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' + shlibpath_var=LIBPATH + + # AIX 3 has no versioning support, so we append a major version to the name. + soname_spec='${libname}${release}${shared_ext}$major' + ;; + +aix4* | aix5*) + version_type=linux + need_lib_prefix=no + need_version=no + hardcode_into_libs=yes + if test "$host_cpu" = ia64; then + # AIX 5 supports IA64 + library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + else + # With GCC up to 2.95.x, collect2 would create an import file + # for dependence libraries. The import file would start with + # the line `#! .'. This would cause the generated library to + # depend on `.', always an invalid library. This was fixed in + # development snapshots of GCC prior to 3.0. + case $host_os in + aix4 | aix4.[01] | aix4.[01].*) + if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' + echo ' yes ' + echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then + : + else + can_build_shared=no + fi + ;; + esac + # AIX (on Power*) has no versioning support, so currently we can not hardcode correct + # soname into executable. Probably we can add versioning support to + # collect2, so additional links can be useful in future. + if test "$aix_use_runtimelinking" = yes; then + # If using run time linking (on AIX 4.2 or later) use lib.so + # instead of lib.a to let people know that these are not + # typical AIX shared libraries. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + else + # We preserve .a as extension for shared libraries through AIX4.2 + # and later when we are not doing run time linking. + library_names_spec='${libname}${release}.a $libname.a' + soname_spec='${libname}${release}${shared_ext}$major' + fi + shlibpath_var=LIBPATH + fi + ;; + +amigaos*) + library_names_spec='$libname.ixlibrary $libname.a' + # Create ${libname}_ixlibrary.a entries in /sys/libs. + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' + ;; + +beos*) + library_names_spec='${libname}${shared_ext}' + dynamic_linker="$host_os ld.so" + shlibpath_var=LIBRARY_PATH + ;; + +bsdi4*) + version_type=linux + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" + sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" + # the default ld.so.conf also contains /usr/contrib/lib and + # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow + # libtool to hard-code these into programs + ;; + +cygwin* | mingw* | pw32*) + version_type=windows + shrext_cmds=".dll" + need_version=no + need_lib_prefix=no + + case $GCC,$host_os in + yes,cygwin* | yes,mingw* | yes,pw32*) + library_names_spec='$libname.dll.a' + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \${file}`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $rm \$dlpath' + shlibpath_overrides_runpath=yes + + case $host_os in + cygwin*) + # Cygwin DLLs use 'cyg' prefix rather than 'lib' + soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" + ;; + mingw*) + # MinGW DLLs use traditional 'lib' prefix + soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then + # It is most probably a Windows format PATH printed by + # mingw gcc, but we are running on Cygwin. Gcc prints its search + # path with ; separators, and with drive letters. We can handle the + # drive letters (cygwin fileutils understands them), so leave them, + # especially as we might pass files found there to a mingw objdump, + # which wouldn't understand a cygwinified path. Ahh. + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + ;; + pw32*) + # pw32 DLLs use 'pw' prefix rather than 'lib' + library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/./-/g'`${versuffix}${shared_ext}' + ;; + esac + ;; + + *) + library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' + ;; + esac + dynamic_linker='Win32 ld.exe' + # FIXME: first we should search . and the directory the executable is in + shlibpath_var=PATH + ;; + +darwin* | rhapsody*) + dynamic_linker="$host_os dyld" + version_type=darwin + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext' + soname_spec='${libname}${release}${major}$shared_ext' + shlibpath_overrides_runpath=yes + shlibpath_var=DYLD_LIBRARY_PATH + shrext_cmds='$(test .$module = .yes && echo .so || echo .dylib)' + # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same. + if test "$GCC" = yes; then + sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"` + else + sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib' + fi + sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' + ;; + +dgux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +freebsd1*) + dynamic_linker=no + ;; + +kfreebsd*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='GNU ld.so' + ;; + +freebsd*) + objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout` + version_type=freebsd-$objformat + case $version_type in + freebsd-elf*) + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + need_version=no + need_lib_prefix=no + ;; + freebsd-*) + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' + need_version=yes + ;; + esac + shlibpath_var=LD_LIBRARY_PATH + case $host_os in + freebsd2*) + shlibpath_overrides_runpath=yes + ;; + freebsd3.01* | freebsdelf3.01*) + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + *) # from 3.2 on + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + esac + ;; + +gnu*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + hardcode_into_libs=yes + ;; + +hpux9* | hpux10* | hpux11*) + # Give a soname corresponding to the major version so that dld.sl refuses to + # link against other versions. + version_type=sunos + need_lib_prefix=no + need_version=no + case "$host_cpu" in + ia64*) + shrext_cmds='.so' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.so" + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + if test "X$HPUX_IA64_MODE" = X32; then + sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" + else + sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" + fi + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + hppa*64*) + shrext_cmds='.sl' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.sl" + shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + *) + shrext_cmds='.sl' + dynamic_linker="$host_os dld.sl" + shlibpath_var=SHLIB_PATH + shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + ;; + esac + # HP-UX runs *really* slowly unless shared libraries are mode 555. + postinstall_cmds='chmod 555 $lib' + ;; + +irix5* | irix6* | nonstopux*) + case $host_os in + nonstopux*) version_type=nonstopux ;; + *) + if test "$lt_cv_prog_gnu_ld" = yes; then + version_type=linux + else + version_type=irix + fi ;; + esac + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' + case $host_os in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in # libtool.m4 will add one of these switches to LD + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") + libsuff= shlibsuff= libmagic=32-bit;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") + libsuff=32 shlibsuff=N32 libmagic=N32;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") + libsuff=64 shlibsuff=64 libmagic=64-bit;; + *) libsuff= shlibsuff= libmagic=never-match;; + esac + ;; + esac + shlibpath_var=LD_LIBRARY${shlibsuff}_PATH + shlibpath_overrides_runpath=no + sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" + sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" + hardcode_into_libs=yes + ;; + +# No shared lib support for Linux oldld, aout, or coff. +linux*oldld* | linux*aout* | linux*coff*) + dynamic_linker=no + ;; + +# This must be Linux ELF. +linux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + # find out which ABI we are using + libsuff= + case "$host_cpu" in + x86_64*|s390x*|powerpc64*) + echo '#line 10918 "configure"' > conftest.$ac_ext + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + case `/usr/bin/file conftest.$ac_objext` in + *64-bit*) + libsuff=64 + sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}" + ;; + esac + fi + rm -rf conftest* + ;; + esac + + # Append ld.so.conf contents to the search path + if test -f /etc/ld.so.conf; then + lt_ld_extra=`$SED -e 's/:,\t/ /g;s/=^=*$//;s/=^= * / /g' /etc/ld.so.conf | tr '\n' ' '` + sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra" + fi + + # We used to test for /lib/ld.so.1 and disable shared libraries on + # powerpc, because MkLinux only supported shared libraries with the + # GNU dynamic linker. Since this was broken with cross compilers, + # most powerpc-linux boxes support dynamic linking these days and + # people can always --disable-shared, the test was removed, and we + # assume the GNU/Linux dynamic linker is in use. + dynamic_linker='GNU/Linux ld.so' + ;; + +knetbsd*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='GNU ld.so' + ;; + +netbsd*) + version_type=sunos + need_lib_prefix=no + need_version=no + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + dynamic_linker='NetBSD (a.out) ld.so' + else + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='NetBSD ld.elf_so' + fi + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + +newsos6) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +nto-qnx*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +openbsd*) + version_type=sunos + need_lib_prefix=no + need_version=yes + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + case $host_os in + openbsd2.[89] | openbsd2.[89].*) + shlibpath_overrides_runpath=no + ;; + *) + shlibpath_overrides_runpath=yes + ;; + esac + else + shlibpath_overrides_runpath=yes + fi + ;; + +os2*) + libname_spec='$name' + shrext_cmds=".dll" + need_lib_prefix=no + library_names_spec='$libname${shared_ext} $libname.a' + dynamic_linker='OS/2 ld.exe' + shlibpath_var=LIBPATH + ;; + +osf3* | osf4* | osf5*) + version_type=osf + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" + sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" + ;; + +sco3.2v5*) + version_type=osf + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + ;; + +solaris*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + # ldd complains unless libraries are executable + postinstall_cmds='chmod +x $lib' + ;; + +sunos4*) + version_type=sunos + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + if test "$with_gnu_ld" = yes; then + need_lib_prefix=no + fi + need_version=yes + ;; + +sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + case $host_vendor in + sni) + shlibpath_overrides_runpath=no + need_lib_prefix=no + export_dynamic_flag_spec='${wl}-Blargedynsym' + runpath_var=LD_RUN_PATH + ;; + siemens) + need_lib_prefix=no + ;; + motorola) + need_lib_prefix=no + need_version=no + shlibpath_overrides_runpath=no + sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' + ;; + esac + ;; + +sysv4*MP*) + if test -d /usr/nec ;then + version_type=linux + library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' + soname_spec='$libname${shared_ext}.$major' + shlibpath_var=LD_LIBRARY_PATH + fi + ;; + +uts4*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +*) + dynamic_linker=no + ;; +esac +echo "$as_me:$LINENO: result: $dynamic_linker" >&5 +echo "${ECHO_T}$dynamic_linker" >&6 +test "$dynamic_linker" = no && can_build_shared=no + +echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5 +echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6 +hardcode_action_CXX= +if test -n "$hardcode_libdir_flag_spec_CXX" || \ + test -n "$runpath_var CXX" || \ + test "X$hardcode_automatic_CXX"="Xyes" ; then + + # We can hardcode non-existant directories. + if test "$hardcode_direct_CXX" != no && + # If the only mechanism to avoid hardcoding is shlibpath_var, we + # have to relink, otherwise we might link with an installed library + # when we should be linking with a yet-to-be-installed one + ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, CXX)" != no && + test "$hardcode_minus_L_CXX" != no; then + # Linking always hardcodes the temporary library directory. + hardcode_action_CXX=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + hardcode_action_CXX=immediate + fi +else + # We cannot hardcode anything, or else we can only hardcode existing + # directories. + hardcode_action_CXX=unsupported +fi +echo "$as_me:$LINENO: result: $hardcode_action_CXX" >&5 +echo "${ECHO_T}$hardcode_action_CXX" >&6 + +if test "$hardcode_action_CXX" = relink; then + # Fast installation is not supported + enable_fast_install=no +elif test "$shlibpath_overrides_runpath" = yes || + test "$enable_shared" = no; then + # Fast installation is not necessary + enable_fast_install=needless +fi + +striplib= +old_striplib= +echo "$as_me:$LINENO: checking whether stripping libraries is possible" >&5 +echo $ECHO_N "checking whether stripping libraries is possible... $ECHO_C" >&6 +if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then + test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" + test -z "$striplib" && striplib="$STRIP --strip-unneeded" + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 +else +# FIXME - insert some real tests, host_os isn't really good enough + case $host_os in + darwin*) + if test -n "$STRIP" ; then + striplib="$STRIP -x" + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + ;; + *) + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + ;; + esac +fi + +if test "x$enable_dlopen" != xyes; then + enable_dlopen=unknown + enable_dlopen_self=unknown + enable_dlopen_self_static=unknown +else + lt_cv_dlopen=no + lt_cv_dlopen_libs= + + case $host_os in + beos*) + lt_cv_dlopen="load_add_on" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ;; + + mingw* | pw32*) + lt_cv_dlopen="LoadLibrary" + lt_cv_dlopen_libs= + ;; + + cygwin*) + lt_cv_dlopen="dlopen" + lt_cv_dlopen_libs= + ;; + + darwin*) + # if libdl is installed we need to link against it + echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5 +echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6 +if test "${ac_cv_lib_dl_dlopen+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldl $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char dlopen (); +int +main () +{ +dlopen (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_dl_dlopen=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_dl_dlopen=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5 +echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6 +if test $ac_cv_lib_dl_dlopen = yes; then + lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" +else + + lt_cv_dlopen="dyld" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + +fi + + ;; + + *) + echo "$as_me:$LINENO: checking for shl_load" >&5 +echo $ECHO_N "checking for shl_load... $ECHO_C" >&6 +if test "${ac_cv_func_shl_load+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define shl_load to an innocuous variant, in case declares shl_load. + For example, HP-UX 11i declares gettimeofday. */ +#define shl_load innocuous_shl_load + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char shl_load (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef shl_load + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char shl_load (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_shl_load) || defined (__stub___shl_load) +choke me +#else +char (*f) () = shl_load; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != shl_load; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_shl_load=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_func_shl_load=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_func_shl_load" >&5 +echo "${ECHO_T}$ac_cv_func_shl_load" >&6 +if test $ac_cv_func_shl_load = yes; then + lt_cv_dlopen="shl_load" +else + echo "$as_me:$LINENO: checking for shl_load in -ldld" >&5 +echo $ECHO_N "checking for shl_load in -ldld... $ECHO_C" >&6 +if test "${ac_cv_lib_dld_shl_load+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldld $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char shl_load (); +int +main () +{ +shl_load (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_dld_shl_load=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_dld_shl_load=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_dld_shl_load" >&5 +echo "${ECHO_T}$ac_cv_lib_dld_shl_load" >&6 +if test $ac_cv_lib_dld_shl_load = yes; then + lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld" +else + echo "$as_me:$LINENO: checking for dlopen" >&5 +echo $ECHO_N "checking for dlopen... $ECHO_C" >&6 +if test "${ac_cv_func_dlopen+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define dlopen to an innocuous variant, in case declares dlopen. + For example, HP-UX 11i declares gettimeofday. */ +#define dlopen innocuous_dlopen + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char dlopen (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef dlopen + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char dlopen (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_dlopen) || defined (__stub___dlopen) +choke me +#else +char (*f) () = dlopen; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != dlopen; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_dlopen=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_func_dlopen=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_func_dlopen" >&5 +echo "${ECHO_T}$ac_cv_func_dlopen" >&6 +if test $ac_cv_func_dlopen = yes; then + lt_cv_dlopen="dlopen" +else + echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5 +echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6 +if test "${ac_cv_lib_dl_dlopen+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldl $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char dlopen (); +int +main () +{ +dlopen (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_dl_dlopen=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_dl_dlopen=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5 +echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6 +if test $ac_cv_lib_dl_dlopen = yes; then + lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" +else + echo "$as_me:$LINENO: checking for dlopen in -lsvld" >&5 +echo $ECHO_N "checking for dlopen in -lsvld... $ECHO_C" >&6 +if test "${ac_cv_lib_svld_dlopen+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lsvld $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char dlopen (); +int +main () +{ +dlopen (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_svld_dlopen=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_svld_dlopen=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_svld_dlopen" >&5 +echo "${ECHO_T}$ac_cv_lib_svld_dlopen" >&6 +if test $ac_cv_lib_svld_dlopen = yes; then + lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld" +else + echo "$as_me:$LINENO: checking for dld_link in -ldld" >&5 +echo $ECHO_N "checking for dld_link in -ldld... $ECHO_C" >&6 +if test "${ac_cv_lib_dld_dld_link+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldld $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char dld_link (); +int +main () +{ +dld_link (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_dld_dld_link=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_dld_dld_link=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_dld_dld_link" >&5 +echo "${ECHO_T}$ac_cv_lib_dld_dld_link" >&6 +if test $ac_cv_lib_dld_dld_link = yes; then + lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld" +fi + + +fi + + +fi + + +fi + + +fi + + +fi + + ;; + esac + + if test "x$lt_cv_dlopen" != xno; then + enable_dlopen=yes + else + enable_dlopen=no + fi + + case $lt_cv_dlopen in + dlopen) + save_CPPFLAGS="$CPPFLAGS" + test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" + + save_LDFLAGS="$LDFLAGS" + eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" + + save_LIBS="$LIBS" + LIBS="$lt_cv_dlopen_libs $LIBS" + + echo "$as_me:$LINENO: checking whether a program can dlopen itself" >&5 +echo $ECHO_N "checking whether a program can dlopen itself... $ECHO_C" >&6 +if test "${lt_cv_dlopen_self+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$cross_compiling" = yes; then : + lt_cv_dlopen_self=cross +else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext < +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LT_DLGLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LT_DLGLOBAL DL_GLOBAL +# else +# define LT_DLGLOBAL 0 +# endif +#endif + +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LT_DLLAZY_OR_NOW +# ifdef RTLD_LAZY +# define LT_DLLAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LT_DLLAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LT_DLLAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LT_DLLAZY_OR_NOW DL_NOW +# else +# define LT_DLLAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +#ifdef __cplusplus +extern "C" void exit (int); +#endif + +void fnord() { int i=42;} +int main () +{ + void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); + int status = $lt_dlunknown; + + if (self) + { + if (dlsym (self,"fnord")) status = $lt_dlno_uscore; + else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + /* dlclose (self); */ + } + + exit (status); +} +EOF + if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then + (./conftest; exit; ) 2>/dev/null + lt_status=$? + case x$lt_status in + x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; + x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; + x$lt_unknown|x*) lt_cv_dlopen_self=no ;; + esac + else : + # compilation failed + lt_cv_dlopen_self=no + fi +fi +rm -fr conftest* + + +fi +echo "$as_me:$LINENO: result: $lt_cv_dlopen_self" >&5 +echo "${ECHO_T}$lt_cv_dlopen_self" >&6 + + if test "x$lt_cv_dlopen_self" = xyes; then + LDFLAGS="$LDFLAGS $link_static_flag" + echo "$as_me:$LINENO: checking whether a statically linked program can dlopen itself" >&5 +echo $ECHO_N "checking whether a statically linked program can dlopen itself... $ECHO_C" >&6 +if test "${lt_cv_dlopen_self_static+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$cross_compiling" = yes; then : + lt_cv_dlopen_self_static=cross +else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext < +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LT_DLGLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LT_DLGLOBAL DL_GLOBAL +# else +# define LT_DLGLOBAL 0 +# endif +#endif + +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LT_DLLAZY_OR_NOW +# ifdef RTLD_LAZY +# define LT_DLLAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LT_DLLAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LT_DLLAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LT_DLLAZY_OR_NOW DL_NOW +# else +# define LT_DLLAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +#ifdef __cplusplus +extern "C" void exit (int); +#endif + +void fnord() { int i=42;} +int main () +{ + void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); + int status = $lt_dlunknown; + + if (self) + { + if (dlsym (self,"fnord")) status = $lt_dlno_uscore; + else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + /* dlclose (self); */ + } + + exit (status); +} +EOF + if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then + (./conftest; exit; ) 2>/dev/null + lt_status=$? + case x$lt_status in + x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; + x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; + x$lt_unknown|x*) lt_cv_dlopen_self_static=no ;; + esac + else : + # compilation failed + lt_cv_dlopen_self_static=no + fi +fi +rm -fr conftest* + + +fi +echo "$as_me:$LINENO: result: $lt_cv_dlopen_self_static" >&5 +echo "${ECHO_T}$lt_cv_dlopen_self_static" >&6 + fi + + CPPFLAGS="$save_CPPFLAGS" + LDFLAGS="$save_LDFLAGS" + LIBS="$save_LIBS" + ;; + esac + + case $lt_cv_dlopen_self in + yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; + *) enable_dlopen_self=unknown ;; + esac + + case $lt_cv_dlopen_self_static in + yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; + *) enable_dlopen_self_static=unknown ;; + esac +fi + + +# The else clause should only fire when bootstrapping the +# libtool distribution, otherwise you forgot to ship ltmain.sh +# with your package, and you will get complaints that there are +# no rules to generate ltmain.sh. +if test -f "$ltmain"; then + # See if we are running on zsh, and set the options which allow our commands through + # without removal of \ escapes. + if test -n "${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST + fi + # Now quote all the things that may contain metacharacters while being + # careful not to overquote the AC_SUBSTed values. We take copies of the + # variables and quote the copies for generation of the libtool script. + for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC NM \ + SED SHELL STRIP \ + libname_spec library_names_spec soname_spec extract_expsyms_cmds \ + old_striplib striplib file_magic_cmd finish_cmds finish_eval \ + deplibs_check_method reload_flag reload_cmds need_locks \ + lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \ + lt_cv_sys_global_symbol_to_c_name_address \ + sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ + old_postinstall_cmds old_postuninstall_cmds \ + compiler_CXX \ + CC_CXX \ + LD_CXX \ + lt_prog_compiler_wl_CXX \ + lt_prog_compiler_pic_CXX \ + lt_prog_compiler_static_CXX \ + lt_prog_compiler_no_builtin_flag_CXX \ + export_dynamic_flag_spec_CXX \ + thread_safe_flag_spec_CXX \ + whole_archive_flag_spec_CXX \ + enable_shared_with_static_runtimes_CXX \ + old_archive_cmds_CXX \ + old_archive_from_new_cmds_CXX \ + predep_objects_CXX \ + postdep_objects_CXX \ + predeps_CXX \ + postdeps_CXX \ + compiler_lib_search_path_CXX \ + archive_cmds_CXX \ + archive_expsym_cmds_CXX \ + postinstall_cmds_CXX \ + postuninstall_cmds_CXX \ + old_archive_from_expsyms_cmds_CXX \ + allow_undefined_flag_CXX \ + no_undefined_flag_CXX \ + export_symbols_cmds_CXX \ + hardcode_libdir_flag_spec_CXX \ + hardcode_libdir_flag_spec_ld_CXX \ + hardcode_libdir_separator_CXX \ + hardcode_automatic_CXX \ + module_cmds_CXX \ + module_expsym_cmds_CXX \ + lt_cv_prog_compiler_c_o_CXX \ + exclude_expsyms_CXX \ + include_expsyms_CXX; do + + case $var in + old_archive_cmds_CXX | \ + old_archive_from_new_cmds_CXX | \ + archive_cmds_CXX | \ + archive_expsym_cmds_CXX | \ + module_cmds_CXX | \ + module_expsym_cmds_CXX | \ + old_archive_from_expsyms_cmds_CXX | \ + export_symbols_cmds_CXX | \ + extract_expsyms_cmds | reload_cmds | finish_cmds | \ + postinstall_cmds | postuninstall_cmds | \ + old_postinstall_cmds | old_postuninstall_cmds | \ + sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) + # Double-quote double-evaled strings. + eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" + ;; + *) + eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" + ;; + esac + done + + case $lt_echo in + *'\$0 --fallback-echo"') + lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'` + ;; + esac + +cfgfile="$ofile" + + cat <<__EOF__ >> "$cfgfile" +# ### BEGIN LIBTOOL TAG CONFIG: $tagname + +# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: + +# Shell to use when invoking shell scripts. +SHELL=$lt_SHELL + +# Whether or not to build shared libraries. +build_libtool_libs=$enable_shared + +# Whether or not to build static libraries. +build_old_libs=$enable_static + +# Whether or not to add -lc for building shared libraries. +build_libtool_need_lc=$archive_cmds_need_lc_CXX + +# Whether or not to disallow shared libs when runtime libs are static +allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_CXX + +# Whether or not to optimize for fast installation. +fast_install=$enable_fast_install + +# The host system. +host_alias=$host_alias +host=$host + +# An echo program that does not interpret backslashes. +echo=$lt_echo + +# The archiver. +AR=$lt_AR +AR_FLAGS=$lt_AR_FLAGS + +# A C compiler. +LTCC=$lt_LTCC + +# A language-specific compiler. +CC=$lt_compiler_CXX + +# Is the compiler the GNU C compiler? +with_gcc=$GCC_CXX + +# An ERE matcher. +EGREP=$lt_EGREP + +# The linker used to build libraries. +LD=$lt_LD_CXX + +# Whether we need hard or soft links. +LN_S=$lt_LN_S + +# A BSD-compatible nm program. +NM=$lt_NM + +# A symbol stripping program +STRIP=$lt_STRIP + +# Used to examine libraries when file_magic_cmd begins "file" +MAGIC_CMD=$MAGIC_CMD + +# Used on cygwin: DLL creation program. +DLLTOOL="$DLLTOOL" + +# Used on cygwin: object dumper. +OBJDUMP="$OBJDUMP" + +# Used on cygwin: assembler. +AS="$AS" + +# The name of the directory that contains temporary libtool files. +objdir=$objdir + +# How to create reloadable object files. +reload_flag=$lt_reload_flag +reload_cmds=$lt_reload_cmds + +# How to pass a linker flag through the compiler. +wl=$lt_lt_prog_compiler_wl_CXX + +# Object file suffix (normally "o"). +objext="$ac_objext" + +# Old archive suffix (normally "a"). +libext="$libext" + +# Shared library suffix (normally ".so"). +shrext_cmds='$shrext_cmds' + +# Executable file suffix (normally ""). +exeext="$exeext" + +# Additional compiler flags for building library objects. +pic_flag=$lt_lt_prog_compiler_pic_CXX +pic_mode=$pic_mode + +# What is the maximum length of a command? +max_cmd_len=$lt_cv_sys_max_cmd_len + +# Does compiler simultaneously support -c and -o options? +compiler_c_o=$lt_lt_cv_prog_compiler_c_o_CXX + +# Must we lock files when doing compilation ? +need_locks=$lt_need_locks + +# Do we need the lib prefix for modules? +need_lib_prefix=$need_lib_prefix + +# Do we need a version for libraries? +need_version=$need_version + +# Whether dlopen is supported. +dlopen_support=$enable_dlopen + +# Whether dlopen of programs is supported. +dlopen_self=$enable_dlopen_self + +# Whether dlopen of statically linked programs is supported. +dlopen_self_static=$enable_dlopen_self_static + +# Compiler flag to prevent dynamic linking. +link_static_flag=$lt_lt_prog_compiler_static_CXX + +# Compiler flag to turn off builtin functions. +no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_CXX + +# Compiler flag to allow reflexive dlopens. +export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_CXX + +# Compiler flag to generate shared objects directly from archives. +whole_archive_flag_spec=$lt_whole_archive_flag_spec_CXX + +# Compiler flag to generate thread-safe objects. +thread_safe_flag_spec=$lt_thread_safe_flag_spec_CXX + +# Library versioning type. +version_type=$version_type + +# Format of library name prefix. +libname_spec=$lt_libname_spec + +# List of archive names. First name is the real one, the rest are links. +# The last name is the one that the linker finds with -lNAME. +library_names_spec=$lt_library_names_spec + +# The coded name of the library, if different from the real name. +soname_spec=$lt_soname_spec + +# Commands used to build and install an old-style archive. +RANLIB=$lt_RANLIB +old_archive_cmds=$lt_old_archive_cmds_CXX +old_postinstall_cmds=$lt_old_postinstall_cmds +old_postuninstall_cmds=$lt_old_postuninstall_cmds + +# Create an old-style archive from a shared archive. +old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_CXX + +# Create a temporary old-style archive to link instead of a shared archive. +old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_CXX + +# Commands used to build and install a shared archive. +archive_cmds=$lt_archive_cmds_CXX +archive_expsym_cmds=$lt_archive_expsym_cmds_CXX +postinstall_cmds=$lt_postinstall_cmds +postuninstall_cmds=$lt_postuninstall_cmds + +# Commands used to build a loadable module (assumed same as above if empty) +module_cmds=$lt_module_cmds_CXX +module_expsym_cmds=$lt_module_expsym_cmds_CXX + +# Commands to strip libraries. +old_striplib=$lt_old_striplib +striplib=$lt_striplib + +# Dependencies to place before the objects being linked to create a +# shared library. +predep_objects=$lt_predep_objects_CXX + +# Dependencies to place after the objects being linked to create a +# shared library. +postdep_objects=$lt_postdep_objects_CXX + +# Dependencies to place before the objects being linked to create a +# shared library. +predeps=$lt_predeps_CXX + +# Dependencies to place after the objects being linked to create a +# shared library. +postdeps=$lt_postdeps_CXX + +# The library search path used internally by the compiler when linking +# a shared library. +compiler_lib_search_path=$lt_compiler_lib_search_path_CXX + +# Method to check whether dependent libraries are shared objects. +deplibs_check_method=$lt_deplibs_check_method + +# Command to use when deplibs_check_method == file_magic. +file_magic_cmd=$lt_file_magic_cmd + +# Flag that allows shared libraries with undefined symbols to be built. +allow_undefined_flag=$lt_allow_undefined_flag_CXX + +# Flag that forces no undefined symbols. +no_undefined_flag=$lt_no_undefined_flag_CXX + +# Commands used to finish a libtool library installation in a directory. +finish_cmds=$lt_finish_cmds + +# Same as above, but a single script fragment to be evaled but not shown. +finish_eval=$lt_finish_eval + +# Take the output of nm and produce a listing of raw symbols and C names. +global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe + +# Transform the output of nm in a proper C declaration +global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl + +# Transform the output of nm in a C name address pair +global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address + +# This is the shared library runtime path variable. +runpath_var=$runpath_var + +# This is the shared library path variable. +shlibpath_var=$shlibpath_var + +# Is shlibpath searched before the hard-coded library search path? +shlibpath_overrides_runpath=$shlibpath_overrides_runpath + +# How to hardcode a shared library path into an executable. +hardcode_action=$hardcode_action_CXX + +# Whether we should hardcode library paths into libraries. +hardcode_into_libs=$hardcode_into_libs + +# Flag to hardcode \$libdir into a binary during linking. +# This must work even if \$libdir does not exist. +hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_CXX + +# If ld is used when linking, flag to hardcode \$libdir into +# a binary during linking. This must work even if \$libdir does +# not exist. +hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_CXX + +# Whether we need a single -rpath flag with a separated argument. +hardcode_libdir_separator=$lt_hardcode_libdir_separator_CXX + +# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the +# resulting binary. +hardcode_direct=$hardcode_direct_CXX + +# Set to yes if using the -LDIR flag during linking hardcodes DIR into the +# resulting binary. +hardcode_minus_L=$hardcode_minus_L_CXX + +# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into +# the resulting binary. +hardcode_shlibpath_var=$hardcode_shlibpath_var_CXX + +# Set to yes if building a shared library automatically hardcodes DIR into the library +# and all subsequent libraries and executables linked against it. +hardcode_automatic=$hardcode_automatic_CXX + +# Variables whose values should be saved in libtool wrapper scripts and +# restored at relink time. +variables_saved_for_relink="$variables_saved_for_relink" + +# Whether libtool must link a program against all its dependency libraries. +link_all_deplibs=$link_all_deplibs_CXX + +# Compile-time system search path for libraries +sys_lib_search_path_spec=$lt_sys_lib_search_path_spec + +# Run-time system search path for libraries +sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec + +# Fix the shell variable \$srcfile for the compiler. +fix_srcfile_path="$fix_srcfile_path_CXX" + +# Set to yes if exported symbols are required. +always_export_symbols=$always_export_symbols_CXX + +# The commands to list exported symbols. +export_symbols_cmds=$lt_export_symbols_cmds_CXX + +# The commands to extract the exported symbol list from a shared archive. +extract_expsyms_cmds=$lt_extract_expsyms_cmds + +# Symbols that should not be listed in the preloaded symbols. +exclude_expsyms=$lt_exclude_expsyms_CXX + +# Symbols that must always be exported. +include_expsyms=$lt_include_expsyms_CXX + +# ### END LIBTOOL TAG CONFIG: $tagname + +__EOF__ + + +else + # If there is no Makefile yet, we rely on a make rule to execute + # `config.status --recheck' to rerun these tests and create the + # libtool script then. + ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'` + if test -f "$ltmain_in"; then + test -f Makefile && make "$ltmain" + fi +fi + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +CC=$lt_save_CC +LDCXX=$LD +LD=$lt_save_LD +GCC=$lt_save_GCC +with_gnu_ldcxx=$with_gnu_ld +with_gnu_ld=$lt_save_with_gnu_ld +lt_cv_path_LDCXX=$lt_cv_path_LD +lt_cv_path_LD=$lt_save_path_LD +lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld +lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld + + else + tagname="" + fi + ;; + + F77) + if test -n "$F77" && test "X$F77" != "Xno"; then + +ac_ext=f +ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5' +ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_f77_compiler_gnu + + +archive_cmds_need_lc_F77=no +allow_undefined_flag_F77= +always_export_symbols_F77=no +archive_expsym_cmds_F77= +export_dynamic_flag_spec_F77= +hardcode_direct_F77=no +hardcode_libdir_flag_spec_F77= +hardcode_libdir_flag_spec_ld_F77= +hardcode_libdir_separator_F77= +hardcode_minus_L_F77=no +hardcode_automatic_F77=no +module_cmds_F77= +module_expsym_cmds_F77= +link_all_deplibs_F77=unknown +old_archive_cmds_F77=$old_archive_cmds +no_undefined_flag_F77= +whole_archive_flag_spec_F77= +enable_shared_with_static_runtimes_F77=no + +# Source file extension for f77 test sources. +ac_ext=f + +# Object file extension for compiled f77 test sources. +objext=o +objext_F77=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code=" subroutine t\n return\n end\n" + +# Code to be used in simple link tests +lt_simple_link_test_code=" program t\n end\n" + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# Allow CC to be a program name with arguments. +compiler=$CC + + +# Allow CC to be a program name with arguments. +lt_save_CC="$CC" +CC=${F77-"f77"} +compiler=$CC +compiler_F77=$CC +cc_basename=`$echo X"$compiler" | $Xsed -e 's%^.*/%%'` + +echo "$as_me:$LINENO: checking if libtool supports shared libraries" >&5 +echo $ECHO_N "checking if libtool supports shared libraries... $ECHO_C" >&6 +echo "$as_me:$LINENO: result: $can_build_shared" >&5 +echo "${ECHO_T}$can_build_shared" >&6 + +echo "$as_me:$LINENO: checking whether to build shared libraries" >&5 +echo $ECHO_N "checking whether to build shared libraries... $ECHO_C" >&6 +test "$can_build_shared" = "no" && enable_shared=no + +# On AIX, shared libraries and static libraries use the same namespace, and +# are all built from PIC. +case "$host_os" in +aix3*) + test "$enable_shared" = yes && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; +aix4* | aix5*) + test "$enable_shared" = yes && enable_static=no + ;; +esac +echo "$as_me:$LINENO: result: $enable_shared" >&5 +echo "${ECHO_T}$enable_shared" >&6 + +echo "$as_me:$LINENO: checking whether to build static libraries" >&5 +echo $ECHO_N "checking whether to build static libraries... $ECHO_C" >&6 +# Make sure either enable_shared or enable_static is yes. +test "$enable_shared" = yes || enable_static=yes +echo "$as_me:$LINENO: result: $enable_static" >&5 +echo "${ECHO_T}$enable_static" >&6 + +test "$ld_shlibs_F77" = no && can_build_shared=no + +GCC_F77="$G77" +LD_F77="$LD" + +lt_prog_compiler_wl_F77= +lt_prog_compiler_pic_F77= +lt_prog_compiler_static_F77= + +echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5 +echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6 + + if test "$GCC" = yes; then + lt_prog_compiler_wl_F77='-Wl,' + lt_prog_compiler_static_F77='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static_F77='-Bstatic' + fi + ;; + + amigaos*) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the `-m68020' flag to GCC prevents building anything better, + # like `-m68040'. + lt_prog_compiler_pic_F77='-m68020 -resident32 -malways-restore-a4' + ;; + + beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + + mingw* | pw32* | os2*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + lt_prog_compiler_pic_F77='-DDLL_EXPORT' + ;; + + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + lt_prog_compiler_pic_F77='-fno-common' + ;; + + msdosdjgpp*) + # Just because we use GCC doesn't mean we suddenly get shared libraries + # on systems that don't support them. + lt_prog_compiler_can_build_shared_F77=no + enable_shared=no + ;; + + sysv4*MP*) + if test -d /usr/nec; then + lt_prog_compiler_pic_F77=-Kconform_pic + fi + ;; + + hpux*) + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case "$host_cpu" in + hppa*64*|ia64*) + # +Z the default + ;; + *) + lt_prog_compiler_pic_F77='-fPIC' + ;; + esac + ;; + + *) + lt_prog_compiler_pic_F77='-fPIC' + ;; + esac + else + # PORTME Check for flag to pass linker flags through the system compiler. + case $host_os in + aix*) + lt_prog_compiler_wl_F77='-Wl,' + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static_F77='-Bstatic' + else + lt_prog_compiler_static_F77='-bnso -bI:/lib/syscalls.exp' + fi + ;; + + mingw* | pw32* | os2*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + lt_prog_compiler_pic_F77='-DDLL_EXPORT' + ;; + + hpux9* | hpux10* | hpux11*) + lt_prog_compiler_wl_F77='-Wl,' + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case "$host_cpu" in + hppa*64*|ia64*) + # +Z the default + ;; + *) + lt_prog_compiler_pic_F77='+Z' + ;; + esac + # Is there a better lt_prog_compiler_static that works with the bundled CC? + lt_prog_compiler_static_F77='${wl}-a ${wl}archive' + ;; + + irix5* | irix6* | nonstopux*) + lt_prog_compiler_wl_F77='-Wl,' + # PIC (with -KPIC) is the default. + lt_prog_compiler_static_F77='-non_shared' + ;; + + newsos6) + lt_prog_compiler_pic_F77='-KPIC' + lt_prog_compiler_static_F77='-Bstatic' + ;; + + linux*) + case $CC in + icc* | ecc*) + lt_prog_compiler_wl_F77='-Wl,' + lt_prog_compiler_pic_F77='-KPIC' + lt_prog_compiler_static_F77='-static' + ;; + ccc*) + lt_prog_compiler_wl_F77='-Wl,' + # All Alpha code is PIC. + lt_prog_compiler_static_F77='-non_shared' + ;; + esac + ;; + + osf3* | osf4* | osf5*) + lt_prog_compiler_wl_F77='-Wl,' + # All OSF/1 code is PIC. + lt_prog_compiler_static_F77='-non_shared' + ;; + + sco3.2v5*) + lt_prog_compiler_pic_F77='-Kpic' + lt_prog_compiler_static_F77='-dn' + ;; + + solaris*) + lt_prog_compiler_wl_F77='-Wl,' + lt_prog_compiler_pic_F77='-KPIC' + lt_prog_compiler_static_F77='-Bstatic' + ;; + + sunos4*) + lt_prog_compiler_wl_F77='-Qoption ld ' + lt_prog_compiler_pic_F77='-PIC' + lt_prog_compiler_static_F77='-Bstatic' + ;; + + sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + lt_prog_compiler_wl_F77='-Wl,' + lt_prog_compiler_pic_F77='-KPIC' + lt_prog_compiler_static_F77='-Bstatic' + ;; + + sysv4*MP*) + if test -d /usr/nec ;then + lt_prog_compiler_pic_F77='-Kconform_pic' + lt_prog_compiler_static_F77='-Bstatic' + fi + ;; + + uts4*) + lt_prog_compiler_pic_F77='-pic' + lt_prog_compiler_static_F77='-Bstatic' + ;; + + *) + lt_prog_compiler_can_build_shared_F77=no + ;; + esac + fi + +echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_F77" >&5 +echo "${ECHO_T}$lt_prog_compiler_pic_F77" >&6 + +# +# Check to make sure the PIC flag actually works. +# +if test -n "$lt_prog_compiler_pic_F77"; then + +echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_F77 works" >&5 +echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_F77 works... $ECHO_C" >&6 +if test "${lt_prog_compiler_pic_works_F77+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + lt_prog_compiler_pic_works_F77=no + ac_outfile=conftest.$ac_objext + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="$lt_prog_compiler_pic_F77" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:12714: $lt_compile\"" >&5) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&5 + echo "$as_me:12718: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + if test ! -s conftest.err; then + lt_prog_compiler_pic_works_F77=yes + fi + fi + $rm conftest* + +fi +echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works_F77" >&5 +echo "${ECHO_T}$lt_prog_compiler_pic_works_F77" >&6 + +if test x"$lt_prog_compiler_pic_works_F77" = xyes; then + case $lt_prog_compiler_pic_F77 in + "" | " "*) ;; + *) lt_prog_compiler_pic_F77=" $lt_prog_compiler_pic_F77" ;; + esac +else + lt_prog_compiler_pic_F77= + lt_prog_compiler_can_build_shared_F77=no +fi + +fi +case "$host_os" in + # For platforms which do not support PIC, -DPIC is meaningless: + *djgpp*) + lt_prog_compiler_pic_F77= + ;; + *) + lt_prog_compiler_pic_F77="$lt_prog_compiler_pic_F77" + ;; +esac + +echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5 +echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6 +if test "${lt_cv_prog_compiler_c_o_F77+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + lt_cv_prog_compiler_c_o_F77=no + $rm -r conftest 2>/dev/null + mkdir conftest + cd conftest + mkdir out + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + + lt_compiler_flag="-o out/conftest2.$ac_objext" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:12774: $lt_compile\"" >&5) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&5 + echo "$as_me:12778: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + if test ! -s out/conftest.err; then + lt_cv_prog_compiler_c_o_F77=yes + fi + fi + chmod u+w . + $rm conftest* + # SGI C++ compiler will create directory out/ii_files/ for + # template instantiation + test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files + $rm out/* && rmdir out + cd .. + rmdir conftest + $rm conftest* + +fi +echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_F77" >&5 +echo "${ECHO_T}$lt_cv_prog_compiler_c_o_F77" >&6 + + +hard_links="nottested" +if test "$lt_cv_prog_compiler_c_o_F77" = no && test "$need_locks" != no; then + # do not overwrite the value of need_locks provided by the user + echo "$as_me:$LINENO: checking if we can lock with hard links" >&5 +echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6 + hard_links=yes + $rm conftest* + ln conftest.a conftest.b 2>/dev/null && hard_links=no + touch conftest.a + ln conftest.a conftest.b 2>&5 || hard_links=no + ln conftest.a conftest.b 2>/dev/null && hard_links=no + echo "$as_me:$LINENO: result: $hard_links" >&5 +echo "${ECHO_T}$hard_links" >&6 + if test "$hard_links" = no; then + { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 +echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} + need_locks=warn + fi +else + need_locks=no +fi + +echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5 +echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6 + + runpath_var= + allow_undefined_flag_F77= + enable_shared_with_static_runtimes_F77=no + archive_cmds_F77= + archive_expsym_cmds_F77= + old_archive_From_new_cmds_F77= + old_archive_from_expsyms_cmds_F77= + export_dynamic_flag_spec_F77= + whole_archive_flag_spec_F77= + thread_safe_flag_spec_F77= + hardcode_libdir_flag_spec_F77= + hardcode_libdir_flag_spec_ld_F77= + hardcode_libdir_separator_F77= + hardcode_direct_F77=no + hardcode_minus_L_F77=no + hardcode_shlibpath_var_F77=unsupported + link_all_deplibs_F77=unknown + hardcode_automatic_F77=no + module_cmds_F77= + module_expsym_cmds_F77= + always_export_symbols_F77=no + export_symbols_cmds_F77='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + # include_expsyms should be a list of space-separated symbols to be *always* + # included in the symbol list + include_expsyms_F77= + # exclude_expsyms can be an extended regexp of symbols to exclude + # it will be wrapped by ` (' and `)$', so one must not match beginning or + # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', + # as well as any symbol that contains `d'. + exclude_expsyms_F77="_GLOBAL_OFFSET_TABLE_" + # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out + # platforms (ab)use it in PIC code, but their linkers get confused if + # the symbol is explicitly referenced. Since portable code cannot + # rely on this symbol name, it's probably fine to never include it in + # preloaded symbol tables. + extract_expsyms_cmds= + + case $host_os in + cygwin* | mingw* | pw32*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + if test "$GCC" != yes; then + with_gnu_ld=no + fi + ;; + openbsd*) + with_gnu_ld=no + ;; + esac + + ld_shlibs_F77=yes + if test "$with_gnu_ld" = yes; then + # If archive_cmds runs LD, not CC, wlarc should be empty + wlarc='${wl}' + + # See if GNU ld supports shared libraries. + case $host_os in + aix3* | aix4* | aix5*) + # On AIX/PPC, the GNU linker is very broken + if test "$host_cpu" != ia64; then + ld_shlibs_F77=no + cat <&2 + +*** Warning: the GNU linker, at least up to release 2.9.1, is reported +*** to be unable to reliably create shared libraries on AIX. +*** Therefore, libtool is disabling shared libraries support. If you +*** really care for shared libraries, you may want to modify your PATH +*** so that a non-GNU linker is found, and then restart. + +EOF + fi + ;; + + amigaos*) + archive_cmds_F77='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec_F77='-L$libdir' + hardcode_minus_L_F77=yes + + # Samuel A. Falvo II reports + # that the semantics of dynamic libraries on AmigaOS, at least up + # to version 4, is to share data among multiple programs linked + # with the same dynamic library. Since this doesn't match the + # behavior of shared libraries on other platforms, we can't use + # them. + ld_shlibs_F77=no + ;; + + beos*) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + allow_undefined_flag_F77=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + archive_cmds_F77='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + else + ld_shlibs_F77=no + fi + ;; + + cygwin* | mingw* | pw32*) + # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, F77) is actually meaningless, + # as there is no search path for DLLs. + hardcode_libdir_flag_spec_F77='-L$libdir' + allow_undefined_flag_F77=unsupported + always_export_symbols_F77=no + enable_shared_with_static_runtimes_F77=yes + export_symbols_cmds_F77='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols' + + if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then + archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib' + # If the export-symbols file already is a .def file (1st line + # is EXPORTS), use it as is; otherwise, prepend... + archive_expsym_cmds_F77='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib' + else + ld_shlibs=no + fi + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + archive_cmds_F77='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' + wlarc= + else + archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + fi + ;; + + solaris* | sysv5*) + if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then + ld_shlibs_F77=no + cat <&2 + +*** Warning: The releases 2.8.* of the GNU linker cannot reliably +*** create shared libraries on Solaris systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.9.1 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +EOF + elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs_F77=no + fi + ;; + + sunos4*) + archive_cmds_F77='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' + wlarc= + hardcode_direct_F77=yes + hardcode_shlibpath_var_F77=no + ;; + + linux*) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + tmp_archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_cmds_F77="$tmp_archive_cmds" + supports_anon_versioning=no + case `$LD -v 2>/dev/null` in + *\ 01.* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 + *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... + *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... + *\ 2.11.*) ;; # other 2.11 versions + *) supports_anon_versioning=yes ;; + esac + if test $supports_anon_versioning = yes; then + archive_expsym_cmds_F77='$echo "{ global:" > $output_objdir/$libname.ver~ +cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ +$echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' + else + archive_expsym_cmds_F77="$tmp_archive_cmds" + fi + else + ld_shlibs_F77=no + fi + ;; + + *) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs_F77=no + fi + ;; + esac + + if test "$ld_shlibs_F77" = yes; then + runpath_var=LD_RUN_PATH + hardcode_libdir_flag_spec_F77='${wl}--rpath ${wl}$libdir' + export_dynamic_flag_spec_F77='${wl}--export-dynamic' + # ancient GNU ld didn't support --whole-archive et. al. + if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then + whole_archive_flag_spec_F77="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + whole_archive_flag_spec_F77= + fi + fi + else + # PORTME fill in a description of your system's linker (not GNU ld) + case $host_os in + aix3*) + allow_undefined_flag_F77=unsupported + always_export_symbols_F77=yes + archive_expsym_cmds_F77='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + hardcode_minus_L_F77=yes + if test "$GCC" = yes && test -z "$link_static_flag"; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + hardcode_direct_F77=unsupported + fi + ;; + + aix4* | aix5*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag="" + else + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to AIX nm, but means don't demangle with GNU nm + if $NM -V 2>&1 | grep 'GNU' > /dev/null; then + export_symbols_cmds_F77='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' + else + export_symbols_cmds_F77='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' + fi + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[23]|aix4.[23].*|aix5*) + for ld_flag in $LDFLAGS; do + if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then + aix_use_runtimelinking=yes + break + fi + done + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + archive_cmds_F77='' + hardcode_direct_F77=yes + hardcode_libdir_separator_F77=':' + link_all_deplibs_F77=yes + + if test "$GCC" = yes; then + case $host_os in aix4.012|aix4.012.*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && \ + strings "$collect2name" | grep resolve_lib_name >/dev/null + then + # We have reworked collect2 + hardcode_direct_F77=yes + else + # We have old collect2 + hardcode_direct_F77=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + hardcode_minus_L_F77=yes + hardcode_libdir_flag_spec_F77='-L$libdir' + hardcode_libdir_separator_F77= + fi + esac + shared_flag='-shared' + else + # not using gcc + if test "$host_cpu" = ia64; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test "$aix_use_runtimelinking" = yes; then + shared_flag='${wl}-G' + else + shared_flag='${wl}-bM:SRE' + fi + fi + fi + + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to export. + always_export_symbols_F77=yes + if test "$aix_use_runtimelinking" = yes; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + allow_undefined_flag_F77='-berok' + # Determine the default libpath from the value encoded in an empty executable. + cat >conftest.$ac_ext <<_ACEOF + program main + + end +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_f77_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'`; fi +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi + + hardcode_libdir_flag_spec_F77='${wl}-blibpath:$libdir:'"$aix_libpath" + archive_expsym_cmds_F77="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag" + else + if test "$host_cpu" = ia64; then + hardcode_libdir_flag_spec_F77='${wl}-R $libdir:/usr/lib:/lib' + allow_undefined_flag_F77="-z nodefs" + archive_expsym_cmds_F77="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an empty executable. + cat >conftest.$ac_ext <<_ACEOF + program main + + end +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_f77_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'`; fi +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi + + hardcode_libdir_flag_spec_F77='${wl}-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + no_undefined_flag_F77=' ${wl}-bernotok' + allow_undefined_flag_F77=' ${wl}-berok' + # -bexpall does not export symbols beginning with underscore (_) + always_export_symbols_F77=yes + # Exported symbols can be pulled into shared objects from archives + whole_archive_flag_spec_F77=' ' + archive_cmds_need_lc_F77=yes + # This is similar to how AIX traditionally builds it's shared libraries. + archive_expsym_cmds_F77="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' + fi + fi + ;; + + amigaos*) + archive_cmds_F77='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec_F77='-L$libdir' + hardcode_minus_L_F77=yes + # see comment about different semantics on the GNU ld section + ld_shlibs_F77=no + ;; + + bsdi4*) + export_dynamic_flag_spec_F77=-rdynamic + ;; + + cygwin* | mingw* | pw32*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + hardcode_libdir_flag_spec_F77=' ' + allow_undefined_flag_F77=unsupported + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=".dll" + # FIXME: Setting linknames here is a bad hack. + archive_cmds_F77='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames=' + # The linker will automatically build a .lib file if we build a DLL. + old_archive_From_new_cmds_F77='true' + # FIXME: Should let the user specify the lib program. + old_archive_cmds_F77='lib /OUT:$oldlib$oldobjs$old_deplibs' + fix_srcfile_path='`cygpath -w "$srcfile"`' + enable_shared_with_static_runtimes_F77=yes + ;; + + darwin* | rhapsody*) + if test "$GXX" = yes ; then + archive_cmds_need_lc_F77=no + case "$host_os" in + rhapsody* | darwin1.[012]) + allow_undefined_flag_F77='-undefined suppress' + ;; + *) # Darwin 1.3 on + if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then + allow_undefined_flag_F77='-flat_namespace -undefined suppress' + else + case ${MACOSX_DEPLOYMENT_TARGET} in + 10.[012]) + allow_undefined_flag_F77='-flat_namespace -undefined suppress' + ;; + 10.*) + allow_undefined_flag_F77='-undefined dynamic_lookup' + ;; + esac + fi + ;; + esac + lt_int_apple_cc_single_mod=no + output_verbose_link_cmd='echo' + if $CC -dumpspecs 2>&1 | grep 'single_module' >/dev/null ; then + lt_int_apple_cc_single_mod=yes + fi + if test "X$lt_int_apple_cc_single_mod" = Xyes ; then + archive_cmds_F77='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring' + else + archive_cmds_F77='$CC -r ${wl}-bind_at_load -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring' + fi + module_cmds_F77='$CC ${wl}-bind_at_load $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' + # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's + if test "X$lt_int_apple_cc_single_mod" = Xyes ; then + archive_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + else + archive_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r ${wl}-bind_at_load -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + fi + module_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + hardcode_direct_F77=no + hardcode_automatic_F77=yes + hardcode_shlibpath_var_F77=unsupported + whole_archive_flag_spec_F77='-all_load $convenience' + link_all_deplibs_F77=yes + else + ld_shlibs_F77=no + fi + ;; + + dgux*) + archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec_F77='-L$libdir' + hardcode_shlibpath_var_F77=no + ;; + + freebsd1*) + ld_shlibs_F77=no + ;; + + # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor + # support. Future versions do this automatically, but an explicit c++rt0.o + # does not break anything, and helps significantly (at the cost of a little + # extra space). + freebsd2.2*) + archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' + hardcode_libdir_flag_spec_F77='-R$libdir' + hardcode_direct_F77=yes + hardcode_shlibpath_var_F77=no + ;; + + # Unfortunately, older versions of FreeBSD 2 do not have this feature. + freebsd2*) + archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct_F77=yes + hardcode_minus_L_F77=yes + hardcode_shlibpath_var_F77=no + ;; + + # FreeBSD 3 and greater uses gcc -shared to do shared libraries. + freebsd* | kfreebsd*-gnu) + archive_cmds_F77='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec_F77='-R$libdir' + hardcode_direct_F77=yes + hardcode_shlibpath_var_F77=no + ;; + + hpux9*) + if test "$GCC" = yes; then + archive_cmds_F77='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + else + archive_cmds_F77='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + fi + hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir' + hardcode_libdir_separator_F77=: + hardcode_direct_F77=yes + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L_F77=yes + export_dynamic_flag_spec_F77='${wl}-E' + ;; + + hpux10* | hpux11*) + if test "$GCC" = yes -a "$with_gnu_ld" = no; then + case "$host_cpu" in + hppa*64*|ia64*) + archive_cmds_F77='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + archive_cmds_F77='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + else + case "$host_cpu" in + hppa*64*|ia64*) + archive_cmds_F77='$LD -b +h $soname -o $lib $libobjs $deplibs $linker_flags' + ;; + *) + archive_cmds_F77='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' + ;; + esac + fi + if test "$with_gnu_ld" = no; then + case "$host_cpu" in + hppa*64*) + hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir' + hardcode_libdir_flag_spec_ld_F77='+b $libdir' + hardcode_libdir_separator_F77=: + hardcode_direct_F77=no + hardcode_shlibpath_var_F77=no + ;; + ia64*) + hardcode_libdir_flag_spec_F77='-L$libdir' + hardcode_direct_F77=no + hardcode_shlibpath_var_F77=no + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L_F77=yes + ;; + *) + hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir' + hardcode_libdir_separator_F77=: + hardcode_direct_F77=yes + export_dynamic_flag_spec_F77='${wl}-E' + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L_F77=yes + ;; + esac + fi + ;; + + irix5* | irix6* | nonstopux*) + if test "$GCC" = yes; then + archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + archive_cmds_F77='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + hardcode_libdir_flag_spec_ld_F77='-rpath $libdir' + fi + hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator_F77=: + link_all_deplibs_F77=yes + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out + else + archive_cmds_F77='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF + fi + hardcode_libdir_flag_spec_F77='-R$libdir' + hardcode_direct_F77=yes + hardcode_shlibpath_var_F77=no + ;; + + newsos6) + archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct_F77=yes + hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator_F77=: + hardcode_shlibpath_var_F77=no + ;; + + openbsd*) + hardcode_direct_F77=yes + hardcode_shlibpath_var_F77=no + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + archive_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec_F77='${wl}-rpath,$libdir' + export_dynamic_flag_spec_F77='${wl}-E' + else + case $host_os in + openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) + archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec_F77='-R$libdir' + ;; + *) + archive_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec_F77='${wl}-rpath,$libdir' + ;; + esac + fi + ;; + + os2*) + hardcode_libdir_flag_spec_F77='-L$libdir' + hardcode_minus_L_F77=yes + allow_undefined_flag_F77=unsupported + archive_cmds_F77='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' + old_archive_From_new_cmds_F77='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' + ;; + + osf3*) + if test "$GCC" = yes; then + allow_undefined_flag_F77=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds_F77='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + allow_undefined_flag_F77=' -expect_unresolved \*' + archive_cmds_F77='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + fi + hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator_F77=: + ;; + + osf4* | osf5*) # as osf3* with the addition of -msym flag + if test "$GCC" = yes; then + allow_undefined_flag_F77=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds_F77='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir' + else + allow_undefined_flag_F77=' -expect_unresolved \*' + archive_cmds_F77='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + archive_expsym_cmds_F77='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~ + $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib~$rm $lib.exp' + + # Both c and cxx compiler support -rpath directly + hardcode_libdir_flag_spec_F77='-rpath $libdir' + fi + hardcode_libdir_separator_F77=: + ;; + + sco3.2v5*) + archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var_F77=no + export_dynamic_flag_spec_F77='${wl}-Bexport' + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + ;; + + solaris*) + no_undefined_flag_F77=' -z text' + if test "$GCC" = yes; then + archive_cmds_F77='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds_F77='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp' + else + archive_cmds_F77='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' + archive_expsym_cmds_F77='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' + fi + hardcode_libdir_flag_spec_F77='-R$libdir' + hardcode_shlibpath_var_F77=no + case $host_os in + solaris2.[0-5] | solaris2.[0-5].*) ;; + *) # Supported since Solaris 2.6 (maybe 2.5.1?) + whole_archive_flag_spec_F77='-z allextract$convenience -z defaultextract' ;; + esac + link_all_deplibs_F77=yes + ;; + + sunos4*) + if test "x$host_vendor" = xsequent; then + # Use $CC to link under sequent, because it throws in some extra .o + # files that make .init and .fini sections work. + archive_cmds_F77='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds_F77='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' + fi + hardcode_libdir_flag_spec_F77='-L$libdir' + hardcode_direct_F77=yes + hardcode_minus_L_F77=yes + hardcode_shlibpath_var_F77=no + ;; + + sysv4) + case $host_vendor in + sni) + archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct_F77=yes # is this really true??? + ;; + siemens) + ## LD is ld it makes a PLAMLIB + ## CC just makes a GrossModule. + archive_cmds_F77='$LD -G -o $lib $libobjs $deplibs $linker_flags' + reload_cmds_F77='$CC -r -o $output$reload_objs' + hardcode_direct_F77=no + ;; + motorola) + archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct_F77=no #Motorola manual says yes, but my tests say they lie + ;; + esac + runpath_var='LD_RUN_PATH' + hardcode_shlibpath_var_F77=no + ;; + + sysv4.3*) + archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var_F77=no + export_dynamic_flag_spec_F77='-Bexport' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var_F77=no + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + ld_shlibs_F77=yes + fi + ;; + + sysv4.2uw2*) + archive_cmds_F77='$LD -G -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct_F77=yes + hardcode_minus_L_F77=no + hardcode_shlibpath_var_F77=no + hardcode_runpath_var=yes + runpath_var=LD_RUN_PATH + ;; + + sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[78]* | unixware7*) + no_undefined_flag_F77='${wl}-z ${wl}text' + if test "$GCC" = yes; then + archive_cmds_F77='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds_F77='$CC -G ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + runpath_var='LD_RUN_PATH' + hardcode_shlibpath_var_F77=no + ;; + + sysv5*) + no_undefined_flag_F77=' -z text' + # $CC -shared without GNU ld will not create a library from C++ + # object files and a static libstdc++, better avoid it by now + archive_cmds_F77='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' + archive_expsym_cmds_F77='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' + hardcode_libdir_flag_spec_F77= + hardcode_shlibpath_var_F77=no + runpath_var='LD_RUN_PATH' + ;; + + uts4*) + archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec_F77='-L$libdir' + hardcode_shlibpath_var_F77=no + ;; + + *) + ld_shlibs_F77=no + ;; + esac + fi + +echo "$as_me:$LINENO: result: $ld_shlibs_F77" >&5 +echo "${ECHO_T}$ld_shlibs_F77" >&6 +test "$ld_shlibs_F77" = no && can_build_shared=no + +variables_saved_for_relink="PATH $shlibpath_var $runpath_var" +if test "$GCC" = yes; then + variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" +fi + +# +# Do we need to explicitly link libc? +# +case "x$archive_cmds_need_lc_F77" in +x|xyes) + # Assume -lc should be added + archive_cmds_need_lc_F77=yes + + if test "$enable_shared" = yes && test "$GCC" = yes; then + case $archive_cmds_F77 in + *'~'*) + # FIXME: we may have to deal with multi-command sequences. + ;; + '$CC '*) + # Test whether the compiler implicitly links with -lc since on some + # systems, -lgcc has to come before -lc. If gcc already passes -lc + # to ld, don't add -lc before -lgcc. + echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5 +echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6 + $rm conftest* + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } 2>conftest.err; then + soname=conftest + lib=conftest + libobjs=conftest.$ac_objext + deplibs= + wl=$lt_prog_compiler_wl_F77 + compiler_flags=-v + linker_flags=-v + verstring= + output_objdir=. + libname=conftest + lt_save_allow_undefined_flag=$allow_undefined_flag_F77 + allow_undefined_flag_F77= + if { (eval echo "$as_me:$LINENO: \"$archive_cmds_F77 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5 + (eval $archive_cmds_F77 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + then + archive_cmds_need_lc_F77=no + else + archive_cmds_need_lc_F77=yes + fi + allow_undefined_flag_F77=$lt_save_allow_undefined_flag + else + cat conftest.err 1>&5 + fi + $rm conftest* + echo "$as_me:$LINENO: result: $archive_cmds_need_lc_F77" >&5 +echo "${ECHO_T}$archive_cmds_need_lc_F77" >&6 + ;; + esac + fi + ;; +esac + +echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5 +echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6 +library_names_spec= +libname_spec='lib$name' +soname_spec= +shrext_cmds=".so" +postinstall_cmds= +postuninstall_cmds= +finish_cmds= +finish_eval= +shlibpath_var= +shlibpath_overrides_runpath=unknown +version_type=none +dynamic_linker="$host_os ld.so" +sys_lib_dlsearch_path_spec="/lib /usr/lib" +if test "$GCC" = yes; then + sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then + # if the path contains ";" then we assume it to be the separator + # otherwise default to the standard path separator (i.e. ":") - it is + # assumed that no part of a normal pathname contains ";" but that should + # okay in the real world where ";" in dirpaths is itself problematic. + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi +else + sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" +fi +need_lib_prefix=unknown +hardcode_into_libs=no + +# when you set need_version to no, make sure it does not cause -set_version +# flags to be left without arguments +need_version=unknown + +case $host_os in +aix3*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' + shlibpath_var=LIBPATH + + # AIX 3 has no versioning support, so we append a major version to the name. + soname_spec='${libname}${release}${shared_ext}$major' + ;; + +aix4* | aix5*) + version_type=linux + need_lib_prefix=no + need_version=no + hardcode_into_libs=yes + if test "$host_cpu" = ia64; then + # AIX 5 supports IA64 + library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + else + # With GCC up to 2.95.x, collect2 would create an import file + # for dependence libraries. The import file would start with + # the line `#! .'. This would cause the generated library to + # depend on `.', always an invalid library. This was fixed in + # development snapshots of GCC prior to 3.0. + case $host_os in + aix4 | aix4.[01] | aix4.[01].*) + if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' + echo ' yes ' + echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then + : + else + can_build_shared=no + fi + ;; + esac + # AIX (on Power*) has no versioning support, so currently we can not hardcode correct + # soname into executable. Probably we can add versioning support to + # collect2, so additional links can be useful in future. + if test "$aix_use_runtimelinking" = yes; then + # If using run time linking (on AIX 4.2 or later) use lib.so + # instead of lib.a to let people know that these are not + # typical AIX shared libraries. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + else + # We preserve .a as extension for shared libraries through AIX4.2 + # and later when we are not doing run time linking. + library_names_spec='${libname}${release}.a $libname.a' + soname_spec='${libname}${release}${shared_ext}$major' + fi + shlibpath_var=LIBPATH + fi + ;; + +amigaos*) + library_names_spec='$libname.ixlibrary $libname.a' + # Create ${libname}_ixlibrary.a entries in /sys/libs. + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' + ;; + +beos*) + library_names_spec='${libname}${shared_ext}' + dynamic_linker="$host_os ld.so" + shlibpath_var=LIBRARY_PATH + ;; + +bsdi4*) + version_type=linux + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" + sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" + # the default ld.so.conf also contains /usr/contrib/lib and + # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow + # libtool to hard-code these into programs + ;; + +cygwin* | mingw* | pw32*) + version_type=windows + shrext_cmds=".dll" + need_version=no + need_lib_prefix=no + + case $GCC,$host_os in + yes,cygwin* | yes,mingw* | yes,pw32*) + library_names_spec='$libname.dll.a' + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \${file}`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $rm \$dlpath' + shlibpath_overrides_runpath=yes + + case $host_os in + cygwin*) + # Cygwin DLLs use 'cyg' prefix rather than 'lib' + soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" + ;; + mingw*) + # MinGW DLLs use traditional 'lib' prefix + soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then + # It is most probably a Windows format PATH printed by + # mingw gcc, but we are running on Cygwin. Gcc prints its search + # path with ; separators, and with drive letters. We can handle the + # drive letters (cygwin fileutils understands them), so leave them, + # especially as we might pass files found there to a mingw objdump, + # which wouldn't understand a cygwinified path. Ahh. + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + ;; + pw32*) + # pw32 DLLs use 'pw' prefix rather than 'lib' + library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/./-/g'`${versuffix}${shared_ext}' + ;; + esac + ;; + + *) + library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' + ;; + esac + dynamic_linker='Win32 ld.exe' + # FIXME: first we should search . and the directory the executable is in + shlibpath_var=PATH + ;; + +darwin* | rhapsody*) + dynamic_linker="$host_os dyld" + version_type=darwin + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext' + soname_spec='${libname}${release}${major}$shared_ext' + shlibpath_overrides_runpath=yes + shlibpath_var=DYLD_LIBRARY_PATH + shrext_cmds='$(test .$module = .yes && echo .so || echo .dylib)' + # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same. + if test "$GCC" = yes; then + sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"` + else + sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib' + fi + sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' + ;; + +dgux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +freebsd1*) + dynamic_linker=no + ;; + +kfreebsd*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='GNU ld.so' + ;; + +freebsd*) + objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout` + version_type=freebsd-$objformat + case $version_type in + freebsd-elf*) + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + need_version=no + need_lib_prefix=no + ;; + freebsd-*) + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' + need_version=yes + ;; + esac + shlibpath_var=LD_LIBRARY_PATH + case $host_os in + freebsd2*) + shlibpath_overrides_runpath=yes + ;; + freebsd3.01* | freebsdelf3.01*) + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + *) # from 3.2 on + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + esac + ;; + +gnu*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + hardcode_into_libs=yes + ;; + +hpux9* | hpux10* | hpux11*) + # Give a soname corresponding to the major version so that dld.sl refuses to + # link against other versions. + version_type=sunos + need_lib_prefix=no + need_version=no + case "$host_cpu" in + ia64*) + shrext_cmds='.so' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.so" + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + if test "X$HPUX_IA64_MODE" = X32; then + sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" + else + sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" + fi + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + hppa*64*) + shrext_cmds='.sl' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.sl" + shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + *) + shrext_cmds='.sl' + dynamic_linker="$host_os dld.sl" + shlibpath_var=SHLIB_PATH + shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + ;; + esac + # HP-UX runs *really* slowly unless shared libraries are mode 555. + postinstall_cmds='chmod 555 $lib' + ;; + +irix5* | irix6* | nonstopux*) + case $host_os in + nonstopux*) version_type=nonstopux ;; + *) + if test "$lt_cv_prog_gnu_ld" = yes; then + version_type=linux + else + version_type=irix + fi ;; + esac + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' + case $host_os in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in # libtool.m4 will add one of these switches to LD + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") + libsuff= shlibsuff= libmagic=32-bit;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") + libsuff=32 shlibsuff=N32 libmagic=N32;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") + libsuff=64 shlibsuff=64 libmagic=64-bit;; + *) libsuff= shlibsuff= libmagic=never-match;; + esac + ;; + esac + shlibpath_var=LD_LIBRARY${shlibsuff}_PATH + shlibpath_overrides_runpath=no + sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" + sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" + hardcode_into_libs=yes + ;; + +# No shared lib support for Linux oldld, aout, or coff. +linux*oldld* | linux*aout* | linux*coff*) + dynamic_linker=no + ;; + +# This must be Linux ELF. +linux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + # find out which ABI we are using + libsuff= + case "$host_cpu" in + x86_64*|s390x*|powerpc64*) + echo '#line 14088 "configure"' > conftest.$ac_ext + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + case `/usr/bin/file conftest.$ac_objext` in + *64-bit*) + libsuff=64 + sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}" + ;; + esac + fi + rm -rf conftest* + ;; + esac + + # Append ld.so.conf contents to the search path + if test -f /etc/ld.so.conf; then + lt_ld_extra=`$SED -e 's/:,\t/ /g;s/=^=*$//;s/=^= * / /g' /etc/ld.so.conf | tr '\n' ' '` + sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra" + fi + + # We used to test for /lib/ld.so.1 and disable shared libraries on + # powerpc, because MkLinux only supported shared libraries with the + # GNU dynamic linker. Since this was broken with cross compilers, + # most powerpc-linux boxes support dynamic linking these days and + # people can always --disable-shared, the test was removed, and we + # assume the GNU/Linux dynamic linker is in use. + dynamic_linker='GNU/Linux ld.so' + ;; + +knetbsd*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='GNU ld.so' + ;; + +netbsd*) + version_type=sunos + need_lib_prefix=no + need_version=no + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + dynamic_linker='NetBSD (a.out) ld.so' + else + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='NetBSD ld.elf_so' + fi + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + +newsos6) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +nto-qnx*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +openbsd*) + version_type=sunos + need_lib_prefix=no + need_version=yes + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + case $host_os in + openbsd2.[89] | openbsd2.[89].*) + shlibpath_overrides_runpath=no + ;; + *) + shlibpath_overrides_runpath=yes + ;; + esac + else + shlibpath_overrides_runpath=yes + fi + ;; + +os2*) + libname_spec='$name' + shrext_cmds=".dll" + need_lib_prefix=no + library_names_spec='$libname${shared_ext} $libname.a' + dynamic_linker='OS/2 ld.exe' + shlibpath_var=LIBPATH + ;; + +osf3* | osf4* | osf5*) + version_type=osf + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" + sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" + ;; + +sco3.2v5*) + version_type=osf + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + ;; + +solaris*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + # ldd complains unless libraries are executable + postinstall_cmds='chmod +x $lib' + ;; + +sunos4*) + version_type=sunos + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + if test "$with_gnu_ld" = yes; then + need_lib_prefix=no + fi + need_version=yes + ;; + +sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + case $host_vendor in + sni) + shlibpath_overrides_runpath=no + need_lib_prefix=no + export_dynamic_flag_spec='${wl}-Blargedynsym' + runpath_var=LD_RUN_PATH + ;; + siemens) + need_lib_prefix=no + ;; + motorola) + need_lib_prefix=no + need_version=no + shlibpath_overrides_runpath=no + sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' + ;; + esac + ;; + +sysv4*MP*) + if test -d /usr/nec ;then + version_type=linux + library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' + soname_spec='$libname${shared_ext}.$major' + shlibpath_var=LD_LIBRARY_PATH + fi + ;; + +uts4*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +*) + dynamic_linker=no + ;; +esac +echo "$as_me:$LINENO: result: $dynamic_linker" >&5 +echo "${ECHO_T}$dynamic_linker" >&6 +test "$dynamic_linker" = no && can_build_shared=no + +echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5 +echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6 +hardcode_action_F77= +if test -n "$hardcode_libdir_flag_spec_F77" || \ + test -n "$runpath_var F77" || \ + test "X$hardcode_automatic_F77"="Xyes" ; then + + # We can hardcode non-existant directories. + if test "$hardcode_direct_F77" != no && + # If the only mechanism to avoid hardcoding is shlibpath_var, we + # have to relink, otherwise we might link with an installed library + # when we should be linking with a yet-to-be-installed one + ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, F77)" != no && + test "$hardcode_minus_L_F77" != no; then + # Linking always hardcodes the temporary library directory. + hardcode_action_F77=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + hardcode_action_F77=immediate + fi +else + # We cannot hardcode anything, or else we can only hardcode existing + # directories. + hardcode_action_F77=unsupported +fi +echo "$as_me:$LINENO: result: $hardcode_action_F77" >&5 +echo "${ECHO_T}$hardcode_action_F77" >&6 + +if test "$hardcode_action_F77" = relink; then + # Fast installation is not supported + enable_fast_install=no +elif test "$shlibpath_overrides_runpath" = yes || + test "$enable_shared" = no; then + # Fast installation is not necessary + enable_fast_install=needless +fi + +striplib= +old_striplib= +echo "$as_me:$LINENO: checking whether stripping libraries is possible" >&5 +echo $ECHO_N "checking whether stripping libraries is possible... $ECHO_C" >&6 +if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then + test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" + test -z "$striplib" && striplib="$STRIP --strip-unneeded" + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 +else +# FIXME - insert some real tests, host_os isn't really good enough + case $host_os in + darwin*) + if test -n "$STRIP" ; then + striplib="$STRIP -x" + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + ;; + *) + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + ;; + esac +fi + + + +# The else clause should only fire when bootstrapping the +# libtool distribution, otherwise you forgot to ship ltmain.sh +# with your package, and you will get complaints that there are +# no rules to generate ltmain.sh. +if test -f "$ltmain"; then + # See if we are running on zsh, and set the options which allow our commands through + # without removal of \ escapes. + if test -n "${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST + fi + # Now quote all the things that may contain metacharacters while being + # careful not to overquote the AC_SUBSTed values. We take copies of the + # variables and quote the copies for generation of the libtool script. + for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC NM \ + SED SHELL STRIP \ + libname_spec library_names_spec soname_spec extract_expsyms_cmds \ + old_striplib striplib file_magic_cmd finish_cmds finish_eval \ + deplibs_check_method reload_flag reload_cmds need_locks \ + lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \ + lt_cv_sys_global_symbol_to_c_name_address \ + sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ + old_postinstall_cmds old_postuninstall_cmds \ + compiler_F77 \ + CC_F77 \ + LD_F77 \ + lt_prog_compiler_wl_F77 \ + lt_prog_compiler_pic_F77 \ + lt_prog_compiler_static_F77 \ + lt_prog_compiler_no_builtin_flag_F77 \ + export_dynamic_flag_spec_F77 \ + thread_safe_flag_spec_F77 \ + whole_archive_flag_spec_F77 \ + enable_shared_with_static_runtimes_F77 \ + old_archive_cmds_F77 \ + old_archive_from_new_cmds_F77 \ + predep_objects_F77 \ + postdep_objects_F77 \ + predeps_F77 \ + postdeps_F77 \ + compiler_lib_search_path_F77 \ + archive_cmds_F77 \ + archive_expsym_cmds_F77 \ + postinstall_cmds_F77 \ + postuninstall_cmds_F77 \ + old_archive_from_expsyms_cmds_F77 \ + allow_undefined_flag_F77 \ + no_undefined_flag_F77 \ + export_symbols_cmds_F77 \ + hardcode_libdir_flag_spec_F77 \ + hardcode_libdir_flag_spec_ld_F77 \ + hardcode_libdir_separator_F77 \ + hardcode_automatic_F77 \ + module_cmds_F77 \ + module_expsym_cmds_F77 \ + lt_cv_prog_compiler_c_o_F77 \ + exclude_expsyms_F77 \ + include_expsyms_F77; do + + case $var in + old_archive_cmds_F77 | \ + old_archive_from_new_cmds_F77 | \ + archive_cmds_F77 | \ + archive_expsym_cmds_F77 | \ + module_cmds_F77 | \ + module_expsym_cmds_F77 | \ + old_archive_from_expsyms_cmds_F77 | \ + export_symbols_cmds_F77 | \ + extract_expsyms_cmds | reload_cmds | finish_cmds | \ + postinstall_cmds | postuninstall_cmds | \ + old_postinstall_cmds | old_postuninstall_cmds | \ + sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) + # Double-quote double-evaled strings. + eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" + ;; + *) + eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" + ;; + esac + done + + case $lt_echo in + *'\$0 --fallback-echo"') + lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'` + ;; + esac + +cfgfile="$ofile" + + cat <<__EOF__ >> "$cfgfile" +# ### BEGIN LIBTOOL TAG CONFIG: $tagname + +# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: + +# Shell to use when invoking shell scripts. +SHELL=$lt_SHELL + +# Whether or not to build shared libraries. +build_libtool_libs=$enable_shared + +# Whether or not to build static libraries. +build_old_libs=$enable_static + +# Whether or not to add -lc for building shared libraries. +build_libtool_need_lc=$archive_cmds_need_lc_F77 + +# Whether or not to disallow shared libs when runtime libs are static +allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_F77 + +# Whether or not to optimize for fast installation. +fast_install=$enable_fast_install + +# The host system. +host_alias=$host_alias +host=$host + +# An echo program that does not interpret backslashes. +echo=$lt_echo + +# The archiver. +AR=$lt_AR +AR_FLAGS=$lt_AR_FLAGS + +# A C compiler. +LTCC=$lt_LTCC + +# A language-specific compiler. +CC=$lt_compiler_F77 + +# Is the compiler the GNU C compiler? +with_gcc=$GCC_F77 + +# An ERE matcher. +EGREP=$lt_EGREP + +# The linker used to build libraries. +LD=$lt_LD_F77 + +# Whether we need hard or soft links. +LN_S=$lt_LN_S + +# A BSD-compatible nm program. +NM=$lt_NM + +# A symbol stripping program +STRIP=$lt_STRIP + +# Used to examine libraries when file_magic_cmd begins "file" +MAGIC_CMD=$MAGIC_CMD + +# Used on cygwin: DLL creation program. +DLLTOOL="$DLLTOOL" + +# Used on cygwin: object dumper. +OBJDUMP="$OBJDUMP" + +# Used on cygwin: assembler. +AS="$AS" + +# The name of the directory that contains temporary libtool files. +objdir=$objdir + +# How to create reloadable object files. +reload_flag=$lt_reload_flag +reload_cmds=$lt_reload_cmds + +# How to pass a linker flag through the compiler. +wl=$lt_lt_prog_compiler_wl_F77 + +# Object file suffix (normally "o"). +objext="$ac_objext" + +# Old archive suffix (normally "a"). +libext="$libext" + +# Shared library suffix (normally ".so"). +shrext_cmds='$shrext_cmds' + +# Executable file suffix (normally ""). +exeext="$exeext" + +# Additional compiler flags for building library objects. +pic_flag=$lt_lt_prog_compiler_pic_F77 +pic_mode=$pic_mode + +# What is the maximum length of a command? +max_cmd_len=$lt_cv_sys_max_cmd_len + +# Does compiler simultaneously support -c and -o options? +compiler_c_o=$lt_lt_cv_prog_compiler_c_o_F77 + +# Must we lock files when doing compilation ? +need_locks=$lt_need_locks + +# Do we need the lib prefix for modules? +need_lib_prefix=$need_lib_prefix + +# Do we need a version for libraries? +need_version=$need_version + +# Whether dlopen is supported. +dlopen_support=$enable_dlopen + +# Whether dlopen of programs is supported. +dlopen_self=$enable_dlopen_self + +# Whether dlopen of statically linked programs is supported. +dlopen_self_static=$enable_dlopen_self_static + +# Compiler flag to prevent dynamic linking. +link_static_flag=$lt_lt_prog_compiler_static_F77 + +# Compiler flag to turn off builtin functions. +no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_F77 + +# Compiler flag to allow reflexive dlopens. +export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_F77 + +# Compiler flag to generate shared objects directly from archives. +whole_archive_flag_spec=$lt_whole_archive_flag_spec_F77 + +# Compiler flag to generate thread-safe objects. +thread_safe_flag_spec=$lt_thread_safe_flag_spec_F77 + +# Library versioning type. +version_type=$version_type + +# Format of library name prefix. +libname_spec=$lt_libname_spec + +# List of archive names. First name is the real one, the rest are links. +# The last name is the one that the linker finds with -lNAME. +library_names_spec=$lt_library_names_spec + +# The coded name of the library, if different from the real name. +soname_spec=$lt_soname_spec + +# Commands used to build and install an old-style archive. +RANLIB=$lt_RANLIB +old_archive_cmds=$lt_old_archive_cmds_F77 +old_postinstall_cmds=$lt_old_postinstall_cmds +old_postuninstall_cmds=$lt_old_postuninstall_cmds + +# Create an old-style archive from a shared archive. +old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_F77 + +# Create a temporary old-style archive to link instead of a shared archive. +old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_F77 + +# Commands used to build and install a shared archive. +archive_cmds=$lt_archive_cmds_F77 +archive_expsym_cmds=$lt_archive_expsym_cmds_F77 +postinstall_cmds=$lt_postinstall_cmds +postuninstall_cmds=$lt_postuninstall_cmds + +# Commands used to build a loadable module (assumed same as above if empty) +module_cmds=$lt_module_cmds_F77 +module_expsym_cmds=$lt_module_expsym_cmds_F77 + +# Commands to strip libraries. +old_striplib=$lt_old_striplib +striplib=$lt_striplib + +# Dependencies to place before the objects being linked to create a +# shared library. +predep_objects=$lt_predep_objects_F77 + +# Dependencies to place after the objects being linked to create a +# shared library. +postdep_objects=$lt_postdep_objects_F77 + +# Dependencies to place before the objects being linked to create a +# shared library. +predeps=$lt_predeps_F77 + +# Dependencies to place after the objects being linked to create a +# shared library. +postdeps=$lt_postdeps_F77 + +# The library search path used internally by the compiler when linking +# a shared library. +compiler_lib_search_path=$lt_compiler_lib_search_path_F77 + +# Method to check whether dependent libraries are shared objects. +deplibs_check_method=$lt_deplibs_check_method + +# Command to use when deplibs_check_method == file_magic. +file_magic_cmd=$lt_file_magic_cmd + +# Flag that allows shared libraries with undefined symbols to be built. +allow_undefined_flag=$lt_allow_undefined_flag_F77 + +# Flag that forces no undefined symbols. +no_undefined_flag=$lt_no_undefined_flag_F77 + +# Commands used to finish a libtool library installation in a directory. +finish_cmds=$lt_finish_cmds + +# Same as above, but a single script fragment to be evaled but not shown. +finish_eval=$lt_finish_eval + +# Take the output of nm and produce a listing of raw symbols and C names. +global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe + +# Transform the output of nm in a proper C declaration +global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl + +# Transform the output of nm in a C name address pair +global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address + +# This is the shared library runtime path variable. +runpath_var=$runpath_var + +# This is the shared library path variable. +shlibpath_var=$shlibpath_var + +# Is shlibpath searched before the hard-coded library search path? +shlibpath_overrides_runpath=$shlibpath_overrides_runpath + +# How to hardcode a shared library path into an executable. +hardcode_action=$hardcode_action_F77 + +# Whether we should hardcode library paths into libraries. +hardcode_into_libs=$hardcode_into_libs + +# Flag to hardcode \$libdir into a binary during linking. +# This must work even if \$libdir does not exist. +hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_F77 + +# If ld is used when linking, flag to hardcode \$libdir into +# a binary during linking. This must work even if \$libdir does +# not exist. +hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_F77 + +# Whether we need a single -rpath flag with a separated argument. +hardcode_libdir_separator=$lt_hardcode_libdir_separator_F77 + +# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the +# resulting binary. +hardcode_direct=$hardcode_direct_F77 + +# Set to yes if using the -LDIR flag during linking hardcodes DIR into the +# resulting binary. +hardcode_minus_L=$hardcode_minus_L_F77 + +# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into +# the resulting binary. +hardcode_shlibpath_var=$hardcode_shlibpath_var_F77 + +# Set to yes if building a shared library automatically hardcodes DIR into the library +# and all subsequent libraries and executables linked against it. +hardcode_automatic=$hardcode_automatic_F77 + +# Variables whose values should be saved in libtool wrapper scripts and +# restored at relink time. +variables_saved_for_relink="$variables_saved_for_relink" + +# Whether libtool must link a program against all its dependency libraries. +link_all_deplibs=$link_all_deplibs_F77 + +# Compile-time system search path for libraries +sys_lib_search_path_spec=$lt_sys_lib_search_path_spec + +# Run-time system search path for libraries +sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec + +# Fix the shell variable \$srcfile for the compiler. +fix_srcfile_path="$fix_srcfile_path_F77" + +# Set to yes if exported symbols are required. +always_export_symbols=$always_export_symbols_F77 + +# The commands to list exported symbols. +export_symbols_cmds=$lt_export_symbols_cmds_F77 + +# The commands to extract the exported symbol list from a shared archive. +extract_expsyms_cmds=$lt_extract_expsyms_cmds + +# Symbols that should not be listed in the preloaded symbols. +exclude_expsyms=$lt_exclude_expsyms_F77 + +# Symbols that must always be exported. +include_expsyms=$lt_include_expsyms_F77 + +# ### END LIBTOOL TAG CONFIG: $tagname + +__EOF__ + + +else + # If there is no Makefile yet, we rely on a make rule to execute + # `config.status --recheck' to rerun these tests and create the + # libtool script then. + ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'` + if test -f "$ltmain_in"; then + test -f Makefile && make "$ltmain" + fi +fi + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +CC="$lt_save_CC" + + else + tagname="" + fi + ;; + + GCJ) + if test -n "$GCJ" && test "X$GCJ" != "Xno"; then + + + +# Source file extension for Java test sources. +ac_ext=java + +# Object file extension for compiled Java test sources. +objext=o +objext_GCJ=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="class foo {}\n" + +# Code to be used in simple link tests +lt_simple_link_test_code='public class conftest { public static void main(String argv) {}; }\n' + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# Allow CC to be a program name with arguments. +compiler=$CC + + +# Allow CC to be a program name with arguments. +lt_save_CC="$CC" +CC=${GCJ-"gcj"} +compiler=$CC +compiler_GCJ=$CC + +# GCJ did not exist at the time GCC didn't implicitly link libc in. +archive_cmds_need_lc_GCJ=no + + +lt_prog_compiler_no_builtin_flag_GCJ= + +if test "$GCC" = yes; then + lt_prog_compiler_no_builtin_flag_GCJ=' -fno-builtin' + + +echo "$as_me:$LINENO: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 +echo $ECHO_N "checking if $compiler supports -fno-rtti -fno-exceptions... $ECHO_C" >&6 +if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + lt_cv_prog_compiler_rtti_exceptions=no + ac_outfile=conftest.$ac_objext + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="-fno-rtti -fno-exceptions" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:14829: $lt_compile\"" >&5) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&5 + echo "$as_me:14833: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + if test ! -s conftest.err; then + lt_cv_prog_compiler_rtti_exceptions=yes + fi + fi + $rm conftest* + +fi +echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 +echo "${ECHO_T}$lt_cv_prog_compiler_rtti_exceptions" >&6 + +if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then + lt_prog_compiler_no_builtin_flag_GCJ="$lt_prog_compiler_no_builtin_flag_GCJ -fno-rtti -fno-exceptions" +else + : +fi + +fi + +lt_prog_compiler_wl_GCJ= +lt_prog_compiler_pic_GCJ= +lt_prog_compiler_static_GCJ= + +echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5 +echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6 + + if test "$GCC" = yes; then + lt_prog_compiler_wl_GCJ='-Wl,' + lt_prog_compiler_static_GCJ='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static_GCJ='-Bstatic' + fi + ;; + + amigaos*) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the `-m68020' flag to GCC prevents building anything better, + # like `-m68040'. + lt_prog_compiler_pic_GCJ='-m68020 -resident32 -malways-restore-a4' + ;; + + beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + + mingw* | pw32* | os2*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + lt_prog_compiler_pic_GCJ='-DDLL_EXPORT' + ;; + + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + lt_prog_compiler_pic_GCJ='-fno-common' + ;; + + msdosdjgpp*) + # Just because we use GCC doesn't mean we suddenly get shared libraries + # on systems that don't support them. + lt_prog_compiler_can_build_shared_GCJ=no + enable_shared=no + ;; + + sysv4*MP*) + if test -d /usr/nec; then + lt_prog_compiler_pic_GCJ=-Kconform_pic + fi + ;; + + hpux*) + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case "$host_cpu" in + hppa*64*|ia64*) + # +Z the default + ;; + *) + lt_prog_compiler_pic_GCJ='-fPIC' + ;; + esac + ;; + + *) + lt_prog_compiler_pic_GCJ='-fPIC' + ;; + esac + else + # PORTME Check for flag to pass linker flags through the system compiler. + case $host_os in + aix*) + lt_prog_compiler_wl_GCJ='-Wl,' + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static_GCJ='-Bstatic' + else + lt_prog_compiler_static_GCJ='-bnso -bI:/lib/syscalls.exp' + fi + ;; + + mingw* | pw32* | os2*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + lt_prog_compiler_pic_GCJ='-DDLL_EXPORT' + ;; + + hpux9* | hpux10* | hpux11*) + lt_prog_compiler_wl_GCJ='-Wl,' + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case "$host_cpu" in + hppa*64*|ia64*) + # +Z the default + ;; + *) + lt_prog_compiler_pic_GCJ='+Z' + ;; + esac + # Is there a better lt_prog_compiler_static that works with the bundled CC? + lt_prog_compiler_static_GCJ='${wl}-a ${wl}archive' + ;; + + irix5* | irix6* | nonstopux*) + lt_prog_compiler_wl_GCJ='-Wl,' + # PIC (with -KPIC) is the default. + lt_prog_compiler_static_GCJ='-non_shared' + ;; + + newsos6) + lt_prog_compiler_pic_GCJ='-KPIC' + lt_prog_compiler_static_GCJ='-Bstatic' + ;; + + linux*) + case $CC in + icc* | ecc*) + lt_prog_compiler_wl_GCJ='-Wl,' + lt_prog_compiler_pic_GCJ='-KPIC' + lt_prog_compiler_static_GCJ='-static' + ;; + ccc*) + lt_prog_compiler_wl_GCJ='-Wl,' + # All Alpha code is PIC. + lt_prog_compiler_static_GCJ='-non_shared' + ;; + esac + ;; + + osf3* | osf4* | osf5*) + lt_prog_compiler_wl_GCJ='-Wl,' + # All OSF/1 code is PIC. + lt_prog_compiler_static_GCJ='-non_shared' + ;; + + sco3.2v5*) + lt_prog_compiler_pic_GCJ='-Kpic' + lt_prog_compiler_static_GCJ='-dn' + ;; + + solaris*) + lt_prog_compiler_wl_GCJ='-Wl,' + lt_prog_compiler_pic_GCJ='-KPIC' + lt_prog_compiler_static_GCJ='-Bstatic' + ;; + + sunos4*) + lt_prog_compiler_wl_GCJ='-Qoption ld ' + lt_prog_compiler_pic_GCJ='-PIC' + lt_prog_compiler_static_GCJ='-Bstatic' + ;; + + sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + lt_prog_compiler_wl_GCJ='-Wl,' + lt_prog_compiler_pic_GCJ='-KPIC' + lt_prog_compiler_static_GCJ='-Bstatic' + ;; + + sysv4*MP*) + if test -d /usr/nec ;then + lt_prog_compiler_pic_GCJ='-Kconform_pic' + lt_prog_compiler_static_GCJ='-Bstatic' + fi + ;; + + uts4*) + lt_prog_compiler_pic_GCJ='-pic' + lt_prog_compiler_static_GCJ='-Bstatic' + ;; + + *) + lt_prog_compiler_can_build_shared_GCJ=no + ;; + esac + fi + +echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_GCJ" >&5 +echo "${ECHO_T}$lt_prog_compiler_pic_GCJ" >&6 + +# +# Check to make sure the PIC flag actually works. +# +if test -n "$lt_prog_compiler_pic_GCJ"; then + +echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_GCJ works" >&5 +echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_GCJ works... $ECHO_C" >&6 +if test "${lt_prog_compiler_pic_works_GCJ+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + lt_prog_compiler_pic_works_GCJ=no + ac_outfile=conftest.$ac_objext + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="$lt_prog_compiler_pic_GCJ" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:15062: $lt_compile\"" >&5) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&5 + echo "$as_me:15066: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + if test ! -s conftest.err; then + lt_prog_compiler_pic_works_GCJ=yes + fi + fi + $rm conftest* + +fi +echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works_GCJ" >&5 +echo "${ECHO_T}$lt_prog_compiler_pic_works_GCJ" >&6 + +if test x"$lt_prog_compiler_pic_works_GCJ" = xyes; then + case $lt_prog_compiler_pic_GCJ in + "" | " "*) ;; + *) lt_prog_compiler_pic_GCJ=" $lt_prog_compiler_pic_GCJ" ;; + esac +else + lt_prog_compiler_pic_GCJ= + lt_prog_compiler_can_build_shared_GCJ=no +fi + +fi +case "$host_os" in + # For platforms which do not support PIC, -DPIC is meaningless: + *djgpp*) + lt_prog_compiler_pic_GCJ= + ;; + *) + lt_prog_compiler_pic_GCJ="$lt_prog_compiler_pic_GCJ" + ;; +esac + +echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5 +echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6 +if test "${lt_cv_prog_compiler_c_o_GCJ+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + lt_cv_prog_compiler_c_o_GCJ=no + $rm -r conftest 2>/dev/null + mkdir conftest + cd conftest + mkdir out + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + + lt_compiler_flag="-o out/conftest2.$ac_objext" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:15122: $lt_compile\"" >&5) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&5 + echo "$as_me:15126: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + if test ! -s out/conftest.err; then + lt_cv_prog_compiler_c_o_GCJ=yes + fi + fi + chmod u+w . + $rm conftest* + # SGI C++ compiler will create directory out/ii_files/ for + # template instantiation + test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files + $rm out/* && rmdir out + cd .. + rmdir conftest + $rm conftest* + +fi +echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_GCJ" >&5 +echo "${ECHO_T}$lt_cv_prog_compiler_c_o_GCJ" >&6 + + +hard_links="nottested" +if test "$lt_cv_prog_compiler_c_o_GCJ" = no && test "$need_locks" != no; then + # do not overwrite the value of need_locks provided by the user + echo "$as_me:$LINENO: checking if we can lock with hard links" >&5 +echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6 + hard_links=yes + $rm conftest* + ln conftest.a conftest.b 2>/dev/null && hard_links=no + touch conftest.a + ln conftest.a conftest.b 2>&5 || hard_links=no + ln conftest.a conftest.b 2>/dev/null && hard_links=no + echo "$as_me:$LINENO: result: $hard_links" >&5 +echo "${ECHO_T}$hard_links" >&6 + if test "$hard_links" = no; then + { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 +echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} + need_locks=warn + fi +else + need_locks=no +fi + +echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5 +echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6 + + runpath_var= + allow_undefined_flag_GCJ= + enable_shared_with_static_runtimes_GCJ=no + archive_cmds_GCJ= + archive_expsym_cmds_GCJ= + old_archive_From_new_cmds_GCJ= + old_archive_from_expsyms_cmds_GCJ= + export_dynamic_flag_spec_GCJ= + whole_archive_flag_spec_GCJ= + thread_safe_flag_spec_GCJ= + hardcode_libdir_flag_spec_GCJ= + hardcode_libdir_flag_spec_ld_GCJ= + hardcode_libdir_separator_GCJ= + hardcode_direct_GCJ=no + hardcode_minus_L_GCJ=no + hardcode_shlibpath_var_GCJ=unsupported + link_all_deplibs_GCJ=unknown + hardcode_automatic_GCJ=no + module_cmds_GCJ= + module_expsym_cmds_GCJ= + always_export_symbols_GCJ=no + export_symbols_cmds_GCJ='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + # include_expsyms should be a list of space-separated symbols to be *always* + # included in the symbol list + include_expsyms_GCJ= + # exclude_expsyms can be an extended regexp of symbols to exclude + # it will be wrapped by ` (' and `)$', so one must not match beginning or + # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', + # as well as any symbol that contains `d'. + exclude_expsyms_GCJ="_GLOBAL_OFFSET_TABLE_" + # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out + # platforms (ab)use it in PIC code, but their linkers get confused if + # the symbol is explicitly referenced. Since portable code cannot + # rely on this symbol name, it's probably fine to never include it in + # preloaded symbol tables. + extract_expsyms_cmds= + + case $host_os in + cygwin* | mingw* | pw32*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + if test "$GCC" != yes; then + with_gnu_ld=no + fi + ;; + openbsd*) + with_gnu_ld=no + ;; + esac + + ld_shlibs_GCJ=yes + if test "$with_gnu_ld" = yes; then + # If archive_cmds runs LD, not CC, wlarc should be empty + wlarc='${wl}' + + # See if GNU ld supports shared libraries. + case $host_os in + aix3* | aix4* | aix5*) + # On AIX/PPC, the GNU linker is very broken + if test "$host_cpu" != ia64; then + ld_shlibs_GCJ=no + cat <&2 + +*** Warning: the GNU linker, at least up to release 2.9.1, is reported +*** to be unable to reliably create shared libraries on AIX. +*** Therefore, libtool is disabling shared libraries support. If you +*** really care for shared libraries, you may want to modify your PATH +*** so that a non-GNU linker is found, and then restart. + +EOF + fi + ;; + + amigaos*) + archive_cmds_GCJ='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec_GCJ='-L$libdir' + hardcode_minus_L_GCJ=yes + + # Samuel A. Falvo II reports + # that the semantics of dynamic libraries on AmigaOS, at least up + # to version 4, is to share data among multiple programs linked + # with the same dynamic library. Since this doesn't match the + # behavior of shared libraries on other platforms, we can't use + # them. + ld_shlibs_GCJ=no + ;; + + beos*) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + allow_undefined_flag_GCJ=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + archive_cmds_GCJ='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + else + ld_shlibs_GCJ=no + fi + ;; + + cygwin* | mingw* | pw32*) + # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, GCJ) is actually meaningless, + # as there is no search path for DLLs. + hardcode_libdir_flag_spec_GCJ='-L$libdir' + allow_undefined_flag_GCJ=unsupported + always_export_symbols_GCJ=no + enable_shared_with_static_runtimes_GCJ=yes + export_symbols_cmds_GCJ='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols' + + if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then + archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib' + # If the export-symbols file already is a .def file (1st line + # is EXPORTS), use it as is; otherwise, prepend... + archive_expsym_cmds_GCJ='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib' + else + ld_shlibs=no + fi + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + archive_cmds_GCJ='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' + wlarc= + else + archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + fi + ;; + + solaris* | sysv5*) + if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then + ld_shlibs_GCJ=no + cat <&2 + +*** Warning: The releases 2.8.* of the GNU linker cannot reliably +*** create shared libraries on Solaris systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.9.1 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +EOF + elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs_GCJ=no + fi + ;; + + sunos4*) + archive_cmds_GCJ='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' + wlarc= + hardcode_direct_GCJ=yes + hardcode_shlibpath_var_GCJ=no + ;; + + linux*) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + tmp_archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_cmds_GCJ="$tmp_archive_cmds" + supports_anon_versioning=no + case `$LD -v 2>/dev/null` in + *\ 01.* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 + *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... + *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... + *\ 2.11.*) ;; # other 2.11 versions + *) supports_anon_versioning=yes ;; + esac + if test $supports_anon_versioning = yes; then + archive_expsym_cmds_GCJ='$echo "{ global:" > $output_objdir/$libname.ver~ +cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ +$echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' + else + archive_expsym_cmds_GCJ="$tmp_archive_cmds" + fi + else + ld_shlibs_GCJ=no + fi + ;; + + *) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs_GCJ=no + fi + ;; + esac + + if test "$ld_shlibs_GCJ" = yes; then + runpath_var=LD_RUN_PATH + hardcode_libdir_flag_spec_GCJ='${wl}--rpath ${wl}$libdir' + export_dynamic_flag_spec_GCJ='${wl}--export-dynamic' + # ancient GNU ld didn't support --whole-archive et. al. + if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then + whole_archive_flag_spec_GCJ="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + whole_archive_flag_spec_GCJ= + fi + fi + else + # PORTME fill in a description of your system's linker (not GNU ld) + case $host_os in + aix3*) + allow_undefined_flag_GCJ=unsupported + always_export_symbols_GCJ=yes + archive_expsym_cmds_GCJ='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + hardcode_minus_L_GCJ=yes + if test "$GCC" = yes && test -z "$link_static_flag"; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + hardcode_direct_GCJ=unsupported + fi + ;; + + aix4* | aix5*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag="" + else + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to AIX nm, but means don't demangle with GNU nm + if $NM -V 2>&1 | grep 'GNU' > /dev/null; then + export_symbols_cmds_GCJ='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' + else + export_symbols_cmds_GCJ='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' + fi + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[23]|aix4.[23].*|aix5*) + for ld_flag in $LDFLAGS; do + if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then + aix_use_runtimelinking=yes + break + fi + done + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + archive_cmds_GCJ='' + hardcode_direct_GCJ=yes + hardcode_libdir_separator_GCJ=':' + link_all_deplibs_GCJ=yes + + if test "$GCC" = yes; then + case $host_os in aix4.012|aix4.012.*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && \ + strings "$collect2name" | grep resolve_lib_name >/dev/null + then + # We have reworked collect2 + hardcode_direct_GCJ=yes + else + # We have old collect2 + hardcode_direct_GCJ=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + hardcode_minus_L_GCJ=yes + hardcode_libdir_flag_spec_GCJ='-L$libdir' + hardcode_libdir_separator_GCJ= + fi + esac + shared_flag='-shared' + else + # not using gcc + if test "$host_cpu" = ia64; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test "$aix_use_runtimelinking" = yes; then + shared_flag='${wl}-G' + else + shared_flag='${wl}-bM:SRE' + fi + fi + fi + + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to export. + always_export_symbols_GCJ=yes + if test "$aix_use_runtimelinking" = yes; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + allow_undefined_flag_GCJ='-berok' + # Determine the default libpath from the value encoded in an empty executable. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'`; fi +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi + + hardcode_libdir_flag_spec_GCJ='${wl}-blibpath:$libdir:'"$aix_libpath" + archive_expsym_cmds_GCJ="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag" + else + if test "$host_cpu" = ia64; then + hardcode_libdir_flag_spec_GCJ='${wl}-R $libdir:/usr/lib:/lib' + allow_undefined_flag_GCJ="-z nodefs" + archive_expsym_cmds_GCJ="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an empty executable. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'`; fi +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi + + hardcode_libdir_flag_spec_GCJ='${wl}-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + no_undefined_flag_GCJ=' ${wl}-bernotok' + allow_undefined_flag_GCJ=' ${wl}-berok' + # -bexpall does not export symbols beginning with underscore (_) + always_export_symbols_GCJ=yes + # Exported symbols can be pulled into shared objects from archives + whole_archive_flag_spec_GCJ=' ' + archive_cmds_need_lc_GCJ=yes + # This is similar to how AIX traditionally builds it's shared libraries. + archive_expsym_cmds_GCJ="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' + fi + fi + ;; + + amigaos*) + archive_cmds_GCJ='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec_GCJ='-L$libdir' + hardcode_minus_L_GCJ=yes + # see comment about different semantics on the GNU ld section + ld_shlibs_GCJ=no + ;; + + bsdi4*) + export_dynamic_flag_spec_GCJ=-rdynamic + ;; + + cygwin* | mingw* | pw32*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + hardcode_libdir_flag_spec_GCJ=' ' + allow_undefined_flag_GCJ=unsupported + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=".dll" + # FIXME: Setting linknames here is a bad hack. + archive_cmds_GCJ='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames=' + # The linker will automatically build a .lib file if we build a DLL. + old_archive_From_new_cmds_GCJ='true' + # FIXME: Should let the user specify the lib program. + old_archive_cmds_GCJ='lib /OUT:$oldlib$oldobjs$old_deplibs' + fix_srcfile_path='`cygpath -w "$srcfile"`' + enable_shared_with_static_runtimes_GCJ=yes + ;; + + darwin* | rhapsody*) + if test "$GXX" = yes ; then + archive_cmds_need_lc_GCJ=no + case "$host_os" in + rhapsody* | darwin1.[012]) + allow_undefined_flag_GCJ='-undefined suppress' + ;; + *) # Darwin 1.3 on + if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then + allow_undefined_flag_GCJ='-flat_namespace -undefined suppress' + else + case ${MACOSX_DEPLOYMENT_TARGET} in + 10.[012]) + allow_undefined_flag_GCJ='-flat_namespace -undefined suppress' + ;; + 10.*) + allow_undefined_flag_GCJ='-undefined dynamic_lookup' + ;; + esac + fi + ;; + esac + lt_int_apple_cc_single_mod=no + output_verbose_link_cmd='echo' + if $CC -dumpspecs 2>&1 | grep 'single_module' >/dev/null ; then + lt_int_apple_cc_single_mod=yes + fi + if test "X$lt_int_apple_cc_single_mod" = Xyes ; then + archive_cmds_GCJ='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring' + else + archive_cmds_GCJ='$CC -r ${wl}-bind_at_load -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring' + fi + module_cmds_GCJ='$CC ${wl}-bind_at_load $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' + # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's + if test "X$lt_int_apple_cc_single_mod" = Xyes ; then + archive_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + else + archive_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r ${wl}-bind_at_load -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + fi + module_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + hardcode_direct_GCJ=no + hardcode_automatic_GCJ=yes + hardcode_shlibpath_var_GCJ=unsupported + whole_archive_flag_spec_GCJ='-all_load $convenience' + link_all_deplibs_GCJ=yes + else + ld_shlibs_GCJ=no + fi + ;; + + dgux*) + archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec_GCJ='-L$libdir' + hardcode_shlibpath_var_GCJ=no + ;; + + freebsd1*) + ld_shlibs_GCJ=no + ;; + + # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor + # support. Future versions do this automatically, but an explicit c++rt0.o + # does not break anything, and helps significantly (at the cost of a little + # extra space). + freebsd2.2*) + archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' + hardcode_libdir_flag_spec_GCJ='-R$libdir' + hardcode_direct_GCJ=yes + hardcode_shlibpath_var_GCJ=no + ;; + + # Unfortunately, older versions of FreeBSD 2 do not have this feature. + freebsd2*) + archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct_GCJ=yes + hardcode_minus_L_GCJ=yes + hardcode_shlibpath_var_GCJ=no + ;; + + # FreeBSD 3 and greater uses gcc -shared to do shared libraries. + freebsd* | kfreebsd*-gnu) + archive_cmds_GCJ='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec_GCJ='-R$libdir' + hardcode_direct_GCJ=yes + hardcode_shlibpath_var_GCJ=no + ;; + + hpux9*) + if test "$GCC" = yes; then + archive_cmds_GCJ='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + else + archive_cmds_GCJ='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + fi + hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir' + hardcode_libdir_separator_GCJ=: + hardcode_direct_GCJ=yes + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L_GCJ=yes + export_dynamic_flag_spec_GCJ='${wl}-E' + ;; + + hpux10* | hpux11*) + if test "$GCC" = yes -a "$with_gnu_ld" = no; then + case "$host_cpu" in + hppa*64*|ia64*) + archive_cmds_GCJ='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + archive_cmds_GCJ='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + else + case "$host_cpu" in + hppa*64*|ia64*) + archive_cmds_GCJ='$LD -b +h $soname -o $lib $libobjs $deplibs $linker_flags' + ;; + *) + archive_cmds_GCJ='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' + ;; + esac + fi + if test "$with_gnu_ld" = no; then + case "$host_cpu" in + hppa*64*) + hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir' + hardcode_libdir_flag_spec_ld_GCJ='+b $libdir' + hardcode_libdir_separator_GCJ=: + hardcode_direct_GCJ=no + hardcode_shlibpath_var_GCJ=no + ;; + ia64*) + hardcode_libdir_flag_spec_GCJ='-L$libdir' + hardcode_direct_GCJ=no + hardcode_shlibpath_var_GCJ=no + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L_GCJ=yes + ;; + *) + hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir' + hardcode_libdir_separator_GCJ=: + hardcode_direct_GCJ=yes + export_dynamic_flag_spec_GCJ='${wl}-E' + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L_GCJ=yes + ;; + esac + fi + ;; + + irix5* | irix6* | nonstopux*) + if test "$GCC" = yes; then + archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + archive_cmds_GCJ='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + hardcode_libdir_flag_spec_ld_GCJ='-rpath $libdir' + fi + hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator_GCJ=: + link_all_deplibs_GCJ=yes + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out + else + archive_cmds_GCJ='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF + fi + hardcode_libdir_flag_spec_GCJ='-R$libdir' + hardcode_direct_GCJ=yes + hardcode_shlibpath_var_GCJ=no + ;; + + newsos6) + archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct_GCJ=yes + hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator_GCJ=: + hardcode_shlibpath_var_GCJ=no + ;; + + openbsd*) + hardcode_direct_GCJ=yes + hardcode_shlibpath_var_GCJ=no + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + archive_cmds_GCJ='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec_GCJ='${wl}-rpath,$libdir' + export_dynamic_flag_spec_GCJ='${wl}-E' + else + case $host_os in + openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) + archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec_GCJ='-R$libdir' + ;; + *) + archive_cmds_GCJ='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec_GCJ='${wl}-rpath,$libdir' + ;; + esac + fi + ;; + + os2*) + hardcode_libdir_flag_spec_GCJ='-L$libdir' + hardcode_minus_L_GCJ=yes + allow_undefined_flag_GCJ=unsupported + archive_cmds_GCJ='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' + old_archive_From_new_cmds_GCJ='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' + ;; + + osf3*) + if test "$GCC" = yes; then + allow_undefined_flag_GCJ=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds_GCJ='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + allow_undefined_flag_GCJ=' -expect_unresolved \*' + archive_cmds_GCJ='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + fi + hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator_GCJ=: + ;; + + osf4* | osf5*) # as osf3* with the addition of -msym flag + if test "$GCC" = yes; then + allow_undefined_flag_GCJ=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds_GCJ='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir' + else + allow_undefined_flag_GCJ=' -expect_unresolved \*' + archive_cmds_GCJ='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + archive_expsym_cmds_GCJ='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~ + $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib~$rm $lib.exp' + + # Both c and cxx compiler support -rpath directly + hardcode_libdir_flag_spec_GCJ='-rpath $libdir' + fi + hardcode_libdir_separator_GCJ=: + ;; + + sco3.2v5*) + archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var_GCJ=no + export_dynamic_flag_spec_GCJ='${wl}-Bexport' + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + ;; + + solaris*) + no_undefined_flag_GCJ=' -z text' + if test "$GCC" = yes; then + archive_cmds_GCJ='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds_GCJ='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp' + else + archive_cmds_GCJ='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' + archive_expsym_cmds_GCJ='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' + fi + hardcode_libdir_flag_spec_GCJ='-R$libdir' + hardcode_shlibpath_var_GCJ=no + case $host_os in + solaris2.[0-5] | solaris2.[0-5].*) ;; + *) # Supported since Solaris 2.6 (maybe 2.5.1?) + whole_archive_flag_spec_GCJ='-z allextract$convenience -z defaultextract' ;; + esac + link_all_deplibs_GCJ=yes + ;; + + sunos4*) + if test "x$host_vendor" = xsequent; then + # Use $CC to link under sequent, because it throws in some extra .o + # files that make .init and .fini sections work. + archive_cmds_GCJ='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds_GCJ='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' + fi + hardcode_libdir_flag_spec_GCJ='-L$libdir' + hardcode_direct_GCJ=yes + hardcode_minus_L_GCJ=yes + hardcode_shlibpath_var_GCJ=no + ;; + + sysv4) + case $host_vendor in + sni) + archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct_GCJ=yes # is this really true??? + ;; + siemens) + ## LD is ld it makes a PLAMLIB + ## CC just makes a GrossModule. + archive_cmds_GCJ='$LD -G -o $lib $libobjs $deplibs $linker_flags' + reload_cmds_GCJ='$CC -r -o $output$reload_objs' + hardcode_direct_GCJ=no + ;; + motorola) + archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct_GCJ=no #Motorola manual says yes, but my tests say they lie + ;; + esac + runpath_var='LD_RUN_PATH' + hardcode_shlibpath_var_GCJ=no + ;; + + sysv4.3*) + archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var_GCJ=no + export_dynamic_flag_spec_GCJ='-Bexport' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var_GCJ=no + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + ld_shlibs_GCJ=yes + fi + ;; + + sysv4.2uw2*) + archive_cmds_GCJ='$LD -G -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct_GCJ=yes + hardcode_minus_L_GCJ=no + hardcode_shlibpath_var_GCJ=no + hardcode_runpath_var=yes + runpath_var=LD_RUN_PATH + ;; + + sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[78]* | unixware7*) + no_undefined_flag_GCJ='${wl}-z ${wl}text' + if test "$GCC" = yes; then + archive_cmds_GCJ='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds_GCJ='$CC -G ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + runpath_var='LD_RUN_PATH' + hardcode_shlibpath_var_GCJ=no + ;; + + sysv5*) + no_undefined_flag_GCJ=' -z text' + # $CC -shared without GNU ld will not create a library from C++ + # object files and a static libstdc++, better avoid it by now + archive_cmds_GCJ='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' + archive_expsym_cmds_GCJ='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' + hardcode_libdir_flag_spec_GCJ= + hardcode_shlibpath_var_GCJ=no + runpath_var='LD_RUN_PATH' + ;; + + uts4*) + archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec_GCJ='-L$libdir' + hardcode_shlibpath_var_GCJ=no + ;; + + *) + ld_shlibs_GCJ=no + ;; + esac + fi + +echo "$as_me:$LINENO: result: $ld_shlibs_GCJ" >&5 +echo "${ECHO_T}$ld_shlibs_GCJ" >&6 +test "$ld_shlibs_GCJ" = no && can_build_shared=no + +variables_saved_for_relink="PATH $shlibpath_var $runpath_var" +if test "$GCC" = yes; then + variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" +fi + +# +# Do we need to explicitly link libc? +# +case "x$archive_cmds_need_lc_GCJ" in +x|xyes) + # Assume -lc should be added + archive_cmds_need_lc_GCJ=yes + + if test "$enable_shared" = yes && test "$GCC" = yes; then + case $archive_cmds_GCJ in + *'~'*) + # FIXME: we may have to deal with multi-command sequences. + ;; + '$CC '*) + # Test whether the compiler implicitly links with -lc since on some + # systems, -lgcc has to come before -lc. If gcc already passes -lc + # to ld, don't add -lc before -lgcc. + echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5 +echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6 + $rm conftest* + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } 2>conftest.err; then + soname=conftest + lib=conftest + libobjs=conftest.$ac_objext + deplibs= + wl=$lt_prog_compiler_wl_GCJ + compiler_flags=-v + linker_flags=-v + verstring= + output_objdir=. + libname=conftest + lt_save_allow_undefined_flag=$allow_undefined_flag_GCJ + allow_undefined_flag_GCJ= + if { (eval echo "$as_me:$LINENO: \"$archive_cmds_GCJ 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5 + (eval $archive_cmds_GCJ 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + then + archive_cmds_need_lc_GCJ=no + else + archive_cmds_need_lc_GCJ=yes + fi + allow_undefined_flag_GCJ=$lt_save_allow_undefined_flag + else + cat conftest.err 1>&5 + fi + $rm conftest* + echo "$as_me:$LINENO: result: $archive_cmds_need_lc_GCJ" >&5 +echo "${ECHO_T}$archive_cmds_need_lc_GCJ" >&6 + ;; + esac + fi + ;; +esac + +echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5 +echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6 +library_names_spec= +libname_spec='lib$name' +soname_spec= +shrext_cmds=".so" +postinstall_cmds= +postuninstall_cmds= +finish_cmds= +finish_eval= +shlibpath_var= +shlibpath_overrides_runpath=unknown +version_type=none +dynamic_linker="$host_os ld.so" +sys_lib_dlsearch_path_spec="/lib /usr/lib" +if test "$GCC" = yes; then + sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then + # if the path contains ";" then we assume it to be the separator + # otherwise default to the standard path separator (i.e. ":") - it is + # assumed that no part of a normal pathname contains ";" but that should + # okay in the real world where ";" in dirpaths is itself problematic. + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi +else + sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" +fi +need_lib_prefix=unknown +hardcode_into_libs=no + +# when you set need_version to no, make sure it does not cause -set_version +# flags to be left without arguments +need_version=unknown + +case $host_os in +aix3*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' + shlibpath_var=LIBPATH + + # AIX 3 has no versioning support, so we append a major version to the name. + soname_spec='${libname}${release}${shared_ext}$major' + ;; + +aix4* | aix5*) + version_type=linux + need_lib_prefix=no + need_version=no + hardcode_into_libs=yes + if test "$host_cpu" = ia64; then + # AIX 5 supports IA64 + library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + else + # With GCC up to 2.95.x, collect2 would create an import file + # for dependence libraries. The import file would start with + # the line `#! .'. This would cause the generated library to + # depend on `.', always an invalid library. This was fixed in + # development snapshots of GCC prior to 3.0. + case $host_os in + aix4 | aix4.[01] | aix4.[01].*) + if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' + echo ' yes ' + echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then + : + else + can_build_shared=no + fi + ;; + esac + # AIX (on Power*) has no versioning support, so currently we can not hardcode correct + # soname into executable. Probably we can add versioning support to + # collect2, so additional links can be useful in future. + if test "$aix_use_runtimelinking" = yes; then + # If using run time linking (on AIX 4.2 or later) use lib.so + # instead of lib.a to let people know that these are not + # typical AIX shared libraries. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + else + # We preserve .a as extension for shared libraries through AIX4.2 + # and later when we are not doing run time linking. + library_names_spec='${libname}${release}.a $libname.a' + soname_spec='${libname}${release}${shared_ext}$major' + fi + shlibpath_var=LIBPATH + fi + ;; + +amigaos*) + library_names_spec='$libname.ixlibrary $libname.a' + # Create ${libname}_ixlibrary.a entries in /sys/libs. + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' + ;; + +beos*) + library_names_spec='${libname}${shared_ext}' + dynamic_linker="$host_os ld.so" + shlibpath_var=LIBRARY_PATH + ;; + +bsdi4*) + version_type=linux + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" + sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" + # the default ld.so.conf also contains /usr/contrib/lib and + # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow + # libtool to hard-code these into programs + ;; + +cygwin* | mingw* | pw32*) + version_type=windows + shrext_cmds=".dll" + need_version=no + need_lib_prefix=no + + case $GCC,$host_os in + yes,cygwin* | yes,mingw* | yes,pw32*) + library_names_spec='$libname.dll.a' + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \${file}`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $rm \$dlpath' + shlibpath_overrides_runpath=yes + + case $host_os in + cygwin*) + # Cygwin DLLs use 'cyg' prefix rather than 'lib' + soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" + ;; + mingw*) + # MinGW DLLs use traditional 'lib' prefix + soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then + # It is most probably a Windows format PATH printed by + # mingw gcc, but we are running on Cygwin. Gcc prints its search + # path with ; separators, and with drive letters. We can handle the + # drive letters (cygwin fileutils understands them), so leave them, + # especially as we might pass files found there to a mingw objdump, + # which wouldn't understand a cygwinified path. Ahh. + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + ;; + pw32*) + # pw32 DLLs use 'pw' prefix rather than 'lib' + library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/./-/g'`${versuffix}${shared_ext}' + ;; + esac + ;; + + *) + library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' + ;; + esac + dynamic_linker='Win32 ld.exe' + # FIXME: first we should search . and the directory the executable is in + shlibpath_var=PATH + ;; + +darwin* | rhapsody*) + dynamic_linker="$host_os dyld" + version_type=darwin + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext' + soname_spec='${libname}${release}${major}$shared_ext' + shlibpath_overrides_runpath=yes + shlibpath_var=DYLD_LIBRARY_PATH + shrext_cmds='$(test .$module = .yes && echo .so || echo .dylib)' + # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same. + if test "$GCC" = yes; then + sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"` + else + sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib' + fi + sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' + ;; + +dgux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +freebsd1*) + dynamic_linker=no + ;; + +kfreebsd*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='GNU ld.so' + ;; + +freebsd*) + objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout` + version_type=freebsd-$objformat + case $version_type in + freebsd-elf*) + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + need_version=no + need_lib_prefix=no + ;; + freebsd-*) + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' + need_version=yes + ;; + esac + shlibpath_var=LD_LIBRARY_PATH + case $host_os in + freebsd2*) + shlibpath_overrides_runpath=yes + ;; + freebsd3.01* | freebsdelf3.01*) + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + *) # from 3.2 on + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + esac + ;; + +gnu*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + hardcode_into_libs=yes + ;; + +hpux9* | hpux10* | hpux11*) + # Give a soname corresponding to the major version so that dld.sl refuses to + # link against other versions. + version_type=sunos + need_lib_prefix=no + need_version=no + case "$host_cpu" in + ia64*) + shrext_cmds='.so' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.so" + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + if test "X$HPUX_IA64_MODE" = X32; then + sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" + else + sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" + fi + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + hppa*64*) + shrext_cmds='.sl' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.sl" + shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + *) + shrext_cmds='.sl' + dynamic_linker="$host_os dld.sl" + shlibpath_var=SHLIB_PATH + shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + ;; + esac + # HP-UX runs *really* slowly unless shared libraries are mode 555. + postinstall_cmds='chmod 555 $lib' + ;; + +irix5* | irix6* | nonstopux*) + case $host_os in + nonstopux*) version_type=nonstopux ;; + *) + if test "$lt_cv_prog_gnu_ld" = yes; then + version_type=linux + else + version_type=irix + fi ;; + esac + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' + case $host_os in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in # libtool.m4 will add one of these switches to LD + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") + libsuff= shlibsuff= libmagic=32-bit;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") + libsuff=32 shlibsuff=N32 libmagic=N32;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") + libsuff=64 shlibsuff=64 libmagic=64-bit;; + *) libsuff= shlibsuff= libmagic=never-match;; + esac + ;; + esac + shlibpath_var=LD_LIBRARY${shlibsuff}_PATH + shlibpath_overrides_runpath=no + sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" + sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" + hardcode_into_libs=yes + ;; + +# No shared lib support for Linux oldld, aout, or coff. +linux*oldld* | linux*aout* | linux*coff*) + dynamic_linker=no + ;; + +# This must be Linux ELF. +linux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + # find out which ABI we are using + libsuff= + case "$host_cpu" in + x86_64*|s390x*|powerpc64*) + echo '#line 16456 "configure"' > conftest.$ac_ext + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + case `/usr/bin/file conftest.$ac_objext` in + *64-bit*) + libsuff=64 + sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}" + ;; + esac + fi + rm -rf conftest* + ;; + esac + + # Append ld.so.conf contents to the search path + if test -f /etc/ld.so.conf; then + lt_ld_extra=`$SED -e 's/:,\t/ /g;s/=^=*$//;s/=^= * / /g' /etc/ld.so.conf | tr '\n' ' '` + sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra" + fi + + # We used to test for /lib/ld.so.1 and disable shared libraries on + # powerpc, because MkLinux only supported shared libraries with the + # GNU dynamic linker. Since this was broken with cross compilers, + # most powerpc-linux boxes support dynamic linking these days and + # people can always --disable-shared, the test was removed, and we + # assume the GNU/Linux dynamic linker is in use. + dynamic_linker='GNU/Linux ld.so' + ;; + +knetbsd*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='GNU ld.so' + ;; + +netbsd*) + version_type=sunos + need_lib_prefix=no + need_version=no + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + dynamic_linker='NetBSD (a.out) ld.so' + else + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='NetBSD ld.elf_so' + fi + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + +newsos6) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +nto-qnx*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +openbsd*) + version_type=sunos + need_lib_prefix=no + need_version=yes + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + case $host_os in + openbsd2.[89] | openbsd2.[89].*) + shlibpath_overrides_runpath=no + ;; + *) + shlibpath_overrides_runpath=yes + ;; + esac + else + shlibpath_overrides_runpath=yes + fi + ;; + +os2*) + libname_spec='$name' + shrext_cmds=".dll" + need_lib_prefix=no + library_names_spec='$libname${shared_ext} $libname.a' + dynamic_linker='OS/2 ld.exe' + shlibpath_var=LIBPATH + ;; + +osf3* | osf4* | osf5*) + version_type=osf + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" + sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" + ;; + +sco3.2v5*) + version_type=osf + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + ;; + +solaris*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + # ldd complains unless libraries are executable + postinstall_cmds='chmod +x $lib' + ;; + +sunos4*) + version_type=sunos + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + if test "$with_gnu_ld" = yes; then + need_lib_prefix=no + fi + need_version=yes + ;; + +sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + case $host_vendor in + sni) + shlibpath_overrides_runpath=no + need_lib_prefix=no + export_dynamic_flag_spec='${wl}-Blargedynsym' + runpath_var=LD_RUN_PATH + ;; + siemens) + need_lib_prefix=no + ;; + motorola) + need_lib_prefix=no + need_version=no + shlibpath_overrides_runpath=no + sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' + ;; + esac + ;; + +sysv4*MP*) + if test -d /usr/nec ;then + version_type=linux + library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' + soname_spec='$libname${shared_ext}.$major' + shlibpath_var=LD_LIBRARY_PATH + fi + ;; + +uts4*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +*) + dynamic_linker=no + ;; +esac +echo "$as_me:$LINENO: result: $dynamic_linker" >&5 +echo "${ECHO_T}$dynamic_linker" >&6 +test "$dynamic_linker" = no && can_build_shared=no + +echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5 +echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6 +hardcode_action_GCJ= +if test -n "$hardcode_libdir_flag_spec_GCJ" || \ + test -n "$runpath_var GCJ" || \ + test "X$hardcode_automatic_GCJ"="Xyes" ; then + + # We can hardcode non-existant directories. + if test "$hardcode_direct_GCJ" != no && + # If the only mechanism to avoid hardcoding is shlibpath_var, we + # have to relink, otherwise we might link with an installed library + # when we should be linking with a yet-to-be-installed one + ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, GCJ)" != no && + test "$hardcode_minus_L_GCJ" != no; then + # Linking always hardcodes the temporary library directory. + hardcode_action_GCJ=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + hardcode_action_GCJ=immediate + fi +else + # We cannot hardcode anything, or else we can only hardcode existing + # directories. + hardcode_action_GCJ=unsupported +fi +echo "$as_me:$LINENO: result: $hardcode_action_GCJ" >&5 +echo "${ECHO_T}$hardcode_action_GCJ" >&6 + +if test "$hardcode_action_GCJ" = relink; then + # Fast installation is not supported + enable_fast_install=no +elif test "$shlibpath_overrides_runpath" = yes || + test "$enable_shared" = no; then + # Fast installation is not necessary + enable_fast_install=needless +fi + +striplib= +old_striplib= +echo "$as_me:$LINENO: checking whether stripping libraries is possible" >&5 +echo $ECHO_N "checking whether stripping libraries is possible... $ECHO_C" >&6 +if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then + test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" + test -z "$striplib" && striplib="$STRIP --strip-unneeded" + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 +else +# FIXME - insert some real tests, host_os isn't really good enough + case $host_os in + darwin*) + if test -n "$STRIP" ; then + striplib="$STRIP -x" + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + ;; + *) + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + ;; + esac +fi + +if test "x$enable_dlopen" != xyes; then + enable_dlopen=unknown + enable_dlopen_self=unknown + enable_dlopen_self_static=unknown +else + lt_cv_dlopen=no + lt_cv_dlopen_libs= + + case $host_os in + beos*) + lt_cv_dlopen="load_add_on" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ;; + + mingw* | pw32*) + lt_cv_dlopen="LoadLibrary" + lt_cv_dlopen_libs= + ;; + + cygwin*) + lt_cv_dlopen="dlopen" + lt_cv_dlopen_libs= + ;; + + darwin*) + # if libdl is installed we need to link against it + echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5 +echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6 +if test "${ac_cv_lib_dl_dlopen+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldl $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char dlopen (); +int +main () +{ +dlopen (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_dl_dlopen=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_dl_dlopen=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5 +echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6 +if test $ac_cv_lib_dl_dlopen = yes; then + lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" +else + + lt_cv_dlopen="dyld" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + +fi + + ;; + + *) + echo "$as_me:$LINENO: checking for shl_load" >&5 +echo $ECHO_N "checking for shl_load... $ECHO_C" >&6 +if test "${ac_cv_func_shl_load+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define shl_load to an innocuous variant, in case declares shl_load. + For example, HP-UX 11i declares gettimeofday. */ +#define shl_load innocuous_shl_load + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char shl_load (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef shl_load + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char shl_load (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_shl_load) || defined (__stub___shl_load) +choke me +#else +char (*f) () = shl_load; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != shl_load; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_shl_load=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_func_shl_load=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_func_shl_load" >&5 +echo "${ECHO_T}$ac_cv_func_shl_load" >&6 +if test $ac_cv_func_shl_load = yes; then + lt_cv_dlopen="shl_load" +else + echo "$as_me:$LINENO: checking for shl_load in -ldld" >&5 +echo $ECHO_N "checking for shl_load in -ldld... $ECHO_C" >&6 +if test "${ac_cv_lib_dld_shl_load+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldld $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char shl_load (); +int +main () +{ +shl_load (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_dld_shl_load=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_dld_shl_load=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_dld_shl_load" >&5 +echo "${ECHO_T}$ac_cv_lib_dld_shl_load" >&6 +if test $ac_cv_lib_dld_shl_load = yes; then + lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld" +else + echo "$as_me:$LINENO: checking for dlopen" >&5 +echo $ECHO_N "checking for dlopen... $ECHO_C" >&6 +if test "${ac_cv_func_dlopen+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define dlopen to an innocuous variant, in case declares dlopen. + For example, HP-UX 11i declares gettimeofday. */ +#define dlopen innocuous_dlopen + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char dlopen (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef dlopen + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char dlopen (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_dlopen) || defined (__stub___dlopen) +choke me +#else +char (*f) () = dlopen; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != dlopen; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_dlopen=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_func_dlopen=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_func_dlopen" >&5 +echo "${ECHO_T}$ac_cv_func_dlopen" >&6 +if test $ac_cv_func_dlopen = yes; then + lt_cv_dlopen="dlopen" +else + echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5 +echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6 +if test "${ac_cv_lib_dl_dlopen+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldl $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char dlopen (); +int +main () +{ +dlopen (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_dl_dlopen=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_dl_dlopen=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5 +echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6 +if test $ac_cv_lib_dl_dlopen = yes; then + lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" +else + echo "$as_me:$LINENO: checking for dlopen in -lsvld" >&5 +echo $ECHO_N "checking for dlopen in -lsvld... $ECHO_C" >&6 +if test "${ac_cv_lib_svld_dlopen+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lsvld $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char dlopen (); +int +main () +{ +dlopen (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_svld_dlopen=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_svld_dlopen=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_svld_dlopen" >&5 +echo "${ECHO_T}$ac_cv_lib_svld_dlopen" >&6 +if test $ac_cv_lib_svld_dlopen = yes; then + lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld" +else + echo "$as_me:$LINENO: checking for dld_link in -ldld" >&5 +echo $ECHO_N "checking for dld_link in -ldld... $ECHO_C" >&6 +if test "${ac_cv_lib_dld_dld_link+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldld $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char dld_link (); +int +main () +{ +dld_link (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_dld_dld_link=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_dld_dld_link=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_dld_dld_link" >&5 +echo "${ECHO_T}$ac_cv_lib_dld_dld_link" >&6 +if test $ac_cv_lib_dld_dld_link = yes; then + lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld" +fi + + +fi + + +fi + + +fi + + +fi + + +fi + + ;; + esac + + if test "x$lt_cv_dlopen" != xno; then + enable_dlopen=yes + else + enable_dlopen=no + fi + + case $lt_cv_dlopen in + dlopen) + save_CPPFLAGS="$CPPFLAGS" + test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" + + save_LDFLAGS="$LDFLAGS" + eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" + + save_LIBS="$LIBS" + LIBS="$lt_cv_dlopen_libs $LIBS" + + echo "$as_me:$LINENO: checking whether a program can dlopen itself" >&5 +echo $ECHO_N "checking whether a program can dlopen itself... $ECHO_C" >&6 +if test "${lt_cv_dlopen_self+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$cross_compiling" = yes; then : + lt_cv_dlopen_self=cross +else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext < +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LT_DLGLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LT_DLGLOBAL DL_GLOBAL +# else +# define LT_DLGLOBAL 0 +# endif +#endif + +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LT_DLLAZY_OR_NOW +# ifdef RTLD_LAZY +# define LT_DLLAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LT_DLLAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LT_DLLAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LT_DLLAZY_OR_NOW DL_NOW +# else +# define LT_DLLAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +#ifdef __cplusplus +extern "C" void exit (int); +#endif + +void fnord() { int i=42;} +int main () +{ + void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); + int status = $lt_dlunknown; + + if (self) + { + if (dlsym (self,"fnord")) status = $lt_dlno_uscore; + else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + /* dlclose (self); */ + } + + exit (status); +} +EOF + if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then + (./conftest; exit; ) 2>/dev/null + lt_status=$? + case x$lt_status in + x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; + x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; + x$lt_unknown|x*) lt_cv_dlopen_self=no ;; + esac + else : + # compilation failed + lt_cv_dlopen_self=no + fi +fi +rm -fr conftest* + + +fi +echo "$as_me:$LINENO: result: $lt_cv_dlopen_self" >&5 +echo "${ECHO_T}$lt_cv_dlopen_self" >&6 + + if test "x$lt_cv_dlopen_self" = xyes; then + LDFLAGS="$LDFLAGS $link_static_flag" + echo "$as_me:$LINENO: checking whether a statically linked program can dlopen itself" >&5 +echo $ECHO_N "checking whether a statically linked program can dlopen itself... $ECHO_C" >&6 +if test "${lt_cv_dlopen_self_static+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$cross_compiling" = yes; then : + lt_cv_dlopen_self_static=cross +else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext < +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LT_DLGLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LT_DLGLOBAL DL_GLOBAL +# else +# define LT_DLGLOBAL 0 +# endif +#endif + +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LT_DLLAZY_OR_NOW +# ifdef RTLD_LAZY +# define LT_DLLAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LT_DLLAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LT_DLLAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LT_DLLAZY_OR_NOW DL_NOW +# else +# define LT_DLLAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +#ifdef __cplusplus +extern "C" void exit (int); +#endif + +void fnord() { int i=42;} +int main () +{ + void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); + int status = $lt_dlunknown; + + if (self) + { + if (dlsym (self,"fnord")) status = $lt_dlno_uscore; + else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + /* dlclose (self); */ + } + + exit (status); +} +EOF + if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then + (./conftest; exit; ) 2>/dev/null + lt_status=$? + case x$lt_status in + x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; + x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; + x$lt_unknown|x*) lt_cv_dlopen_self_static=no ;; + esac + else : + # compilation failed + lt_cv_dlopen_self_static=no + fi +fi +rm -fr conftest* + + +fi +echo "$as_me:$LINENO: result: $lt_cv_dlopen_self_static" >&5 +echo "${ECHO_T}$lt_cv_dlopen_self_static" >&6 + fi + + CPPFLAGS="$save_CPPFLAGS" + LDFLAGS="$save_LDFLAGS" + LIBS="$save_LIBS" + ;; + esac + + case $lt_cv_dlopen_self in + yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; + *) enable_dlopen_self=unknown ;; + esac + + case $lt_cv_dlopen_self_static in + yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; + *) enable_dlopen_self_static=unknown ;; + esac +fi + + +# The else clause should only fire when bootstrapping the +# libtool distribution, otherwise you forgot to ship ltmain.sh +# with your package, and you will get complaints that there are +# no rules to generate ltmain.sh. +if test -f "$ltmain"; then + # See if we are running on zsh, and set the options which allow our commands through + # without removal of \ escapes. + if test -n "${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST + fi + # Now quote all the things that may contain metacharacters while being + # careful not to overquote the AC_SUBSTed values. We take copies of the + # variables and quote the copies for generation of the libtool script. + for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC NM \ + SED SHELL STRIP \ + libname_spec library_names_spec soname_spec extract_expsyms_cmds \ + old_striplib striplib file_magic_cmd finish_cmds finish_eval \ + deplibs_check_method reload_flag reload_cmds need_locks \ + lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \ + lt_cv_sys_global_symbol_to_c_name_address \ + sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ + old_postinstall_cmds old_postuninstall_cmds \ + compiler_GCJ \ + CC_GCJ \ + LD_GCJ \ + lt_prog_compiler_wl_GCJ \ + lt_prog_compiler_pic_GCJ \ + lt_prog_compiler_static_GCJ \ + lt_prog_compiler_no_builtin_flag_GCJ \ + export_dynamic_flag_spec_GCJ \ + thread_safe_flag_spec_GCJ \ + whole_archive_flag_spec_GCJ \ + enable_shared_with_static_runtimes_GCJ \ + old_archive_cmds_GCJ \ + old_archive_from_new_cmds_GCJ \ + predep_objects_GCJ \ + postdep_objects_GCJ \ + predeps_GCJ \ + postdeps_GCJ \ + compiler_lib_search_path_GCJ \ + archive_cmds_GCJ \ + archive_expsym_cmds_GCJ \ + postinstall_cmds_GCJ \ + postuninstall_cmds_GCJ \ + old_archive_from_expsyms_cmds_GCJ \ + allow_undefined_flag_GCJ \ + no_undefined_flag_GCJ \ + export_symbols_cmds_GCJ \ + hardcode_libdir_flag_spec_GCJ \ + hardcode_libdir_flag_spec_ld_GCJ \ + hardcode_libdir_separator_GCJ \ + hardcode_automatic_GCJ \ + module_cmds_GCJ \ + module_expsym_cmds_GCJ \ + lt_cv_prog_compiler_c_o_GCJ \ + exclude_expsyms_GCJ \ + include_expsyms_GCJ; do + + case $var in + old_archive_cmds_GCJ | \ + old_archive_from_new_cmds_GCJ | \ + archive_cmds_GCJ | \ + archive_expsym_cmds_GCJ | \ + module_cmds_GCJ | \ + module_expsym_cmds_GCJ | \ + old_archive_from_expsyms_cmds_GCJ | \ + export_symbols_cmds_GCJ | \ + extract_expsyms_cmds | reload_cmds | finish_cmds | \ + postinstall_cmds | postuninstall_cmds | \ + old_postinstall_cmds | old_postuninstall_cmds | \ + sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) + # Double-quote double-evaled strings. + eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" + ;; + *) + eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" + ;; + esac + done + + case $lt_echo in + *'\$0 --fallback-echo"') + lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'` + ;; + esac + +cfgfile="$ofile" + + cat <<__EOF__ >> "$cfgfile" +# ### BEGIN LIBTOOL TAG CONFIG: $tagname + +# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: + +# Shell to use when invoking shell scripts. +SHELL=$lt_SHELL + +# Whether or not to build shared libraries. +build_libtool_libs=$enable_shared + +# Whether or not to build static libraries. +build_old_libs=$enable_static + +# Whether or not to add -lc for building shared libraries. +build_libtool_need_lc=$archive_cmds_need_lc_GCJ + +# Whether or not to disallow shared libs when runtime libs are static +allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_GCJ + +# Whether or not to optimize for fast installation. +fast_install=$enable_fast_install + +# The host system. +host_alias=$host_alias +host=$host + +# An echo program that does not interpret backslashes. +echo=$lt_echo + +# The archiver. +AR=$lt_AR +AR_FLAGS=$lt_AR_FLAGS + +# A C compiler. +LTCC=$lt_LTCC + +# A language-specific compiler. +CC=$lt_compiler_GCJ + +# Is the compiler the GNU C compiler? +with_gcc=$GCC_GCJ + +# An ERE matcher. +EGREP=$lt_EGREP + +# The linker used to build libraries. +LD=$lt_LD_GCJ + +# Whether we need hard or soft links. +LN_S=$lt_LN_S + +# A BSD-compatible nm program. +NM=$lt_NM + +# A symbol stripping program +STRIP=$lt_STRIP + +# Used to examine libraries when file_magic_cmd begins "file" +MAGIC_CMD=$MAGIC_CMD + +# Used on cygwin: DLL creation program. +DLLTOOL="$DLLTOOL" + +# Used on cygwin: object dumper. +OBJDUMP="$OBJDUMP" + +# Used on cygwin: assembler. +AS="$AS" + +# The name of the directory that contains temporary libtool files. +objdir=$objdir + +# How to create reloadable object files. +reload_flag=$lt_reload_flag +reload_cmds=$lt_reload_cmds + +# How to pass a linker flag through the compiler. +wl=$lt_lt_prog_compiler_wl_GCJ + +# Object file suffix (normally "o"). +objext="$ac_objext" + +# Old archive suffix (normally "a"). +libext="$libext" + +# Shared library suffix (normally ".so"). +shrext_cmds='$shrext_cmds' + +# Executable file suffix (normally ""). +exeext="$exeext" + +# Additional compiler flags for building library objects. +pic_flag=$lt_lt_prog_compiler_pic_GCJ +pic_mode=$pic_mode + +# What is the maximum length of a command? +max_cmd_len=$lt_cv_sys_max_cmd_len + +# Does compiler simultaneously support -c and -o options? +compiler_c_o=$lt_lt_cv_prog_compiler_c_o_GCJ + +# Must we lock files when doing compilation ? +need_locks=$lt_need_locks + +# Do we need the lib prefix for modules? +need_lib_prefix=$need_lib_prefix + +# Do we need a version for libraries? +need_version=$need_version + +# Whether dlopen is supported. +dlopen_support=$enable_dlopen + +# Whether dlopen of programs is supported. +dlopen_self=$enable_dlopen_self + +# Whether dlopen of statically linked programs is supported. +dlopen_self_static=$enable_dlopen_self_static + +# Compiler flag to prevent dynamic linking. +link_static_flag=$lt_lt_prog_compiler_static_GCJ + +# Compiler flag to turn off builtin functions. +no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_GCJ + +# Compiler flag to allow reflexive dlopens. +export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_GCJ + +# Compiler flag to generate shared objects directly from archives. +whole_archive_flag_spec=$lt_whole_archive_flag_spec_GCJ + +# Compiler flag to generate thread-safe objects. +thread_safe_flag_spec=$lt_thread_safe_flag_spec_GCJ + +# Library versioning type. +version_type=$version_type + +# Format of library name prefix. +libname_spec=$lt_libname_spec + +# List of archive names. First name is the real one, the rest are links. +# The last name is the one that the linker finds with -lNAME. +library_names_spec=$lt_library_names_spec + +# The coded name of the library, if different from the real name. +soname_spec=$lt_soname_spec + +# Commands used to build and install an old-style archive. +RANLIB=$lt_RANLIB +old_archive_cmds=$lt_old_archive_cmds_GCJ +old_postinstall_cmds=$lt_old_postinstall_cmds +old_postuninstall_cmds=$lt_old_postuninstall_cmds + +# Create an old-style archive from a shared archive. +old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_GCJ + +# Create a temporary old-style archive to link instead of a shared archive. +old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_GCJ + +# Commands used to build and install a shared archive. +archive_cmds=$lt_archive_cmds_GCJ +archive_expsym_cmds=$lt_archive_expsym_cmds_GCJ +postinstall_cmds=$lt_postinstall_cmds +postuninstall_cmds=$lt_postuninstall_cmds + +# Commands used to build a loadable module (assumed same as above if empty) +module_cmds=$lt_module_cmds_GCJ +module_expsym_cmds=$lt_module_expsym_cmds_GCJ + +# Commands to strip libraries. +old_striplib=$lt_old_striplib +striplib=$lt_striplib + +# Dependencies to place before the objects being linked to create a +# shared library. +predep_objects=$lt_predep_objects_GCJ + +# Dependencies to place after the objects being linked to create a +# shared library. +postdep_objects=$lt_postdep_objects_GCJ + +# Dependencies to place before the objects being linked to create a +# shared library. +predeps=$lt_predeps_GCJ + +# Dependencies to place after the objects being linked to create a +# shared library. +postdeps=$lt_postdeps_GCJ + +# The library search path used internally by the compiler when linking +# a shared library. +compiler_lib_search_path=$lt_compiler_lib_search_path_GCJ + +# Method to check whether dependent libraries are shared objects. +deplibs_check_method=$lt_deplibs_check_method + +# Command to use when deplibs_check_method == file_magic. +file_magic_cmd=$lt_file_magic_cmd + +# Flag that allows shared libraries with undefined symbols to be built. +allow_undefined_flag=$lt_allow_undefined_flag_GCJ + +# Flag that forces no undefined symbols. +no_undefined_flag=$lt_no_undefined_flag_GCJ + +# Commands used to finish a libtool library installation in a directory. +finish_cmds=$lt_finish_cmds + +# Same as above, but a single script fragment to be evaled but not shown. +finish_eval=$lt_finish_eval + +# Take the output of nm and produce a listing of raw symbols and C names. +global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe + +# Transform the output of nm in a proper C declaration +global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl + +# Transform the output of nm in a C name address pair +global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address + +# This is the shared library runtime path variable. +runpath_var=$runpath_var + +# This is the shared library path variable. +shlibpath_var=$shlibpath_var + +# Is shlibpath searched before the hard-coded library search path? +shlibpath_overrides_runpath=$shlibpath_overrides_runpath + +# How to hardcode a shared library path into an executable. +hardcode_action=$hardcode_action_GCJ + +# Whether we should hardcode library paths into libraries. +hardcode_into_libs=$hardcode_into_libs + +# Flag to hardcode \$libdir into a binary during linking. +# This must work even if \$libdir does not exist. +hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_GCJ + +# If ld is used when linking, flag to hardcode \$libdir into +# a binary during linking. This must work even if \$libdir does +# not exist. +hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_GCJ + +# Whether we need a single -rpath flag with a separated argument. +hardcode_libdir_separator=$lt_hardcode_libdir_separator_GCJ + +# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the +# resulting binary. +hardcode_direct=$hardcode_direct_GCJ + +# Set to yes if using the -LDIR flag during linking hardcodes DIR into the +# resulting binary. +hardcode_minus_L=$hardcode_minus_L_GCJ + +# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into +# the resulting binary. +hardcode_shlibpath_var=$hardcode_shlibpath_var_GCJ + +# Set to yes if building a shared library automatically hardcodes DIR into the library +# and all subsequent libraries and executables linked against it. +hardcode_automatic=$hardcode_automatic_GCJ + +# Variables whose values should be saved in libtool wrapper scripts and +# restored at relink time. +variables_saved_for_relink="$variables_saved_for_relink" + +# Whether libtool must link a program against all its dependency libraries. +link_all_deplibs=$link_all_deplibs_GCJ + +# Compile-time system search path for libraries +sys_lib_search_path_spec=$lt_sys_lib_search_path_spec + +# Run-time system search path for libraries +sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec + +# Fix the shell variable \$srcfile for the compiler. +fix_srcfile_path="$fix_srcfile_path_GCJ" + +# Set to yes if exported symbols are required. +always_export_symbols=$always_export_symbols_GCJ + +# The commands to list exported symbols. +export_symbols_cmds=$lt_export_symbols_cmds_GCJ + +# The commands to extract the exported symbol list from a shared archive. +extract_expsyms_cmds=$lt_extract_expsyms_cmds + +# Symbols that should not be listed in the preloaded symbols. +exclude_expsyms=$lt_exclude_expsyms_GCJ + +# Symbols that must always be exported. +include_expsyms=$lt_include_expsyms_GCJ + +# ### END LIBTOOL TAG CONFIG: $tagname + +__EOF__ + + +else + # If there is no Makefile yet, we rely on a make rule to execute + # `config.status --recheck' to rerun these tests and create the + # libtool script then. + ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'` + if test -f "$ltmain_in"; then + test -f Makefile && make "$ltmain" + fi +fi + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +CC="$lt_save_CC" + + else + tagname="" + fi + ;; + + RC) + + + +# Source file extension for RC test sources. +ac_ext=rc + +# Object file extension for compiled RC test sources. +objext=o +objext_RC=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }\n' + +# Code to be used in simple link tests +lt_simple_link_test_code="$lt_simple_compile_test_code" + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# Allow CC to be a program name with arguments. +compiler=$CC + + +# Allow CC to be a program name with arguments. +lt_save_CC="$CC" +CC=${RC-"windres"} +compiler=$CC +compiler_RC=$CC +lt_cv_prog_compiler_c_o_RC=yes + +# The else clause should only fire when bootstrapping the +# libtool distribution, otherwise you forgot to ship ltmain.sh +# with your package, and you will get complaints that there are +# no rules to generate ltmain.sh. +if test -f "$ltmain"; then + # See if we are running on zsh, and set the options which allow our commands through + # without removal of \ escapes. + if test -n "${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST + fi + # Now quote all the things that may contain metacharacters while being + # careful not to overquote the AC_SUBSTed values. We take copies of the + # variables and quote the copies for generation of the libtool script. + for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC NM \ + SED SHELL STRIP \ + libname_spec library_names_spec soname_spec extract_expsyms_cmds \ + old_striplib striplib file_magic_cmd finish_cmds finish_eval \ + deplibs_check_method reload_flag reload_cmds need_locks \ + lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \ + lt_cv_sys_global_symbol_to_c_name_address \ + sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ + old_postinstall_cmds old_postuninstall_cmds \ + compiler_RC \ + CC_RC \ + LD_RC \ + lt_prog_compiler_wl_RC \ + lt_prog_compiler_pic_RC \ + lt_prog_compiler_static_RC \ + lt_prog_compiler_no_builtin_flag_RC \ + export_dynamic_flag_spec_RC \ + thread_safe_flag_spec_RC \ + whole_archive_flag_spec_RC \ + enable_shared_with_static_runtimes_RC \ + old_archive_cmds_RC \ + old_archive_from_new_cmds_RC \ + predep_objects_RC \ + postdep_objects_RC \ + predeps_RC \ + postdeps_RC \ + compiler_lib_search_path_RC \ + archive_cmds_RC \ + archive_expsym_cmds_RC \ + postinstall_cmds_RC \ + postuninstall_cmds_RC \ + old_archive_from_expsyms_cmds_RC \ + allow_undefined_flag_RC \ + no_undefined_flag_RC \ + export_symbols_cmds_RC \ + hardcode_libdir_flag_spec_RC \ + hardcode_libdir_flag_spec_ld_RC \ + hardcode_libdir_separator_RC \ + hardcode_automatic_RC \ + module_cmds_RC \ + module_expsym_cmds_RC \ + lt_cv_prog_compiler_c_o_RC \ + exclude_expsyms_RC \ + include_expsyms_RC; do + + case $var in + old_archive_cmds_RC | \ + old_archive_from_new_cmds_RC | \ + archive_cmds_RC | \ + archive_expsym_cmds_RC | \ + module_cmds_RC | \ + module_expsym_cmds_RC | \ + old_archive_from_expsyms_cmds_RC | \ + export_symbols_cmds_RC | \ + extract_expsyms_cmds | reload_cmds | finish_cmds | \ + postinstall_cmds | postuninstall_cmds | \ + old_postinstall_cmds | old_postuninstall_cmds | \ + sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) + # Double-quote double-evaled strings. + eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" + ;; + *) + eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" + ;; + esac + done + + case $lt_echo in + *'\$0 --fallback-echo"') + lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'` + ;; + esac + +cfgfile="$ofile" + + cat <<__EOF__ >> "$cfgfile" +# ### BEGIN LIBTOOL TAG CONFIG: $tagname + +# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: + +# Shell to use when invoking shell scripts. +SHELL=$lt_SHELL + +# Whether or not to build shared libraries. +build_libtool_libs=$enable_shared + +# Whether or not to build static libraries. +build_old_libs=$enable_static + +# Whether or not to add -lc for building shared libraries. +build_libtool_need_lc=$archive_cmds_need_lc_RC + +# Whether or not to disallow shared libs when runtime libs are static +allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_RC + +# Whether or not to optimize for fast installation. +fast_install=$enable_fast_install + +# The host system. +host_alias=$host_alias +host=$host + +# An echo program that does not interpret backslashes. +echo=$lt_echo + +# The archiver. +AR=$lt_AR +AR_FLAGS=$lt_AR_FLAGS + +# A C compiler. +LTCC=$lt_LTCC + +# A language-specific compiler. +CC=$lt_compiler_RC + +# Is the compiler the GNU C compiler? +with_gcc=$GCC_RC + +# An ERE matcher. +EGREP=$lt_EGREP + +# The linker used to build libraries. +LD=$lt_LD_RC + +# Whether we need hard or soft links. +LN_S=$lt_LN_S + +# A BSD-compatible nm program. +NM=$lt_NM + +# A symbol stripping program +STRIP=$lt_STRIP + +# Used to examine libraries when file_magic_cmd begins "file" +MAGIC_CMD=$MAGIC_CMD + +# Used on cygwin: DLL creation program. +DLLTOOL="$DLLTOOL" + +# Used on cygwin: object dumper. +OBJDUMP="$OBJDUMP" + +# Used on cygwin: assembler. +AS="$AS" + +# The name of the directory that contains temporary libtool files. +objdir=$objdir + +# How to create reloadable object files. +reload_flag=$lt_reload_flag +reload_cmds=$lt_reload_cmds + +# How to pass a linker flag through the compiler. +wl=$lt_lt_prog_compiler_wl_RC + +# Object file suffix (normally "o"). +objext="$ac_objext" + +# Old archive suffix (normally "a"). +libext="$libext" + +# Shared library suffix (normally ".so"). +shrext_cmds='$shrext_cmds' + +# Executable file suffix (normally ""). +exeext="$exeext" + +# Additional compiler flags for building library objects. +pic_flag=$lt_lt_prog_compiler_pic_RC +pic_mode=$pic_mode + +# What is the maximum length of a command? +max_cmd_len=$lt_cv_sys_max_cmd_len + +# Does compiler simultaneously support -c and -o options? +compiler_c_o=$lt_lt_cv_prog_compiler_c_o_RC + +# Must we lock files when doing compilation ? +need_locks=$lt_need_locks + +# Do we need the lib prefix for modules? +need_lib_prefix=$need_lib_prefix + +# Do we need a version for libraries? +need_version=$need_version + +# Whether dlopen is supported. +dlopen_support=$enable_dlopen + +# Whether dlopen of programs is supported. +dlopen_self=$enable_dlopen_self + +# Whether dlopen of statically linked programs is supported. +dlopen_self_static=$enable_dlopen_self_static + +# Compiler flag to prevent dynamic linking. +link_static_flag=$lt_lt_prog_compiler_static_RC + +# Compiler flag to turn off builtin functions. +no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_RC + +# Compiler flag to allow reflexive dlopens. +export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_RC + +# Compiler flag to generate shared objects directly from archives. +whole_archive_flag_spec=$lt_whole_archive_flag_spec_RC + +# Compiler flag to generate thread-safe objects. +thread_safe_flag_spec=$lt_thread_safe_flag_spec_RC + +# Library versioning type. +version_type=$version_type + +# Format of library name prefix. +libname_spec=$lt_libname_spec + +# List of archive names. First name is the real one, the rest are links. +# The last name is the one that the linker finds with -lNAME. +library_names_spec=$lt_library_names_spec + +# The coded name of the library, if different from the real name. +soname_spec=$lt_soname_spec + +# Commands used to build and install an old-style archive. +RANLIB=$lt_RANLIB +old_archive_cmds=$lt_old_archive_cmds_RC +old_postinstall_cmds=$lt_old_postinstall_cmds +old_postuninstall_cmds=$lt_old_postuninstall_cmds + +# Create an old-style archive from a shared archive. +old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_RC + +# Create a temporary old-style archive to link instead of a shared archive. +old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_RC + +# Commands used to build and install a shared archive. +archive_cmds=$lt_archive_cmds_RC +archive_expsym_cmds=$lt_archive_expsym_cmds_RC +postinstall_cmds=$lt_postinstall_cmds +postuninstall_cmds=$lt_postuninstall_cmds + +# Commands used to build a loadable module (assumed same as above if empty) +module_cmds=$lt_module_cmds_RC +module_expsym_cmds=$lt_module_expsym_cmds_RC + +# Commands to strip libraries. +old_striplib=$lt_old_striplib +striplib=$lt_striplib + +# Dependencies to place before the objects being linked to create a +# shared library. +predep_objects=$lt_predep_objects_RC + +# Dependencies to place after the objects being linked to create a +# shared library. +postdep_objects=$lt_postdep_objects_RC + +# Dependencies to place before the objects being linked to create a +# shared library. +predeps=$lt_predeps_RC + +# Dependencies to place after the objects being linked to create a +# shared library. +postdeps=$lt_postdeps_RC + +# The library search path used internally by the compiler when linking +# a shared library. +compiler_lib_search_path=$lt_compiler_lib_search_path_RC + +# Method to check whether dependent libraries are shared objects. +deplibs_check_method=$lt_deplibs_check_method + +# Command to use when deplibs_check_method == file_magic. +file_magic_cmd=$lt_file_magic_cmd + +# Flag that allows shared libraries with undefined symbols to be built. +allow_undefined_flag=$lt_allow_undefined_flag_RC + +# Flag that forces no undefined symbols. +no_undefined_flag=$lt_no_undefined_flag_RC + +# Commands used to finish a libtool library installation in a directory. +finish_cmds=$lt_finish_cmds + +# Same as above, but a single script fragment to be evaled but not shown. +finish_eval=$lt_finish_eval + +# Take the output of nm and produce a listing of raw symbols and C names. +global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe + +# Transform the output of nm in a proper C declaration +global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl + +# Transform the output of nm in a C name address pair +global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address + +# This is the shared library runtime path variable. +runpath_var=$runpath_var + +# This is the shared library path variable. +shlibpath_var=$shlibpath_var + +# Is shlibpath searched before the hard-coded library search path? +shlibpath_overrides_runpath=$shlibpath_overrides_runpath + +# How to hardcode a shared library path into an executable. +hardcode_action=$hardcode_action_RC + +# Whether we should hardcode library paths into libraries. +hardcode_into_libs=$hardcode_into_libs + +# Flag to hardcode \$libdir into a binary during linking. +# This must work even if \$libdir does not exist. +hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_RC + +# If ld is used when linking, flag to hardcode \$libdir into +# a binary during linking. This must work even if \$libdir does +# not exist. +hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_RC + +# Whether we need a single -rpath flag with a separated argument. +hardcode_libdir_separator=$lt_hardcode_libdir_separator_RC + +# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the +# resulting binary. +hardcode_direct=$hardcode_direct_RC + +# Set to yes if using the -LDIR flag during linking hardcodes DIR into the +# resulting binary. +hardcode_minus_L=$hardcode_minus_L_RC + +# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into +# the resulting binary. +hardcode_shlibpath_var=$hardcode_shlibpath_var_RC + +# Set to yes if building a shared library automatically hardcodes DIR into the library +# and all subsequent libraries and executables linked against it. +hardcode_automatic=$hardcode_automatic_RC + +# Variables whose values should be saved in libtool wrapper scripts and +# restored at relink time. +variables_saved_for_relink="$variables_saved_for_relink" + +# Whether libtool must link a program against all its dependency libraries. +link_all_deplibs=$link_all_deplibs_RC + +# Compile-time system search path for libraries +sys_lib_search_path_spec=$lt_sys_lib_search_path_spec + +# Run-time system search path for libraries +sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec + +# Fix the shell variable \$srcfile for the compiler. +fix_srcfile_path="$fix_srcfile_path_RC" + +# Set to yes if exported symbols are required. +always_export_symbols=$always_export_symbols_RC + +# The commands to list exported symbols. +export_symbols_cmds=$lt_export_symbols_cmds_RC + +# The commands to extract the exported symbol list from a shared archive. +extract_expsyms_cmds=$lt_extract_expsyms_cmds + +# Symbols that should not be listed in the preloaded symbols. +exclude_expsyms=$lt_exclude_expsyms_RC + +# Symbols that must always be exported. +include_expsyms=$lt_include_expsyms_RC + +# ### END LIBTOOL TAG CONFIG: $tagname + +__EOF__ + + +else + # If there is no Makefile yet, we rely on a make rule to execute + # `config.status --recheck' to rerun these tests and create the + # libtool script then. + ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'` + if test -f "$ltmain_in"; then + test -f Makefile && make "$ltmain" + fi +fi + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +CC="$lt_save_CC" + + ;; + + *) + { { echo "$as_me:$LINENO: error: Unsupported tag name: $tagname" >&5 +echo "$as_me: error: Unsupported tag name: $tagname" >&2;} + { (exit 1); exit 1; }; } + ;; + esac + + # Append the new tag name to the list of available tags. + if test -n "$tagname" ; then + available_tags="$available_tags $tagname" + fi + fi + done + IFS="$lt_save_ifs" + + # Now substitute the updated list of available tags. + if eval "sed -e 's/^available_tags=.*\$/available_tags=\"$available_tags\"/' \"$ofile\" > \"${ofile}T\""; then + mv "${ofile}T" "$ofile" + chmod +x "$ofile" + else + rm -f "${ofile}T" + { { echo "$as_me:$LINENO: error: unable to update list of available tagged configurations." >&5 +echo "$as_me: error: unable to update list of available tagged configurations." >&2;} + { (exit 1); exit 1; }; } + fi +fi + + + +# This can be used to rebuild libtool when needed +LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh" + +# Always use our own libtool. +LIBTOOL='$(SHELL) $(top_builddir)/libtool' + +# Prevent multiple expansion + + + + + + + + + + + + + + + + + + + + + + + +# Overrides the default CFLAGS setting +if test "$ac_test_CFLAGS" = "set" +then + CFLAGS=$ac_save_CFLAGS +else + if test "$GCC" = "yes" + then + CFLAGS="-O2" + else + CFLAGS= + fi +fi + +if test "$ac_test_CXXFLAGS" = "set" +then + CXXFLAGS=$ac_save_CXXFLAGS +else + if test "$GCC" = "yes" + then + CXXFLAGS="-O2" + else + CXXFLAGS= + fi +fi + +# Checks for header files. +echo "$as_me:$LINENO: checking for ANSI C header files" >&5 +echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 +if test "${ac_cv_header_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_header_stdc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_header_stdc=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then + : +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then + : +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then + : +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + exit(2); + exit (0); +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_header_stdc=no +fi +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 +echo "${ECHO_T}$ac_cv_header_stdc" >&6 +if test $ac_cv_header_stdc = yes; then + +cat >>confdefs.h <<\_ACEOF +#define STDC_HEADERS 1 +_ACEOF + +fi + + +# Checks for typedefs, structures, and compiler characteristics. +echo "$as_me:$LINENO: checking whether byte ordering is bigendian" >&5 +echo $ECHO_N "checking whether byte ordering is bigendian... $ECHO_C" >&6 +if test "${ac_cv_c_bigendian+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # See if sys/param.h defines the BYTE_ORDER macro. +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include + +int +main () +{ +#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN + bogus endian macros +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + # It does; now see whether it defined to BIG_ENDIAN or not. +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include + +int +main () +{ +#if BYTE_ORDER != BIG_ENDIAN + not big endian +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_c_bigendian=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_c_bigendian=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +# It does not; compile a test program. +if test "$cross_compiling" = yes; then + # try to guess the endianness by grepping values into an object file + ac_cv_c_bigendian=unknown + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +short ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; +short ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; +void _ascii () { char *s = (char *) ascii_mm; s = (char *) ascii_ii; } +short ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; +short ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; +void _ebcdic () { char *s = (char *) ebcdic_mm; s = (char *) ebcdic_ii; } +int +main () +{ + _ascii (); _ebcdic (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + if grep BIGenDianSyS conftest.$ac_objext >/dev/null ; then + ac_cv_c_bigendian=yes +fi +if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then + if test "$ac_cv_c_bigendian" = unknown; then + ac_cv_c_bigendian=no + else + # finding both strings is unlikely to happen, but who knows? + ac_cv_c_bigendian=unknown + fi +fi +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +int +main () +{ + /* Are we little or big endian? From Harbison&Steele. */ + union + { + long l; + char c[sizeof (long)]; + } u; + u.l = 1; + exit (u.c[sizeof (long) - 1] == 1); +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_c_bigendian=no +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_c_bigendian=yes +fi +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_c_bigendian" >&5 +echo "${ECHO_T}$ac_cv_c_bigendian" >&6 +case $ac_cv_c_bigendian in + yes) + +cat >>confdefs.h <<\_ACEOF +#define ASE_ENDIAN_BIG +_ACEOF + ;; + no) + +cat >>confdefs.h <<\_ACEOF +#define ASE_ENDIAN_LITTLE +_ACEOF + ;; + *) + +cat >>confdefs.h <<\_ACEOF +#define ASE_ENDIAN_UNKNOWN +_ACEOF + ;; +esac + + +# Checks for data types +echo "$as_me:$LINENO: checking for long long" >&5 +echo $ECHO_N "checking for long long... $ECHO_C" >&6 +if test "${ac_cv_type_long_long+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +if ((long long *) 0) + return 0; +if (sizeof (long long)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_long_long=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_type_long_long=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_long_long" >&5 +echo "${ECHO_T}$ac_cv_type_long_long" >&6 +if test $ac_cv_type_long_long = yes; then + +cat >>confdefs.h <<\_ACEOF +#define ASE_HAVE_LONG_LONG +_ACEOF + +fi + +echo "$as_me:$LINENO: checking for long double" >&5 +echo $ECHO_N "checking for long double... $ECHO_C" >&6 +if test "${ac_cv_type_long_double+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +if ((long double *) 0) + return 0; +if (sizeof (long double)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_long_double=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_type_long_double=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_long_double" >&5 +echo "${ECHO_T}$ac_cv_type_long_double" >&6 +if test $ac_cv_type_long_double = yes; then + +cat >>confdefs.h <<\_ACEOF +#define ASE_HAVE_LONG_DOUBLE +_ACEOF + +fi + + +echo "$as_me:$LINENO: checking for char" >&5 +echo $ECHO_N "checking for char... $ECHO_C" >&6 +if test "${ac_cv_type_char+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +if ((char *) 0) + return 0; +if (sizeof (char)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_char=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_type_char=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_char" >&5 +echo "${ECHO_T}$ac_cv_type_char" >&6 + +echo "$as_me:$LINENO: checking size of char" >&5 +echo $ECHO_N "checking size of char... $ECHO_C" >&6 +if test "${ac_cv_sizeof_char+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$ac_cv_type_char" = yes; then + # The cast to unsigned long works around a bug in the HP C Compiler + # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects + # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. + # This bug is HP SR number 8606223364. + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (char))) >= 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_lo=0 ac_mid=0 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (char))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo=`expr $ac_mid + 1` + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid + 1` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (char))) < 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=-1 ac_mid=-1 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (char))) >= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_lo=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_hi=`expr '(' $ac_mid ')' - 1` + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo= ac_hi= +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (char))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=$ac_mid +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo=`expr '(' $ac_mid ')' + 1` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in +?*) ac_cv_sizeof_char=$ac_lo;; +'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (char), 77 +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (char), 77 +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } ;; +esac +else + if test "$cross_compiling" = yes; then + { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot run test program while cross compiling +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +long longval () { return (long) (sizeof (char)); } +unsigned long ulongval () { return (long) (sizeof (char)); } +#include +#include +int +main () +{ + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + exit (1); + if (((long) (sizeof (char))) < 0) + { + long i = longval (); + if (i != ((long) (sizeof (char)))) + exit (1); + fprintf (f, "%ld\n", i); + } + else + { + unsigned long i = ulongval (); + if (i != ((long) (sizeof (char)))) + exit (1); + fprintf (f, "%lu\n", i); + } + exit (ferror (f) || fclose (f) != 0); + + ; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sizeof_char=`cat conftest.val` +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +{ { echo "$as_me:$LINENO: error: cannot compute sizeof (char), 77 +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (char), 77 +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +rm -f conftest.val +else + ac_cv_sizeof_char=0 +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_sizeof_char" >&5 +echo "${ECHO_T}$ac_cv_sizeof_char" >&6 +cat >>confdefs.h <<_ACEOF +#define SIZEOF_CHAR $ac_cv_sizeof_char +_ACEOF + + +echo "$as_me:$LINENO: checking for short" >&5 +echo $ECHO_N "checking for short... $ECHO_C" >&6 +if test "${ac_cv_type_short+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +if ((short *) 0) + return 0; +if (sizeof (short)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_short=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_type_short=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_short" >&5 +echo "${ECHO_T}$ac_cv_type_short" >&6 + +echo "$as_me:$LINENO: checking size of short" >&5 +echo $ECHO_N "checking size of short... $ECHO_C" >&6 +if test "${ac_cv_sizeof_short+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$ac_cv_type_short" = yes; then + # The cast to unsigned long works around a bug in the HP C Compiler + # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects + # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. + # This bug is HP SR number 8606223364. + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (short))) >= 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_lo=0 ac_mid=0 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (short))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo=`expr $ac_mid + 1` + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid + 1` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (short))) < 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=-1 ac_mid=-1 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (short))) >= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_lo=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_hi=`expr '(' $ac_mid ')' - 1` + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo= ac_hi= +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (short))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=$ac_mid +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo=`expr '(' $ac_mid ')' + 1` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in +?*) ac_cv_sizeof_short=$ac_lo;; +'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (short), 77 +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (short), 77 +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } ;; +esac +else + if test "$cross_compiling" = yes; then + { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot run test program while cross compiling +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +long longval () { return (long) (sizeof (short)); } +unsigned long ulongval () { return (long) (sizeof (short)); } +#include +#include +int +main () +{ + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + exit (1); + if (((long) (sizeof (short))) < 0) + { + long i = longval (); + if (i != ((long) (sizeof (short)))) + exit (1); + fprintf (f, "%ld\n", i); + } + else + { + unsigned long i = ulongval (); + if (i != ((long) (sizeof (short)))) + exit (1); + fprintf (f, "%lu\n", i); + } + exit (ferror (f) || fclose (f) != 0); + + ; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sizeof_short=`cat conftest.val` +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +{ { echo "$as_me:$LINENO: error: cannot compute sizeof (short), 77 +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (short), 77 +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +rm -f conftest.val +else + ac_cv_sizeof_short=0 +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_sizeof_short" >&5 +echo "${ECHO_T}$ac_cv_sizeof_short" >&6 +cat >>confdefs.h <<_ACEOF +#define SIZEOF_SHORT $ac_cv_sizeof_short +_ACEOF + + +echo "$as_me:$LINENO: checking for int" >&5 +echo $ECHO_N "checking for int... $ECHO_C" >&6 +if test "${ac_cv_type_int+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +if ((int *) 0) + return 0; +if (sizeof (int)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_int=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_type_int=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_int" >&5 +echo "${ECHO_T}$ac_cv_type_int" >&6 + +echo "$as_me:$LINENO: checking size of int" >&5 +echo $ECHO_N "checking size of int... $ECHO_C" >&6 +if test "${ac_cv_sizeof_int+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$ac_cv_type_int" = yes; then + # The cast to unsigned long works around a bug in the HP C Compiler + # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects + # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. + # This bug is HP SR number 8606223364. + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (int))) >= 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_lo=0 ac_mid=0 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (int))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo=`expr $ac_mid + 1` + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid + 1` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (int))) < 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=-1 ac_mid=-1 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (int))) >= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_lo=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_hi=`expr '(' $ac_mid ')' - 1` + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo= ac_hi= +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (int))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=$ac_mid +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo=`expr '(' $ac_mid ')' + 1` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in +?*) ac_cv_sizeof_int=$ac_lo;; +'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (int), 77 +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (int), 77 +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } ;; +esac +else + if test "$cross_compiling" = yes; then + { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot run test program while cross compiling +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +long longval () { return (long) (sizeof (int)); } +unsigned long ulongval () { return (long) (sizeof (int)); } +#include +#include +int +main () +{ + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + exit (1); + if (((long) (sizeof (int))) < 0) + { + long i = longval (); + if (i != ((long) (sizeof (int)))) + exit (1); + fprintf (f, "%ld\n", i); + } + else + { + unsigned long i = ulongval (); + if (i != ((long) (sizeof (int)))) + exit (1); + fprintf (f, "%lu\n", i); + } + exit (ferror (f) || fclose (f) != 0); + + ; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sizeof_int=`cat conftest.val` +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +{ { echo "$as_me:$LINENO: error: cannot compute sizeof (int), 77 +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (int), 77 +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +rm -f conftest.val +else + ac_cv_sizeof_int=0 +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_sizeof_int" >&5 +echo "${ECHO_T}$ac_cv_sizeof_int" >&6 +cat >>confdefs.h <<_ACEOF +#define SIZEOF_INT $ac_cv_sizeof_int +_ACEOF + + +echo "$as_me:$LINENO: checking for long" >&5 +echo $ECHO_N "checking for long... $ECHO_C" >&6 +if test "${ac_cv_type_long+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +if ((long *) 0) + return 0; +if (sizeof (long)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_long=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_type_long=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_long" >&5 +echo "${ECHO_T}$ac_cv_type_long" >&6 + +echo "$as_me:$LINENO: checking size of long" >&5 +echo $ECHO_N "checking size of long... $ECHO_C" >&6 +if test "${ac_cv_sizeof_long+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$ac_cv_type_long" = yes; then + # The cast to unsigned long works around a bug in the HP C Compiler + # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects + # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. + # This bug is HP SR number 8606223364. + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (long))) >= 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_lo=0 ac_mid=0 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (long))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo=`expr $ac_mid + 1` + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid + 1` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (long))) < 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=-1 ac_mid=-1 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (long))) >= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_lo=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_hi=`expr '(' $ac_mid ')' - 1` + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo= ac_hi= +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (long))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=$ac_mid +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo=`expr '(' $ac_mid ')' + 1` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in +?*) ac_cv_sizeof_long=$ac_lo;; +'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (long), 77 +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (long), 77 +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } ;; +esac +else + if test "$cross_compiling" = yes; then + { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot run test program while cross compiling +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +long longval () { return (long) (sizeof (long)); } +unsigned long ulongval () { return (long) (sizeof (long)); } +#include +#include +int +main () +{ + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + exit (1); + if (((long) (sizeof (long))) < 0) + { + long i = longval (); + if (i != ((long) (sizeof (long)))) + exit (1); + fprintf (f, "%ld\n", i); + } + else + { + unsigned long i = ulongval (); + if (i != ((long) (sizeof (long)))) + exit (1); + fprintf (f, "%lu\n", i); + } + exit (ferror (f) || fclose (f) != 0); + + ; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sizeof_long=`cat conftest.val` +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +{ { echo "$as_me:$LINENO: error: cannot compute sizeof (long), 77 +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (long), 77 +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +rm -f conftest.val +else + ac_cv_sizeof_long=0 +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_sizeof_long" >&5 +echo "${ECHO_T}$ac_cv_sizeof_long" >&6 +cat >>confdefs.h <<_ACEOF +#define SIZEOF_LONG $ac_cv_sizeof_long +_ACEOF + + +echo "$as_me:$LINENO: checking for long long" >&5 +echo $ECHO_N "checking for long long... $ECHO_C" >&6 +if test "${ac_cv_type_long_long+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +if ((long long *) 0) + return 0; +if (sizeof (long long)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_long_long=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_type_long_long=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_long_long" >&5 +echo "${ECHO_T}$ac_cv_type_long_long" >&6 + +echo "$as_me:$LINENO: checking size of long long" >&5 +echo $ECHO_N "checking size of long long... $ECHO_C" >&6 +if test "${ac_cv_sizeof_long_long+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$ac_cv_type_long_long" = yes; then + # The cast to unsigned long works around a bug in the HP C Compiler + # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects + # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. + # This bug is HP SR number 8606223364. + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (long long))) >= 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_lo=0 ac_mid=0 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (long long))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo=`expr $ac_mid + 1` + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid + 1` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (long long))) < 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=-1 ac_mid=-1 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (long long))) >= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_lo=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_hi=`expr '(' $ac_mid ')' - 1` + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo= ac_hi= +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (long long))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=$ac_mid +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo=`expr '(' $ac_mid ')' + 1` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in +?*) ac_cv_sizeof_long_long=$ac_lo;; +'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (long long), 77 +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (long long), 77 +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } ;; +esac +else + if test "$cross_compiling" = yes; then + { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot run test program while cross compiling +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +long longval () { return (long) (sizeof (long long)); } +unsigned long ulongval () { return (long) (sizeof (long long)); } +#include +#include +int +main () +{ + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + exit (1); + if (((long) (sizeof (long long))) < 0) + { + long i = longval (); + if (i != ((long) (sizeof (long long)))) + exit (1); + fprintf (f, "%ld\n", i); + } + else + { + unsigned long i = ulongval (); + if (i != ((long) (sizeof (long long)))) + exit (1); + fprintf (f, "%lu\n", i); + } + exit (ferror (f) || fclose (f) != 0); + + ; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sizeof_long_long=`cat conftest.val` +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +{ { echo "$as_me:$LINENO: error: cannot compute sizeof (long long), 77 +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (long long), 77 +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +rm -f conftest.val +else + ac_cv_sizeof_long_long=0 +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_sizeof_long_long" >&5 +echo "${ECHO_T}$ac_cv_sizeof_long_long" >&6 +cat >>confdefs.h <<_ACEOF +#define SIZEOF_LONG_LONG $ac_cv_sizeof_long_long +_ACEOF + + +echo "$as_me:$LINENO: checking for __int8" >&5 +echo $ECHO_N "checking for __int8... $ECHO_C" >&6 +if test "${ac_cv_type___int8+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +if ((__int8 *) 0) + return 0; +if (sizeof (__int8)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type___int8=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_type___int8=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type___int8" >&5 +echo "${ECHO_T}$ac_cv_type___int8" >&6 + +echo "$as_me:$LINENO: checking size of __int8" >&5 +echo $ECHO_N "checking size of __int8... $ECHO_C" >&6 +if test "${ac_cv_sizeof___int8+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$ac_cv_type___int8" = yes; then + # The cast to unsigned long works around a bug in the HP C Compiler + # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects + # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. + # This bug is HP SR number 8606223364. + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (__int8))) >= 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_lo=0 ac_mid=0 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (__int8))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo=`expr $ac_mid + 1` + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid + 1` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (__int8))) < 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=-1 ac_mid=-1 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (__int8))) >= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_lo=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_hi=`expr '(' $ac_mid ')' - 1` + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo= ac_hi= +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (__int8))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=$ac_mid +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo=`expr '(' $ac_mid ')' + 1` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in +?*) ac_cv_sizeof___int8=$ac_lo;; +'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (__int8), 77 +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (__int8), 77 +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } ;; +esac +else + if test "$cross_compiling" = yes; then + { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot run test program while cross compiling +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +long longval () { return (long) (sizeof (__int8)); } +unsigned long ulongval () { return (long) (sizeof (__int8)); } +#include +#include +int +main () +{ + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + exit (1); + if (((long) (sizeof (__int8))) < 0) + { + long i = longval (); + if (i != ((long) (sizeof (__int8)))) + exit (1); + fprintf (f, "%ld\n", i); + } + else + { + unsigned long i = ulongval (); + if (i != ((long) (sizeof (__int8)))) + exit (1); + fprintf (f, "%lu\n", i); + } + exit (ferror (f) || fclose (f) != 0); + + ; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sizeof___int8=`cat conftest.val` +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +{ { echo "$as_me:$LINENO: error: cannot compute sizeof (__int8), 77 +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (__int8), 77 +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +rm -f conftest.val +else + ac_cv_sizeof___int8=0 +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_sizeof___int8" >&5 +echo "${ECHO_T}$ac_cv_sizeof___int8" >&6 +cat >>confdefs.h <<_ACEOF +#define SIZEOF___INT8 $ac_cv_sizeof___int8 +_ACEOF + + +echo "$as_me:$LINENO: checking for __int16" >&5 +echo $ECHO_N "checking for __int16... $ECHO_C" >&6 +if test "${ac_cv_type___int16+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +if ((__int16 *) 0) + return 0; +if (sizeof (__int16)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type___int16=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_type___int16=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type___int16" >&5 +echo "${ECHO_T}$ac_cv_type___int16" >&6 + +echo "$as_me:$LINENO: checking size of __int16" >&5 +echo $ECHO_N "checking size of __int16... $ECHO_C" >&6 +if test "${ac_cv_sizeof___int16+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$ac_cv_type___int16" = yes; then + # The cast to unsigned long works around a bug in the HP C Compiler + # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects + # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. + # This bug is HP SR number 8606223364. + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (__int16))) >= 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_lo=0 ac_mid=0 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (__int16))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo=`expr $ac_mid + 1` + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid + 1` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (__int16))) < 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=-1 ac_mid=-1 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (__int16))) >= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_lo=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_hi=`expr '(' $ac_mid ')' - 1` + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo= ac_hi= +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (__int16))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=$ac_mid +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo=`expr '(' $ac_mid ')' + 1` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in +?*) ac_cv_sizeof___int16=$ac_lo;; +'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (__int16), 77 +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (__int16), 77 +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } ;; +esac +else + if test "$cross_compiling" = yes; then + { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot run test program while cross compiling +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +long longval () { return (long) (sizeof (__int16)); } +unsigned long ulongval () { return (long) (sizeof (__int16)); } +#include +#include +int +main () +{ + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + exit (1); + if (((long) (sizeof (__int16))) < 0) + { + long i = longval (); + if (i != ((long) (sizeof (__int16)))) + exit (1); + fprintf (f, "%ld\n", i); + } + else + { + unsigned long i = ulongval (); + if (i != ((long) (sizeof (__int16)))) + exit (1); + fprintf (f, "%lu\n", i); + } + exit (ferror (f) || fclose (f) != 0); + + ; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sizeof___int16=`cat conftest.val` +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +{ { echo "$as_me:$LINENO: error: cannot compute sizeof (__int16), 77 +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (__int16), 77 +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +rm -f conftest.val +else + ac_cv_sizeof___int16=0 +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_sizeof___int16" >&5 +echo "${ECHO_T}$ac_cv_sizeof___int16" >&6 +cat >>confdefs.h <<_ACEOF +#define SIZEOF___INT16 $ac_cv_sizeof___int16 +_ACEOF + + +echo "$as_me:$LINENO: checking for __int32" >&5 +echo $ECHO_N "checking for __int32... $ECHO_C" >&6 +if test "${ac_cv_type___int32+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +if ((__int32 *) 0) + return 0; +if (sizeof (__int32)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type___int32=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_type___int32=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type___int32" >&5 +echo "${ECHO_T}$ac_cv_type___int32" >&6 + +echo "$as_me:$LINENO: checking size of __int32" >&5 +echo $ECHO_N "checking size of __int32... $ECHO_C" >&6 +if test "${ac_cv_sizeof___int32+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$ac_cv_type___int32" = yes; then + # The cast to unsigned long works around a bug in the HP C Compiler + # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects + # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. + # This bug is HP SR number 8606223364. + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (__int32))) >= 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_lo=0 ac_mid=0 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (__int32))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo=`expr $ac_mid + 1` + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid + 1` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (__int32))) < 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=-1 ac_mid=-1 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (__int32))) >= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_lo=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_hi=`expr '(' $ac_mid ')' - 1` + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo= ac_hi= +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (__int32))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=$ac_mid +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo=`expr '(' $ac_mid ')' + 1` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in +?*) ac_cv_sizeof___int32=$ac_lo;; +'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (__int32), 77 +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (__int32), 77 +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } ;; +esac +else + if test "$cross_compiling" = yes; then + { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot run test program while cross compiling +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +long longval () { return (long) (sizeof (__int32)); } +unsigned long ulongval () { return (long) (sizeof (__int32)); } +#include +#include +int +main () +{ + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + exit (1); + if (((long) (sizeof (__int32))) < 0) + { + long i = longval (); + if (i != ((long) (sizeof (__int32)))) + exit (1); + fprintf (f, "%ld\n", i); + } + else + { + unsigned long i = ulongval (); + if (i != ((long) (sizeof (__int32)))) + exit (1); + fprintf (f, "%lu\n", i); + } + exit (ferror (f) || fclose (f) != 0); + + ; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sizeof___int32=`cat conftest.val` +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +{ { echo "$as_me:$LINENO: error: cannot compute sizeof (__int32), 77 +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (__int32), 77 +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +rm -f conftest.val +else + ac_cv_sizeof___int32=0 +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_sizeof___int32" >&5 +echo "${ECHO_T}$ac_cv_sizeof___int32" >&6 +cat >>confdefs.h <<_ACEOF +#define SIZEOF___INT32 $ac_cv_sizeof___int32 +_ACEOF + + +echo "$as_me:$LINENO: checking for __int64" >&5 +echo $ECHO_N "checking for __int64... $ECHO_C" >&6 +if test "${ac_cv_type___int64+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +if ((__int64 *) 0) + return 0; +if (sizeof (__int64)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type___int64=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_type___int64=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type___int64" >&5 +echo "${ECHO_T}$ac_cv_type___int64" >&6 + +echo "$as_me:$LINENO: checking size of __int64" >&5 +echo $ECHO_N "checking size of __int64... $ECHO_C" >&6 +if test "${ac_cv_sizeof___int64+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$ac_cv_type___int64" = yes; then + # The cast to unsigned long works around a bug in the HP C Compiler + # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects + # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. + # This bug is HP SR number 8606223364. + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (__int64))) >= 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_lo=0 ac_mid=0 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (__int64))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo=`expr $ac_mid + 1` + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid + 1` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (__int64))) < 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=-1 ac_mid=-1 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (__int64))) >= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_lo=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_hi=`expr '(' $ac_mid ')' - 1` + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo= ac_hi= +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (__int64))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=$ac_mid +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo=`expr '(' $ac_mid ')' + 1` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in +?*) ac_cv_sizeof___int64=$ac_lo;; +'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (__int64), 77 +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (__int64), 77 +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } ;; +esac +else + if test "$cross_compiling" = yes; then + { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot run test program while cross compiling +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +long longval () { return (long) (sizeof (__int64)); } +unsigned long ulongval () { return (long) (sizeof (__int64)); } +#include +#include +int +main () +{ + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + exit (1); + if (((long) (sizeof (__int64))) < 0) + { + long i = longval (); + if (i != ((long) (sizeof (__int64)))) + exit (1); + fprintf (f, "%ld\n", i); + } + else + { + unsigned long i = ulongval (); + if (i != ((long) (sizeof (__int64)))) + exit (1); + fprintf (f, "%lu\n", i); + } + exit (ferror (f) || fclose (f) != 0); + + ; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sizeof___int64=`cat conftest.val` +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +{ { echo "$as_me:$LINENO: error: cannot compute sizeof (__int64), 77 +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (__int64), 77 +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +rm -f conftest.val +else + ac_cv_sizeof___int64=0 +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_sizeof___int64" >&5 +echo "${ECHO_T}$ac_cv_sizeof___int64" >&6 +cat >>confdefs.h <<_ACEOF +#define SIZEOF___INT64 $ac_cv_sizeof___int64 +_ACEOF + + +echo "$as_me:$LINENO: checking for __int96" >&5 +echo $ECHO_N "checking for __int96... $ECHO_C" >&6 +if test "${ac_cv_type___int96+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +if ((__int96 *) 0) + return 0; +if (sizeof (__int96)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type___int96=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_type___int96=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type___int96" >&5 +echo "${ECHO_T}$ac_cv_type___int96" >&6 + +echo "$as_me:$LINENO: checking size of __int96" >&5 +echo $ECHO_N "checking size of __int96... $ECHO_C" >&6 +if test "${ac_cv_sizeof___int96+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$ac_cv_type___int96" = yes; then + # The cast to unsigned long works around a bug in the HP C Compiler + # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects + # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. + # This bug is HP SR number 8606223364. + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (__int96))) >= 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_lo=0 ac_mid=0 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (__int96))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo=`expr $ac_mid + 1` + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid + 1` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (__int96))) < 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=-1 ac_mid=-1 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (__int96))) >= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_lo=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_hi=`expr '(' $ac_mid ')' - 1` + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo= ac_hi= +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (__int96))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=$ac_mid +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo=`expr '(' $ac_mid ')' + 1` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in +?*) ac_cv_sizeof___int96=$ac_lo;; +'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (__int96), 77 +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (__int96), 77 +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } ;; +esac +else + if test "$cross_compiling" = yes; then + { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot run test program while cross compiling +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +long longval () { return (long) (sizeof (__int96)); } +unsigned long ulongval () { return (long) (sizeof (__int96)); } +#include +#include +int +main () +{ + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + exit (1); + if (((long) (sizeof (__int96))) < 0) + { + long i = longval (); + if (i != ((long) (sizeof (__int96)))) + exit (1); + fprintf (f, "%ld\n", i); + } + else + { + unsigned long i = ulongval (); + if (i != ((long) (sizeof (__int96)))) + exit (1); + fprintf (f, "%lu\n", i); + } + exit (ferror (f) || fclose (f) != 0); + + ; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sizeof___int96=`cat conftest.val` +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +{ { echo "$as_me:$LINENO: error: cannot compute sizeof (__int96), 77 +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (__int96), 77 +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +rm -f conftest.val +else + ac_cv_sizeof___int96=0 +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_sizeof___int96" >&5 +echo "${ECHO_T}$ac_cv_sizeof___int96" >&6 +cat >>confdefs.h <<_ACEOF +#define SIZEOF___INT96 $ac_cv_sizeof___int96 +_ACEOF + + +echo "$as_me:$LINENO: checking for __int128" >&5 +echo $ECHO_N "checking for __int128... $ECHO_C" >&6 +if test "${ac_cv_type___int128+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +if ((__int128 *) 0) + return 0; +if (sizeof (__int128)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type___int128=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_type___int128=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type___int128" >&5 +echo "${ECHO_T}$ac_cv_type___int128" >&6 + +echo "$as_me:$LINENO: checking size of __int128" >&5 +echo $ECHO_N "checking size of __int128... $ECHO_C" >&6 +if test "${ac_cv_sizeof___int128+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$ac_cv_type___int128" = yes; then + # The cast to unsigned long works around a bug in the HP C Compiler + # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects + # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. + # This bug is HP SR number 8606223364. + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (__int128))) >= 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_lo=0 ac_mid=0 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (__int128))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo=`expr $ac_mid + 1` + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid + 1` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (__int128))) < 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=-1 ac_mid=-1 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (__int128))) >= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_lo=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_hi=`expr '(' $ac_mid ')' - 1` + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo= ac_hi= +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (__int128))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=$ac_mid +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo=`expr '(' $ac_mid ')' + 1` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in +?*) ac_cv_sizeof___int128=$ac_lo;; +'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (__int128), 77 +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (__int128), 77 +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } ;; +esac +else + if test "$cross_compiling" = yes; then + { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot run test program while cross compiling +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +long longval () { return (long) (sizeof (__int128)); } +unsigned long ulongval () { return (long) (sizeof (__int128)); } +#include +#include +int +main () +{ + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + exit (1); + if (((long) (sizeof (__int128))) < 0) + { + long i = longval (); + if (i != ((long) (sizeof (__int128)))) + exit (1); + fprintf (f, "%ld\n", i); + } + else + { + unsigned long i = ulongval (); + if (i != ((long) (sizeof (__int128)))) + exit (1); + fprintf (f, "%lu\n", i); + } + exit (ferror (f) || fclose (f) != 0); + + ; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sizeof___int128=`cat conftest.val` +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +{ { echo "$as_me:$LINENO: error: cannot compute sizeof (__int128), 77 +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (__int128), 77 +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +rm -f conftest.val +else + ac_cv_sizeof___int128=0 +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_sizeof___int128" >&5 +echo "${ECHO_T}$ac_cv_sizeof___int128" >&6 +cat >>confdefs.h <<_ACEOF +#define SIZEOF___INT128 $ac_cv_sizeof___int128 +_ACEOF + + +echo "$as_me:$LINENO: checking for void *" >&5 +echo $ECHO_N "checking for void *... $ECHO_C" >&6 +if test "${ac_cv_type_void_p+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +if ((void * *) 0) + return 0; +if (sizeof (void *)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_void_p=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_type_void_p=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_void_p" >&5 +echo "${ECHO_T}$ac_cv_type_void_p" >&6 + +echo "$as_me:$LINENO: checking size of void *" >&5 +echo $ECHO_N "checking size of void *... $ECHO_C" >&6 +if test "${ac_cv_sizeof_void_p+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$ac_cv_type_void_p" = yes; then + # The cast to unsigned long works around a bug in the HP C Compiler + # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects + # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. + # This bug is HP SR number 8606223364. + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (void *))) >= 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_lo=0 ac_mid=0 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (void *))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo=`expr $ac_mid + 1` + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid + 1` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (void *))) < 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=-1 ac_mid=-1 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (void *))) >= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_lo=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_hi=`expr '(' $ac_mid ')' - 1` + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo= ac_hi= +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (void *))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=$ac_mid +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo=`expr '(' $ac_mid ')' + 1` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in +?*) ac_cv_sizeof_void_p=$ac_lo;; +'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (void *), 77 +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (void *), 77 +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } ;; +esac +else + if test "$cross_compiling" = yes; then + { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot run test program while cross compiling +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +long longval () { return (long) (sizeof (void *)); } +unsigned long ulongval () { return (long) (sizeof (void *)); } +#include +#include +int +main () +{ + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + exit (1); + if (((long) (sizeof (void *))) < 0) + { + long i = longval (); + if (i != ((long) (sizeof (void *)))) + exit (1); + fprintf (f, "%ld\n", i); + } + else + { + unsigned long i = ulongval (); + if (i != ((long) (sizeof (void *)))) + exit (1); + fprintf (f, "%lu\n", i); + } + exit (ferror (f) || fclose (f) != 0); + + ; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sizeof_void_p=`cat conftest.val` +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +{ { echo "$as_me:$LINENO: error: cannot compute sizeof (void *), 77 +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (void *), 77 +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +rm -f conftest.val +else + ac_cv_sizeof_void_p=0 +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_sizeof_void_p" >&5 +echo "${ECHO_T}$ac_cv_sizeof_void_p" >&6 +cat >>confdefs.h <<_ACEOF +#define SIZEOF_VOID_P $ac_cv_sizeof_void_p +_ACEOF + + +echo "$as_me:$LINENO: checking for float" >&5 +echo $ECHO_N "checking for float... $ECHO_C" >&6 +if test "${ac_cv_type_float+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +if ((float *) 0) + return 0; +if (sizeof (float)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_float=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_type_float=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_float" >&5 +echo "${ECHO_T}$ac_cv_type_float" >&6 + +echo "$as_me:$LINENO: checking size of float" >&5 +echo $ECHO_N "checking size of float... $ECHO_C" >&6 +if test "${ac_cv_sizeof_float+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$ac_cv_type_float" = yes; then + # The cast to unsigned long works around a bug in the HP C Compiler + # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects + # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. + # This bug is HP SR number 8606223364. + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (float))) >= 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_lo=0 ac_mid=0 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (float))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo=`expr $ac_mid + 1` + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid + 1` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (float))) < 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=-1 ac_mid=-1 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (float))) >= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_lo=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_hi=`expr '(' $ac_mid ')' - 1` + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo= ac_hi= +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (float))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=$ac_mid +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo=`expr '(' $ac_mid ')' + 1` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in +?*) ac_cv_sizeof_float=$ac_lo;; +'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (float), 77 +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (float), 77 +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } ;; +esac +else + if test "$cross_compiling" = yes; then + { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot run test program while cross compiling +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +long longval () { return (long) (sizeof (float)); } +unsigned long ulongval () { return (long) (sizeof (float)); } +#include +#include +int +main () +{ + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + exit (1); + if (((long) (sizeof (float))) < 0) + { + long i = longval (); + if (i != ((long) (sizeof (float)))) + exit (1); + fprintf (f, "%ld\n", i); + } + else + { + unsigned long i = ulongval (); + if (i != ((long) (sizeof (float)))) + exit (1); + fprintf (f, "%lu\n", i); + } + exit (ferror (f) || fclose (f) != 0); + + ; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sizeof_float=`cat conftest.val` +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +{ { echo "$as_me:$LINENO: error: cannot compute sizeof (float), 77 +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (float), 77 +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +rm -f conftest.val +else + ac_cv_sizeof_float=0 +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_sizeof_float" >&5 +echo "${ECHO_T}$ac_cv_sizeof_float" >&6 +cat >>confdefs.h <<_ACEOF +#define SIZEOF_FLOAT $ac_cv_sizeof_float +_ACEOF + + +echo "$as_me:$LINENO: checking for double" >&5 +echo $ECHO_N "checking for double... $ECHO_C" >&6 +if test "${ac_cv_type_double+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +if ((double *) 0) + return 0; +if (sizeof (double)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_double=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_type_double=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_double" >&5 +echo "${ECHO_T}$ac_cv_type_double" >&6 + +echo "$as_me:$LINENO: checking size of double" >&5 +echo $ECHO_N "checking size of double... $ECHO_C" >&6 +if test "${ac_cv_sizeof_double+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$ac_cv_type_double" = yes; then + # The cast to unsigned long works around a bug in the HP C Compiler + # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects + # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. + # This bug is HP SR number 8606223364. + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (double))) >= 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_lo=0 ac_mid=0 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (double))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo=`expr $ac_mid + 1` + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid + 1` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (double))) < 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=-1 ac_mid=-1 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (double))) >= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_lo=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_hi=`expr '(' $ac_mid ')' - 1` + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo= ac_hi= +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (double))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=$ac_mid +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo=`expr '(' $ac_mid ')' + 1` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in +?*) ac_cv_sizeof_double=$ac_lo;; +'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (double), 77 +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (double), 77 +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } ;; +esac +else + if test "$cross_compiling" = yes; then + { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot run test program while cross compiling +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +long longval () { return (long) (sizeof (double)); } +unsigned long ulongval () { return (long) (sizeof (double)); } +#include +#include +int +main () +{ + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + exit (1); + if (((long) (sizeof (double))) < 0) + { + long i = longval (); + if (i != ((long) (sizeof (double)))) + exit (1); + fprintf (f, "%ld\n", i); + } + else + { + unsigned long i = ulongval (); + if (i != ((long) (sizeof (double)))) + exit (1); + fprintf (f, "%lu\n", i); + } + exit (ferror (f) || fclose (f) != 0); + + ; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sizeof_double=`cat conftest.val` +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +{ { echo "$as_me:$LINENO: error: cannot compute sizeof (double), 77 +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (double), 77 +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +rm -f conftest.val +else + ac_cv_sizeof_double=0 +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_sizeof_double" >&5 +echo "${ECHO_T}$ac_cv_sizeof_double" >&6 +cat >>confdefs.h <<_ACEOF +#define SIZEOF_DOUBLE $ac_cv_sizeof_double +_ACEOF + + +echo "$as_me:$LINENO: checking for long double" >&5 +echo $ECHO_N "checking for long double... $ECHO_C" >&6 +if test "${ac_cv_type_long_double+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +if ((long double *) 0) + return 0; +if (sizeof (long double)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_long_double=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_type_long_double=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_long_double" >&5 +echo "${ECHO_T}$ac_cv_type_long_double" >&6 + +echo "$as_me:$LINENO: checking size of long double" >&5 +echo $ECHO_N "checking size of long double... $ECHO_C" >&6 +if test "${ac_cv_sizeof_long_double+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$ac_cv_type_long_double" = yes; then + # The cast to unsigned long works around a bug in the HP C Compiler + # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects + # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. + # This bug is HP SR number 8606223364. + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (long double))) >= 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_lo=0 ac_mid=0 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (long double))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo=`expr $ac_mid + 1` + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid + 1` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (long double))) < 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=-1 ac_mid=-1 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (long double))) >= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_lo=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_hi=`expr '(' $ac_mid ')' - 1` + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo= ac_hi= +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (long double))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=$ac_mid +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo=`expr '(' $ac_mid ')' + 1` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in +?*) ac_cv_sizeof_long_double=$ac_lo;; +'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (long double), 77 +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (long double), 77 +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } ;; +esac +else + if test "$cross_compiling" = yes; then + { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot run test program while cross compiling +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +long longval () { return (long) (sizeof (long double)); } +unsigned long ulongval () { return (long) (sizeof (long double)); } +#include +#include +int +main () +{ + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + exit (1); + if (((long) (sizeof (long double))) < 0) + { + long i = longval (); + if (i != ((long) (sizeof (long double)))) + exit (1); + fprintf (f, "%ld\n", i); + } + else + { + unsigned long i = ulongval (); + if (i != ((long) (sizeof (long double)))) + exit (1); + fprintf (f, "%lu\n", i); + } + exit (ferror (f) || fclose (f) != 0); + + ; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sizeof_long_double=`cat conftest.val` +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +{ { echo "$as_me:$LINENO: error: cannot compute sizeof (long double), 77 +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (long double), 77 +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +rm -f conftest.val +else + ac_cv_sizeof_long_double=0 +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_sizeof_long_double" >&5 +echo "${ECHO_T}$ac_cv_sizeof_long_double" >&6 +cat >>confdefs.h <<_ACEOF +#define SIZEOF_LONG_DOUBLE $ac_cv_sizeof_long_double +_ACEOF + + +echo "$as_me:$LINENO: checking for wchar_t" >&5 +echo $ECHO_N "checking for wchar_t... $ECHO_C" >&6 +if test "${ac_cv_type_wchar_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +if ((wchar_t *) 0) + return 0; +if (sizeof (wchar_t)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_wchar_t=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_type_wchar_t=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_wchar_t" >&5 +echo "${ECHO_T}$ac_cv_type_wchar_t" >&6 + +echo "$as_me:$LINENO: checking size of wchar_t" >&5 +echo $ECHO_N "checking size of wchar_t... $ECHO_C" >&6 +if test "${ac_cv_sizeof_wchar_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$ac_cv_type_wchar_t" = yes; then + # The cast to unsigned long works around a bug in the HP C Compiler + # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects + # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. + # This bug is HP SR number 8606223364. + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (wchar_t))) >= 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_lo=0 ac_mid=0 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (wchar_t))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo=`expr $ac_mid + 1` + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid + 1` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (wchar_t))) < 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=-1 ac_mid=-1 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (wchar_t))) >= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_lo=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_hi=`expr '(' $ac_mid ')' - 1` + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo= ac_hi= +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long) (sizeof (wchar_t))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_hi=$ac_mid +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_lo=`expr '(' $ac_mid ')' + 1` +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in +?*) ac_cv_sizeof_wchar_t=$ac_lo;; +'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (wchar_t), 77 +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (wchar_t), 77 +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } ;; +esac +else + if test "$cross_compiling" = yes; then + { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot run test program while cross compiling +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +long longval () { return (long) (sizeof (wchar_t)); } +unsigned long ulongval () { return (long) (sizeof (wchar_t)); } +#include +#include +int +main () +{ + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + exit (1); + if (((long) (sizeof (wchar_t))) < 0) + { + long i = longval (); + if (i != ((long) (sizeof (wchar_t)))) + exit (1); + fprintf (f, "%ld\n", i); + } + else + { + unsigned long i = ulongval (); + if (i != ((long) (sizeof (wchar_t)))) + exit (1); + fprintf (f, "%lu\n", i); + } + exit (ferror (f) || fclose (f) != 0); + + ; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sizeof_wchar_t=`cat conftest.val` +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +{ { echo "$as_me:$LINENO: error: cannot compute sizeof (wchar_t), 77 +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (wchar_t), 77 +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +rm -f conftest.val +else + ac_cv_sizeof_wchar_t=0 +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_sizeof_wchar_t" >&5 +echo "${ECHO_T}$ac_cv_sizeof_wchar_t" >&6 +cat >>confdefs.h <<_ACEOF +#define SIZEOF_WCHAR_T $ac_cv_sizeof_wchar_t +_ACEOF + + + +cat >>confdefs.h <<_ACEOF +#define ASE_SIZEOF_CHAR ${ac_cv_sizeof_char} +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define ASE_SIZEOF_SHORT ${ac_cv_sizeof_short} +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define ASE_SIZEOF_INT ${ac_cv_sizeof_int} +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define ASE_SIZEOF_LONG ${ac_cv_sizeof_long} +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define ASE_SIZEOF_LONG_LONG ${ac_cv_sizeof_long_long} +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define ASE_SIZEOF___INT8 ${ac_cv_sizeof___int8} +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define ASE_SIZEOF___INT16 ${ac_cv_sizeof___int16} +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define ASE_SIZEOF___INT32 ${ac_cv_sizeof___int32} +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define ASE_SIZEOF___INT64 ${ac_cv_sizeof___int64} +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define ASE_SIZEOF___INT96 ${ac_cv_sizeof___int96} +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define ASE_SIZEOF___INT128 ${ac_cv_sizeof___int128} +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define ASE_SIZEOF_VOID_P ${ac_cv_sizeof_void_p} +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define ASE_SIZEOF_FLOAT ${ac_cv_sizeof_float} +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define ASE_SIZEOF_DOUBLE ${ac_cv_sizeof_double} +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define ASE_SIZEOF_LONG_DOUBLE ${ac_cv_sizeof_long_double} +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define ASE_SIZEOF_WCHAR_T ${ac_cv_sizeof_wchar_t} +_ACEOF + + +# Defines extra options + +# Check whether --enable-wchar or --disable-wchar was given. +if test "${enable_wchar+set}" = set; then + enableval="$enable_wchar" + enable_wchar_is=$enableval +else + enable_wchar_is=yes +fi; +if test "$enable_wchar_is" = "yes" +then + +cat >>confdefs.h <<\_ACEOF +#define ASE_CHAR_IS_WCHAR +_ACEOF + +else + +cat >>confdefs.h <<\_ACEOF +#define ASE_CHAR_IS_MCHAR +_ACEOF + +fi + +# Check whether --enable-mode or --disable-mode was given. +if test "${enable_mode+set}" = set; then + enableval="$enable_mode" + enable_debug_is=$enableval +else + enable_debug_is=no +fi; +if test "$enable_debug_is" = "yes" +then + CFLAGS="$CFLAGS -g -D_DEBUG -UNDEBUG" + CXXFLAGS="$CXXFLAGS -g -D_DEBUG -UNDEBUG" + BUILDMODE="debug" + +else + CFLAGS="$CFLAGS -DNDEBUG -U_DEBUG" + CXXFLAGS="$CXXFLAGS -DNDEBUG -U_DEBUG" + BUILDMODE="release" + +fi + +# Configure makefiles +# Check whether --enable-reentrant or --disable-reentrant was given. +if test "${enable_reentrant+set}" = set; then + enableval="$enable_reentrant" + enable_reentrant_is=$enableval +else + enable_reentrant_is=yes +fi; +if test "$enable_reentrant_is" = "yes" +then + CFLAGS="$CFLAGS -D_REENTRANT -D_THREAD_SAFE" + CXXFLAGS="$CXXFLAGS -D_REENTRANT -D_THREAD_SAFE" +fi + +# Java & JNI Configuration +# Extract the first word of "javac", so it can be a program name with args. +set dummy javac; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_path_JAVAC_PATH+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $JAVAC_PATH in + [\\/]* | ?:[\\/]*) + ac_cv_path_JAVAC_PATH="$JAVAC_PATH" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_JAVAC_PATH="$as_dir/$ac_word$ac_exec_ext" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + + test -z "$ac_cv_path_JAVAC_PATH" && ac_cv_path_JAVAC_PATH=":" + ;; +esac +fi +JAVAC_PATH=$ac_cv_path_JAVAC_PATH + +if test -n "$JAVAC_PATH"; then + echo "$as_me:$LINENO: result: $JAVAC_PATH" >&5 +echo "${ECHO_T}$JAVAC_PATH" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +# Extract the first word of "jar", so it can be a program name with args. +set dummy jar; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_path_JAR_PATH+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $JAR_PATH in + [\\/]* | ?:[\\/]*) + ac_cv_path_JAR_PATH="$JAR_PATH" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_JAR_PATH="$as_dir/$ac_word$ac_exec_ext" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + + test -z "$ac_cv_path_JAR_PATH" && ac_cv_path_JAR_PATH=":" + ;; +esac +fi +JAR_PATH=$ac_cv_path_JAR_PATH + +if test -n "$JAR_PATH"; then + echo "$as_me:$LINENO: result: $JAR_PATH" >&5 +echo "${ECHO_T}$JAR_PATH" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + +if test "$JAVAC_PATH" != ":" +then + CUR_JAVAC_PATH="$JAVAC_PATH" + + while ls -ld "$CUR_JAVAC_PATH" 2>/dev/null | grep " -> " >/dev/null + do + echo "$as_me:$LINENO: checking symlink for $CUR_JAVAC_PATH" >&5 +echo $ECHO_N "checking symlink for $CUR_JAVAC_PATH... $ECHO_C" >&6 + REAL_JAVAC_PATH=`ls -ld "$CUR_JAVAC_PATH" | sed 's/.* -> //'` + + case "$REAL_JAVAC_PATH" in + /*) CUR_JAVAC_PATH="$REAL_JAVAC_PATH";; + *) CUR_JAVAC_PATH=`echo "X$CUR_JAVAC_PATH" | sed -e 's/^X//' -e 's:[^/]*$::'`"$REAL_JAVAC_PATH";; + esac + + echo "$as_me:$LINENO: result: $CUR_JAVAC_PATH" >&5 +echo "${ECHO_T}$CUR_JAVAC_PATH" >&6 + done + + JAVA_DIR="$CUR_JAVAC_PATH" + + while true + do + JAVA_DIR=`echo "$JAVA_DIR" | sed -e 's://*:/:g' -e 's:/[^/]*$::'` + if test "$JAVA_DIR" = "" + then + break + fi + + echo "$as_me:$LINENO: checking $JAVA_DIR/include/jni.h" >&5 +echo $ECHO_N "checking $JAVA_DIR/include/jni.h... $ECHO_C" >&6 + if test -f "$JAVA_DIR/include/jni.h" + then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $JAVA_DIR/include" + break; + else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + fi + done + + for i in $JNI_INCLUDE_DIRS + do + JNI_MD_H=`find "$i" -name jni_md.h -print` + if test "$JNI_MD_H" != "" + then + tmp=`echo "$JNI_MD_H" | sed -e 's://*:/:g' -e 's:/[^/]*$::'` + JNI_MD_INCLUDE_DIRS="$JNI_MD_INCLUDE_DIRS $tmp" + fi + done + + JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $JNI_MD_INCLUDE_DIRS" + + for i in $JNI_INCLUDE_DIRS + do + CFLAGS_JNI="$CFLAGS_JNI -I$i" + done + + JNI="jni" +else + JAVAC_PATH="" + CFLAGS_JNI="" + JNI="" +fi + +CFLAGS_JNI=$CFLAGS_JNI + +JAVAC=$JAVAC_PATH + +JAR=$JAR_PATH + +JNI=$JNI + + + ac_config_files="$ac_config_files makefile cmn/makefile awk/makefile lsp/makefile utl/makefile test/awk/makefile test/lsp/makefile" + +cat >confcache <<\_ACEOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `ac_cv_env_foo' variables (set or unset) will be overridden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, don't put newlines in cache variables' values. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +{ + (set) 2>&1 | + case `(ac_space=' '; set | grep ac_space) 2>&1` in + *ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n \ + "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + ;; + esac; +} | + sed ' + t clear + : clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + : end' >>confcache +if diff $cache_file confcache >/dev/null 2>&1; then :; else + if test -w $cache_file; then + test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file" + cat confcache >$cache_file + else + echo "not updating unwritable cache $cache_file" + fi +fi +rm -f confcache + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +# VPATH may cause trouble with some makes, so we remove $(srcdir), +# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=/{ +s/:*\$(srcdir):*/:/; +s/:*\${srcdir}:*/:/; +s/:*@srcdir@:*/:/; +s/^\([^=]*=[ ]*\):*/\1/; +s/:*$//; +s/^[^=]*=[ ]*$//; +}' +fi + +DEFS=-DHAVE_CONFIG_H + +ac_libobjs= +ac_ltlibobjs= +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue + # 1. Remove the extension, and $U if already installed. + ac_i=`echo "$ac_i" | + sed 's/\$U\././;s/\.o$//;s/\.obj$//'` + # 2. Add them. + ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext" + ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs + +LTLIBOBJS=$ac_ltlibobjs + + + +: ${CONFIG_STATUS=./config.status} +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 +echo "$as_me: creating $CONFIG_STATUS" >&6;} +cat >$CONFIG_STATUS <<_ACEOF +#! $SHELL +# Generated by $as_me. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false +SHELL=\${CONFIG_SHELL-$SHELL} +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' +elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then + set -o posix +fi +DUALCASE=1; export DUALCASE # for MKS sh + +# Support unset when possible. +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + + +# Work around bugs in pre-3.0 UWIN ksh. +$as_unset ENV MAIL MAILPATH +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME +do + if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + $as_unset $as_var + fi +done + +# Required to use basename. +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + + +# Name of the executable. +as_me=`$as_basename "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)$' \| \ + . : '\(.\)' 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } + /^X\/\(\/\/\)$/{ s//\1/; q; } + /^X\/\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + + +# PATH needs CR, and LINENO needs CR and PATH. +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" || { + # Find who we are. Look in the path if we contain no path at all + # relative or not. + case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done + + ;; + esac + # We did not find ourselves, most probably we were run as `sh COMMAND' + # in which case we are not to be found in the path. + if test "x$as_myself" = x; then + as_myself=$0 + fi + if test ! -f "$as_myself"; then + { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5 +echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;} + { (exit 1); exit 1; }; } + fi + case $CONFIG_SHELL in + '') + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for as_base in sh bash ksh sh5; do + case $as_dir in + /*) + if ("$as_dir/$as_base" -c ' + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then + $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } + $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } + CONFIG_SHELL=$as_dir/$as_base + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$0" ${1+"$@"} + fi;; + esac + done +done +;; + esac + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line before each line; the second 'sed' does the real + # work. The second script uses 'N' to pair each line-number line + # with the numbered line, and appends trailing '-' during + # substitution so that $LINENO is not a special case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) + sed '=' <$as_myself | + sed ' + N + s,$,-, + : loop + s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, + t loop + s,-$,, + s,^['$as_cr_digits']*\n,, + ' >$as_me.lineno && + chmod +x $as_me.lineno || + { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5 +echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;} + { (exit 1); exit 1; }; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensible to this). + . ./$as_me.lineno + # Exit status is that of the last command. + exit +} + + +case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in + *c*,-n*) ECHO_N= ECHO_C=' +' ECHO_T=' ' ;; + *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; + *) ECHO_N= ECHO_C='\c' ECHO_T= ;; +esac + +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + # We could just check for DJGPP; but this test a) works b) is more generic + # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). + if test -f conf$$.exe; then + # Don't use ln at all; we don't have any links + as_ln_s='cp -p' + else + as_ln_s='ln -s' + fi +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.file + +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +as_executable_p="test -f" + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +# IFS +# We need space, tab and new line, in precisely that order. +as_nl=' +' +IFS=" $as_nl" + +# CDPATH. +$as_unset CDPATH + +exec 6>&1 + +# Open the log real soon, to keep \$[0] and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. Logging --version etc. is OK. +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX +} >&5 +cat >&5 <<_CSEOF + +This file was extended by ase $as_me deb-0.1.0, which was +generated by GNU Autoconf 2.59. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +_CSEOF +echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5 +echo >&5 +_ACEOF + +# Files that config.status was made for. +if test -n "$ac_config_files"; then + echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_headers"; then + echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_links"; then + echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_commands"; then + echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS +fi + +cat >>$CONFIG_STATUS <<\_ACEOF + +ac_cs_usage="\ +\`$as_me' instantiates files from templates according to the +current configuration. + +Usage: $0 [OPTIONS] [FILE]... + + -h, --help print this help, then exit + -V, --version print version number, then exit + -q, --quiet do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + --header=FILE[:TEMPLATE] + instantiate the configuration header FILE + +Configuration files: +$config_files + +Configuration headers: +$config_headers + +Report bugs to ." +_ACEOF + +cat >>$CONFIG_STATUS <<_ACEOF +ac_cs_version="\\ +ase config.status deb-0.1.0 +configured by $0, generated by GNU Autoconf 2.59, + with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" + +Copyright (C) 2003 Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." +srcdir=$srcdir +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +# If no file are specified by the user, then we need to provide default +# value. By we need to know if files were specified by the user. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=*) + ac_option=`expr "x$1" : 'x\([^=]*\)='` + ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'` + ac_shift=: + ;; + -*) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + *) # This is not an option, so the user has probably given explicit + # arguments. + ac_option=$1 + ac_need_defaults=false;; + esac + + case $ac_option in + # Handling of the options. +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --vers* | -V ) + echo "$ac_cs_version"; exit 0 ;; + --he | --h) + # Conflict between --help and --header + { { echo "$as_me:$LINENO: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&5 +echo "$as_me: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&2;} + { (exit 1); exit 1; }; };; + --help | --hel | -h ) + echo "$ac_cs_usage"; exit 0 ;; + --debug | --d* | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + CONFIG_FILES="$CONFIG_FILES $ac_optarg" + ac_need_defaults=false;; + --header | --heade | --head | --hea ) + $ac_shift + CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg" + ac_need_defaults=false;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&5 +echo "$as_me: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&2;} + { (exit 1); exit 1; }; } ;; + + *) ac_config_targets="$ac_config_targets $1" ;; + + esac + shift +done + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF +if \$ac_cs_recheck; then + echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 + exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion +fi + +_ACEOF + + + + + +cat >>$CONFIG_STATUS <<\_ACEOF +for ac_config_target in $ac_config_targets +do + case "$ac_config_target" in + # Handling of arguments. + "makefile" ) CONFIG_FILES="$CONFIG_FILES makefile" ;; + "cmn/makefile" ) CONFIG_FILES="$CONFIG_FILES cmn/makefile" ;; + "awk/makefile" ) CONFIG_FILES="$CONFIG_FILES awk/makefile" ;; + "lsp/makefile" ) CONFIG_FILES="$CONFIG_FILES lsp/makefile" ;; + "utl/makefile" ) CONFIG_FILES="$CONFIG_FILES utl/makefile" ;; + "test/awk/makefile" ) CONFIG_FILES="$CONFIG_FILES test/awk/makefile" ;; + "test/lsp/makefile" ) CONFIG_FILES="$CONFIG_FILES test/lsp/makefile" ;; + "cmn/conf_unx.h" ) CONFIG_HEADERS="$CONFIG_HEADERS cmn/conf_unx.h" ;; + *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 +echo "$as_me: error: invalid argument: $ac_config_target" >&2;} + { (exit 1); exit 1; }; };; + esac +done + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files + test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason to put it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Create a temporary directory, and hook for its removal unless debugging. +$debug || +{ + trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0 + trap '{ (exit 1); exit 1; }' 1 2 13 15 +} + +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` && + test -n "$tmp" && test -d "$tmp" +} || +{ + tmp=./confstat$$-$RANDOM + (umask 077 && mkdir $tmp) +} || +{ + echo "$me: cannot create a temporary directory in ." >&2 + { (exit 1); exit 1; } +} + +_ACEOF + +cat >>$CONFIG_STATUS <<_ACEOF + +# +# CONFIG_FILES section. +# + +# No need to generate the scripts if there are no CONFIG_FILES. +# This happens for instance when ./config.status config.h +if test -n "\$CONFIG_FILES"; then + # Protect against being on the right side of a sed subst in config.status. + sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g; + s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF +s,@SHELL@,$SHELL,;t t +s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t +s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t +s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t +s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t +s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t +s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t +s,@exec_prefix@,$exec_prefix,;t t +s,@prefix@,$prefix,;t t +s,@program_transform_name@,$program_transform_name,;t t +s,@bindir@,$bindir,;t t +s,@sbindir@,$sbindir,;t t +s,@libexecdir@,$libexecdir,;t t +s,@datadir@,$datadir,;t t +s,@sysconfdir@,$sysconfdir,;t t +s,@sharedstatedir@,$sharedstatedir,;t t +s,@localstatedir@,$localstatedir,;t t +s,@libdir@,$libdir,;t t +s,@includedir@,$includedir,;t t +s,@oldincludedir@,$oldincludedir,;t t +s,@infodir@,$infodir,;t t +s,@mandir@,$mandir,;t t +s,@build_alias@,$build_alias,;t t +s,@host_alias@,$host_alias,;t t +s,@target_alias@,$target_alias,;t t +s,@DEFS@,$DEFS,;t t +s,@ECHO_C@,$ECHO_C,;t t +s,@ECHO_N@,$ECHO_N,;t t +s,@ECHO_T@,$ECHO_T,;t t +s,@LIBS@,$LIBS,;t t +s,@CC@,$CC,;t t +s,@CFLAGS@,$CFLAGS,;t t +s,@LDFLAGS@,$LDFLAGS,;t t +s,@CPPFLAGS@,$CPPFLAGS,;t t +s,@ac_ct_CC@,$ac_ct_CC,;t t +s,@EXEEXT@,$EXEEXT,;t t +s,@OBJEXT@,$OBJEXT,;t t +s,@build@,$build,;t t +s,@build_cpu@,$build_cpu,;t t +s,@build_vendor@,$build_vendor,;t t +s,@build_os@,$build_os,;t t +s,@host@,$host,;t t +s,@host_cpu@,$host_cpu,;t t +s,@host_vendor@,$host_vendor,;t t +s,@host_os@,$host_os,;t t +s,@EGREP@,$EGREP,;t t +s,@LN_S@,$LN_S,;t t +s,@ECHO@,$ECHO,;t t +s,@AR@,$AR,;t t +s,@ac_ct_AR@,$ac_ct_AR,;t t +s,@RANLIB@,$RANLIB,;t t +s,@ac_ct_RANLIB@,$ac_ct_RANLIB,;t t +s,@STRIP@,$STRIP,;t t +s,@ac_ct_STRIP@,$ac_ct_STRIP,;t t +s,@CPP@,$CPP,;t t +s,@CXX@,$CXX,;t t +s,@CXXFLAGS@,$CXXFLAGS,;t t +s,@ac_ct_CXX@,$ac_ct_CXX,;t t +s,@CXXCPP@,$CXXCPP,;t t +s,@F77@,$F77,;t t +s,@FFLAGS@,$FFLAGS,;t t +s,@ac_ct_F77@,$ac_ct_F77,;t t +s,@LIBTOOL@,$LIBTOOL,;t t +s,@LIBTOOL_DEPS@,$LIBTOOL_DEPS,;t t +s,@BUILDMODE@,$BUILDMODE,;t t +s,@JAVAC_PATH@,$JAVAC_PATH,;t t +s,@JAR_PATH@,$JAR_PATH,;t t +s,@CFLAGS_JNI@,$CFLAGS_JNI,;t t +s,@JAVAC@,$JAVAC,;t t +s,@JAR@,$JAR,;t t +s,@JNI@,$JNI,;t t +s,@LIBOBJS@,$LIBOBJS,;t t +s,@LTLIBOBJS@,$LTLIBOBJS,;t t +CEOF + +_ACEOF + + cat >>$CONFIG_STATUS <<\_ACEOF + # Split the substitutions into bite-sized pieces for seds with + # small command number limits, like on Digital OSF/1 and HP-UX. + ac_max_sed_lines=48 + ac_sed_frag=1 # Number of current file. + ac_beg=1 # First line for current file. + ac_end=$ac_max_sed_lines # Line after last line for current file. + ac_more_lines=: + ac_sed_cmds= + while $ac_more_lines; do + if test $ac_beg -gt 1; then + sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag + else + sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag + fi + if test ! -s $tmp/subs.frag; then + ac_more_lines=false + else + # The purpose of the label and of the branching condition is to + # speed up the sed processing (if there are no `@' at all, there + # is no need to browse any of the substitutions). + # These are the two extra sed commands mentioned above. + (echo ':t + /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed + if test -z "$ac_sed_cmds"; then + ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed" + else + ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed" + fi + ac_sed_frag=`expr $ac_sed_frag + 1` + ac_beg=$ac_end + ac_end=`expr $ac_end + $ac_max_sed_lines` + fi + done + if test -z "$ac_sed_cmds"; then + ac_sed_cmds=cat + fi +fi # test -n "$CONFIG_FILES" + +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case $ac_file in + - | *:- | *:-:* ) # input from stdin + cat >$tmp/stdin + ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + * ) ac_file_in=$ac_file.in ;; + esac + + # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories. + ac_dir=`(dirname "$ac_file") 2>/dev/null || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + { if $as_mkdir_p; then + mkdir -p "$ac_dir" + else + as_dir="$ac_dir" + as_dirs= + while test ! -d "$as_dir"; do + as_dirs="$as_dir $as_dirs" + as_dir=`(dirname "$as_dir") 2>/dev/null || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + done + test ! -n "$as_dirs" || mkdir $as_dirs + fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 +echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} + { (exit 1); exit 1; }; }; } + + ac_builddir=. + +if test "$ac_dir" != .; then + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A "../" for each directory in $ac_dir_suffix. + ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` +else + ac_dir_suffix= ac_top_builddir= +fi + +case $srcdir in + .) # No --srcdir option. We are building in place. + ac_srcdir=. + if test -z "$ac_top_builddir"; then + ac_top_srcdir=. + else + ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` + fi ;; + [\\/]* | ?:[\\/]* ) # Absolute path. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir ;; + *) # Relative path. + ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_builddir$srcdir ;; +esac + +# Do not use `cd foo && pwd` to compute absolute paths, because +# the directories may not exist. +case `pwd` in +.) ac_abs_builddir="$ac_dir";; +*) + case "$ac_dir" in + .) ac_abs_builddir=`pwd`;; + [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; + *) ac_abs_builddir=`pwd`/"$ac_dir";; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_builddir=${ac_top_builddir}.;; +*) + case ${ac_top_builddir}. in + .) ac_abs_top_builddir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; + *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_srcdir=$ac_srcdir;; +*) + case $ac_srcdir in + .) ac_abs_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; + *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_srcdir=$ac_top_srcdir;; +*) + case $ac_top_srcdir in + .) ac_abs_top_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; + *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; + esac;; +esac + + + + if test x"$ac_file" != x-; then + { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + rm -f "$ac_file" + fi + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + if test x"$ac_file" = x-; then + configure_input= + else + configure_input="$ac_file. " + fi + configure_input=$configure_input"Generated from `echo $ac_file_in | + sed 's,.*/,,'` by configure." + + # First look for the input files in the build tree, otherwise in the + # src tree. + ac_file_inputs=`IFS=: + for f in $ac_file_in; do + case $f in + -) echo $tmp/stdin ;; + [\\/$]*) + # Absolute (can't be DOS-style, as IFS=:) + test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + echo "$f";; + *) # Relative + if test -f "$f"; then + # Build tree + echo "$f" + elif test -f "$srcdir/$f"; then + # Source tree + echo "$srcdir/$f" + else + # /dev/null tree + { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + fi;; + esac + done` || { (exit 1); exit 1; } +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF + sed "$ac_vpsub +$extrasub +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s,@configure_input@,$configure_input,;t t +s,@srcdir@,$ac_srcdir,;t t +s,@abs_srcdir@,$ac_abs_srcdir,;t t +s,@top_srcdir@,$ac_top_srcdir,;t t +s,@abs_top_srcdir@,$ac_abs_top_srcdir,;t t +s,@builddir@,$ac_builddir,;t t +s,@abs_builddir@,$ac_abs_builddir,;t t +s,@top_builddir@,$ac_top_builddir,;t t +s,@abs_top_builddir@,$ac_abs_top_builddir,;t t +" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out + rm -f $tmp/stdin + if test x"$ac_file" != x-; then + mv $tmp/out $ac_file + else + cat $tmp/out + rm -f $tmp/out + fi + +done +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF + +# +# CONFIG_HEADER section. +# + +# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where +# NAME is the cpp macro being defined and VALUE is the value it is being given. +# +# ac_d sets the value in "#define NAME VALUE" lines. +ac_dA='s,^\([ ]*\)#\([ ]*define[ ][ ]*\)' +ac_dB='[ ].*$,\1#\2' +ac_dC=' ' +ac_dD=',;t' +# ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE". +ac_uA='s,^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' +ac_uB='$,\1#\2define\3' +ac_uC=' ' +ac_uD=',;t' + +for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case $ac_file in + - | *:- | *:-:* ) # input from stdin + cat >$tmp/stdin + ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + * ) ac_file_in=$ac_file.in ;; + esac + + test x"$ac_file" != x- && { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + + # First look for the input files in the build tree, otherwise in the + # src tree. + ac_file_inputs=`IFS=: + for f in $ac_file_in; do + case $f in + -) echo $tmp/stdin ;; + [\\/$]*) + # Absolute (can't be DOS-style, as IFS=:) + test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + # Do quote $f, to prevent DOS paths from being IFS'd. + echo "$f";; + *) # Relative + if test -f "$f"; then + # Build tree + echo "$f" + elif test -f "$srcdir/$f"; then + # Source tree + echo "$srcdir/$f" + else + # /dev/null tree + { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + fi;; + esac + done` || { (exit 1); exit 1; } + # Remove the trailing spaces. + sed 's/[ ]*$//' $ac_file_inputs >$tmp/in + +_ACEOF + +# Transform confdefs.h into two sed scripts, `conftest.defines' and +# `conftest.undefs', that substitutes the proper values into +# config.h.in to produce config.h. The first handles `#define' +# templates, and the second `#undef' templates. +# And first: Protect against being on the right side of a sed subst in +# config.status. Protect against being in an unquoted here document +# in config.status. +rm -f conftest.defines conftest.undefs +# Using a here document instead of a string reduces the quoting nightmare. +# Putting comments in sed scripts is not portable. +# +# `end' is used to avoid that the second main sed command (meant for +# 0-ary CPP macros) applies to n-ary macro definitions. +# See the Autoconf documentation for `clear'. +cat >confdef2sed.sed <<\_ACEOF +s/[\\&,]/\\&/g +s,[\\$`],\\&,g +t clear +: clear +s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*\)\(([^)]*)\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1\2${ac_dC}\3${ac_dD},gp +t end +s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp +: end +_ACEOF +# If some macros were called several times there might be several times +# the same #defines, which is useless. Nevertheless, we may not want to +# sort them, since we want the *last* AC-DEFINE to be honored. +uniq confdefs.h | sed -n -f confdef2sed.sed >conftest.defines +sed 's/ac_d/ac_u/g' conftest.defines >conftest.undefs +rm -f confdef2sed.sed + +# This sed command replaces #undef with comments. This is necessary, for +# example, in the case of _POSIX_SOURCE, which is predefined and required +# on some systems where configure will not decide to define it. +cat >>conftest.undefs <<\_ACEOF +s,^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */, +_ACEOF + +# Break up conftest.defines because some shells have a limit on the size +# of here documents, and old seds have small limits too (100 cmds). +echo ' # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS +echo ' if grep "^[ ]*#[ ]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS +echo ' # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS +echo ' :' >>$CONFIG_STATUS +rm -f conftest.tail +while grep . conftest.defines >/dev/null +do + # Write a limited-size here document to $tmp/defines.sed. + echo ' cat >$tmp/defines.sed <>$CONFIG_STATUS + # Speed up: don't consider the non `#define' lines. + echo '/^[ ]*#[ ]*define/!b' >>$CONFIG_STATUS + # Work around the forget-to-reset-the-flag bug. + echo 't clr' >>$CONFIG_STATUS + echo ': clr' >>$CONFIG_STATUS + sed ${ac_max_here_lines}q conftest.defines >>$CONFIG_STATUS + echo 'CEOF + sed -f $tmp/defines.sed $tmp/in >$tmp/out + rm -f $tmp/in + mv $tmp/out $tmp/in +' >>$CONFIG_STATUS + sed 1,${ac_max_here_lines}d conftest.defines >conftest.tail + rm -f conftest.defines + mv conftest.tail conftest.defines +done +rm -f conftest.defines +echo ' fi # grep' >>$CONFIG_STATUS +echo >>$CONFIG_STATUS + +# Break up conftest.undefs because some shells have a limit on the size +# of here documents, and old seds have small limits too (100 cmds). +echo ' # Handle all the #undef templates' >>$CONFIG_STATUS +rm -f conftest.tail +while grep . conftest.undefs >/dev/null +do + # Write a limited-size here document to $tmp/undefs.sed. + echo ' cat >$tmp/undefs.sed <>$CONFIG_STATUS + # Speed up: don't consider the non `#undef' + echo '/^[ ]*#[ ]*undef/!b' >>$CONFIG_STATUS + # Work around the forget-to-reset-the-flag bug. + echo 't clr' >>$CONFIG_STATUS + echo ': clr' >>$CONFIG_STATUS + sed ${ac_max_here_lines}q conftest.undefs >>$CONFIG_STATUS + echo 'CEOF + sed -f $tmp/undefs.sed $tmp/in >$tmp/out + rm -f $tmp/in + mv $tmp/out $tmp/in +' >>$CONFIG_STATUS + sed 1,${ac_max_here_lines}d conftest.undefs >conftest.tail + rm -f conftest.undefs + mv conftest.tail conftest.undefs +done +rm -f conftest.undefs + +cat >>$CONFIG_STATUS <<\_ACEOF + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + if test x"$ac_file" = x-; then + echo "/* Generated by configure. */" >$tmp/config.h + else + echo "/* $ac_file. Generated by configure. */" >$tmp/config.h + fi + cat $tmp/in >>$tmp/config.h + rm -f $tmp/in + if test x"$ac_file" != x-; then + if diff $ac_file $tmp/config.h >/dev/null 2>&1; then + { echo "$as_me:$LINENO: $ac_file is unchanged" >&5 +echo "$as_me: $ac_file is unchanged" >&6;} + else + ac_dir=`(dirname "$ac_file") 2>/dev/null || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + { if $as_mkdir_p; then + mkdir -p "$ac_dir" + else + as_dir="$ac_dir" + as_dirs= + while test ! -d "$as_dir"; do + as_dirs="$as_dir $as_dirs" + as_dir=`(dirname "$as_dir") 2>/dev/null || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + done + test ! -n "$as_dirs" || mkdir $as_dirs + fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 +echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} + { (exit 1); exit 1; }; }; } + + rm -f $ac_file + mv $tmp/config.h $ac_file + fi + else + cat $tmp/config.h + rm -f $tmp/config.h + fi +done +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF + +{ (exit 0); exit 0; } +_ACEOF +chmod +x $CONFIG_STATUS +ac_clean_files=$ac_clean_files_save + + +# configure is writing to config.log, and then calls config.status. +# config.status does its own redirection, appending to config.log. +# Unfortunately, on DOS this fails, as config.log is still kept open +# by configure, so config.status won't be able to write to it; its +# output is simply discarded. So we exec the FD to /dev/null, +# effectively closing config.log, so it can be properly (re)opened and +# appended to by config.status. When coming back to configure, we +# need to make the FD available again. +if test "$no_create" != yes; then + ac_cs_success=: + ac_config_status_args= + test "$silent" = yes && + ac_config_status_args="$ac_config_status_args --quiet" + exec 5>/dev/null + $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. + $ac_cs_success || { (exit 1); exit 1; } +fi + diff --git a/ase/configure.ac b/ase/configure.ac new file mode 100644 index 00000000..7ea6891a --- /dev/null +++ b/ase/configure.ac @@ -0,0 +1,198 @@ +# +# $Id: configure.ac,v 1.3 2007/04/30 05:51:26 bacon Exp $ +# + +AC_PREREQ(2.53) +AC_INIT([ase], [deb-0.1.0]) +AC_REVISION([$Revision: 1.3 $]) +AC_CONFIG_HEADER([cmn/conf_unx.h]) +AC_CONFIG_AUX_DIR(config) + +# Checks for programs. +AC_PROG_CC +#AC_PROG_RANLIB +AC_PROG_LIBTOOL + +AC_SUBST(LIBTOOL_DEPS) + +# Overrides the default CFLAGS setting +if test "$ac_test_CFLAGS" = "set" +then + CFLAGS=$ac_save_CFLAGS +else + if test "$GCC" = "yes" + then + CFLAGS="-O2" + else + CFLAGS= + fi +fi + +if test "$ac_test_CXXFLAGS" = "set" +then + CXXFLAGS=$ac_save_CXXFLAGS +else + if test "$GCC" = "yes" + then + CXXFLAGS="-O2" + else + CXXFLAGS= + fi +fi + +# Checks for header files. +AC_HEADER_STDC + +# Checks for typedefs, structures, and compiler characteristics. +AC_C_BIGENDIAN( + [AC_DEFINE([ASE_ENDIAN_BIG],[],[Big Endian])], + [AC_DEFINE([ASE_ENDIAN_LITTLE],[],[Little Endian])], + [AC_DEFINE([ASE_ENDIAN_UNKNOWN],[],[Unknown Endian])]) + +# Checks for data types +AC_CHECK_TYPE(long long, [AC_DEFINE([ASE_HAVE_LONG_LONG],[],[long long])]) +AC_CHECK_TYPE(long double, [AC_DEFINE([ASE_HAVE_LONG_DOUBLE],[],[long double])]) + +AC_CHECK_SIZEOF(char) +AC_CHECK_SIZEOF(short) +AC_CHECK_SIZEOF(int) +AC_CHECK_SIZEOF(long) +AC_CHECK_SIZEOF(long long) +AC_CHECK_SIZEOF(__int8) +AC_CHECK_SIZEOF(__int16) +AC_CHECK_SIZEOF(__int32) +AC_CHECK_SIZEOF(__int64) +AC_CHECK_SIZEOF(__int96) +AC_CHECK_SIZEOF(__int128) +AC_CHECK_SIZEOF(void *) +AC_CHECK_SIZEOF(float) +AC_CHECK_SIZEOF(double) +AC_CHECK_SIZEOF(long double) +AC_CHECK_SIZEOF(wchar_t) + +AC_DEFINE_UNQUOTED(ASE_SIZEOF_CHAR,${ac_cv_sizeof_char}) +AC_DEFINE_UNQUOTED(ASE_SIZEOF_SHORT,${ac_cv_sizeof_short}) +AC_DEFINE_UNQUOTED(ASE_SIZEOF_INT,${ac_cv_sizeof_int}) +AC_DEFINE_UNQUOTED(ASE_SIZEOF_LONG,${ac_cv_sizeof_long}) +AC_DEFINE_UNQUOTED(ASE_SIZEOF_LONG_LONG,${ac_cv_sizeof_long_long}) +AC_DEFINE_UNQUOTED(ASE_SIZEOF___INT8,${ac_cv_sizeof___int8}) +AC_DEFINE_UNQUOTED(ASE_SIZEOF___INT16,${ac_cv_sizeof___int16}) +AC_DEFINE_UNQUOTED(ASE_SIZEOF___INT32,${ac_cv_sizeof___int32}) +AC_DEFINE_UNQUOTED(ASE_SIZEOF___INT64,${ac_cv_sizeof___int64}) +AC_DEFINE_UNQUOTED(ASE_SIZEOF___INT96,${ac_cv_sizeof___int96}) +AC_DEFINE_UNQUOTED(ASE_SIZEOF___INT128,${ac_cv_sizeof___int128}) +AC_DEFINE_UNQUOTED(ASE_SIZEOF_VOID_P,${ac_cv_sizeof_void_p}) +AC_DEFINE_UNQUOTED(ASE_SIZEOF_FLOAT,${ac_cv_sizeof_float}) +AC_DEFINE_UNQUOTED(ASE_SIZEOF_DOUBLE,${ac_cv_sizeof_double}) +AC_DEFINE_UNQUOTED(ASE_SIZEOF_LONG_DOUBLE,${ac_cv_sizeof_long_double}) +AC_DEFINE_UNQUOTED(ASE_SIZEOF_WCHAR_T,${ac_cv_sizeof_wchar_t}) + +# Defines extra options + +AC_ARG_ENABLE([wchar], [AC_HELP_STRING([--enable-wchar], + [use wchar_t a default charater type when enabled (default. yes)])], + enable_wchar_is=$enableval,enable_wchar_is=yes) +if test "$enable_wchar_is" = "yes" +then + AC_DEFINE([ASE_CHAR_IS_WCHAR],[],[char is wchar]) +else + AC_DEFINE([ASE_CHAR_IS_MCHAR],[],[char is mchar]) +fi + +AC_ARG_ENABLE([mode], [AC_HELP_STRING([--enable-debug], + [build the library in the debug mode (default. no)])], + enable_debug_is=$enableval,enable_debug_is=no) +if test "$enable_debug_is" = "yes" +then + [CFLAGS="$CFLAGS -g -D_DEBUG -UNDEBUG"] + [CXXFLAGS="$CXXFLAGS -g -D_DEBUG -UNDEBUG"] + AC_SUBST(BUILDMODE, "debug") +else + [CFLAGS="$CFLAGS -DNDEBUG -U_DEBUG"] + [CXXFLAGS="$CXXFLAGS -DNDEBUG -U_DEBUG"] + AC_SUBST(BUILDMODE, "release") +fi + +# Configure makefiles +AC_ARG_ENABLE([reentrant], [AC_HELP_STRING([--enable-reentrant], + [define _REENTRANT (default. yes)])], + enable_reentrant_is=$enableval,enable_reentrant_is=yes) +if test "$enable_reentrant_is" = "yes" +then + [CFLAGS="$CFLAGS -D_REENTRANT -D_THREAD_SAFE"] + [CXXFLAGS="$CXXFLAGS -D_REENTRANT -D_THREAD_SAFE"] +fi + +# Java & JNI Configuration +AC_PATH_PROG(JAVAC_PATH, javac, :) +AC_PATH_PROG(JAR_PATH, jar, :) + +if test "$JAVAC_PATH" != ":" +then + CUR_JAVAC_PATH="$JAVAC_PATH" + + while ls -ld "$CUR_JAVAC_PATH" 2>/dev/null | grep " -> " >/dev/null + do + AC_MSG_CHECKING(symlink for $CUR_JAVAC_PATH) + REAL_JAVAC_PATH=`ls -ld "$CUR_JAVAC_PATH" | sed 's/.* -> //'` + + case "$REAL_JAVAC_PATH" in + /*) CUR_JAVAC_PATH="$REAL_JAVAC_PATH";; + *) CUR_JAVAC_PATH=`echo "X$CUR_JAVAC_PATH" | sed -e 's/^X//' -e 's:[[^/]]*$::'`"$REAL_JAVAC_PATH";; + esac + + AC_MSG_RESULT($CUR_JAVAC_PATH) + done + + JAVA_DIR="$CUR_JAVAC_PATH" + + while true + do + JAVA_DIR=`echo "$JAVA_DIR" | sed -e 's://*:/:g' -e 's:/[[^/]]*$::'` + if test "$JAVA_DIR" = "" + then + break + fi + + AC_MSG_CHECKING($JAVA_DIR/include/jni.h) + if test -f "$JAVA_DIR/include/jni.h" + then + AC_MSG_RESULT(yes) + JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $JAVA_DIR/include" + break; + else + AC_MSG_RESULT(no) + fi + done + + for i in $JNI_INCLUDE_DIRS + do + JNI_MD_H=`find "$i" -name jni_md.h -print` + if test "$JNI_MD_H" != "" + then + tmp=`echo "$JNI_MD_H" | sed -e 's://*:/:g' -e 's:/[[^/]]*$::'` + JNI_MD_INCLUDE_DIRS="$JNI_MD_INCLUDE_DIRS $tmp" + fi + done + + JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $JNI_MD_INCLUDE_DIRS" + + for i in $JNI_INCLUDE_DIRS + do + CFLAGS_JNI="$CFLAGS_JNI -I$i" + done + + JNI="jni" +else + JAVAC_PATH="" + CFLAGS_JNI="" + JNI="" +fi + +AC_SUBST(CFLAGS_JNI, $CFLAGS_JNI) +AC_SUBST(JAVAC, $JAVAC_PATH) +AC_SUBST(JAR, $JAR_PATH) +AC_SUBST(JNI, $JNI) + +AC_CONFIG_FILES([makefile cmn/makefile awk/makefile lsp/makefile utl/makefile test/awk/makefile test/lsp/makefile]) +AC_OUTPUT diff --git a/ase/doc/ase-en.man b/ase/doc/ase-en.man new file mode 100644 index 00000000..2779be1b --- /dev/null +++ b/ase/doc/ase-en.man @@ -0,0 +1,30 @@ +.title ASE + += ASE = + +ASE is a programming library implementing various programming languages and text utilities for embedding purposes. The library is developed in the C programming language and provides the JNI binding to JAVA and the COM interface. + +(Warning: This page is only for the test purpose prior to proper release and the contents can be changed anytime without prior notice.) + +== Download == + +Download the library source code from the following links. + +ase-0.1.0.tgz +[[[ +* {Link 1,ase-0.1.0.tgz} +* Link 2 +]]] + +== Documentation == + +[[[ +* {Quickstart,quickstart-en.html} +* {AWK Embedder's guide,awk-en.html} +* {LISP Embedder's guide,lsp-en.html} +* {Frequently Asked Questions,faq-en.html} +]]] + +== Licensing == + +ASE is distributed under a {BSD license,license.html} and is free for all uses. diff --git a/ase/doc/ase-ko.man b/ase/doc/ase-ko.man new file mode 100644 index 00000000..4ee3e885 --- /dev/null +++ b/ase/doc/ase-ko.man @@ -0,0 +1,29 @@ +.title ASE + += ASE = + +ASE는 임베딩을 목적으로 여러가지 프로그래밍언어를 구현하는 라이브러리이다. C언어로 개발되며 자바 JNI인터페이스와 COM인터페이스를 제공한다. + +(경고: 본 페이지는 정식 배포전에 시험용으로 제작된것이므로, 언제든지 내용이 변경될 수 있다.) + +== Download == + +다음 링크에서 소스코드를 받을수 있다. + +ase-0.1.0.tgz +[[[ +* {링크 1,ase-0.1.0.tgz} +* 링크 2 +]]] + +== Documentation == + +[[[ +* {초간단가이드,quickstart-ko.html} +* {사용자가이드,awk-en.html} +* {자주받는질문,faq-ko.html} +]]] + +== Licensing == + +ASE는 {BSD 라이센스,license.html}하에 무료로 배포된다. 단 {라이센스,license.html}는 번역상에 발생할수 있는 문제를 최소화하기 위해 영문으로만 제공된다. diff --git a/ase/doc/awk-en.man b/ase/doc/awk-en.man new file mode 100644 index 00000000..e0584aab --- /dev/null +++ b/ase/doc/awk-en.man @@ -0,0 +1,202 @@ +.title ASEAWK + += ASEAWK = +ASE provides an embeddable processor of a dialect of the AWK programming language. The language implemented is slightly different from {the version developed by Brian W. Kernighan, http://cm.bell-labs.com/cm/cs/awkbook/index.html} and has been adjusted to the author's preference. + +== Overview == +The following code fragment illustrates the basic steps of embedding the processor. + +{{{ +1) #include + +2) ase_awk_t* awk; +3) awk = ase_awk_open (...); +4) if (ase_awk_parse (awk, ...) == -1) + { + /* parse error */ + } + else + { +5) if (ase_awk_run (awk, ...) == -1) + { + /* run-time error */ + } + } +6) ase_awk_close (awk); +}}} + +((( +* Most of the functions and data types needed are defined in the header file [[ase/awk/awk.h]]. +* [[ase_awk_t]] represents the processor. However, the internal representation is not exposed. +* [[ase_awk_open]] creates the processor instance. +* [[ase_awk_parse]] parses an AWK script. +* [[ase_awk_run]] executes the script parsed. +* [[ase_awk_close]] destroys the processor instance. +))) + +More detailed description is available {here,awk-mini-en.html}. You may refer to other sample files such as [[ase/test/awk/awk.c]] and [[ase/awk/jni.c]]. + +== Primitive Functions == +A set of primitive functions is needed to create an instance of the AWK processor. A primitive function is a user-defined function to help the library perform system-dependent operations such as memory allocation, character class handling. + +{{{ +typedef struct ase_awk_prmfns_t ase_awk_prmfns_t; + +struct ase_awk_prmfns_t +{ + ase_mmgr_t mmgr; + ase_ccls_t ccls; + + struct + { + ase_awk_pow_t pow; + ase_awk_sprintf_t sprintf; + ase_awk_dprintf_t dprintf; + void* custom_data; + } misc; +}; +}}} + +A caller of [[ase_awk_open]] should fill in most of the fields of a [[ase_awk_prmfns_t]] structure and pass the structure to it. The function pointers in the miscellaneous group labeled [misc] is defined as follows: + +{{{ +/* returns the value of x raised to the power of y */ +typedef ase_real_t (*ase_awk_pow_t) (void* custom, ase_real_t x, ase_real_t y); + +/* similar to snprintf of the standard C library. */ +typedef int (*ase_awk_sprintf_t) (void* custom, ase_char_t* buf, ase_size_t size, const ase_char_t* fmt, ...); + +/* similar to printf of the standard C library. called by a few uncommonly + * used output functions usually for debugging purpose */ +typedef void (*ase_awk_dprintf_t) (void* custom, const ase_char_t* fmt, ...); +}}} + +The fourth field of the group is passed to its member functions as the first argument on invocation. The function pointed by the [[sprintf]] field should ensure that the resuliting string is null-terminated and [[%s]] and [[%c]] are accepted for the [[ase_char_t*]] and [[ase_char_t]] type respectively regardless the character mode. + +The memory manager group labeled [mmgr] and the character class group labled [ccls] are defined as follows: + +{{{ +typedef void* (*ase_malloc_t) (void* custom, ase_size_t n); +typedef void* (*ase_realloc_t) (void* custom, void* ptr, ase_size_t n); +typedef void (*ase_free_t) (void* custom, void* ptr); + +typedef ase_bool_t (*ase_isccls_t) (void* custom, ase_cint_t c); +typedef ase_cint_t (*ase_toccls_t) (void* custom, ase_cint_t c); + +struct ase_mmgr_t +{ + ase_malloc_t malloc; + ase_realloc_t realloc; + ase_free_t free; + void* custom_data; +}; + +struct ase_ccls_t +{ + ase_isccls_t is_upper; + ase_isccls_t is_lower; + ase_isccls_t is_alpha; + ase_isccls_t is_digit; + ase_isccls_t is_xdigit; + ase_isccls_t is_alnum; + ase_isccls_t is_space; + ase_isccls_t is_print; + ase_isccls_t is_graph; + ase_isccls_t is_cntrl; + ase_isccls_t is_punct; + ase_toccls_t to_upper; + ase_toccls_t to_lower; + void* custom_data; +}; +}}} + +The functions in these groups perform the memory operations and character class related operations respectively. They follow the style of the memory allocation functions and character class handling functions of the standard C library except that they accept a pointer to the user-defined data as the first argument, thus providing more flexibility. The pointer to the user-defined data is specified into the [[custom_data]] field of each group. The [[realloc]] field, however, can be [[ASE_NULL]], in which case the functions pointed by the free and the malloc field replace the role of the function pointed by the [[realloc]] field. + +== Source IO Handler == + +The source code is handled by a source input handler provided by the user. The optional source code output handler can be provided to have the internal parse tree converted back to the source code. + +The source code handler is defined as follows: + +{{{ +typedef ase_ssize_t (*ase_awk_io_t) (int cmd, void* custom, ase_char_t* data, ase_size_t count); + +typedef struct ase_awk_srcios_t ase_awk_srcios_t; + +struct ase_awk_srcios_t +{ + ase_awk_io_t in; /* source input */ + ase_awk_io_t out; /* source output */ + void* custom_data; +}; +}}} + +The [[in]] field of the ase_awk_srcios_t is mandatory and should be filled in. The [[out]] field can be set to [[ASE_NULL]] or can point to a source output handling function. The [[custom_data]] field is passed to the source handlers as the second argument. The first parameter [[cmd]] of the source input handler is one of [[ASE_AWK_IO_OPEN]], [[ASE_AWK_IO_CLOSE]], [[ASE_AWK_IO_READ]]. The first parameter [[cmd]] of the source output handler is one of [[ASE_AWK_IO_OPEN]], [[ASE_AWK_IO_CLOSE]], [[ASE_AWK_IO_WRITE]]. The third parameter [[data]] and the fourth parameter [[count]] are the pointer to the buffer to read data into and its size if the first parameter [[cmd]] is [[ASE_AWK_IO_READ]] while they are the pointer to the data and its size if [[cmd]] is [[ASE_AWK_IO_WRITE]]. + +The source handler should return a negative value for an error and zero or a positive value otherwise. However, there is a subtle difference in the meaning of the return value depending on the value of the first parameter [[cmd]]. + +When [[cmd]] is [[ASE_AWK_IO_OPEN]], the return value of -1 and 1 indicates the failure and the success respectively. In addition, the return value of 0 indicates that the operation is successful but has reached the end of the stream. The library calls the handler with [[ASE_AWK_IO_CLOSE]] for deinitialization if the return value is 0 or 1. When [[cmd]] is [[ASE_AWK_IO_CLOSE]], the return value of -1 and 0 indicate the failure and the success respectively. When [[cmd]] is [[ASE_AWK_IO_READ]] or [[ASE_AWK_IO_WRITE]], the return value of -1 indicates the failure, 0 the end of the stream, and other positive values the number of characters read or written. + +The typical source handler will look as follows: +{{{ +ase_ssize_t awk_srcio_in (int cmd, void* arg, ase_char_t* data, ase_size_t size) +{ + if (cmd == ASE_AWK_IO_OPEN) + { + /* open the stream */ + return 1; + } + else if (cmd == ASE_AWK_IO_CLOSE) + { + /* close the stream */ + return 0; + } + else if (cmd == ASE_AWK_IO_READ) + { + /* read the stream */ + return the number of characters read; + } + + return -1; +} + +ase_ssize_t awk_srcio_out (int cmd, void* arg, ase_char_t* data, ase_size_t size) +{ + if (cmd == ASE_AWK_IO_OPEN) + { + /* open the stream */ + return 1; + } + else if (cmd == ASE_AWK_IO_CLOSE) + { + /* close the stream after flushing it */ + return 0; + } + else if (cmd == ASE_AWK_IO_WRITE) + { + /* write the stream */ + return the number of characters written; + } + + return -1; +} +}}} + +Once you have the source handler ready, you can fill in the fields of a [[ase_awk_srcios_t]] structure and pass it to the call of [[ase_awk_parse]]. + +{{{ +ase_awk_srcios_t srcios; + +srcios.in = awk_srcio_in; +srcios.out = awk_srcio_out; +srcios.custom_data = point to the extra information necessary; + +if (ase_awk_parse (awk, &srcios) == -1) +{ + /* handle error */ +} +}}} + +== External IO Handler == + +External IO handlers should be provided to support the AWK's built-in IO facilities. diff --git a/ase/doc/awk-mini-en.man b/ase/doc/awk-mini-en.man new file mode 100644 index 00000000..2ccb86b6 --- /dev/null +++ b/ase/doc/awk-mini-en.man @@ -0,0 +1,458 @@ +.title Annotated ASEAWK Embedding Sample + += Annotated ASEAWK Embedding Sample = + +This document annotates a simple embedding sample code [[ase/test/awk/mini.c]]. Locate the [[ase_main]] function to begin exploring the sample. + +== mini.c == + +{{{ +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +}}} + +Most of the data types and functions needed to embed a AWK processor is defined in [[ase/awk/awk.h]]. Other headers files are included as this sample code uses functions from them. + +{{{ +struct awk_src_io +{ + const ase_char_t* file; + FILE* handle; +}; + +static const ase_char_t* data_file = ASE_NULL; + +#if defined(vms) || defined(__vms) +/* it seems that the main function should be placed in the main object file + * in OpenVMS. otherwise, the first function in the main object file seems + * to become the main function resulting in program start-up failure. */ +#include +#endif + +#ifndef NDEBUG +void ase_assert_abort (void) +{ + abort (); +} + +void ase_assert_printf (const ase_char_t* fmt, ...) +{ + va_list ap; + va_start (ap, fmt); + ase_vprintf (fmt, ap); + va_end (ap); +} +#endif +}}} + +The library requires [[ase_assert_abort]] and [[ase_assert_printf]] to be defined to support the assertion statements [[ASE_ASSERT]] and [[ASE_ASSERTX]] defined in [[ase/cmn/macros.h]] when [[NDEBUG]] is not defined. [[ASE_ASSERT]] behaves the same as the standard [[assert]] statement while an additional textual description can be passed to [[ASE_ASSERTX]]. They are all usuable in the caller program as well. + +{{{ +void* awk_malloc (void* custom, ase_size_t n) { return malloc (n); } +void* awk_realloc (void* custom, void* ptr, ase_size_t n) { return realloc (ptr, n); } +void awk_free (void* custom, void* ptr) { free (ptr); } +}}} + +The memory management functions are required by the library. They need to form a part of the [[ase_awk_prmfns_t]] structure and be passed to [[ase_awk_open]]. Each function looks after the counterpart in the standard C library except that the first parameter to each function is a pointer to a custom data provided by the caller. + +{{{ +ase_bool_t awk_isupper (void* custom, ase_cint_t c) { return ase_isupper (c); } +ase_bool_t awk_islower (void* custom, ase_cint_t c) { return ase_islower (c); } +ase_bool_t awk_isalpha (void* custom, ase_cint_t c) { return ase_isalpha (c); } +ase_bool_t awk_isdigit (void* custom, ase_cint_t c) { return ase_isdigit (c); } +ase_bool_t awk_isxdigit (void* custom, ase_cint_t c) { return ase_isxdigit (c); } +ase_bool_t awk_isalnum (void* custom, ase_cint_t c) { return ase_isalnum (c); } +ase_bool_t awk_isspace (void* custom, ase_cint_t c) { return ase_isspace (c); } +ase_bool_t awk_isprint (void* custom, ase_cint_t c) { return ase_isprint (c); } +ase_bool_t awk_isgraph (void* custom, ase_cint_t c) { return ase_isgraph (c); } +ase_bool_t awk_iscntrl (void* custom, ase_cint_t c) { return ase_iscntrl (c); } +ase_bool_t awk_ispunct (void* custom, ase_cint_t c) { return ase_ispunct (c); } +ase_cint_t awk_toupper (void* custom, ase_cint_t c) { return ase_toupper (c); } +ase_cint_t awk_tolower (void* custom, ase_cint_t c) { return ase_tolower (c); } +}}} + +The character class handling functions must be provided by the caller. Like the memory management functions, they form a part of the [[ase_awk_prmfns_t]] structure and passwd to [[ase_awk_open]]. + +{{{ +ase_real_t awk_pow (void* custom, ase_real_t x, ase_real_t y) +{ + return pow (x, y); +} + +int awk_sprintf (void* custom, ase_char_t* buf, ase_size_t size, const ase_char_t* fmt, ...) +{ + int n; + + va_list ap; + va_start (ap, fmt); + n = ase_vsprintf (buf, size, fmt, ap); + va_end (ap); + + return n; +} + +void awk_dprintf (void* custom, const ase_char_t* fmt, ...) +{ + va_list ap; + va_start (ap, fmt); + ase_vfprintf (stderr, fmt, ap); + va_end (ap); +} +}}} + +The [[awk_pow]] function returns the value of the second parameter [[x]] raised to the third parameter [[y]]. The [[awk_sprintf]] function is similar to the standard [[snprintf]] to the standard [[snprintf]]. It should make sure that the buffer [[buf]] is null-terminated if the size [[size]] is greater than 0. Refer to [[ase_sprintf]] in [[ase/utl/stdio.h]] for details. The [[awk_dprintf]] fucntion is similar to [[fprintf(stderr,...)]] is called when the text output is performed for debugging purpose. + +{{{ +ase_ssize_t awk_srcio_in (int cmd, void* arg, ase_char_t* data, ase_size_t size) +{ + struct awk_src_io* src_io = (struct awk_src_io*)arg; + ase_cint_t c; + + if (cmd == ASE_AWK_IO_OPEN) + { + if (src_io->file == ASE_NULL) return 0; + src_io->handle = ase_fopen (src_io->file, ASE_T("r")); + if (src_io->handle == NULL) return -1; + return 1; + } + else if (cmd == ASE_AWK_IO_CLOSE) + { + if (src_io->file == ASE_NULL) return 0; + fclose ((FILE*)src_io->handle); + return 0; + } + else if (cmd == ASE_AWK_IO_READ) + { + if (size <= 0) return -1; + c = ase_fgetc ((FILE*)src_io->handle); + if (c == ASE_CHAR_EOF) return 0; + *data = (ase_char_t)c; + return 1; + } + + return -1; +} +}}} + +The source code is read in by the source code input handler as specified in the [[in]] field of the [[ase_awk_srcios_t]] structure passed to the [[ase_awk_parse]] function. This sample, however, doesn't use the source output handler which is used to show the internal parse tree. + +{{{ +/* external i/o handler for pipe */ +ase_ssize_t awk_extio_pipe (int cmd, void* arg, ase_char_t* data, ase_size_t size) +{ + ase_awk_extio_t* epa = (ase_awk_extio_t*)arg; + + switch (cmd) + { + case ASE_AWK_IO_OPEN: + { + FILE* handle; + const ase_char_t* mode; + + if (epa->mode == ASE_AWK_EXTIO_PIPE_READ) + mode = ASE_T("r"); + else if (epa->mode == ASE_AWK_EXTIO_PIPE_WRITE) + mode = ASE_T("w"); + else return -1; + + handle = ase_popen (epa->name, mode); + if (handle == NULL) return -1; + epa->handle = (void*)handle; + return 1; + } + + case ASE_AWK_IO_CLOSE: + { + fclose ((FILE*)epa->handle); + epa->handle = NULL; + return 0; + } + + case ASE_AWK_IO_READ: + { + if (ase_fgets (data, size, (FILE*)epa->handle) == ASE_NULL) + { + if (ferror((FILE*)epa->handle)) return -1; + return 0; + } + return ase_strlen(data); + } + + case ASE_AWK_IO_WRITE: + { + #if defined(ASE_CHAR_IS_WCHAR) && defined(__linux) + /* fwprintf seems to return an error with the file + * pointer opened by popen, as of this writing. + * anyway, hopefully the following replacement + * will work all the way. */ + int n = fprintf ( + (FILE*)epa->handle, "%.*ls", size, data); + #else + int n = ase_fprintf ( + (FILE*)epa->handle, ASE_T("%.*s"), size, data); + #endif + if (n < 0) return -1; + + return size; + } + + case ASE_AWK_IO_FLUSH: + { + if (epa->mode == ASE_AWK_EXTIO_PIPE_READ) return -1; + else return 0; + } + + case ASE_AWK_IO_NEXT: + { + return -1; + } + } + + return -1; +} + +/* external i/o handler for file */ +ase_ssize_t awk_extio_file (int cmd, void* arg, ase_char_t* data, ase_size_t size) +{ + ase_awk_extio_t* epa = (ase_awk_extio_t*)arg; + + switch (cmd) + { + case ASE_AWK_IO_OPEN: + { + FILE* handle; + const ase_char_t* mode; + + if (epa->mode == ASE_AWK_EXTIO_FILE_READ) + mode = ASE_T("r"); + else if (epa->mode == ASE_AWK_EXTIO_FILE_WRITE) + mode = ASE_T("w"); + else if (epa->mode == ASE_AWK_EXTIO_FILE_APPEND) + mode = ASE_T("a"); + else return -1; + + handle = ase_fopen (epa->name, mode); + if (handle == NULL) return -1; + + epa->handle = (void*)handle; + return 1; + } + + case ASE_AWK_IO_CLOSE: + { + fclose ((FILE*)epa->handle); + epa->handle = NULL; + return 0; + } + + case ASE_AWK_IO_READ: + { + if (ase_fgets (data, size, (FILE*)epa->handle) == ASE_NULL) + { + if (ferror((FILE*)epa->handle)) return -1; + return 0; + } + return ase_strlen(data); + } + + case ASE_AWK_IO_WRITE: + { + int n = ase_fprintf ( + (FILE*)epa->handle, ASE_T("%.*s"), size, data); + if (n < 0) return -1; + + return size; + } + + case ASE_AWK_IO_FLUSH: + { + if (fflush ((FILE*)epa->handle) == EOF) return -1; + return 0; + } + + case ASE_AWK_IO_NEXT: + { + return -1; + } + + } + + return -1; +} + +/* external i/o handler for console */ +ase_ssize_t awk_extio_console (int cmd, void* arg, ase_char_t* data, ase_size_t size) +{ + ase_awk_extio_t* epa = (ase_awk_extio_t*)arg; + + if (cmd == ASE_AWK_IO_OPEN) + { + if (epa->mode == ASE_AWK_EXTIO_CONSOLE_READ) + { + FILE* fp = ase_fopen (data_file, ASE_T("r")); + if (fp == ASE_NULL) return -1; + + if (ase_awk_setfilename ( + epa->run, data_file, ase_strlen(data_file)) == -1) + { + fclose (fp); + return -1; + } + + epa->handle = fp; + + return 1; + } + else if (epa->mode == ASE_AWK_EXTIO_CONSOLE_WRITE) + { + epa->handle = stdout; + return 1; + } + + return -1; + } + else if (cmd == ASE_AWK_IO_CLOSE) + { + fclose ((FILE*)epa->handle); + epa->handle = NULL; + return 0; + } + else if (cmd == ASE_AWK_IO_READ) + { + while (ase_fgets (data, size, (FILE*)epa->handle) == ASE_NULL) + { + if (ferror((FILE*)epa->handle)) return -1; + return 0; + } + + return ase_strlen(data); + } + else if (cmd == ASE_AWK_IO_WRITE) + { + int n = ase_fprintf ((FILE*)epa->handle, ASE_T("%.*s"), size, data); + if (n < 0) return -1; + + return size; + } + else if (cmd == ASE_AWK_IO_FLUSH) + { + if (fflush ((FILE*)epa->handle) == EOF) return -1; + return 0; + } + else if (cmd == ASE_AWK_IO_NEXT) + { + return -1; + } + + return -1; +} +}}} + +External Input-Output Handler. + +{{{ +int ase_main (int argc, ase_char_t* argv[]) +{ + ase_awk_t* awk; + + ase_awk_prmfns_t prmfns; + ase_awk_srcios_t srcios; + ase_awk_runios_t runios; + + struct awk_src_io src_io = { NULL, NULL }; + + if (argc != 3) + { + ase_printf (ASE_T("Usage: %s source-file data-file\n"), argv[0]); + return -1; + } + + src_io.file = argv[1]; + data_file = argv[2]; + + ase_memset (&prmfns, 0, ASE_SIZEOF(prmfns)); + + prmfns.mmgr.malloc = awk_malloc; + prmfns.mmgr.realloc = awk_realloc; + prmfns.mmgr.free = awk_free; + prmfns.mmgr.custom_data = ASE_NULL; + + prmfns.ccls.is_upper = awk_isupper; + prmfns.ccls.is_lower = awk_islower; + prmfns.ccls.is_alpha = awk_isalpha; + prmfns.ccls.is_digit = awk_isdigit; + prmfns.ccls.is_xdigit = awk_isxdigit; + prmfns.ccls.is_alnum = awk_isalnum; + prmfns.ccls.is_space = awk_isspace; + prmfns.ccls.is_print = awk_isprint; + prmfns.ccls.is_graph = awk_isgraph; + prmfns.ccls.is_cntrl = awk_iscntrl; + prmfns.ccls.is_punct = awk_ispunct; + prmfns.ccls.to_upper = awk_toupper; + prmfns.ccls.to_lower = awk_tolower; + prmfns.ccls.custom_data = ASE_NULL; + + prmfns.misc.pow = awk_pow; + prmfns.misc.sprintf = awk_sprintf; + prmfns.misc.dprintf = awk_dprintf; + prmfns.misc.custom_data = ASE_NULL; + + if ((awk = ase_awk_open(&prmfns, ASE_NULL)) == ASE_NULL) + { + ase_printf (ASE_T("ERROR: cannot open awk\n")); + return -1; + } + + ase_awk_setoption (awk, + ASE_AWK_IMPLICIT | ASE_AWK_EXPLICIT | ASE_AWK_UNIQUEFN | + ASE_AWK_IDIV | ASE_AWK_SHADING | ASE_AWK_SHIFT | + ASE_AWK_EXTIO | ASE_AWK_BLOCKLESS | ASE_AWK_STRBASEONE | + ASE_AWK_STRIPSPACES | ASE_AWK_NEXTOFILE); + + srcios.in = awk_srcio_in; + srcios.out = ASE_NULL; + srcios.custom_data = &src_io; + + if (ase_awk_parse (awk, &srcios) == -1) + { + ase_printf ( + ASE_T("PARSE ERROR: CODE [%d] LINE [%u] %s\n"), + ase_awk_geterrnum(awk), + (unsigned int)ase_awk_geterrlin(awk), + ase_awk_geterrmsg(awk)); + ase_awk_close (awk); + return -1; + } + + runios.pipe = awk_extio_pipe; + runios.file = awk_extio_file; + runios.console = awk_extio_console; + runios.custom_data = ASE_NULL; + + if (ase_awk_run (awk, ASE_NULL, &runios, ASE_NULL, ASE_NULL, ASE_NULL) == -1) + { + ase_printf ( + ASE_T("RUN ERROR: CODE [%d] LINE [%u] %s\n"), + ase_awk_geterrnum(awk), + (unsigned int)ase_awk_geterrlin(awk), + ase_awk_geterrmsg(awk)); + + ase_awk_close (awk); + return -1; + } + + ase_awk_close (awk); + return 0; +} +}}} + +The main function. diff --git a/ase/doc/awk.man b/ase/doc/awk.man new file mode 100644 index 00000000..f192fdfc --- /dev/null +++ b/ase/doc/awk.man @@ -0,0 +1,93 @@ +.title Introduction To ASE AWK + +== OVERVIEW == + +=== What is it? === +'''''ASE AWK''''' is an embeddable implementation of the AWK programming language. It is composed of a set of C functions to help programmers embed the AWK interpreter to their own applications easily. + +=== What does it do? === +'''''ASE AWK''''' can do most of the things that other existing AWK interpreters can do. + +=== Differences with other implementations === +There exist a number of AWK interpreters available. Most of Unix/Linux operating systems come with an AWK interpreter. + +== DESCRIPTION == + +=== Interpreter === +Multiple instances of interpreters can be created in a single application and each instance of the interpreter created maintains its own state in the data structure pointed at by its handle of the type ''ase_awk_t''. + + * ase_awk_t - an abstract type to an interpreter object. + * ase_awk_open - creates an interpreter object. + * ase_awk_close - destroys the interprer object created by ase_awk_open. + +{{{ +ase_awk_t* ase_awk_open (void); +void ase_awk_close (ase_awk_t* awk); +}}} + +The interpreter provides two distinct functionalites in large; the parser and the executor. The parser transforms the source code into the internal parse tree and the executor evaluates the parse tree and runs the code. + +{{{ +int ase_awk_parse (ase_awk_t* awk); +int ase_awk_run (ase_awk_t* awk, ase_awk_io_t txtio, void* txtio_arg); +}}} + +=== IO Handlers === +'''''ASE AWK''''' does not provide any built-in IO handling routines. Instead, it requires users to provide them. 4 different IO streams should be provided to take full advantage of the interpreter. + + * Source code input + * Source code output + * Data input + * Data output + +{{{ +enum +{ + XP_AWK_INPUT_OPEN = 0, + XP_AWK_INPUT_CLOSE = 1, + XP_AWK_INPUT_NEXT = 2, + XP_AWK_INPUT_DATA = 3, + + XP_AWK_OUTPUT_OPEN = 4, + XP_AWK_OUTPUT_CLOSE = 5, + XP_AWK_OUTPUT_NEXT = 6, + XP_AWK_OUTPUT_DATA = 7 +}; + +typedef ase_ssize_t (*ase_awk_io_t) (int cmd, void* arg, ase_char_t* data, ase_size_t count); +}}} + +=== Miscellaneous Functions === +'''''ASE AWK''''' provides extra utility routines as well as the interpreter. These routines used by the interpreter can be accessed from the interested applications directly without regard to the interpreter. + +==== String ==== + +==== Conversion ==== + * ase_awk_strtolong - convert a numeric string to an integer of the ase_long_t type. + * ase_awk_strtoreal - convert a numeric string to a decimal number of the ase_real_t type. + +{{{ +ase_long_t ase_awk_strtolong (const ase_char_t* str, int base, const ase_char_t** endptr); +ase_real_t ase_awk_strtoreal (const ase_char_t* str); +}}} + +==== Regular Expression ==== +The regular expression routines built into the interpreter can replace other regular expression libraries available. By utilizing this, the application can have the identical regular expression functionalities as the embedded AWK interpreter. + +{{{ +ase_awk_rex_t* ase_awk_rex_open (ase_awk_rex_t* rex); +void ase_awk_rex_close (ase_awk_rex_t* rex); +}}} + +=== User-defined Built-in Functions === +Custom built-in functions can be added to the interpreter. This requires the deeper look into the internals of the interpreter. + +== EXAMPLE == +{{{ +#include + +int ase_main () +{ + return 0; +} +}}} diff --git a/ase/doc/diff.man b/ase/doc/diff.man new file mode 100644 index 00000000..0a8337f5 --- /dev/null +++ b/ase/doc/diff.man @@ -0,0 +1,11 @@ +== Difference From The Standard AWK == + +== line terminiator == +it doesn't accept the new line as a line terminator. + +== print/printf == +if the statement succeeds, it sets ERRNO to 0. otherwise, it sets ERRNO to -1. + + + + diff --git a/ase/doc/doc.css b/ase/doc/doc.css new file mode 100644 index 00000000..fe7f3705 --- /dev/null +++ b/ase/doc/doc.css @@ -0,0 +1,86 @@ +body +{ + font-family: verdana, "times new roman", tahoma, lucida, sans-serif; + background-color: white; + color: black; + #padding: 10px 10px 10px 10px; + + font-size: 90%; + padding-left: 10px; + padding-right: 10px; + line-height: 1.3; + text-align: justify; +} + +#a:link { color: #F89E59;} +#a:visited { color: #F89E59;} +#a:hover { color:#000000;} + +h1,h2,h3,h4,h5 +{ + font-family: tahoma, "times new roman", verdana; + border-bottom: 1px solid #779098; +} +h1 { font-size: 120%; } +h2 { font-size: 115%; padding-left: 5px; } +h3 { font-size: 110%; padding-left: 10px; } +h4 { font-size: 105%; padding-left: 15px; } +h5 { font-size: 100%; padding-left: 20px; } + +.header +{ + font-family: verdana, tahoma; + font-size: 120%; + font-weight: bold; + #padding-right: 20px; + text-decoration: none; + border-bottom: 1px solid black; +} + +.footer +{ + font-family: "times new roman", tahoma; + font-size: 14px; + #padding-right: 20px; + text-decoration: none; + text-align: right; + border-top: 1px solid black; +} + +.contents +{ + font-family: "times new roman", tahoma; + font-size: 95%; +} + +.maintext +{ + font-size: 90%; + #color: #555555; + color: black; + padding-left: 20px; + padding-right: 20px; + line-height: 1.3; + text-align: justify; +} + +pre.code +{ + font-family: "Lucida TypeWriter", monotype, lucida, fixed; + font-size: 80%; + padding: 6px 6px 6px 6px; + xbackground-color: #000000; + xcolor: #FFD700; + #border: 1px dashed #779098; + #border: 1px solid #779098; + border: none; + background-color: yellow; +} + +.linenum +{ + font-weight: bold; +} + + + diff --git a/ase/doc/embed.man b/ase/doc/embed.man new file mode 100644 index 00000000..3202c9cc --- /dev/null +++ b/ase/doc/embed.man @@ -0,0 +1,51 @@ +.title Embedding AWK + +To embed the awk interpreter to an application, the developer should provide the following routines. + + * System functions including memory management + * Source code I/O functions + * I/O functions to interface with the console, files, and pipes. + +ase_awk_open creates an awk object and requires a pointer to a structure holding system functions. The structure is described in ase_awk_prmfns_t. + +{{{ +struct ase_awk_prmfns_t +{ + /* memory */ + void* (*malloc) (ase_size_t n, void* custom_data); + void* (*realloc) (void* ptr, ase_size_t n, void* custom_data); + void (*free) (void* ptr, void* custom_data); + + /* thread lock */ + ase_awk_lk_t lock; + ase_awk_lk_t unlock; + + /* character class */ + ase_bool_t (*is_upper) (ase_cint_t c); + ase_bool_t (*is_lower) (ase_cint_t c); + ase_bool_t (*is_alpha) (ase_cint_t c); + ase_bool_t (*is_digit) (ase_cint_t c); + ase_bool_t (*is_xdigit) (ase_cint_t c); + ase_bool_t (*is_alnum) (ase_cint_t c); + ase_bool_t (*is_space) (ase_cint_t c); + ase_bool_t (*is_print) (ase_cint_t c); + ase_bool_t (*is_graph) (ase_cint_t c); + ase_bool_t (*is_cntrl) (ase_cint_t c); + ase_bool_t (*is_punct) (ase_cint_t c); + ase_cint_t (*to_upper) (ase_cint_t c); + ase_cint_t (*to_lower) (ase_cint_t c); + + /* utilities */ + void* (*memcpy) (void* dst, const void* src, ase_size_t n); + void* (*memset) (void* dst, int val, ase_size_t n); + ase_real_t (*pow) (ase_real_t x, ase_real_t y); + + int (*sprintf) (ase_char_t* buf, ase_size_t size, const ase_char_t* fmt, ...); + void (*aprintf) (const ase_char_t* fmt, ...); /* assertion */ + void (*dprintf) (const ase_char_t* fmt, ...); /* debug */ + void (*abort) (void); + + void* custom_data; +}; +}}} + diff --git a/ase/doc/license.man b/ase/doc/license.man new file mode 100644 index 00000000..2b2ed8e1 --- /dev/null +++ b/ase/doc/license.man @@ -0,0 +1,19 @@ +.title ASE License Agreement + +Software License Agreement (BSD License) + +Copyright (c) 2006-2007, Hyung-Hwan Chung +All rights reserved. + +Redistribution and use of this software in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +[[[ +* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +* Neither the name of the copyright owner nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. +]]] + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT OWNER AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + diff --git a/ase/doc/lsp-en.man b/ase/doc/lsp-en.man new file mode 100644 index 00000000..f36a3cc2 --- /dev/null +++ b/ase/doc/lsp-en.man @@ -0,0 +1,22 @@ + += ASELSP = + +ASELSP is an implementation of a lisp-like language for embedding purposes. + +== Types == + +[[[ +* ase_lsp_t +* ase_lsp_io_t +* ase_lsp_obj_t +]]] + +== Functions == + +[[[ +* ase_lsp_open +* ase_lsp_close +* ase_lsp_read +* ase_lsp_eval +* ase_lsp_print +]]] diff --git a/ase/doc/quickstart-en.man b/ase/doc/quickstart-en.man new file mode 100644 index 00000000..a33d1fdb --- /dev/null +++ b/ase/doc/quickstart-en.man @@ -0,0 +1,118 @@ +.title ASE Quick Start Guide + += ASE Quick Start Guide = + +The first step in using this library is to build it. This document shows how to build the core library on various operating systems. + +== Source Code Directories == + +The source code is organized in the following directory structure. + +{{{ +ase +- cmn .................... contains common functions and macros. + +- utl .................... contains more general-purpose utillity + | functions and macros. + +- awk .................... implementation of the awk processor. + +- lsp .................... implementation of the lisp processor. + +- com .................... COM wrapper of the processors. + +- test +- awk ............ contains test program for the awk processor. + +- lsp ............ contains test programs for the lisp processor. + +- com ............ contains test programs for the COM module. +}}} + +== Unix/Linux == + +You may run the [[configure]] script on most of the supported operation systems to set up the build environment and then run the [[make]] utility. + +{{{ +$ ./configure +$ make +}}} + +The [[make]] utility visits each module subdirectory and build binary files. The library files are placed in the [[release/lib]] directory and the executable files in the [[release/bin]] directory. + +If you appened the option [[--enable-debug]] to the [[configure]] script, the files would be located in [[debug/lib]] and [[debug/bin]] directory. Besides, it sets up the environment to be more debugging friendly. + +{{{ +$ ./configure --enable-debug +$ make +}}} + +Refer to the following table for the output location of generated files. + +{{{ +--------------------------------------------------------------------------- +mode executable files library files include files +--------------------------------------------------------------------------- +release ${top}/release/bin ${top}/release/lib ${top}/release/inc +debug ${top)/debug/bin $(top)/debug/lib ${top}/debug/inc +--------------------------------------------------------------------------- + +* ${top} - the top level directory +}}} + +If you have preference for a particular compiler and the flags, you may explicitly specify them when you run the [[configure]] script. Here are presented a few such examples. + +{{{ +# HP-UX B.11.23 with HP ANSI C +CC=cc CFLAGS="-O2 +DD64" LDFLAGS="+DD64" ./configure # 64-bit +CC=cc CFLAGS="-O2 +DD32" LDFLAGS="+DD32" ./configure # 32-bit + +# SCO OpenServer Release 5.0.7 (SCO_SV 3.2 5.0.7) with SCO OpenServer Development System +CC=cc CFLAGS="-Xc -a ansi -O2" ./configure + +# Solaris 10 with GCC +CC=gcc CFLAGS="-Wall -O2 -m64" LDFLAGS="-m64" ./configure # 64-bit +CC=gcc CFLAGS="-Wall -O2" ./configure # 32-bit +}}} + +You may specify the C++ compiler with [[CXX]] and its flags in [[CXXFLAGS]]. + +The JNI library for JAVA is built automatically if required JNI header files are detected by the [[configure]] script. Make sure that the [[javac]] command is included in the [[PATH]] environment variable for this. The JAVA class files are built with the [[javac]] command detected as well. The {ant,http://ant.apache.org} utility from the Apache Software Foundataion can be used to build the java class files. The [[build.xml]] file is provided at the top-level directory for this. + +== OpenVMS == + +You may use the [[mms]] command or the [[mmk]] command to build the library. No counterpart for the [[configure]] script is provided. As not top-level build script is provided, you have to run the command in each directory that you want to build the library in. + +Let's build the AWK library and its test program, for instance. + +{{{ +set default [.ase.cmn] +mms +set default [-.awk] +mms +set default [-.utl] +mms +set default [-.test.awk] +mms +}}} + +For those who are not familar with OpenVMS, here is one of the ways how to run the test program. + +{{{ +; define the foreign command. +aseawk :== $DISK$GEIN_SYS:[USERS.BACON.ASE.TEST.AWK]aseawk.exe +; run the command. +aseawk -f hello.awk +}}} + +== MS-Windows == + +You may use the Visual Studio 6 or later to open the project. But you need Visual Studio 2003 or later to build the .NET related projects. Otherwise, open the command-line build environment and use the [[make]] utility. + +A set of make scripts is provided to support the Microsoft build environement and the Borland build environment. The script for the Miscrosoft build environment is named [[makefile.msw.cl]] while it is [[makefile.msw.bcc]] for the Borland counterpart. + +If you are building the AWK library and the test program, this is probably what you have to do. + +{{{ +cd ase\cmn +nmake /f makefile.msw.cl +cd ..\awk +nmake /f makefile.msw.cl +cd ..\utl +nmake /f makefile.msw.cl +cd ..\test\awk +nmake /f makefile.msw.cl +}}} + +However, The COM module can only be built within the Visual Studio environment. After having built the COM module, you may open [[ase/test/com/asetestcom.vbp]] for testing. diff --git a/ase/doc/quickstart-ko.man b/ase/doc/quickstart-ko.man new file mode 100644 index 00000000..2105c623 --- /dev/null +++ b/ase/doc/quickstart-ko.man @@ -0,0 +1,116 @@ +.title ASE 시작하기 + += ASE 시작하기 = + +본 문서는 ASE를 사용하기위해서 필요한 정보를 제공한다. + +== 소스코드 디렉토리 == + +소스코드는 다음과 같은 디렉토리로 구성된다. + +{{{ +ase +- cmn .................... 공통 함수와 매크로를 포함한다. + +- utl .................... 보다 일반적인 공통 함수와 매크로를 포함한다. + +- awk .................... AWK 처리기 + +- lsp .................... LISP 처리기 + +- com .................... 각 처리기들의 COM 래퍼모듈 + +- test +- awk ............ AWK 처리기 시험 프로그램 + +- lsp ............ LISP 처리기 시험 프로그램 + +- com ............ COM 래퍼모듈 시험 프로그램 +}}} + +== 빌드 == + +각종 운영체제에서 어떻게 ASE를 빌드하는지 보여준다. + +=== Unix/Linux === + +[[configure]]스크립트를 실행한후 [[make]]프로그램을 실행한다. + +{{{ +$ ./configure +$ make +}}} +[[configure]]스크립트는 해당 시스템의 정보를 수집하여 빌드환경을 설정하고 [[make]]는 각각의 서브다이렉트리를 방문해서 바이너리 파일을 만든다. 라이브러리 파일을 [[release/lib]]에, 실행파일들읜 [[release/bin]]에 만들어 진다. + +[[--enable-debug]]를 [[configure]]에 사용한 경우에는, 빌드환경이 디버깅에 적합하도록 만들어진다. [[make]]를 실행하면 결과 파일들은 [[debug/lib]]와 [[debug/bin]]에 만들어 진다. + +{{{ +$ ./configure --enable-debug +$ make +}}} + +다음의 표는 빌드환경별로 파일이 만들어지는 위치를 보여준다. + +{{{ +--------------------------------------------------------------------------- +모드 실행파일 라이브러리파일 헤더파일 +--------------------------------------------------------------------------- +release ${top}/release/bin ${top}/release/lib ${top}/release/inc +debug ${top)/debug/bin $(top)/debug/lib ${top}/debug/inc +--------------------------------------------------------------------------- + +* ${top} - 최상위 디렉토리 +}}} + +특정한 컴파일러와 컴파일러 옵션을 사용하고 싶을때는 [[configure]]를 실행할때 이를 명시해야 한다. 다음의 예들을 보라. + +{{{ +# HP-UX B.11.23 with HP ANSI C +CC=cc CFLAGS="-O2 +DD64" LDFLAGS="+DD64" ./configure # 64-bit +CC=cc CFLAGS="-O2 +DD32" LDFLAGS="+DD32" ./configure # 32-bit + +# SCO OpenServer Release 5.0.7 (SCO_SV 3.2 5.0.7) with SCO OpenServer Development System +CC=cc CFLAGS="-Xc -a ansi -O2" ./configure + +# Solaris 10 with GCC +CC=gcc CFLAGS="-Wall -O2 -m64" LDFLAGS="-m64" ./configure # 64-bit +CC=gcc CFLAGS="-Wall -O2" ./configure # 32-bit +}}} + +C++컴파일러와 옵션은 [[CXX]]와 [[CXXFLAGS]]을 사용해서 명시하면 된다. + +JNI헤더파일을 찾을수 있으면 [[configure]]는 JNI라이브러리와 클래스파일들이 만들어 질수 있도록 빌드환경을 설정한다. 이를 위해서 [[javac]]명령어를 [[PATH]]환경변수에 설정된 경로에서 찿고, 이 정보를 이용해서 JNI헤더파일을 찾아낸다. 아파치재단의 {ant,http://ant.apache.org}를 이용하여 자바클래스파일들을 만들수도 있다. 이를 위해서 [[build.xml]]파일이 최상위 디렉토리에 제공된다. + +=== OpenVMS === + +OpenVMS에서는 [[mms]]나 [[mmk]]명령어를 사용해야 한다. 다만 [[configure]]같은 환경설정 스크립트가 제공되지 않으므로, 필요한 경우 [[descrip.mms]]파일을 직접 편집해야 한다. + +예를 들어, awk라이브러리와 시험프로그램을 만들려면 필요한 서브디렉토리에서 [[mms]]나 [[mmk]]를 실행하면 된다. + +{{{ +set default [.ase.cmn] +mms +set default [-.awk] +mms +set default [-.utl] +mms +set default [-.test.awk] +mms +}}} + +OpenVMS에 익숙하지 않은 사용자라면 다음의 방법으로 만들어진 시험프로그램을 실행해볼수 있다. + +{{{ +; define the foreign command. +aseawk :== $DISK$GEIN_SYS:[USERS.BACON.ASE.TEST.AWK]aseawk.exe +; run the command. +aseawk -f hello.awk +}}} + +=== MS-Windows === + +윈도우즈에서는 비쥬얼스튜디오6이나 그 이후 버전이 필요하다. 닷넷관련 프로젝트를 빌드하려면 비쥬얼슈트디오2003이나 그 이후 버전이 필요하다. + +== 바이너리파일 == + +빌드에 성공하면 다음과 같은 파일들이 만들어 진다. + +{{{ +lib +- libaseawk.a + +- libaselsp.a + +- libasecmn.a + +- libaseutl.a + +bin +}}} diff --git a/ase/lsp/aselsp.dsp b/ase/lsp/aselsp.dsp new file mode 100644 index 00000000..032c3d77 --- /dev/null +++ b/ase/lsp/aselsp.dsp @@ -0,0 +1,180 @@ +# Microsoft Developer Studio Project File - Name="aselsp" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=aselsp - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "aselsp.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "aselsp.mak" CFG="aselsp - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "aselsp - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "aselsp - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "aselsp - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "../release/lib" +# PROP Intermediate_Dir "release" +# PROP Target_Dir "" +MTL=midl.exe +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD CPP /nologo /MT /W3 /GX /O2 /I "../.." /D "NDEBUG" /D "WIN32" /D "_UNICODE" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo + +!ELSEIF "$(CFG)" == "aselsp - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "../debug/lib" +# PROP Intermediate_Dir "debug" +# PROP Target_Dir "" +MTL=midl.exe +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../.." /D "_DEBUG" /D "WIN32" /D "_UNICODE" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo + +!ENDIF + +# Begin Target + +# Name "aselsp - Win32 Release" +# Name "aselsp - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\env.c +# End Source File +# Begin Source File + +SOURCE=.\err.c +# End Source File +# Begin Source File + +SOURCE=.\eval.c +# End Source File +# Begin Source File + +SOURCE=.\lsp.c +# End Source File +# Begin Source File + +SOURCE=.\mem.c +# End Source File +# Begin Source File + +SOURCE=.\misc.c +# End Source File +# Begin Source File + +SOURCE=.\name.c +# End Source File +# Begin Source File + +SOURCE=.\prim.c +# End Source File +# Begin Source File + +SOURCE=.\prim_compar.c +# End Source File +# Begin Source File + +SOURCE=.\prim_let.c +# End Source File +# Begin Source File + +SOURCE=.\prim_math.c +# End Source File +# Begin Source File + +SOURCE=.\prim_prog.c +# End Source File +# Begin Source File + +SOURCE=.\print.c +# End Source File +# Begin Source File + +SOURCE=.\read.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\env.h +# End Source File +# Begin Source File + +SOURCE=.\lsp.h +# End Source File +# Begin Source File + +SOURCE=.\lsp_i.h +# End Source File +# Begin Source File + +SOURCE=.\mem.h +# End Source File +# Begin Source File + +SOURCE=.\misc.h +# End Source File +# Begin Source File + +SOURCE=.\name.h +# End Source File +# Begin Source File + +SOURCE=.\obj.h +# End Source File +# Begin Source File + +SOURCE=.\prim.h +# End Source File +# End Group +# End Target +# End Project diff --git a/ase/lsp/aselsp.vcproj b/ase/lsp/aselsp.vcproj new file mode 100644 index 00000000..cad9d7a3 --- /dev/null +++ b/ase/lsp/aselsp.vcproj @@ -0,0 +1,522 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ase/lsp/descrip.mms b/ase/lsp/descrip.mms new file mode 100644 index 00000000..95564785 --- /dev/null +++ b/ase/lsp/descrip.mms @@ -0,0 +1,28 @@ +# +# OpenVMS MMS/MMK +# + +objects = lsp.obj name.obj mem.obj env.obj err.obj read.obj eval.obj print.obj misc.obj prim.obj prim_prog.obj prim_let.obj prim_compar.obj prim_math.obj + +CFLAGS = /include="../.." +#CFLAGS = /pointer_size=long /include="../.." + +aselsp.olb : $(objects) + $(LIBR)/create $(MMS$TARGET) *.obj +# $(LIBR)/create $(MMS$TARGET) $(objects) + +lsp.obj depends_on lsp.c +name.obj depends_on name.c +mem.obj depends_on mem.c +env.obj depends_on env.c +err.obj depends_on err.c +read.obj depends_on read.c +eval.obj depends_on eval.c +print.obj depends_on print.c +misc.obj depends_on misc.c +prim.obj depends_on prim.c +prim_prog.obj depends_on prim_prog.c +prim_let.obj depends_on prim_let.c +prim_compar.obj depends_on prim_compar.c +prim_math.obj depends_on prim_math.c + diff --git a/ase/lsp/env.c b/ase/lsp/env.c new file mode 100644 index 00000000..73b2a24b --- /dev/null +++ b/ase/lsp/env.c @@ -0,0 +1,146 @@ +/* + * $Id: env.c,v 1.3 2007/04/30 06:09:46 bacon Exp $ + * + * {License} + */ + +#include + +/* TODO: make the frame hash accessible */ + +static ase_lsp_assoc_t* __new_assoc ( + ase_lsp_t* lsp, ase_lsp_obj_t* name, + ase_lsp_obj_t* value, ase_lsp_obj_t* func) +{ + ase_lsp_assoc_t* assoc; + + assoc = (ase_lsp_assoc_t*) + ASE_LSP_MALLOC (lsp, sizeof(ase_lsp_assoc_t)); + if (assoc == ASE_NULL) + { + ase_lsp_seterror (lsp, ASE_LSP_ENOMEM, ASE_NULL, 0); + return ASE_NULL; + } + + assoc->name = name; + assoc->value = value; + assoc->func = func; + assoc->link = ASE_NULL; + + return assoc; +} + +ase_lsp_frame_t* ase_lsp_newframe (ase_lsp_t* lsp) +{ + ase_lsp_frame_t* frame; + + frame = (ase_lsp_frame_t*) + ASE_LSP_MALLOC (lsp, sizeof(ase_lsp_frame_t)); + if (frame == ASE_NULL) + { + ase_lsp_seterror (lsp, ASE_LSP_ENOMEM, ASE_NULL, 0); + return ASE_NULL; + } + + frame->assoc = ASE_NULL; + frame->link = ASE_NULL; + + return frame; +} + +void ase_lsp_freeframe (ase_lsp_t* lsp, ase_lsp_frame_t* frame) +{ + ase_lsp_assoc_t* assoc, * link; + + /* destroy the associations */ + assoc = frame->assoc; + while (assoc != ASE_NULL) + { + link = assoc->link; + ASE_LSP_FREE (lsp, assoc); + assoc = link; + } + + ASE_LSP_FREE (lsp, frame); +} + +ase_lsp_assoc_t* ase_lsp_lookupinframe ( + ase_lsp_t* lsp, ase_lsp_frame_t* frame, ase_lsp_obj_t* name) +{ + ase_lsp_assoc_t* assoc; + + ASE_ASSERT (ASE_LSP_TYPE(name) == ASE_LSP_OBJ_SYM); + + assoc = frame->assoc; + while (assoc != ASE_NULL) + { + if (name == assoc->name) return assoc; + assoc = assoc->link; + } + return ASE_NULL; +} + +ase_lsp_assoc_t* ase_lsp_insvalueintoframe ( + ase_lsp_t* lsp, ase_lsp_frame_t* frame, + ase_lsp_obj_t* name, ase_lsp_obj_t* value) +{ + ase_lsp_assoc_t* assoc; + + ASE_ASSERT (ASE_LSP_TYPE(name) == ASE_LSP_OBJ_SYM); + + assoc = __new_assoc (lsp, name, value, ASE_NULL); + if (assoc == ASE_NULL) return ASE_NULL; + + assoc->link = frame->assoc; + frame->assoc = assoc; + return assoc; +} + +ase_lsp_assoc_t* ase_lsp_insfuncintoframe ( + ase_lsp_t* lsp, ase_lsp_frame_t* frame, + ase_lsp_obj_t* name, ase_lsp_obj_t* func) +{ + ase_lsp_assoc_t* assoc; + + ASE_ASSERT (ASE_LSP_TYPE(name) == ASE_LSP_OBJ_SYM); + + assoc = __new_assoc (lsp, name, ASE_NULL, func); + if (assoc == ASE_NULL) return ASE_NULL; + + assoc->link = frame->assoc; + frame->assoc = assoc; + return assoc; +} + +ase_lsp_tlink_t* ase_lsp_pushtmp (ase_lsp_t* lsp, ase_lsp_obj_t* obj) +{ + ase_lsp_tlink_t* tlink; + + tlink = (ase_lsp_tlink_t*) + ASE_LSP_MALLOC (lsp, sizeof(ase_lsp_tlink_t)); + if (tlink == ASE_NULL) + { + ase_lsp_seterror (lsp, ASE_LSP_ENOMEM, ASE_NULL, 0); + return ASE_NULL; + } + + tlink->obj = obj; + tlink->link = lsp->mem->tlink; + lsp->mem->tlink = tlink; + lsp->mem->tlink_count++; + + return tlink; +} + +void ase_lsp_poptmp (ase_lsp_t* lsp) +{ + ase_lsp_tlink_t* top; + + ASE_ASSERT (lsp->mem->tlink != ASE_NULL); + + top = lsp->mem->tlink; + lsp->mem->tlink = top->link; + lsp->mem->tlink_count--; + + ASE_LSP_FREE (lsp, top); +} diff --git a/ase/lsp/env.h b/ase/lsp/env.h new file mode 100644 index 00000000..69f0af44 --- /dev/null +++ b/ase/lsp/env.h @@ -0,0 +1,63 @@ +/* + * $Id: env.h,v 1.3 2007/04/30 06:09:46 bacon Exp $ + * + * {License} + */ + +#ifndef _ASE_LSP_ENV_H_ +#define _ASE_LSP_ENV_H_ + +#ifndef _ASE_LSP_LSP_H_ +#error Never include this file directly. Include instead +#endif + +typedef struct ase_lsp_assoc_t ase_lsp_assoc_t; +typedef struct ase_lsp_frame_t ase_lsp_frame_t; +typedef struct ase_lsp_tlink_t ase_lsp_tlink_t; + +struct ase_lsp_assoc_t +{ + ase_lsp_obj_t* name; /* ase_lsp_obj_sym_t */ + ase_lsp_obj_t* value; /* value as a variable */ + ase_lsp_obj_t* func; /* function definition */ + + ase_lsp_assoc_t* link; +}; + +struct ase_lsp_frame_t +{ + ase_lsp_assoc_t* assoc; + ase_lsp_frame_t* link; +}; + +struct ase_lsp_tlink_t +{ + ase_lsp_obj_t* obj; + ase_lsp_tlink_t* link; +}; + +#ifdef __cplusplus +extern "C" { +#endif + +ase_lsp_frame_t* ase_lsp_newframe (ase_lsp_t* lsp); +void ase_lsp_freeframe (ase_lsp_t* lsp, ase_lsp_frame_t* frame); + +ase_lsp_assoc_t* ase_lsp_lookupinframe ( + ase_lsp_t* lsp, ase_lsp_frame_t* frame, ase_lsp_obj_t* name); + +ase_lsp_assoc_t* ase_lsp_insvalueintoframe ( + ase_lsp_t* lsp, ase_lsp_frame_t* frame, + ase_lsp_obj_t* name, ase_lsp_obj_t* value); +ase_lsp_assoc_t* ase_lsp_insfuncintoframe ( + ase_lsp_t* lsp, ase_lsp_frame_t* frame, + ase_lsp_obj_t* name, ase_lsp_obj_t* func); + +ase_lsp_tlink_t* ase_lsp_pushtmp (ase_lsp_t* lsp, ase_lsp_obj_t* obj); +void ase_lsp_poptmp (ase_lsp_t* lsp); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ase/lsp/err.c b/ase/lsp/err.c new file mode 100644 index 00000000..8d7c7adc --- /dev/null +++ b/ase/lsp/err.c @@ -0,0 +1,130 @@ +/* + * $Id: err.c,v 1.3 2007/04/30 06:09:46 bacon Exp $ + * + * {License} + */ + +#include + +static const ase_char_t* __geterrstr (int errnum) +{ + static const ase_char_t* __errstr[] = + { + ASE_T("no error"), + ASE_T("out of memory"), + ASE_T("exit"), + ASE_T("end of source"), + ASE_T("unexpected end of string"), + ASE_T("input not attached"), + ASE_T("input"), + ASE_T("output not attached"), + ASE_T("output"), + ASE_T("syntax"), + ASE_T("right parenthesis expected"), + ASE_T("bad arguments"), + ASE_T("too few arguments"), + ASE_T("too many arguments"), + ASE_T("undefined function '%s'"), + ASE_T("bad function"), + ASE_T("duplicate formal"), + ASE_T("bad symbol"), + ASE_T("undefined symbol '%s'"), + ASE_T("empty body"), + ASE_T("bad value"), + ASE_T("divide by zero") + }; + + if (errnum >= 0 && errnum < ASE_COUNTOF(__errstr)) + { + return __errstr[errnum]; + } + + return ASE_T("unknown error"); +} + +void ase_lsp_geterror ( + ase_lsp_t* lsp, int* errnum, const ase_char_t** errmsg) +{ + if (errnum != ASE_NULL) *errnum = lsp->errnum; + if (errmsg != ASE_NULL) *errmsg = lsp->errmsg; +} + +void ase_lsp_seterror ( + ase_lsp_t* lsp, int errnum, + const ase_char_t** errarg, ase_size_t argcnt) +{ + const ase_char_t* errfmt; + + ASE_ASSERT (argcnt <= 5); + + lsp->errnum = errnum; + errfmt = __geterrstr (errnum); + + switch (argcnt) + { + case 0: + lsp->prmfns.misc.sprintf ( + lsp->prmfns.misc.custom_data, + lsp->errmsg, + ASE_COUNTOF(lsp->errmsg), + errfmt); + return; + + case 1: + lsp->prmfns.misc.sprintf ( + lsp->prmfns.misc.custom_data, + lsp->errmsg, + ASE_COUNTOF(lsp->errmsg), + errfmt, + errarg[0]); + return; + + case 2: + lsp->prmfns.misc.sprintf ( + lsp->prmfns.misc.custom_data, + lsp->errmsg, + ASE_COUNTOF(lsp->errmsg), + errfmt, + errarg[0], + errarg[1]); + return; + + case 3: + lsp->prmfns.misc.sprintf ( + lsp->prmfns.misc.custom_data, + lsp->errmsg, + ASE_COUNTOF(lsp->errmsg), + errfmt, + errarg[0], + errarg[1], + errarg[2]); + return; + + case 4: + lsp->prmfns.misc.sprintf ( + lsp->prmfns.misc.custom_data, + lsp->errmsg, + ASE_COUNTOF(lsp->errmsg), + errfmt, + errarg[0], + errarg[1], + errarg[2], + errarg[3]); + return; + + case 5: + lsp->prmfns.misc.sprintf ( + lsp->prmfns.misc.custom_data, + lsp->errmsg, + ASE_COUNTOF(lsp->errmsg), + errfmt, + errarg[0], + errarg[1], + errarg[2], + errarg[3], + errarg[4]); + return; + } +} + + diff --git a/ase/lsp/eval.c b/ase/lsp/eval.c new file mode 100644 index 00000000..8560fa12 --- /dev/null +++ b/ase/lsp/eval.c @@ -0,0 +1,380 @@ +/* + * $Id: eval.c,v 1.3 2007/04/30 06:09:46 bacon Exp $ + * + * {License} + */ + +#include + +static ase_lsp_obj_t* __eval (ase_lsp_t* lsp, ase_lsp_obj_t* obj); +static ase_lsp_obj_t* makefn ( + ase_lsp_t* lsp, ase_lsp_obj_t* cdr, int is_macro); +static ase_lsp_obj_t* eval_cons ( + ase_lsp_t* lsp, ase_lsp_obj_t* cons); +static ase_lsp_obj_t* apply ( + ase_lsp_t* lsp, ase_lsp_obj_t* func, ase_lsp_obj_t* actual); +static ase_lsp_obj_t* apply_to_prim ( + ase_lsp_t* lsp, ase_lsp_obj_t* func, ase_lsp_obj_t* actual); + +ase_lsp_obj_t* ase_lsp_eval (ase_lsp_t* lsp, ase_lsp_obj_t* obj) +{ + if (ASE_LSP_TYPE(obj) == ASE_LSP_OBJ_CONS) + { + return eval_cons (lsp, obj); + } + else if (ASE_LSP_TYPE(obj) == ASE_LSP_OBJ_SYM) + { + ase_lsp_assoc_t* assoc; + + /* + if (obj == lsp->mem->lambda || obj == lsp->mem->macro) { + ase_char_t* arg[1]; + + arg[0] = ASE_LSP_SYMPTR(obj); + + printf ("lambda or macro can't be used as a normal symbol\n"); + ase_lsp_seterror ( + lsp, ASE_LSP_EBADSYM, + arg, ASE_COUNTOF(arg)); + return ASE_NULL; + } + */ + + assoc = ase_lsp_lookup(lsp->mem, obj); + if (assoc == ASE_NULL || assoc->value == ASE_NULL) + { + if (lsp->opt_undef_symbol) + { + const ase_char_t* arg[1]; + + arg[0] = ASE_LSP_SYMPTR(obj); + + ase_lsp_seterror ( + lsp, ASE_LSP_EUNDEFSYM, + arg, ASE_COUNTOF(arg)); + return ASE_NULL; + } + return lsp->mem->nil; + } + + obj = assoc->value; + } + + return obj; +} + +static ase_lsp_obj_t* makefn (ase_lsp_t* lsp, ase_lsp_obj_t* cdr, int is_macro) +{ + ase_lsp_obj_t* func, * formal, * body, * p; + + if (cdr == lsp->mem->nil) + { + ase_lsp_seterror (lsp, ASE_LSP_EARGFEW, ASE_NULL, 0); + return ASE_NULL; + } + + if (ASE_LSP_TYPE(cdr) != ASE_LSP_OBJ_CONS) + { + ase_lsp_seterror (lsp, ASE_LSP_EARGBAD, ASE_NULL, 0); + return ASE_NULL; + } + + formal = ASE_LSP_CAR(cdr); + body = ASE_LSP_CDR(cdr); + + if (body == lsp->mem->nil) + { + ase_lsp_seterror (lsp, ASE_LSP_EEMPBDY, ASE_NULL, 0); + return ASE_NULL; + } + +/* TODO: more lambda expression syntax checks required???. */ + + /* check if the lambda express has non-nil value + * at the terminating cdr */ + for (p = body; ASE_LSP_TYPE(p) == ASE_LSP_OBJ_CONS; p = ASE_LSP_CDR(p)); + if (p != lsp->mem->nil) + { + /* like in (lambda (x) (+ x 10) . 4) */ + ase_lsp_seterror (lsp, ASE_LSP_EARGBAD, ASE_NULL, 0); + return ASE_NULL; + } + + func = (is_macro)? + ase_lsp_makemacro (lsp->mem, formal, body): + ase_lsp_makefunc (lsp->mem, formal, body); + if (func == ASE_NULL) return ASE_NULL; + + return func; +} + +static ase_lsp_obj_t* eval_cons (ase_lsp_t* lsp, ase_lsp_obj_t* cons) +{ + ase_lsp_obj_t* car, * cdr; + + ASE_ASSERT (ASE_LSP_TYPE(cons) == ASE_LSP_OBJ_CONS); + + car = ASE_LSP_CAR(cons); + cdr = ASE_LSP_CDR(cons); + + if (car == lsp->mem->lambda) + { + /* (lambda (x) (+ x 20)) */ + return makefn (lsp, cdr, 0); + } + else if (car == lsp->mem->macro) + { + /* (macro (x) (+ x 20)) */ + return makefn (lsp, cdr, 1); + } + else if (ASE_LSP_TYPE(car) == ASE_LSP_OBJ_SYM) + { + ase_lsp_assoc_t* assoc; + + if ((assoc = ase_lsp_lookup(lsp->mem, car)) != ASE_NULL) + { + /*ase_lsp_obj_t* func = assoc->value;*/ + ase_lsp_obj_t* func = assoc->func; + if (func == ASE_NULL) + { + /* the symbol's function definition is void */ + const ase_char_t* arg[1]; + + arg[0] = ASE_LSP_SYMPTR(car); + ase_lsp_seterror ( + lsp, ASE_LSP_EUNDEFFN, + arg, ASE_COUNTOF(arg)); + + return ASE_NULL; + } + + if (ASE_LSP_TYPE(func) == ASE_LSP_OBJ_FUNC || + ASE_LSP_TYPE(func) == ASE_LSP_OBJ_MACRO) + { + return apply (lsp, func, cdr); + } + else if (ASE_LSP_TYPE(func) == ASE_LSP_OBJ_PRIM) + { + /* primitive function */ + return apply_to_prim (lsp, func, cdr); + } + else + { + const ase_char_t* arg[1]; + + arg[0] = ASE_LSP_SYMPTR(car); + ase_lsp_seterror ( + lsp, ASE_LSP_EUNDEFFN, + arg, ASE_COUNTOF(arg)); + + return ASE_NULL; + } + } + else + { + const ase_char_t* arg[1]; + + arg[0] = ASE_LSP_SYMPTR(car); + ase_lsp_seterror ( + lsp, ASE_LSP_EUNDEFFN, + arg, ASE_COUNTOF(arg)); + + return ASE_NULL; + } + } + else if (ASE_LSP_TYPE(car) == ASE_LSP_OBJ_FUNC || + ASE_LSP_TYPE(car) == ASE_LSP_OBJ_MACRO) + { + return apply (lsp, car, cdr); + } + else if (ASE_LSP_TYPE(car) == ASE_LSP_OBJ_CONS) + { + /* anonymous function or macros + * ((lambda (x) (+ x 10)) 50) */ + if (ASE_LSP_CAR(car) == lsp->mem->lambda) + { + ase_lsp_obj_t* func = makefn (lsp, ASE_LSP_CDR(car), 0); + if (func == ASE_NULL) return ASE_NULL; + return apply (lsp, func, cdr); + } + else if (ASE_LSP_CAR(car) == lsp->mem->macro) + { + ase_lsp_obj_t* func = makefn (lsp, ASE_LSP_CDR(car), 1); + if (func == ASE_NULL) return ASE_NULL; + return apply (lsp, func, cdr); + } + } + + ase_lsp_seterror (lsp, ASE_LSP_EBADFN, ASE_NULL, 0); + return ASE_NULL; +} + +static ase_lsp_obj_t* apply ( + ase_lsp_t* lsp, ase_lsp_obj_t* func, ase_lsp_obj_t* actual) +{ + ase_lsp_frame_t* frame; + ase_lsp_obj_t* formal; + ase_lsp_obj_t* body; + ase_lsp_obj_t* value; + ase_lsp_mem_t* mem; + + ASE_ASSERT (ASE_LSP_TYPE(func) == ASE_LSP_OBJ_FUNC || + ASE_LSP_TYPE(func) == ASE_LSP_OBJ_MACRO); + + ASE_ASSERT (ASE_LSP_TYPE(ASE_LSP_CDR(func)) == ASE_LSP_OBJ_CONS); + + mem = lsp->mem; + + if (ASE_LSP_TYPE(func) == ASE_LSP_OBJ_MACRO) + { + formal = ASE_LSP_MFORMAL (func); + body = ASE_LSP_MBODY (func); + } + else + { + formal = ASE_LSP_FFORMAL (func); + body = ASE_LSP_FBODY (func); + } + + /* make a new frame. */ + frame = ase_lsp_newframe (lsp); + if (frame == ASE_NULL) return ASE_NULL; + + /* attach it to the brooding frame list to + * prevent them from being garbage-collected. */ + frame->link = mem->brooding_frame; + mem->brooding_frame = frame; + + /* evaluate arguments and push them into the frame. */ + while (formal != mem->nil) + { + if (actual == mem->nil) + { + mem->brooding_frame = frame->link; + ase_lsp_freeframe (lsp, frame); + + ase_lsp_seterror (lsp, ASE_LSP_EARGFEW, ASE_NULL, 0); + return ASE_NULL; + } + + value = ASE_LSP_CAR(actual); + if (ASE_LSP_TYPE(func) != ASE_LSP_OBJ_MACRO) + { + /* macro doesn't evaluate actual arguments. */ + value = ase_lsp_eval (lsp, value); + if (value == ASE_NULL) + { + mem->brooding_frame = frame->link; + ase_lsp_freeframe (lsp, frame); + return ASE_NULL; + } + } + + if (ase_lsp_lookupinframe ( + lsp, frame, ASE_LSP_CAR(formal)) != ASE_NULL) + { + mem->brooding_frame = frame->link; + ase_lsp_freeframe (lsp, frame); + + ase_lsp_seterror (lsp, ASE_LSP_EDUPFML, ASE_NULL, 0); + return ASE_NULL; + } + + if (ase_lsp_insvalueintoframe ( + lsp, frame, ASE_LSP_CAR(formal), value) == ASE_NULL) + { + mem->brooding_frame = frame->link; + ase_lsp_freeframe (lsp, frame); + return ASE_NULL; + } + + actual = ASE_LSP_CDR(actual); + formal = ASE_LSP_CDR(formal); + } + + if (ASE_LSP_TYPE(actual) == ASE_LSP_OBJ_CONS) + { + mem->brooding_frame = frame->link; + ase_lsp_freeframe (lsp, frame); + + ase_lsp_seterror (lsp, ASE_LSP_EARGMANY, ASE_NULL, 0); + return ASE_NULL; + } + else if (actual != mem->nil) + { + mem->brooding_frame = frame->link; + ase_lsp_freeframe (lsp, frame); + + ase_lsp_seterror (lsp, ASE_LSP_EARGBAD, ASE_NULL, 0); + return ASE_NULL; + } + + /* push the frame */ + mem->brooding_frame = frame->link; + frame->link = mem->frame; + mem->frame = frame; + + /* do the evaluation of the body */ + value = mem->nil; + while (body != mem->nil) + { + value = ase_lsp_eval(lsp, ASE_LSP_CAR(body)); + if (value == ASE_NULL) + { + mem->frame = frame->link; + ase_lsp_freeframe (lsp, frame); + return ASE_NULL; + } + body = ASE_LSP_CDR(body); + } + + /* pop the frame. */ + mem->frame = frame->link; + + /* destroy the frame. */ + ase_lsp_freeframe (lsp, frame); + + /*if (ASE_LSP_CAR(func) == mem->macro) {*/ + if (ASE_LSP_TYPE(func) == ASE_LSP_OBJ_MACRO) + { + value = ase_lsp_eval (lsp, value); + if (value == ASE_NULL) return ASE_NULL; + } + + return value; +} + +static ase_lsp_obj_t* apply_to_prim ( + ase_lsp_t* lsp, ase_lsp_obj_t* func, ase_lsp_obj_t* actual) +{ + ase_lsp_obj_t* obj; + ase_size_t count = 0; + + ASE_ASSERT (ASE_LSP_TYPE(func) == ASE_LSP_OBJ_PRIM); + + obj = actual; + while (ASE_LSP_TYPE(obj) == ASE_LSP_OBJ_CONS) + { + count++; + obj = ASE_LSP_CDR(obj); + } + if (obj != lsp->mem->nil) + { + ase_lsp_seterror (lsp, ASE_LSP_EARGBAD, ASE_NULL, 0); + return ASE_NULL; + } + + if (count < ASE_LSP_PMINARGS(func)) + { + ase_lsp_seterror (lsp, ASE_LSP_EARGFEW, ASE_NULL, 0); + return ASE_NULL; + } + + if (count > ASE_LSP_PMAXARGS(func)) + { + ase_lsp_seterror (lsp, ASE_LSP_EARGMANY, ASE_NULL, 0); + return ASE_NULL; + } + + return ASE_LSP_PIMPL(func) (lsp, actual); +} diff --git a/ase/lsp/lsp.c b/ase/lsp/lsp.c new file mode 100644 index 00000000..cfcc3877 --- /dev/null +++ b/ase/lsp/lsp.c @@ -0,0 +1,218 @@ +/* + * $Id: lsp.c,v 1.3 2007/04/30 06:09:46 bacon Exp $ + * + * {License} + */ + +#if defined(__BORLANDC__) +#pragma hdrstop +#define Library +#endif + +#include + +static int __add_builtin_prims (ase_lsp_t* lsp); + +ase_lsp_t* ase_lsp_open ( + const ase_lsp_prmfns_t* prmfns, + ase_size_t mem_ubound, ase_size_t mem_ubound_inc) +{ + ase_lsp_t* lsp; + + if (prmfns == ASE_NULL) return ASE_NULL; + + if (prmfns->mmgr.malloc == ASE_NULL || + prmfns->mmgr.realloc == ASE_NULL || + prmfns->mmgr.free == ASE_NULL) return ASE_NULL; + + if (prmfns->ccls.is_upper == ASE_NULL || + prmfns->ccls.is_lower == ASE_NULL || + prmfns->ccls.is_alpha == ASE_NULL || + prmfns->ccls.is_digit == ASE_NULL || + prmfns->ccls.is_xdigit == ASE_NULL || + prmfns->ccls.is_alnum == ASE_NULL || + prmfns->ccls.is_space == ASE_NULL || + prmfns->ccls.is_print == ASE_NULL || + prmfns->ccls.is_graph == ASE_NULL || + prmfns->ccls.is_cntrl == ASE_NULL || + prmfns->ccls.is_punct == ASE_NULL || + prmfns->ccls.to_upper == ASE_NULL || + prmfns->ccls.to_lower == ASE_NULL) return ASE_NULL; + + if (prmfns->misc.sprintf == ASE_NULL || + prmfns->misc.dprintf == ASE_NULL) return ASE_NULL; + +#if defined(_WIN32) && defined(_MSC_VER) && defined(_DEBUG) + lsp = (ase_lsp_t*) malloc (ASE_SIZEOF(ase_lsp_t)); +#else + lsp = (ase_lsp_t*) prmfns->mmgr.malloc ( + prmfns->mmgr.custom_data, ASE_SIZEOF(ase_lsp_t)); +#endif + if (lsp == ASE_NULL) return ASE_NULL; + + /* it uses the built-in ase_lsp_memset because lsp is not + * fully initialized yet */ + ase_memset (lsp, 0, ASE_SIZEOF(ase_lsp_t)); + ase_memcpy (&lsp->prmfns, prmfns, ASE_SIZEOF(lsp->prmfns)); + + if (ase_lsp_name_open(&lsp->token.name, 0, lsp) == ASE_NULL) + { + ASE_LSP_FREE (lsp, lsp); + return ASE_NULL; + } + + lsp->errnum = ASE_LSP_ENOERR; + lsp->errmsg[0] = ASE_T('\0'); + lsp->opt_undef_symbol = 1; + /*lsp->opt_undef_symbol = 0;*/ + + lsp->curc = ASE_CHAR_EOF; + lsp->input_func = ASE_NULL; + lsp->output_func = ASE_NULL; + lsp->input_arg = ASE_NULL; + lsp->output_arg = ASE_NULL; + + lsp->mem = ase_lsp_openmem (lsp, mem_ubound, mem_ubound_inc); + if (lsp->mem == ASE_NULL) + { + ase_lsp_name_close (&lsp->token.name); + ASE_LSP_FREE (lsp, lsp); + return ASE_NULL; + } + + if (__add_builtin_prims(lsp) == -1) + { + ase_lsp_closemem (lsp->mem); + ase_lsp_name_close (&lsp->token.name); + ASE_LSP_FREE (lsp, lsp); + return ASE_NULL; + } + + lsp->max_eval_depth = 0; /* TODO: put restriction here.... */ + lsp->cur_eval_depth = 0; + + return lsp; +} + +void ase_lsp_close (ase_lsp_t* lsp) +{ + ase_lsp_closemem (lsp->mem); + ase_lsp_name_close (&lsp->token.name); + ASE_LSP_FREE (lsp, lsp); +} + +int ase_lsp_attinput (ase_lsp_t* lsp, ase_lsp_io_t input, void* arg) +{ + if (ase_lsp_detinput(lsp) == -1) return -1; + + ASE_ASSERT (lsp->input_func == ASE_NULL); + + if (input(ASE_LSP_IO_OPEN, arg, ASE_NULL, 0) == -1) + { + /* TODO: set error number */ + return -1; + } + + lsp->input_func = input; + lsp->input_arg = arg; + lsp->curc = ASE_CHAR_EOF; + return 0; +} + +int ase_lsp_detinput (ase_lsp_t* lsp) +{ + if (lsp->input_func != ASE_NULL) + { + if (lsp->input_func ( + ASE_LSP_IO_CLOSE, lsp->input_arg, ASE_NULL, 0) == -1) + { + /* TODO: set error number */ + return -1; + } + lsp->input_func = ASE_NULL; + lsp->input_arg = ASE_NULL; + lsp->curc = ASE_CHAR_EOF; + } + + return 0; +} + +int ase_lsp_attoutput (ase_lsp_t* lsp, ase_lsp_io_t output, void* arg) +{ + if (ase_lsp_detoutput(lsp) == -1) return -1; + + ASE_ASSERT (lsp->output_func == ASE_NULL); + + if (output(ASE_LSP_IO_OPEN, arg, ASE_NULL, 0) == -1) + { + /* TODO: set error number */ + return -1; + } + lsp->output_func = output; + lsp->output_arg = arg; + return 0; +} + +int ase_lsp_detoutput (ase_lsp_t* lsp) +{ + if (lsp->output_func != ASE_NULL) + { + if (lsp->output_func ( + ASE_LSP_IO_CLOSE, lsp->output_arg, ASE_NULL, 0) == -1) + { + /* TODO: set error number */ + return -1; + } + lsp->output_func = ASE_NULL; + lsp->output_arg = ASE_NULL; + } + + return 0; +} + +static int __add_builtin_prims (ase_lsp_t* lsp) +{ + +#define ADD_PRIM(mem,name,name_len,pimpl,min_args,max_args) \ + if (ase_lsp_addprim(mem,name,name_len,pimpl,min_args,max_args) == -1) return -1; +#define MAX_ARGS ASE_TYPE_MAX(ase_size_t) + + ADD_PRIM (lsp, ASE_T("exit"), 4, ase_lsp_prim_exit, 0, 0); + ADD_PRIM (lsp, ASE_T("eval"), 4, ase_lsp_prim_eval, 1, 1); + ADD_PRIM (lsp, ASE_T("prog1"), 5, ase_lsp_prim_prog1, 1, MAX_ARGS); + ADD_PRIM (lsp, ASE_T("progn"), 5, ase_lsp_prim_progn, 1, MAX_ARGS); + ADD_PRIM (lsp, ASE_T("gc"), 2, ase_lsp_prim_gc, 0, 0); + + ADD_PRIM (lsp, ASE_T("cond"), 4, ase_lsp_prim_cond, 0, MAX_ARGS); + ADD_PRIM (lsp, ASE_T("if"), 2, ase_lsp_prim_if, 2, MAX_ARGS); + ADD_PRIM (lsp, ASE_T("while"), 5, ase_lsp_prim_while, 1, MAX_ARGS); + + ADD_PRIM (lsp, ASE_T("car"), 3, ase_lsp_prim_car, 1, 1); + ADD_PRIM (lsp, ASE_T("cdr"), 3, ase_lsp_prim_cdr, 1, 1); + ADD_PRIM (lsp, ASE_T("cons"), 4, ase_lsp_prim_cons, 2, 2); + ADD_PRIM (lsp, ASE_T("length"), 6, ase_lsp_prim_length, 1, 1); + + ADD_PRIM (lsp, ASE_T("set"), 3, ase_lsp_prim_set, 2, 2); + ADD_PRIM (lsp, ASE_T("setq"), 4, ase_lsp_prim_setq, 1, MAX_ARGS); + ADD_PRIM (lsp, ASE_T("quote"), 5, ase_lsp_prim_quote, 1, 1); + ADD_PRIM (lsp, ASE_T("defun"), 5, ase_lsp_prim_defun, 3, MAX_ARGS); + ADD_PRIM (lsp, ASE_T("demac"), 5, ase_lsp_prim_demac, 3, MAX_ARGS); + ADD_PRIM (lsp, ASE_T("let"), 3, ase_lsp_prim_let, 1, MAX_ARGS); + ADD_PRIM (lsp, ASE_T("let*"), 4, ase_lsp_prim_letx, 1, MAX_ARGS); + /*ADD_PRIM (lsp, ASE_T("or"), 2, ase_lsp_prim_or, 2, MAX_ARGS);*/ + + ADD_PRIM (lsp, ASE_T("="), 1, ase_lsp_prim_eq, 2, 2); + ADD_PRIM (lsp, ASE_T("/="), 2, ase_lsp_prim_ne, 2, 2); + ADD_PRIM (lsp, ASE_T(">"), 1, ase_lsp_prim_gt, 2, 2); + ADD_PRIM (lsp, ASE_T("<"), 1, ase_lsp_prim_lt, 2, 2); + ADD_PRIM (lsp, ASE_T(">="), 2, ase_lsp_prim_ge, 2, 2); + ADD_PRIM (lsp, ASE_T("<="), 2, ase_lsp_prim_le, 2, 2); + + ADD_PRIM (lsp, ASE_T("+"), 1, ase_lsp_prim_plus, 1, MAX_ARGS); + ADD_PRIM (lsp, ASE_T("-"), 1, ase_lsp_prim_minus, 1, MAX_ARGS); + ADD_PRIM (lsp, ASE_T("*"), 1, ase_lsp_prim_mul, 1, MAX_ARGS); + ADD_PRIM (lsp, ASE_T("/"), 1, ase_lsp_prim_div, 1, MAX_ARGS); + ADD_PRIM (lsp, ASE_T("%"), 1, ase_lsp_prim_mod , 1, MAX_ARGS); + + return 0; +} diff --git a/ase/lsp/lsp.h b/ase/lsp/lsp.h new file mode 100644 index 00000000..246e08ca --- /dev/null +++ b/ase/lsp/lsp.h @@ -0,0 +1,123 @@ +/* + * $Id: lsp.h,v 1.3 2007/04/30 06:09:46 bacon Exp $ + * + * {License} + */ + +#ifndef _ASE_LSP_LSP_H_ +#define _ASE_LSP_LSP_H_ + +#include +#include + +typedef struct ase_lsp_t ase_lsp_t; +typedef struct ase_lsp_obj_t ase_lsp_obj_t; +typedef struct ase_lsp_prmfns_t ase_lsp_prmfns_t; + +typedef ase_ssize_t (*ase_lsp_io_t) ( + int cmd, void* arg, ase_char_t* data, ase_size_t count); + +typedef ase_real_t (*ase_lsp_pow_t) ( + void* custom, ase_real_t x, ase_real_t y); +typedef int (*ase_lsp_sprintf_t) ( + void* custom, ase_char_t* buf, ase_size_t size, + const ase_char_t* fmt, ...); +typedef void (*ase_lsp_dprintf_t) (void* custom, const ase_char_t* fmt, ...); + +struct ase_lsp_prmfns_t +{ + ase_mmgr_t mmgr; + ase_ccls_t ccls; + + /* utilities */ + struct + { + ase_lsp_sprintf_t sprintf; + ase_lsp_dprintf_t dprintf; + void* custom_data; + } misc; +}; + +/* io function commands */ +enum +{ + ASE_LSP_IO_OPEN = 0, + ASE_LSP_IO_CLOSE = 1, + ASE_LSP_IO_READ = 2, + ASE_LSP_IO_WRITE = 3 +}; + +/* option code */ +enum +{ + ASE_LSP_UNDEFSYMBOL = (1 << 0) +}; + +/* error code */ +enum +{ + ASE_LSP_ENOERR, + ASE_LSP_ENOMEM, + + ASE_LSP_EEXIT, + ASE_LSP_EEND, + ASE_LSP_EENDSTR, + ASE_LSP_ENOINP, + ASE_LSP_EINPUT, + ASE_LSP_ENOOUTP, + ASE_LSP_EOUTPUT, + + ASE_LSP_ESYNTAX, + ASE_LSP_ERPAREN, + ASE_LSP_EARGBAD, + ASE_LSP_EARGFEW, + ASE_LSP_EARGMANY, + ASE_LSP_EUNDEFFN, + ASE_LSP_EBADFN, + ASE_LSP_EDUPFML, + ASE_LSP_EBADSYM, + ASE_LSP_EUNDEFSYM, + ASE_LSP_EEMPBDY, + ASE_LSP_EVALBAD, + ASE_LSP_EDIVBY0 +}; + +typedef ase_lsp_obj_t* (*ase_lsp_prim_t) (ase_lsp_t* lsp, ase_lsp_obj_t* obj); + +#ifdef __cplusplus +extern "C" { +#endif + +ase_lsp_t* ase_lsp_open ( + const ase_lsp_prmfns_t* prmfns, + ase_size_t mem_ubound, ase_size_t mem_ubound_inc); + +void ase_lsp_close (ase_lsp_t* lsp); + +void ase_lsp_geterror ( + ase_lsp_t* lsp, int* errnum, const ase_char_t** errmsg); + +void ase_lsp_seterror ( + ase_lsp_t* lsp, int errnum, + const ase_char_t** errarg, ase_size_t argcnt); + +int ase_lsp_attinput (ase_lsp_t* lsp, ase_lsp_io_t input, void* arg); +int ase_lsp_detinput (ase_lsp_t* lsp); + +int ase_lsp_attoutput (ase_lsp_t* lsp, ase_lsp_io_t output, void* arg); +int ase_lsp_detoutput (ase_lsp_t* lsp); + +ase_lsp_obj_t* ase_lsp_read (ase_lsp_t* lsp); +ase_lsp_obj_t* ase_lsp_eval (ase_lsp_t* lsp, ase_lsp_obj_t* obj); +int ase_lsp_print (ase_lsp_t* lsp, const ase_lsp_obj_t* obj); + +int ase_lsp_addprim ( + ase_lsp_t* lsp, const ase_char_t* name, ase_size_t name_len, + ase_lsp_prim_t prim, ase_size_t min_args, ase_size_t max_args); +int ase_lsp_removeprim (ase_lsp_t* lsp, const ase_char_t* name); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ase/lsp/lsp_i.h b/ase/lsp/lsp_i.h new file mode 100644 index 00000000..031fdfb2 --- /dev/null +++ b/ase/lsp/lsp_i.h @@ -0,0 +1,87 @@ +/* + * $Id: lsp_i.h,v 1.3 2007/04/30 06:09:46 bacon Exp $ + * + * {License} + */ + +#ifndef _ASE_LSP_LSPI_H_ +#define _ASE_LSP_LSPI_H_ + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#ifdef _MSC_VER +#pragma warning (disable: 4996) +#endif + +#if defined(_WIN32) && defined(_MSC_VER) && defined(_DEBUG) + #define _CRTDBG_MAP_ALLOC + #include + + #define ASE_LSP_MALLOC(lsp,size) malloc (size) + #define ASE_LSP_REALLOC(lsp,ptr,size) realloc (ptr, size) + #define ASE_LSP_FREE(lsp,ptr) free (ptr) +#else + #define ASE_LSP_MALLOC(lsp,size) ASE_MALLOC(&(lsp)->prmfns.mmgr,size) + #define ASE_LSP_REALLOC(lsp,ptr,size) ASE_REALLOC(&(lsp)->prmfns.mmgr,ptr,size) + #define ASE_LSP_FREE(lsp,ptr) ASE_FREE(&(lsp)->prmfns.mmgr,ptr) +#endif + +#define ASE_LSP_ISUPPER(lsp,c) ASE_ISUPPER(&(lsp)->prmfns.ccls,c) +#define ASE_LSP_ISLOWER(lsp,c) ASE_ISLOWER(&(lsp)->prmfns.ccls,c) +#define ASE_LSP_ISALPHA(lsp,c) ASE_ISALPHA(&(lsp)->prmfns.ccls,c) +#define ASE_LSP_ISDIGIT(lsp,c) ASE_ISDIGIT(&(lsp)->prmfns.ccls,c) +#define ASE_LSP_ISXDIGIT(lsp,c) ASE_ISXDIGIT(&(lsp)->prmfns.ccls,c) +#define ASE_LSP_ISALNUM(lsp,c) ASE_ISALNUM(&(lsp)->prmfns.ccls,c) +#define ASE_LSP_ISSPACE(lsp,c) ASE_ISSPACE(&(lsp)->prmfns.ccls,c) +#define ASE_LSP_ISPRINT(lsp,c) ASE_ISPRINT(&(lsp)->prmfns.ccls,c) +#define ASE_LSP_ISGRAPH(lsp,c) ASE_ISGRAPH(&(lsp)->prmfns.ccls,c) +#define ASE_LSP_ISCNTRL(lsp,c) ASE_ISCNTRL(&(lsp)->prmfns.ccls,c) +#define ASE_LSP_ISPUNCT(lsp,c) ASE_ISPUNCT(&(lsp)->prmfns.ccls,c) +#define ASE_LSP_TOUPPER(lsp,c) ASE_TOUPPER(&(lsp)->prmfns.ccls,c) +#define ASE_LSP_TOLOWER(lsp,c) ASE_TOLOWER(&(lsp)->prmfns.ccls,c) + +struct ase_lsp_t +{ + ase_lsp_prmfns_t prmfns; + + /* error */ + int errnum; + ase_char_t errmsg[256]; + + /* options */ + int opt_undef_symbol; + + /* for read */ + ase_cint_t curc; + struct + { + int type; + ase_long_t ival; + ase_real_t rval; + ase_lsp_name_t name; + } token; + + /* io functions */ + ase_lsp_io_t input_func; + ase_lsp_io_t output_func; + void* input_arg; + void* output_arg; + + /* security options */ + ase_size_t max_eval_depth; + ase_size_t cur_eval_depth; + + /* memory manager */ + ase_lsp_mem_t* mem; +}; + +#endif diff --git a/ase/lsp/makefile.in b/ase/lsp/makefile.in new file mode 100644 index 00000000..def3e66e --- /dev/null +++ b/ase/lsp/makefile.in @@ -0,0 +1,93 @@ +# +# $Id: makefile.in,v 1.3 2007/04/30 06:09:46 bacon Exp $ +# + +NAME = aselsp + +CC = @CC@ +AR = ar +MAKE = @MAKE@ +RANLIB = @RANLIB@ +CFLAGS = @CFLAGS@ -I@abs_top_builddir@/.. +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ +MODE = @BUILDMODE@ + +OUT_DIR = ../$(MODE)/lib +OUT_FILE = $(OUT_DIR)/lib$(NAME).a + +TMP_DIR = $(MODE) + +OBJ_FILES = \ + $(TMP_DIR)/lsp.o \ + $(TMP_DIR)/name.o \ + $(TMP_DIR)/mem.o \ + $(TMP_DIR)/env.o \ + $(TMP_DIR)/err.o \ + $(TMP_DIR)/eval.o \ + $(TMP_DIR)/read.o \ + $(TMP_DIR)/print.o \ + $(TMP_DIR)/misc.o \ + $(TMP_DIR)/prim.o \ + $(TMP_DIR)/prim_prog.o \ + $(TMP_DIR)/prim_let.o \ + $(TMP_DIR)/prim_compar.o \ + $(TMP_DIR)/prim_math.o + +lib: $(OUT_FILE) + +$(OUT_FILE): $(TMP_DIR) $(OBJ_FILES) $(OUT_DIR) + $(AR) cr $(OUT_FILE) $(OBJ_FILES) + if [ "$(RANLIB)" = "ranlib" ]; then ranlib $(OUT_FILE); fi + +$(TMP_DIR)/lsp.o: lsp.c + $(CC) $(CFLAGS) -o $@ -c lsp.c + +$(TMP_DIR)/name.o: name.c + $(CC) $(CFLAGS) -o $@ -c name.c + +$(TMP_DIR)/mem.o: mem.c + $(CC) $(CFLAGS) -o $@ -c mem.c + +$(TMP_DIR)/env.o: env.c + $(CC) $(CFLAGS) -o $@ -c env.c + +$(TMP_DIR)/err.o: err.c + $(CC) $(CFLAGS) -o $@ -c err.c + +$(TMP_DIR)/eval.o: eval.c + $(CC) $(CFLAGS) -o $@ -c eval.c + +$(TMP_DIR)/read.o: read.c + $(CC) $(CFLAGS) -o $@ -c read.c + +$(TMP_DIR)/print.o: print.c + $(CC) $(CFLAGS) -o $@ -c print.c + +$(TMP_DIR)/misc.o: misc.c + $(CC) $(CFLAGS) -o $@ -c misc.c + +$(TMP_DIR)/prim.o: prim.c + $(CC) $(CFLAGS) -o $@ -c prim.c + +$(TMP_DIR)/prim_prog.o: prim_prog.c + $(CC) $(CFLAGS) -o $@ -c prim_prog.c + +$(TMP_DIR)/prim_let.o: prim_let.c + $(CC) $(CFLAGS) -o $@ -c prim_let.c + +$(TMP_DIR)/prim_compar.o: prim_compar.c + $(CC) $(CFLAGS) -o $@ -c prim_compar.c + +$(TMP_DIR)/prim_math.o: prim_math.c + $(CC) $(CFLAGS) -o $@ -c prim_math.c + +$(OUT_DIR): + mkdir -p $(OUT_DIR) + +$(TMP_DIR): + mkdir -p $(TMP_DIR) + +clean: + rm -rf $(OUT_FILE) $(OBJ_FILES) + diff --git a/ase/lsp/makefile.msw.bcc b/ase/lsp/makefile.msw.bcc new file mode 100644 index 00000000..d3a13f88 --- /dev/null +++ b/ase/lsp/makefile.msw.bcc @@ -0,0 +1,21 @@ +SRCS = lsp.c name.c mem.c env.c err.c read.c eval.c print.c misc.c \ + prim.c prim_prog.c prim_let.c prim_compar.c prim_math.c +OBJS = $(SRCS:.c=.obj) +OUT = aselsp.lib + +CC = bcc32 +CFLAGS = -O2 -WM -w -w-inl -w-sig -w-spa -w-hid -RT- -I../.. + +all: $(OBJS) + tlib $(OUT) @&&! ++-$(**: = &^ ++-) +! + +clean: + -del $(OBJS) $(OUT) *.obj + +.SUFFIXES: .c .obj +.c.obj: + $(CC) $(CFLAGS) -c $< + diff --git a/ase/lsp/makefile.msw.cl b/ase/lsp/makefile.msw.cl new file mode 100644 index 00000000..e7e9c797 --- /dev/null +++ b/ase/lsp/makefile.msw.cl @@ -0,0 +1,24 @@ +OUT = aselsp + +SRCS = lsp.c name.c mem.c env.c err.c read.c eval.c print.c misc.c \ + prim.c prim_prog.c prim_let.c prim_compar.c prim_math.c +OBJS = $(SRCS:.c=.obj) + +CC = cl +LD = link +CFLAGS = /nologo /O2 /MT /W3 /GR- /Za -I../.. + +all: lib + +lib: $(OBJS) + $(LD) -lib @<< +/nologo /out:$(OUT).lib $(OBJS) +<< + +clean: + del $(OBJS) $(OUT) *.obj + +.SUFFIXES: .c .obj +.c.obj: + $(CC) $(CFLAGS) /c $< + diff --git a/ase/lsp/mem.c b/ase/lsp/mem.c new file mode 100644 index 00000000..7c70de81 --- /dev/null +++ b/ase/lsp/mem.c @@ -0,0 +1,603 @@ +/* + * $Id: mem.c,v 1.3 2007/04/30 06:09:46 bacon Exp $ + * + * {License} + */ + +#include + +ase_lsp_mem_t* ase_lsp_openmem ( + ase_lsp_t* lsp, ase_size_t ubound, ase_size_t ubound_inc) +{ + ase_lsp_mem_t* mem; + ase_size_t i; + + /* allocate memory */ + mem = (ase_lsp_mem_t*) ASE_LSP_MALLOC (lsp, ASE_SIZEOF(ase_lsp_mem_t)); + if (mem == ASE_NULL) return ASE_NULL; + + ase_memset (mem, 0, ASE_SIZEOF(ase_lsp_mem_t)); + mem->lsp = lsp; + + /* create a new root environment frame */ + mem->frame = ase_lsp_newframe (lsp); + if (mem->frame == ASE_NULL) + { + ASE_LSP_FREE (lsp, mem); + return ASE_NULL; + } + mem->root_frame = mem->frame; + mem->brooding_frame = ASE_NULL; + mem->tlink = ASE_NULL; + mem->tlink_count = 0; + + /* initialize object allocation list */ + mem->ubound = ubound; + mem->ubound_inc = ubound_inc; + mem->count = 0; + for (i = 0; i < ASE_LSP_TYPE_COUNT; i++) + { + mem->used[i] = ASE_NULL; + mem->free[i] = ASE_NULL; + } + mem->read = ASE_NULL; + + /* when "ubound" is too small, the garbage collection can + * be performed while making the common objects. */ + mem->nil = ASE_NULL; + mem->t = ASE_NULL; + mem->quote = ASE_NULL; + mem->lambda = ASE_NULL; + mem->macro = ASE_NULL; + + /* initialize common object pointers */ + mem->nil = ase_lsp_makenil (mem); + mem->t = ase_lsp_maketrue (mem); + mem->quote = ase_lsp_makesym (mem, ASE_T("quote"), 5); + mem->lambda = ase_lsp_makesym (mem, ASE_T("lambda"), 6); + mem->macro = ase_lsp_makesym (mem, ASE_T("macro"), 5); + + if (mem->nil == ASE_NULL || + mem->t == ASE_NULL || + mem->quote == ASE_NULL || + mem->lambda == ASE_NULL || + mem->macro == ASE_NULL) + { + ase_lsp_dispose_all (mem); + ase_lsp_freeframe (lsp, mem->frame); + ASE_LSP_FREE (lsp, mem); + return ASE_NULL; + } + + ASE_LSP_PERM(mem->nil) = 1; + ASE_LSP_PERM(mem->t) = 1; + ASE_LSP_PERM(mem->quote) = 1; + ASE_LSP_PERM(mem->lambda) = 1; + ASE_LSP_PERM(mem->macro) = 1; + + return mem; +} + +void ase_lsp_closemem (ase_lsp_mem_t* mem) +{ + /* dispose of the allocated objects */ + ase_lsp_dispose_all (mem); + + /* dispose of environment frames */ + ase_lsp_freeframe (mem->lsp, mem->frame); + + /* free the memory */ + ASE_LSP_FREE (mem->lsp, mem); +} + +ase_lsp_obj_t* ase_lsp_alloc (ase_lsp_mem_t* mem, int type, ase_size_t size) +{ + ase_lsp_obj_t* obj; + +/* TODO: remove the following line... */ +ase_lsp_gc (mem); + + if (mem->count >= mem->ubound) ase_lsp_gc (mem); + if (mem->count >= mem->ubound) + { + mem->ubound += mem->ubound_inc; + if (mem->count >= mem->ubound) return ASE_NULL; + } + + obj = (ase_lsp_obj_t*) ASE_LSP_MALLOC (mem->lsp, size); + if (obj == ASE_NULL) + { + ase_lsp_gc (mem); + + obj = (ase_lsp_obj_t*) ASE_LSP_MALLOC (mem->lsp, size); + if (obj == ASE_NULL) + { + ase_lsp_seterror (mem->lsp, ASE_LSP_ENOMEM, ASE_NULL, 0); + return ASE_NULL; + } + } + + ASE_LSP_TYPE(obj) = type; + ASE_LSP_SIZE(obj) = size; + ASE_LSP_MARK(obj) = 0; + ASE_LSP_PERM(obj) = 0; + ASE_LSP_LOCK(obj) = 0; + + /* insert the object at the head of the used list */ + ASE_LSP_LINK(obj) = mem->used[type]; + mem->used[type] = obj; + mem->count++; + +#if 0 + ase_dprint1 (ASE_T("mem->count: %u\n"), mem->count); +#endif + + return obj; +} + +void ase_lsp_dispose ( + ase_lsp_mem_t* mem, ase_lsp_obj_t* prev, ase_lsp_obj_t* obj) +{ + ASE_ASSERT (obj != ASE_NULL); + ASE_ASSERT (mem->count > 0); + + /* TODO: push the object to the free list for more + * efficient memory management */ + + if (prev == ASE_NULL) + mem->used[ASE_LSP_TYPE(obj)] = ASE_LSP_LINK(obj); + else ASE_LSP_LINK(prev) = ASE_LSP_LINK(obj); + + mem->count--; +#if 0 + ase_dprint1 (ASE_T("mem->count: %u\n"), mem->count); +#endif + + ASE_LSP_FREE (mem->lsp, obj); +} + +void ase_lsp_dispose_all (ase_lsp_mem_t* mem) +{ + ase_lsp_obj_t* obj, * next; + ase_size_t i; + + for (i = 0; i < ASE_LSP_TYPE_COUNT; i++) + { + obj = mem->used[i]; + + while (obj != ASE_NULL) + { + next = ASE_LSP_LINK(obj); + ase_lsp_dispose (mem, ASE_NULL, obj); + obj = next; + } + } +} + +static void __mark_obj (ase_lsp_t* lsp, ase_lsp_obj_t* obj) +{ + ASE_ASSERT (obj != ASE_NULL); + + /* TODO: can it be recursive? */ + if (ASE_LSP_MARK(obj) != 0) return; + + ASE_LSP_MARK(obj) = 1; + + if (ASE_LSP_TYPE(obj) == ASE_LSP_OBJ_CONS) + { + __mark_obj (lsp, ASE_LSP_CAR(obj)); + __mark_obj (lsp, ASE_LSP_CDR(obj)); + } + else if (ASE_LSP_TYPE(obj) == ASE_LSP_OBJ_FUNC) + { + __mark_obj (lsp, ASE_LSP_FFORMAL(obj)); + __mark_obj (lsp, ASE_LSP_FBODY(obj)); + } + else if (ASE_LSP_TYPE(obj) == ASE_LSP_OBJ_MACRO) + { + __mark_obj (lsp, ASE_LSP_MFORMAL(obj)); + __mark_obj (lsp, ASE_LSP_MBODY(obj)); + } +} + +/* + * ase_lsp_lockobj and ase_lsp_deepunlockobj are just called by ase_lsp_read. + */ +void ase_lsp_lockobj (ase_lsp_t* lsp, ase_lsp_obj_t* obj) +{ + ASE_ASSERTX (obj != ASE_NULL, + "an object pointer should not be ASE_NULL"); + if (ASE_LSP_PERM(obj) == 0) ASE_LSP_LOCK(obj)++; +} + +void ase_lsp_unlockobj (ase_lsp_t* lsp, ase_lsp_obj_t* obj) +{ + ASE_ASSERTX (obj != ASE_NULL, + "an object pointer should not be ASE_NULL"); + + if (ASE_LSP_PERM(obj) != 0) return; + ASE_ASSERTX (ASE_LSP_LOCK(obj) > 0, + "the lock count should be greater than zero to be unlocked"); + + ASE_LSP_LOCK(obj)--; +} + +void ase_lsp_deepunlockobj (ase_lsp_t* lsp, ase_lsp_obj_t* obj) +{ + ASE_ASSERTX (obj != ASE_NULL, + "an object pointer should not be ASE_NULL"); + + if (ASE_LSP_PERM(obj) == 0) + { + ASE_ASSERTX (ASE_LSP_LOCK(obj) > 0, + "the lock count should be greater than zero to be unlocked"); + ASE_LSP_LOCK(obj)--; + } + + if (ASE_LSP_TYPE(obj) == ASE_LSP_OBJ_CONS) + { + ase_lsp_deepunlockobj (lsp, ASE_LSP_CAR(obj)); + ase_lsp_deepunlockobj (lsp, ASE_LSP_CDR(obj)); + } + else if (ASE_LSP_TYPE(obj) == ASE_LSP_OBJ_FUNC) + { + ase_lsp_deepunlockobj (lsp, ASE_LSP_FFORMAL(obj)); + ase_lsp_deepunlockobj (lsp, ASE_LSP_FBODY(obj)); + } + else if (ASE_LSP_TYPE(obj) == ASE_LSP_OBJ_MACRO) + { + ase_lsp_deepunlockobj (lsp, ASE_LSP_MFORMAL(obj)); + ase_lsp_deepunlockobj (lsp, ASE_LSP_MBODY(obj)); + } +} + +static void __mark_objs_in_use (ase_lsp_mem_t* mem) +{ + ase_lsp_frame_t* frame; + ase_lsp_assoc_t* assoc; + ase_lsp_tlink_t* tlink; + /*ase_lsp_arr_t* arr;*/ + /*ase_size_t i;*/ + +#if 0 + ase_dprint0 (ASE_T("marking environment frames\n")); +#endif + /* mark objects in the environment frames */ + frame = mem->frame; + while (frame != ASE_NULL) + { + assoc = frame->assoc; + while (assoc != ASE_NULL) + { + __mark_obj (mem->lsp, assoc->name); + + if (assoc->value != ASE_NULL) + __mark_obj (mem->lsp, assoc->value); + if (assoc->func != ASE_NULL) + __mark_obj (mem->lsp, assoc->func); + + assoc = assoc->link; + } + + frame = frame->link; + } + +#if 0 + ase_dprint0 (ASE_T("marking interim frames\n")); +#endif + + /* mark objects in the interim frames */ + frame = mem->brooding_frame; + while (frame != ASE_NULL) + { + assoc = frame->assoc; + while (assoc != ASE_NULL) + { + __mark_obj (mem->lsp, assoc->name); + + if (assoc->value != ASE_NULL) + __mark_obj (mem->lsp, assoc->value); + if (assoc->func != ASE_NULL) + __mark_obj (mem->lsp, assoc->func); + + assoc = assoc->link; + } + + frame = frame->link; + } + + /* ase_dprint0 (ASE_T("marking the read object\n"));*/ + if (mem->read != ASE_NULL) __mark_obj (mem->lsp, mem->read); + + /* ase_dprint0 (ASE_T("marking the temporary objects\n"));*/ + for (tlink = mem->tlink; tlink != ASE_NULL; tlink = tlink->link) + { + __mark_obj (mem->lsp, tlink->obj); + } + +#if 0 + ase_dprint0 (ASE_T("marking builtin objects\n")); +#endif + /* mark common objects */ + if (mem->t != ASE_NULL) __mark_obj (mem->lsp, mem->t); + if (mem->nil != ASE_NULL) __mark_obj (mem->lsp, mem->nil); + if (mem->quote != ASE_NULL) __mark_obj (mem->lsp, mem->quote); + if (mem->lambda != ASE_NULL) __mark_obj (mem->lsp, mem->lambda); + if (mem->macro != ASE_NULL) __mark_obj (mem->lsp, mem->macro); +} + +//#include +static void __sweep_unmarked_objs (ase_lsp_mem_t* mem) +{ + ase_lsp_obj_t* obj, * prev, * next; + ase_size_t i; + + /* scan all the allocated objects and get rid of unused objects */ + for (i = 0; i < ASE_LSP_TYPE_COUNT; i++) + { + prev = ASE_NULL; + obj = mem->used[i]; + +#if 0 + ase_dprint1 (ASE_T("sweeping objects of type: %u\n"), i); +#endif + while (obj != ASE_NULL) + { + next = ASE_LSP_LINK(obj); + + if (ASE_LSP_LOCK(obj) == 0 && + ASE_LSP_MARK(obj) == 0 && + ASE_LSP_PERM(obj) == 0) + { + /* dispose of unused objects */ +/* +if (i == ASE_LSP_OBJ_INT) +ase_printf (ASE_T("disposing....%d [%d]\n"), i, (int)ASE_LSP_IVAL(obj)); +if (i == ASE_LSP_OBJ_REAL) +ase_printf (ASE_T("disposing....%d [%Lf]\n"), i, (double)ASE_LSP_RVAL(obj)); +else if (i == ASE_LSP_OBJ_SYM) +ase_printf (ASE_T("disposing....%d [%s]\n"), i, ASE_LSP_SYMPTR(obj)); +else if (i == ASE_LSP_OBJ_STR) +ase_printf (ASE_T("disposing....%d [%s]\n"), i, ASE_LSP_STRPTR(obj)); +else +ase_printf (ASE_T("disposing....%d\n"), i); +*/ + ase_lsp_dispose (mem, prev, obj); + } + else + { + /* unmark the object in use */ + ASE_LSP_MARK(obj) = 0; + prev = obj; + } + + obj = next; + } + } +} + +void ase_lsp_gc (ase_lsp_mem_t* mem) +{ + __mark_objs_in_use (mem); + __sweep_unmarked_objs (mem); +} + +ase_lsp_obj_t* ase_lsp_makenil (ase_lsp_mem_t* mem) +{ + if (mem->nil != ASE_NULL) return mem->nil; + mem->nil = ase_lsp_alloc ( + mem, ASE_LSP_OBJ_NIL, ASE_SIZEOF(ase_lsp_obj_nil_t)); + return mem->nil; +} + +ase_lsp_obj_t* ase_lsp_maketrue (ase_lsp_mem_t* mem) +{ + if (mem->t != ASE_NULL) return mem->t; + mem->t = ase_lsp_alloc ( + mem, ASE_LSP_OBJ_TRUE, ASE_SIZEOF(ase_lsp_obj_true_t)); + return mem->t; +} + +ase_lsp_obj_t* ase_lsp_makeintobj (ase_lsp_mem_t* mem, ase_long_t value) +{ + ase_lsp_obj_t* obj; + + obj = ase_lsp_alloc (mem, + ASE_LSP_OBJ_INT, ASE_SIZEOF(ase_lsp_obj_int_t)); + if (obj == ASE_NULL) return ASE_NULL; + + ASE_LSP_IVAL(obj) = value; + + return obj; +} + +ase_lsp_obj_t* ase_lsp_makerealobj (ase_lsp_mem_t* mem, ase_real_t value) +{ + ase_lsp_obj_t* obj; + + obj = ase_lsp_alloc (mem, + ASE_LSP_OBJ_REAL, ASE_SIZEOF(ase_lsp_obj_real_t)); + if (obj == ASE_NULL) return ASE_NULL; + + ASE_LSP_RVAL(obj) = value; + + return obj; +} + +ase_lsp_obj_t* ase_lsp_makesym ( + ase_lsp_mem_t* mem, const ase_char_t* str, ase_size_t len) +{ + ase_lsp_obj_t* obj; + + /* look for a sysmbol with the given name */ + obj = mem->used[ASE_LSP_OBJ_SYM]; + while (obj != ASE_NULL) + { + /* if there is a symbol with the same name, it is just used. */ + if (ase_strxncmp ( + ASE_LSP_SYMPTR(obj), + ASE_LSP_SYMLEN(obj), + str, len) == 0) return obj; + obj = ASE_LSP_LINK(obj); + } + + /* no such symbol found. create a new one */ + obj = ase_lsp_alloc (mem, ASE_LSP_OBJ_SYM, + ASE_SIZEOF(ase_lsp_obj_sym_t)+(len + 1)*ASE_SIZEOF(ase_char_t)); + if (obj == ASE_NULL) return ASE_NULL; + + /* fill in the symbol buffer */ + ase_strncpy (ASE_LSP_SYMPTR(obj), str, len); + + return obj; +} + +ase_lsp_obj_t* ase_lsp_makestr ( + ase_lsp_mem_t* mem, const ase_char_t* str, ase_size_t len) +{ + ase_lsp_obj_t* obj; + + /* allocate memory for the string */ + obj = ase_lsp_alloc (mem, ASE_LSP_OBJ_STR, + ASE_SIZEOF(ase_lsp_obj_str_t)+(len + 1)*ASE_SIZEOF(ase_char_t)); + if (obj == ASE_NULL) return ASE_NULL; + + /* fill in the string buffer */ + ase_strncpy (ASE_LSP_STRPTR(obj), str, len); + + return obj; +} + +ase_lsp_obj_t* ase_lsp_makecons ( + ase_lsp_mem_t* mem, ase_lsp_obj_t* car, ase_lsp_obj_t* cdr) +{ + ase_lsp_obj_t* obj; + + obj = ase_lsp_alloc (mem, + ASE_LSP_OBJ_CONS, ASE_SIZEOF(ase_lsp_obj_cons_t)); + if (obj == ASE_NULL) return ASE_NULL; + + ASE_LSP_CAR(obj) = car; + ASE_LSP_CDR(obj) = cdr; + + return obj; +} + +ase_lsp_obj_t* ase_lsp_makefunc ( + ase_lsp_mem_t* mem, ase_lsp_obj_t* formal, ase_lsp_obj_t* body) +{ + ase_lsp_obj_t* obj; + + obj = ase_lsp_alloc (mem, + ASE_LSP_OBJ_FUNC, ASE_SIZEOF(ase_lsp_obj_func_t)); + if (obj == ASE_NULL) return ASE_NULL; + + ASE_LSP_FFORMAL(obj) = formal; + ASE_LSP_FBODY(obj) = body; + + return obj; +} + +ase_lsp_obj_t* ase_lsp_makemacro ( + ase_lsp_mem_t* mem, ase_lsp_obj_t* formal, ase_lsp_obj_t* body) +{ + ase_lsp_obj_t* obj; + + obj = ase_lsp_alloc (mem, + ASE_LSP_OBJ_MACRO, ASE_SIZEOF(ase_lsp_obj_macro_t)); + if (obj == ASE_NULL) return ASE_NULL; + + ASE_LSP_MFORMAL(obj) = formal; + ASE_LSP_MBODY(obj) = body; + + return obj; +} + +ase_lsp_obj_t* ase_lsp_makeprim (ase_lsp_mem_t* mem, + ase_lsp_prim_t impl, ase_size_t min_args, ase_size_t max_args) +{ + ase_lsp_obj_t* obj; + + obj = ase_lsp_alloc ( + mem, ASE_LSP_OBJ_PRIM, ASE_SIZEOF(ase_lsp_obj_prim_t)); + if (obj == ASE_NULL) return ASE_NULL; + + ASE_LSP_PIMPL(obj) = impl; + ASE_LSP_PMINARGS(obj) = min_args; + ASE_LSP_PMAXARGS(obj) = max_args; + return obj; +} + +ase_lsp_assoc_t* ase_lsp_lookup (ase_lsp_mem_t* mem, ase_lsp_obj_t* name) +{ + ase_lsp_frame_t* frame; + ase_lsp_assoc_t* assoc; + + ASE_ASSERT (ASE_LSP_TYPE(name) == ASE_LSP_OBJ_SYM); + + frame = mem->frame; + + while (frame != ASE_NULL) + { + assoc = ase_lsp_lookupinframe (mem->lsp, frame, name); + if (assoc != ASE_NULL) return assoc; + frame = frame->link; + } + + return ASE_NULL; +} + +ase_lsp_assoc_t* ase_lsp_setvalue ( + ase_lsp_mem_t* mem, ase_lsp_obj_t* name, ase_lsp_obj_t* value) +{ + ase_lsp_assoc_t* assoc; + + assoc = ase_lsp_lookup (mem, name); + if (assoc == ASE_NULL) + { + assoc = ase_lsp_insvalueintoframe ( + mem->lsp, mem->root_frame, name, value); + if (assoc == ASE_NULL) return ASE_NULL; + } + else assoc->value = value; + + return assoc; +} + +ase_lsp_assoc_t* ase_lsp_setfunc ( + ase_lsp_mem_t* mem, ase_lsp_obj_t* name, ase_lsp_obj_t* func) +{ + ase_lsp_assoc_t* assoc; + + assoc = ase_lsp_lookup (mem, name); + if (assoc == ASE_NULL) + { + assoc = ase_lsp_insfuncintoframe ( + mem->lsp, mem->root_frame, name, func); + if (assoc == ASE_NULL) return ASE_NULL; + } + else assoc->func = func; + + return assoc; +} + +ase_size_t ase_lsp_conslen (ase_lsp_mem_t* mem, ase_lsp_obj_t* obj) +{ + ase_size_t count; + + ASE_ASSERT ( + obj == mem->nil || ASE_LSP_TYPE(obj) == ASE_LSP_OBJ_CONS); + + count = 0; + /*while (obj != mem->nil) {*/ + while (ASE_LSP_TYPE(obj) == ASE_LSP_OBJ_CONS) + { + count++; + obj = ASE_LSP_CDR(obj); + } + + return count; +} + + + diff --git a/ase/lsp/mem.h b/ase/lsp/mem.h new file mode 100644 index 00000000..be7f4731 --- /dev/null +++ b/ase/lsp/mem.h @@ -0,0 +1,99 @@ +/* + * $Id: mem.h,v 1.3 2007/04/30 06:09:46 bacon Exp $ + * + * {License} + */ + +#ifndef _ASE_LSP_MEM_H_ +#define _ASE_LSP_MEM_H_ + +#ifndef _ASE_LSP_LSP_H_ +#error Never include this file directly. Include instead +#endif + +typedef struct ase_lsp_mem_t ase_lsp_mem_t; + +struct ase_lsp_mem_t +{ + ase_lsp_t* lsp; + + /* object allocation list */ + ase_size_t ubound; /* upper bounds of the maximum number of objects */ + ase_size_t ubound_inc; /* increment of the upper bounds */ + ase_size_t count; /* the number of objects currently allocated */ + ase_lsp_obj_t* used[ASE_LSP_TYPE_COUNT]; + ase_lsp_obj_t* free[ASE_LSP_TYPE_COUNT]; + ase_lsp_obj_t* read; + + /* commonly accessed objects */ + ase_lsp_obj_t* nil; /* ase_lsp_obj_nil_t */ + ase_lsp_obj_t* t; /* ase_lsp_obj_true_t */ + ase_lsp_obj_t* quote; /* ase_lsp_obj_sym_t */ + ase_lsp_obj_t* lambda; /* ase_lsp_obj_sym_t */ + ase_lsp_obj_t* macro; /* ase_lsp_obj_sym_t */ + + /* run-time environment frame */ + ase_lsp_frame_t* frame; + /* pointer to a global-level frame */ + ase_lsp_frame_t* root_frame; + /* pointer to an interim frame not yet added to "frame" */ + ase_lsp_frame_t* brooding_frame; + + /* links for temporary objects */ + ase_lsp_tlink_t* tlink; + ase_size_t tlink_count; +}; + +#ifdef __cplusplus +extern "C" { +#endif + +ase_lsp_mem_t* ase_lsp_openmem ( + ase_lsp_t* lsp, ase_size_t ubound, ase_size_t ubound_inc); +void ase_lsp_closemem (ase_lsp_mem_t* mem); + +ase_lsp_obj_t* ase_lsp_alloc (ase_lsp_mem_t* mem, int type, ase_size_t size); +void ase_lsp_dispose (ase_lsp_mem_t* mem, ase_lsp_obj_t* prev, ase_lsp_obj_t* obj); +void ase_lsp_dispose_all (ase_lsp_mem_t* mem); +void ase_lsp_gc (ase_lsp_mem_t* mem); + +void ase_lsp_lockobj (ase_lsp_t* lsp, ase_lsp_obj_t* obj); +void ase_lsp_unlockobj (ase_lsp_t* lsp, ase_lsp_obj_t* obj); +void ase_lsp_deepunlockobj (ase_lsp_t* lsp, ase_lsp_obj_t* obj); + +/* object creation of standard types */ +ase_lsp_obj_t* ase_lsp_makenil (ase_lsp_mem_t* mem); +ase_lsp_obj_t* ase_lsp_maketrue (ase_lsp_mem_t* mem); +ase_lsp_obj_t* ase_lsp_makeintobj (ase_lsp_mem_t* mem, ase_long_t value); +ase_lsp_obj_t* ase_lsp_makerealobj (ase_lsp_mem_t* mem, ase_real_t value); + +ase_lsp_obj_t* ase_lsp_makesym ( + ase_lsp_mem_t* mem, const ase_char_t* str, ase_size_t len); +ase_lsp_obj_t* ase_lsp_makestr ( + ase_lsp_mem_t* mem, const ase_char_t* str, ase_size_t len); + +ase_lsp_obj_t* ase_lsp_makecons ( + ase_lsp_mem_t* mem, ase_lsp_obj_t* car, ase_lsp_obj_t* cdr); +ase_lsp_obj_t* ase_lsp_makefunc ( + ase_lsp_mem_t* mem, ase_lsp_obj_t* formal, ase_lsp_obj_t* body); +ase_lsp_obj_t* ase_lsp_makemacro ( + ase_lsp_mem_t* mem, ase_lsp_obj_t* formal, ase_lsp_obj_t* body); + +ase_lsp_obj_t* ase_lsp_makeprim (ase_lsp_mem_t* mem, + ase_lsp_prim_t impl, ase_size_t min_args, ase_size_t max_args); + +/* frame lookup */ +ase_lsp_assoc_t* ase_lsp_lookup (ase_lsp_mem_t* mem, ase_lsp_obj_t* name); +ase_lsp_assoc_t* ase_lsp_setvalue ( + ase_lsp_mem_t* mem, ase_lsp_obj_t* name, ase_lsp_obj_t* value); +ase_lsp_assoc_t* ase_lsp_setfunc ( + ase_lsp_mem_t* mem, ase_lsp_obj_t* name, ase_lsp_obj_t* func); + +/* cons operations */ +ase_size_t ase_lsp_conslen (ase_lsp_mem_t* mem, ase_lsp_obj_t* obj); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ase/lsp/misc.c b/ase/lsp/misc.c new file mode 100644 index 00000000..9391f54f --- /dev/null +++ b/ase/lsp/misc.c @@ -0,0 +1,575 @@ +/* + * $Id: misc.c,v 1.3 2007/04/30 06:09:46 bacon Exp $ + * + * {License} + */ + +#include + +ase_long_t ase_lsp_strxtolong ( + ase_lsp_t* lsp, const ase_char_t* str, ase_size_t len, + int base, const ase_char_t** endptr) +{ + ase_long_t n = 0; + const ase_char_t* p; + const ase_char_t* end; + ase_size_t rem; + int digit, negative = 0; + + ASE_ASSERT (base < 37); + + p = str; + end = str + len; + + /* strip off leading spaces */ + /*while (ASE_LSP_ISSPACE(lsp,*p)) p++;*/ + + /* check for a sign */ + /*while (*p != ASE_T('\0')) */ + while (p < end) + { + if (*p == ASE_T('-')) + { + negative = ~negative; + p++; + } + else if (*p == ASE_T('+')) p++; + else break; + } + + /* check for a binary/octal/hexadecimal notation */ + rem = end - p; + if (base == 0) + { + if (rem >= 1 && *p == ASE_T('0')) + { + p++; + + if (rem == 1) base = 8; + else if (*p == ASE_T('x') || *p == ASE_T('X')) + { + p++; base = 16; + } + else if (*p == ASE_T('b') || *p == ASE_T('B')) + { + p++; base = 2; + } + else base = 8; + } + else base = 10; + } + else if (rem >= 2 && base == 16) + { + if (*p == ASE_T('0') && + (*(p+1) == ASE_T('x') || *(p+1) == ASE_T('X'))) p += 2; + } + else if (rem >= 2 && base == 2) + { + if (*p == ASE_T('0') && + (*(p+1) == ASE_T('b') || *(p+1) == ASE_T('B'))) p += 2; + } + + /* process the digits */ + /*while (*p != ASE_T('\0'))*/ + while (p < end) + { + if (*p >= ASE_T('0') && *p <= ASE_T('9')) + digit = *p - ASE_T('0'); + else if (*p >= ASE_T('A') && *p <= ASE_T('Z')) + digit = *p - ASE_T('A') + 10; + else if (*p >= ASE_T('a') && *p <= ASE_T('z')) + digit = *p - ASE_T('a') + 10; + else break; + + if (digit >= base) break; + n = n * base + digit; + + p++; + } + + if (endptr != ASE_NULL) *endptr = p; + return (negative)? -n: n; +} + + +/* + * ase_lsp_strtoreal is almost a replica of strtod. + * + * strtod.c -- + * + * Source code for the "strtod" library procedure. + * + * Copyright (c) 1988-1993 The Regents of the University of California. + * Copyright (c) 1994 Sun Microsystems, Inc. + * + * Permission to use, copy, modify, and distribute this + * software and its documentation for any purpose and without + * fee is hereby granted, provided that the above copyright + * notice appear in all copies. The University of California + * makes no representations about the suitability of this + * software for any purpose. It is provided "as is" without + * express or implied warranty. + */ + +#define MAX_EXPONENT 511 + +ase_real_t ase_lsp_strtoreal (ase_lsp_t* lsp, const ase_char_t* str) +{ + /* + * Table giving binary powers of 10. Entry is 10^2^i. + * Used to convert decimal exponents into floating-point numbers. + */ + static ase_real_t powers_of_10[] = + { + 10., 100., 1.0e4, 1.0e8, 1.0e16, + 1.0e32, 1.0e64, 1.0e128, 1.0e256 + }; + + ase_real_t fraction, dbl_exp, * d; + const ase_char_t* p; + ase_cint_t c; + int exp = 0; /* Esseonent read from "EX" field */ + + /* + * Esseonent that derives from the fractional part. Under normal + * circumstatnces, it is the negative of the number of digits in F. + * However, if I is very long, the last digits of I get dropped + * (otherwise a long I with a large negative exponent could cause an + * unnecessary overflow on I alone). In this case, frac_exp is + * incremented one for each dropped digit. + */ + + int frac_exp; + int mant_size; /* Number of digits in mantissa. */ + int dec_pt; /* Number of mantissa digits BEFORE decimal point */ + const ase_char_t *pexp; /* Temporarily holds location of exponent in string */ + int negative = 0, exp_negative = 0; + + p = str; + + /* strip off leading blanks */ + /*while (ASE_LSP_ISSPACE(lsp,*p)) p++;*/ + + /* check for a sign */ + while (*p != ASE_T('\0')) + { + if (*p == ASE_T('-')) + { + negative = ~negative; + p++; + } + else if (*p == ASE_T('+')) p++; + else break; + } + + /* Count the number of digits in the mantissa (including the decimal + * point), and also locate the decimal point. */ + dec_pt = -1; + for (mant_size = 0; ; mant_size++) + { + c = *p; + if (!ASE_LSP_ISDIGIT (lsp, c)) + { + if ((c != ASE_T('.')) || (dec_pt >= 0)) break; + dec_pt = mant_size; + } + p++; + } + + /* + * Now suck up the digits in the mantissa. Use two integers to + * collect 9 digits each (this is faster than using floating-point). + * If the mantissa has more than 18 digits, ignore the extras, since + * they can't affect the value anyway. + */ + pexp = p; + p -= mant_size; + if (dec_pt < 0) + { + dec_pt = mant_size; + } + else + { + mant_size--; /* One of the digits was the point */ + } + + if (mant_size > 18) + { + frac_exp = dec_pt - 18; + mant_size = 18; + } + else + { + frac_exp = dec_pt - mant_size; + } + + if (mant_size == 0) + { + fraction = 0.0; + /*p = str;*/ + p = pexp; + goto done; + } + else + { + int frac1, frac2; + frac1 = 0; + for ( ; mant_size > 9; mant_size--) + { + c = *p; + p++; + if (c == ASE_T('.')) + { + c = *p; + p++; + } + frac1 = 10 * frac1 + (c - ASE_T('0')); + } + frac2 = 0; + for (; mant_size > 0; mant_size--) { + c = *p; + p++; + if (c == ASE_T('.')) + { + c = *p; + p++; + } + frac2 = 10*frac2 + (c - ASE_T('0')); + } + fraction = (1.0e9 * frac1) + frac2; + } + + /* Skim off the exponent */ + p = pexp; + if ((*p == ASE_T('E')) || (*p == ASE_T('e'))) + { + p++; + if (*p == ASE_T('-')) + { + exp_negative = 1; + p++; + } + else + { + if (*p == ASE_T('+')) p++; + exp_negative = 0; + } + if (!ASE_LSP_ISDIGIT (lsp, *p)) + { + /* p = pexp; */ + /* goto done; */ + goto no_exp; + } + while (ASE_LSP_ISDIGIT (lsp, *p)) + { + exp = exp * 10 + (*p - ASE_T('0')); + p++; + } + } + +no_exp: + if (exp_negative) exp = frac_exp - exp; + else exp = frac_exp + exp; + + /* + * Generate a floating-point number that represents the exponent. + * Do this by processing the exponent one bit at a time to combine + * many powers of 2 of 10. Then combine the exponent with the + * fraction. + */ + if (exp < 0) + { + exp_negative = 1; + exp = -exp; + } + else exp_negative = 0; + + if (exp > MAX_EXPONENT) exp = MAX_EXPONENT; + + dbl_exp = 1.0; + + for (d = powers_of_10; exp != 0; exp >>= 1, d++) + { + if (exp & 01) dbl_exp *= *d; + } + + if (exp_negative) fraction /= dbl_exp; + else fraction *= dbl_exp; + +done: + return (negative)? -fraction: fraction; +} + +ase_real_t ase_lsp_strxtoreal ( + ase_lsp_t* lsp, const ase_char_t* str, ase_size_t len, + const ase_char_t** endptr) +{ + /* + * Table giving binary powers of 10. Entry is 10^2^i. + * Used to convert decimal exponents into floating-point numbers. + */ + static ase_real_t powers_of_10[] = + { + 10., 100., 1.0e4, 1.0e8, 1.0e16, + 1.0e32, 1.0e64, 1.0e128, 1.0e256 + }; + + ase_real_t fraction, dbl_exp, * d; + const ase_char_t* p, * end; + ase_cint_t c; + int exp = 0; /* Esseonent read from "EX" field */ + + /* + * Esseonent that derives from the fractional part. Under normal + * circumstatnces, it is the negative of the number of digits in F. + * However, if I is very long, the last digits of I get dropped + * (otherwise a long I with a large negative exponent could cause an + * unnecessary overflow on I alone). In this case, frac_exp is + * incremented one for each dropped digit. + */ + + int frac_exp; + int mant_size; /* Number of digits in mantissa. */ + int dec_pt; /* Number of mantissa digits BEFORE decimal point */ + const ase_char_t *pexp; /* Temporarily holds location of exponent in string */ + int negative = 0, exp_negative = 0; + + p = str; + end = str + len; + + /* Strip off leading blanks and check for a sign */ + /*while (ASE_LSP_ISSPACE(lsp,*p)) p++;*/ + + /*while (*p != ASE_T('\0')) */ + while (p < end) + { + if (*p == ASE_T('-')) + { + negative = ~negative; + p++; + } + else if (*p == ASE_T('+')) p++; + else break; + } + + /* Count the number of digits in the mantissa (including the decimal + * point), and also locate the decimal point. */ + dec_pt = -1; + /*for (mant_size = 0; ; mant_size++) */ + for (mant_size = 0; p < end; mant_size++) + { + c = *p; + if (!ASE_LSP_ISDIGIT (lsp, c)) + { + if (c != ASE_T('.') || dec_pt >= 0) break; + dec_pt = mant_size; + } + p++; + } + + /* + * Now suck up the digits in the mantissa. Use two integers to + * collect 9 digits each (this is faster than using floating-point). + * If the mantissa has more than 18 digits, ignore the extras, since + * they can't affect the value anyway. + */ + pexp = p; + p -= mant_size; + if (dec_pt < 0) + { + dec_pt = mant_size; + } + else + { + mant_size--; /* One of the digits was the point */ + } + + if (mant_size > 18) /* TODO: is 18 correct for ase_real_t??? */ + { + frac_exp = dec_pt - 18; + mant_size = 18; + } + else + { + frac_exp = dec_pt - mant_size; + } + + if (mant_size == 0) + { + fraction = 0.0; + /*p = str;*/ + p = pexp; + goto done; + } + else + { + int frac1, frac2; + + frac1 = 0; + for ( ; mant_size > 9; mant_size--) + { + c = *p; + p++; + if (c == ASE_T('.')) + { + c = *p; + p++; + } + frac1 = 10 * frac1 + (c - ASE_T('0')); + } + + frac2 = 0; + for (; mant_size > 0; mant_size--) { + c = *p++; + if (c == ASE_T('.')) + { + c = *p; + p++; + } + frac2 = 10 * frac2 + (c - ASE_T('0')); + } + fraction = (1.0e9 * frac1) + frac2; + } + + /* Skim off the exponent */ + p = pexp; + if (p < end && (*p == ASE_T('E') || *p == ASE_T('e'))) + { + p++; + + if (p < end) + { + if (*p == ASE_T('-')) + { + exp_negative = 1; + p++; + } + else + { + if (*p == ASE_T('+')) p++; + exp_negative = 0; + } + } + else exp_negative = 0; + + if (!(p < end && ASE_LSP_ISDIGIT (lsp, *p))) + { + /*p = pexp;*/ + /*goto done;*/ + goto no_exp; + } + + while (p < end && ASE_LSP_ISDIGIT (lsp, *p)) + { + exp = exp * 10 + (*p - ASE_T('0')); + p++; + } + } + +no_exp: + if (exp_negative) exp = frac_exp - exp; + else exp = frac_exp + exp; + + /* + * Generate a floating-point number that represents the exponent. + * Do this by processing the exponent one bit at a time to combine + * many powers of 2 of 10. Then combine the exponent with the + * fraction. + */ + if (exp < 0) + { + exp_negative = 1; + exp = -exp; + } + else exp_negative = 0; + + if (exp > MAX_EXPONENT) exp = MAX_EXPONENT; + + dbl_exp = 1.0; + + for (d = powers_of_10; exp != 0; exp >>= 1, d++) + { + if (exp & 01) dbl_exp *= *d; + } + + if (exp_negative) fraction /= dbl_exp; + else fraction *= dbl_exp; + +done: + if (endptr != ASE_NULL) *endptr = p; + return (negative)? -fraction: fraction; +} + +ase_size_t ase_lsp_longtostr ( + ase_long_t value, int radix, const ase_char_t* prefix, + ase_char_t* buf, ase_size_t size) +{ + ase_long_t t, rem; + ase_size_t len, ret, i; + ase_size_t prefix_len; + + prefix_len = (prefix != ASE_NULL)? ase_strlen(prefix): 0; + + t = value; + if (t == 0) + { + /* zero */ + if (buf == ASE_NULL) return prefix_len + 1; + + if (size < prefix_len+1) + { + /* buffer too small */ + return (ase_size_t)-1; + } + + for (i = 0; i < prefix_len; i++) buf[i] = prefix[i]; + buf[prefix_len] = ASE_T('0'); + if (size > prefix_len+1) buf[prefix_len+1] = ASE_T('\0'); + return 1; + } + + /* non-zero values */ + len = prefix_len; + if (t < 0) { t = -t; len++; } + while (t > 0) { len++; t /= radix; } + + if (buf == ASE_NULL) + { + /* if buf is not given, return the number of bytes required */ + return len; + } + + if (size < len) return (ase_size_t)-1; /* buffer too small */ + if (size > len) buf[len] = ASE_T('\0'); + ret = len; + + t = value; + if (t < 0) t = -t; + + while (t > 0) + { + rem = t % radix; + if (rem >= 10) + buf[--len] = (ase_char_t)rem + ASE_T('a') - 10; + else + buf[--len] = (ase_char_t)rem + ASE_T('0'); + t /= radix; + } + + if (value < 0) + { + for (i = 1; i <= prefix_len; i++) + { + buf[i] = prefix[i-1]; + len--; + } + buf[--len] = ASE_T('-'); + } + else + { + for (i = 0; i < prefix_len; i++) buf[i] = prefix[i]; + } + + return ret; +} + diff --git a/ase/lsp/misc.h b/ase/lsp/misc.h new file mode 100644 index 00000000..1b8d23d2 --- /dev/null +++ b/ase/lsp/misc.h @@ -0,0 +1,26 @@ +/* + * $Id: misc.h,v 1.3 2007/04/30 06:09:46 bacon Exp $ + * + * {License} + */ + +#ifndef _ASE_LSP_MISC_H_ +#define _ASE_LSP_MISC_H_ + +#ifndef _ASE_LSP_LSP_H_ +#error Never include this file directly. Include instead +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +void* ase_lsp_memcpy (void* dst, const void* src, ase_size_t n); +void* ase_lsp_memset (void* dst, int val, ase_size_t n); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/ase/lsp/name.c b/ase/lsp/name.c new file mode 100644 index 00000000..c58a835a --- /dev/null +++ b/ase/lsp/name.c @@ -0,0 +1,125 @@ +/* + * $Id: name.c,v 1.3 2007/04/30 06:09:46 bacon Exp $ + * + * {License} + */ + +#include + +ase_lsp_name_t* ase_lsp_name_open ( + ase_lsp_name_t* name, ase_size_t capa, ase_lsp_t* lsp) +{ + if (capa == 0) capa = ASE_COUNTOF(name->static_buf) - 1; + + if (name == ASE_NULL) + { + name = (ase_lsp_name_t*) + ASE_LSP_MALLOC (lsp, ASE_SIZEOF(ase_lsp_name_t)); + if (name == ASE_NULL) return ASE_NULL; + name->__dynamic = ase_true; + } + else name->__dynamic = ase_false; + + if (capa < ASE_COUNTOF(name->static_buf)) + { + name->buf = name->static_buf; + } + else + { + name->buf = (ase_char_t*) + ASE_LSP_MALLOC (lsp, (capa+1)*ASE_SIZEOF(ase_char_t)); + if (name->buf == ASE_NULL) + { + if (name->__dynamic) ASE_LSP_FREE (lsp, name); + return ASE_NULL; + } + } + + name->size = 0; + name->capa = capa; + name->buf[0] = ASE_T('\0'); + name->lsp = lsp; + + return name; +} + +void ase_lsp_name_close (ase_lsp_name_t* name) +{ + if (name->capa >= ASE_COUNTOF(name->static_buf)) + { + ASE_ASSERT (name->buf != name->static_buf); + ASE_LSP_FREE (name->lsp, name->buf); + } + if (name->__dynamic) ASE_LSP_FREE (name->lsp, name); +} + +int ase_lsp_name_addc (ase_lsp_name_t* name, ase_cint_t c) +{ + if (name->size >= name->capa) + { + /* double the capacity */ + ase_size_t new_capa = name->capa * 2; + + if (new_capa >= ASE_COUNTOF(name->static_buf)) + { + ase_char_t* space; + + if (name->capa < ASE_COUNTOF(name->static_buf)) + { + space = (ase_char_t*) ASE_LSP_MALLOC ( + name->lsp, (new_capa+1)*ASE_SIZEOF(ase_char_t)); + if (space == ASE_NULL) return -1; + + /* don't need to copy up to the terminating null */ + ase_memcpy (space, name->buf, name->capa*ASE_SIZEOF(ase_char_t)); + } + else + { + space = (ase_char_t*) ASE_LSP_REALLOC ( + name->lsp, name->buf, + (new_capa+1)*ASE_SIZEOF(ase_char_t)); + if (space == ASE_NULL) return -1; + } + + name->buf = space; + } + + name->capa = new_capa; + } + + name->buf[name->size++] = c; + name->buf[name->size] = ASE_T('\0'); + return 0; +} + +int ase_lsp_name_adds (ase_lsp_name_t* name, const ase_char_t* s) +{ + while (*s != ASE_T('\0')) + { + if (ase_lsp_name_addc(name, *s) == -1) return -1; + s++; + } + + return 0; +} + +void ase_lsp_name_clear (ase_lsp_name_t* name) +{ + name->size = 0; + name->buf[0] = ASE_T('\0'); +} + +int ase_lsp_name_compare (ase_lsp_name_t* name, const ase_char_t* str) +{ + ase_char_t* p = name->buf; + ase_size_t index = 0; + + while (index < name->size) + { + if (*p > *str) return 1; + if (*p < *str) return -1; + index++; p++; str++; + } + + return (*str == ASE_T('\0'))? 0: -1; +} diff --git a/ase/lsp/name.h b/ase/lsp/name.h new file mode 100644 index 00000000..8d45e490 --- /dev/null +++ b/ase/lsp/name.h @@ -0,0 +1,42 @@ +/* + * $Id: name.h,v 1.3 2007/04/30 06:09:46 bacon Exp $ + * + * {License} + */ + +#ifndef _ASE_LSP_NAME_H_ +#define _ASE_LSP_NAME_H_ + +#include +#include + +struct ase_lsp_name_t +{ + ase_size_t capa; + ase_size_t size; + ase_char_t* buf; + ase_char_t static_buf[128]; + ase_lsp_t* lsp; + ase_bool_t __dynamic; +}; + +typedef struct ase_lsp_name_t ase_lsp_name_t; + +#ifdef __cplusplus +extern "C" { +#endif + +ase_lsp_name_t* ase_lsp_name_open ( + ase_lsp_name_t* name, ase_size_t capa, ase_lsp_t* lsp); +void ase_lsp_name_close (ase_lsp_name_t* name); + +int ase_lsp_name_addc (ase_lsp_name_t* name, ase_cint_t c); +int ase_lsp_name_adds (ase_lsp_name_t* name, const ase_char_t* s); +void ase_lsp_name_clear (ase_lsp_name_t* name); +int ase_lsp_name_compare (ase_lsp_name_t* name, const ase_char_t* str); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ase/lsp/obj.h b/ase/lsp/obj.h new file mode 100644 index 00000000..f9a14c7b --- /dev/null +++ b/ase/lsp/obj.h @@ -0,0 +1,161 @@ +/* + * $Id: obj.h,v 1.3 2007/04/30 06:09:46 bacon Exp $ + * + * {License} + */ + +#ifndef _ASE_LSP_OBJ_H_ +#define _ASE_LSP_OBJ_H_ + +#ifndef _ASE_LSP_LSP_H_ +#error Never include this file directly. Include instead +#endif + +/* object types */ +enum +{ + ASE_LSP_OBJ_NIL = 0, + ASE_LSP_OBJ_TRUE, + ASE_LSP_OBJ_INT, + ASE_LSP_OBJ_REAL, + ASE_LSP_OBJ_SYM, + ASE_LSP_OBJ_STR, + ASE_LSP_OBJ_CONS, + ASE_LSP_OBJ_FUNC, + ASE_LSP_OBJ_MACRO, + ASE_LSP_OBJ_PRIM, + + ASE_LSP_TYPE_COUNT /* the number of lsp object types */ +}; + +typedef struct ase_lsp_objhdr_t ase_lsp_objhdr_t; +typedef struct ase_lsp_obj_nil_t ase_lsp_obj_nil_t; +typedef struct ase_lsp_obj_true_t ase_lsp_obj_true_t; +typedef struct ase_lsp_obj_int_t ase_lsp_obj_int_t; +typedef struct ase_lsp_obj_real_t ase_lsp_obj_real_t; +typedef struct ase_lsp_obj_sym_t ase_lsp_obj_sym_t; +typedef struct ase_lsp_obj_str_t ase_lsp_obj_str_t; +typedef struct ase_lsp_obj_cons_t ase_lsp_obj_cons_t; +typedef struct ase_lsp_obj_func_t ase_lsp_obj_func_t; +typedef struct ase_lsp_obj_macro_t ase_lsp_obj_macro_t; +typedef struct ase_lsp_obj_prim_t ase_lsp_obj_prim_t; + +struct ase_lsp_objhdr_t +{ + ase_uint32_t type: 8; + ase_uint32_t mark: 4; + ase_uint32_t perm: 4; + ase_uint32_t lock: 16; + ase_size_t size; + ase_lsp_obj_t* link; +}; + +struct ase_lsp_obj_t +{ + ase_lsp_objhdr_t hdr; +}; + +struct ase_lsp_obj_nil_t +{ + ase_lsp_objhdr_t hdr; +}; + +struct ase_lsp_obj_true_t +{ + ase_lsp_objhdr_t hdr; +}; + +struct ase_lsp_obj_int_t +{ + ase_lsp_objhdr_t hdr; + ase_long_t value; +}; + +struct ase_lsp_obj_real_t +{ + ase_lsp_objhdr_t hdr; + ase_real_t value; +}; + +struct ase_lsp_obj_sym_t +{ + ase_lsp_objhdr_t hdr; +#if defined(__GNUC__) + ase_char_t buffer[0]; +#endif +}; + +struct ase_lsp_obj_str_t +{ + ase_lsp_objhdr_t hdr; +#if defined(__GNUC__) + ase_char_t buffer[0]; +#endif +}; + +struct ase_lsp_obj_cons_t +{ + ase_lsp_objhdr_t hdr; + ase_lsp_obj_t* car; + ase_lsp_obj_t* cdr; +}; + +struct ase_lsp_obj_func_t +{ + ase_lsp_objhdr_t hdr; + ase_lsp_obj_t* formal; + ase_lsp_obj_t* body; +}; + +struct ase_lsp_obj_macro_t +{ + ase_lsp_objhdr_t hdr; + ase_lsp_obj_t* formal; + ase_lsp_obj_t* body; +}; + +struct ase_lsp_obj_prim_t +{ + ase_lsp_objhdr_t hdr; + ase_lsp_prim_t impl; + ase_size_t min_args; + ase_size_t max_args; +}; + +/* header access */ +#define ASE_LSP_TYPE(x) (((ase_lsp_obj_t*)x)->hdr.type) +#define ASE_LSP_SIZE(x) (((ase_lsp_obj_t*)x)->hdr.size) +#define ASE_LSP_MARK(x) (((ase_lsp_obj_t*)x)->hdr.mark) +#define ASE_LSP_PERM(x) (((ase_lsp_obj_t*)x)->hdr.perm) +#define ASE_LSP_LOCK(x) (((ase_lsp_obj_t*)x)->hdr.lock) +#define ASE_LSP_LINK(x) (((ase_lsp_obj_t*)x)->hdr.link) + +/* value access */ +#define ASE_LSP_IVAL(x) (((ase_lsp_obj_int_t*)x)->value) +#define ASE_LSP_RVAL(x) (((ase_lsp_obj_real_t*)x)->value) + +#if defined(__GNUC__) + #define ASE_LSP_SYMPTR(x) (((ase_lsp_obj_sym_t*)x)->buffer) +#else + #define ASE_LSP_SYMPTR(x) ((ase_char_t*)(((ase_lsp_obj_sym_t*)x) + 1)) +#endif +#define ASE_LSP_SYMLEN(x) ((((ase_lsp_obj_sym_t*)x)->hdr.size - sizeof(ase_lsp_obj_t)) / sizeof(ase_char_t) - 1) + +#if defined(__GNUC__) + #define ASE_LSP_STRPTR(x) (((ase_lsp_obj_str_t*)x)->buffer) +#else + #define ASE_LSP_STRPTR(x) ((ase_char_t*)(((ase_lsp_obj_str_t*)x) + 1)) +#endif +#define ASE_LSP_STRLEN(x) ((((ase_lsp_obj_str_t*)x)->hdr.size - sizeof(ase_lsp_obj_t)) / sizeof(ase_char_t) - 1) + +#define ASE_LSP_CAR(x) (((ase_lsp_obj_cons_t*)x)->car) +#define ASE_LSP_CDR(x) (((ase_lsp_obj_cons_t*)x)->cdr) +#define ASE_LSP_FFORMAL(x) (((ase_lsp_obj_func_t*)x)->formal) +#define ASE_LSP_FBODY(x) (((ase_lsp_obj_func_t*)x)->body) +#define ASE_LSP_MFORMAL(x) (((ase_lsp_obj_macro_t*)x)->formal) +#define ASE_LSP_MBODY(x) (((ase_lsp_obj_macro_t*)x)->body) +#define ASE_LSP_PIMPL(x) (((ase_lsp_obj_prim_t*)x)->impl) +#define ASE_LSP_PMINARGS(x) (((ase_lsp_obj_prim_t*)x)->min_args) +#define ASE_LSP_PMAXARGS(x) (((ase_lsp_obj_prim_t*)x)->max_args) + +#endif diff --git a/ase/lsp/prim.c b/ase/lsp/prim.c new file mode 100644 index 00000000..5f83170d --- /dev/null +++ b/ase/lsp/prim.c @@ -0,0 +1,621 @@ +/* + * $Id: prim.c,v 1.3 2007/04/30 06:09:46 bacon Exp $ + * + * {License} + */ + +#include + +static int __add_prim (ase_lsp_mem_t* mem, + const ase_char_t* name, ase_size_t len, + ase_lsp_prim_t pimpl, ase_size_t min_args, ase_size_t max_args); + +int ase_lsp_addprim ( + ase_lsp_t* lsp, const ase_char_t* name, ase_size_t name_len, + ase_lsp_prim_t prim, ase_size_t min_args, ase_size_t max_args) +{ + return __add_prim (lsp->mem, name, name_len, prim, min_args, max_args); +} + +int ase_lsp_removeprim (ase_lsp_t* lsp, const ase_char_t* name) +{ + /* TODO: */ + return -1; +} + +static int __add_prim (ase_lsp_mem_t* mem, + const ase_char_t* name, ase_size_t name_len, + ase_lsp_prim_t pimpl, ase_size_t min_args, ase_size_t max_args) +{ + ase_lsp_obj_t* n, * p; + + n = ase_lsp_makesym (mem, name, name_len); + if (n == ASE_NULL) return -1; + + if (ase_lsp_pushtmp (mem->lsp, n) == ASE_NULL) return -1; + + p = ase_lsp_makeprim (mem, pimpl, min_args, max_args); + if (p == ASE_NULL) + { + ase_lsp_poptmp (mem->lsp); + return -1; + } + + if (ase_lsp_pushtmp (mem->lsp, p) == ASE_NULL) + { + ase_lsp_poptmp (mem->lsp); + return -1; + } + + if (ase_lsp_setfunc(mem, n, p) == ASE_NULL) + { + ase_lsp_poptmp (mem->lsp); + ase_lsp_poptmp (mem->lsp); + return -1; + } + + ase_lsp_poptmp (mem->lsp); + ase_lsp_poptmp (mem->lsp); + return 0; +} + +ase_lsp_obj_t* ase_lsp_prim_exit (ase_lsp_t* lsp, ase_lsp_obj_t* args) +{ + lsp->errnum = ASE_LSP_EEXIT; + return ASE_NULL; +} + +ase_lsp_obj_t* ase_lsp_prim_eval (ase_lsp_t* lsp, ase_lsp_obj_t* args) +{ + ase_lsp_obj_t* tmp1, * tmp2; + + ASE_ASSERT (ASE_LSP_TYPE(args) == ASE_LSP_OBJ_CONS); + + tmp1 = ase_lsp_eval (lsp, ASE_LSP_CAR(args)); + if (tmp1 == ASE_NULL) return ASE_NULL; + + if (ase_lsp_pushtmp (lsp, tmp1) == ASE_NULL) return ASE_NULL; + + tmp2 = ase_lsp_eval (lsp, tmp1); + if (tmp2 == ASE_NULL) + { + ase_lsp_poptmp (lsp); + return ASE_NULL; + } + + ase_lsp_poptmp (lsp); + return tmp2; +} + +ase_lsp_obj_t* ase_lsp_prim_gc (ase_lsp_t* lsp, ase_lsp_obj_t* args) +{ + ase_lsp_gc (lsp->mem); + return lsp->mem->nil; +} + +ase_lsp_obj_t* ase_lsp_prim_cond (ase_lsp_t* lsp, ase_lsp_obj_t* args) +{ + /* + * (cond + * (condition1 result1) + * (consition2 result2) + * ... + * (t resultN)) + */ + + ase_lsp_obj_t* tmp, * ret; + + while (ASE_LSP_TYPE(args) == ASE_LSP_OBJ_CONS) + { + if (ASE_LSP_TYPE(ASE_LSP_CAR(args)) != ASE_LSP_OBJ_CONS) + { + ase_lsp_seterror (lsp, ASE_LSP_EARGBAD, ASE_NULL, 0); + return ASE_NULL; + } + + tmp = ase_lsp_eval (lsp, ASE_LSP_CAR(ASE_LSP_CAR(args))); + if (tmp == ASE_NULL) return ASE_NULL; + + if (ase_lsp_pushtmp (lsp, tmp) == ASE_NULL) return ASE_NULL; + + if (tmp != lsp->mem->nil) + { + int f = 0; + + tmp = ASE_LSP_CDR(ASE_LSP_CAR(args)); + ret = lsp->mem->nil; + + while (ASE_LSP_TYPE(tmp) == ASE_LSP_OBJ_CONS) + { + ret = ase_lsp_eval (lsp, ASE_LSP_CAR(tmp)); + if (ret == ASE_NULL) + { + if (!f) ase_lsp_poptmp (lsp); /* ret */ + ase_lsp_poptmp (lsp); /* tmp */ + return ASE_NULL; + } + + if (!f) ase_lsp_poptmp (lsp); /* ret */ + if (ase_lsp_pushtmp (lsp, ret) == ASE_NULL) + { + ase_lsp_poptmp (lsp); /* tmp */ + return ASE_NULL; + } + + f = 1; + tmp = ASE_LSP_CDR(tmp); + } + if (tmp != lsp->mem->nil) + { + if (!f) ase_lsp_poptmp (lsp); /* ret */ + ase_lsp_poptmp (lsp); /* tmp */ + + ase_lsp_seterror (lsp, ASE_LSP_EARGBAD, ASE_NULL, 0); + return ASE_NULL; + } + + if (!f) ase_lsp_poptmp (lsp); /* ret */ + ase_lsp_poptmp (lsp); /* tmp */ + return ret; + } + + ase_lsp_poptmp (lsp); /* tmp */ + args = ASE_LSP_CDR(args); + } + + return lsp->mem->nil; +} + +ase_lsp_obj_t* ase_lsp_prim_if (ase_lsp_t* lsp, ase_lsp_obj_t* args) +{ + ase_lsp_obj_t* tmp; + + ASE_ASSERT (ASE_LSP_TYPE(args) == ASE_LSP_OBJ_CONS); + + tmp = ase_lsp_eval (lsp, ASE_LSP_CAR(args)); + if (tmp == ASE_NULL) return ASE_NULL; + + if (ase_lsp_pushtmp (lsp, tmp) == ASE_NULL) return ASE_NULL; + + if (tmp != lsp->mem->nil) + { + tmp = ase_lsp_eval (lsp, ASE_LSP_CAR(ASE_LSP_CDR(args))); + if (tmp == ASE_NULL) + { + ase_lsp_poptmp (lsp); /* tmp */ + return ASE_NULL; + } + + ase_lsp_poptmp (lsp); /* tmp */ + return tmp; + } + else + { + ase_lsp_obj_t* res = lsp->mem->nil; + int f = 0; + + tmp = ASE_LSP_CDR(ASE_LSP_CDR(args)); + + while (ASE_LSP_TYPE(tmp) == ASE_LSP_OBJ_CONS) + { + res = ase_lsp_eval (lsp, ASE_LSP_CAR(tmp)); + if (res == ASE_NULL) + { + if (!f) ase_lsp_poptmp (lsp); /* res */ + ase_lsp_poptmp (lsp); /* tmp */ + return ASE_NULL; + } + + if (!f) ase_lsp_poptmp (lsp); /* res */ + if (ase_lsp_pushtmp (lsp, res) == ASE_NULL) + { + ase_lsp_poptmp (lsp); /* tmp */ + return ASE_NULL; + } + + f = 1; + tmp = ASE_LSP_CDR(tmp); + } + + if (tmp != lsp->mem->nil) + { + if (!f) ase_lsp_poptmp (lsp); /* ret */ + ase_lsp_poptmp (lsp); /* tmp */ + + ase_lsp_seterror (lsp, ASE_LSP_EARGBAD, ASE_NULL, 0); + return ASE_NULL; + } + + if (!f) ase_lsp_poptmp (lsp); /* ret */ + ase_lsp_poptmp (lsp); /* tmp */ + return res; + } +} + +ase_lsp_obj_t* ase_lsp_prim_while (ase_lsp_t* lsp, ase_lsp_obj_t* args) +{ + /* + * (setq a 1) + * (while (< a 100) (setq a (+ a 1))) + */ + + ase_lsp_obj_t* tmp; + + ASE_ASSERT (ASE_LSP_TYPE(args) == ASE_LSP_OBJ_CONS); + + while (1) + { + tmp = ase_lsp_eval (lsp, ASE_LSP_CAR(args)); + if (tmp == ASE_NULL) return ASE_NULL; + if (tmp == lsp->mem->nil) break; + + if (ase_lsp_pushtmp (lsp, tmp) == ASE_NULL) return ASE_NULL; + + tmp = ASE_LSP_CDR(args); + while (ASE_LSP_TYPE(tmp) == ASE_LSP_OBJ_CONS) + { + if (ase_lsp_eval(lsp, ASE_LSP_CAR(tmp)) == ASE_NULL) + { + ase_lsp_poptmp (lsp); /* tmp */ + return ASE_NULL; + } + + tmp = ASE_LSP_CDR(tmp); + } + + if (tmp != lsp->mem->nil) + { + ase_lsp_poptmp (lsp); /* tmp */ + + ase_lsp_seterror (lsp, ASE_LSP_EARGBAD, ASE_NULL, 0); + return ASE_NULL; + } + + ase_lsp_poptmp (lsp); /* tmp */ + } + + return lsp->mem->nil; +} + +ase_lsp_obj_t* ase_lsp_prim_car (ase_lsp_t* lsp, ase_lsp_obj_t* args) +{ + /* + * (car '(10 20 30)) + */ + + ase_lsp_obj_t* tmp; + + ASE_ASSERT (ASE_LSP_TYPE(args) == ASE_LSP_OBJ_CONS); + + tmp = ase_lsp_eval (lsp, ASE_LSP_CAR(args)); + if (tmp == ASE_NULL) return ASE_NULL; + if (tmp == lsp->mem->nil) return lsp->mem->nil; + + if (ASE_LSP_TYPE(tmp) != ASE_LSP_OBJ_CONS) + { + ase_lsp_seterror (lsp, ASE_LSP_EARGBAD, ASE_NULL, 0); + return ASE_NULL; + } + + return ASE_LSP_CAR(tmp); +} + +ase_lsp_obj_t* ase_lsp_prim_cdr (ase_lsp_t* lsp, ase_lsp_obj_t* args) +{ + /* + * (cdr '(10 20 30)) + */ + + ase_lsp_obj_t* tmp; + + ASE_ASSERT (ASE_LSP_TYPE(args) == ASE_LSP_OBJ_CONS); + + tmp = ase_lsp_eval (lsp, ASE_LSP_CAR(args)); + if (tmp == ASE_NULL) return ASE_NULL; + if (tmp == lsp->mem->nil) return lsp->mem->nil; + + if (ASE_LSP_TYPE(tmp) != ASE_LSP_OBJ_CONS) + { + ase_lsp_seterror (lsp, ASE_LSP_EARGBAD, ASE_NULL, 0); + return ASE_NULL; + } + + return ASE_LSP_CDR(tmp); +} + +ase_lsp_obj_t* ase_lsp_prim_cons (ase_lsp_t* lsp, ase_lsp_obj_t* args) +{ + /* + * (cons 10 20) + * (cons '(10 20) 30) + */ + + ase_lsp_obj_t* car, * cdr, * cons; + + ASE_ASSERT (ASE_LSP_TYPE(args) == ASE_LSP_OBJ_CONS); + + car = ase_lsp_eval (lsp, ASE_LSP_CAR(args)); + if (car == ASE_NULL) return ASE_NULL; + + if (ase_lsp_pushtmp (lsp, car) == ASE_NULL) return ASE_NULL; + + cdr = ase_lsp_eval (lsp, ASE_LSP_CAR(ASE_LSP_CDR(args))); + if (cdr == ASE_NULL) + { + ase_lsp_poptmp (lsp); /* car */ + return ASE_NULL; + } + + if (ase_lsp_pushtmp (lsp, cdr) == ASE_NULL) + { + ase_lsp_poptmp (lsp); /* car */ + return ASE_NULL; + } + + cons = ase_lsp_makecons (lsp->mem, car, cdr); + if (cons == ASE_NULL) + { + ase_lsp_poptmp (lsp); /* cdr */ + ase_lsp_poptmp (lsp); /* car */ + return ASE_NULL; + } + + ase_lsp_poptmp (lsp); /* cdr */ + ase_lsp_poptmp (lsp); /* car */ + return cons; +} + +ase_lsp_obj_t* ase_lsp_prim_length (ase_lsp_t* lsp, ase_lsp_obj_t* args) +{ + ase_lsp_obj_t* body, * tmp; + ase_long_t len = 0; + + ASE_ASSERT (ASE_LSP_TYPE(args) == ASE_LSP_OBJ_CONS); + + body = args; + while (ASE_LSP_TYPE(body) == ASE_LSP_OBJ_CONS) + { + tmp = ase_lsp_eval (lsp, ASE_LSP_CAR(body)); + if (tmp == ASE_NULL) return ASE_NULL; + + if (ASE_LSP_TYPE(tmp) == ASE_LSP_OBJ_NIL) + { + len = 0; + } + else if (ASE_LSP_TYPE(tmp) == ASE_LSP_OBJ_STR) + { + len = ASE_LSP_STRLEN(tmp); + } + else if (ASE_LSP_TYPE(tmp) == ASE_LSP_OBJ_SYM) + { + len = ASE_LSP_SYMLEN(tmp); + } + else if (ASE_LSP_TYPE(tmp) == ASE_LSP_OBJ_CONS) + { + len = 0; + do + { + len++; + tmp = ASE_LSP_CDR(tmp); + } + while (ASE_LSP_TYPE(tmp) == ASE_LSP_OBJ_CONS); + + /* TODO: more flexible without the check below? + * both of the following expression evalute + * to 3 without it. + * (length '(9 9 9 . 9)) + * (length '(9 9 9)) + */ + if (ASE_LSP_TYPE(tmp) != ASE_LSP_OBJ_NIL) + { + ase_lsp_seterror (lsp, ASE_LSP_EVALBAD, ASE_NULL, 0); + return ASE_NULL; + } + } + else + { + ase_lsp_seterror (lsp, ASE_LSP_EVALBAD, ASE_NULL, 0); + return ASE_NULL; + } + + body = ASE_LSP_CDR(body); + } + + ASE_ASSERT (body == lsp->mem->nil); + return ase_lsp_makeintobj (lsp->mem, len); +} + +ase_lsp_obj_t* ase_lsp_prim_set (ase_lsp_t* lsp, ase_lsp_obj_t* args) +{ + /* + * (set 'flowers 'rose) + * (set flowers 20) + * rose + */ + + ase_lsp_obj_t* p1, * p2; + + ASE_ASSERT (ASE_LSP_TYPE(args) == ASE_LSP_OBJ_CONS); + + p1 = ase_lsp_eval (lsp, ASE_LSP_CAR(args)); + if (p1 == ASE_NULL) return ASE_NULL; + + if (ase_lsp_pushtmp (lsp, p1) == ASE_NULL) return ASE_NULL; + + if (ASE_LSP_TYPE(p1) != ASE_LSP_OBJ_SYM) + { + ase_lsp_poptmp (lsp); /* p1 */ + + ase_lsp_seterror (lsp, ASE_LSP_EARGBAD, ASE_NULL, 0); + return ASE_NULL; + } + + p2 = ase_lsp_eval (lsp, ASE_LSP_CAR(ASE_LSP_CDR(args))); + if (p2 == ASE_NULL) + { + ase_lsp_poptmp (lsp); /* p1 */ + return ASE_NULL; + } + + if (ase_lsp_pushtmp (lsp, p2) == ASE_NULL) + { + ase_lsp_poptmp (lsp); /* p1 */ + return ASE_NULL; + } + + if (ase_lsp_setvalue (lsp->mem, p1, p2) == ASE_NULL) + { + ase_lsp_poptmp (lsp); /* p2 */ + ase_lsp_poptmp (lsp); /* p1 */ + return ASE_NULL; + } + + ase_lsp_poptmp (lsp); /* p2 */ + ase_lsp_poptmp (lsp); /* p1 */ + return p2; +} + +ase_lsp_obj_t* ase_lsp_prim_setq (ase_lsp_t* lsp, ase_lsp_obj_t* args) +{ + /* + * (setq x 10) + * (setq x "string") + */ + + ase_lsp_obj_t* p = args, * p1, * p2 = lsp->mem->nil; + + while (p != lsp->mem->nil) + { + ASE_ASSERT (ASE_LSP_TYPE(p) == ASE_LSP_OBJ_CONS); + + p1 = ASE_LSP_CAR(p); + if (ASE_LSP_TYPE(p1) != ASE_LSP_OBJ_SYM) + { + ase_lsp_seterror (lsp, ASE_LSP_EARGBAD, ASE_NULL, 0); + return ASE_NULL; + } + + if (ASE_LSP_TYPE(ASE_LSP_CDR(p)) != ASE_LSP_OBJ_CONS) + { + lsp->errnum = ASE_LSP_EARGFEW; + return ASE_NULL; + } + + p2 = ase_lsp_eval (lsp, ASE_LSP_CAR(ASE_LSP_CDR(p))); + if (p2 == ASE_NULL) return ASE_NULL; + + if (ase_lsp_pushtmp (lsp, p2) == ASE_NULL) return ASE_NULL; + + if (ase_lsp_setvalue (lsp->mem, p1, p2) == ASE_NULL) + { + ase_lsp_poptmp (lsp); + return ASE_NULL; + } + + ase_lsp_poptmp (lsp); + p = ASE_LSP_CDR(ASE_LSP_CDR(p)); + } + + return p2; +} + +ase_lsp_obj_t* ase_lsp_prim_quote (ase_lsp_t* lsp, ase_lsp_obj_t* args) +{ + /* + * (quote (10 20 30 50)) + */ + + ASE_ASSERT (ASE_LSP_TYPE(args) == ASE_LSP_OBJ_CONS); + return ASE_LSP_CAR(args); +} + +ase_lsp_obj_t* ase_lsp_prim_defun (ase_lsp_t* lsp, ase_lsp_obj_t* args) +{ + /* + * (defun x (a b) (+ a b 100)) + * (x 40 50) + * + * (setq x (lambda (x y) (setq temp 10) (+ x y temp))) + * (x 40 50) + * temp + */ + + ase_lsp_obj_t* name, * fun; + + name = ASE_LSP_CAR(args); + if (ASE_LSP_TYPE(name) != ASE_LSP_OBJ_SYM) + { + ase_lsp_seterror (lsp, ASE_LSP_EARGBAD, ASE_NULL, 0); + return ASE_NULL; + } + + fun = ase_lsp_makefunc (lsp->mem, + ASE_LSP_CAR(ASE_LSP_CDR(args)), ASE_LSP_CDR(ASE_LSP_CDR(args))); + if (fun == ASE_NULL) return ASE_NULL; + + if (ase_lsp_pushtmp (lsp, fun) == ASE_NULL) return ASE_NULL; + + if (ase_lsp_setfunc (lsp->mem, ASE_LSP_CAR(args), fun) == ASE_NULL) + { + ase_lsp_poptmp (lsp); + return ASE_NULL; + } + + ase_lsp_poptmp (lsp); + return fun; +} + +ase_lsp_obj_t* ase_lsp_prim_demac (ase_lsp_t* lsp, ase_lsp_obj_t* args) +{ + /* + * (demac x (abc) x y z) + * (setq x (macro (abc) x y z)) + */ + + ase_lsp_obj_t* name, * mac; + + name = ASE_LSP_CAR(args); + if (ASE_LSP_TYPE(name) != ASE_LSP_OBJ_SYM) + { + ase_lsp_seterror (lsp, ASE_LSP_EARGBAD, ASE_NULL, 0); + return ASE_NULL; + } + + mac = ase_lsp_makemacro (lsp->mem, + ASE_LSP_CAR(ASE_LSP_CDR(args)), ASE_LSP_CDR(ASE_LSP_CDR(args))); + if (mac == ASE_NULL) return ASE_NULL; + + if (ase_lsp_pushtmp (lsp, mac) == ASE_NULL) return ASE_NULL; + + if (ase_lsp_setfunc (lsp->mem, ASE_LSP_CAR(args), mac) == ASE_NULL) + { + ase_lsp_poptmp (lsp); + return ASE_NULL; + } + + ase_lsp_poptmp (lsp); + return mac; +} + +ase_lsp_obj_t* ase_lsp_prim_or (ase_lsp_t* lsp, ase_lsp_obj_t* args) +{ + /* + * (or 10 20 30 40) + * (or (= n 20) (= n 30)) + */ + ase_lsp_obj_t* tmp; + +/* TODO: this is wrong. redo the work */ + while (ASE_LSP_TYPE(args) == ASE_LSP_OBJ_CONS) + { + tmp = ase_lsp_eval (lsp, ASE_LSP_CAR(args)); + if (tmp == ASE_NULL) return ASE_NULL; + + if (ASE_LSP_TYPE(args) == ASE_LSP_OBJ_INT) + if (tmp != lsp->mem->nil) return lsp->mem->t; + args = ASE_LSP_CDR(args); + } + + return lsp->mem->nil; +} + diff --git a/ase/lsp/prim.h b/ase/lsp/prim.h new file mode 100644 index 00000000..baa9e958 --- /dev/null +++ b/ase/lsp/prim.h @@ -0,0 +1,69 @@ +/* + * $Id: prim.h,v 1.3 2007/04/30 06:09:46 bacon Exp $ + * + * {License} + */ + +#ifndef _ASE_LSP_PRIM_H_ +#define _ASE_LSP_PRIM_H_ + +#ifndef _ASE_LSP_LSP_H_ +#error Never include this file directly. Include instead +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +ase_lsp_obj_t* ase_lsp_prim_exit (ase_lsp_t* lsp, ase_lsp_obj_t* args); +ase_lsp_obj_t* ase_lsp_prim_eval (ase_lsp_t* lsp, ase_lsp_obj_t* args); +ase_lsp_obj_t* ase_lsp_prim_prog1 (ase_lsp_t* lsp, ase_lsp_obj_t* args); +ase_lsp_obj_t* ase_lsp_prim_progn (ase_lsp_t* lsp, ase_lsp_obj_t* args); +ase_lsp_obj_t* ase_lsp_prim_gc (ase_lsp_t* lsp, ase_lsp_obj_t* args); +ase_lsp_obj_t* ase_lsp_prim_cond (ase_lsp_t* lsp, ase_lsp_obj_t* args); +ase_lsp_obj_t* ase_lsp_prim_if (ase_lsp_t* lsp, ase_lsp_obj_t* args); +ase_lsp_obj_t* ase_lsp_prim_while (ase_lsp_t* lsp, ase_lsp_obj_t* args); + +ase_lsp_obj_t* ase_lsp_prim_car (ase_lsp_t* lsp, ase_lsp_obj_t* args); +ase_lsp_obj_t* ase_lsp_prim_cdr (ase_lsp_t* lsp, ase_lsp_obj_t* args); +ase_lsp_obj_t* ase_lsp_prim_cons (ase_lsp_t* lsp, ase_lsp_obj_t* args); +ase_lsp_obj_t* ase_lsp_prim_length (ase_lsp_t* lsp, ase_lsp_obj_t* args); + +ase_lsp_obj_t* ase_lsp_prim_set (ase_lsp_t* lsp, ase_lsp_obj_t* args); +ase_lsp_obj_t* ase_lsp_prim_setq (ase_lsp_t* lsp, ase_lsp_obj_t* args); +ase_lsp_obj_t* ase_lsp_prim_quote (ase_lsp_t* lsp, ase_lsp_obj_t* args); +ase_lsp_obj_t* ase_lsp_prim_defun (ase_lsp_t* lsp, ase_lsp_obj_t* args); +ase_lsp_obj_t* ase_lsp_prim_demac (ase_lsp_t* lsp, ase_lsp_obj_t* args); +ase_lsp_obj_t* ase_lsp_prim_let (ase_lsp_t* lsp, ase_lsp_obj_t* args); +ase_lsp_obj_t* ase_lsp_prim_letx (ase_lsp_t* lsp, ase_lsp_obj_t* args); +ase_lsp_obj_t* ase_lsp_prim_or (ase_lsp_t* lsp, ase_lsp_obj_t* args); + +/*--------------------- + prim_compar.c + ---------------------*/ +ase_lsp_obj_t* ase_lsp_prim_eq (ase_lsp_t* lsp, ase_lsp_obj_t* args); +ase_lsp_obj_t* ase_lsp_prim_ne (ase_lsp_t* lsp, ase_lsp_obj_t* args); +ase_lsp_obj_t* ase_lsp_prim_gt (ase_lsp_t* lsp, ase_lsp_obj_t* args); +ase_lsp_obj_t* ase_lsp_prim_lt (ase_lsp_t* lsp, ase_lsp_obj_t* args); +ase_lsp_obj_t* ase_lsp_prim_ge (ase_lsp_t* lsp, ase_lsp_obj_t* args); +ase_lsp_obj_t* ase_lsp_prim_le (ase_lsp_t* lsp, ase_lsp_obj_t* args); + +/*--------------------- + prim_math.c + ---------------------*/ +ase_lsp_obj_t* ase_lsp_prim_plus (ase_lsp_t* lsp, ase_lsp_obj_t* args); +ase_lsp_obj_t* ase_lsp_prim_minus (ase_lsp_t* lsp, ase_lsp_obj_t* args); +ase_lsp_obj_t* ase_lsp_prim_mul (ase_lsp_t* lsp, ase_lsp_obj_t* args); +ase_lsp_obj_t* ase_lsp_prim_div (ase_lsp_t* lsp, ase_lsp_obj_t* args); +ase_lsp_obj_t* ase_lsp_prim_mod (ase_lsp_t* lsp, ase_lsp_obj_t* args); + +/*--------------------- + prim_fact.c + ---------------------*/ +ase_lsp_obj_t* ase_lsp_prim_fact (ase_lsp_t* lsp, ase_lsp_obj_t* args); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ase/lsp/prim_compar.c b/ase/lsp/prim_compar.c new file mode 100644 index 00000000..7036ed0f --- /dev/null +++ b/ase/lsp/prim_compar.c @@ -0,0 +1,141 @@ +/* + * $Id: prim_compar.c,v 1.3 2007/04/30 06:09:46 bacon Exp $ + * + * {License} + */ + +#include + +#define PRIM_COMPAR(lsp,args,op) \ +{ \ + ase_lsp_obj_t* p1, * p2; \ + int res; \ + ASE_ASSERT (ASE_LSP_TYPE(args) == ASE_LSP_OBJ_CONS); \ +\ + p1 = ase_lsp_eval (lsp, ASE_LSP_CAR(args)); \ + if (p1 == ASE_NULL) return ASE_NULL; \ + if (ase_lsp_pushtmp (lsp, p1) == ASE_NULL) return ASE_NULL; \ +\ + p2 = ase_lsp_eval (lsp, ASE_LSP_CAR(ASE_LSP_CDR(args))); \ + if (p2 == ASE_NULL) \ + { \ + ase_lsp_poptmp (lsp); \ + return ASE_NULL; \ + } \ +\ + if (ase_lsp_pushtmp (lsp, p2) == ASE_NULL) \ + { \ + ase_lsp_poptmp (lsp); \ + return ASE_NULL; \ + } \ +\ + if (ASE_LSP_TYPE(p1) == ASE_LSP_OBJ_INT) \ + { \ + if (ASE_LSP_TYPE(p2) == ASE_LSP_OBJ_INT) \ + { \ + res = ASE_LSP_IVAL(p1) op ASE_LSP_IVAL(p2); \ + } \ + else if (ASE_LSP_TYPE(p2) == ASE_LSP_OBJ_REAL) \ + { \ + res = ASE_LSP_IVAL(p1) op ASE_LSP_RVAL(p2); \ + } \ + else \ + { \ + ase_lsp_poptmp (lsp); \ + ase_lsp_poptmp (lsp); \ + ase_lsp_seterror (lsp, ASE_LSP_EVALBAD, ASE_NULL, 0); \ + return ASE_NULL; \ + } \ + } \ + else if (ASE_LSP_TYPE(p1) == ASE_LSP_OBJ_REAL) \ + { \ + if (ASE_LSP_TYPE(p2) == ASE_LSP_OBJ_INT) \ + { \ + res = ASE_LSP_RVAL(p1) op ASE_LSP_IVAL(p2); \ + } \ + else if (ASE_LSP_TYPE(p2) == ASE_LSP_OBJ_REAL) \ + { \ + res = ASE_LSP_RVAL(p1) op ASE_LSP_RVAL(p2); \ + } \ + else \ + { \ + ase_lsp_poptmp (lsp); \ + ase_lsp_poptmp (lsp); \ + ase_lsp_seterror (lsp, ASE_LSP_EVALBAD, ASE_NULL, 0); \ + return ASE_NULL; \ + } \ + } \ + else if (ASE_LSP_TYPE(p1) == ASE_LSP_OBJ_SYM) \ + { \ + if (ASE_LSP_TYPE(p2) == ASE_LSP_OBJ_SYM) \ + { \ + res = ase_strxncmp ( \ + ASE_LSP_SYMPTR(p1), ASE_LSP_SYMLEN(p1), \ + ASE_LSP_SYMPTR(p2), ASE_LSP_SYMLEN(p2)) op 0; \ + } \ + else \ + { \ + ase_lsp_poptmp (lsp); \ + ase_lsp_poptmp (lsp); \ + ase_lsp_seterror (lsp, ASE_LSP_EVALBAD, ASE_NULL, 0); \ + return ASE_NULL; \ + } \ + } \ + else if (ASE_LSP_TYPE(p1) == ASE_LSP_OBJ_STR) \ + { \ + if (ASE_LSP_TYPE(p2) == ASE_LSP_OBJ_STR) \ + { \ + res = ase_strxncmp ( \ + ASE_LSP_STRPTR(p1), ASE_LSP_STRLEN(p1), \ + ASE_LSP_STRPTR(p2), ASE_LSP_STRLEN(p2)) op 0; \ + } \ + else \ + { \ + ase_lsp_poptmp (lsp); \ + ase_lsp_poptmp (lsp); \ + ase_lsp_seterror (lsp, ASE_LSP_EVALBAD, ASE_NULL, 0); \ + return ASE_NULL; \ + } \ + } \ + else \ + { \ + ase_lsp_poptmp (lsp); \ + ase_lsp_poptmp (lsp); \ + ase_lsp_seterror (lsp, ASE_LSP_EVALBAD, ASE_NULL, 0); \ + return ASE_NULL; \ + } \ +\ + ase_lsp_poptmp (lsp); \ + ase_lsp_poptmp (lsp); \ + return (res)? lsp->mem->t: lsp->mem->nil; \ +} + +ase_lsp_obj_t* ase_lsp_prim_eq (ase_lsp_t* lsp, ase_lsp_obj_t* args) +{ + PRIM_COMPAR (lsp, args, ==); +} + +ase_lsp_obj_t* ase_lsp_prim_ne (ase_lsp_t* lsp, ase_lsp_obj_t* args) +{ + PRIM_COMPAR (lsp, args, !=); +} + +ase_lsp_obj_t* ase_lsp_prim_gt (ase_lsp_t* lsp, ase_lsp_obj_t* args) +{ + PRIM_COMPAR (lsp, args, >); +} + +ase_lsp_obj_t* ase_lsp_prim_lt (ase_lsp_t* lsp, ase_lsp_obj_t* args) +{ + PRIM_COMPAR (lsp, args, <); +} + +ase_lsp_obj_t* ase_lsp_prim_ge (ase_lsp_t* lsp, ase_lsp_obj_t* args) +{ + PRIM_COMPAR (lsp, args, >=); +} + +ase_lsp_obj_t* ase_lsp_prim_le (ase_lsp_t* lsp, ase_lsp_obj_t* args) +{ + PRIM_COMPAR (lsp, args, <=); +} diff --git a/ase/lsp/prim_let.c b/ase/lsp/prim_let.c new file mode 100644 index 00000000..d485fbff --- /dev/null +++ b/ase/lsp/prim_let.c @@ -0,0 +1,186 @@ +/* + * $Id: prim_let.c,v 1.3 2007/04/30 06:09:46 bacon Exp $ + * + * {License} + */ + +#include + +/* + * (let ((variable value) + * (variable value) + * ...) + * body...) + */ + +static ase_lsp_obj_t* __prim_let ( + ase_lsp_t* lsp, ase_lsp_obj_t* args, int sequential) +{ + ase_lsp_frame_t* frame; + ase_lsp_obj_t* assoc; + ase_lsp_obj_t* body; + ase_lsp_obj_t* value; + + /* create a new frameq */ + frame = ase_lsp_newframe (lsp); + if (frame == ASE_NULL) return ASE_NULL; + /*frame->link = lsp->mem->frame;*/ + + if (sequential) + { + frame->link = lsp->mem->frame; + lsp->mem->frame = frame; + } + else + { + frame->link = lsp->mem->brooding_frame; + lsp->mem->brooding_frame = frame; + } + + assoc = ASE_LSP_CAR(args); + + /*while (assoc != lsp->mem->nil) {*/ + while (ASE_LSP_TYPE(assoc) == ASE_LSP_OBJ_CONS) + { + ase_lsp_obj_t* ass = ASE_LSP_CAR(assoc); + if (ASE_LSP_TYPE(ass) == ASE_LSP_OBJ_CONS) + { + ase_lsp_obj_t* n = ASE_LSP_CAR(ass); + ase_lsp_obj_t* v = ASE_LSP_CDR(ass); + + if (ASE_LSP_TYPE(n) != ASE_LSP_OBJ_SYM) + { + if (sequential) lsp->mem->frame = frame->link; + else lsp->mem->brooding_frame = frame->link; + ase_lsp_freeframe (lsp, frame); + + ase_lsp_seterror (lsp, ASE_LSP_EARGBAD, ASE_NULL, 0); + return ASE_NULL; + } + + if (v != lsp->mem->nil) + { + if (ASE_LSP_CDR(v) != lsp->mem->nil) + { + if (sequential) lsp->mem->frame = frame->link; + else lsp->mem->brooding_frame = frame->link; + ase_lsp_freeframe (lsp, frame); + + ase_lsp_seterror (lsp, ASE_LSP_EARGMANY, ASE_NULL, 0); + return ASE_NULL; + } + if ((v = ase_lsp_eval(lsp, ASE_LSP_CAR(v))) == ASE_NULL) + { + if (sequential) lsp->mem->frame = frame->link; + else lsp->mem->brooding_frame = frame->link; + ase_lsp_freeframe (lsp, frame); + return ASE_NULL; + } + } + + if (ase_lsp_lookupinframe (lsp, frame, n) != ASE_NULL) + { + if (sequential) lsp->mem->frame = frame->link; + else lsp->mem->brooding_frame = frame->link; + ase_lsp_freeframe (lsp, frame); + + ase_lsp_seterror (lsp, ASE_LSP_EDUPFML, ASE_NULL, 0); + return ASE_NULL; + } + if (ase_lsp_insvalueintoframe (lsp, frame, n, v) == ASE_NULL) + { + if (sequential) lsp->mem->frame = frame->link; + else lsp->mem->brooding_frame = frame->link; + ase_lsp_freeframe (lsp, frame); + return ASE_NULL; + } + } + else if (ASE_LSP_TYPE(ass) == ASE_LSP_OBJ_SYM) + { + if (ase_lsp_lookupinframe (lsp, frame, ass) != ASE_NULL) + { + if (sequential) lsp->mem->frame = frame->link; + else lsp->mem->brooding_frame = frame->link; + ase_lsp_freeframe (lsp, frame); + + ase_lsp_seterror (lsp, ASE_LSP_EDUPFML, ASE_NULL, 0); + return ASE_NULL; + } + if (ase_lsp_insvalueintoframe (lsp, frame, ass, lsp->mem->nil) == ASE_NULL) + { + if (sequential) lsp->mem->frame = frame->link; + else lsp->mem->brooding_frame = frame->link; + ase_lsp_freeframe (lsp, frame); + return ASE_NULL; + } + } + else + { + if (sequential) lsp->mem->frame = frame->link; + else lsp->mem->brooding_frame = frame->link; + ase_lsp_freeframe (lsp, frame); + + ase_lsp_seterror (lsp, ASE_LSP_EARGBAD, ASE_NULL, 0); + return ASE_NULL; + } + + assoc = ASE_LSP_CDR(assoc); + } + + if (assoc != lsp->mem->nil) + { + if (sequential) lsp->mem->frame = frame->link; + else lsp->mem->brooding_frame = frame->link; + ase_lsp_freeframe (lsp, frame); + + ase_lsp_seterror (lsp, ASE_LSP_EARGBAD, ASE_NULL, 0); + return ASE_NULL; + } + + /* push the frame */ + if (!sequential) + { + lsp->mem->brooding_frame = frame->link; + frame->link = lsp->mem->frame; + lsp->mem->frame = frame; + } + + /* evaluate forms in the body */ + value = lsp->mem->nil; + body = ASE_LSP_CDR(args); + while (body != lsp->mem->nil) + { + value = ase_lsp_eval (lsp, ASE_LSP_CAR(body)); + if (value == ASE_NULL) + { + lsp->mem->frame = frame->link; + ase_lsp_freeframe (lsp, frame); + return ASE_NULL; + } + body = ASE_LSP_CDR(body); + } + + /* pop the frame */ + lsp->mem->frame = frame->link; + + /* destroy the frame */ + ase_lsp_freeframe (lsp, frame); + return value; +} + +ase_lsp_obj_t* ase_lsp_prim_let (ase_lsp_t* lsp, ase_lsp_obj_t* args) +{ + /* + * (defun x (x y) + * (let ((temp1 10) (temp2 20)) + * (+ x y temp1 temp2))) + * (x 40 50) + * temp1 + */ + return __prim_let (lsp, args, 0); +} + +ase_lsp_obj_t* ase_lsp_prim_letx (ase_lsp_t* lsp, ase_lsp_obj_t* args) +{ + return __prim_let (lsp, args, 1); +} diff --git a/ase/lsp/prim_math.c b/ase/lsp/prim_math.c new file mode 100644 index 00000000..5b21c13e --- /dev/null +++ b/ase/lsp/prim_math.c @@ -0,0 +1,351 @@ +/* + * $Id: prim_math.c,v 1.3 2007/04/30 06:09:46 bacon Exp $ + * + * {License} + */ + +#include + +ase_lsp_obj_t* ase_lsp_prim_plus (ase_lsp_t* lsp, ase_lsp_obj_t* args) +{ + ase_lsp_obj_t* body, * tmp; + ase_long_t ival = 0; + ase_real_t rval = .0; + ase_bool_t realnum = ase_false; + + ASE_ASSERT (ASE_LSP_TYPE(args) == ASE_LSP_OBJ_CONS); + + body = args; + while (ASE_LSP_TYPE(body) == ASE_LSP_OBJ_CONS) + { + tmp = ase_lsp_eval (lsp, ASE_LSP_CAR(body)); + if (tmp == ASE_NULL) return ASE_NULL; + + if (ASE_LSP_TYPE(tmp) == ASE_LSP_OBJ_INT) + { + if (body == args) + { + ASE_ASSERT (realnum == ase_false); + ival = ASE_LSP_IVAL(tmp); + } + else + { + if (!realnum) + ival = ival + ASE_LSP_IVAL(tmp); + else + rval = rval + ASE_LSP_IVAL(tmp); + } + } + else if (ASE_LSP_TYPE(tmp) == ASE_LSP_OBJ_REAL) + { + if (body == args) + { + ASE_ASSERT (realnum == ase_false); + realnum = ase_true; + rval = ASE_LSP_RVAL(tmp); + } + else + { + if (!realnum) + { + realnum = ase_true; + rval = (ase_real_t)ival; + } + rval = rval + ASE_LSP_RVAL(tmp); + } + } + else + { + ase_lsp_seterror (lsp, ASE_LSP_EVALBAD, ASE_NULL, 0); + return ASE_NULL; + } + + + body = ASE_LSP_CDR(body); + } + + ASE_ASSERT (body == lsp->mem->nil); + + tmp = (realnum)? + ase_lsp_makerealobj (lsp->mem, rval): + ase_lsp_makeintobj (lsp->mem, ival); + if (tmp == ASE_NULL) return ASE_NULL; + + return tmp; +} + +ase_lsp_obj_t* ase_lsp_prim_minus (ase_lsp_t* lsp, ase_lsp_obj_t* args) +{ + ase_lsp_obj_t* body, * tmp; + ase_long_t ival = 0; + ase_real_t rval = .0; + ase_bool_t realnum = ase_false; + + ASE_ASSERT (ASE_LSP_TYPE(args) == ASE_LSP_OBJ_CONS); + + body = args; + while (ASE_LSP_TYPE(body) == ASE_LSP_OBJ_CONS) + { + tmp = ase_lsp_eval (lsp, ASE_LSP_CAR(body)); + if (tmp == ASE_NULL) return ASE_NULL; + + + if (ASE_LSP_TYPE(tmp) == ASE_LSP_OBJ_INT) + { + if (body == args) + { + ASE_ASSERT (realnum == ase_false); + ival = ASE_LSP_IVAL(tmp); + } + else + { + if (!realnum) + ival = ival - ASE_LSP_IVAL(tmp); + else + rval = rval - ASE_LSP_IVAL(tmp); + } + } + else if (ASE_LSP_TYPE(tmp) == ASE_LSP_OBJ_REAL) + { + if (body == args) + { + ASE_ASSERT (realnum == ase_false); + realnum = ase_true; + rval = ASE_LSP_RVAL(tmp); + } + else + { + if (!realnum) + { + realnum = ase_true; + rval = (ase_real_t)ival; + } + rval = rval - ASE_LSP_RVAL(tmp); + } + } + else + { + ase_lsp_seterror (lsp, ASE_LSP_EVALBAD, ASE_NULL, 0); + return ASE_NULL; + } + + + body = ASE_LSP_CDR(body); + } + + ASE_ASSERT (body == lsp->mem->nil); + + tmp = (realnum)? + ase_lsp_makerealobj (lsp->mem, rval): + ase_lsp_makeintobj (lsp->mem, ival); + if (tmp == ASE_NULL) return ASE_NULL; + + return tmp; +} + +ase_lsp_obj_t* ase_lsp_prim_mul (ase_lsp_t* lsp, ase_lsp_obj_t* args) +{ + ase_lsp_obj_t* body, * tmp; + ase_long_t ival = 0; + ase_real_t rval = .0; + ase_bool_t realnum = ase_false; + + ASE_ASSERT (ASE_LSP_TYPE(args) == ASE_LSP_OBJ_CONS); + + body = args; + while (ASE_LSP_TYPE(body) == ASE_LSP_OBJ_CONS) + { + tmp = ase_lsp_eval (lsp, ASE_LSP_CAR(body)); + if (tmp == ASE_NULL) return ASE_NULL; + + if (ASE_LSP_TYPE(tmp) == ASE_LSP_OBJ_INT) + { + if (body == args) + { + ASE_ASSERT (realnum == ase_false); + ival = ASE_LSP_IVAL(tmp); + } + else + { + if (!realnum) + ival = ival * ASE_LSP_IVAL(tmp); + else + rval = rval * ASE_LSP_IVAL(tmp); + } + } + else if (ASE_LSP_TYPE(tmp) == ASE_LSP_OBJ_REAL) + { + if (body == args) + { + ASE_ASSERT (realnum == ase_false); + realnum = ase_true; + rval = ASE_LSP_RVAL(tmp); + } + else + { + if (!realnum) + { + realnum = ase_true; + rval = (ase_real_t)ival; + } + rval = rval * ASE_LSP_RVAL(tmp); + } + } + else + { + ase_lsp_seterror (lsp, ASE_LSP_EVALBAD, ASE_NULL, 0); + return ASE_NULL; + } + + + body = ASE_LSP_CDR(body); + } + + ASE_ASSERT (body == lsp->mem->nil); + + tmp = (realnum)? + ase_lsp_makerealobj (lsp->mem, rval): + ase_lsp_makeintobj (lsp->mem, ival); + if (tmp == ASE_NULL) return ASE_NULL; + + return tmp; +} + +ase_lsp_obj_t* ase_lsp_prim_div (ase_lsp_t* lsp, ase_lsp_obj_t* args) +{ + ase_lsp_obj_t* body, * tmp; + ase_long_t ival = 0; + ase_real_t rval = .0; + ase_bool_t realnum = ase_false; + + ASE_ASSERT (ASE_LSP_TYPE(args) == ASE_LSP_OBJ_CONS); + + body = args; + while (ASE_LSP_TYPE(body) == ASE_LSP_OBJ_CONS) + { + tmp = ase_lsp_eval (lsp, ASE_LSP_CAR(body)); + if (tmp == ASE_NULL) return ASE_NULL; + + if (ASE_LSP_TYPE(tmp) == ASE_LSP_OBJ_INT) + { + if (body == args) + { + ASE_ASSERT (realnum == ase_false); + ival = ASE_LSP_IVAL(tmp); + } + else + { + if (!realnum) + { + if (ASE_LSP_IVAL(tmp) == 0) + { + ase_lsp_seterror (lsp, ASE_LSP_EDIVBY0, ASE_NULL, 0); + return ASE_NULL; + } + ival = ival / ASE_LSP_IVAL(tmp); + } + else + rval = rval / ASE_LSP_IVAL(tmp); + } + } + else if (ASE_LSP_TYPE(tmp) == ASE_LSP_OBJ_REAL) + { + if (body == args) + { + ASE_ASSERT (realnum == ase_false); + realnum = ase_true; + rval = ASE_LSP_RVAL(tmp); + } + else + { + if (!realnum) + { + realnum = ase_true; + rval = (ase_real_t)ival; + } + rval = rval / ASE_LSP_RVAL(tmp); + } + } + else + { + ase_lsp_seterror (lsp, ASE_LSP_EVALBAD, ASE_NULL, 0); + return ASE_NULL; + } + + + body = ASE_LSP_CDR(body); + } + + ASE_ASSERT (body == lsp->mem->nil); + + tmp = (realnum)? + ase_lsp_makerealobj (lsp->mem, rval): + ase_lsp_makeintobj (lsp->mem, ival); + if (tmp == ASE_NULL) return ASE_NULL; + + return tmp; +} + +ase_lsp_obj_t* ase_lsp_prim_mod (ase_lsp_t* lsp, ase_lsp_obj_t* args) +{ + ase_lsp_obj_t* body, * tmp; + ase_long_t ival = 0; + + ASE_ASSERT (ASE_LSP_TYPE(args) == ASE_LSP_OBJ_CONS); + + body = args; + while (ASE_LSP_TYPE(body) == ASE_LSP_OBJ_CONS) + { + tmp = ase_lsp_eval (lsp, ASE_LSP_CAR(body)); + if (tmp == ASE_NULL) return ASE_NULL; + + if (ASE_LSP_TYPE(tmp) == ASE_LSP_OBJ_INT) + { + if (body == args) + { + ival = ASE_LSP_IVAL(tmp); + } + else + { + if (ASE_LSP_IVAL(tmp) == 0) + { + ase_lsp_seterror (lsp, ASE_LSP_EDIVBY0, ASE_NULL, 0); + return ASE_NULL; + } + ival = ival % ASE_LSP_IVAL(tmp); + } + } + else if (ASE_LSP_TYPE(tmp) == ASE_LSP_OBJ_REAL) + { + if (body == args) + { + ival = (ase_long_t)ASE_LSP_RVAL(tmp); + } + else + { + ase_long_t tmpi = (ase_long_t)ASE_LSP_RVAL(tmp); + if (tmpi == 0) + { + ase_lsp_seterror (lsp, ASE_LSP_EDIVBY0, ASE_NULL, 0); + return ASE_NULL; + } + ival = ival % tmpi; + } + } + else + { + ase_lsp_seterror (lsp, ASE_LSP_EVALBAD, ASE_NULL, 0); + return ASE_NULL; + } + + + body = ASE_LSP_CDR(body); + } + + ASE_ASSERT (body == lsp->mem->nil); + + tmp = ase_lsp_makeintobj (lsp->mem, ival); + if (tmp == ASE_NULL) return ASE_NULL; + + return tmp; +} diff --git a/ase/lsp/prim_prog.c b/ase/lsp/prim_prog.c new file mode 100644 index 00000000..fa2f7ac7 --- /dev/null +++ b/ase/lsp/prim_prog.c @@ -0,0 +1,53 @@ +/* + * $Id: prim_prog.c,v 1.3 2007/04/30 06:09:46 bacon Exp $ + * + * {License} + */ + +#include + +ase_lsp_obj_t* ase_lsp_prim_prog1 (ase_lsp_t* lsp, ase_lsp_obj_t* args) +{ + /* (prog1 1 2 3) returns 1 */ + ase_lsp_obj_t* res = ASE_NULL, * tmp; + + /*while (args != lsp->mem->nil) {*/ + while (ASE_LSP_TYPE(args) == ASE_LSP_OBJ_CONS) + { + tmp = ase_lsp_eval (lsp, ASE_LSP_CAR(args)); + if (tmp == ASE_NULL) return ASE_NULL; + + if (res == ASE_NULL) + { + res = tmp; + if (ase_lsp_pushtmp (lsp, res) == ASE_NULL) + { + return ASE_NULL; + } + } + args = ASE_LSP_CDR(args); + } + + if (res != ASE_NULL) ase_lsp_poptmp (lsp); + return res; +} + +ase_lsp_obj_t* ase_lsp_prim_progn (ase_lsp_t* lsp, ase_lsp_obj_t* args) +{ + /* (progn 1 2 3) returns 3 */ + + ase_lsp_obj_t* res, * tmp; + + res = lsp->mem->nil; + /*while (args != lsp->mem->nil) {*/ + while (ASE_LSP_TYPE(args) == ASE_LSP_OBJ_CONS) + { + tmp = ase_lsp_eval (lsp, ASE_LSP_CAR(args)); + if (tmp == ASE_NULL) return ASE_NULL; + + res = tmp; + args = ASE_LSP_CDR(args); + } + + return res; +} diff --git a/ase/lsp/print.c b/ase/lsp/print.c new file mode 100644 index 00000000..00bf7d70 --- /dev/null +++ b/ase/lsp/print.c @@ -0,0 +1,150 @@ +/* + * $Id: print.c,v 1.3 2007/04/30 06:09:46 bacon Exp $ + * + * {License} + */ + +#include + +#define OUTPUT_STR(lsp,str) \ + do { \ + if (lsp->output_func(ASE_LSP_IO_WRITE, lsp->output_arg, (ase_char_t*)str, ase_strlen(str)) == -1) { \ + ase_lsp_seterror (lsp, ASE_LSP_EOUTPUT, ASE_NULL, 0); \ + return -1; \ + } \ + } while (0) + +#define OUTPUT_STRX(lsp,str,len) \ + do { \ + if (lsp->output_func(ASE_LSP_IO_WRITE, lsp->output_arg, (ase_char_t*)str, len) == -1) { \ + ase_lsp_seterror (lsp, ASE_LSP_EOUTPUT, ASE_NULL, 0); \ + return -1; \ + } \ + } while (0) + +static int __print (ase_lsp_t* lsp, const ase_lsp_obj_t* obj, ase_bool_t prt_cons_par) +{ + ase_char_t buf[256]; + + if (lsp->output_func == ASE_NULL) + { + ase_lsp_seterror (lsp, ASE_LSP_ENOOUTP, ASE_NULL, 0); + return -1; + } + + switch (ASE_LSP_TYPE(obj)) + { + case ASE_LSP_OBJ_NIL: + OUTPUT_STR (lsp, ASE_T("nil")); + break; + + case ASE_LSP_OBJ_TRUE: + OUTPUT_STR (lsp, ASE_T("t")); + break; + + case ASE_LSP_OBJ_INT: + #if ASE_SIZEOF_LONG_LONG > 0 + lsp->prmfns.misc.sprintf ( + lsp->prmfns.misc.custom_data, + buf, ASE_COUNTOF(buf), + ASE_T("%lld"), (long long)ASE_LSP_IVAL(obj)); + #elif ASE_SIZEOF___INT64 > 0 + lsp->prmfns.misc.sprintf ( + lsp->prmfns.misc.custom_data, + buf, ASE_COUNTOF(buf), + ASE_T("%I64d"), (__int64)ASE_LSP_IVAL(obj)); + #elif ASE_SIZEOF_LONG > 0 + lsp->prmfns.misc.sprintf ( + lsp->prmfns.misc.custom_data, + buf, ASE_COUNTOF(buf), + ASE_T("%ld"), (long)ASE_LSP_IVAL(obj)); + #elif ASE_SIZEOF_INT > 0 + lsp->prmfns.misc.sprintf ( + lsp->prmfns.misc.custom_data, + buf, ASE_COUNTOF(buf), + ASE_T("%d"), (int)ASE_LSP_IVAL(obj)); + #else + #error unsupported size + #endif + OUTPUT_STR (lsp, buf); + break; + + case ASE_LSP_OBJ_REAL: + lsp->prmfns.misc.sprintf ( + lsp->prmfns.misc.custom_data, + buf, ASE_COUNTOF(buf), + ASE_T("%Lf"), (long double)ASE_LSP_RVAL(obj)); + + OUTPUT_STR (lsp, buf); + break; + + case ASE_LSP_OBJ_SYM: + OUTPUT_STRX (lsp, ASE_LSP_SYMPTR(obj), ASE_LSP_SYMLEN(obj)); + break; + + case ASE_LSP_OBJ_STR: + OUTPUT_STR (lsp, ASE_T("\"")); + /* TODO: deescaping */ + OUTPUT_STRX (lsp, ASE_LSP_STRPTR(obj), ASE_LSP_STRLEN(obj)); + OUTPUT_STR (lsp, ASE_T("\"")); + break; + + case ASE_LSP_OBJ_CONS: + { + const ase_lsp_obj_t* p = obj; + if (prt_cons_par) OUTPUT_STR (lsp, ASE_T("(")); + do + { + ase_lsp_print (lsp, ASE_LSP_CAR(p)); + p = ASE_LSP_CDR(p); + if (p != lsp->mem->nil) + { + OUTPUT_STR (lsp, ASE_T(" ")); + if (ASE_LSP_TYPE(p) != ASE_LSP_OBJ_CONS) + { + OUTPUT_STR (lsp, ASE_T(". ")); + ase_lsp_print (lsp, p); + } + } + } + while (p != lsp->mem->nil && ASE_LSP_TYPE(p) == ASE_LSP_OBJ_CONS); + if (prt_cons_par) OUTPUT_STR (lsp, ASE_T(")")); + + break; + } + + case ASE_LSP_OBJ_FUNC: + /*OUTPUT_STR (lsp, ASE_T("func"));*/ + OUTPUT_STR (lsp, ASE_T("(lambda ")); + if (__print (lsp, ASE_LSP_FFORMAL(obj), ase_true) == -1) return -1; + OUTPUT_STR (lsp, ASE_T(" ")); + if (__print (lsp, ASE_LSP_FBODY(obj), ase_false) == -1) return -1; + OUTPUT_STR (lsp, ASE_T(")")); + break; + + case ASE_LSP_OBJ_MACRO: + OUTPUT_STR (lsp, ASE_T("(macro ")); + if (__print (lsp, ASE_LSP_FFORMAL(obj), ase_true) == -1) return -1; + OUTPUT_STR (lsp, ASE_T(" ")); + if (__print (lsp, ASE_LSP_FBODY(obj), ase_false) == -1) return -1; + OUTPUT_STR (lsp, ASE_T(")")); + break; + case ASE_LSP_OBJ_PRIM: + OUTPUT_STR (lsp, ASE_T("prim")); + break; + + default: + lsp->prmfns.misc.sprintf ( + lsp->prmfns.misc.custom_data, + buf, ASE_COUNTOF(buf), + ASE_T("unknown object type: %d"), ASE_LSP_TYPE(obj)); + OUTPUT_STR (lsp, buf); + } + + return 0; +} + +int ase_lsp_print (ase_lsp_t* lsp, const ase_lsp_obj_t* obj) +{ + return __print (lsp, obj, ase_true); +} diff --git a/ase/lsp/read.c b/ase/lsp/read.c new file mode 100644 index 00000000..da723662 --- /dev/null +++ b/ase/lsp/read.c @@ -0,0 +1,567 @@ +/* + * $Id: read.c,v 1.3 2007/04/30 06:09:46 bacon Exp $ + * + * {License} + */ + +#include + +#define IS_IDENT(c) \ + ((c) == ASE_T('+') || (c) == ASE_T('-') || \ + (c) == ASE_T('*') || (c) == ASE_T('/') || \ + (c) == ASE_T('%') || (c) == ASE_T('&') || \ + (c) == ASE_T('<') || (c) == ASE_T('>') || \ + (c) == ASE_T('=') || (c) == ASE_T('_') || \ + (c) == ASE_T('?')) + +#define TOKEN_CLEAR(lsp) ase_lsp_name_clear (&(lsp)->token.name) +#define TOKEN_TYPE(lsp) (lsp)->token.type +#define TOKEN_IVAL(lsp) (lsp)->token.ival +#define TOKEN_RVAL(lsp) (lsp)->token.rval +#define TOKEN_SPTR(lsp) (lsp)->token.name.buf +#define TOKEN_SLEN(lsp) (lsp)->token.name.size + +#define TOKEN_ADD_CHAR(lsp,ch) \ + do { \ + if (ase_lsp_name_addc(&(lsp)->token.name, ch) == -1) { \ + ase_lsp_seterror (lsp, ASE_LSP_ENOMEM, ASE_NULL, 0); \ + return -1; \ + } \ + } while (0) + +#define TOKEN_COMPARE(lsp,str) \ + ase_lsp_name_compare (&(lsp)->token.name, str) + +#define TOKEN_END 0 +#define TOKEN_INT 1 +#define TOKEN_REAL 2 +#define TOKEN_STRING 3 +#define TOKEN_LPAREN 4 +#define TOKEN_RPAREN 5 +#define TOKEN_IDENT 6 +#define TOKEN_QUOTE 7 +#define TOKEN_DOT 8 +#define TOKEN_INVALID 50 +#define TOKEN_UNTERM_STRING 51 + +#define NEXT_CHAR(lsp) \ + do { if (read_char(lsp) == -1) return -1;} while (0) + +#define NEXT_CHAR_TO(lsp,c) \ + do { \ + if (read_char(lsp) == -1) return -1;\ + c = (lsp)->curc; \ + } while (0) + +#define NEXT_TOKEN(lsp) \ + do { if (read_token(lsp) == -1) return ASE_NULL; } while (0) + +static ase_lsp_obj_t* read_obj (ase_lsp_t* lsp); +static ase_lsp_obj_t* read_list (ase_lsp_t* lsp); +static ase_lsp_obj_t* read_quote (ase_lsp_t* lsp); + +static int read_char (ase_lsp_t* lsp); +static int read_token (ase_lsp_t* lsp); +static int read_number (ase_lsp_t* lsp, int negative); +static int read_ident (ase_lsp_t* lsp); +static int read_string (ase_lsp_t* lsp); + +ase_lsp_obj_t* ase_lsp_read (ase_lsp_t* lsp) +{ + if (lsp->curc == ASE_CHAR_EOF && + read_char(lsp) == -1) return ASE_NULL; + + NEXT_TOKEN (lsp); + + lsp->mem->read = read_obj (lsp); + if (lsp->mem->read != ASE_NULL) + ase_lsp_deepunlockobj (lsp, lsp->mem->read); + return lsp->mem->read; +} + +static ase_lsp_obj_t* read_obj (ase_lsp_t* lsp) +{ + ase_lsp_obj_t* obj; + + switch (TOKEN_TYPE(lsp)) + { + case TOKEN_END: + ase_lsp_seterror (lsp, ASE_LSP_EEND, ASE_NULL, 0); + return ASE_NULL; + + case TOKEN_LPAREN: + NEXT_TOKEN (lsp); + return read_list (lsp); + + case TOKEN_QUOTE: + NEXT_TOKEN (lsp); + return read_quote (lsp); + + case TOKEN_INT: + obj = ase_lsp_makeintobj (lsp->mem, TOKEN_IVAL(lsp)); + if (obj == ASE_NULL) return ASE_NULL; + ase_lsp_lockobj (lsp, obj); + return obj; + + case TOKEN_REAL: + obj = ase_lsp_makerealobj (lsp->mem, TOKEN_RVAL(lsp)); + if (obj == ASE_NULL) return ASE_NULL; + ase_lsp_lockobj (lsp, obj); + return obj; + + case TOKEN_STRING: + obj = ase_lsp_makestr ( + lsp->mem, TOKEN_SPTR(lsp), TOKEN_SLEN(lsp)); + if (obj == ASE_NULL) return ASE_NULL; + ase_lsp_lockobj (lsp, obj); + return obj; + + case TOKEN_IDENT: + ASE_ASSERT ( + lsp->mem->nil != ASE_NULL && + lsp->mem->t != ASE_NULL); + + if (TOKEN_COMPARE(lsp,ASE_T("nil")) == 0) + { + obj = lsp->mem->nil; + } + else if (TOKEN_COMPARE(lsp,ASE_T("t")) == 0) + { + obj = lsp->mem->t; + } + else + { + obj = ase_lsp_makesym ( + lsp->mem, + TOKEN_SPTR(lsp), + TOKEN_SLEN(lsp)); + if (obj == ASE_NULL) return ASE_NULL; + ase_lsp_lockobj (lsp, obj); + } + + return obj; + } + + ase_lsp_seterror (lsp, ASE_LSP_ESYNTAX, ASE_NULL, 0); + return ASE_NULL; +} + +static ase_lsp_obj_t* read_list (ase_lsp_t* lsp) +{ + ase_lsp_obj_t* obj; + ase_lsp_obj_cons_t* p, * first = ASE_NULL, * prev = ASE_NULL; + + while (TOKEN_TYPE(lsp) != TOKEN_RPAREN) + { + if (TOKEN_TYPE(lsp) == TOKEN_END) + { + /* unexpected end of input */ + ase_lsp_seterror (lsp, ASE_LSP_ESYNTAX, ASE_NULL, 0); + return ASE_NULL; + } + + if (TOKEN_TYPE(lsp) == TOKEN_DOT) + { + if (prev == ASE_NULL) + { + /* unexpected dot */ + ase_lsp_seterror (lsp, ASE_LSP_ESYNTAX, ASE_NULL, 0); + return ASE_NULL; + } + + NEXT_TOKEN (lsp); + obj = read_obj (lsp); + if (obj == ASE_NULL) + { + if (lsp->errnum == ASE_LSP_EEND) + { + /* unexpected end of input */ + ase_lsp_seterror (lsp, ASE_LSP_ESYNTAX, ASE_NULL, 0); + } + return ASE_NULL; + } + prev->cdr = obj; + + NEXT_TOKEN (lsp); + if (TOKEN_TYPE(lsp) != TOKEN_RPAREN) + { + /* ) expected */ + ase_lsp_seterror (lsp, ASE_LSP_ERPAREN, ASE_NULL, 0); + return ASE_NULL; + } + + break; + } + + obj = read_obj (lsp); + if (obj == ASE_NULL) + { + if (lsp->errnum == ASE_LSP_EEND) + { + /* unexpected end of input */ + ase_lsp_seterror (lsp, ASE_LSP_ESYNTAX, ASE_NULL, 0); + } + return ASE_NULL; + } + + p = (ase_lsp_obj_cons_t*)ase_lsp_makecons ( + lsp->mem, lsp->mem->nil, lsp->mem->nil); + if (p == ASE_NULL) return ASE_NULL; + ase_lsp_lockobj (lsp, (ase_lsp_obj_t*)p); + + if (first == ASE_NULL) first = p; + if (prev != ASE_NULL) prev->cdr = (ase_lsp_obj_t*)p; + + p->car = obj; + prev = p; + + NEXT_TOKEN (lsp); + } + + return (first == ASE_NULL)? lsp->mem->nil: (ase_lsp_obj_t*)first; +} + +static ase_lsp_obj_t* read_quote (ase_lsp_t* lsp) +{ + ase_lsp_obj_t* cons, * tmp; + + tmp = read_obj (lsp); + if (tmp == ASE_NULL) + { + if (lsp->errnum == ASE_LSP_EEND) + { + /* unexpected end of input */ + ase_lsp_seterror (lsp, ASE_LSP_ESYNTAX, ASE_NULL, 0); + } + return ASE_NULL; + } + + cons = ase_lsp_makecons (lsp->mem, tmp, lsp->mem->nil); + if (cons == ASE_NULL) return ASE_NULL; + ase_lsp_lockobj (lsp, cons); + + cons = ase_lsp_makecons (lsp->mem, lsp->mem->quote, cons); + if (cons == ASE_NULL) return ASE_NULL; + ase_lsp_lockobj (lsp, cons); + + return cons; +} + +static int read_char (ase_lsp_t* lsp) +{ + ase_ssize_t n; + ase_char_t c; + + if (lsp->input_func == ASE_NULL) + { + ase_lsp_seterror (lsp, ASE_LSP_ENOINP, ASE_NULL, 0); + return -1; + } + + n = lsp->input_func(ASE_LSP_IO_READ, lsp->input_arg, &c, 1); + if (n == -1) + { + ase_lsp_seterror (lsp, ASE_LSP_EINPUT, ASE_NULL, 0); + return -1; + } + + if (n == 0) lsp->curc = ASE_CHAR_EOF; + else lsp->curc = c; + return 0; +} + +static int read_token (ase_lsp_t* lsp) +{ + ASE_ASSERT (lsp->input_func != ASE_NULL); + + TOKEN_CLEAR (lsp); + + while (1) + { + /* skip white spaces */ + while (ASE_LSP_ISSPACE(lsp, lsp->curc)) NEXT_CHAR (lsp); + + /* skip the comments here */ + if (lsp->curc == ASE_T(';')) + { + do + { + NEXT_CHAR (lsp); + } + while (lsp->curc != ASE_T('\n') && + lsp->curc != ASE_CHAR_EOF); + } + else break; + } + + if (lsp->curc == ASE_CHAR_EOF) + { + TOKEN_TYPE(lsp) = TOKEN_END; + return 0; + } + else if (lsp->curc == ASE_T('(')) + { + TOKEN_ADD_CHAR (lsp, lsp->curc); + TOKEN_TYPE(lsp) = TOKEN_LPAREN; + NEXT_CHAR (lsp); + return 0; + } + else if (lsp->curc == ASE_T(')')) + { + TOKEN_ADD_CHAR (lsp, lsp->curc); + TOKEN_TYPE(lsp) = TOKEN_RPAREN; + NEXT_CHAR (lsp); + return 0; + } + else if (lsp->curc == ASE_T('\'')) + { + TOKEN_ADD_CHAR (lsp, lsp->curc); + TOKEN_TYPE(lsp) = TOKEN_QUOTE; + NEXT_CHAR (lsp); + return 0; + } + else if (lsp->curc == ASE_T('.')) + { + TOKEN_ADD_CHAR (lsp, lsp->curc); + TOKEN_TYPE(lsp) = TOKEN_DOT; + NEXT_CHAR (lsp); + return 0; + } + else if (lsp->curc == ASE_T('-')) + { + TOKEN_ADD_CHAR (lsp, lsp->curc); + NEXT_CHAR (lsp); + if (ASE_LSP_ISDIGIT(lsp,lsp->curc)) + { + return read_number (lsp, 1); + } + else if (IS_IDENT(lsp->curc)) + { + return read_ident (lsp); + } + else + { + TOKEN_TYPE(lsp) = TOKEN_IDENT; + return 0; + } + } + else if (ASE_LSP_ISDIGIT(lsp,lsp->curc)) + { + return read_number (lsp, 0); + } + else if (ASE_LSP_ISALPHA(lsp,lsp->curc) || IS_IDENT(lsp->curc)) + { + return read_ident (lsp); + } + else if (lsp->curc == ASE_T('\"')) + { + return read_string (lsp); + } + + TOKEN_TYPE(lsp) = TOKEN_INVALID; + NEXT_CHAR (lsp); /* consume */ + return 0; +} + +static int read_number (ase_lsp_t* lsp, int negative) +{ + ase_long_t ival = 0; + ase_real_t rval = .0; + + do + { + ival = ival * 10 + (lsp->curc - ASE_T('0')); + TOKEN_ADD_CHAR (lsp, lsp->curc); + NEXT_CHAR (lsp); + } + while (ASE_LSP_ISDIGIT(lsp, lsp->curc)); + +/* TODO: extend parsing floating point number */ + if (lsp->curc == ASE_T('.')) + { + ase_real_t fraction = 0.1; + + NEXT_CHAR (lsp); + rval = (ase_real_t)ival; + + while (ASE_LSP_ISDIGIT(lsp, lsp->curc)) + { + rval += (ase_real_t)(lsp->curc - ASE_T('0')) * fraction; + fraction *= 0.1; + NEXT_CHAR (lsp); + } + + TOKEN_RVAL(lsp) = rval; + TOKEN_TYPE(lsp) = TOKEN_REAL; + if (negative) rval *= -1; + } + else + { + TOKEN_IVAL(lsp) = ival; + TOKEN_TYPE(lsp) = TOKEN_INT; + if (negative) ival *= -1; + } + + return 0; +} + +static int read_ident (ase_lsp_t* lsp) +{ + do + { + TOKEN_ADD_CHAR (lsp, lsp->curc); + NEXT_CHAR (lsp); + } + while (ASE_LSP_ISALNUM(lsp,lsp->curc) || IS_IDENT(lsp->curc)); + TOKEN_TYPE(lsp) = TOKEN_IDENT; + return 0; +} + +static int read_string (ase_lsp_t* lsp) +{ + ase_cint_t c; + int escaped = 0; + int digit_count = 0; + ase_cint_t c_acc = 0; + + while (1) + { + NEXT_CHAR_TO (lsp, c); + + if (c == ASE_CHAR_EOF) + { + ase_lsp_seterror (lsp, ASE_LSP_EENDSTR, ASE_NULL, 0); + return -1; + } + + if (escaped == 3) + { + if (c >= ASE_T('0') && c <= ASE_T('7')) + { + c_acc = c_acc * 8 + c - ASE_T('0'); + digit_count++; + if (digit_count >= escaped) + { + TOKEN_ADD_CHAR (lsp, c_acc); + escaped = 0; + } + continue; + } + else + { + TOKEN_ADD_CHAR (lsp, c_acc); + escaped = 0; + } + } + else if (escaped == 2 || escaped == 4 || escaped == 8) + { + if (c >= ASE_T('0') && c <= ASE_T('9')) + { + c_acc = c_acc * 16 + c - ASE_T('0'); + digit_count++; + if (digit_count >= escaped) + { + TOKEN_ADD_CHAR (lsp, c_acc); + escaped = 0; + } + continue; + } + else if (c >= ASE_T('A') && c <= ASE_T('F')) + { + c_acc = c_acc * 16 + c - ASE_T('A') + 10; + digit_count++; + if (digit_count >= escaped) + { + TOKEN_ADD_CHAR (lsp, c_acc); + escaped = 0; + } + continue; + } + else if (c >= ASE_T('a') && c <= ASE_T('f')) + { + c_acc = c_acc * 16 + c - ASE_T('a') + 10; + digit_count++; + if (digit_count >= escaped) + { + TOKEN_ADD_CHAR (lsp, c_acc); + escaped = 0; + } + continue; + } + else + { + ase_char_t rc; + + rc = (escaped == 2)? ASE_T('x'): + (escaped == 4)? ASE_T('u'): ASE_T('U'); + + if (digit_count == 0) TOKEN_ADD_CHAR (lsp, rc); + else TOKEN_ADD_CHAR (lsp, c_acc); + + escaped = 0; + } + } + + if (escaped == 0 && c == ASE_T('\"')) + { + /* terminating quote */ + /*NEXT_CHAR_TO (lsp, c);*/ + NEXT_CHAR (lsp); + break; + } + + if (escaped == 0 && c == ASE_T('\\')) + { + escaped = 1; + continue; + } + + if (escaped == 1) + { + if (c == ASE_T('n')) c = ASE_T('\n'); + else if (c == ASE_T('r')) c = ASE_T('\r'); + else if (c == ASE_T('t')) c = ASE_T('\t'); + else if (c == ASE_T('f')) c = ASE_T('\f'); + else if (c == ASE_T('b')) c = ASE_T('\b'); + else if (c == ASE_T('v')) c = ASE_T('\v'); + else if (c == ASE_T('a')) c = ASE_T('\a'); + else if (c >= ASE_T('0') && c <= ASE_T('7')) + { + escaped = 3; + digit_count = 1; + c_acc = c - ASE_T('0'); + continue; + } + else if (c == ASE_T('x')) + { + escaped = 2; + digit_count = 0; + c_acc = 0; + continue; + } + #ifdef ASE_CHAR_IS_WCHAR + else if (c == ASE_T('u') && ASE_SIZEOF(ase_char_t) >= 2) + { + escaped = 4; + digit_count = 0; + c_acc = 0; + continue; + } + else if (c == ASE_T('U') && ASE_SIZEOF(ase_char_t) >= 4) + { + escaped = 8; + digit_count = 0; + c_acc = 0; + continue; + } + #endif + + escaped = 0; + } + + TOKEN_ADD_CHAR (lsp, c); + } + + TOKEN_TYPE(lsp) = TOKEN_STRING; + return 0; +} diff --git a/ase/makefile.in b/ase/makefile.in new file mode 100644 index 00000000..ed60b780 --- /dev/null +++ b/ase/makefile.in @@ -0,0 +1,46 @@ +# +# $Id: makefile.in,v 1.3 2007/04/30 05:51:26 bacon Exp $ +# + + +LIBDIRS = cmn utl awk lsp test/awk test/lsp +MODE = @BUILDMODE@ +LIBTOOL_DEPS = @LIBTOOL_DEPS@ + +all: build + +build: + @for i in $(LIBDIRS); \ + do \ + if [ ! -d $$i ]; \ + then \ + echo Error: $$i not a directory; \ + exit 1; \ + fi; \ + saved=`pwd`; cd "$$i"; \ + if make; \ + then \ + echo > /dev/null; \ + else \ + exit 1; \ + fi; \ + cd "$$saved"; \ + done + +clean: + @for i in $(LIBDIRS); \ + do \ + if [ ! -d $$i ]; \ + then \ + echo Error: $$i not a directory; \ + exit 1; \ + fi; \ + saved=`pwd`; cd "$$i"; \ + if make $@; \ + then \ + echo > /dev/null; \ + else \ + exit 1; \ + fi; \ + cd "$$saved"; \ + done diff --git a/ase/net/AssemblyInfo.cpp b/ase/net/AssemblyInfo.cpp new file mode 100644 index 00000000..f857107c --- /dev/null +++ b/ase/net/AssemblyInfo.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute("asenet")]; +[assembly:AssemblyDescriptionAttribute("")]; +[assembly:AssemblyConfigurationAttribute("")]; +[assembly:AssemblyCompanyAttribute("")]; +[assembly:AssemblyProductAttribute("asenet")]; +[assembly:AssemblyCopyrightAttribute("Copyright (c) 2007")]; +[assembly:AssemblyTrademarkAttribute("")]; +[assembly:AssemblyCultureAttribute("")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("1.0.*")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; + +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; diff --git a/ase/net/Stdafx.cpp b/ase/net/Stdafx.cpp new file mode 100644 index 00000000..f3feb62d --- /dev/null +++ b/ase/net/Stdafx.cpp @@ -0,0 +1,5 @@ +// stdafx.cpp : source file that includes just the standard includes +// asenet.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" diff --git a/ase/net/Stdafx.h b/ase/net/Stdafx.h new file mode 100644 index 00000000..3cc4c24e --- /dev/null +++ b/ase/net/Stdafx.h @@ -0,0 +1,7 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, +// but are changed infrequently + +#pragma once + + diff --git a/ase/net/app.ico b/ase/net/app.ico new file mode 100644 index 0000000000000000000000000000000000000000..3a5525fd794f7a7c5c8e6187f470ea3af38cd2b6 GIT binary patch literal 1078 zcmeHHJr05}7=1t!Hp3A*8IHkVf+j?-!eHY14Gtcw1Eb*_9>Bq^zETJ@GKj{_2j4$w zo9}xCh!8{T3=X##Skq>ikMjsvB|y%crWBM2iW(4pI}c%z6%lW!=~4v77#3{z!dmB1 z__&l)-{KUYR+|8|;wB^R|9ET$J@(@=#rd^=)qs85?vAy(PSF5CyNkus435LVkZ$rj zNw|JG-P7^hF<(;#o*Vk}5R#e|^13tBbQkeF?djULtvqyxd3<{9 literal 0 HcmV?d00001 diff --git a/ase/net/app.rc b/ase/net/app.rc new file mode 100644 index 00000000..807aa896 --- /dev/null +++ b/ase/net/app.rc @@ -0,0 +1,63 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon placed first or with lowest ID value becomes application icon + +LANGUAGE 9, 1 +#pragma code_page(1252) +1 ICON "app.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" + "\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/ase/net/asenet.vcproj b/ase/net/asenet.vcproj new file mode 100644 index 00000000..7a13b631 --- /dev/null +++ b/ase/net/asenet.vcproj @@ -0,0 +1,242 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ase/net/resource.h b/ase/net/resource.h new file mode 100644 index 00000000..d5ac7c42 --- /dev/null +++ b/ase/net/resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/ase/rel/doc.awk b/ase/rel/doc.awk new file mode 100644 index 00000000..fc0afbb0 --- /dev/null +++ b/ase/rel/doc.awk @@ -0,0 +1,266 @@ +/* + * $Id: doc.awk,v 1.3 2007/04/30 08:32:40 bacon Exp $ + * + * {License} + */ + +global header, mode; +global empty_line_count; +global para_started; +global list_count; + +func print_text (full) +{ + local fra1, fra2, link, idx, t1, t2; + + gsub ("<", "\\<", full); + gsub (">", "\\>", full); + + while (match (full, /\{[^{},]+,[^{},]+\}/) > 0) + { + fra1 = substr (full, 1, RSTART-1); + link = substr (full, RSTART, RLENGTH); + fra2 = substr (full, RSTART+RLENGTH, length(full)-RLENGTH); + + idx = index(link, ","); + t1 = substr (link, 2, idx-2); + t2 = substr (link, idx+1, length(link)-idx-1); + + full = sprintf ("%s%s%s", fra1, t2, t1, fra2); + } + + while (match (full, /\[\[[^\[\][:space:]]+\]\]/) > 0) + { + fra1 = substr (full, 1, RSTART-1); + link = substr (full, RSTART+2, RLENGTH-4); + fra2 = substr (full, RSTART+RLENGTH, length(full)-RLENGTH); + + full = sprintf ("%s%s%s", fra1, link, fra2); + } + + while (match (full, /##[^#[:space:]]+##/) > 0) + { + fra1 = substr (full, 1, RSTART-1); + link = substr (full, RSTART+2, RLENGTH-4); + fra2 = substr (full, RSTART+RLENGTH, length(full)-RLENGTH); + + full = sprintf ("%s%s%s", fra1, link, fra2); + } + + print full; +} + +BEGIN { + header = 1; + mode = 0; + empty_line_count = 0; + para_started = 0; + + #output=ARGV[0]; + #gsub (/\.man/, ".html", output); + #print "OUTPUT TO: " output; + + print ""; + print ""; + print ""; + print ""; +} + +header && /^\.[[:alpha:]]+[[:space:]]/ { + if ($1 == ".title") + { + local i; + + printf ""; + for (i = 2; i <= NF; i++) printf "%s ", $i; + print ""; + } +} + +header && !/^\.[[:alpha:]]+[[:space:]]/ { + + header = 0; + print ""; + print ""; +} + +!header { + local text; + + if (mode == 0) + { + if (/^$/) + { + # empty line + if (para_started) + { + para_started = 0; + print "

"; + } + empty_line_count++; + } + else + { + if (/^= [^=]+ =$/) + { + if (para_started) + { + print "

"; + para_started = 0; + } + text=substr($0, 2, length($0)-2); + print "

" text "

"; + } + else if (/^== [^=]+ ==$/) + { + if (para_started) + { + print "

"; + para_started = 0; + } + text=substr($0, 3, length($0)-4); + print "

" text "

"; + } + else if (/^=== [^=]+ ===$/) + { + if (para_started) + { + print "

"; + para_started = 0; + } + text=substr($0, 4, length($0)-6); + print "

" text "

"; + } + else if (/^==== [^=]+ ====$/) + { + if (para_started) + { + print "

"; + para_started = 0; + } + text=substr($0, 5, length($0)-8); + print "

" text "

"; + } + else if (/^\{\{\{$/) + { + # {{{ + if (para_started) + { + print "

"; + para_started = 0; + } + print "
";
+				mode = 1;
+			}
+			else if (/\[\[\[/)
+			{
+				if (para_started)
+				{
+					print "

"; + para_started = 0; + } + print "
    "; + mode = 2; + list_count = 0; + } + else if (/\(\(\(/) + { + if (para_started) + { + print "

    "; + para_started = 0; + } + print "
      "; + mode = 3; + list_count = 0; + } + else + { + if (!para_started > 0) + { + print "

      "; + para_started = 1; + } + + /* + gsub ("<", "\\<"); + gsub (">", "\\>"); + print $0; + */ + + print_text ($0); + print "
      "; + } + + empty_line_count = 0; + } + } + else if (mode == 1) + { + if (/^}}}$/) + { + # }}} + print "

"; + mode = 0; + } + else + { + gsub ("<", "\\<"); + gsub (">", "\\>"); + print $0; + } + } + else if (mode == 2) + { + if (/^]]]$/) + { + # ]]] + print ""; + print ""; + mode = 0; + } + else if (/^\* [^[:space:]]+/) + { + gsub ("<", "\\<"); + gsub (">", "\\>"); + if (list_count > 0) print ""; + print "
  • "; + + print_text (substr ($0, 3, length($0)-2)); + list_count++; + } + else + { + print_text ($0); + } + } + else if (mode == 3) + { + if (/^\)\)\)$/) + { + # ))) + print "
  • "; + print ""; + mode = 0; + } + else if (/^\* [^[:space:]]+/) + { + gsub ("<", "\\<"); + gsub (">", "\\>"); + if (list_count > 0) print ""; + print "
  • "; + + print_text (substr ($0, 3, length($0)-2)); + list_count++; + } + else + { + print_text ($0); + } + } +} + +END { + print ""; + print ""; +} diff --git a/ase/rel/lic.awk b/ase/rel/lic.awk new file mode 100644 index 00000000..a020770e --- /dev/null +++ b/ase/rel/lic.awk @@ -0,0 +1,21 @@ +/* + * $Id: lic.awk,v 1.3 2007/04/30 08:32:40 bacon Exp $ + * + * {License} + */ + +NR == 1 { + new_file = ARGV[0]; + printf "" > new_file; /* clear the file */ +} + +/^ \* \{License\}/ { + print " * Copyright (c) 2007, Hyung-Hwan Chung." >> new_file; + print " * All rights reserved." >> new_file; + print " * Licensed under the BSD license: " >> new_file; + print " * http://www.abiyo.net/ase/license.html" >> new_file; +} + +!/^ \* \{License\}/ { + print $0 >> new_file; +} diff --git a/ase/rel/rel.sh b/ase/rel/rel.sh new file mode 100755 index 00000000..e09c4d6c --- /dev/null +++ b/ase/rel/rel.sh @@ -0,0 +1,144 @@ +#!/bin/sh + +finalize () +{ + cur="$1"; dir="$2"; + + if [ "$dir" = "" ] + then + cd "$BASE" + else + cd "$BASE/$dir" + fi + + for i in * + do + if [ "$i" = "*" ]; then continue; fi + if [ "$i" = "CVS" ]; then continue; fi + if [ "$i" = "stx" ]; then continue; fi + + if [ "$cur" = "" ] + then + file="$i" + full="$BASE/$i" + else + file="$cur/$i" + full="$BASE/$cur/$i" + fi + + if [ -d "$full" ] + then + if [ "$dir" = "" ] + then + new="$i" + else + new="$dir/$i" + fi + + finalize "$file" "$new" + cur="$1"; dir="$2"; + elif [ -f "$full" ] + then + target="$SOURCE_ROOT/ase" + mkdir -p "$target/$cur" + + case "$i" in + *.h|*.c|*.cc|*.cpp|*.java|*.awk|*.in) + "$ASEAWK" -f "$BASE/rel/lic.awk" -a "$target/$file" "$full" + ;; + *.man) + html=`echo $i | sed 's/.man$/.html/'` + "$ASEAWK" -f "$BASE/rel/doc.awk" "$full" > "$SOURCE_ROOT/html/$html" + "$ASEAWK" -f "$BASE/rel/doc.awk" "$full" > "$ASETGT/$html" + cp -f "$full" "$target/$file" + ;; + *.css) + cp -f "$full" "$target/$file" + cp -f "$full" "$SOURCE_ROOT/html/$i" + cp -f "$full" "$ASETGT/$i" + ;; + *.dsp|*.dsw|*.sln|*.vcproj|*.csproj|*.bat|*.cmd) + "$ASEAWK" -f "$BASE/rel/unix2dos.awk" "$full" > "$target/$file" + ;; + descrip.mms) + "$ASEAWK" -f "$BASE/rel/unix2dos.awk" "$full" > "$target/$file" + ;; + *.frx) + cp -f "$full" "$target/$file" + ;; + *) + if [ "$dir" = "test/com" ] + then + "$ASEAWK" -f "$BASE/rel/unix2dos.awk" "$full" > "$target/$file" + else + cp -f "$full" "$target/$file" + fi + ;; + esac + fi + done +} + + +print_usage () +{ + echo "Usage: $0 awk version target archiver" + echo "where awk := full path to aseawk" + echo " version := any string" + echo " target := full path to the target directory" + echo " archiver := gzip | zip" +} + +############################ +# BEGINNING OF THE PROGRAM # +############################ + +if [ $# -ne 4 ] +then + print_usage "$0" + exit 1 +fi + +if [ "$4" != "gzip" -a "$4" != "zip" ] +then + print_usage "$0" + exit 1 +fi + +ASEAWK="$1" +ASEVER="$2" +ASETGT="$3" +ASEARC="$4" + +CURDIR=`pwd` +cd ".." +BASE=`pwd` + +SOURCE_ROOT="$ASETGT/ase-$ASEVER" + +rm -rf "$ASETGT" +mkdir -p "$ASETGT" +mkdir -p "$SOURCE_ROOT" +mkdir -p "$SOURCE_ROOT/html" + +finalize "" "" + +cd "$ASETGT" + +if [ "$ASEARC" = "gzip" ] +then + tar -cvf "ase-$ASEVER.tar" "ase-$ASEVER" + gzip "ase-$ASEVER.tar" + mv "ase-$ASEVER.tar.gz" "ase-$ASEVER.tgz" +elif [ "$ASEARC" = "zip" ] +then + ls -l + echo zip -r "ase-$ASEVER" "ase-$ASEVER" + zip -r ase "ase-$ASEVER" + mv -f ase.zip "ase-$ASEVER.zip" +fi + +rm -rf "ase-$ASEVER" + +cd "$CURDIR" +exit 0 diff --git a/ase/rel/unix2dos.awk b/ase/rel/unix2dos.awk new file mode 100644 index 00000000..b8a6e3ef --- /dev/null +++ b/ase/rel/unix2dos.awk @@ -0,0 +1,2 @@ +BEGIN { ORS="\r\n"; } +{ print $0; } diff --git a/ase/stx/array.c b/ase/stx/array.c new file mode 100644 index 00000000..418d30c2 --- /dev/null +++ b/ase/stx/array.c @@ -0,0 +1,18 @@ +/* + * $Id: array.c,v 1.3 2007/04/30 08:32:40 bacon Exp $ + */ + +#include +#include +#include + +ase_word_t ase_stx_new_array (ase_stx_t* stx, ase_word_t size) +{ + ase_word_t x; + + ase_assert (stx->class_array != stx->nil); + x = ase_stx_alloc_word_object (stx, ASE_NULL, 0, ASE_NULL, size); + ASE_STX_CLASS(stx,x) = stx->class_array; + + return x; +} diff --git a/ase/stx/array.h b/ase/stx/array.h new file mode 100644 index 00000000..5ca70c09 --- /dev/null +++ b/ase/stx/array.h @@ -0,0 +1,21 @@ +/* + * $Id: array.h,v 1.3 2007/04/30 08:32:40 bacon Exp $ + */ + +#ifndef _ASE_STX_ARRAY_H_ +#define _ASE_STX_ARRAY_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +ase_word_t ase_stx_new_array (ase_stx_t* stx, ase_word_t size); + +#ifdef __cplusplus +} +#endif + + +#endif diff --git a/ase/stx/bootstrp.c b/ase/stx/bootstrp.c new file mode 100644 index 00000000..16423020 --- /dev/null +++ b/ase/stx/bootstrp.c @@ -0,0 +1,676 @@ +/* + * $Id: bootstrp.c,v 1.3 2007/04/30 08:32:40 bacon Exp $ + */ + +#include +#include +#include +#include +#include +#include + +static void __create_bootstrapping_objects (ase_stx_t* stx); +static void __create_builtin_classes (ase_stx_t* stx); +static ase_word_t __make_classvar_dict ( + ase_stx_t* stx, ase_word_t class, const ase_char_t* names); +static void __filein_kernel (ase_stx_t* stx); + +static ase_word_t __count_names (const ase_char_t* str); +static void __set_names ( + ase_stx_t* stx, ase_word_t* array, const ase_char_t* str); + +static ase_word_t __count_subclasses (const ase_char_t* str); +static void __set_subclasses ( + ase_stx_t* stx, ase_word_t* array, const ase_char_t* str); +static void __set_metaclass_subclasses ( + ase_stx_t* stx, ase_word_t* array, const ase_char_t* str); + +struct class_info_t +{ + const ase_char_t* name; + const ase_char_t* superclass; + const ase_char_t* instance_variables; + const ase_char_t* class_variables; + const ase_char_t* pool_dictionaries; + const int indexable; +}; + +typedef struct class_info_t class_info_t; + +static class_info_t class_info[] = +{ + { + ASE_T("Object"), + ASE_NULL, + ASE_NULL, + ASE_NULL, + ASE_NULL, + ASE_STX_SPEC_NOT_INDEXABLE + }, + { + ASE_T("UndefinedObject"), + ASE_T("Object"), + ASE_NULL, + ASE_NULL, + ASE_NULL, + ASE_STX_SPEC_NOT_INDEXABLE + }, + { + ASE_T("Behavior"), + ASE_T("Object"), + ASE_T("spec methods superclass"), + ASE_NULL, + ASE_NULL, + ASE_STX_SPEC_NOT_INDEXABLE + }, + { + ASE_T("Class"), + ASE_T("Behavior"), + ASE_T("name variables classVariables poolDictionaries"), + ASE_NULL, + ASE_NULL, + ASE_STX_SPEC_NOT_INDEXABLE + }, + { + ASE_T("Metaclass"), + ASE_T("Behavior"), + ASE_T("instanceClass"), + ASE_NULL, + ASE_NULL, + ASE_STX_SPEC_NOT_INDEXABLE + }, + { + ASE_T("Block"), + ASE_T("Object"), + ASE_T("context argCount argLoc bytePointer"), + ASE_NULL, + ASE_NULL, + ASE_STX_SPEC_NOT_INDEXABLE + }, + { + ASE_T("Boolean"), + ASE_T("Object"), + ASE_NULL, + ASE_NULL, + ASE_NULL, + ASE_STX_SPEC_NOT_INDEXABLE + }, + { + ASE_T("True"), + ASE_T("Boolean"), + ASE_NULL, + ASE_NULL, + ASE_NULL, + ASE_STX_SPEC_NOT_INDEXABLE + }, + { + ASE_T("False"), + ASE_T("Boolean"), + ASE_NULL, + ASE_NULL, + ASE_NULL, + ASE_STX_SPEC_NOT_INDEXABLE + }, + { + ASE_T("Context"), + ASE_T("Object"), + ASE_T("stack stackTop receiver pc method"), + ASE_NULL, + ASE_NULL, + ASE_STX_SPEC_NOT_INDEXABLE + }, + { + ASE_T("Method"), + ASE_T("Object"), + ASE_T("text selector bytecodes tmpCount argCount"), + ASE_NULL, + ASE_NULL, + ASE_STX_SPEC_WORD_INDEXABLE + }, + { + ASE_T("Magnitude"), + ASE_T("Object"), + ASE_NULL, + ASE_NULL, + ASE_NULL, + ASE_STX_SPEC_NOT_INDEXABLE + }, + { + ASE_T("Association"), + ASE_T("Magnitude"), + ASE_T("key value"), + ASE_NULL, + ASE_NULL, + ASE_STX_SPEC_NOT_INDEXABLE + }, + { + ASE_T("Character"), + ASE_T("Magnitude"), + ASE_T("value"), + ASE_NULL, + ASE_NULL, + ASE_STX_SPEC_NOT_INDEXABLE + }, + { + ASE_T("Number"), + ASE_T("Magnitude"), + ASE_NULL, + ASE_NULL, + ASE_NULL, + ASE_STX_SPEC_NOT_INDEXABLE + }, + { + ASE_T("Integer"), + ASE_T("Number"), + ASE_NULL, + ASE_NULL, + ASE_NULL, + ASE_STX_SPEC_NOT_INDEXABLE + }, + { + ASE_T("SmallInteger"), + ASE_T("Integer"), + ASE_NULL, + ASE_NULL, + ASE_NULL, + ASE_STX_SPEC_NOT_INDEXABLE + }, + { + ASE_T("LargeInteger"), + ASE_T("Integer"), + ASE_NULL, + ASE_NULL, + ASE_NULL, + ASE_STX_SPEC_BYTE_INDEXABLE + }, + { + ASE_T("Collection"), + ASE_T("Magnitude"), + ASE_NULL, + ASE_NULL, + ASE_NULL, + ASE_STX_SPEC_NOT_INDEXABLE + }, + { + ASE_T("IndexedCollection"), + ASE_T("Collection"), + ASE_NULL, + ASE_NULL, + ASE_NULL, + ASE_STX_SPEC_NOT_INDEXABLE + }, + { + ASE_T("Array"), + ASE_T("IndexedCollection"), + ASE_NULL, + ASE_NULL, + ASE_NULL, + ASE_STX_SPEC_WORD_INDEXABLE + }, + { + ASE_T("ByteArray"), + ASE_T("IndexedCollection"), + ASE_NULL, + ASE_NULL, + ASE_NULL, + ASE_STX_SPEC_BYTE_INDEXABLE + }, + { + ASE_T("Dictionary"), + ASE_T("IndexedCollection"), + ASE_T("tally"), + ASE_NULL, + ASE_NULL, + ASE_STX_SPEC_WORD_INDEXABLE + }, + { + ASE_T("SystemDictionary"), + ASE_T("Dictionary"), + ASE_NULL, + ASE_NULL, + ASE_NULL, + ASE_STX_SPEC_WORD_INDEXABLE + }, + { + ASE_T("PoolDictionary"), + ASE_T("Dictionary"), + ASE_NULL, + ASE_NULL, + ASE_NULL, + ASE_STX_SPEC_WORD_INDEXABLE + }, + { + ASE_T("String"), + ASE_T("IndexedCollection"), + ASE_NULL, + ASE_NULL, + ASE_NULL, + ASE_STX_SPEC_CHAR_INDEXABLE + }, + { + ASE_T("Symbol"), + ASE_T("String"), + ASE_NULL, + ASE_NULL, + ASE_NULL, + ASE_STX_SPEC_CHAR_INDEXABLE + }, + { + ASE_T("Link"), + ASE_T("Object"), + ASE_T("link"), + ASE_NULL, + ASE_NULL, + ASE_STX_SPEC_NOT_INDEXABLE + }, + { + ASE_NULL, + ASE_NULL, + ASE_NULL, + ASE_NULL, + ASE_NULL, + ASE_STX_SPEC_NOT_INDEXABLE + } +}; + +ase_word_t INLINE __new_string (ase_stx_t* stx, const ase_char_t* str) +{ + ase_word_t x; + + ase_assert (stx->class_string != stx->nil); + x = ase_stx_alloc_char_object (stx, str); + ASE_STX_CLASS(stx,x) = stx->class_string; + + return x; +} + +int ase_stx_bootstrap (ase_stx_t* stx) +{ + ase_word_t symbol_Smalltalk; + ase_word_t object_meta; + + __create_bootstrapping_objects (stx); + + /* object, class, and array are precreated for easier instantiation + * of builtin classes */ + stx->class_object = ase_stx_new_class (stx, ASE_T("Object")); + stx->class_class = ase_stx_new_class (stx, ASE_T("Class")); + stx->class_array = ase_stx_new_class (stx, ASE_T("Array")); + stx->class_bytearray = ase_stx_new_class (stx, ASE_T("ByteArray")); + stx->class_string = ase_stx_new_class (stx, ASE_T("String")); + stx->class_character = ase_stx_new_class (stx, ASE_T("Character")); + stx->class_context = ase_stx_new_class (stx, ASE_T("Context")); + stx->class_system_dictionary = + ase_stx_new_class (stx, ASE_T("SystemDictionary")); + stx->class_method = + ase_stx_new_class (stx, ASE_T("Method")); + stx->class_smallinteger = + ase_stx_new_class (stx, ASE_T("SmallInteger")); + + __create_builtin_classes (stx); + + /* (Object class) setSuperclass: Class */ + object_meta = ASE_STX_CLASS(stx,stx->class_object); + ASE_STX_WORD_AT(stx,object_meta,ASE_STX_METACLASS_SUPERCLASS) = stx->class_class; + /* instance class for Object is set here as it is not + * set in __create_builtin_classes */ + ASE_STX_WORD_AT(stx,object_meta,ASE_STX_METACLASS_INSTANCE_CLASS) = stx->class_object; + + /* for some fun here */ + { + ase_word_t array; + array = ase_stx_new_array (stx, 1); + ASE_STX_WORD_AT(stx,array,0) = object_meta; + ASE_STX_WORD_AT(stx,stx->class_class,ASE_STX_CLASS_SUBCLASSES) = array; + } + + /* more initialization */ + ASE_STX_CLASS(stx,stx->smalltalk) = stx->class_system_dictionary; + + symbol_Smalltalk = ase_stx_new_symbol (stx, ASE_T("Smalltalk")); + ase_stx_dict_put (stx, stx->smalltalk, symbol_Smalltalk, stx->smalltalk); + + /* create #nil, #true, #false */ + ase_stx_new_symbol (stx, ASE_T("nil")); + ase_stx_new_symbol (stx, ASE_T("true")); + ase_stx_new_symbol (stx, ASE_T("false")); + + /* nil setClass: UndefinedObject */ + ASE_STX_CLASS(stx,stx->nil) = + ase_stx_lookup_class(stx, ASE_T("UndefinedObject")); + /* true setClass: True */ + ASE_STX_CLASS(stx,stx->true) = + ase_stx_lookup_class (stx, ASE_T("True")); + /* fales setClass: False */ + ASE_STX_CLASS(stx,stx->false) = + ase_stx_lookup_class (stx, ASE_T("False")); + + __filein_kernel (stx); + return 0; +} + +static void __create_bootstrapping_objects (ase_stx_t* stx) +{ + ase_word_t class_SymbolMeta; + ase_word_t class_MetaclassMeta; + ase_word_t class_AssociationMeta; + ase_word_t symbol_Symbol; + ase_word_t symbol_Metaclass; + ase_word_t symbol_Association; + + /* allocate three keyword objects */ + stx->nil = ase_stx_alloc_word_object (stx, ASE_NULL, 0, ASE_NULL, 0); + stx->true = ase_stx_alloc_word_object (stx, ASE_NULL, 0, ASE_NULL, 0); + stx->false = ase_stx_alloc_word_object (stx, ASE_NULL, 0, ASE_NULL, 0); + + ase_assert (stx->nil == ASE_STX_NIL); + ase_assert (stx->true == ASE_STX_TRUE); + ase_assert (stx->false == ASE_STX_FALSE); + + /* system dictionary */ + /* TODO: dictionary size */ + stx->smalltalk = ase_stx_alloc_word_object ( + stx, ASE_NULL, 1, ASE_NULL, 256); + /* set tally */ + ASE_STX_WORD_AT(stx,stx->smalltalk,0) = ASE_STX_TO_SMALLINT(0); + + /* Symbol */ + stx->class_symbol = ase_stx_alloc_word_object( + stx, ASE_NULL, ASE_STX_CLASS_SIZE, ASE_NULL, 0); + /* Metaclass */ + stx->class_metaclass = ase_stx_alloc_word_object( + stx, ASE_NULL, ASE_STX_CLASS_SIZE, ASE_NULL, 0); + /* Association */ + stx->class_association = ase_stx_alloc_word_object( + stx, ASE_NULL, ASE_STX_CLASS_SIZE, ASE_NULL, 0); + + /* Metaclass is a class so it has the same structure + * as a normal class. "Metaclass class" is an instance of + * Metaclass. */ + + /* Symbol class */ + class_SymbolMeta = ase_stx_alloc_word_object( + stx, ASE_NULL, ASE_STX_METACLASS_SIZE, ASE_NULL, 0); + /* Metaclass class */ + class_MetaclassMeta = ase_stx_alloc_word_object( + stx, ASE_NULL, ASE_STX_METACLASS_SIZE, ASE_NULL, 0); + /* Association class */ + class_AssociationMeta = ase_stx_alloc_word_object( + stx, ASE_NULL, ASE_STX_METACLASS_SIZE, ASE_NULL, 0); + + /* (Symbol class) setClass: Metaclass */ + ASE_STX_CLASS(stx,class_SymbolMeta) = stx->class_metaclass; + /* (Metaclass class) setClass: Metaclass */ + ASE_STX_CLASS(stx,class_MetaclassMeta) = stx->class_metaclass; + /* (Association class) setClass: Metaclass */ + ASE_STX_CLASS(stx,class_AssociationMeta) = stx->class_metaclass; + + /* Symbol setClass: (Symbol class) */ + ASE_STX_CLASS(stx,stx->class_symbol) = class_SymbolMeta; + /* Metaclass setClass: (Metaclass class) */ + ASE_STX_CLASS(stx,stx->class_metaclass) = class_MetaclassMeta; + /* Association setClass: (Association class) */ + ASE_STX_CLASS(stx,stx->class_association) = class_AssociationMeta; + + /* (Symbol class) setSpec: CLASS_SIZE */ + ASE_STX_WORD_AT(stx,class_SymbolMeta,ASE_STX_CLASS_SPEC) = + ASE_STX_TO_SMALLINT((ASE_STX_CLASS_SIZE << ASE_STX_SPEC_INDEXABLE_BITS) | ASE_STX_SPEC_NOT_INDEXABLE); + /* (Metaclass class) setSpec: CLASS_SIZE */ + ASE_STX_WORD_AT(stx,class_MetaclassMeta,ASE_STX_CLASS_SPEC) = + ASE_STX_TO_SMALLINT((ASE_STX_CLASS_SIZE << ASE_STX_SPEC_INDEXABLE_BITS) | ASE_STX_SPEC_NOT_INDEXABLE); + /* (Association class) setSpec: CLASS_SIZE */ + ASE_STX_WORD_AT(stx,class_AssociationMeta,ASE_STX_CLASS_SPEC) = + ASE_STX_TO_SMALLINT((ASE_STX_CLASS_SIZE << ASE_STX_SPEC_INDEXABLE_BITS) | ASE_STX_SPEC_NOT_INDEXABLE); + + /* specs for class_metaclass, class_association, + * class_symbol are set later in __create_builtin_classes */ + + /* #Symbol */ + symbol_Symbol = ase_stx_new_symbol (stx, ASE_T("Symbol")); + /* #Metaclass */ + symbol_Metaclass = ase_stx_new_symbol (stx, ASE_T("Metaclass")); + /* #Association */ + symbol_Association = ase_stx_new_symbol (stx, ASE_T("Association")); + + /* Symbol setName: #Symbol */ + ASE_STX_WORD_AT(stx,stx->class_symbol,ASE_STX_CLASS_NAME) = symbol_Symbol; + /* Metaclass setName: #Metaclass */ + ASE_STX_WORD_AT(stx,stx->class_metaclass,ASE_STX_CLASS_NAME) = symbol_Metaclass; + /* Association setName: #Association */ + ASE_STX_WORD_AT(stx,stx->class_association,ASE_STX_CLASS_NAME) = symbol_Association; + + /* register class names into the system dictionary */ + ase_stx_dict_put (stx, + stx->smalltalk, symbol_Symbol, stx->class_symbol); + ase_stx_dict_put (stx, + stx->smalltalk, symbol_Metaclass, stx->class_metaclass); + ase_stx_dict_put (stx, + stx->smalltalk, symbol_Association, stx->class_association); +} + +static void __create_builtin_classes (ase_stx_t* stx) +{ + class_info_t* p; + ase_word_t class, superclass, array; + ase_stx_class_t* class_obj, * superclass_obj; + ase_word_t metaclass; + ase_stx_metaclass_t* metaclass_obj; + ase_word_t n, nfields; + + ase_assert (stx->class_array != stx->nil); + + for (p = class_info; p->name != ASE_NULL; p++) { + class = ase_stx_lookup_class(stx, p->name); + if (class == stx->nil) { + class = ase_stx_new_class (stx, p->name); + } + + ase_assert (class != stx->nil); + class_obj = (ase_stx_class_t*)ASE_STX_OBJECT(stx, class); + class_obj->superclass = (p->superclass == ASE_NULL)? + stx->nil: ase_stx_lookup_class(stx,p->superclass); + + nfields = 0; + if (p->superclass != ASE_NULL) { + ase_word_t meta; + ase_stx_metaclass_t* meta_obj; + + superclass = ase_stx_lookup_class(stx,p->superclass); + ase_assert (superclass != stx->nil); + + meta = class_obj->header.class; + meta_obj = (ase_stx_metaclass_t*)ASE_STX_OBJECT(stx,meta); + meta_obj->superclass = ASE_STX_CLASS(stx,superclass); + meta_obj->instance_class = class; + + while (superclass != stx->nil) { + superclass_obj = (ase_stx_class_t*) + ASE_STX_OBJECT(stx,superclass); + nfields += + ASE_STX_FROM_SMALLINT(superclass_obj->spec) >> + ASE_STX_SPEC_INDEXABLE_BITS; + superclass = superclass_obj->superclass; + } + + } + + if (p->instance_variables != ASE_NULL) { + nfields += __count_names (p->instance_variables); + class_obj->variables = + __new_string (stx, p->instance_variables); + } + + ase_assert (nfields <= 0 || (nfields > 0 && + (p->indexable == ASE_STX_SPEC_NOT_INDEXABLE || + p->indexable == ASE_STX_SPEC_WORD_INDEXABLE))); + + class_obj->spec = ASE_STX_TO_SMALLINT( + (nfields << ASE_STX_SPEC_INDEXABLE_BITS) | p->indexable); + } + + for (p = class_info; p->name != ASE_NULL; p++) { + class = ase_stx_lookup_class(stx, p->name); + ase_assert (class != stx->nil); + + class_obj = (ase_stx_class_t*)ASE_STX_OBJECT(stx, class); + + if (p->class_variables != ASE_NULL) { + class_obj->class_variables = + __make_classvar_dict(stx, class, p->class_variables); + } + + /* + TODO: + if (p->pool_dictionaries != ASE_NULL) { + class_obj->pool_dictionaries = + __make_pool_dictionary(stx, class, p->pool_dictionaries); + } + */ + } + + /* fill subclasses */ + for (p = class_info; p->name != ASE_NULL; p++) { + n = __count_subclasses (p->name); + array = ase_stx_new_array (stx, n); + __set_subclasses (stx, ASE_STX_DATA(stx,array), p->name); + + class = ase_stx_lookup_class(stx, p->name); + ase_assert (class != stx->nil); + class_obj = (ase_stx_class_t*)ASE_STX_OBJECT(stx, class); + class_obj->subclasses = array; + } + + /* fill subclasses for metaclasses */ + for (p = class_info; p->name != ASE_NULL; p++) { + n = __count_subclasses (p->name); + array = ase_stx_new_array (stx, n); + __set_metaclass_subclasses (stx, ASE_STX_DATA(stx,array), p->name); + + class = ase_stx_lookup_class(stx, p->name); + ase_assert (class != stx->nil); + metaclass = ASE_STX_CLASS(stx,class); + metaclass_obj = (ase_stx_metaclass_t*)ASE_STX_OBJECT(stx, metaclass); + metaclass_obj->subclasses = array; + } +} + +static ase_word_t __count_names (const ase_char_t* str) +{ + ase_word_t n = 0; + const ase_char_t* p = str; + + do { + while (*p == ASE_T(' ') || + *p == ASE_T('\t')) p++; + if (*p == ASE_T('\0')) break; + + n++; + while (*p != ASE_T(' ') && + *p != ASE_T('\t') && + *p != ASE_T('\0')) p++; + } while (1); + + return n; +} + +static void __set_names ( + ase_stx_t* stx, ase_word_t* array, const ase_char_t* str) +{ + ase_word_t n = 0; + const ase_char_t* p = str; + const ase_char_t* name; + + do { + while (*p == ASE_T(' ') || + *p == ASE_T('\t')) p++; + if (*p == ASE_T('\0')) break; + + name = p; + while (*p != ASE_T(' ') && + *p != ASE_T('\t') && + *p != ASE_T('\0')) p++; + + array[n++] = ase_stx_new_symbolx (stx, name, p - name); + } while (1); +} + +static ase_word_t __count_subclasses (const ase_char_t* str) +{ + class_info_t* p; + ase_word_t n = 0; + + for (p = class_info; p->name != ASE_NULL; p++) { + if (p->superclass == ASE_NULL) continue; + if (ase_strcmp (str, p->superclass) == 0) n++; + } + + return n; +} + +static void __set_subclasses ( + ase_stx_t* stx, ase_word_t* array, const ase_char_t* str) +{ + class_info_t* p; + ase_word_t n = 0, class; + + for (p = class_info; p->name != ASE_NULL; p++) { + if (p->superclass == ASE_NULL) continue; + if (ase_strcmp (str, p->superclass) != 0) continue; + class = ase_stx_lookup_class (stx, p->name); + ase_assert (class != stx->nil); + array[n++] = class; + } +} + +static void __set_metaclass_subclasses ( + ase_stx_t* stx, ase_word_t* array, const ase_char_t* str) +{ + class_info_t* p; + ase_word_t n = 0, class; + + for (p = class_info; p->name != ASE_NULL; p++) { + if (p->superclass == ASE_NULL) continue; + if (ase_strcmp (str, p->superclass) != 0) continue; + class = ase_stx_lookup_class (stx, p->name); + ase_assert (class != stx->nil); + array[n++] = ASE_STX_CLASS(stx,class); + } +} + +static ase_word_t __make_classvar_dict ( + ase_stx_t* stx, ase_word_t class, const ase_char_t* names) +{ + ase_word_t dict, symbol; + const ase_char_t* p = names; + const ase_char_t* name; + + dict = ase_stx_instantiate ( + stx, stx->class_system_dictionary, + ASE_NULL, ASE_NULL, __count_names(names)); + + do { + while (*p == ASE_T(' ') || + *p == ASE_T('\t')) p++; + if (*p == ASE_T('\0')) break; + + name = p; + while (*p != ASE_T(' ') && + *p != ASE_T('\t') && + *p != ASE_T('\0')) p++; + + symbol = ase_stx_new_symbolx (stx, name, p - name); + ase_stx_dict_put (stx, dict, symbol, stx->nil); + } while (1); + + return dict; +} + +static void __filein_kernel (ase_stx_t* stx) +{ + class_info_t* p; + + for (p = class_info; p->name != ASE_NULL; p++) { + /* TODO: */ + } +} + diff --git a/ase/stx/bootstrp.h b/ase/stx/bootstrp.h new file mode 100644 index 00000000..d8ce359b --- /dev/null +++ b/ase/stx/bootstrp.h @@ -0,0 +1,21 @@ +/* + * $Id: bootstrp.h,v 1.3 2007/04/30 08:32:40 bacon Exp $ + */ + +#ifndef _ASE_STX_BOOTSTRP_H_ +#define _ASE_STX_BOOTSTRP_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +ase_word_t ase_stx_new_array (ase_stx_t* stx, ase_word_t size); +int ase_stx_bootstrap (ase_stx_t* stx); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ase/stx/bytecode.c b/ase/stx/bytecode.c new file mode 100644 index 00000000..c16654c2 --- /dev/null +++ b/ase/stx/bytecode.c @@ -0,0 +1,193 @@ +/* + * $Id: bytecode.c,v 1.3 2007/04/30 08:32:40 bacon Exp $ + */ +#include +#include +#include +#include + +static void __decode1 (ase_stx_t* stx, ase_word_t idx, void* data); +static int __decode2 (ase_stx_t* stx, + ase_stx_class_t* class_obj, ase_stx_method_t* method_obj); + +int ase_stx_decode (ase_stx_t* stx, ase_word_t class) +{ + ase_stx_class_t* class_obj; + + class_obj = (ase_stx_class_t*)ASE_STX_OBJECT(stx, class); + if (class_obj->methods == stx->nil) return 0; + +/* TODO */ + ase_stx_dict_traverse (stx, class_obj->methods, __decode1, class_obj); + return 0; +} + +#include +static void __dump_object (ase_stx_t* stx, ase_word_t obj) +{ + if (ASE_STX_IS_SMALLINT(obj)) { + ase_printf (ASE_T("%d"), ASE_STX_FROM_SMALLINT(obj)); + } + else if (ASE_STX_CLASS(stx,obj) == stx->class_character) { + ase_printf (ASE_T("$%c"), ASE_STX_WORD_AT(stx,obj,0)); + } + else if (ASE_STX_CLASS(stx,obj) == stx->class_string) { + ase_printf (ASE_T("'%s'"), ASE_STX_DATA(stx,obj)); + } + else if (ASE_STX_CLASS(stx,obj) == stx->class_symbol) { + ase_printf (ASE_T("#%s"), ASE_STX_DATA(stx,obj)); + } + else if (ASE_STX_IS_CHAR_OBJECT(stx, obj)) { + ase_printf (ASE_T("unknow char object [%s]"), ASE_STX_DATA(stx,obj)); + } + else if (ASE_STX_IS_BYTE_OBJECT(stx, obj)) { + ase_printf (ASE_T("unknown byte object"), ASE_STX_DATA(stx,obj)); + } + else if (ASE_STX_IS_WORD_OBJECT(stx, obj)) { + ase_printf (ASE_T("unknown word object"), ASE_STX_DATA(stx,obj)); + } + else { + ase_printf (ASE_T("invalid object type")); + } +} + +static void __decode1 (ase_stx_t* stx, ase_word_t idx, void* data) +{ + ase_stx_method_t* method_obj; + ase_stx_class_t* class_obj; + ase_word_t key = ASE_STX_WORD_AT(stx,idx,ASE_STX_ASSOCIATION_KEY); + ase_word_t value = ASE_STX_WORD_AT(stx,idx,ASE_STX_ASSOCIATION_VALUE); + ase_word_t* literals; + ase_word_t literal_count, i; + + ase_word_t method_class; + ase_stx_class_t* method_class_obj; + + class_obj = (ase_stx_class_t*)data; + + ase_printf (ASE_T("* Method: %s\n"), ASE_STX_DATA(stx, key)); + method_obj = (ase_stx_method_t*)ASE_STX_OBJECT(stx, value); + + literals = method_obj->literals; + /* + literal_count = ASE_STX_SIZE(stx, value) - + (ASE_STX_FROM_SMALLINT(class_obj->spec) >> ASE_STX_SPEC_INDEXABLE_BITS); + */ + method_class = ASE_STX_CLASS(stx,value); + method_class_obj = ASE_STX_OBJECT(stx, method_class); + literal_count = ASE_STX_SIZE(stx,value) - + (ASE_STX_FROM_SMALLINT(method_class_obj->spec) >> ASE_STX_SPEC_INDEXABLE_BITS); + + ase_printf (ASE_T("* Literal Count: %d, Temporary Count: %d, Argument Count: %d\n"), + literal_count, + ASE_STX_FROM_SMALLINT(method_obj->tmpcount), + ASE_STX_FROM_SMALLINT(method_obj->argcount)); + for (i = 0; i < literal_count; i++) { + ase_printf (ASE_T("%d. ["), i); + __dump_object (stx, literals[i]); + ase_printf (ASE_T("]\n")); + } + __decode2 (stx, data, method_obj); +} + +static int __decode2 (ase_stx_t* stx, + ase_stx_class_t* class_obj, ase_stx_method_t* method_obj) +{ + ase_stx_byte_object_t* bytecodes; + ase_word_t bytecode_size, pc = 0; + int code, next, next2; + + static const ase_char_t* stack_opcode_names[] = + { + ASE_T("push_receiver_variable"), + ASE_T("push_temporary_location"), + ASE_T("push_literal_constant"), + ASE_T("push_literal_variable"), + ASE_T("store_receiver_variable"), + ASE_T("store_temporary_location") + }; + + static const ase_char_t* send_opcode_names[] = + { + ASE_T("send_to_self"), + ASE_T("send_to_super") + }; + + static const ase_char_t* stack_special_opcode_names[] = + { + ASE_T("pop_stack_top"), + ASE_T("duplicate_pop_stack_top"), + ASE_T("push_active_context"), + ASE_T("push_nil"), + ASE_T("push_true"), + ASE_T("push_false"), + ASE_T("push_receiver") + }; + + static const ase_char_t* return_opcode_names[] = + { + ASE_T("return_receiver"), + ASE_T("return_true"), + ASE_T("return_false"), + ASE_T("return_nil"), + ASE_T("return_from_message"), + ASE_T("return_from_block") + }; + + bytecodes = ASE_STX_BYTE_OBJECT(stx, method_obj->bytecodes); + bytecode_size = ASE_STX_SIZE(stx, method_obj->bytecodes); + + while (pc < bytecode_size) { + code = bytecodes->data[pc++]; + + if (code >= 0x00 && code <= 0x5F) { + /* stack */ + ase_printf (ASE_T("%s %d\n"), + stack_opcode_names[code >> 4], code & 0x0F); + } + else if (code >= 0x60 && code <= 0x65) { + /* stack extended */ + next = bytecodes->data[pc++]; + ase_printf (ASE_T("%s %d\n"), + stack_opcode_names[code & 0x0F], next); + } + else if (code >= 0x67 && code <= 0x6D) { + /* stack special */ + ase_printf (ASE_T("%s\n"), + stack_special_opcode_names[code - 0x67]); + } + + else if (code >= 0x70 && code <= 0x71 ) { + /* send message */ + next = bytecodes->data[pc++]; + ase_printf (ASE_T("%s nargs(%d) selector(%d)\n"), + send_opcode_names[code - 0x70], next >> 5, next & 0x1F); + } + else if (code >= 0x72 && code <= 0x73 ) { + /* send message extended */ + next = bytecodes->data[pc++]; + next2 = bytecodes->data[pc++]; + ase_printf (ASE_T("%s %d %d\n"), + send_opcode_names[code - 0x72], next, next2); + + } + else if (code >= 0x78 && code <= 0x7D) { + ase_printf (ASE_T("%s\n"), + return_opcode_names[code - 0x78]); + } + else if (code >= 0x80 && code <= 0x8F) { + // jump + } + else if (code >= 0xF0 && code <= 0xFF) { + // primitive + next = bytecodes->data[pc++]; + ase_printf (ASE_T("do_primitive %d\n"), ((code & 0x0F) << 8) | next); + + } + else { + ase_printf (ASE_T("unknown byte code 0x%x\n"), code); + } + } + + return 0; +} diff --git a/ase/stx/bytecode.h b/ase/stx/bytecode.h new file mode 100644 index 00000000..681f0ef2 --- /dev/null +++ b/ase/stx/bytecode.h @@ -0,0 +1,56 @@ +/* + * $Id: bytecode.h,v 1.3 2007/04/30 08:32:40 bacon Exp $ + */ + +#ifndef _ASE_STX_BYTECODE_H_ +#define _ASE_STX_BYTECODE_H_ + +#include + +#define PUSH_RECEIVER_VARIABLE 0x00 +#define PUSH_TEMPORARY_LOCATION 0x10 +#define PUSH_LITERAL_CONSTANT 0x20 +#define PUSH_LITERAL_VARIABLE 0x30 +#define STORE_RECEIVER_VARIABLE 0x40 +#define STORE_TEMPORARY_LOCATION 0x50 + +#define PUSH_RECEIVER_VARIABLE_EXTENDED 0x60 +#define PUSH_TEMPORARY_LOCATION_EXTENDED 0x61 +#define PUSH_LITERAL_CONSTANT_EXTENDED 0x62 +#define PUSH_LITERAL_VARIABLE_EXTENDED 0x63 +#define STORE_RECEIVER_VARIABLE_EXTENDED 0x64 +#define STORE_TEMPORARY_LOCATION_EXTENDED 0x65 + +#define POP_STACK_TOP 0x67 +#define DUPLICATE_POP_STACK_TOP 0x68 +#define PUSH_ACTIVE_CONTEXT 0x69 +#define PUSH_NIL 0x6A +#define PUSH_TRUE 0x6B +#define PUSH_FALSE 0x6C +#define PUSH_RECEIVER 0x6D + +#define SEND_TO_SELF 0x70 +#define SEND_TO_SUPER 0x71 +#define SEND_TO_SELF_EXTENDED 0x72 +#define SEND_TO_SUPER_EXTENDED 0x73 + +#define RETURN_RECEIVER 0x78 +#define RETURN_TRUE 0x79 +#define RETURN_FALSE 0x7A +#define RETURN_NIL 0x7B +#define RETURN_FROM_MESSAGE 0x7C +#define RETURN_FROM_BLOCK 0x7D + +#define DO_PRIMITIVE 0xF0 + +#ifdef __cplusplus +extern "C" { +#endif + +int ase_stx_decode (ase_stx_t* stx, ase_word_t class_idx); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ase/stx/class.c b/ase/stx/class.c new file mode 100644 index 00000000..0c29119b --- /dev/null +++ b/ase/stx/class.c @@ -0,0 +1,168 @@ +/* + * $Id: class.c,v 1.3 2007/04/30 08:32:40 bacon Exp $ + */ + +#include +#include +#include +#include +#include + +ase_word_t ase_stx_new_class (ase_stx_t* stx, const ase_char_t* name) +{ + ase_word_t meta, class; + ase_word_t class_name; + + meta = ase_stx_alloc_word_object ( + stx, ASE_NULL, ASE_STX_METACLASS_SIZE, ASE_NULL, 0); + ASE_STX_CLASS(stx,meta) = stx->class_metaclass; + /* the spec of the metaclass must be the spec of its + * instance. so the ASE_STX_CLASS_SIZE is set */ + ASE_STX_WORD_AT(stx,meta,ASE_STX_METACLASS_SPEC) = + ASE_STX_TO_SMALLINT((ASE_STX_CLASS_SIZE << ASE_STX_SPEC_INDEXABLE_BITS) | ASE_STX_SPEC_NOT_INDEXABLE); + + /* the spec of the class is set later in __create_builtin_classes */ + class = ase_stx_alloc_word_object ( + stx, ASE_NULL, ASE_STX_CLASS_SIZE, ASE_NULL, 0); + ASE_STX_CLASS(stx,class) = meta; + class_name = ase_stx_new_symbol (stx, name); + ASE_STX_WORD_AT(stx,class,ASE_STX_CLASS_NAME) = class_name; + + ase_stx_dict_put (stx, stx->smalltalk, class_name, class); + return class; +} + +ase_word_t ase_stx_lookup_class (ase_stx_t* stx, const ase_char_t* name) +{ + ase_word_t assoc, meta, value; + + assoc = ase_stx_dict_lookup (stx, stx->smalltalk, name); + if (assoc == stx->nil) { + return stx->nil; + } + + value = ASE_STX_WORD_AT(stx,assoc,ASE_STX_ASSOCIATION_VALUE); + meta = ASE_STX_CLASS(stx,value); + if (ASE_STX_CLASS(stx,meta) != stx->class_metaclass) return stx->nil; + + return value; +} + +int ase_stx_get_instance_variable_index ( + ase_stx_t* stx, ase_word_t class_index, + const ase_char_t* name, ase_word_t* index) +{ + ase_word_t index_super = 0; + ase_stx_class_t* class_obj; + ase_stx_char_object_t* string; + + class_obj = (ase_stx_class_t*)ASE_STX_OBJECT(stx, class_index); + ase_assert (class_obj != ASE_NULL); + + if (class_obj->superclass != stx->nil) { + if (ase_stx_get_instance_variable_index ( + stx, class_obj->superclass, name, &index_super) == 0) { + *index = index_super; + return 0; + } + } + + if (class_obj->header.class == stx->class_metaclass) { + /* metaclass */ + /* TODO: can a metaclas have instance variables? */ + *index = index_super; + } + else { + if (class_obj->variables == stx->nil) *index = 0; + else { + string = ASE_STX_CHAR_OBJECT(stx, class_obj->variables); + if (ase_stx_strword(string->data, name, index) != ASE_NULL) { + *index += index_super; + return 0; + } + } + + *index += index_super; + } + + return -1; +} + +ase_word_t ase_stx_lookup_class_variable ( + ase_stx_t* stx, ase_word_t class_index, const ase_char_t* name) +{ + ase_stx_class_t* class_obj; + + class_obj = (ase_stx_class_t*)ASE_STX_OBJECT(stx, class_index); + ase_assert (class_obj != ASE_NULL); + + if (class_obj->superclass != stx->nil) { + ase_word_t tmp; + tmp = ase_stx_lookup_class_variable ( + stx, class_obj->superclass, name); + if (tmp != stx->nil) return tmp; + } + + /* TODO: can a metaclas have class variables? */ + if (class_obj->header.class != stx->class_metaclass && + class_obj->class_variables != stx->nil) { + if (ase_stx_dict_lookup(stx, + class_obj->class_variables,name) != stx->nil) return class_index; + } + + return stx->nil; +} + +ase_word_t ase_stx_lookup_method (ase_stx_t* stx, + ase_word_t class_index, const ase_char_t* name, ase_bool_t from_super) +{ + ase_stx_class_t* class_obj; + + class_obj = (ase_stx_class_t*)ASE_STX_OBJECT(stx, class_index); + ase_assert (class_obj != ASE_NULL); + +#if 0 + if (class_obj->header.class != stx->class_metaclass && + class_obj->methods != stx->nil) { + ase_word_t assoc; + assoc = ase_stx_dict_lookup(stx, class_obj->methods, name); + if (assoc != stx->nil) { + ase_assert (ASE_STX_CLASS(stx,assoc) == stx->class_association); + return ASE_STX_WORD_AT(stx, assoc, ASE_STX_ASSOCIATION_VALUE); + } + } + + if (class_obj->superclass != stx->nil) { + ase_word_t tmp; + tmp = ase_stx_lookup_method ( + stx, class_obj->superclass, name); + if (tmp != stx->nil) return tmp; + } +#endif + + while (class_index != stx->nil) { + class_obj = (ase_stx_class_t*)ASE_STX_OBJECT(stx, class_index); + + ase_assert (class_obj != ASE_NULL); + ase_assert ( + class_obj->header.class == stx->class_metaclass || + ASE_STX_CLASS(stx,class_obj->header.class) == stx->class_metaclass); + + if (from_super) { + from_super = ase_false; + } + else if (class_obj->methods != stx->nil) { + ase_word_t assoc; + assoc = ase_stx_dict_lookup(stx, class_obj->methods, name); + if (assoc != stx->nil) { + ase_assert (ASE_STX_CLASS(stx,assoc) == stx->class_association); + return ASE_STX_WORD_AT(stx, assoc, ASE_STX_ASSOCIATION_VALUE); + } + } + + class_index = class_obj->superclass; + } + + return stx->nil; +} + diff --git a/ase/stx/class.h b/ase/stx/class.h new file mode 100644 index 00000000..a13afbdc --- /dev/null +++ b/ase/stx/class.h @@ -0,0 +1,81 @@ +/* + * $Id: class.h,v 1.3 2007/04/30 08:32:40 bacon Exp $ + */ + +#ifndef _ASE_STX_CLASS_H_ +#define _ASE_STX_CLASS_H_ + +#include + +/* definitions for common objects */ +#define ASE_STX_CLASS_SIZE 8 +#define ASE_STX_CLASS_SPEC 0 +#define ASE_STX_CLASS_METHODS 1 +#define ASE_STX_CLASS_SUPERCLASS 2 +#define ASE_STX_CLASS_SUBCLASSES 3 +#define ASE_STX_CLASS_NAME 4 +#define ASE_STX_CLASS_VARIABLES 5 +#define ASE_STX_CLASS_CLASS_VARIABLES 6 +#define ASE_STX_CLASS_POOL_DICTIONARIES 7 + +#define ASE_STX_METACLASS_SIZE 5 +#define ASE_STX_METACLASS_SPEC 0 +#define ASE_STX_METACLASS_METHODS 1 +#define ASE_STX_METACLASS_SUPERCLASS 2 +#define ASE_STX_METACLASS_SUBCLASSES 3 +#define ASE_STX_METACLASS_INSTANCE_CLASS 4 + +#define ASE_STX_SPEC_INDEXABLE_BITS 2 +#define ASE_STX_SPEC_INDEXABLE_MASK 3 +#define ASE_STX_SPEC_NOT_INDEXABLE 0 +#define ASE_STX_SPEC_WORD_INDEXABLE 1 +#define ASE_STX_SPEC_BYTE_INDEXABLE 2 +#define ASE_STX_SPEC_CHAR_INDEXABLE 3 + +struct ase_stx_class_t +{ + ase_stx_objhdr_t header; + ase_word_t spec; /* indexable: 2, nfields: the rest */ + ase_word_t methods; + ase_word_t superclass; + ase_word_t subclasses; + ase_word_t name; + ase_word_t variables; + ase_word_t class_variables; + ase_word_t pool_dictonaries; +}; + +struct ase_stx_metaclass_t +{ + ase_stx_objhdr_t header; + ase_word_t spec; + ase_word_t methods; + ase_word_t superclass; + ase_word_t subclasses; + ase_word_t instance_class; +}; + +typedef struct ase_stx_class_t ase_stx_class_t; +typedef struct ase_stx_metaclass_t ase_stx_metaclass_t; + +#ifdef __cplusplus +extern "C" { +#endif + +ase_word_t ase_stx_new_class (ase_stx_t* stx, const ase_char_t* name); +ase_word_t ase_stx_lookup_class (ase_stx_t* stx, const ase_char_t* name); + +int ase_stx_get_instance_variable_index ( + ase_stx_t* stx, ase_word_t class_index, + const ase_char_t* name, ase_word_t* index); + +ase_word_t ase_stx_lookup_class_variable ( + ase_stx_t* stx, ase_word_t class_index, const ase_char_t* name); +ase_word_t ase_stx_lookup_method (ase_stx_t* stx, + ase_word_t class_index, const ase_char_t* name, ase_bool_t from_super); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ase/stx/context.c b/ase/stx/context.c new file mode 100644 index 00000000..bb71fca5 --- /dev/null +++ b/ase/stx/context.c @@ -0,0 +1,75 @@ +/* + * $Id: context.c,v 1.3 2007/04/30 08:32:41 bacon Exp $ + */ + +#include +#include +#include +#include + +ase_word_t ase_stx_new_context (ase_stx_t* stx, + ase_word_t method, ase_word_t args, ase_word_t temp) +{ + ase_word_t context; + ase_stx_context_t* obj; + + context = ase_stx_alloc_word_object( + stx, ASE_NULL, ASE_STX_CONTEXT_SIZE, ASE_NULL, 0); + obj = (ase_stx_context_t*)ASE_STX_OBJECT(stx,context); + obj->header.class = ase_stx_lookup_class(stx,ASE_T("Context")); + obj->ip = ASE_STX_TO_SMALLINT(0); + obj->method = method; + obj->arguments = args; + obj->temporaries = temp; + + return context; +} + +static ase_byte_t __fetch_byte ( + ase_stx_t* stx, ase_stx_context_t* context_obj) +{ + ase_word_t ip, method; + + ase_assert (ASE_STX_IS_SMALLINT(context_obj->ip)); + ip = ASE_STX_FROM_SMALLINT(context_obj->ip); + method = context_obj->method; + + /* increment instruction pointer */ + context_obj->ip = ASE_STX_TO_SMALLINT(ip + 1); + + ase_assert (ASE_STX_TYPE(stx,method) == ASE_STX_BYTE_INDEXED); + return ASE_STX_BYTE_AT(stx,method,ip); +} + +int ase_stx_run_context (ase_stx_t* stx, ase_word_t context) +{ + ase_byte_t byte, operand; + ase_stx_context_t* context_obj; + + context_obj = (ase_stx_context_t*)ASE_STX_OBJECT(stx,context); + + while (!stx->__wantabort) { + /* check_process_switch (); // hopefully */ + byte = __fetch_byte (stx, context_obj); + +#ifdef _DOS +printf (ASE_T("code: %x\n"), byte); +#else +ase_printf (ASE_T("code: %x\n"), byte); +#endif + + switch (byte) { + case PUSH_OBJECT: + operand = __fetch_byte (stx, context_obj); + break; + case SEND_UNARY_MESSAGE: + operand = __fetch_byte (stx, context_obj); + break; + case HALT: + goto exit_run_context; + } + } + +exit_run_context: + return 0; +} diff --git a/ase/stx/context.h b/ase/stx/context.h new file mode 100644 index 00000000..843ad1ac --- /dev/null +++ b/ase/stx/context.h @@ -0,0 +1,43 @@ +/* + * $Id: context.h,v 1.3 2007/04/30 08:32:41 bacon Exp $ + */ + +#ifndef _ASE_STX_CONTEXT_H_ +#define _ASE_STX_CONTEXT_H_ + +#include + +#define PUSH_OBJECT 0xA0 +#define SEND_UNARY_MESSAGE 0xB0 +#define HALT 0xFF + +#define ASE_STX_CONTEXT_SIZE 4 +#define ASE_STX_CONTEXT_IP 0 +#define ASE_STX_CONTEXT_METHOD 1 +#define ASE_STX_CONTEXT_ARGUMENTS 2 +#define ASE_STX_CONTEXT_TEMPORARIES 3 + +struct ase_stx_context_t +{ + ase_stx_objhdr_t header; + ase_word_t ip; + ase_word_t method; + ase_word_t arguments; + ase_word_t temporaries; +}; + +typedef struct ase_stx_context_t ase_stx_context_t; + +#ifdef __cplusplus +extern "C" { +#endif + +ase_word_t ase_stx_new_context (ase_stx_t* stx, + ase_word_t method, ase_word_t args, ase_word_t temp); +int ase_stx_run_context (ase_stx_t* stx, ase_word_t context); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ase/stx/dict.c b/ase/stx/dict.c new file mode 100644 index 00000000..ca44e0f8 --- /dev/null +++ b/ase/stx/dict.c @@ -0,0 +1,190 @@ +/* + * $Id: dict.c,v 1.3 2007/04/30 08:32:41 bacon Exp $ + */ + +#include +#include +#include + +/* NOTE: + * The code here implements SystemDictionary whose key is always a symbol. + * Dictionary, on the contrary, can accept any object as a key. + */ + +ase_word_t __new_association ( + ase_stx_t* stx, ase_word_t key, ase_word_t value) +{ + ase_word_t x; +#ifdef __GNUC__ + ase_word_t data[2] = { key, value }; +#else + ase_word_t data[2]; + data[0] = key; + data[1] = value; +#endif + x = ase_stx_alloc_word_object ( + stx, data, ASE_STX_ASSOCIATION_SIZE, ASE_NULL, 0); + ASE_STX_CLASS(stx,x) = stx->class_association; + return x; +} + +static ase_word_t __dict_find_slot ( + ase_stx_t* stx, ase_word_t dict, ase_word_t key) +{ + ase_word_t size, hash, index, assoc, symbol; + ase_stx_word_object_t* dict_obj; + + ase_assert (!ASE_STX_IS_SMALLINT(dict) && + ASE_STX_IS_WORD_OBJECT(stx, dict)); + ase_assert (dict == stx->smalltalk || + ase_stx_classof(stx,dict) == stx->class_system_dictionary); + ase_assert (ase_stx_classof(stx,key) == stx->class_symbol); + + size = ASE_STX_SIZE(stx,dict); + hash = ase_stx_hash_object(stx, key); + + /* consider tally, the only instance variable of a system dictionary */ + index = hash % (size - 1) + 1; + + dict_obj = ASE_STX_WORD_OBJECT(stx,dict); + + while (1) { + assoc = dict_obj->data[index]; + if (assoc == stx->nil) break; + + symbol = ASE_STX_WORD_AT(stx,assoc,ASE_STX_ASSOCIATION_KEY); + ase_assert (ase_stx_classof(stx,symbol) == stx->class_symbol); + + /* NOTE: + * shallow comparison is enough for identity check + * because a symbol can just be a key of a system dictionary + */ + if (ase_strxncmp( + ASE_STX_DATA(stx,key), ASE_STX_SIZE(stx,key), + ASE_STX_DATA(stx,symbol), ASE_STX_SIZE(stx,symbol)) == 0) break; + + /* consider tally here too */ + index = index % (size - 1) + 1; + } + + return index; +} + +static void __grow_dict (ase_stx_t* stx, ase_word_t dict) +{ + ase_word_t new, size, index, assoc; + + /* WARNING: + * if this assertion fails, adjust the initial size of the + * system dictionary. i don't want this function to be called + * during the bootstrapping. + */ + ase_assert (stx->class_system_dictionary != stx->nil); + ase_assert (ase_stx_classof(stx,dict) == stx->class_system_dictionary); + + size = ASE_STX_SIZE(stx,dict); + new = ase_stx_instantiate (stx, + ASE_STX_CLASS(stx,dict), ASE_NULL, ASE_NULL, (size - 1) * 2); + ASE_STX_WORD_AT(stx,new,0) = ASE_STX_TO_SMALLINT(0); + + for (index = 1; index < size; index++) { + assoc = ASE_STX_WORD_AT(stx,dict,index); + if (assoc == stx->nil) continue; + + ase_stx_dict_put (stx, new, + ASE_STX_WORD_AT(stx,assoc,ASE_STX_ASSOCIATION_KEY), + ASE_STX_WORD_AT(stx,assoc,ASE_STX_ASSOCIATION_VALUE)); + } + + /* TODO: explore if dict can be immediately destroyed. */ + + ase_assert (ase_sizeof(ase_stx_object_t*) == ase_sizeof(ase_uint_t)); + ASE_SWAP (ASE_STX_OBJECT(stx,dict), + ASE_STX_OBJECT(stx,new), + ase_stx_object_t*, ase_uint_t); +} + +ase_word_t ase_stx_dict_lookup ( + ase_stx_t* stx, ase_word_t dict, const ase_char_t* key) +{ + ase_word_t size, hash, index, assoc, symbol; + ase_stx_word_object_t* dict_obj; + + ase_assert (!ASE_STX_IS_SMALLINT(dict) && + ASE_STX_IS_WORD_OBJECT(stx, dict)); + ase_assert (dict == stx->smalltalk || + ase_stx_classof(stx,dict) == stx->class_system_dictionary); + + size = ASE_STX_SIZE(stx,dict); + hash = ase_stx_hash(key, ase_strlen(key) * ase_sizeof(ase_char_t)); + + /* consider tally, the only instance variable of a system dictionary */ + index = hash % (size - 1) + 1; + + dict_obj = ASE_STX_WORD_OBJECT(stx,dict); + + while (1) { + assoc = dict_obj->data[index]; + if (assoc == stx->nil) break; + + symbol = ASE_STX_WORD_AT(stx,assoc,ASE_STX_ASSOCIATION_KEY); + ase_assert (ase_stx_classof(stx,symbol) == stx->class_symbol); + + if (ase_strxcmp (ASE_STX_DATA(stx,symbol), + ASE_STX_SIZE(stx,symbol), key) == 0) break; + + /* consider tally here too */ + index = index % (size - 1) + 1; + } + + return ASE_STX_WORD_AT(stx,dict,index); +} + +ase_word_t ase_stx_dict_get (ase_stx_t* stx, ase_word_t dict, ase_word_t key) +{ + return ASE_STX_WORD_AT(stx,dict,__dict_find_slot(stx, dict, key)); +} + +ase_word_t ase_stx_dict_put ( + ase_stx_t* stx, ase_word_t dict, ase_word_t key, ase_word_t value) +{ + ase_word_t slot, capa, tally, assoc; + + /* the dictionary must have at least one slot excluding tally */ + ase_assert (ASE_STX_SIZE(stx,dict) > 1); + + capa = ASE_STX_SIZE(stx,dict) - 1; + tally = ASE_STX_FROM_SMALLINT(ASE_STX_WORD_AT(stx,dict,0)); + if (capa <= tally + 1) { + __grow_dict (stx, dict); + /* refresh tally */ + tally = ASE_STX_FROM_SMALLINT(ASE_STX_WORD_AT(stx,dict,0)); + } + + slot = __dict_find_slot (stx, dict, key); + + assoc = ASE_STX_WORD_AT(stx,dict,slot); + if (assoc == stx->nil) { + ASE_STX_WORD_AT(stx,dict,slot) = + __new_association (stx, key, value); + ASE_STX_WORD_AT(stx,dict,0) = ASE_STX_TO_SMALLINT(tally + 1); + } + else ASE_STX_WORD_AT(stx,assoc,ASE_STX_ASSOCIATION_VALUE) = value; + + return ASE_STX_WORD_AT(stx,dict,slot); +} + +void ase_stx_dict_traverse ( + ase_stx_t* stx, ase_word_t dict, + void (*func) (ase_stx_t*,ase_word_t,void*), void* data) +{ + ase_word_t index, assoc; + ase_word_t size = ASE_STX_SIZE(stx,dict); + + for (index = 1; index < size; index++) { + assoc = ASE_STX_WORD_AT(stx,dict,index); + if (assoc == stx->nil) continue; + func (stx, assoc, data); + } +} + diff --git a/ase/stx/dict.h b/ase/stx/dict.h new file mode 100644 index 00000000..5a9de031 --- /dev/null +++ b/ase/stx/dict.h @@ -0,0 +1,42 @@ +/* + * $Id: dict.h,v 1.3 2007/04/30 08:32:41 bacon Exp $ + */ + +#ifndef _ASE_STX_DICT_H_ +#define _ASE_STX_DICT_H_ + +#include + +#define ASE_STX_ASSOCIATION_SIZE 2 +#define ASE_STX_ASSOCIATION_KEY 0 +#define ASE_STX_ASSOCIATION_VALUE 1 + +struct ase_stx_association_t +{ + ase_stx_objhdr_t header; + ase_word_t key; + ase_word_t value; +}; + +typedef struct ase_stx_association_t ase_stx_association_t; + +#ifdef __cplusplus +extern "C" +#endif + +ase_word_t ase_stx_dict_lookup ( + ase_stx_t* stx, ase_word_t dict, const ase_char_t* key); +ase_word_t ase_stx_dict_get ( + ase_stx_t* stx, ase_word_t dict, ase_word_t key); +ase_word_t ase_stx_dict_put ( + ase_stx_t* stx, ase_word_t dict, ase_word_t key, ase_word_t value); +void ase_stx_dict_traverse ( + ase_stx_t* stx, ase_word_t dict, + void (*func) (ase_stx_t*,ase_word_t,void*), void* data); + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ase/stx/interp.c b/ase/stx/interp.c new file mode 100644 index 00000000..a69adfa2 --- /dev/null +++ b/ase/stx/interp.c @@ -0,0 +1,380 @@ +/* + * $Id: interp.c,v 1.3 2007/04/30 08:32:41 bacon Exp $ + */ + +#include +#include +#include +#include +#include +#include +#include + +/* +activation record + +.... +.... +.... +------------------- +previous stack_base +------------------- +method +------------------- +pc +------------------- +temporaries +------------------- +arguments +------------------- +receiver +------------------- <----- current stack_base +.... +.... +.... + + */ + +struct process_t +{ + ase_word_t* stack; + ase_word_t stack_size; + ase_word_t stack_base; + ase_word_t stack_top; + + ase_word_t receiver; + ase_word_t method; + ase_word_t pc; + + /* cached information about the method above */ + ase_word_t* literals; + ase_byte_t* bytecodes; + ase_word_t bytecode_size; + ase_size_t argcount; + ase_size_t tmpcount; +}; + +typedef struct process_t process_t; + +static int __run_process (ase_stx_t* stx, process_t* proc); +static int __push_to_stack (ase_stx_t* stx, + process_t* proc, ase_word_t what, ase_word_t index); +static int __store_from_stack (ase_stx_t* stx, + process_t* proc, ase_word_t what, ase_word_t index); +static int __send_message (ase_stx_t* stx, process_t* proc, + ase_word_t nargs, ase_word_t selector, ase_bool_t to_super); +static int __return_from_message (ase_stx_t* stx, process_t* proc); +static int __dispatch_primitive (ase_stx_t* stx, process_t* proc, ase_word_t no); + +int ase_stx_interp (ase_stx_t* stx, ase_word_t receiver, ase_word_t method) +{ + process_t proc; + ase_stx_method_t* mthobj; + ase_word_t i; + int n; + + // TODO: size of process stack. + proc.stack = (ase_word_t*)ase_malloc (10000 * ase_sizeof(ase_word_t)); + if (proc.stack == ASE_NULL) { +ase_printf (ASE_T("out of memory in ase_stx_interp\n")); + return -1; + } + + proc.stack_size = 10000; + proc.stack_base = 0; + proc.stack_top = 0; + + mthobj = (ase_stx_method_t*)ASE_STX_OBJECT(stx,method); + ase_assert (mthobj != ASE_NULL); + + proc.literals = mthobj->literals; + proc.bytecodes = ASE_STX_DATA(stx, mthobj->bytecodes); + proc.bytecode_size = ASE_STX_SIZE(stx, mthobj->bytecodes); + /* TODO: disable the method with arguments for start-up */ + proc.argcount = ASE_STX_FROM_SMALLINT(mthobj->argcount); + proc.tmpcount = ASE_STX_FROM_SMALLINT(mthobj->tmpcount); + + proc.receiver = receiver; + proc.method = method; + proc.pc = 0; + + proc.stack_base = proc.stack_top; + + /* push the receiver */ + proc.stack[proc.stack_top++] = receiver; + + /* push arguments */ + for (i = 0; i < proc.argcount; i++) { + proc.stack[proc.stack_top++] = stx->nil; + } + + /* secure space for temporaries */ + for (i = 0; i < proc.tmpcount; i++) + proc.stack[proc.stack_top++] = stx->nil; + + /* push dummy pc */ + proc.stack[proc.stack_top++] = 0; + /* push dummy method */ + proc.stack[proc.stack_top++] = stx->nil; + /* push dummy previous stack base */ + proc.stack[proc.stack_top++] = 0; + + n = __run_process (stx, &proc); + + ase_free (proc.stack); + return n; +} + +static int __run_process (ase_stx_t* stx, process_t* proc) +{ + int code, next, next2; + + while (proc->pc < proc->bytecode_size) { + code = proc->bytecodes[proc->pc++]; + +#ifdef DEBUG + ase_printf (ASE_T("code = 0x%x\n"), code); +#endif + + if (code >= 0x00 && code <= 0x3F) { + /* stack - push */ + __push_to_stack (stx, proc, code >> 4, code & 0x0F); + } + else if (code >= 0x40 && code <= 0x5F) { + /* stack - store */ + int what = code >> 4; + int index = code & 0x0F; + __store_from_stack (stx, proc, code >> 4, code & 0x0F); + } + + /* TODO: more here .... */ + + else if (code == 0x67) { + /* pop stack top */ + proc->stack_top--; + } + + /* TODO: more here .... */ + + else if (code == 0x6A) { + proc->stack[proc->stack_top++] = stx->nil; + } + else if (code == 0x6B) { + proc->stack[proc->stack_top++] = stx->true; + } + else if (code == 0x6C) { + proc->stack[proc->stack_top++] = stx->false; + } + else if (code == 0x6D) { + /* push receiver */ + proc->stack[proc->stack_top++] = proc->receiver; + } + + /* TODO: more here .... */ + + else if (code == 0x70) { + /* send message to self */ + next = proc->bytecodes[proc->pc++]; + if (__send_message (stx, proc, next >> 5, + proc->literals[next & 0x1F], ase_false) == -1) break; + } + else if (code == 0x71) { + /* send message to super */ + next = proc->bytecodes[proc->pc++]; + if (__send_message (stx, proc, next >> 5, + proc->literals[next & 0x1F], ase_true) == -1) break; + } + else if (code == 0x72) { + /* send message to self extended */ + next = proc->bytecodes[proc->pc++]; + next2 = proc->bytecodes[proc->pc++]; + if (__send_message (stx, proc, next >> 5, + proc->literals[next2], ase_false) == -1) break; + } + else if (code == 0x73) { + /* send message to super extended */ + next = proc->bytecodes[proc->pc++]; + next2 = proc->bytecodes[proc->pc++]; + if (__send_message (stx, proc, next >> 5, + proc->literals[next2], ase_true) == -1) break; + } + + /* more code .... */ + else if (code == 0x78) { + /* return receiver */ + proc->stack[proc->stack_top++] = proc->receiver; + if (__return_from_message (stx, proc) == -1) break; + } + + else if (code == 0x7C) { + /* return from message */ + if (__return_from_message (stx, proc) == -1) break; + } + + else if (code >= 0xF0 && code <= 0xFF) { + /* primitive */ + next = proc->bytecodes[proc->pc++]; + __dispatch_primitive (stx, proc, ((code & 0x0F) << 8) | next); + } + + else { +ase_printf (ASE_T("INVALID OPCODE...........\n")); +break; + } + } + + return 0; +} + +static int __push_to_stack (ase_stx_t* stx, + process_t* proc, ase_word_t what, ase_word_t index) +{ + switch (what) { + case 0: /* receiver variable */ + proc->stack[proc->stack_top++] = + ASE_STX_WORD_AT(stx, proc->stack[proc->stack_base], index); + break; + case 1: /* temporary variable */ + proc->stack[proc->stack_top++] = + proc->stack[proc->stack_base + 1 + index]; + break; + case 2: /* literal constant */ + proc->stack[proc->stack_top++] = proc->literals[index]; + break; + case 3: /* literal variable */ + break; + } + + return 0; +} + +static int __store_from_stack (ase_stx_t* stx, + process_t* proc, ase_word_t what, ase_word_t index) +{ + switch (what) { + case 4: /* receiver variable */ + ASE_STX_WORD_AT(stx,proc->stack[proc->stack_base],index) = proc->stack[--proc->stack_top]; + break; + case 5: /* temporary location */ + proc->stack[proc->stack_base + 1 + index] = proc->stack[--proc->stack_top]; + break; + } + + return 0; +} + +static int __send_message (ase_stx_t* stx, process_t* proc, + ase_word_t nargs, ase_word_t selector, ase_bool_t to_super) +{ + ase_word_t receiver, method; + ase_word_t i, tmpcount, argcount; + ase_stx_method_t* mthobj; + + ase_assert (ASE_STX_CLASS(stx,selector) == stx->class_symbol); + + receiver = proc->stack[proc->stack_top - nargs - 1]; + method = ase_stx_lookup_method ( + stx, ASE_STX_CLASS(stx,receiver), + ASE_STX_DATA(stx,selector), to_super); + if (method == stx->nil) { +ase_printf (ASE_T("cannot find the method....\n")); + return -1; + } + + mthobj = (ase_stx_method_t*)ASE_STX_OBJECT(stx,method); + + argcount = ASE_STX_FROM_SMALLINT(mthobj->argcount); + tmpcount = ASE_STX_FROM_SMALLINT(mthobj->tmpcount); + ase_assert (argcount == nargs); + + /* secure space for temporaries */ + for (i = 0; i < tmpcount; i++) { + proc->stack[proc->stack_top++] = stx->nil; + } + + /* push pc */ + proc->stack[proc->stack_top++] = proc->pc; + /* push method */ + proc->stack[proc->stack_top++] = proc->method; + /* push previous stack base */ + proc->stack[proc->stack_top++] = proc->stack_base; + + proc->stack_base = proc->stack_top - 3 - tmpcount - argcount - 1; + ase_assert (proc->stack_base > 0); + + proc->receiver = receiver; + proc->method = method; + proc->pc = 0; + + proc->literals = mthobj->literals; + proc->bytecodes = ASE_STX_DATA(stx, mthobj->bytecodes); + proc->bytecode_size = ASE_STX_SIZE(stx, mthobj->bytecodes); + proc->argcount = argcount; + proc->tmpcount = tmpcount; + + return 0; +} + +static int __return_from_message (ase_stx_t* stx, process_t* proc) +{ + ase_word_t method, pc, stack_base; + ase_stx_method_t* mthobj; + + if (proc->stack_base == 0) { + /* return from the startup method */ + return -1; + } + + stack_base = proc->stack[proc->stack_base + 1 + proc->tmpcount + proc->argcount + 2]; + method = proc->stack[proc->stack_base + 1 + proc->tmpcount + proc->argcount + 1]; + pc = proc->stack[proc->stack_base + 1 + proc->tmpcount + proc->argcount]; + + mthobj = (ase_stx_method_t*)ASE_STX_OBJECT(stx,method); + ase_assert (mthobj != ASE_NULL); + + /* return value is located on top of the previous stack */ + proc->stack[proc->stack_base - 1] = proc->stack[proc->stack_top - 1]; + + /* restore the stack pointers */ + proc->stack_top = proc->stack_base; + proc->stack_base = stack_base; + + proc->receiver = proc->stack[stack_base]; + proc->method = method; + proc->pc = pc; + + proc->literals = mthobj->literals; + proc->bytecodes = ASE_STX_DATA(stx, mthobj->bytecodes); + proc->bytecode_size = ASE_STX_SIZE(stx, mthobj->bytecodes); + proc->argcount = ASE_STX_FROM_SMALLINT(mthobj->argcount); + proc->tmpcount = ASE_STX_FROM_SMALLINT(mthobj->tmpcount); + + return 0; +} + + +static int __dispatch_primitive (ase_stx_t* stx, process_t* proc, ase_word_t no) +{ + switch (no) { + case 0: + ase_printf (ASE_T("[[ hello stx smalltalk ]]\n")); + break; + case 1: + ase_printf (ASE_T("<< AMAZING STX SMALLTALK WORLD >>\n")); + break; + case 2: + ase_printf (ASE_T("<< FUNKY STX SMALLTALK >> %d\n"), + ASE_STX_FROM_SMALLINT(proc->stack[proc->stack_base + 1])); + break; + case 3: + ase_printf (ASE_T("<< HIGH STX SMALLTALK >> %d, %d\n"), + ASE_STX_FROM_SMALLINT(proc->stack[proc->stack_base + 1]), + ASE_STX_FROM_SMALLINT(proc->stack[proc->stack_base + 2])); + break; + case 20: + ase_printf (ASE_T("<< PRIMITIVE 20 >>\n")); + break; + } + + return 0; +} diff --git a/ase/stx/interp.h b/ase/stx/interp.h new file mode 100644 index 00000000..962f50da --- /dev/null +++ b/ase/stx/interp.h @@ -0,0 +1,20 @@ +/* + * $Id: interp.h,v 1.3 2007/04/30 08:32:41 bacon Exp $ + */ + +#ifndef _ASE_STX_INTERP_H_ +#define _ASE_STX_INTERP_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +int ase_stx_interp (ase_stx_t* stx, ase_word_t receiver, ase_word_t method); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ase/stx/makefile.bcc b/ase/stx/makefile.bcc new file mode 100644 index 00000000..a23bf9cf --- /dev/null +++ b/ase/stx/makefile.bcc @@ -0,0 +1,21 @@ +SRCS = stx.c memory.c object.c symbol.c class.c dict.c misc.c array.c \ + name.c token.c parser.c bootstrp.c bytecode.c interp.c +OBJS = $(SRCS:.c=.obj) +OUT = xpstx.lib + +CC = bcc32 +CFLAGS = -O2 -WM -w -w-inl -w-sig -w-spa -w-hid -RT- -I../.. + +all: $(OBJS) + tlib $(OUT) @&&! ++-$(**: = &^ ++-) +! + +clean: + del $(OBJS) $(OUT) *.obj + +.SUFFIXES: .c .obj +.c.obj: + $(CC) $(CFLAGS) -c $< + diff --git a/ase/stx/makefile.cl b/ase/stx/makefile.cl new file mode 100644 index 00000000..0ee1f8fd --- /dev/null +++ b/ase/stx/makefile.cl @@ -0,0 +1,23 @@ +SRCS = \ + stx.c memory.c object.c symbol.c class.c array.c \ + dict.c misc.c name.c token.c parser.c bootstrp.c \ + bytecode.c interp.c +OBJS = $(SRCS:.c=.obj) +OUT = xpstx.lib + +CC = cl +CFLAGS = /nologo /MT /GX /W3 /GR- -I../.. + +all: $(OBJS) + link -lib @<< +/nologo /out:$(OUT) $(OBJS) +<< + + +clean: + del $(OBJS) $(OUT) *.obj + +.SUFFIXES: .c .obj +.c.obj: + $(CC) $(CFLAGS) /c $< + diff --git a/ase/stx/makefile.in b/ase/stx/makefile.in new file mode 100644 index 00000000..89d3d474 --- /dev/null +++ b/ase/stx/makefile.in @@ -0,0 +1,28 @@ +OUT = asestx + +C_SRCS = stx.c memory.c object.c symbol.c class.c array.c \ + dict.c misc.c context.c name.c token.c parser.c bootstrp.c \ + bytecode.c interp.c + +C_OBJS = $(C_SRCS:.c=.o) + +CC = @CC@ +AR = ar +RANLIB = @RANLIB@ +CFLAGS = @CFLAGS@ -I@abs_top_builddir@/.. +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ + +all: lib + +lib: $(C_OBJS) + $(AR) cr lib$(OUT).a $(C_OBJS) + if [ "$(RANLIB)" = "ranlib" ]; then ranlib lib$(OUT).a; fi + +clean: + rm -rf $(OBJS) lib$(OUT).a *.o + +.SUFFIXES: .c .o +.c.o: + $(CC) $(CFLAGS) -c $< + diff --git a/ase/stx/makefile.lcc b/ase/stx/makefile.lcc new file mode 100644 index 00000000..21f10a9b --- /dev/null +++ b/ase/stx/makefile.lcc @@ -0,0 +1,22 @@ +SRCS = stx.c memory.c object.c symbol.c class.c array.c \ + dict.c misc.c name.c token.c parser.c bootstrp.c \ + bytecode.c interp.c +OBJS = stx.obj memory.obj object.obj symbol.obj class.obj array.obj \ + dict.obj misc.obj name.obj token.obj parser.obj bootstrp.obj \ + bytecode.obj interp.obj +OUT = xpstx.lib + +CC = lcc +CFLAGS = -I../.. -A -ansic #-libcdll +LDFLAGS = +LIBS = + +all: $(OBJS) + lcclib $(OUT) $(OBJS) + +clean: + del $(OBJS) $(OUT) *.obj + +.SUFFIXES: .c .obj +.c.obj: + $(CC) $(CFLAGS) -c $< diff --git a/ase/stx/makefile.tcc b/ase/stx/makefile.tcc new file mode 100644 index 00000000..85f31683 --- /dev/null +++ b/ase/stx/makefile.tcc @@ -0,0 +1,22 @@ +SRCS = \ + stx.c memory.c object.c symbol.c dict.c misc.c context.c +OBJS = $(SRCS:.c=.obj) +OUT = xpstx.lib + +TC = \dos\tcc +CC = $(TC)\tcc +CFLAGS = -I..\.. -D_DOS -ml -w + +all: $(OBJS) + $(TC)\tlib $(OUT) @&&! ++-$(**: = &^ ++-) +! + +clean: + del $(OBJS) $(OUT) *.obj + +.SUFFIXES: .c .obj +.c.obj: + $(CC) $(CFLAGS) -c $< + diff --git a/ase/stx/memory.c b/ase/stx/memory.c new file mode 100644 index 00000000..31d021ff --- /dev/null +++ b/ase/stx/memory.c @@ -0,0 +1,98 @@ +/* + * $Id: memory.c,v 1.3 2007/04/30 08:32:41 bacon Exp $ + */ + +#include +#include + +ase_stx_memory_t* ase_stx_memory_open ( + ase_stx_memory_t* mem, ase_word_t capacity) +{ + ase_stx_object_t** slots; + ase_word_t n; + + ase_assert (capacity > 0); + if (mem == ASE_NULL) { + mem = (ase_stx_memory_t*)ase_malloc(ase_sizeof(ase_stx_memory_t)); + if (mem == ASE_NULL) return ASE_NULL; + mem->__dynamic = ase_true; + } + else mem->__dynamic = ase_false; + + slots = (ase_stx_object_t**)ase_malloc ( + capacity * ase_sizeof(ase_stx_object_t*)); + if (slots == ASE_NULL) { + if (mem->__dynamic) ase_free (mem); + mem = ASE_NULL; + } + + mem->capacity = capacity; + mem->slots = slots; + + /* weave the free slot list */ + mem->free = &slots[0]; + for (n = 0; n < capacity - 1; n++) { + mem->slots[n] = (ase_stx_object_t*)&mem->slots[n + 1]; + } + mem->slots[n] = ASE_NULL; + + return mem; +} + +void ase_stx_memory_close (ase_stx_memory_t* mem) +{ + /* TODO: free all linked objects... */ + + ase_free (mem->slots); + mem->capacity = 0; + mem->slots = ASE_NULL; + mem->free = ASE_NULL; + if (mem->__dynamic) ase_free (mem); +} + +void ase_stx_memory_gc (ase_stx_memory_t* mem) +{ + /* TODO: implement this function */ +} + +ase_word_t ase_stx_memory_alloc (ase_stx_memory_t* mem, ase_word_t nbytes) +{ + ase_stx_object_t** slot; + ase_stx_object_t* object; + + /* find the free object slot */ + if (mem->free == ASE_NULL) { + ase_stx_memory_gc (mem); + if (mem->free == ASE_NULL) return mem->capacity;; + } + + object = (ase_stx_object_t*)ase_malloc (nbytes); + if (object == ASE_NULL) { + ase_stx_memory_gc (mem); + object = (ase_stx_object_t*)ase_malloc (nbytes); + /*if (object == ASE_NULL) return mem->capacity;*/ +if (object == ASE_NULL) { +ase_assert (ASE_T("MEMORY ALLOCATION ERROR\n") == ASE_NULL); +exit (1); +} + } + + slot = mem->free; + mem->free = (ase_stx_object_t**)*slot; + *slot = object; + + return (ase_word_t)(slot - mem->slots); +} + +void ase_stx_memory_dealloc (ase_stx_memory_t* mem, ase_word_t object_index) +{ + /* + * THIS IS PRIMITIVE LOW-LEVEL DEALLOC. THIS WILL NOT + * DEALLOCATE MEMORY ALLOCATED FOR ITS INSTANCE VARIABLES. + */ + + ase_free (mem->slots[object_index]); + mem->slots[object_index] = (ase_stx_object_t*)mem->free; + mem->free = &mem->slots[object_index]; +} + diff --git a/ase/stx/memory.h b/ase/stx/memory.h new file mode 100644 index 00000000..c8168e2d --- /dev/null +++ b/ase/stx/memory.h @@ -0,0 +1,26 @@ +/* + * $Id: memory.h,v 1.3 2007/04/30 08:32:41 bacon Exp $ + */ + +#ifndef _ASE_STX_MEMORY_H_ +#define _ASE_STX_MEMORY_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +ase_stx_memory_t* ase_stx_memory_open ( + ase_stx_memory_t* mem, ase_word_t capacity); +void ase_stx_memory_close (ase_stx_memory_t* mem); + +void ase_stx_memory_gc (ase_stx_memory_t* mem); +ase_word_t ase_stx_memory_alloc (ase_stx_memory_t* mem, ase_word_t size); +void ase_stx_memory_dealloc (ase_stx_memory_t* mem, ase_word_t object_index); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ase/stx/method.h b/ase/stx/method.h new file mode 100644 index 00000000..1959743b --- /dev/null +++ b/ase/stx/method.h @@ -0,0 +1,50 @@ +/* + * $Id: method.h,v 1.3 2007/04/30 08:32:41 bacon Exp $ + */ + +#ifndef _ASE_STX_METHOD_H_ +#define _ASE_STX_METHOD_H_ + +#include + +#define ASE_STX_METHOD_SIZE 5 +#define ASE_STX_METHOD_TEXT 0 +#define ASE_STX_METHOD_SELECTOR 1 +#define ASE_STX_METHOD_BYTECODES 2 +#define ASE_STX_METHOD_TMPCOUNT 3 +#define ASE_STX_METHOD_ARGCOUNT 4 + + +/* dolphin smalltalk's flags representation + 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 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| 1| | | | 0| 0| 0| 1| +------------------------------------------------------------------------------------------------- +\----------|-----------/ \----------|----------/ \---------|-----------/ | \---|--/ | + extraIndex arg Count temp Count | flags | + | | + Block flag SmallInteger flag" +*/ + +struct ase_stx_method_t +{ + ase_stx_objhdr_t header; + ase_word_t text; + ase_word_t selector; /* is this necessary? */ + ase_word_t bytecodes; + ase_word_t tmpcount; + ase_word_t argcount; + ase_word_t literals[1]; +}; + +typedef struct ase_stx_method_t ase_stx_method_t; + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ase/stx/misc.c b/ase/stx/misc.c new file mode 100644 index 00000000..c4b75a9b --- /dev/null +++ b/ase/stx/misc.c @@ -0,0 +1,70 @@ +/* + * $Id: misc.c,v 1.3 2007/04/30 08:32:41 bacon Exp $ + */ + +#include + +ase_word_t ase_stx_hash (const void* data, ase_word_t len) +{ + ase_word_t h = 0; + ase_byte_t* bp, * be; + + bp = (ase_byte_t*)data; be = bp + len; + while (bp < be) h = h * 31 + *bp++; + + return h; +} + +ase_word_t ase_stx_strhash (const ase_char_t* str) +{ + ase_word_t h = 0; + ase_byte_t* bp, * be; + const ase_char_t* p = str; + + while (*p != ASE_T('\0')) { + bp = (ase_byte_t*)p; + be = bp + ase_sizeof(ase_char_t); + while (bp < be) h = h * 31 + *bp++; + p++; + } + + return h; +} + +ase_word_t ase_stx_strxhash (const ase_char_t* str, ase_word_t len) +{ + ase_word_t h = 0; + ase_byte_t* bp, * be; + const ase_char_t* p = str, * end = str + len; + + while (p < end) { + bp = (ase_byte_t*)p; + be = bp + ase_sizeof(ase_char_t); + while (bp < be) h = h * 31 + *bp++; + p++; + } + + return h; +} + +ase_char_t* ase_stx_strword ( + const ase_char_t* str, const ase_char_t* word, ase_word_t* word_index) +{ + ase_char_t* p = (ase_char_t*)str; + ase_char_t* tok; + ase_size_t len; + ase_word_t index = 0; + + while (p != ASE_NULL) { + p = ase_strtok (p, ASE_T(""), &tok, &len); + if (ase_strxcmp (tok, len, word) == 0) { + *word_index = index; + return tok; + } + + index++; + } + + *word_index = index; + return ASE_NULL; +} diff --git a/ase/stx/misc.h b/ase/stx/misc.h new file mode 100644 index 00000000..9d9b6464 --- /dev/null +++ b/ase/stx/misc.h @@ -0,0 +1,63 @@ +/* + * $Id: misc.h,v 1.3 2007/04/30 08:32:41 bacon Exp $ + */ + +#ifndef _ASE_STX_MISC_H_ +#define _ASE_STX_MISC_H_ + +#include + +/* TODO: remove this header later */ +#include + +#ifdef _DOS + #include + #include + #include + #include + #include + #include + + #define ase_assert assert + #define ase_malloc malloc + #define ase_realloc realloc + #define ase_free free + #define ase_va_list va_list + #define ase_va_start va_start + #define ase_va_end va_end + #define ase_va_arg va_arg + #define ase_isspace isspace + #define ase_isdigit isdigit + #define ase_isalpha isalpha + #define ase_isalnum isalnum +#else + #include + #include + #include + #include + #include + #include +#endif + +#if defined(__BORLANDC__) || defined(_MSC_VER) + #define INLINE +#else + #define INLINE inline +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +ase_word_t ase_stx_hash (const void* data, ase_word_t len); +ase_word_t ase_stx_strhash (const ase_char_t* str); +ase_word_t ase_stx_strxhash (const ase_char_t* str, ase_word_t len); + +ase_char_t* ase_stx_strword ( + const ase_char_t* str, const ase_char_t* word, ase_word_t* word_index); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ase/stx/name.c b/ase/stx/name.c new file mode 100644 index 00000000..d269b239 --- /dev/null +++ b/ase/stx/name.c @@ -0,0 +1,146 @@ +/* + * $Id: name.c,v 1.3 2007/04/30 08:32:41 bacon Exp $ + */ + +#include +#include + +ase_stx_name_t* ase_stx_name_open ( + ase_stx_name_t* name, ase_word_t capacity) +{ + if (capacity == 0) + capacity = ase_countof(name->static_buffer) - 1; + + if (name == ASE_NULL) { + name = (ase_stx_name_t*) + ase_malloc (ase_sizeof(ase_stx_name_t)); + if (name == ASE_NULL) return ASE_NULL; + name->__dynamic = ase_true; + } + else name->__dynamic = ase_false; + + if (capacity < ase_countof(name->static_buffer)) { + name->buffer = name->static_buffer; + } + else { + name->buffer = (ase_char_t*) + ase_malloc ((capacity + 1) * ase_sizeof(ase_char_t)); + if (name->buffer == ASE_NULL) { + if (name->__dynamic) ase_free (name); + return ASE_NULL; + } + } + + name->size = 0; + name->capacity = capacity; + name->buffer[0] = ASE_T('\0'); + + return name; +} + +void ase_stx_name_close (ase_stx_name_t* name) +{ + if (name->capacity >= ase_countof(name->static_buffer)) { + ase_assert (name->buffer != name->static_buffer); + ase_free (name->buffer); + } + if (name->__dynamic) ase_free (name); +} + +int ase_stx_name_addc (ase_stx_name_t* name, ase_cint_t c) +{ + if (name->size >= name->capacity) { + /* double the capacity. */ + ase_size_t new_capacity = name->capacity * 2; + + if (new_capacity >= ase_countof(name->static_buffer)) { + ase_char_t* space; + + if (name->capacity < ase_countof(name->static_buffer)) { + space = (ase_char_t*)ase_malloc ( + (new_capacity + 1) * ase_sizeof(ase_char_t)); + if (space == ASE_NULL) return -1; + + /* don't need to copy up to the terminating null */ + ase_memcpy (space, name->buffer, + name->capacity * ase_sizeof(ase_char_t)); + } + else { + space = (ase_char_t*)ase_realloc (name->buffer, + (new_capacity + 1) * ase_sizeof(ase_char_t)); + if (space == ASE_NULL) return -1; + } + + name->buffer = space; + } + + name->capacity = new_capacity; + } + + name->buffer[name->size++] = c; + name->buffer[name->size] = ASE_T('\0'); + return 0; +} + +int ase_stx_name_adds (ase_stx_name_t* name, const ase_char_t* s) +{ + while (*s != ASE_T('\0')) { + if (ase_stx_name_addc(name, *s) == -1) return -1; + s++; + } + + return 0; +} + +void ase_stx_name_clear (ase_stx_name_t* name) +{ + name->size = 0; + name->buffer[0] = ASE_T('\0'); +} + +ase_char_t* ase_stx_name_yield (ase_stx_name_t* name, ase_word_t capacity) +{ + ase_char_t* old_buffer, * new_buffer; + + if (capacity == 0) + capacity = ase_countof(name->static_buffer) - 1; + + if (name->capacity < ase_countof(name->static_buffer)) { + old_buffer = (ase_char_t*) + ase_malloc((name->capacity + 1) * ase_sizeof(ase_char_t)); + if (old_buffer == ASE_NULL) return ASE_NULL; + ase_memcpy (old_buffer, name->buffer, + (name->capacity + 1) * ase_sizeof(ase_char_t)); + } + else old_buffer = name->buffer; + + if (capacity < ase_countof(name->static_buffer)) { + new_buffer = name->static_buffer; + } + else { + new_buffer = (ase_char_t*) + ase_malloc((capacity + 1) * ase_sizeof(ase_char_t)); + if (new_buffer == ASE_NULL) return ASE_NULL; + } + + name->buffer = new_buffer; + name->size = 0; + name->capacity = capacity; + name->buffer[0] = ASE_T('\0'); + + return old_buffer; +} + +int ase_stx_name_compare (ase_stx_name_t* name, const ase_char_t* str) +{ + ase_char_t* p = name->buffer; + ase_word_t index = 0; + + while (index < name->size) { + if (*p > *str) return 1; + if (*p < *str) return -1; + index++; p++; str++; + } + + return (*str == ASE_T('\0'))? 0: -1; +} diff --git a/ase/stx/name.h b/ase/stx/name.h new file mode 100644 index 00000000..6e0e85a3 --- /dev/null +++ b/ase/stx/name.h @@ -0,0 +1,39 @@ +/* + * $Id: name.h,v 1.3 2007/04/30 08:32:41 bacon Exp $ + */ + +#ifndef _ASE_STX_NAME_H_ +#define _ASE_STX_NAME_H_ + +#include + +struct ase_stx_name_t +{ + ase_word_t capacity; + ase_word_t size; + ase_char_t* buffer; + ase_char_t static_buffer[128]; + ase_bool_t __dynamic; +}; + +typedef struct ase_stx_name_t ase_stx_name_t; + +#ifdef __cplusplus +extern "C" { +#endif + +ase_stx_name_t* ase_stx_name_open ( + ase_stx_name_t* name, ase_word_t capacity); +void ase_stx_name_close (ase_stx_name_t* name); + +int ase_stx_name_addc (ase_stx_name_t* name, ase_cint_t c); +int ase_stx_name_adds (ase_stx_name_t* name, const ase_char_t* s); +void ase_stx_name_clear (ase_stx_name_t* name); +ase_char_t* ase_stx_name_yield (ase_stx_name_t* name, ase_word_t capacity); +int ase_stx_name_compare (ase_stx_name_t* name, const ase_char_t* str); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ase/stx/object.c b/ase/stx/object.c new file mode 100644 index 00000000..f19caaad --- /dev/null +++ b/ase/stx/object.c @@ -0,0 +1,246 @@ +/* + * $Id: object.c,v 1.3 2007/04/30 08:32:41 bacon Exp $ + */ + +#include +#include +#include +#include +#include + +/* n: number of instance variables */ +ase_word_t ase_stx_alloc_word_object ( + ase_stx_t* stx, const ase_word_t* data, ase_word_t nfields, + const ase_word_t* variable_data, ase_word_t variable_nfields) +{ + ase_word_t idx, n; + ase_stx_word_object_t* obj; + + ase_assert (stx->nil == ASE_STX_NIL); + + /* bytes to allocated = + * (number of instance variables + + * number of variable instance variables) * word_size + */ + n = nfields + variable_nfields; + idx = ase_stx_memory_alloc (&stx->memory, + n * ase_sizeof(ase_word_t) + ase_sizeof(ase_stx_object_t)); + if (idx >= stx->memory.capacity) return idx; /* failed TODO: return a difference value OINDEX_INVALID */ + + idx = ASE_STX_TO_OINDEX(idx); + obj = ASE_STX_WORD_OBJECT(stx,idx); + obj->header.class = stx->nil; + obj->header.access = (n << 2) | ASE_STX_WORD_INDEXED; + + if (variable_data == ASE_NULL) { + while (n > nfields) obj->data[--n] = stx->nil; + } + else { + while (n > nfields) { + n--; obj->data[n] = variable_data[n - nfields]; + } + } + + if (data == ASE_NULL) { + while (n > 0) obj->data[--n] = stx->nil; + } + else { + while (n > 0) { + n--; obj->data[n] = data[n]; + } + } + + return idx; +} + +/* n: number of bytes */ +ase_word_t ase_stx_alloc_byte_object ( + ase_stx_t* stx, const ase_byte_t* data, ase_word_t n) +{ + ase_word_t idx; + ase_stx_byte_object_t* obj; + + ase_assert (stx->nil == ASE_STX_NIL); + + idx = ase_stx_memory_alloc ( + &stx->memory, n + ase_sizeof(ase_stx_object_t)); + if (idx >= stx->memory.capacity) return idx; /* failed */ + + idx = ASE_STX_TO_OINDEX(idx); + obj = ASE_STX_BYTE_OBJECT(stx,idx); + obj->header.class = stx->nil; + obj->header.access = (n << 2) | ASE_STX_BYTE_INDEXED; + + if (data == ASE_NULL) { + while (n-- > 0) obj->data[n] = 0; + } + else { + while (n-- > 0) obj->data[n] = data[n]; + } + + return idx; +} + +ase_word_t ase_stx_alloc_char_object ( + ase_stx_t* stx, const ase_char_t* str) +{ + return (str == ASE_NULL)? + ase_stx_alloc_char_objectx (stx, ASE_NULL, 0): + ase_stx_alloc_char_objectx (stx, str, ase_strlen(str)); +} + +/* n: number of characters */ +ase_word_t ase_stx_alloc_char_objectx ( + ase_stx_t* stx, const ase_char_t* str, ase_word_t n) +{ + ase_word_t idx; + ase_stx_char_object_t* obj; + + ase_assert (stx->nil == ASE_STX_NIL); + + idx = ase_stx_memory_alloc (&stx->memory, + (n + 1) * ase_sizeof(ase_char_t) + ase_sizeof(ase_stx_object_t)); + if (idx >= stx->memory.capacity) return idx; /* failed */ + + idx = ASE_STX_TO_OINDEX(idx); + obj = ASE_STX_CHAR_OBJECT(stx,idx); + obj->header.class = stx->nil; + obj->header.access = (n << 2) | ASE_STX_CHAR_INDEXED; + obj->data[n] = ASE_T('\0'); + + if (str == ASE_NULL) { + while (n-- > 0) obj->data[n] = ASE_T('\0'); + } + else { + while (n-- > 0) obj->data[n] = str[n]; + } + + return idx; +} + +ase_word_t ase_stx_allocn_char_object (ase_stx_t* stx, ...) +{ + ase_word_t idx, n = 0; + const ase_char_t* p; + ase_va_list ap; + ase_stx_char_object_t* obj; + + ase_assert (stx->nil == ASE_STX_NIL); + + ase_va_start (ap, stx); + while ((p = ase_va_arg(ap, const ase_char_t*)) != ASE_NULL) { + n += ase_strlen(p); + } + ase_va_end (ap); + + idx = ase_stx_memory_alloc (&stx->memory, + (n + 1) * ase_sizeof(ase_char_t) + ase_sizeof(ase_stx_object_t)); + if (idx >= stx->memory.capacity) return idx; /* failed */ + + idx = ASE_STX_TO_OINDEX(idx); + obj = ASE_STX_CHAR_OBJECT(stx,idx); + obj->header.class = stx->nil; + obj->header.access = (n << 2) | ASE_STX_CHAR_INDEXED; + obj->data[n] = ASE_T('\0'); + + ase_va_start (ap, stx); + n = 0; + while ((p = ase_va_arg(ap, const ase_char_t*)) != ASE_NULL) { + while (*p != ASE_T('\0')) { + /*ASE_STX_CHAR_AT(stx,idx,n++) = *p++;*/ + obj->data[n++] = *p++; + } + } + ase_va_end (ap); + + return idx; +} + +ase_word_t ase_stx_hash_object (ase_stx_t* stx, ase_word_t object) +{ + ase_word_t hv; + + if (ASE_STX_IS_SMALLINT(object)) { + ase_word_t tmp = ASE_STX_FROM_SMALLINT(object); + hv = ase_stx_hash(&tmp, ase_sizeof(tmp)); + } + else if (ASE_STX_IS_CHAR_OBJECT(stx,object)) { + /* the additional null is not taken into account */ + hv = ase_stx_hash (ASE_STX_DATA(stx,object), + ASE_STX_SIZE(stx,object) * ase_sizeof(ase_char_t)); + } + else if (ASE_STX_IS_BYTE_OBJECT(stx,object)) { + hv = ase_stx_hash ( + ASE_STX_DATA(stx,object), ASE_STX_SIZE(stx,object)); + } + else { + ase_assert (ASE_STX_IS_WORD_OBJECT(stx,object)); + hv = ase_stx_hash (ASE_STX_DATA(stx,object), + ASE_STX_SIZE(stx,object) * ase_sizeof(ase_word_t)); + } + + return hv; +} + +ase_word_t ase_stx_instantiate ( + ase_stx_t* stx, ase_word_t class, const void* data, + const void* variable_data, ase_word_t variable_nfields) +{ + ase_stx_class_t* class_obj; + ase_word_t spec, nfields, new; + int indexable; + + ase_assert (class != stx->class_smallinteger); + class_obj = (ase_stx_class_t*)ASE_STX_OBJECT(stx, class); + + /* don't instantiate a metaclass whose instance must be + created in a different way */ + /* TODO: maybe delete the following line */ + ase_assert (class_obj->header.class != stx->class_metaclass); + ase_assert (ASE_STX_IS_SMALLINT(class_obj->spec)); + + spec = ASE_STX_FROM_SMALLINT(class_obj->spec); + nfields = (spec >> ASE_STX_SPEC_INDEXABLE_BITS); + indexable = spec & ASE_STX_SPEC_INDEXABLE_MASK; + + if (indexable == ASE_STX_SPEC_BYTE_INDEXABLE) { + ase_assert (nfields == 0 && data == ASE_NULL); + new = ase_stx_alloc_byte_object( + stx, variable_data, variable_nfields); + } + else if (indexable == ASE_STX_SPEC_CHAR_INDEXABLE) { + ase_assert (nfields == 0 && data == ASE_NULL); + new = ase_stx_alloc_char_objectx( + stx, variable_data, variable_nfields); + } + else if (indexable == ASE_STX_SPEC_WORD_INDEXABLE) { + new = ase_stx_alloc_word_object ( + stx, data, nfields, variable_data, variable_nfields); + } + else { + ase_assert (indexable == ASE_STX_SPEC_NOT_INDEXABLE); + ase_assert (variable_nfields == 0 && variable_data == ASE_NULL); + new = ase_stx_alloc_word_object ( + stx, data, nfields, ASE_NULL, 0); + } + + ASE_STX_CLASS(stx, new) = class; + return new; +} + +ase_word_t ase_stx_class (ase_stx_t* stx, ase_word_t obj) +{ + return ASE_STX_IS_SMALLINT(obj)? + stx->class_smallinteger: ASE_STX_CLASS(stx,obj); +} + +ase_word_t ase_stx_classof (ase_stx_t* stx, ase_word_t obj) +{ + return ASE_STX_IS_SMALLINT(obj)? + stx->class_smallinteger: ASE_STX_CLASS(stx,obj); +} + +ase_word_t ase_stx_sizeof (ase_stx_t* stx, ase_word_t obj) +{ + return ASE_STX_IS_SMALLINT(obj)? 1: ASE_STX_SIZE(stx,obj); +} diff --git a/ase/stx/object.h b/ase/stx/object.h new file mode 100644 index 00000000..89f746f7 --- /dev/null +++ b/ase/stx/object.h @@ -0,0 +1,40 @@ +/* + * $Id: object.h,v 1.3 2007/04/30 08:32:41 bacon Exp $ + */ + +#ifndef _ASE_STX_OBJECT_H_ +#define _ASE_STX_OBJECT_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +ase_word_t ase_stx_alloc_word_object ( + ase_stx_t* stx, const ase_word_t* data, ase_word_t nfields, + const ase_word_t* variable_data, ase_word_t variable_nfields); + +ase_word_t ase_stx_alloc_byte_object ( + ase_stx_t* stx, const ase_byte_t* data, ase_word_t n); + +ase_word_t ase_stx_alloc_char_object ( + ase_stx_t* stx, const ase_char_t* str); +ase_word_t ase_stx_alloc_char_objectx ( + ase_stx_t* stx, const ase_char_t* str, ase_word_t n); +ase_word_t ase_stx_allocn_char_object (ase_stx_t* stx, ...); + +ase_word_t ase_stx_hash_object (ase_stx_t* stx, ase_word_t object); + +ase_word_t ase_stx_instantiate ( + ase_stx_t* stx, ase_word_t class_index, const void* data, + const void* variable_data, ase_word_t variable_nfields); +ase_word_t ase_stx_classof (ase_stx_t* stx, ase_word_t obj); +ase_word_t ase_stx_sizeof (ase_stx_t* stx, ase_word_t obj); + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ase/stx/parser.c b/ase/stx/parser.c new file mode 100644 index 00000000..e5a47b09 --- /dev/null +++ b/ase/stx/parser.c @@ -0,0 +1,1608 @@ +/* + * $Id: parser.c,v 1.3 2007/04/30 08:32:41 bacon Exp $ + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +static int __parse_method ( + ase_stx_parser_t* parser, + ase_word_t method_class, void* input); +static int __finish_method (ase_stx_parser_t* parser); + +static int __parse_message_pattern (ase_stx_parser_t* parser); +static int __parse_unary_pattern (ase_stx_parser_t* parser); +static int __parse_binary_pattern (ase_stx_parser_t* parser); +static int __parse_keyword_pattern (ase_stx_parser_t* parser); + +static int __parse_temporaries (ase_stx_parser_t* parser); +static int __parse_primitive (ase_stx_parser_t* parser); +static int __parse_statements (ase_stx_parser_t* parser); +static int __parse_block_statements (ase_stx_parser_t* parser); +static int __parse_statement (ase_stx_parser_t* parser); +static int __parse_expression (ase_stx_parser_t* parser); + +static int __parse_assignment ( + ase_stx_parser_t* parser, const ase_char_t* target); +static int __parse_basic_expression ( + ase_stx_parser_t* parser, const ase_char_t* ident); +static int __parse_primary ( + ase_stx_parser_t* parser, const ase_char_t* ident, ase_bool_t* is_super); +static int __parse_primary_ident ( + ase_stx_parser_t* parser, const ase_char_t* ident, ase_bool_t* is_super); + +static int __parse_block_constructor (ase_stx_parser_t* parser); +static int __parse_message_continuation ( + ase_stx_parser_t* parser, ase_bool_t is_super); +static int __parse_keyword_message ( + ase_stx_parser_t* parser, ase_bool_t is_super); +static int __parse_binary_message ( + ase_stx_parser_t* parser, ase_bool_t is_super); +static int __parse_unary_message ( + ase_stx_parser_t* parser, ase_bool_t is_super); + +static int __get_token (ase_stx_parser_t* parser); +static int __get_ident (ase_stx_parser_t* parser); +static int __get_numlit (ase_stx_parser_t* parser, ase_bool_t negated); +static int __get_charlit (ase_stx_parser_t* parser); +static int __get_strlit (ase_stx_parser_t* parser); +static int __get_binary (ase_stx_parser_t* parser); +static int __skip_spaces (ase_stx_parser_t* parser); +static int __skip_comment (ase_stx_parser_t* parser); +static int __get_char (ase_stx_parser_t* parser); +static int __unget_char (ase_stx_parser_t* parser, ase_cint_t c); +static int __open_input (ase_stx_parser_t* parser, void* input); +static int __close_input (ase_stx_parser_t* parser); + +ase_stx_parser_t* ase_stx_parser_open (ase_stx_parser_t* parser, ase_stx_t* stx) +{ + if (parser == ASE_NULL) { + parser = (ase_stx_parser_t*) + ase_malloc (ase_sizeof(ase_stx_parser_t)); + if (parser == ASE_NULL) return ASE_NULL; + parser->__dynamic = ase_true; + } + else parser->__dynamic = ase_false; + + if (ase_stx_name_open (&parser->method_name, 0) == ASE_NULL) { + if (parser->__dynamic) ase_free (parser); + return ASE_NULL; + } + + if (ase_stx_token_open (&parser->token, 0) == ASE_NULL) { + ase_stx_name_close (&parser->method_name); + if (parser->__dynamic) ase_free (parser); + return ASE_NULL; + } + + if (ase_arr_open ( + &parser->bytecode, 256, + ase_sizeof(ase_byte_t), ASE_NULL) == ASE_NULL) { + ase_stx_name_close (&parser->method_name); + ase_stx_token_close (&parser->token); + if (parser->__dynamic) ase_free (parser); + return ASE_NULL; + } + + parser->stx = stx; + parser->error_code = ASE_STX_PARSER_ERROR_NONE; + + parser->temporary_count = 0; + parser->argument_count = 0; + parser->literal_count = 0; + + parser->curc = ASE_T_EOF; + parser->ungotc_count = 0; + + parser->input_owner = ASE_NULL; + parser->input_func = ASE_NULL; + return parser; +} + +void ase_stx_parser_close (ase_stx_parser_t* parser) +{ + while (parser->temporary_count > 0) { + ase_free (parser->temporaries[--parser->temporary_count]); + } + parser->argument_count = 0; + + ase_arr_close (&parser->bytecode); + ase_stx_name_close (&parser->method_name); + ase_stx_token_close (&parser->token); + + if (parser->__dynamic) ase_free (parser); +} + +#define GET_CHAR(parser) \ + do { if (__get_char(parser) == -1) return -1; } while (0) +#define UNGET_CHAR(parser,c) \ + do { if (__unget_char(parser,c) == -1) return -1; } while (0) +#define GET_TOKEN(parser) \ + do { if (__get_token(parser) == -1) return -1; } while (0) +#define ADD_TOKEN_CHAR(parser,c) \ + do { \ + if (ase_stx_token_addc (&(parser)->token, c) == -1) { \ + (parser)->error_code = ASE_STX_PARSER_ERROR_MEMORY; \ + return -1; \ + } \ + } while (0) + +const ase_char_t* ase_stx_parser_error_string (ase_stx_parser_t* parser) +{ + static const ase_char_t* msg[] = + { + ASE_T("no error"), + + ASE_T("input fucntion not ready"), + ASE_T("input function error"), + ASE_T("out of memory"), + + ASE_T("invalid character"), + ASE_T("incomplete character literal"), + ASE_T("incomplete string literal"), + ASE_T("incomplete literal"), + + ASE_T("message selector"), + ASE_T("invalid argument name"), + ASE_T("too many arguments"), + + ASE_T("invalid primitive type"), + ASE_T("primitive number expected"), + ASE_T("primitive number out of range"), + ASE_T("primitive not closed"), + + ASE_T("temporary list not closed"), + ASE_T("too many temporaries"), + ASE_T("cannot redefine pseudo variable"), + ASE_T("invalid primary/expression-start"), + + ASE_T("no period at end of statement"), + ASE_T("no closing parenthesis"), + ASE_T("block argument name missing"), + ASE_T("block argument list not closed"), + ASE_T("block not closed"), + + ASE_T("undeclared name"), + ASE_T("too many literals") + }; + + if (parser->error_code >= 0 && + parser->error_code < ase_countof(msg)) return msg[parser->error_code]; + + return ASE_T("unknown error"); +} + +static INLINE ase_bool_t __is_pseudo_variable (const ase_stx_token_t* token) +{ + return token->type == ASE_STX_TOKEN_IDENT && + (ase_strcmp(token->name.buffer, ASE_T("self")) == 0 || + ase_strcmp(token->name.buffer, ASE_T("super")) == 0 || + ase_strcmp(token->name.buffer, ASE_T("nil")) == 0 || + ase_strcmp(token->name.buffer, ASE_T("true")) == 0 || + ase_strcmp(token->name.buffer, ASE_T("false")) == 0); +} + +static INLINE ase_bool_t __is_vbar_token (const ase_stx_token_t* token) +{ + return + token->type == ASE_STX_TOKEN_BINARY && + token->name.size == 1 && + token->name.buffer[0] == ASE_T('|'); +} + +static INLINE ase_bool_t __is_primitive_opener (const ase_stx_token_t* token) +{ + return + token->type == ASE_STX_TOKEN_BINARY && + token->name.size == 1 && + token->name.buffer[0] == ASE_T('<'); +} + +static INLINE ase_bool_t __is_primitive_closer (const ase_stx_token_t* token) +{ + return + token->type == ASE_STX_TOKEN_BINARY && + token->name.size == 1 && + token->name.buffer[0] == ASE_T('>'); +} + +static INLINE ase_bool_t __is_binary_char (ase_cint_t c) +{ + /* + * binaryCharacter ::= + * '!' | '%' | '&' | '*' | '+' | ',' | + * '/' | '<' | '=' | '>' | '?' | '@' | + * '\' | '~' | '|' | '-' + */ + + return + c == ASE_T('!') || c == ASE_T('%') || + c == ASE_T('&') || c == ASE_T('*') || + c == ASE_T('+') || c == ASE_T(',') || + c == ASE_T('/') || c == ASE_T('<') || + c == ASE_T('=') || c == ASE_T('>') || + c == ASE_T('?') || c == ASE_T('@') || + c == ASE_T('\\') || c == ASE_T('|') || + c == ASE_T('~') || c == ASE_T('-'); +} + +static INLINE ase_bool_t __is_closing_char (ase_cint_t c) +{ + return + c == ASE_T('.') || c == ASE_T(']') || + c == ASE_T(')') || c == ASE_T(';') || + c == ASE_T('\"') || c == ASE_T('\''); +} + +#define EMIT_CODE_TEST(parser,high,low) \ + do { if (__emit_code_test(parser,high,low) == -1) return -1; } while (0) + +#define EMIT_CODE(parser,code) \ + do { if (__emit_code(parser,code) == -1) return -1; } while(0) + +#define EMIT_PUSH_RECEIVER_VARIABLE(parser,pos) \ + do { \ + if (__emit_stack_positional ( \ + parser, PUSH_RECEIVER_VARIABLE, pos) == -1) return -1; \ + } while (0) + +#define EMIT_PUSH_TEMPORARY_LOCATION(parser,pos) \ + do { \ + if (__emit_stack_positional ( \ + parser, PUSH_TEMPORARY_LOCATION, pos) == -1) return -1; \ + } while (0) + +#define EMIT_PUSH_LITERAL_CONSTANT(parser,pos) \ + do { \ + if (__emit_stack_positional ( \ + parser, PUSH_LITERAL_CONSTANT, pos) == -1) return -1; \ + } while (0) + + +#define EMIT_PUSH_LITERAL_VARIABLE(parser,pos) \ + do { \ + if (__emit_stack_positional ( \ + parser, PUSH_LITERAL_VARIABLE, pos) == -1) return -1; \ + } while (0) + +#define EMIT_STORE_RECEIVER_VARIABLE(parser,pos) \ + do { \ + if (__emit_stack_positional ( \ + parser, STORE_RECEIVER_VARIABLE, pos) == -1) return -1; \ + } while (0) + +#define EMIT_STORE_TEMPORARY_LOCATION(parser,pos) \ + do { \ + if (__emit_stack_positional ( \ + parser, STORE_TEMPORARY_LOCATION, pos) == -1) return -1; \ + } while (0) + + +#define EMIT_POP_STACK_TOP(parser) EMIT_CODE(parser, POP_STACK_TOP) +#define EMIT_DUPLICATE_STACK_TOP(parser) EMIT_CODE(parser, DUPLICATE_STACK_TOP) +#define EMIT_PUSH_ACTIVE_CONTEXT(parser) EMIT_CODE(parser, PUSH_ACTIVE_CONTEXT) +#define EMIT_RETURN_FROM_MESSAGE(parser) EMIT_CODE(parser, RETURN_FROM_MESSAGE) +#define EMIT_RETURN_FROM_BLOCK(parser) EMIT_CODE(parser, RETURN_FROM_BLOCK) + +#define EMIT_SEND_TO_SELF(parser,nargs,selector) \ + do { \ + if (__emit_send_to_self(parser,nargs,selector) == -1) return -1; \ + } while (0) + +#define EMIT_SEND_TO_SUPER(parser,nargs,selector) \ + do { \ + if (__emit_send_to_super(parser,nargs,selector) == -1) return -1; \ + } while (0) + +#define EMIT_DO_PRIMITIVE(parser,no) \ + do { if (__emit_do_primitive(parser,no) == -1) return -1; } while(0) + +static INLINE int __emit_code_test ( + ase_stx_parser_t* parser, const ase_char_t* high, const ase_char_t* low) +{ + ase_printf (ASE_T("CODE: %s %s\n"), high, low); + return 0; +} + +static INLINE int __emit_code (ase_stx_parser_t* parser, ase_byte_t code) +{ + if (ase_arr_adddatum(&parser->bytecode, &code) == ASE_NULL) { + parser->error_code = ASE_STX_PARSER_ERROR_MEMORY; + return -1; + } + + return 0; +} + +static INLINE int __emit_stack_positional ( + ase_stx_parser_t* parser, int opcode, int pos) +{ + ase_assert (pos >= 0x0 && pos <= 0xFF); + + if (pos <= 0x0F) { + EMIT_CODE (parser, (opcode & 0xF0) | (pos & 0x0F)); + } + else { + EMIT_CODE (parser, (opcode >> 4) & 0x6F); + EMIT_CODE (parser, pos & 0xFF); + } + + return 0; +} + +static INLINE int __emit_send_to_self ( + ase_stx_parser_t* parser, int nargs, int selector) +{ + ase_assert (nargs >= 0x00 && nargs <= 0xFF); + ase_assert (selector >= 0x00 && selector <= 0xFF); + + if (nargs <= 0x08 && selector <= 0x1F) { + EMIT_CODE (parser, SEND_TO_SELF); + EMIT_CODE (parser, (nargs << 5) | selector); + } + else { + EMIT_CODE (parser, SEND_TO_SELF_EXTENDED); + EMIT_CODE (parser, nargs); + EMIT_CODE (parser, selector); + } + + return 0; +} + +static INLINE int __emit_send_to_super ( + ase_stx_parser_t* parser, int nargs, int selector) +{ + ase_assert (nargs >= 0x00 && nargs <= 0xFF); + ase_assert (selector >= 0x00 && selector <= 0xFF); + + if (nargs <= 0x08 && selector <= 0x1F) { + EMIT_CODE (parser, SEND_TO_SUPER); + EMIT_CODE (parser, (nargs << 5) | selector); + } + else { + EMIT_CODE (parser, SEND_TO_SUPER_EXTENDED); + EMIT_CODE (parser, nargs); + EMIT_CODE (parser, selector); + } + + return 0; +} + +static INLINE int __emit_do_primitive (ase_stx_parser_t* parser, int no) +{ + ase_assert (no >= 0x0 && no <= 0xFFF); + + EMIT_CODE (parser, DO_PRIMITIVE | ((no >> 8) & 0x0F)); + EMIT_CODE (parser, no & 0xFF); + + return 0; +} + +static int __add_literal (ase_stx_parser_t* parser, ase_word_t literal) +{ + ase_word_t i; + + for (i = 0; i < parser->literal_count; i++) { + /* + * it would remove redundancy of symbols and small integers. + * more complex redundacy check may be done somewhere else + * like in __add_string_literal. + */ + if (parser->literals[i] == literal) return i; + } + + if (parser->literal_count >= ase_countof(parser->literals)) { + parser->error_code = ASE_STX_PARSER_ERROR_TOO_MANY_LITERALS; + return -1; + } + + parser->literals[parser->literal_count++] = literal; + return parser->literal_count - 1; +} + +static int __add_character_literal (ase_stx_parser_t* parser, ase_char_t ch) +{ + ase_word_t i, c, literal; + ase_stx_t* stx = parser->stx; + + for (i = 0; i < parser->literal_count; i++) { + c = ASE_STX_IS_SMALLINT(parser->literals[i])? + stx->class_smallinteger: ASE_STX_CLASS (stx, parser->literals[i]); + if (c != stx->class_character) continue; + + if (ch == ASE_STX_CHAR_AT(stx,parser->literals[i],0)) return i; + } + + literal = ase_stx_instantiate ( + stx, stx->class_character, &ch, ASE_NULL, 0); + return __add_literal (parser, literal); +} + +static int __add_string_literal ( + ase_stx_parser_t* parser, const ase_char_t* str, ase_word_t size) +{ + ase_word_t i, c, literal; + ase_stx_t* stx = parser->stx; + + for (i = 0; i < parser->literal_count; i++) { + c = ASE_STX_IS_SMALLINT(parser->literals[i])? + stx->class_smallinteger: ASE_STX_CLASS (stx, parser->literals[i]); + if (c != stx->class_string) continue; + + if (ase_strxncmp (str, size, + ASE_STX_DATA(stx,parser->literals[i]), + ASE_STX_SIZE(stx,parser->literals[i])) == 0) return i; + } + + literal = ase_stx_instantiate ( + stx, stx->class_string, ASE_NULL, str, size); + return __add_literal (parser, literal); +} + +static int __add_symbol_literal ( + ase_stx_parser_t* parser, const ase_char_t* str, ase_word_t size) +{ + ase_stx_t* stx = parser->stx; + return __add_literal (parser, ase_stx_new_symbolx(stx, str, size)); +} + +int ase_stx_parser_parse_method ( + ase_stx_parser_t* parser, ase_word_t method_class, void* input) +{ + int n; + + if (parser->input_func == ASE_NULL) { + parser->error_code = ASE_STX_PARSER_ERROR_INPUT_FUNC; + return -1; + } + + parser->method_class = method_class; + if (__open_input(parser, input) == -1) return -1; + n = __parse_method (parser, method_class, input); + if (__close_input(parser) == -1) return -1; + + return n; +} + +static int __parse_method ( + ase_stx_parser_t* parser, ase_word_t method_class, void* input) +{ + /* + * ::= + * [] [] [] + */ + + GET_CHAR (parser); + GET_TOKEN (parser); + + ase_stx_name_clear (&parser->method_name); + ase_arr_clear (&parser->bytecode); + + while (parser->temporary_count > 0) { + ase_free (parser->temporaries[--parser->temporary_count]); + } + parser->argument_count = 0; + parser->literal_count = 0; + + if (__parse_message_pattern(parser) == -1) return -1; + if (__parse_temporaries(parser) == -1) return -1; + if (__parse_primitive(parser) == -1) return -1; + if (__parse_statements(parser) == -1) return -1; + if (__finish_method (parser) == -1) return -1; + + return 0; +} + +static int __finish_method (ase_stx_parser_t* parser) +{ + ase_stx_t* stx = parser->stx; + ase_stx_class_t* class_obj; + ase_stx_method_t* method_obj; + ase_word_t method, selector; + + ase_assert (parser->bytecode.size != 0); + + class_obj = (ase_stx_class_t*) + ASE_STX_OBJECT(stx, parser->method_class); + + if (class_obj->methods == stx->nil) { + /* TODO: reconfigure method dictionary size */ + class_obj->methods = ase_stx_instantiate ( + stx, stx->class_system_dictionary, + ASE_NULL, ASE_NULL, 64); + } + ase_assert (class_obj->methods != stx->nil); + + selector = ase_stx_new_symbolx ( + stx, parser->method_name.buffer, parser->method_name.size); + + method = ase_stx_instantiate(stx, stx->class_method, + ASE_NULL, parser->literals, parser->literal_count); + method_obj = (ase_stx_method_t*)ASE_STX_OBJECT(stx, method); + + /* TODO: text saving must be optional */ + /*method_obj->text = ase_stx_instantiate ( + stx, stx->class_string, ASE_NULL, + parser->text, ase_strlen(parser->text)); + */ + method_obj->selector = selector; + method_obj->bytecodes = ase_stx_instantiate ( + stx, stx->class_bytearray, ASE_NULL, + parser->bytecode.buf, parser->bytecode.size); + + /* TODO: better way to store argument count & temporary count */ + method_obj->tmpcount = + ASE_STX_TO_SMALLINT(parser->temporary_count - parser->argument_count); + method_obj->argcount = ASE_STX_TO_SMALLINT(parser->argument_count); + + ase_stx_dict_put (stx, class_obj->methods, selector, method); + return 0; +} + +static int __parse_message_pattern (ase_stx_parser_t* parser) +{ + /* + * ::= + * | | + * ::= unarySelector + * ::= binarySelector + * ::= (keyword )+ + */ + int n; + + if (parser->token.type == ASE_STX_TOKEN_IDENT) { + n = __parse_unary_pattern (parser); + } + else if (parser->token.type == ASE_STX_TOKEN_BINARY) { + n = __parse_binary_pattern (parser); + } + else if (parser->token.type == ASE_STX_TOKEN_KEYWORD) { + n = __parse_keyword_pattern (parser); + } + else { + parser->error_code = ASE_STX_PARSER_ERROR_MESSAGE_SELECTOR; + n = -1; + } + + parser->temporary_count = parser->argument_count; + return n; +} + +static int __parse_unary_pattern (ase_stx_parser_t* parser) +{ + /* TODO: check if the method name exists */ + + if (ase_stx_name_adds( + &parser->method_name, parser->token.name.buffer) == -1) { + parser->error_code = ASE_STX_PARSER_ERROR_MEMORY; + return -1; + } + + GET_TOKEN (parser); + return 0; +} + +static int __parse_binary_pattern (ase_stx_parser_t* parser) +{ + /* TODO: check if the method name exists */ + + if (ase_stx_name_adds( + &parser->method_name, parser->token.name.buffer) == -1) { + parser->error_code = ASE_STX_PARSER_ERROR_MEMORY; + return -1; + } + + GET_TOKEN (parser); + if (parser->token.type != ASE_STX_TOKEN_IDENT) { + parser->error_code = ASE_STX_PARSER_ERROR_ARGUMENT_NAME; + return -1; + } + + if (parser->argument_count >= ase_countof(parser->temporaries)) { + parser->error_code = ASE_STX_PARSER_ERROR_TOO_MANY_ARGUMENTS; + return -1; + } + + /* TODO: check for duplicate entries...in instvars */ + parser->temporaries[parser->argument_count] = + ase_stx_token_yield (&parser->token, 0); + if (parser->temporaries[parser->argument_count] == ASE_NULL) { + parser->error_code = ASE_STX_PARSER_ERROR_MEMORY; + return -1; + } + parser->argument_count++; + + GET_TOKEN (parser); + return 0; +} + +static int __parse_keyword_pattern (ase_stx_parser_t* parser) +{ + do { + if (ase_stx_name_adds( + &parser->method_name, parser->token.name.buffer) == -1) { + parser->error_code = ASE_STX_PARSER_ERROR_MEMORY; + return -1; + } + + GET_TOKEN (parser); + if (parser->token.type != ASE_STX_TOKEN_IDENT) { + parser->error_code = ASE_STX_PARSER_ERROR_ARGUMENT_NAME; + return -1; + } + + if (__is_pseudo_variable(&parser->token)) { + parser->error_code = ASE_STX_PARSER_ERROR_PSEUDO_VARIABLE; + return -1; + } + + if (parser->argument_count >= ase_countof(parser->temporaries)) { + parser->error_code = ASE_STX_PARSER_ERROR_TOO_MANY_ARGUMENTS; + return -1; + } + + parser->temporaries[parser->argument_count] = + ase_stx_token_yield (&parser->token, 0); + if (parser->temporaries[parser->argument_count] == ASE_NULL) { + parser->error_code = ASE_STX_PARSER_ERROR_MEMORY; + return -1; + } + +/* TODO: check for duplicate entries...in instvars/arguments */ + parser->argument_count++; + + GET_TOKEN (parser); + } while (parser->token.type == ASE_STX_TOKEN_KEYWORD); + + /* TODO: check if the method name exists */ + /* if it exists, collapse arguments */ +ase_printf (ASE_T("METHOD NAME ==> [%s]\n"), parser->method_name.buffer); + + return 0; +} + +static int __parse_temporaries (ase_stx_parser_t* parser) +{ + /* + * ::= '|' '|' + * ::= identifier* + */ + + if (!__is_vbar_token(&parser->token)) return 0; + + GET_TOKEN (parser); + while (parser->token.type == ASE_STX_TOKEN_IDENT) { + if (parser->temporary_count >= ase_countof(parser->temporaries)) { + parser->error_code = ASE_STX_PARSER_ERROR_TOO_MANY_TEMPORARIES; + return -1; + } + + if (__is_pseudo_variable(&parser->token)) { + parser->error_code = ASE_STX_PARSER_ERROR_PSEUDO_VARIABLE; + return -1; + } + + parser->temporaries[parser->temporary_count] = + ase_stx_token_yield (&parser->token, 0); + if (parser->temporaries[parser->temporary_count] == ASE_NULL) { + parser->error_code = ASE_STX_PARSER_ERROR_MEMORY; + return -1; + } + +/* TODO: check for duplicate entries...in instvars/arguments/temporaries */ + parser->temporary_count++; + + GET_TOKEN (parser); + } + if (!__is_vbar_token(&parser->token)) { + parser->error_code = ASE_STX_PARSER_ERROR_TEMPORARIES_NOT_CLOSED; + return -1; + } + + GET_TOKEN (parser); + return 0; +} + +static int __parse_primitive (ase_stx_parser_t* parser) +{ + /* + * ::= '<' 'primitive:' number '>' + */ + + int prim_no; + + if (!__is_primitive_opener(&parser->token)) return 0; + GET_TOKEN (parser); + + if (parser->token.type != ASE_STX_TOKEN_KEYWORD || + ase_strcmp (parser->token.name.buffer, ASE_T("primitive:")) != 0) { + parser->error_code = ASE_STX_PARSER_ERROR_PRIMITIVE_KEYWORD; + return -1; + } + + GET_TOKEN (parser); /* TODO: only integer */ + if (parser->token.type != ASE_STX_TOKEN_NUMLIT) { + parser->error_code = ASE_STX_PARSER_ERROR_PRIMITIVE_NUMBER; + return -1; + } + +/*TODO: more checks the validity of the primitive number */ + if (!ase_stristype(parser->token.name.buffer, ase_isdigit)) { + parser->error_code = ASE_STX_PARSER_ERROR_PRIMITIVE_NUMBER; + return -1; + } + + ASE_STRTOI (prim_no, parser->token.name.buffer, ASE_NULL, 10); + if (prim_no < 0 || prim_no > 0xFF) { + parser->error_code = ASE_STX_PARSER_ERROR_PRIMITIVE_NUMBER_RANGE; + return -1; + } + + EMIT_DO_PRIMITIVE (parser, prim_no); + + GET_TOKEN (parser); + if (!__is_primitive_closer(&parser->token)) { + parser->error_code = ASE_STX_PARSER_ERROR_PRIMITIVE_NOT_CLOSED; + return -1; + } + + GET_TOKEN (parser); + return 0; +} + +static int __parse_statements (ase_stx_parser_t* parser) +{ + /* + * ::= (ORIGINAL->maybe wrong) + * ( ['.'] ) | + * ( ['.' []]) + * ::= (REVISED->correct?) + * ['. []] + */ + + while (parser->token.type != ASE_STX_TOKEN_END) { + if (__parse_statement (parser) == -1) return -1; + + if (parser->token.type == ASE_STX_TOKEN_PERIOD) { + GET_TOKEN (parser); + continue; + } + + if (parser->token.type != ASE_STX_TOKEN_END) { + parser->error_code = ASE_STX_PARSER_ERROR_NO_PERIOD; + return -1; + } + } + + EMIT_CODE (parser, RETURN_RECEIVER); + return 0; +} + +static int __parse_block_statements (ase_stx_parser_t* parser) +{ + while (parser->token.type != ASE_STX_TOKEN_RBRACKET && + parser->token.type != ASE_STX_TOKEN_END) { + + if (__parse_statement(parser) == -1) return -1; + if (parser->token.type != ASE_STX_TOKEN_PERIOD) break; + GET_TOKEN (parser); + } + + return 0; +} + +static int __parse_statement (ase_stx_parser_t* parser) +{ + /* + * ::= | + * ::= returnOperator + * returnOperator ::= '^' + */ + + if (parser->token.type == ASE_STX_TOKEN_RETURN) { + GET_TOKEN (parser); + if (__parse_expression(parser) == -1) return -1; + EMIT_RETURN_FROM_MESSAGE (parser); + } + else { + if (__parse_expression(parser) == -1) return -1; + } + + return 0; +} + +static int __parse_expression (ase_stx_parser_t* parser) +{ + /* + * ::= | + * ::= assignmentOperator + * ::= [ ] + * ::= identifier + * assignmentOperator ::= ':=' + */ + ase_stx_t* stx = parser->stx; + + if (parser->token.type == ASE_STX_TOKEN_IDENT) { + ase_char_t* ident = ase_stx_token_yield (&parser->token, 0); + if (ident == ASE_NULL) { + parser->error_code = ASE_STX_PARSER_ERROR_MEMORY; + return -1; + } + + GET_TOKEN (parser); + if (parser->token.type == ASE_STX_TOKEN_ASSIGN) { + GET_TOKEN (parser); + if (__parse_assignment(parser, ident) == -1) { + ase_free (ident); + return -1; + } + } + else { + if (__parse_basic_expression(parser, ident) == -1) { + ase_free (ident); + return -1; + } + } + + ase_free (ident); + } + else { + if (__parse_basic_expression(parser, ASE_NULL) == -1) return -1; + } + + return 0; +} + +static int __parse_basic_expression ( + ase_stx_parser_t* parser, const ase_char_t* ident) +{ + /* + * ::= [ ] + */ + ase_bool_t is_super; + + if (__parse_primary(parser, ident, &is_super) == -1) return -1; + if (parser->token.type != ASE_STX_TOKEN_END && + parser->token.type != ASE_STX_TOKEN_PERIOD) { + if (__parse_message_continuation(parser, is_super) == -1) return -1; + } + return 0; +} + +static int __parse_assignment ( + ase_stx_parser_t* parser, const ase_char_t* target) +{ + /* + * ::= assignmentOperator + */ + + ase_word_t i; + ase_stx_t* stx = parser->stx; + + for (i = parser->argument_count; i < parser->temporary_count; i++) { + if (ase_strcmp (target, parser->temporaries[i]) == 0) { + if (__parse_expression(parser) == -1) return -1; + EMIT_STORE_TEMPORARY_LOCATION (parser, i); + return 0; + } + } + + if (ase_stx_get_instance_variable_index ( + stx, parser->method_class, target, &i) == 0) { + if (__parse_expression(parser) == -1) return -1; + EMIT_STORE_RECEIVER_VARIABLE (parser, i); + return 0; + } + + if (ase_stx_lookup_class_variable ( + stx, parser->method_class, target) != stx->nil) { + if (__parse_expression(parser) == -1) return -1; + + /* TODO */ + EMIT_CODE_TEST (parser, ASE_T("ASSIGN_CLASSVAR #"), target); + //EMIT_STORE_CLASS_VARIABLE (parser, target); + return 0; + } + + /* TODO: IMPLEMENT POOL DICTIONARIES */ + + /* TODO: IMPLEMENT GLOBLAS, but i don't like this idea */ + + parser->error_code = ASE_STX_PARSER_ERROR_UNDECLARED_NAME; + return -1; +} + +static int __parse_primary ( + ase_stx_parser_t* parser, const ase_char_t* ident, ase_bool_t* is_super) +{ + /* + * ::= + * identifier | | + * | ( '('')' ) + */ + + ase_stx_t* stx = parser->stx; + + if (ident == ASE_NULL) { + int pos; + ase_word_t literal; + + *is_super = ase_false; + + if (parser->token.type == ASE_STX_TOKEN_IDENT) { + if (__parse_primary_ident(parser, + parser->token.name.buffer, is_super) == -1) return -1; + GET_TOKEN (parser); + } + else if (parser->token.type == ASE_STX_TOKEN_CHARLIT) { + pos = __add_character_literal( + parser, parser->token.name.buffer[0]); + if (pos == -1) return -1; + EMIT_PUSH_LITERAL_CONSTANT (parser, pos); + GET_TOKEN (parser); + } + else if (parser->token.type == ASE_STX_TOKEN_STRLIT) { + pos = __add_string_literal (parser, + parser->token.name.buffer, parser->token.name.size); + if (pos == -1) return -1; + EMIT_PUSH_LITERAL_CONSTANT (parser, pos); + GET_TOKEN (parser); + } + else if (parser->token.type == ASE_STX_TOKEN_NUMLIT) { + /* TODO: other types of numbers, negative numbers, etc */ + ase_word_t tmp; + ASE_STRTOI (tmp, parser->token.name.buffer, ASE_NULL, 10); + literal = ASE_STX_TO_SMALLINT(tmp); + pos = __add_literal(parser, literal); + if (pos == -1) return -1; + EMIT_PUSH_LITERAL_CONSTANT (parser, pos); + GET_TOKEN (parser); + } + else if (parser->token.type == ASE_STX_TOKEN_SYMLIT) { + pos = __add_symbol_literal (parser, + parser->token.name.buffer, parser->token.name.size); + if (pos == -1) return -1; + EMIT_PUSH_LITERAL_CONSTANT (parser, pos); + GET_TOKEN (parser); + } + else if (parser->token.type == ASE_STX_TOKEN_LBRACKET) { + GET_TOKEN (parser); + if (__parse_block_constructor(parser) == -1) return -1; + } + else if (parser->token.type == ASE_STX_TOKEN_APAREN) { + /* TODO: array literal */ + } + else if (parser->token.type == ASE_STX_TOKEN_LPAREN) { + GET_TOKEN (parser); + if (__parse_expression(parser) == -1) return -1; + if (parser->token.type != ASE_STX_TOKEN_RPAREN) { + parser->error_code = ASE_STX_PARSER_ERROR_NO_RPAREN; + return -1; + } + GET_TOKEN (parser); + } + else { + parser->error_code = ASE_STX_PARSER_ERROR_PRIMARY; + return -1; + } + } + else { + /*if (__parse_primary_ident(parser, parser->token.name.buffer) == -1) return -1;*/ + if (__parse_primary_ident(parser, ident, is_super) == -1) return -1; + } + + return 0; +} + +static int __parse_primary_ident ( + ase_stx_parser_t* parser, const ase_char_t* ident, ase_bool_t* is_super) +{ + ase_word_t i; + ase_stx_t* stx = parser->stx; + + *is_super = ase_false; + + if (ase_strcmp(ident, ASE_T("self")) == 0) { + EMIT_CODE (parser, PUSH_RECEIVER); + return 0; + } + else if (ase_strcmp(ident, ASE_T("super")) == 0) { + *is_super = ase_true; + EMIT_CODE (parser, PUSH_RECEIVER); + return 0; + } + else if (ase_strcmp(ident, ASE_T("nil")) == 0) { + EMIT_CODE (parser, PUSH_NIL); + return 0; + } + else if (ase_strcmp(ident, ASE_T("true")) == 0) { + EMIT_CODE (parser, PUSH_TRUE); + return 0; + } + else if (ase_strcmp(ident, ASE_T("false")) == 0) { + EMIT_CODE (parser, PUSH_FALSE); + return 0; + } + + /* Refer to __parse_assignment for identifier lookup */ + + for (i = 0; i < parser->temporary_count; i++) { + if (ase_strcmp(ident, parser->temporaries[i]) == 0) { + EMIT_PUSH_TEMPORARY_LOCATION (parser, i); + return 0; + } + } + + if (ase_stx_get_instance_variable_index ( + stx, parser->method_class, ident, &i) == 0) { + EMIT_PUSH_RECEIVER_VARIABLE (parser, i); + return 0; + } + + /* TODO: what is the best way to look up a class variable? */ + /* 1. Use the class containing it and using its position */ + /* 2. Use a primitive method after pushing the name as a symbol */ + /* 3. Implement a vm instruction to do it */ +/* + if (ase_stx_lookup_class_variable ( + stx, parser->method_class, ident) != stx->nil) { + //EMIT_LOOKUP_CLASS_VARIABLE (parser, ident); + return 0; + } +*/ + + /* TODO: IMPLEMENT POOL DICTIONARIES */ + + /* TODO: IMPLEMENT GLOBLAS, but i don't like this idea */ + + parser->error_code = ASE_STX_PARSER_ERROR_UNDECLARED_NAME; + return -1; +} + +static int __parse_block_constructor (ase_stx_parser_t* parser) +{ + /* + * ::= '[' ']' + * ::= [* '|'] + * [] [] + * ::= ':' identifier + */ + + if (parser->token.type == ASE_STX_TOKEN_COLON) { + do { + GET_TOKEN (parser); + + if (parser->token.type != ASE_STX_TOKEN_IDENT) { + parser->error_code = ASE_STX_PARSER_ERROR_BLOCK_ARGUMENT_NAME; + return -1; + } + + /* TODO : store block arguments */ + GET_TOKEN (parser); + } while (parser->token.type == ASE_STX_TOKEN_COLON); + + if (!__is_vbar_token(&parser->token)) { + parser->error_code = ASE_STX_PARSER_ERROR_BLOCK_ARGUMENT_LIST; + return -1; + } + + GET_TOKEN (parser); + } + + /* TODO: create a block closure */ + if (__parse_temporaries(parser) == -1) return -1; + if (__parse_block_statements(parser) == -1) return -1; + + if (parser->token.type != ASE_STX_TOKEN_RBRACKET) { + parser->error_code = ASE_STX_PARSER_ERROR_BLOCK_NOT_CLOSED; + return -1; + } + + GET_TOKEN (parser); + + /* TODO: do special treatment for block closures */ + + return 0; +} + +static int __parse_message_continuation ( + ase_stx_parser_t* parser, ase_bool_t is_super) +{ + /* + * ::= + * (+ * [] ) | + * (+ [] ) | + * + * ::= (';' )* + */ + if (__parse_keyword_message(parser, is_super) == -1) return -1; + + while (parser->token.type == ASE_STX_TOKEN_SEMICOLON) { + EMIT_CODE_TEST (parser, ASE_T("DoSpecial(DUP_RECEIVER(CASCADE))"), ASE_T("")); + GET_TOKEN (parser); + + if (__parse_keyword_message(parser, ase_false) == -1) return -1; + EMIT_CODE_TEST (parser, ASE_T("DoSpecial(POP_TOP)"), ASE_T("")); + } + + return 0; +} + +static int __parse_keyword_message (ase_stx_parser_t* parser, ase_bool_t is_super) +{ + /* + * ::= (keyword )+ + * ::= * * + */ + + ase_stx_name_t name; + ase_word_t pos; + ase_bool_t is_super2; + int nargs = 0, n; + + if (__parse_binary_message (parser, is_super) == -1) return -1; + if (parser->token.type != ASE_STX_TOKEN_KEYWORD) return 0; + + if (ase_stx_name_open(&name, 0) == ASE_NULL) { + parser->error_code = ASE_STX_PARSER_ERROR_MEMORY; + return -1; + } + + do { + if (ase_stx_name_adds(&name, parser->token.name.buffer) == -1) { + parser->error_code = ASE_STX_PARSER_ERROR_MEMORY; + ase_stx_name_close (&name); + return -1; + } + + GET_TOKEN (parser); + if (__parse_primary(parser, ASE_NULL, &is_super2) == -1) { + ase_stx_name_close (&name); + return -1; + } + + if (__parse_binary_message(parser, is_super2) == -1) { + ase_stx_name_close (&name); + return -1; + } + + nargs++; + /* TODO: check if it has too many arguments.. */ + } while (parser->token.type == ASE_STX_TOKEN_KEYWORD); + + pos = __add_symbol_literal (parser, name.buffer, name.size); + if (pos == -1) { + ase_stx_name_close (&name); + return -1; + } + + n = (is_super)? + __emit_send_to_super(parser,nargs,pos): + __emit_send_to_self(parser,nargs,pos); + if (n == -1) { + ase_stx_name_close (&name); + return -1; + } + + ase_stx_name_close (&name); + return 0; +} + +static int __parse_binary_message (ase_stx_parser_t* parser, ase_bool_t is_super) +{ + /* + * ::= binarySelector + * ::= * + */ + ase_word_t pos; + ase_bool_t is_super2; + int n; + + if (__parse_unary_message (parser, is_super) == -1) return -1; + + while (parser->token.type == ASE_STX_TOKEN_BINARY) { + ase_char_t* op = ase_stx_token_yield (&parser->token, 0); + if (op == ASE_NULL) { + parser->error_code = ASE_STX_PARSER_ERROR_MEMORY; + return -1; + } + + GET_TOKEN (parser); + if (__parse_primary(parser, ASE_NULL, &is_super2) == -1) { + ase_free (op); + return -1; + } + + if (__parse_unary_message(parser, is_super2) == -1) { + ase_free (op); + return -1; + } + + pos = __add_symbol_literal (parser, op, ase_strlen(op)); + if (pos == -1) { + ase_free (op); + return -1; + } + + n = (is_super)? + __emit_send_to_super(parser,2,pos): + __emit_send_to_self(parser,2,pos); + if (n == -1) { + ase_free (op); + return -1; + } + + ase_free (op); + } + + return 0; +} + +static int __parse_unary_message (ase_stx_parser_t* parser, ase_bool_t is_super) +{ + /* ::= unarySelector */ + + ase_word_t pos; + int n; + + while (parser->token.type == ASE_STX_TOKEN_IDENT) { + pos = __add_symbol_literal (parser, + parser->token.name.buffer, parser->token.name.size); + if (pos == -1) return -1; + + n = (is_super)? + __emit_send_to_super(parser,0,pos): + __emit_send_to_self(parser,0,pos); + if (n == -1) return -1; + + GET_TOKEN (parser); + } + + return 0; +} + +static int __get_token (ase_stx_parser_t* parser) +{ + ase_cint_t c; + + do { + if (__skip_spaces(parser) == -1) return -1; + if (parser->curc == ASE_T('"')) { + GET_CHAR (parser); + if (__skip_comment(parser) == -1) return -1; + } + else break; + } while (1); + + c = parser->curc; + ase_stx_token_clear (&parser->token); + + if (c == ASE_T_EOF) { + parser->token.type = ASE_STX_TOKEN_END; + } + else if (ase_isalpha(c)) { + if (__get_ident(parser) == -1) return -1; + } + else if (ase_isdigit(c)) { + if (__get_numlit(parser, ase_false) == -1) return -1; + } + else if (c == ASE_T('$')) { + GET_CHAR (parser); + if (__get_charlit(parser) == -1) return -1; + } + else if (c == ASE_T('\'')) { + GET_CHAR (parser); + if (__get_strlit(parser) == -1) return -1; + } + else if (c == ASE_T(':')) { + parser->token.type = ASE_STX_TOKEN_COLON; + ADD_TOKEN_CHAR(parser, c); + GET_CHAR (parser); + + c = parser->curc; + if (c == ASE_T('=')) { + parser->token.type = ASE_STX_TOKEN_ASSIGN; + ADD_TOKEN_CHAR(parser, c); + GET_CHAR (parser); + } + } + else if (c == ASE_T('^')) { + parser->token.type = ASE_STX_TOKEN_RETURN; + ADD_TOKEN_CHAR(parser, c); + GET_CHAR (parser); + } + else if (c == ASE_T('[')) { + parser->token.type = ASE_STX_TOKEN_LBRACKET; + ADD_TOKEN_CHAR(parser, c); + GET_CHAR (parser); + } + else if (c == ASE_T(']')) { + parser->token.type = ASE_STX_TOKEN_RBRACKET; + ADD_TOKEN_CHAR(parser, c); + GET_CHAR (parser); + } + else if (c == ASE_T('(')) { + parser->token.type = ASE_STX_TOKEN_LPAREN; + ADD_TOKEN_CHAR(parser, c); + GET_CHAR (parser); + } + else if (c == ASE_T(')')) { + parser->token.type = ASE_STX_TOKEN_RPAREN; + ADD_TOKEN_CHAR(parser, c); + GET_CHAR (parser); + } + else if (c == ASE_T('#')) { + /*ADD_TOKEN_CHAR(parser, c);*/ + GET_CHAR (parser); + + c = parser->curc; + if (c == ASE_T_EOF) { + parser->error_code = ASE_STX_PARSER_ERROR_LITERAL; + return -1; + } + else if (c == ASE_T('(')) { + ADD_TOKEN_CHAR(parser, c); + parser->token.type = ASE_STX_TOKEN_APAREN; + GET_CHAR (parser); + } + else if (c == ASE_T('\'')) { + GET_CHAR (parser); + if (__get_strlit(parser) == -1) return -1; + parser->token.type = ASE_STX_TOKEN_SYMLIT; + } + else if (!__is_closing_char(c) && !ase_isspace(c)) { + do { + ADD_TOKEN_CHAR(parser, c); + GET_CHAR (parser); + c = parser->curc; + } while (!__is_closing_char(c) && !ase_isspace(c)); + + parser->token.type = ASE_STX_TOKEN_SYMLIT; + } + else { + parser->error_code = ASE_STX_PARSER_ERROR_LITERAL; + return -1; + } + } + else if (c == ASE_T('.')) { + parser->token.type = ASE_STX_TOKEN_PERIOD; + ADD_TOKEN_CHAR(parser, c); + GET_CHAR (parser); + } + else if (c == ASE_T(';')) { + parser->token.type = ASE_STX_TOKEN_SEMICOLON; + ADD_TOKEN_CHAR(parser, c); + GET_CHAR (parser); + } + else if (__is_binary_char(c)) { + if (__get_binary(parser) == -1) return -1; + } + else { + parser->error_code = ASE_STX_PARSER_ERROR_CHAR; + return -1; + } + +//ase_printf (ASE_T("TOKEN: %s\n"), parser->token.name.buffer); + return 0; +} + +static int __get_ident (ase_stx_parser_t* parser) +{ + /* + * identifier ::= letter (letter | digit)* + * keyword ::= identifier ':' + */ + + ase_cint_t c = parser->curc; + parser->token.type = ASE_STX_TOKEN_IDENT; + + do { + ADD_TOKEN_CHAR(parser, c); + GET_CHAR (parser); + c = parser->curc; + } while (ase_isalnum(c)); + + if (c == ASE_T(':')) { + ADD_TOKEN_CHAR (parser, c); + parser->token.type = ASE_STX_TOKEN_KEYWORD; + GET_CHAR (parser); + } + + return 0; +} + +static int __get_numlit (ase_stx_parser_t* parser, ase_bool_t negated) +{ + /* + * ::= ['-'] + * ::= integer | float | scaledDecimal + * integer ::= decimalInteger | radixInteger + * decimalInteger ::= digits + * digits ::= digit+ + * radixInteger ::= radixSpecifier 'r' radixDigits + * radixSpecifier := digits + * radixDigits ::= (digit | uppercaseAlphabetic)+ + * float ::= mantissa [exponentLetter exponent] + * mantissa ::= digits'.' digits + * exponent ::= ['-']decimalInteger + * exponentLetter ::= 'e' | 'd' | 'q' + * scaledDecimal ::= scaledMantissa 's' [fractionalDigits] + * scaledMantissa ::= decimalInteger | mantissa + * fractionalDigits ::= decimalInteger + */ + + ase_cint_t c = parser->curc; + parser->token.type = ASE_STX_TOKEN_NUMLIT; + + do { + ADD_TOKEN_CHAR(parser, c); + GET_CHAR (parser); + c = parser->curc; + } while (ase_isalnum(c)); + + /* TODO; more */ + return 0; +} + +static int __get_charlit (ase_stx_parser_t* parser) +{ + /* + * character_literal ::= '$' character + * character ::= "Any character in the implementation-defined character set" + */ + + ase_cint_t c = parser->curc; /* even a new-line or white space would be taken */ + if (c == ASE_T_EOF) { + parser->error_code = ASE_STX_PARSER_ERROR_CHARLIT; + return -1; + } + + parser->token.type = ASE_STX_TOKEN_CHARLIT; + ADD_TOKEN_CHAR(parser, c); + GET_CHAR (parser); + return 0; +} + +static int __get_strlit (ase_stx_parser_t* parser) +{ + /* + * string_literal ::= stringDelimiter stringBody stringDelimiter + * stringBody ::= (nonStringDelimiter | (stringDelimiter stringDelimiter)*) + * stringDelimiter ::= ''' "a single quote" + */ + + /* TODO: C-like string */ + + ase_cint_t c = parser->curc; + parser->token.type = ASE_STX_TOKEN_STRLIT; + + do { + do { + ADD_TOKEN_CHAR (parser, c); + GET_CHAR (parser); + c = parser->curc; + + if (c == ASE_T_EOF) { + parser->error_code = ASE_STX_PARSER_ERROR_STRLIT; + return -1; + } + } while (c != ASE_T('\'')); + + GET_CHAR (parser); + c = parser->curc; + } while (c == ASE_T('\'')); + + return 0; +} + +static int __get_binary (ase_stx_parser_t* parser) +{ + /* + * binarySelector ::= binaryCharacter+ + */ + + ase_cint_t c = parser->curc; + ADD_TOKEN_CHAR (parser, c); + + if (c == ASE_T('-')) { + GET_CHAR (parser); + c = parser->curc; + if (ase_isdigit(c)) return __get_numlit(parser,ase_true); + } + else { + GET_CHAR (parser); + c = parser->curc; + } + + /* up to 2 characters only */ + if (__is_binary_char(c)) { + ADD_TOKEN_CHAR (parser, c); + GET_CHAR (parser); + c = parser->curc; + } + + /* or up to any occurrences */ + /* + while (__is_binary_char(c)) { + ADD_TOKEN_CHAR (parser, c); + GET_CHAR (parser); + c = parser->curc; + } + */ + + parser->token.type = ASE_STX_TOKEN_BINARY; + return 0; +} + +static int __skip_spaces (ase_stx_parser_t* parser) +{ + while (ase_isspace(parser->curc)) GET_CHAR (parser); + return 0; +} + +static int __skip_comment (ase_stx_parser_t* parser) +{ + while (parser->curc != ASE_T('"')) GET_CHAR (parser); + GET_CHAR (parser); + return 0; +} + +static int __get_char (ase_stx_parser_t* parser) +{ + ase_cint_t c; + + if (parser->ungotc_count > 0) { + parser->curc = parser->ungotc[parser->ungotc_count--]; + } + else { + if (parser->input_func ( + ASE_STX_PARSER_INPUT_CONSUME, + parser->input_owner, (void*)&c) == -1) { + parser->error_code = ASE_STX_PARSER_ERROR_INPUT; + return -1; + } + parser->curc = c; + } + return 0; +} + +static int __unget_char (ase_stx_parser_t* parser, ase_cint_t c) +{ + if (parser->ungotc_count >= ase_countof(parser->ungotc)) return -1; + parser->ungotc[parser->ungotc_count++] = c; + return 0; +} + +static int __open_input (ase_stx_parser_t* parser, void* input) +{ + if (parser->input_func( + ASE_STX_PARSER_INPUT_OPEN, + (void*)&parser->input_owner, input) == -1) { + parser->error_code = ASE_STX_PARSER_ERROR_INPUT; + return -1; + } + + parser->error_code = ASE_STX_PARSER_ERROR_NONE; + parser->curc = ASE_T_EOF; + parser->ungotc_count = 0; + return 0; +} + +static int __close_input (ase_stx_parser_t* parser) +{ + if (parser->input_func( + ASE_STX_PARSER_INPUT_CLOSE, + parser->input_owner, ASE_NULL) == -1) { + parser->error_code = ASE_STX_PARSER_ERROR_INPUT; + return -1; + } + + return 0; +} + diff --git a/ase/stx/parser.h b/ase/stx/parser.h new file mode 100644 index 00000000..a616587d --- /dev/null +++ b/ase/stx/parser.h @@ -0,0 +1,107 @@ +/* + * $Id: parser.h,v 1.3 2007/04/30 08:32:41 bacon Exp $ + */ + +#ifndef _ASE_STX_PARSER_H_ +#define _ASE_STX_PARSER_H_ + +#include +#include +#include +#include + +enum +{ + ASE_STX_PARSER_ERROR_NONE, + + /* system errors */ + ASE_STX_PARSER_ERROR_INPUT_FUNC, + ASE_STX_PARSER_ERROR_INPUT, + ASE_STX_PARSER_ERROR_MEMORY, + + /* lexical errors */ + ASE_STX_PARSER_ERROR_CHAR, + ASE_STX_PARSER_ERROR_CHARLIT, + ASE_STX_PARSER_ERROR_STRLIT, + ASE_STX_PARSER_ERROR_LITERAL, + + /* syntatic error */ + ASE_STX_PARSER_ERROR_MESSAGE_SELECTOR, + ASE_STX_PARSER_ERROR_ARGUMENT_NAME, + ASE_STX_PARSER_ERROR_TOO_MANY_ARGUMENTS, + + ASE_STX_PARSER_ERROR_PRIMITIVE_KEYWORD, + ASE_STX_PARSER_ERROR_PRIMITIVE_NUMBER, + ASE_STX_PARSER_ERROR_PRIMITIVE_NUMBER_RANGE, + ASE_STX_PARSER_ERROR_PRIMITIVE_NOT_CLOSED, + + ASE_STX_PARSER_ERROR_TEMPORARIES_NOT_CLOSED, + ASE_STX_PARSER_ERROR_TOO_MANY_TEMPORARIES, + ASE_STX_PARSER_ERROR_PSEUDO_VARIABLE, + ASE_STX_PARSER_ERROR_PRIMARY, + + ASE_STX_PARSER_ERROR_NO_PERIOD, + ASE_STX_PARSER_ERROR_NO_RPAREN, + ASE_STX_PARSER_ERROR_BLOCK_ARGUMENT_NAME, + ASE_STX_PARSER_ERROR_BLOCK_ARGUMENT_LIST, + ASE_STX_PARSER_ERROR_BLOCK_NOT_CLOSED, + + ASE_STX_PARSER_ERROR_UNDECLARED_NAME, + ASE_STX_PARSER_ERROR_TOO_MANY_LITERALS +}; + +enum +{ + /* input_func cmd */ + ASE_STX_PARSER_INPUT_OPEN, + ASE_STX_PARSER_INPUT_CLOSE, + ASE_STX_PARSER_INPUT_CONSUME, + ASE_STX_PARSER_INPUT_REWIND +}; + +typedef struct ase_stx_parser_t ase_stx_parser_t; + +struct ase_stx_parser_t +{ + ase_stx_t* stx; + int error_code; + + ase_word_t method_class; + ase_stx_name_t method_name; + + ase_char_t* temporaries[256]; /* TODO: different size? or dynamic? */ + ase_word_t argument_count; + ase_word_t temporary_count; + + ase_word_t literals[256]; /* TODO: make it a dynamic array */ + ase_word_t literal_count; + + ase_arr_t bytecode; + + ase_stx_token_t token; + ase_cint_t curc; + ase_cint_t ungotc[5]; + ase_size_t ungotc_count; + + void* input_owner; + int (*input_func) (int cmd, void* owner, void* arg); + + ase_bool_t __dynamic; +}; + +#ifdef __cplusplus +extern "C" { +#endif + +ase_stx_parser_t* ase_stx_parser_open (ase_stx_parser_t* parser, ase_stx_t* stx); +void ase_stx_parser_close (ase_stx_parser_t* parser); + +const ase_char_t* ase_stx_parser_error_string (ase_stx_parser_t* parser); +int ase_stx_parser_parse_method ( + ase_stx_parser_t* parser, ase_word_t method_class, void* input); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ase/stx/stx.bnf b/ase/stx/stx.bnf new file mode 100644 index 00000000..81112540 --- /dev/null +++ b/ase/stx/stx.bnf @@ -0,0 +1,196 @@ +~~~ method grammar ~~~ + + ::= + + [ ] + [] + + ::= | + | + + + ::= unarySelector + + ::= binarySelector + + ::= (keyword )+ + + ::= '|' '|' + + ::= identifier* + + ::= '[' ']' + + ::= [* '|'] + [] [] + + ::= ':' identifier + + ::= + ( ['.'] ) | + ( ['.' []]) + + ::= returnOperator + + ::= + | + + + ::= assignmentOperator + + ::= + [ ] + + := identifier + + ::= + identifier | + | + | + ( '(' ')' ) + + + ::= + (+ * [] ) | + (+ [] ) | + + + ::= unarySelector + + ::= binarySelector + + ::= * + + ::= (keyword )+ + + ::= * * + + ::= (';' )* + + ::= + | + | + | + | + | + + + ::= ['-'] + + ::= integer | float | scaledDecimal + + ::= quotedCharacter + + ::= quotedString + + ::= hashedString + + ::= quotedSelector + + ::= '#(' * ')' + + ::= | identifier + +reserved identifiers -> nil true false self super + + +~~~ lexical grammar ~~~ + +character ::= + "Any character in the implementation-defined character set" + +whitespace ::= + "Any non-printing character interpreted as white space + including spaces, tabs, and line breaks" + +digit ::= + '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' + +uppercaseAlphabetic ::= + 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | + 'J' | 'K' | 'L' | 'M' | 'N' | 'O' | 'P' | 'Q' | 'R' | + 'S' | 'T' | 'U' | 'V' | 'W' | 'X' | 'Y' | 'Z' + +lowercaseAlphabetic ::= + 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | + 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | + 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z' + +nonCaseLetter ::= '_' + +letter ::= + uppercaseAlphabetic | + lowercaseAlphabetic | + nonCaseLetter | + "implementation defined letters" + +commentDelimiter ::= '"' + +nonCommentDelimiter::= +"any character that is not a commentDelimiter " + + comment := + commentDelimiter nonCommentDelimiter * commentDelimiter + +identifier ::= letter (letter | digit)* + +keyword ::= identifier ':' + +binaryCharacter ::= + '!' | '%' | '&' | '*' | '+' | ',' | + '/' | '<' | '=' | '>' | '?' | '@' | + '\' | '~' | '|' | '-' + +binarySelector ::= binaryCharacter+ + +returnOperator ::= '^' + +assignmentOperator ::= ':=' + + +integer ::= decimalInteger | radixInteger + +decimalInteger ::= digits + +digits ::= digit+ + +radixInteger ::= radixSpecifier 'r' radixDigits + +radixSpecifier := digits + +radixDigits ::= (digit | uppercaseAlphabetic)+ + + +float ::= mantissa [exponentLetter exponent] + +mantissa ::= digits'.' digits + +exponent ::= ['-']decimalInteger + +exponentLetter ::= 'e' | 'd' | 'q' + +scaledDecimal ::= scaledMantissa 's' [fractionalDigits] + +scaledMantissa ::= decimalInteger | mantissa + +fractionalDigits ::= decimalInteger + +quotedCharacter ::= '$' character + +quotedString ::= stringDelimiter stringBody stringDelimiter + +stringBody ::= (nonStringDelimiter | (stringDelimiter stringDelimiter)*) + +stringDelimiter ::= ''' "a single quote" + +nonStringDelimiter ::= "any character except stringDelimiter" + +hashedString ::= '#' quotedString + +quotedSelector ::= '#' (unarySelector | binarySelector | keywordSelector) + +keywordSelector ::= keyword+ + +separator ::= (whitespace | comment)* + + diff --git a/ase/stx/stx.c b/ase/stx/stx.c new file mode 100644 index 00000000..d6c6a9b8 --- /dev/null +++ b/ase/stx/stx.c @@ -0,0 +1,70 @@ +/* + * $Id: stx.c,v 1.3 2007/04/30 08:32:41 bacon Exp $ + */ + +#include +#include +#include + +ase_stx_t* ase_stx_open (ase_stx_t* stx, ase_word_t capacity) +{ + ase_word_t i; + + if (stx == ASE_NULL) { + stx = (ase_stx_t*)ase_malloc (ase_sizeof(stx)); + if (stx == ASE_NULL) return ASE_NULL; + stx->__dynamic = ase_true; + } + else stx->__dynamic = ase_false; + + if (ase_stx_memory_open (&stx->memory, capacity) == ASE_NULL) { + if (stx->__dynamic) ase_free (stx); + return ASE_NULL; + } + + stx->symtab.size = 0; + stx->symtab.capacity = 128; /* TODO: symbol table size */ + stx->symtab.datum = (ase_word_t*)ase_malloc ( + ase_sizeof(ase_word_t) * stx->symtab.capacity); + if (stx->symtab.datum == ASE_NULL) { + ase_stx_memory_close (&stx->memory); + if (stx->__dynamic) ase_free (stx); + return ASE_NULL; + } + + stx->nil = ASE_STX_NIL; + stx->true = ASE_STX_TRUE; + stx->false = ASE_STX_FALSE; + + stx->smalltalk = ASE_STX_NIL; + + stx->class_symbol = ASE_STX_NIL; + stx->class_metaclass = ASE_STX_NIL; + stx->class_association = ASE_STX_NIL; + + stx->class_object = ASE_STX_NIL; + stx->class_class = ASE_STX_NIL; + stx->class_array = ASE_STX_NIL; + stx->class_bytearray = ASE_STX_NIL; + stx->class_string = ASE_STX_NIL; + stx->class_character = ASE_STX_NIL; + stx->class_context = ASE_STX_NIL; + stx->class_system_dictionary = ASE_STX_NIL; + stx->class_method = ASE_STX_NIL; + stx->class_smallinteger = ASE_STX_NIL; + + for (i = 0; i < stx->symtab.capacity; i++) { + stx->symtab.datum[i] = stx->nil; + } + + stx->__wantabort = ase_false; + return stx; +} + +void ase_stx_close (ase_stx_t* stx) +{ + ase_free (stx->symtab.datum); + ase_stx_memory_close (&stx->memory); + if (stx->__dynamic) ase_free (stx); +} + diff --git a/ase/stx/stx.h b/ase/stx/stx.h new file mode 100644 index 00000000..1c32db83 --- /dev/null +++ b/ase/stx/stx.h @@ -0,0 +1,163 @@ +/* + * $Id: stx.h,v 1.3 2007/04/30 08:32:41 bacon Exp $ + */ + +#ifndef _ASE_STX_STX_H_ +#define _ASE_STX_STX_H_ + +#include +#include + +typedef struct ase_stx_objhdr_t ase_stx_objhdr_t; +typedef struct ase_stx_object_t ase_stx_object_t; +typedef struct ase_stx_word_object_t ase_stx_word_object_t; +typedef struct ase_stx_byte_object_t ase_stx_byte_object_t; +typedef struct ase_stx_char_object_t ase_stx_char_object_t; +typedef struct ase_stx_memory_t ase_stx_memory_t; +typedef struct ase_stx_symtab_t ase_stx_symtab_t; +typedef struct ase_stx_t ase_stx_t; + +/* common object structure */ +struct ase_stx_objhdr_t +{ + /* access - type: 2; size: rest; + * type - word indexed: 00 byte indexed: 01 char indexed: 10 + */ + ase_word_t access; + ase_word_t class; +}; + +struct ase_stx_object_t +{ + ase_stx_objhdr_t header; +}; + +struct ase_stx_word_object_t +{ + ase_stx_objhdr_t header; + ase_word_t data[1]; +}; + +struct ase_stx_byte_object_t +{ + ase_stx_objhdr_t header; + ase_byte_t data[1]; +}; + +struct ase_stx_char_object_t +{ + ase_stx_objhdr_t header; + ase_char_t data[1]; +}; + + +struct ase_stx_memory_t +{ + ase_word_t capacity; + ase_stx_object_t** slots; + ase_stx_object_t** free; + ase_bool_t __dynamic; +}; + +struct ase_stx_symtab_t +{ + ase_word_t* datum; + ase_word_t size; + ase_word_t capacity; +}; + +struct ase_stx_t +{ + ase_stx_memory_t memory; + ase_stx_symtab_t symtab; + + ase_word_t nil; + ase_word_t true; + ase_word_t false; + + ase_word_t smalltalk; + + ase_word_t class_symbol; + ase_word_t class_metaclass; + ase_word_t class_association; + + ase_word_t class_object; + ase_word_t class_class; + ase_word_t class_array; + ase_word_t class_bytearray; + ase_word_t class_string; + ase_word_t class_character; + ase_word_t class_context; + ase_word_t class_system_dictionary; + ase_word_t class_method; + ase_word_t class_smallinteger; + + ase_bool_t __dynamic; + ase_bool_t __wantabort; /* TODO: make it a function pointer */ +}; + +#define ASE_STX_IS_SMALLINT(x) (((x) & 0x01) == 0x01) +#define ASE_STX_TO_SMALLINT(x) (((x) << 1) | 0x01) +#define ASE_STX_FROM_SMALLINT(x) ((x) >> 1) + +#define ASE_STX_IS_OINDEX(x) (((x) & 0x01) == 0x00) +#define ASE_STX_TO_OINDEX(x) (((x) << 1) | 0x00) +#define ASE_STX_FROM_OINDEX(x) ((x) >> 1) + +#define ASE_STX_NIL ASE_STX_TO_OINDEX(0) +#define ASE_STX_TRUE ASE_STX_TO_OINDEX(1) +#define ASE_STX_FALSE ASE_STX_TO_OINDEX(2) + +#define ASE_STX_OBJECT(stx,idx) (((stx)->memory).slots[ASE_STX_FROM_OINDEX(idx)]) +#define ASE_STX_CLASS(stx,idx) (ASE_STX_OBJECT(stx,(idx))->header.class) +#define ASE_STX_ACCESS(stx,idx) (ASE_STX_OBJECT(stx,(idx))->header.access) +#define ASE_STX_DATA(stx,idx) ((void*)(ASE_STX_OBJECT(stx,idx) + 1)) + +#define ASE_STX_TYPE(stx,idx) (ASE_STX_ACCESS(stx,idx) & 0x03) +#define ASE_STX_SIZE(stx,idx) (ASE_STX_ACCESS(stx,idx) >> 0x02) + +#define ASE_STX_WORD_INDEXED (0x00) +#define ASE_STX_BYTE_INDEXED (0x01) +#define ASE_STX_CHAR_INDEXED (0x02) + +#define ASE_STX_IS_WORD_OBJECT(stx,idx) \ + (ASE_STX_TYPE(stx,idx) == ASE_STX_WORD_INDEXED) +#define ASE_STX_IS_BYTE_OBJECT(stx,idx) \ + (ASE_STX_TYPE(stx,idx) == ASE_STX_BYTE_INDEXED) +#define ASE_STX_IS_CHAR_OBJECT(stx,idx) \ + (ASE_STX_TYPE(stx,idx) == ASE_STX_CHAR_INDEXED) + +#define ASE_STX_WORD_OBJECT(stx,idx) \ + ((ase_stx_word_object_t*)ASE_STX_OBJECT(stx,idx)) +#define ASE_STX_BYTE_OBJECT(stx,idx) \ + ((ase_stx_byte_object_t*)ASE_STX_OBJECT(stx,idx)) +#define ASE_STX_CHAR_OBJECT(stx,idx) \ + ((ase_stx_char_object_t*)ASE_STX_OBJECT(stx,idx)) + +/* +#define ASE_STX_WORD_AT(stx,idx,n) \ + (((ase_word_t*)(ASE_STX_OBJECT(stx,idx) + 1))[n]) +#define ASE_STX_BYTE_AT(stx,idx,n) \ + (((ase_byte_t*)(ASE_STX_OBJECT(stx,idx) + 1))[n]) +#define ASE_STX_CHAR_AT(stx,idx,n) \ + (((ase_char_t*)(ASE_STX_OBJECT(stx,idx) + 1))[n]) +*/ +#define ASE_STX_WORD_AT(stx,idx,n) \ + (ASE_STX_WORD_OBJECT(stx,idx)->data[n]) +#define ASE_STX_BYTE_AT(stx,idx,n) \ + (ASE_STX_BYTE_OBJECT(stx,idx)->data[n]) +#define ASE_STX_CHAR_AT(stx,idx,n) \ + (ASE_STX_CHAR_OBJECT(stx,idx)->data[n]) + +#ifdef __cplusplus +extern "C" { +#endif + +ase_stx_t* ase_stx_open (ase_stx_t* stx, ase_word_t capacity); +void ase_stx_close (ase_stx_t* stx); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ase/stx/stx.txt b/ase/stx/stx.txt new file mode 100644 index 00000000..c6e373cd --- /dev/null +++ b/ase/stx/stx.txt @@ -0,0 +1,90 @@ +stx(1) xpkit + +NAME + stx - xpkit embeddable smalltalk system + +SYNOPSIS + stx [-f imageFile] MainClass + +DESCRIPTION + The virtual machine executes "MainClass main" on start-up. + + +method 1. +push lookup_class(#MainClass) -> receiver. +send a unary(no argument) message with the selector #main. +return the returned value from main and exits. + +method 2. - take a command parameter +push lookup_class(#MainClass) -> receiver. +push argc as an argument. +push argv as an argument. +send a double-argument message the the selector #main:withArgv:. +return the returned value from #main:withArgv and exits. + + +AUTHOR(S) + Chung, Hyung-Hwan (bacon@piowave.com) is the sole designer and implementer of stx. + +BUG REPORTS + Report bugs to bacon@piowave.com if you find any bugs. but make sure that it is really a bug before you report it. + +COPYRIGHT + Copyright(c) 2005 bacon@piowave.com + +SEE ALSO + xpkit(7) + + +-- stack bytecodes -- +0 0000 XXXX push_receiver_variable +1 0001 XXXX push_temporary_location +2 0010 XXXX push_literal_constant +3 0011 XXXX push_literal_variable +4 0100 XXXX store_receiver_variable +5 0101 XXXX store_temporary_location +6 0110 0000 XXXXXXXX push_receiver_variable_extended + 0110 0001 XXXXXXXX push_temporary_location_extended + 0110 0010 XXXXXXXX push_literal_constant_extended + 0110 0011 XXXXXXXX push_literal_variable_extended + 0110 0100 XXXXXXXX store_receiver_variable_extended + 0110 0101 XXXXXXXX store_temporary_location_extended + 0110 0110 unused + 0110 0111 unused + 0110 1000 pop_stack_top + 0110 1001 duplicate_stack_top + 0110 1010 push_active_context + 0110 1011 unused + 0110 1100 unused + 0110 1101 unused + 0110 1110 unused + 0110 1111 unused + +-- send bytecodes -- +7 0111 0000 JJJKKKKK send_to_self + 0111 0001 JJJKKKKK send_to_super + 0111 0010 JJJJJJJJ KKKKKKKK send_to_self_extended + 0111 0011 JJJJJJJJ KKKKKKKK send_to_super_extended + + 0111 0100 XXXXXXXX + 0111 0101 XXXXXXXX + 0111 0110 XXXXXXXX + 0111 0111 XXXXXXXX + +-- return bytecodes -- + 0111 1000 return receiver + 0111 1001 return_true + 0111 1010 return_false + 0111 1011 return_nil + + 0111 1100 return_from_message + 0111 1101 return_from_block + 0111 1110 + 0111 1111 + +-- jump bytecodes -- +8 1000 0XXX jump_forward + 1000 1XXX XXXXXXXX jump_forward + +-- primitive -- +F 1111 XXXX XXXXXXXX do_primitive diff --git a/ase/stx/symbol.c b/ase/stx/symbol.c new file mode 100644 index 00000000..ac3ccdec --- /dev/null +++ b/ase/stx/symbol.c @@ -0,0 +1,102 @@ +/* + * $Id: symbol.c,v 1.3 2007/04/30 08:32:41 bacon Exp $ + */ + +#include +#include +#include + +static void __grow_symtab (ase_stx_t* stx) +{ + ase_word_t capa, ncapa, i, j; + ase_word_t* nspace; + + capa = stx->symtab.capacity; + ncapa = capa << 1; + + nspace = (ase_word_t*)ase_malloc(ase_sizeof(ase_word_t) * ncapa); + if (nspace == ASE_NULL) + { + /* TODO: handle memory error */ + } + + for (i = 0; i < capa; i++) + { + ase_word_t x = stx->symtab.datum[i]; + if (x == stx->nil) continue; + + j = ase_stx_strxhash ( + ASE_STX_DATA(stx,x), ASE_STX_SIZE(stx,x)) % ncapa; + + while (1) + { + if (nspace[j] == stx->nil) + { + nspace[j] = x; + break; + } + j = (j % ncapa) + 1; + } + } + + stx->symtab.capacity = ncapa; + ase_free (stx->symtab.datum); + stx->symtab.datum = nspace; +} + +ase_word_t ase_stx_new_symbol (ase_stx_t* stx, const ase_char_t* name) +{ + return ase_stx_new_symbolx (stx, name, ase_strlen(name)); +} + +ase_word_t ase_stx_new_symbolx ( + ase_stx_t* stx, const ase_char_t* name, ase_word_t len) +{ + ase_word_t capa, hash, index, size, x; + + capa = stx->symtab.capacity; + size = stx->symtab.size; + + if (capa <= size + 1) + { + __grow_symtab (stx); + capa = stx->symtab.capacity; + } + + hash = ase_stx_strxhash(name,len); + index = hash % stx->symtab.capacity; + + while (1) + { + x = stx->symtab.datum[index]; + if (x == stx->nil) + { + /* insert a new item into an empty slot */ + x = ase_stx_alloc_char_objectx (stx, name, len); + ASE_STX_CLASS(stx,x) = stx->class_symbol; + stx->symtab.datum[index] = x; + stx->symtab.size++; + break; + } + + if (ase_strxncmp(name, len, + ASE_STX_DATA(stx,x), ASE_STX_SIZE(stx,x)) == 0) break; + + index = (index % stx->symtab.capacity) + 1; + } + + return x; +} + +void ase_stx_traverse_symbol_table ( + ase_stx_t* stx, void (*func) (ase_stx_t*,ase_word_t,void*), void* data) +{ + ase_word_t index, x; + + for (index = 0; index < stx->symtab.capacity; index++) + { + x = stx->symtab.datum[index]; + if (x != stx->nil) func (stx, x, data); + } +} + diff --git a/ase/stx/symbol.h b/ase/stx/symbol.h new file mode 100644 index 00000000..385c9774 --- /dev/null +++ b/ase/stx/symbol.h @@ -0,0 +1,40 @@ +/* + * $Id: symbol.h,v 1.3 2007/04/30 08:32:41 bacon Exp $ + */ + +#ifndef _ASE_STX_SYMBOL_H_ +#define _ASE_STX_SYMBOL_H_ + +#include + +#define ASE_STX_SYMLINK_SIZE 2 +#define ASE_STX_SYMLINK_LINK 0 +#define ASE_STX_SYMLINK_SYMBOL 1 + +struct ase_stx_symlink_t +{ + ase_stx_objhdr_t header; + ase_word_t link; + ase_word_t symbol; +}; + +typedef struct ase_stx_symlink_t ase_stx_symlink_t; + +#ifdef __cplusplus +extern "C" { +#endif + +ase_word_t ase_stx_new_symbol_link (ase_stx_t* stx, ase_word_t sym); + +ase_word_t ase_stx_new_symbol ( + ase_stx_t* stx, const ase_char_t* name); +ase_word_t ase_stx_new_symbolx ( + ase_stx_t* stx, const ase_char_t* name, ase_word_t len); +void ase_stx_traverse_symbol_table ( + ase_stx_t* stx, void (*func) (ase_stx_t*,ase_word_t,void*), void* data); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ase/stx/token.c b/ase/stx/token.c new file mode 100644 index 00000000..8d4a6621 --- /dev/null +++ b/ase/stx/token.c @@ -0,0 +1,77 @@ +/* + * $Id: token.c,v 1.3 2007/04/30 08:32:41 bacon Exp $ + */ + +#include +#include + +ase_stx_token_t* ase_stx_token_open ( + ase_stx_token_t* token, ase_word_t capacity) +{ + if (token == ASE_NULL) { + token = (ase_stx_token_t*) + ase_malloc (ase_sizeof(ase_stx_token_t)); + if (token == ASE_NULL) return ASE_NULL; + token->__dynamic = ase_true; + } + else token->__dynamic = ase_false; + + if (ase_stx_name_open(&token->name, capacity) == ASE_NULL) { + if (token->__dynamic) ase_free (token); + return ASE_NULL; + } + + /* + token->ivalue = 0; + token->fvalue = .0; + */ + token->type = ASE_STX_TOKEN_END; + return token; +} + +void ase_stx_token_close (ase_stx_token_t* token) +{ + ase_stx_name_close (&token->name); + if (token->__dynamic) ase_free (token); +} + +int ase_stx_token_addc (ase_stx_token_t* token, ase_cint_t c) +{ + return ase_stx_name_addc (&token->name, c); +} + +int ase_stx_token_adds (ase_stx_token_t* token, const ase_char_t* s) +{ + return ase_stx_name_adds (&token->name, s); +} + +void ase_stx_token_clear (ase_stx_token_t* token) +{ + /* + token->ivalue = 0; + token->fvalue = .0; + */ + + token->type = ASE_STX_TOKEN_END; + ase_stx_name_clear (&token->name); +} + +ase_char_t* ase_stx_token_yield (ase_stx_token_t* token, ase_word_t capacity) +{ + ase_char_t* p; + + p = ase_stx_name_yield (&token->name, capacity); + if (p == ASE_NULL) return ASE_NULL; + + /* + token->ivalue = 0; + token->fvalue = .0; + */ + token->type = ASE_STX_TOKEN_END; + return p; +} + +int ase_stx_token_compare_name (ase_stx_token_t* token, const ase_char_t* str) +{ + return ase_stx_name_compare (&token->name, str); +} diff --git a/ase/stx/token.h b/ase/stx/token.h new file mode 100644 index 00000000..f5028d87 --- /dev/null +++ b/ase/stx/token.h @@ -0,0 +1,66 @@ +/* + * $Id: token.h,v 1.3 2007/04/30 08:32:41 bacon Exp $ + */ + +#ifndef _ASE_STX_TOKEN_H_ +#define _ASE_STX_TOKEN_H_ + +#include +#include + +enum +{ + ASE_STX_TOKEN_END, + ASE_STX_TOKEN_CHARLIT, + ASE_STX_TOKEN_STRLIT, + ASE_STX_TOKEN_SYMLIT, + ASE_STX_TOKEN_NUMLIT, + ASE_STX_TOKEN_IDENT, + ASE_STX_TOKEN_BINARY, + ASE_STX_TOKEN_KEYWORD, + ASE_STX_TOKEN_PRIMITIVE, + ASE_STX_TOKEN_ASSIGN, + ASE_STX_TOKEN_COLON, + ASE_STX_TOKEN_RETURN, + ASE_STX_TOKEN_LBRACKET, + ASE_STX_TOKEN_RBRACKET, + ASE_STX_TOKEN_LPAREN, + ASE_STX_TOKEN_RPAREN, + ASE_STX_TOKEN_APAREN, + ASE_STX_TOKEN_PERIOD, + ASE_STX_TOKEN_SEMICOLON +}; + +struct ase_stx_token_t +{ + int type; + + /* + ase_stx_int_t ivalue; + ase_stx_real_t fvalue; + */ + ase_stx_name_t name; + ase_bool_t __dynamic; +}; + +typedef struct ase_stx_token_t ase_stx_token_t; + +#ifdef __cplusplus +extern "C" { +#endif + +ase_stx_token_t* ase_stx_token_open ( + ase_stx_token_t* token, ase_word_t capacity); +void ase_stx_token_close (ase_stx_token_t* token); + +int ase_stx_token_addc (ase_stx_token_t* token, ase_cint_t c); +int ase_stx_token_adds (ase_stx_token_t* token, const ase_char_t* s); +void ase_stx_token_clear (ase_stx_token_t* token); +ase_char_t* ase_stx_token_yield (ase_stx_token_t* token, ase_word_t capacity); +int ase_stx_token_compare_name (ase_stx_token_t* token, const ase_char_t* str); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ase/test/awk/AseAwk.java b/ase/test/awk/AseAwk.java new file mode 100644 index 00000000..febf8956 --- /dev/null +++ b/ase/test/awk/AseAwk.java @@ -0,0 +1,142 @@ +/* + * $Id: AseAwk.java,v 1.1 2007/04/30 08:32:41 bacon Exp $ + */ + +import java.awt.*; +import java.awt.event.*; + +public class AseAwk extends ase.awk.StdAwk +{ + public AseAwk () throws ase.awk.Exception + { + super (); + } + + protected String[] consoleInputNames () + { + String[] cin = new String[3]; + cin[0] = "c1.txt"; + cin[1] = "c2.txt"; + cin[2] = "c3.txt"; + return cin; + } + + protected String[] consoleOutputNames () + { + String[] cout = new String[1]; + cout[0] = ""; + return cout; +/* + String[] cout = new String[3]; + cout[0] = "c4.txt"; + cout[1] = "c5.txt"; + cout[2] = ""; + return cout; +*/ + } + + protected String[] sourceInputNames () + { + String[] sin = new String[1]; + sin[0] = "t.awk"; + return sin; + } + + /* + protected String sourceOutputName () + { + return ""; + } + */ + + public static void main (String[] args) + { + // AWT mode + if (args.length == 0) + { + final Frame frame = new Frame (); + + frame.setLayout (new BorderLayout()); + frame.setTitle (AseAwk.class.getName()); + frame.setSize (640, 480); + frame.addWindowListener (new WindowListener () + { + public void windowActivated (WindowEvent e) {} + public void windowClosed (WindowEvent e) {} + public void windowClosing (WindowEvent e) { frame.dispose (); } + public void windowDeactivated (WindowEvent e) {} + public void windowDeiconified (WindowEvent e) {} + public void windowIconified (WindowEvent e) {} + public void windowOpened (WindowEvent e) {} + }); + + frame.add (new AseAwkPanel(), BorderLayout.CENTER); + frame.setVisible (true); + return; + } + + // console mode + AseAwk awk = null; + + if (args.length != 1) + { + + System.err.println ("Usage: " + AseAwk.class.getName() + " jni"); + System.err.println ("Where jni := the full path to the jni library"); + return; + } + + try + { + System.load (args[0]); + } + catch (java.lang.UnsatisfiedLinkError e) + { + System.err.println ("Error: cannot load the library - " + args[0]); + return; + } + + try + { + awk = new AseAwk (); + awk.setMaxDepth (AseAwk.DEPTH_BLOCK_PARSE, 30); + awk.setDebug (true); + //awk.setDebug (false); + + //awk.setOption (awk.getOption() | OPTION_STRBASEONE); + System.out.println ("Option: [" + awk.getOption() + "]"); + + awk.parse (); + + System.out.println ("about to run"); + String[] aaa = new String[3]; + aaa[0] = "abcdefg"; + aaa[1] = "qwerty"; + aaa[2] = "awk is bad"; + awk.run ("main", aaa); + } + catch (ase.awk.Exception e) + { + if (e.getLine() == 0) + { + System.out.println ("ase.awk.Exception - " + e.getMessage()); + } + else + { + System.out.println ( + "ase.awk.Exception at line " + + e.getLine() + " - " + e.getMessage()); + } + } + finally + { + if (awk != null) + { + awk.close (); + awk = null; + } + } + System.out.println ("==== end of awk ===="); + } + +} diff --git a/ase/test/awk/AseAwkApplet.html b/ase/test/awk/AseAwkApplet.html new file mode 100644 index 00000000..fddbf84a --- /dev/null +++ b/ase/test/awk/AseAwkApplet.html @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/ase/test/awk/AseAwkApplet.java b/ase/test/awk/AseAwkApplet.java new file mode 100644 index 00000000..44f67501 --- /dev/null +++ b/ase/test/awk/AseAwkApplet.java @@ -0,0 +1,23 @@ +/* + * $Id: AseAwkApplet.java,v 1.1 2007/04/30 08:32:41 bacon Exp $ + */ + +import java.applet.*; +import java.awt.*; +import java.awt.event.*; + +public class AseAwkApplet extends Applet +{ + AseAwkPanel awkPanel; + + public void init () + { + awkPanel = new AseAwkPanel (); + + setLayout (new BorderLayout ()); + add (awkPanel, BorderLayout.CENTER); + } + + public void stop () {} + public void paint (Graphics g) {} +} diff --git a/ase/test/awk/AseAwkPanel.java b/ase/test/awk/AseAwkPanel.java new file mode 100644 index 00000000..d67d7e7f --- /dev/null +++ b/ase/test/awk/AseAwkPanel.java @@ -0,0 +1,404 @@ +/* + * $Id: AseAwkPanel.java,v 1.1 2007/04/30 08:32:41 bacon Exp $ + */ + +import java.awt.*; +import java.awt.event.*; + +import java.net.URL; +import java.io.File; +import java.io.IOException; +import java.io.StringReader; +import java.io.StringWriter; + +import ase.awk.StdAwk; +import ase.awk.Extio; + +public class AseAwkPanel extends Panel +{ + /* MsgBox taken from http://www.rgagnon.com/javadetails/java-0242.html */ + class MsgBox extends Dialog implements ActionListener + { + boolean id = false; + Button ok,can; + + MsgBox (Frame frame, String msg, boolean okcan) + { + super (frame, "Message", true); + setLayout(new BorderLayout()); + add("Center",new Label(msg)); + addOKCancelPanel(okcan); + createFrame(); + pack(); + setVisible(true); + } + + void addOKCancelPanel( boolean okcan ) + { + Panel p = new Panel(); + p.setLayout(new FlowLayout()); + createOKButton( p ); + if (okcan == true) createCancelButton( p ); + add("South",p); + } + + void createOKButton(Panel p) + { + p.add(ok = new Button("OK")); + ok.addActionListener(this); + } + + void createCancelButton(Panel p) + { + p.add(can = new Button("Cancel")); + can.addActionListener(this); + } + + void createFrame() + { + Dimension d = getToolkit().getScreenSize(); + setLocation(d.width/3,d.height/3); + } + + public void actionPerformed(ActionEvent ae) + { + if(ae.getSource() == ok) + { + id = true; + setVisible(false); + } + else if(ae.getSource() == can) + { + setVisible(false); + } + } + } + + class Awk extends StdAwk + { + private AseAwkPanel awkPanel; + + private StringReader srcIn; + private StringWriter srcOut; + + private StringReader conIn; + private StringWriter conOut; + + public Awk (AseAwkPanel awkPanel) throws Exception + { + super (); + this.awkPanel = awkPanel; + } + + protected int openSource (int mode) + { + if (mode == SOURCE_READ) + { + srcIn = new StringReader (awkPanel.getSourceInput()); + return 1; + } + else if (mode == SOURCE_WRITE) + { + srcOut = new StringWriter (); + return 1; + } + + return -1; + } + + protected int closeSource (int mode) + { + if (mode == SOURCE_READ) + { + srcIn.close (); + return 0; + } + else if (mode == SOURCE_WRITE) + { + awkPanel.setSourceOutput (srcOut.toString()); + + try { srcOut.close (); } + catch (IOException e) { return -1; } + return 0; + } + + return -1; + } + + protected int readSource (char[] buf, int len) + { + try + { + int n = srcIn.read (buf, 0, len); + if (n == -1) n = 0; + return n; + } + catch (IOException e) { return -1; } + } + + protected int writeSource (char[] buf, int len) + { + srcOut.write (buf, 0, len); + return len; + } + + protected int openConsole (Extio extio) + { + int mode = extio.getMode (); + + if (mode == Extio.MODE_CONSOLE_READ) + { + conIn = new StringReader (awkPanel.getConsoleInput()); + return 1; + } + else if (mode == Extio.MODE_CONSOLE_WRITE) + { + conOut = new StringWriter (); + return 1; + } + + return -1; + + } + + protected int closeConsole (Extio extio) + { + int mode = extio.getMode (); + + if (mode == Extio.MODE_CONSOLE_READ) + { + conIn.close (); + return 0; + } + else if (mode == Extio.MODE_CONSOLE_WRITE) + { + awkPanel.setConsoleOutput (conOut.toString()); + + try { conOut.close (); } + catch (IOException e) { return -1; } + return 0; + } + + return -1; + } + + protected int readConsole (Extio extio, char[] buf, int len) + { + int mode = extio.getMode (); + + if (mode == Extio.MODE_CONSOLE_READ) + { + try + { + int n = conIn.read (buf, 0, len); + if (n == -1) n = 0; + return n; + } + catch (IOException e) { return -1; } + } + + return -1; + } + + protected int writeConsole (Extio extio, char[] buf, int len) + { + int mode = extio.getMode (); + + if (mode == Extio.MODE_CONSOLE_WRITE) + { + conOut.write (buf, 0, len); + return len; + } + + return -1; + } + + protected int flushConsole (Extio extio) + { + int mode = extio.getMode (); + + if (mode == Extio.MODE_CONSOLE_WRITE) + { + return 0; + } + + return -1; + } + + protected int nextConsole (Extio extio) + { + int mode = extio.getMode (); + + if (mode == Extio.MODE_CONSOLE_READ) + { + } + else if (mode == Extio.MODE_CONSOLE_WRITE) + { + } + + return -1; + } + } + + private TextArea srcIn; + private TextArea srcOut; + private TextArea conIn; + private TextArea conOut; + private TextField jniLib; + + private boolean jniLibLoaded = false; + + public AseAwkPanel () + { + jniLib = new TextField (); + + srcIn = new TextArea (); + srcOut = new TextArea (); + conIn = new TextArea (); + conOut = new TextArea (); + + Button runBtn = new Button ("Run Awk"); + + runBtn.addActionListener (new ActionListener () + { + public void actionPerformed (ActionEvent e) + { + runAwk (); + } + }); + + Panel topPanel = new Panel (); + BorderLayout topPanelLayout = new BorderLayout (); + topPanel.setLayout (topPanelLayout); + + topPanelLayout.setHgap (2); + topPanelLayout.setVgap (2); + topPanel.add (new Label ("JNI Library: "), BorderLayout.WEST); + topPanel.add (jniLib, BorderLayout.CENTER); + + Panel centerPanel = new Panel (); + GridLayout centerPanelLayout = new GridLayout (2, 2); + + centerPanel.setLayout (centerPanelLayout); + + centerPanelLayout.setHgap (2); + centerPanelLayout.setVgap (2); + + centerPanel.add (srcIn); + centerPanel.add (srcOut); + centerPanel.add (conIn); + centerPanel.add (conOut); + + BorderLayout mainLayout = new BorderLayout (); + mainLayout.setHgap (2); + mainLayout.setVgap (2); + + setLayout (mainLayout); + + add (topPanel, BorderLayout.NORTH); + add (centerPanel, BorderLayout.CENTER); + add (runBtn, BorderLayout.SOUTH); + + URL url = this.getClass().getResource ( + this.getClass().getName() + ".class"); + File file = new File (url.getFile()); + + String osname = System.getProperty ("os.name").toLowerCase(); + String aseBase = file.getParentFile().getParentFile().getParent(); + + if (osname.startsWith ("windows")) + { + String path = aseBase + "\\lib\\aseawk_jni.dll"; + jniLib.setText (path.substring(6)); + } + else if (osname.startsWith ("mac")) + { + String path = aseBase + "/lib/.libs/libaseawk_jni.dylib"; + jniLib.setText (path.substring(5)); + } + else + { + String path = aseBase + "/lib/.libs/libaseawk_jni.so"; + jniLib.setText (path.substring(5)); + } + } + + public String getSourceInput () + { + return srcIn.getText (); + } + + public void setSourceOutput (String output) + { + srcOut.setText (output); + } + + public String getConsoleInput () + { + return conIn.getText (); + } + + public void setConsoleOutput (String output) + { + conOut.setText (output); + } + + private void runAwk () + { + Awk awk = null; + + if (!jniLibLoaded) + { + try + { + System.load (jniLib.getText()); + jniLib.setEnabled (false); + jniLibLoaded = true; + } + catch (UnsatisfiedLinkError e) + { + showMessage ("Cannot load library - " + e.getMessage()); + return; + } + catch (Exception e) + { + showMessage ("Cannot load library - " + e.getMessage()); + return; + } + } + + try + { + try + { + awk = new Awk (this); + } + catch (Exception e) + { + showMessage ("Cannot instantiate awk - " + e.getMessage()); + return; + } + + awk.parse (); + awk.run (); + } + catch (ase.awk.Exception e) + { + showMessage ("An exception occurred - " + e.getMessage()); + return; + } + finally + { + if (awk != null) awk.close (); + } + } + + private void showMessage (String msg) + { + Frame tmp = new Frame (""); + MsgBox message = new MsgBox (tmp, msg, false); + requestFocus (); + message.dispose (); + tmp.dispose (); + } +} diff --git a/ase/test/awk/arg.awk b/ase/test/awk/arg.awk new file mode 100644 index 00000000..01bdf5f0 --- /dev/null +++ b/ase/test/awk/arg.awk @@ -0,0 +1,34 @@ +BEGIN { + print "ARGC=", ARGC; + for (i in ARGV) + { + print "ARGV[" i "]", ARGV[i]; + } + + print "----------------------"; + print "ARGC=", ARGC; + split ("111 22 333 555 666 777", ARGV); + for (i in ARGV) + { + print "ARGV[" i "]", ARGV[i]; + } + + #for (i = 0 + # i < 20 + # i;;) print "[" i "]"; + #for (i = 0 + # (i < 20) + # i;;) print "[" i "]"; + + #printf 10, 20, 30; + if (ARGC >= 0) printf ("ARGC [%++#10.10i] is positive\n", 10); + if (ARGC >= 0) printf ("ARGC [%++#10.10f] is positive\n", 10); + if (ARGC >= 0) printf ("ARGC [%++#10.10E] is positive\n", 10124.1123); + if (ARGC >= 0) printf ("ARGC [%++#10.10G] is positive\n", 10124.1123); + if (ARGC >= 0) printf ("ARGC [%++#10.10g] is positive\n", 10124.1123); + if (ARGC >= 0) printf ("ARGC [%++#10.10f] is positive\n", 10124.1123); + printf ("[%d], [%f], [%s]\n", 10124.1123, 10124.1123, 10124.1123); + printf ("[%-10c] [% 0*.*d]\n", 65, 45, 48, -1); + + print sprintf ("abc%d %*.*d %c %s %c", 10, 20, 30, 40, "good", "good", 75.34); +} diff --git a/ase/test/awk/arr.awk b/ase/test/awk/arr.awk new file mode 100644 index 00000000..f3b58e93 --- /dev/null +++ b/ase/test/awk/arr.awk @@ -0,0 +1,18 @@ +BEGIN { + a[1,2,3] = 20; + a[4,5,6] = 30; + + for (i in a) + { + n = split (i, k, SUBSEP); + for (j = 1; j < n; j++) + { + print k[j] + } + } + + if ((1,2,3) in a) + { + print a[1,2,3]; + } +} diff --git a/ase/test/awk/asetestawk.dsp b/ase/test/awk/asetestawk.dsp new file mode 100644 index 00000000..f3ba3803 --- /dev/null +++ b/ase/test/awk/asetestawk.dsp @@ -0,0 +1,102 @@ +# Microsoft Developer Studio Project File - Name="asetestawk" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=asetestawk - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "asetestawk.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "asetestawk.mak" CFG="asetestawk - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "asetestawk - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "asetestawk - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "asetestawk - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "../../release/bin" +# PROP Intermediate_Dir "release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\.." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_UNICODE" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 asecmn.lib aseawk.lib aseutl.lib user32.lib kernel32.lib /nologo /subsystem:console /machine:I386 /out:"../../release/bin/aseawk.exe" /libpath:"../../release/lib" + +!ELSEIF "$(CFG)" == "asetestawk - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "../../debug/bin" +# PROP Intermediate_Dir "debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\.." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /FR /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 asecmn.lib aseawk.lib aseutl.lib user32.lib kernel32.lib /nologo /subsystem:console /debug /machine:I386 /out:"../../debug/bin/aseawk.exe" /pdbtype:sept /libpath:"../../debug/lib" + +!ENDIF + +# Begin Target + +# Name "asetestawk - Win32 Release" +# Name "asetestawk - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\awk.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/ase/test/awk/asetestawk.vcproj b/ase/test/awk/asetestawk.vcproj new file mode 100644 index 00000000..4f53c430 --- /dev/null +++ b/ase/test/awk/asetestawk.vcproj @@ -0,0 +1,247 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ase/test/awk/awk.c b/ase/test/awk/awk.c new file mode 100644 index 00000000..a3a16675 --- /dev/null +++ b/ase/test/awk/awk.c @@ -0,0 +1,1082 @@ +/* + * $Id: awk.c,v 1.3 2007/04/30 08:32:41 bacon Exp $ + */ + +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include + +#if defined(_WIN32) + #include + #include + #include + #pragma warning (disable: 4996) + #pragma warning (disable: 4296) +#endif + +#if defined(__linux) && defined(_DEBUG) +#include +#endif + +#if defined(_WIN32) && defined(_MSC_VER) && defined(_DEBUG) +#define _CRTDBG_MAP_ALLOC +#include +#endif + +struct awk_src_io +{ + const ase_char_t* input_file; + FILE* input_handle; +}; + +#if defined(_WIN32) +struct mmgr_data_t +{ + HANDLE heap; +}; +#endif + +#if defined(vms) || defined(__vms) +/* it seems that the main function should be placed in the main object file + * in OpenVMS. otherwise, the first function in the main object file seems + * to become the main function resulting in program start-up failure. */ +#include +#endif + +#ifndef NDEBUG +void ase_assert_abort (void) +{ + abort (); +} + +void ase_assert_printf (const ase_char_t* fmt, ...) +{ + va_list ap; +#ifdef _WIN32 + int n; + ase_char_t buf[1024]; +#endif + + va_start (ap, fmt); +#if defined(_WIN32) + n = _vsntprintf (buf, ASE_COUNTOF(buf), fmt, ap); + if (n < 0) buf[ASE_COUNTOF(buf)-1] = ASE_T('\0'); + + #if defined(_MSC_VER) && (_MSC_VER<1400) + MessageBox (NULL, buf, + ASE_T("Assertion Failure"), MB_OK|MB_ICONERROR); + #else + MessageBox (NULL, buf, + ASE_T("\uB2DD\uAE30\uB9AC \uC870\uB610"), MB_OK|MB_ICONERROR); + #endif +#else + ase_vprintf (fmt, ap); +#endif + va_end (ap); +} +#endif + +static void dprintf (const ase_char_t* fmt, ...) +{ + va_list ap; + va_start (ap, fmt); + ase_vfprintf (stderr, fmt, ap); + va_end (ap); +} + +static void custom_awk_dprintf (void* custom, const ase_char_t* fmt, ...) +{ + va_list ap; + va_start (ap, fmt); + ase_vfprintf (stderr, fmt, ap); + va_end (ap); +} + + +/* custom memory management function */ +static void* custom_awk_malloc (void* custom, ase_size_t n) +{ +#ifdef _WIN32 + return HeapAlloc (((struct mmgr_data_t*)custom)->heap, 0, n); +#else + return malloc (n); +#endif +} + +static void* custom_awk_realloc (void* custom, void* ptr, ase_size_t n) +{ +#ifdef _WIN32 + /* HeapReAlloc behaves differently from realloc */ + if (ptr == NULL) + return HeapAlloc (((struct mmgr_data_t*)custom)->heap, 0, n); + else + return HeapReAlloc (((struct mmgr_data_t*)custom)->heap, 0, ptr, n); +#else + return realloc (ptr, n); +#endif +} + +static void custom_awk_free (void* custom, void* ptr) +{ +#ifdef _WIN32 + HeapFree (((struct mmgr_data_t*)custom)->heap, 0, ptr); +#else + free (ptr); +#endif +} + +/* custom character class functions */ +static ase_bool_t custom_awk_isupper (void* custom, ase_cint_t c) +{ + return ase_isupper (c); +} + +static ase_bool_t custom_awk_islower (void* custom, ase_cint_t c) +{ + return ase_islower (c); +} + +static ase_bool_t custom_awk_isalpha (void* custom, ase_cint_t c) +{ + return ase_isalpha (c); +} + +static ase_bool_t custom_awk_isdigit (void* custom, ase_cint_t c) +{ + return ase_isdigit (c); +} + +static ase_bool_t custom_awk_isxdigit (void* custom, ase_cint_t c) +{ + return ase_isxdigit (c); +} + +static ase_bool_t custom_awk_isalnum (void* custom, ase_cint_t c) +{ + return ase_isalnum (c); +} + +static ase_bool_t custom_awk_isspace (void* custom, ase_cint_t c) +{ + return ase_isspace (c); +} + +static ase_bool_t custom_awk_isprint (void* custom, ase_cint_t c) +{ + return ase_isprint (c); +} + +static ase_bool_t custom_awk_isgraph (void* custom, ase_cint_t c) +{ + return ase_isgraph (c); +} + +static ase_bool_t custom_awk_iscntrl (void* custom, ase_cint_t c) +{ + return ase_iscntrl (c); +} + +static ase_bool_t custom_awk_ispunct (void* custom, ase_cint_t c) +{ + return ase_ispunct (c); +} + +static ase_cint_t custom_awk_toupper (void* custom, ase_cint_t c) +{ + return ase_toupper (c); +} + +static ase_cint_t custom_awk_tolower (void* custom, ase_cint_t c) +{ + return ase_tolower (c); +} + + +/* custom miscellaneous functions */ + +static ase_real_t custom_awk_pow (void* custom, ase_real_t x, ase_real_t y) +{ + return pow (x, y); +} + + +static int custom_awk_sprintf ( + void* custom, ase_char_t* buf, ase_size_t size, + const ase_char_t* fmt, ...) +{ + int n; + + va_list ap; + va_start (ap, fmt); + n = ase_vsprintf (buf, size, fmt, ap); + va_end (ap); + + return n; +} + + +static ase_ssize_t awk_srcio_in ( + int cmd, void* arg, ase_char_t* data, ase_size_t size) +{ + struct awk_src_io* src_io = (struct awk_src_io*)arg; + ase_cint_t c; + + if (cmd == ASE_AWK_IO_OPEN) + { + if (src_io->input_file == ASE_NULL) return 0; + src_io->input_handle = ase_fopen (src_io->input_file, ASE_T("r")); + if (src_io->input_handle == NULL) return -1; + return 1; + } + else if (cmd == ASE_AWK_IO_CLOSE) + { + if (src_io->input_file == ASE_NULL) return 0; + fclose ((FILE*)src_io->input_handle); + return 0; + } + else if (cmd == ASE_AWK_IO_READ) + { + if (size <= 0) return -1; + c = ase_fgetc ((FILE*)src_io->input_handle); + if (c == ASE_CHAR_EOF) return 0; + *data = (ase_char_t)c; + return 1; + } + + return -1; +} + +static ase_ssize_t awk_srcio_out ( + int cmd, void* arg, ase_char_t* data, ase_size_t size) +{ + /*struct awk_src_io* src_io = (struct awk_src_io*)arg;*/ + + if (cmd == ASE_AWK_IO_OPEN) return 1; + else if (cmd == ASE_AWK_IO_CLOSE) + { + fflush (stdout); + return 0; + } + else if (cmd == ASE_AWK_IO_WRITE) + { + int n = ase_fprintf (stdout, ASE_T("%.*s"), size, data); + if (n < 0) return -1; + + return size; + } + + return -1; +} + +static ase_ssize_t awk_extio_pipe ( + int cmd, void* arg, ase_char_t* data, ase_size_t size) +{ + ase_awk_extio_t* epa = (ase_awk_extio_t*)arg; + + switch (cmd) + { + case ASE_AWK_IO_OPEN: + { + FILE* handle; + const ase_char_t* mode; + + if (epa->mode == ASE_AWK_EXTIO_PIPE_READ) + mode = ASE_T("r"); + else if (epa->mode == ASE_AWK_EXTIO_PIPE_WRITE) + mode = ASE_T("w"); + else return -1; /* TODO: any way to set the error number? */ + + dprintf (ASE_T("opening %s of type %d (pipe)\n"), epa->name, epa->type); + handle = ase_popen (epa->name, mode); + if (handle == NULL) return -1; + epa->handle = (void*)handle; + return 1; + } + + case ASE_AWK_IO_CLOSE: + { + dprintf (ASE_T("closing %s of type (pipe) %d\n"), epa->name, epa->type); + fclose ((FILE*)epa->handle); + epa->handle = NULL; + return 0; + } + + case ASE_AWK_IO_READ: + { + if (ase_fgets (data, size, (FILE*)epa->handle) == ASE_NULL) + { + if (ferror((FILE*)epa->handle)) return -1; + return 0; + } + return ase_strlen(data); + } + + case ASE_AWK_IO_WRITE: + { + #if defined(ASE_CHAR_IS_WCHAR) && defined(__linux) + /* fwprintf seems to return an error with the file + * pointer opened by popen, as of this writing. + * anyway, hopefully the following replacement + * will work all the way. */ + int n = fprintf ( + (FILE*)epa->handle, "%.*ls", size, data); + #else + int n = ase_fprintf ( + (FILE*)epa->handle, ASE_T("%.*s"), size, data); + #endif + if (n < 0) return -1; + + return size; + } + + case ASE_AWK_IO_FLUSH: + { + if (epa->mode == ASE_AWK_EXTIO_PIPE_READ) return -1; + else return 0; + } + + case ASE_AWK_IO_NEXT: + { + return -1; + } + } + + return -1; +} + +static ase_ssize_t awk_extio_file ( + int cmd, void* arg, ase_char_t* data, ase_size_t size) +{ + ase_awk_extio_t* epa = (ase_awk_extio_t*)arg; + + switch (cmd) + { + case ASE_AWK_IO_OPEN: + { + FILE* handle; + const ase_char_t* mode; + + if (epa->mode == ASE_AWK_EXTIO_FILE_READ) + mode = ASE_T("r"); + else if (epa->mode == ASE_AWK_EXTIO_FILE_WRITE) + mode = ASE_T("w"); + else if (epa->mode == ASE_AWK_EXTIO_FILE_APPEND) + mode = ASE_T("a"); + else return -1; /* TODO: any way to set the error number? */ + + dprintf (ASE_T("opening %s of type %d (file)\n"), epa->name, epa->type); + handle = ase_fopen (epa->name, mode); + if (handle == NULL) + { + ase_cstr_t errarg; + + errarg.ptr = epa->name; + errarg.len = ase_strlen(epa->name); + + + ase_awk_setrunerror (epa->run, ASE_AWK_EOPEN, 0, &errarg, 1); + return -1; + } + + epa->handle = (void*)handle; + return 1; + } + + case ASE_AWK_IO_CLOSE: + { + dprintf (ASE_T("closing %s of type %d (file)\n"), epa->name, epa->type); + fclose ((FILE*)epa->handle); + epa->handle = NULL; + return 0; + } + + case ASE_AWK_IO_READ: + { + if (ase_fgets (data, size, (FILE*)epa->handle) == ASE_NULL) + { + if (ferror((FILE*)epa->handle)) return -1; + return 0; + } + return ase_strlen(data); + } + + case ASE_AWK_IO_WRITE: + { + int n = ase_fprintf ( + (FILE*)epa->handle, ASE_T("%.*s"), size, data); + if (n < 0) return -1; + + return size; + } + + case ASE_AWK_IO_FLUSH: + { + if (fflush ((FILE*)epa->handle) == EOF) return -1; + return 0; + } + + case ASE_AWK_IO_NEXT: + { + return -1; + } + + } + + return -1; +} + +static int open_extio_console (ase_awk_extio_t* epa); +static int close_extio_console (ase_awk_extio_t* epa); +static int next_extio_console (ase_awk_extio_t* epa); + +static ase_size_t infile_no = 0; +static const ase_char_t* infiles[1000] = +{ + ASE_T(""), + ASE_NULL +}; + +static ase_ssize_t awk_extio_console ( + int cmd, void* arg, ase_char_t* data, ase_size_t size) +{ + ase_awk_extio_t* epa = (ase_awk_extio_t*)arg; + + if (cmd == ASE_AWK_IO_OPEN) + { + return open_extio_console (epa); + } + else if (cmd == ASE_AWK_IO_CLOSE) + { + return close_extio_console (epa); + } + else if (cmd == ASE_AWK_IO_READ) + { + while (ase_fgets (data, size, (FILE*)epa->handle) == ASE_NULL) + { + if (ferror((FILE*)epa->handle)) return -1; + + /* it has reached the end of the current file. + * open the next file if available */ + if (infiles[infile_no] == ASE_NULL) + { + /* no more input console */ + return 0; + } + + if (infiles[infile_no][0] == ASE_T('\0')) + { + if (epa->handle != ASE_NULL && + epa->handle != stdin && + epa->handle != stdout && + epa->handle != stderr) + { + /* TODO: ................................ */ + if (fclose ((FILE*)epa->handle) == EOF) + { + ase_cstr_t errarg; + + errarg.ptr = ASE_T("consolXXXe"); + errarg.len = 7; + + ase_awk_setrunerror (epa->run, ASE_AWK_ECLOSE, 0, &errarg, 1); + return -1; + } + } + + epa->handle = stdin; + } + else + { + FILE* fp = ase_fopen (infiles[infile_no], ASE_T("r")); + if (fp == ASE_NULL) + { + ase_cstr_t errarg; + + errarg.ptr = infiles[infile_no]; + errarg.len = ase_strlen(infiles[infile_no]); + + ase_awk_setrunerror (epa->run, ASE_AWK_EOPEN, 0, &errarg, 1); + return -1; + } + + if (ase_awk_setfilename ( + epa->run, infiles[infile_no], + ase_strlen(infiles[infile_no])) == -1) + { + fclose (fp); + return -1; + } + + if (epa->handle != ASE_NULL && + epa->handle != stdin && + epa->handle != stdout && + epa->handle != stderr) + { + /* TODO: ................................ */ + if (fclose ((FILE*)epa->handle) == EOF) + { + ase_cstr_t errarg; + + errarg.ptr = ASE_T("console"); + errarg.len = 7; + + ase_awk_setrunerror (epa->run, ASE_AWK_ECLOSE, 0, &errarg, 1); + + fclose (fp); + return -1; + } + } + + dprintf (ASE_T("open the next console [%s]\n"), infiles[infile_no]); + epa->handle = fp; + } + + infile_no++; + } + + return ase_strlen(data); + } + else if (cmd == ASE_AWK_IO_WRITE) + { + int n = ase_fprintf ( + (FILE*)epa->handle, ASE_T("%.*s"), size, data); + if (n < 0) return -1; + + return size; + } + else if (cmd == ASE_AWK_IO_FLUSH) + { + if (fflush ((FILE*)epa->handle) == EOF) return -1; + return 0; + } + else if (cmd == ASE_AWK_IO_NEXT) + { + return next_extio_console (epa); + } + + return -1; +} + +static int open_extio_console (ase_awk_extio_t* epa) +{ + /* TODO: OpenConsole in GUI APPLICATION */ + + dprintf (ASE_T("opening console[%s] of type %x\n"), epa->name, epa->type); + + if (epa->mode == ASE_AWK_EXTIO_CONSOLE_READ) + { + if (infiles[infile_no] == ASE_NULL) + { + /* no more input file */ + dprintf (ASE_T("console - no more file\n"));; + return 0; + } + + if (infiles[infile_no][0] == ASE_T('\0')) + { + dprintf (ASE_T(" console(r) - \n")); + epa->handle = stdin; + } + else + { + /* a temporary variable fp is used here not to change + * any fields of epa when the open operation fails */ + FILE* fp = ase_fopen (infiles[infile_no], ASE_T("r")); + if (fp == ASE_NULL) + { + ase_cstr_t errarg; + + errarg.ptr = infiles[infile_no]; + errarg.len = ase_strlen(infiles[infile_no]); + + ase_awk_setrunerror (epa->run, ASE_AWK_EOPEN, 0, &errarg, 1); + return -1; + } + + dprintf (ASE_T(" console(r) - %s\n"), infiles[infile_no]); + if (ase_awk_setfilename ( + epa->run, infiles[infile_no], + ase_strlen(infiles[infile_no])) == -1) + { + fclose (fp); + return -1; + } + + epa->handle = fp; + } + + infile_no++; + return 1; + } + else if (epa->mode == ASE_AWK_EXTIO_CONSOLE_WRITE) + { + dprintf (ASE_T(" console(w) - \n")); + + if (ase_awk_setofilename (epa->run, ASE_T(""), 0) == -1) + { + return -1; + } + + epa->handle = stdout; + return 1; + } + + return -1; +} + +static int close_extio_console (ase_awk_extio_t* epa) +{ + dprintf (ASE_T("closing console of type %x\n"), epa->type); + + if (epa->handle != ASE_NULL && + epa->handle != stdin && + epa->handle != stdout && + epa->handle != stderr) + { + if (fclose ((FILE*)epa->handle) == EOF) + { + ase_cstr_t errarg; + + errarg.ptr = epa->name; + errarg.len = ase_strlen(epa->name); + + ase_awk_setrunerror (epa->run, ASE_AWK_ECLOSE, 0, &errarg, 1); + return -1; + } + } + + return 0; +} + +static int next_extio_console (ase_awk_extio_t* epa) +{ + int n; + FILE* fp = (FILE*)epa->handle; + + dprintf (ASE_T("switching console[%s] of type %x\n"), epa->name, epa->type); + + n = open_extio_console(epa); + if (n == -1) return -1; + + if (n == 0) + { + /* if there is no more file, keep the previous handle */ + return 0; + } + + if (fp != ASE_NULL && fp != stdin && + fp != stdout && fp != stderr) fclose (fp); + + return n; +} + +ase_awk_t* app_awk = NULL; +ase_awk_run_t* app_run = NULL; + +#ifdef _WIN32 +static BOOL WINAPI stop_run (DWORD ctrl_type) +{ + if (ctrl_type == CTRL_C_EVENT || + ctrl_type == CTRL_CLOSE_EVENT) + { + ase_awk_stop (app_run); + return TRUE; + } + + return FALSE; +} +#else +static void stop_run (int sig) +{ + signal (SIGINT, SIG_IGN); + ase_awk_stop (app_run); + signal (SIGINT, stop_run); +} +#endif + +static void on_run_start (ase_awk_run_t* run, void* custom) +{ + app_run = run; + dprintf (ASE_T("[AWK ABOUT TO START]\n")); +} + +static int print_awk_value (ase_awk_pair_t* pair, void* arg) +{ + ase_awk_run_t* run = (ase_awk_run_t*)arg; + dprintf (ASE_T("%.*s = "), pair->key.len, pair->key.ptr); + ase_awk_dprintval (run, (ase_awk_val_t*)pair->val); + dprintf (ASE_T("\n")); + return 0; +} + +static void on_run_statement ( + ase_awk_run_t* run, ase_size_t line, void* custom) +{ + /*dprintf (L"running %d\n", (int)line);*/ +} + +static void on_run_return ( + ase_awk_run_t* run, ase_awk_val_t* ret, void* custom) +{ + dprintf (ASE_T("[RETURN] - ")); + ase_awk_dprintval (run, ret); + dprintf (ASE_T("\n")); + + dprintf (ASE_T("[NAMED VARIABLES]\n")); + ase_awk_map_walk (ase_awk_getrunnamedvarmap(run), print_awk_value, run); + dprintf (ASE_T("[END NAMED VARIABLES]\n")); +} + +static void on_run_end (ase_awk_run_t* run, int errnum, void* custom_data) +{ + if (errnum != ASE_AWK_ENOERR) + { + dprintf (ASE_T("[AWK ENDED WITH AN ERROR]\n")); + ase_printf (ASE_T("RUN ERROR: CODE [%d] LINE [%u] %s\n"), + errnum, + (unsigned int)ase_awk_getrunerrlin(run), + ase_awk_getrunerrmsg(run)); + } + else dprintf (ASE_T("[AWK ENDED SUCCESSFULLY]\n")); + + app_run = NULL; +} + +static void print_usage (const ase_char_t* argv0) +{ + ase_printf (ASE_T("Usage: %s [-m] [-d] [-a argument]* -f source-file [data-file]*\n"), argv0); +} + +static int run_awk (ase_awk_t* awk, + const ase_char_t* mfn, ase_awk_runarg_t* runarg) +{ + ase_awk_runcbs_t runcbs; + ase_awk_runios_t runios; + + runios.pipe = awk_extio_pipe; + runios.file = awk_extio_file; + runios.console = awk_extio_console; + runios.custom_data = ASE_NULL; + + runcbs.on_start = on_run_start; + runcbs.on_statement = on_run_statement; + runcbs.on_return = on_run_return; + runcbs.on_end = on_run_end; + runcbs.custom_data = ASE_NULL; + + if (ase_awk_run (awk, mfn, &runios, &runcbs, runarg, ASE_NULL) == -1) + { + ase_printf ( + ASE_T("RUN ERROR: CODE [%d] LINE [%u] %s\n"), + ase_awk_geterrnum(awk), + (unsigned int)ase_awk_geterrlin(awk), + ase_awk_geterrmsg(awk)); + + return -1; + } + + return 0; +} + +#if defined(_WIN32) && defined(TEST_THREAD) +typedef struct thr_arg_t thr_arg_t; +struct thr_arg_t +{ + ase_awk_t* awk; + const ase_char_t* mfn; + ase_awk_runarg_t* runarg; +}; + +static unsigned int __stdcall run_awk_thr (void* arg) +{ + int n; + thr_arg_t* x = (thr_arg_t*)arg; + + n = run_awk (x->awk, x->mfn, x->runarg); + + _endthreadex (n); + return 0; +} +#endif + +static int awk_main (int argc, ase_char_t* argv[]) +{ + ase_awk_t* awk; + ase_awk_srcios_t srcios; + ase_awk_prmfns_t prmfns; + struct awk_src_io src_io = { NULL, NULL }; + int opt, i, file_count = 0; +#ifdef _WIN32 + struct mmgr_data_t mmgr_data; +#endif + const ase_char_t* mfn = ASE_NULL; + int mode = 0; + int runarg_count = 0; + ase_awk_runarg_t runarg[128]; + int deparse = 0; + + opt = ASE_AWK_IMPLICIT | + ASE_AWK_EXPLICIT | + ASE_AWK_UNIQUEFN | + ASE_AWK_IDIV | + ASE_AWK_SHADING | + ASE_AWK_SHIFT | + ASE_AWK_EXTIO | + ASE_AWK_BLOCKLESS | + ASE_AWK_STRBASEONE | + ASE_AWK_STRIPSPACES | + ASE_AWK_NEXTOFILE /*| + ASE_AWK_ARGSTOMAIN*/; + + if (argc <= 1) + { + print_usage (argv[0]); + return -1; + } + + for (i = 1; i < argc; i++) + { + if (mode == 0) + { + if (ase_strcmp(argv[i], ASE_T("-m")) == 0) + { + mfn = ASE_T("main"); + } + else if (ase_strcmp(argv[i], ASE_T("-d")) == 0) + { + deparse = 1; + } + else if (ase_strcmp(argv[i], ASE_T("-f")) == 0) + { + /* specify source file */ + mode = 1; + } + else if (ase_strcmp(argv[i], ASE_T("-a")) == 0) + { + /* specify arguments */ + mode = 2; + } + else if (argv[i][0] == ASE_T('-')) + { + print_usage (argv[0]); + return -1; + } + else if (file_count < ASE_COUNTOF(infiles)-1) + { + infiles[file_count] = argv[i]; + file_count++; + } + else + { + print_usage (argv[0]); + return -1; + } + } + else if (mode == 1) /* source mode */ + { + if (argv[i][0] == ASE_T('-')) + { + print_usage (argv[0]); + return -1; + } + + if (src_io.input_file != NULL) + { + print_usage (argv[0]); + return -1; + } + + src_io.input_file = argv[i]; + mode = 0; + } + else if (mode == 2) /* argument mode */ + { + if (argv[i][0] == ASE_T('-')) + { + print_usage (argv[0]); + return -1; + } + + if (runarg_count >= ASE_COUNTOF(runarg)-1) + { + print_usage (argv[0]); + return -1; + } + + runarg[runarg_count].ptr = argv[i]; + runarg[runarg_count].len = ase_strlen(argv[i]); + runarg_count++; + mode = 0; + } + } + + infiles[file_count] = ASE_NULL; + runarg[runarg_count].ptr = NULL; + runarg[runarg_count].len = 0; + + if (mode != 0 || src_io.input_file == NULL) + { + print_usage (argv[0]); + return -1; + } + + memset (&prmfns, 0, ASE_SIZEOF(prmfns)); + + prmfns.mmgr.malloc = custom_awk_malloc; + prmfns.mmgr.realloc = custom_awk_realloc; + prmfns.mmgr.free = custom_awk_free; +#ifdef _WIN32 + mmgr_data.heap = HeapCreate (0, 1000000, 1000000); + if (mmgr_data.heap == NULL) + { + ase_printf (ASE_T("Error: cannot create an awk heap\n")); + return -1; + } + + prmfns.mmgr.custom_data = &mmgr_data; +#else + prmfns.mmgr.custom_data = NULL; +#endif + + prmfns.ccls.is_upper = custom_awk_isupper; + prmfns.ccls.is_lower = custom_awk_islower; + prmfns.ccls.is_alpha = custom_awk_isalpha; + prmfns.ccls.is_digit = custom_awk_isdigit; + prmfns.ccls.is_xdigit = custom_awk_isxdigit; + prmfns.ccls.is_alnum = custom_awk_isalnum; + prmfns.ccls.is_space = custom_awk_isspace; + prmfns.ccls.is_print = custom_awk_isprint; + prmfns.ccls.is_graph = custom_awk_isgraph; + prmfns.ccls.is_cntrl = custom_awk_iscntrl; + prmfns.ccls.is_punct = custom_awk_ispunct; + prmfns.ccls.to_upper = custom_awk_toupper; + prmfns.ccls.to_lower = custom_awk_tolower; + prmfns.ccls.custom_data = NULL; + + prmfns.misc.pow = custom_awk_pow; + prmfns.misc.sprintf = custom_awk_sprintf; + prmfns.misc.dprintf = custom_awk_dprintf; + prmfns.misc.custom_data = NULL; + + if ((awk = ase_awk_open(&prmfns, ASE_NULL)) == ASE_NULL) + { +#ifdef _WIN32 + HeapDestroy (mmgr_data.heap); +#endif + ase_printf (ASE_T("ERROR: cannot open awk\n")); + return -1; + } + + app_awk = awk; + + ase_awk_setoption (awk, opt); + + /* + ase_awk_seterrstr (awk, ASE_AWK_EGBLRED, ASE_T("\uC804\uC5ED\uBCC0\uC218 \'%.*s\'\uAC00 \uC7AC\uC815\uC758 \uB418\uC5C8\uC2B5\uB2C8\uB2E4")); + ase_awk_seterrstr (awk, ASE_AWK_EAFNRED, ASE_T("\uD568\uC218 \'%.*s\'\uAC00 \uC7AC\uC815\uC758 \uB418\uC5C8\uC2B5\uB2C8\uB2E4")); + */ + + srcios.in = awk_srcio_in; + srcios.out = deparse? awk_srcio_out: NULL; + srcios.custom_data = &src_io; + + ase_awk_setmaxdepth ( + awk, ASE_AWK_DEPTH_BLOCK_PARSE | ASE_AWK_DEPTH_EXPR_PARSE, 20); + ase_awk_setmaxdepth ( + awk, ASE_AWK_DEPTH_BLOCK_RUN | ASE_AWK_DEPTH_EXPR_RUN, 50); + + if (ase_awk_parse (awk, &srcios) == -1) + { + ase_printf ( + ASE_T("PARSE ERROR: CODE [%d] LINE [%u] %s\n"), + ase_awk_geterrnum(awk), + (unsigned int)ase_awk_geterrlin(awk), + ase_awk_geterrmsg(awk)); + ase_awk_close (awk); + return -1; + } + +#ifdef _WIN32 + SetConsoleCtrlHandler (stop_run, TRUE); +#else + signal (SIGINT, stop_run); +#endif + +#if defined(_WIN32) && defined(TEST_THREAD) + { + unsigned int tid; + HANDLE thr[5]; + thr_arg_t arg; + int y; + + arg.awk = awk; + arg.mfn = mfn; + arg.runarg = runarg; + + for (y = 0; y < ASE_COUNTOF(thr); y++) + { + thr[y] = (HANDLE)_beginthreadex (NULL, 0, run_awk_thr, &arg, 0, &tid); + if (thr[y] == (HANDLE)0) + { + ase_printf (ASE_T("ERROR: cannot create a thread %d\n"), y); + } + } + + for (y = 0; y < ASE_COUNTOF(thr); y++) + { + if (thr[y]) WaitForSingleObject (thr[y], INFINITE); + } + } +#else + if (run_awk (awk, mfn, runarg) == -1) + { + ase_awk_close (awk); + return -1; + } +#endif + + ase_awk_close (awk); +#ifdef _WIN32 + HeapDestroy (mmgr_data.heap); +#endif + return 0; +} + +int ase_main (int argc, ase_char_t* argv[]) +{ + int n; + +#if defined(__linux) && defined(_DEBUG) + mtrace (); +#endif +/* +#if defined(_WIN32) && defined(_MSC_VER) && defined(_DEBUG) + _CrtSetDbgFlag (_CRTDBG_LEAK_CHECK_DF | _CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_ALWAYS_DF); +#endif +*/ + + n = awk_main (argc, argv); + +#if defined(__linux) && defined(_DEBUG) + muntrace (); +#endif +#if defined(_WIN32) && defined(_DEBUG) + #if defined(_MSC_VER) + _CrtDumpMemoryLeaks (); + #endif + _tprintf (_T("Press ENTER to quit\n")); + getchar (); +#endif + + return n; +} diff --git a/ase/test/awk/comp.awk b/ase/test/awk/comp.awk new file mode 100644 index 00000000..4c6220e9 --- /dev/null +++ b/ase/test/awk/comp.awk @@ -0,0 +1,121 @@ +BEGIN { + OFS="\t\t"; + + print "1==1 :", (1 == 1); + print "1==0 :", (1 == 0); + + print "1.0==1 :", (1.0 == 1); + print "1.1==1 :", (1.1 == 1); + + print "1.0!=1 :", (1.0 != 1); + print "1.1!=1 :", (1.1 != 1); + + print "\"abc\" == \"abc\"", ("abc" == "abc"); + print "\"abc\" != \"abc\"", ("abc" != "abc"); + + print "--------------------------"; + print "a == \"\" :", (a == ""); + print "a >= \"\" :", (a >= ""); + print "a <= \"\" :", (a <= ""); + print "a > \"\" :", (a > ""); + print "a < \"\" :", (a < ""); + + print "--------------------------"; + print "a == \" \" :", (a == " "); + print "a >= \" \" :", (a >= " "); + print "a <= \" \" :", (a <= " "); + print "a > \" \" :", (a > " "); + print "a < \" \" :", (a < " "); + + print "--------------------------"; + print "\"\" == a :", ("" == a); + print "\"\" >= a:", ("" >= a); + print "\"\" <= a:", ("" <= a); + print "\"\" > a:", ("" > a); + print "\"\" < a:", ("" < a); + + print "--------------------------"; + print "\" \" == a :", (" " == a); + print "\" \" >= a:", (" " >= a); + print "\" \" <= a:", (" " <= a); + print "\" \" > a:", (" " > a); + print "\" \" < a:", (" " < a); + + print "--------------------------"; + print "10 == \"10\"", (10 == "10"); + print "10 != \"10\"", (10 != "10"); + print "10 >= \"10\"", (10 >= "10"); + print "10 <= \"10\"", (10 <= "10"); + print "10 > \"10\"", (10 > "10"); + print "10 < \"10\"", (10 < "10"); + + print "--------------------------"; + print "10 == \"11\"", (10 == "11"); + print "10 != \"11\"", (10 != "11"); + print "10 >= \"11\"", (10 >= "11"); + print "10 <= \"11\"", (10 <= "11"); + print "10 > \"11\"", (10 > "11"); + print "10 < \"11\"", (10 < "11"); + + print "--------------------------"; + print "11 == \"10\"", (11 == "10"); + print "11 != \"10\"", (11 != "10"); + print "11 >= \"10\"", (11 >= "10"); + print "11 <= \"10\"", (11 <= "10"); + print "11 > \"10\"", (11 > "10"); + print "11 < \"10\"", (11 < "10"); + + print "--------------------------"; + print "010 == \"8\"", (010 == "8"); + print "010 != \"8\"", (010 != "8"); + print "010 >= \"8\"", (010 >= "8"); + print "010 <= \"8\"", (010 <= "8"); + print "010 > \"8\"", (010 > "8"); + print "010 < \"8\"", (010 < "8"); + + print "--------------------------"; + print "10 == \"10.0\"", (10 == "10.0"); + print "10 != \"10.0\"", (10 != "10.0"); + print "10 >= \"10.0\"", (10 >= "10.0"); + print "10 <= \"10.0\"", (10 <= "10.0"); + print "10 > \"10.0\"", (10 > "10.0"); + print "10 < \"10.0\"", (10 < "10.0"); + + #OFMT="abc"; + print "--------------------------"; + print "10.0 == \"10\"", (10.0 == "10"); + print "10.0 != \"10\"", (10.0 != "10"); + print "10.0 >= \"10\"", (10.0 >= "10"); + print "10.0 <= \"10\"", (10.0 <= "10"); + print "10.0 > \"10\"", (10.0 > "10"); + print "10.0 < \"10\"", (10.0 < "10"); + + print "--------------------------"; + print "\"10\" == 10.0", ("10" == 10.0); + print "\"10\" != 10.0", ("10" != 10.0); + print "\"10\" >= 10.0", ("10" >= 10.0); + print "\"10\" <= 10.0", ("10" <= 10.0); + print "\"10\" > 10.0", ("10" > 10.0); + print "\"10\" < 10.0", ("10" < 10.0); + + print "--------------------------"; + print "\"10\" == 10.1", ("10" == 10.1); + print "\"10\" != 10.1", ("10" != 10.1); + print "\"10\" >= 10.1", ("10" >= 10.1); + print "\"10\" <= 10.1", ("10" <= 10.1); + print "\"10\" > 10.1", ("10" > 10.1); + print "\"10\" < 10.1", ("10" < 10.1); + + #a[10] = 2; + #print a == 1; + + print (0.234 + 1.01123); + print 12345678901234567890E20; + print .123; + print +.123; + print -.123; + print .123E-; + print +.123E-; + print -.123E-; + print -.123E- + "123"; +} diff --git a/ase/test/awk/cou-001.awk b/ase/test/awk/cou-001.awk new file mode 100644 index 00000000..61c997b1 --- /dev/null +++ b/ase/test/awk/cou-001.awk @@ -0,0 +1 @@ +{ print $1, $3; } # print country name and population diff --git a/ase/test/awk/cou-001.out b/ase/test/awk/cou-001.out new file mode 100644 index 00000000..b3842fbd --- /dev/null +++ b/ase/test/awk/cou-001.out @@ -0,0 +1,15 @@ +{ + print $1,$3; +} + +USSR 275 +Canada 25 +China 1032 +USA 237 +Brazil 134 +India 746 +Mexico 78 +France 55 +Japan 120 +Germany 61 +England 56 diff --git a/ase/test/awk/cou-002.awk b/ase/test/awk/cou-002.awk new file mode 100644 index 00000000..dbe8c549 --- /dev/null +++ b/ase/test/awk/cou-002.awk @@ -0,0 +1,15 @@ +BEGIN { + FS = "\t"; + printf ("%10s %6s %5s %s\n\n", + "COUNTRY", "AREA", "POP", "CONTINENT"); +} + +{ + printf ("%10s %6d %5d %s\n", $1, $2, $3, $4); + area = area + $2; + pop = pop + $3; +} + +END { + printf ("\n%10s %6d %5d\n", "TOTAL", area, pop); +} diff --git a/ase/test/awk/cou-002.out b/ase/test/awk/cou-002.out new file mode 100644 index 00000000..e8e10501 --- /dev/null +++ b/ase/test/awk/cou-002.out @@ -0,0 +1,29 @@ +BEGIN { + FS = " "; + printf ("%10s %6s %5s %s\n\n","COUNTRY","AREA","POP","CONTINENT"); +} + +{ + printf ("%10s %6d %5d %s\n",$1,$2,$3,$4); + area = (area + $2); + pop = (pop + $3); +} + +END { + printf ("\n%10s %6d %5d\n","TOTAL",area,pop); +} + COUNTRY AREA POP CONTINENT + + USSR 8649 275 Asia + Canada 3852 25 North America + China 3705 1032 Asia + USA 3615 237 North America + Brazil 3286 134 South America + India 1267 746 Asia + Mexico 762 78 North America + France 211 55 Europe + Japan 144 120 Asia + Germany 96 61 Europe + England 94 56 Europe + + TOTAL 25681 2819 diff --git a/ase/test/awk/cou-003.awk b/ase/test/awk/cou-003.awk new file mode 100644 index 00000000..8ddb4769 --- /dev/null +++ b/ase/test/awk/cou-003.awk @@ -0,0 +1 @@ +$3/$2 >= 0.5 diff --git a/ase/test/awk/cou-003.out b/ase/test/awk/cou-003.out new file mode 100644 index 00000000..05417c26 --- /dev/null +++ b/ase/test/awk/cou-003.out @@ -0,0 +1,6 @@ +(($3 / $2) >= 0.5) + +India 1267 746 Asia +Japan 144 120 Asia +Germany 96 61 Europe +England 94 56 Europe diff --git a/ase/test/awk/cou-004.awk b/ase/test/awk/cou-004.awk new file mode 100644 index 00000000..df559a9f --- /dev/null +++ b/ase/test/awk/cou-004.awk @@ -0,0 +1 @@ +$0 >= "M" diff --git a/ase/test/awk/cou-004.out b/ase/test/awk/cou-004.out new file mode 100644 index 00000000..bb237a77 --- /dev/null +++ b/ase/test/awk/cou-004.out @@ -0,0 +1,5 @@ +($0 >= "M") + +USSR 8649 275 Asia +USA 3615 237 North America +Mexico 762 78 North America diff --git a/ase/test/awk/cou-005.awk b/ase/test/awk/cou-005.awk new file mode 100644 index 00000000..d609c02f --- /dev/null +++ b/ase/test/awk/cou-005.awk @@ -0,0 +1 @@ +$1 < $4 diff --git a/ase/test/awk/cou-005.out b/ase/test/awk/cou-005.out new file mode 100644 index 00000000..345dae8f --- /dev/null +++ b/ase/test/awk/cou-005.out @@ -0,0 +1,6 @@ +($1 < $4) + +Canada 3852 25 North America +Brazil 3286 134 South America +Mexico 762 78 North America +England 94 56 Europe diff --git a/ase/test/awk/cou-006.awk b/ase/test/awk/cou-006.awk new file mode 100644 index 00000000..19ab3b3c --- /dev/null +++ b/ase/test/awk/cou-006.awk @@ -0,0 +1 @@ +$2 < $3 diff --git a/ase/test/awk/cou-006.out b/ase/test/awk/cou-006.out new file mode 100644 index 00000000..7de5b826 --- /dev/null +++ b/ase/test/awk/cou-006.out @@ -0,0 +1,5 @@ +($2 < $3) + +India 1267 746 Asia +Mexico 762 78 North America +France 211 55 Europe diff --git a/ase/test/awk/cou-007.awk b/ase/test/awk/cou-007.awk new file mode 100644 index 00000000..d583cd82 --- /dev/null +++ b/ase/test/awk/cou-007.awk @@ -0,0 +1 @@ +/Asia/ diff --git a/ase/test/awk/cou-007.out b/ase/test/awk/cou-007.out new file mode 100644 index 00000000..5b1f4af7 --- /dev/null +++ b/ase/test/awk/cou-007.out @@ -0,0 +1,6 @@ +/Asia/ + +USSR 8649 275 Asia +China 3705 1032 Asia +India 1267 746 Asia +Japan 144 120 Asia diff --git a/ase/test/awk/cou-008.awk b/ase/test/awk/cou-008.awk new file mode 100644 index 00000000..43069847 --- /dev/null +++ b/ase/test/awk/cou-008.awk @@ -0,0 +1 @@ +$4 ~ /Asia/ diff --git a/ase/test/awk/cou-008.out b/ase/test/awk/cou-008.out new file mode 100644 index 00000000..d681dfc0 --- /dev/null +++ b/ase/test/awk/cou-008.out @@ -0,0 +1,6 @@ +($4 ~ /Asia/) + +USSR 8649 275 Asia +China 3705 1032 Asia +India 1267 746 Asia +Japan 144 120 Asia diff --git a/ase/test/awk/cou-009.awk b/ase/test/awk/cou-009.awk new file mode 100644 index 00000000..9a6a6bc6 --- /dev/null +++ b/ase/test/awk/cou-009.awk @@ -0,0 +1 @@ +$4 !~ /Asia/ diff --git a/ase/test/awk/cou-009.out b/ase/test/awk/cou-009.out new file mode 100644 index 00000000..df78739f --- /dev/null +++ b/ase/test/awk/cou-009.out @@ -0,0 +1,9 @@ +($4 !~ /Asia/) + +Canada 3852 25 North America +USA 3615 237 North America +Brazil 3286 134 South America +Mexico 762 78 North America +France 211 55 Europe +Germany 96 61 Europe +England 94 56 Europe diff --git a/ase/test/awk/cou-010.awk b/ase/test/awk/cou-010.awk new file mode 100644 index 00000000..c3651638 --- /dev/null +++ b/ase/test/awk/cou-010.awk @@ -0,0 +1 @@ +$0 ~ /Asia/ diff --git a/ase/test/awk/cou-010.out b/ase/test/awk/cou-010.out new file mode 100644 index 00000000..6b66e924 --- /dev/null +++ b/ase/test/awk/cou-010.out @@ -0,0 +1,6 @@ +($0 ~ /Asia/) + +USSR 8649 275 Asia +China 3705 1032 Asia +India 1267 746 Asia +Japan 144 120 Asia diff --git a/ase/test/awk/cou-011.awk b/ase/test/awk/cou-011.awk new file mode 100644 index 00000000..b354c678 --- /dev/null +++ b/ase/test/awk/cou-011.awk @@ -0,0 +1,3 @@ +$2 !~ /^[0-9]+$/ + + diff --git a/ase/test/awk/cou-011.out b/ase/test/awk/cou-011.out new file mode 100644 index 00000000..1f009317 --- /dev/null +++ b/ase/test/awk/cou-011.out @@ -0,0 +1,2 @@ +($2 !~ /^[0-9]+$/) + diff --git a/ase/test/awk/cou-012.awk b/ase/test/awk/cou-012.awk new file mode 100644 index 00000000..7147bc42 --- /dev/null +++ b/ase/test/awk/cou-012.awk @@ -0,0 +1 @@ +$4 == "Asia" && $3 > 500 diff --git a/ase/test/awk/cou-012.out b/ase/test/awk/cou-012.out new file mode 100644 index 00000000..636c837d --- /dev/null +++ b/ase/test/awk/cou-012.out @@ -0,0 +1,4 @@ +(($4 == "Asia") && ($3 > 500)) + +China 3705 1032 Asia +India 1267 746 Asia diff --git a/ase/test/awk/cou-013.awk b/ase/test/awk/cou-013.awk new file mode 100644 index 00000000..8926c135 --- /dev/null +++ b/ase/test/awk/cou-013.awk @@ -0,0 +1 @@ +$4 == "Asia" || $4 == "Europe" diff --git a/ase/test/awk/cou-013.out b/ase/test/awk/cou-013.out new file mode 100644 index 00000000..b0f594db --- /dev/null +++ b/ase/test/awk/cou-013.out @@ -0,0 +1,9 @@ +(($4 == "Asia") || ($4 == "Europe")) + +USSR 8649 275 Asia +China 3705 1032 Asia +India 1267 746 Asia +France 211 55 Europe +Japan 144 120 Asia +Germany 96 61 Europe +England 94 56 Europe diff --git a/ase/test/awk/cou-014.awk b/ase/test/awk/cou-014.awk new file mode 100644 index 00000000..84fe7474 --- /dev/null +++ b/ase/test/awk/cou-014.awk @@ -0,0 +1 @@ +$4 ~ /^(Asia|Europe)$/ diff --git a/ase/test/awk/cou-014.out b/ase/test/awk/cou-014.out new file mode 100644 index 00000000..eae34bfa --- /dev/null +++ b/ase/test/awk/cou-014.out @@ -0,0 +1,9 @@ +($4 ~ /^(Asia|Europe)$/) + +USSR 8649 275 Asia +China 3705 1032 Asia +India 1267 746 Asia +France 211 55 Europe +Japan 144 120 Asia +Germany 96 61 Europe +England 94 56 Europe diff --git a/ase/test/awk/cou-015.awk b/ase/test/awk/cou-015.awk new file mode 100644 index 00000000..8afea30d --- /dev/null +++ b/ase/test/awk/cou-015.awk @@ -0,0 +1 @@ +/Asia/ || /Europe/ diff --git a/ase/test/awk/cou-015.out b/ase/test/awk/cou-015.out new file mode 100644 index 00000000..28616eda --- /dev/null +++ b/ase/test/awk/cou-015.out @@ -0,0 +1,9 @@ +(/Asia/ || /Europe/) + +USSR 8649 275 Asia +China 3705 1032 Asia +India 1267 746 Asia +France 211 55 Europe +Japan 144 120 Asia +Germany 96 61 Europe +England 94 56 Europe diff --git a/ase/test/awk/cou-016.awk b/ase/test/awk/cou-016.awk new file mode 100644 index 00000000..b8c94a01 --- /dev/null +++ b/ase/test/awk/cou-016.awk @@ -0,0 +1 @@ +/Asia|Europe/ diff --git a/ase/test/awk/cou-016.out b/ase/test/awk/cou-016.out new file mode 100644 index 00000000..68a43190 --- /dev/null +++ b/ase/test/awk/cou-016.out @@ -0,0 +1,9 @@ +/Asia|Europe/ + +USSR 8649 275 Asia +China 3705 1032 Asia +India 1267 746 Asia +France 211 55 Europe +Japan 144 120 Asia +Germany 96 61 Europe +England 94 56 Europe diff --git a/ase/test/awk/cou-017.awk b/ase/test/awk/cou-017.awk new file mode 100644 index 00000000..bf01d88f --- /dev/null +++ b/ase/test/awk/cou-017.awk @@ -0,0 +1 @@ +/Canada/, /USA/ diff --git a/ase/test/awk/cou-017.out b/ase/test/awk/cou-017.out new file mode 100644 index 00000000..0beca645 --- /dev/null +++ b/ase/test/awk/cou-017.out @@ -0,0 +1,5 @@ +/Canada/,/USA/ + +Canada 3852 25 North America +China 3705 1032 Asia +USA 3615 237 North America diff --git a/ase/test/awk/cou-018.awk b/ase/test/awk/cou-018.awk new file mode 100644 index 00000000..851a3d3c --- /dev/null +++ b/ase/test/awk/cou-018.awk @@ -0,0 +1 @@ +/Eurpoe/, /Africa/ diff --git a/ase/test/awk/cou-018.out b/ase/test/awk/cou-018.out new file mode 100644 index 00000000..77442148 --- /dev/null +++ b/ase/test/awk/cou-018.out @@ -0,0 +1,2 @@ +/Eurpoe/,/Africa/ + diff --git a/ase/test/awk/cou-019.awk b/ase/test/awk/cou-019.awk new file mode 100644 index 00000000..e4f9bdf0 --- /dev/null +++ b/ase/test/awk/cou-019.awk @@ -0,0 +1 @@ +FNR == 1, FNR == 5 { print FILENAME ": " $0; } diff --git a/ase/test/awk/cou-019.out b/ase/test/awk/cou-019.out new file mode 100644 index 00000000..90fdcbc4 --- /dev/null +++ b/ase/test/awk/cou-019.out @@ -0,0 +1,9 @@ +(FNR == 1),(FNR == 5) { + print ((FILENAME ": ") $0); +} + +cou-en.data: USSR 8649 275 Asia +cou-en.data: Canada 3852 25 North America +cou-en.data: China 3705 1032 Asia +cou-en.data: USA 3615 237 North America +cou-en.data: Brazil 3286 134 South America diff --git a/ase/test/awk/cou-020.awk b/ase/test/awk/cou-020.awk new file mode 100644 index 00000000..fb1ac184 --- /dev/null +++ b/ase/test/awk/cou-020.awk @@ -0,0 +1 @@ +FNR <= 5 { print FILENAME ": " $0; } diff --git a/ase/test/awk/cou-020.out b/ase/test/awk/cou-020.out new file mode 100644 index 00000000..12deeda3 --- /dev/null +++ b/ase/test/awk/cou-020.out @@ -0,0 +1,9 @@ +(FNR <= 5) { + print ((FILENAME ": ") $0); +} + +cou-en.data: USSR 8649 275 Asia +cou-en.data: Canada 3852 25 North America +cou-en.data: China 3705 1032 Asia +cou-en.data: USA 3615 237 North America +cou-en.data: Brazil 3286 134 South America diff --git a/ase/test/awk/cou-021.awk b/ase/test/awk/cou-021.awk new file mode 100644 index 00000000..dfcc0b09 --- /dev/null +++ b/ase/test/awk/cou-021.awk @@ -0,0 +1 @@ +$4 == "Asia" { print $1, 1000 * $2; } diff --git a/ase/test/awk/cou-021.out b/ase/test/awk/cou-021.out new file mode 100644 index 00000000..7dfe4dad --- /dev/null +++ b/ase/test/awk/cou-021.out @@ -0,0 +1,8 @@ +($4 == "Asia") { + print $1,(1000 * $2); +} + +USSR 8649000 +China 3705000 +India 1267000 +Japan 144000 diff --git a/ase/test/awk/cou-022.awk b/ase/test/awk/cou-022.awk new file mode 100644 index 00000000..7767c865 --- /dev/null +++ b/ase/test/awk/cou-022.awk @@ -0,0 +1,6 @@ +#BEGIN { FS = "\t"; OFS = "\t"; } +BEGIN { FS = OFS = "\t"; } +$4 == "North America" { $4 = "NA"; } +$4 == "South America" { $4 = "SA"; } + { print; } + diff --git a/ase/test/awk/cou-022.out b/ase/test/awk/cou-022.out new file mode 100644 index 00000000..b415ed26 --- /dev/null +++ b/ase/test/awk/cou-022.out @@ -0,0 +1,27 @@ +BEGIN { + FS = OFS = " "; +} + +($4 == "North America") { + $4 = "NA"; +} + +($4 == "South America") { + $4 = "SA"; +} + +{ + print; +} + +USSR 8649 275 Asia +Canada 3852 25 NA +China 3705 1032 Asia +USA 3615 237 NA +Brazil 3286 134 SA +India 1267 746 Asia +Mexico 762 78 NA +France 211 55 Europe +Japan 144 120 Asia +Germany 96 61 Europe +England 94 56 Europe diff --git a/ase/test/awk/cou-023.awk b/ase/test/awk/cou-023.awk new file mode 100644 index 00000000..540b65c6 --- /dev/null +++ b/ase/test/awk/cou-023.awk @@ -0,0 +1,2 @@ +BEGIN { FS = OFS = "\t"; } + { $5 = 1000 * $3 / $2; print; } diff --git a/ase/test/awk/cou-023.out b/ase/test/awk/cou-023.out new file mode 100644 index 00000000..853ae1e1 --- /dev/null +++ b/ase/test/awk/cou-023.out @@ -0,0 +1,20 @@ +BEGIN { + FS = OFS = " "; +} + +{ + $5 = ((1000 * $3) / $2); + print; +} + +USSR 8649 275 Asia 31.7956 +Canada 3852 25 North America 6.49013 +China 3705 1032 Asia 278.543 +USA 3615 237 North America 65.5602 +Brazil 3286 134 South America 40.7791 +India 1267 746 Asia 588.792 +Mexico 762 78 North America 102.362 +France 211 55 Europe 260.664 +Japan 144 120 Asia 833.333 +Germany 96 61 Europe 635.417 +England 94 56 Europe 595.745 diff --git a/ase/test/awk/cou-024.awk b/ase/test/awk/cou-024.awk new file mode 100644 index 00000000..a10bce8f --- /dev/null +++ b/ase/test/awk/cou-024.awk @@ -0,0 +1,4 @@ +$4 == "Asia" { pop = pop + $3; n = n + 1; } +END { print "Total population of the", n, + "Asian countries is", pop, "million."; + } diff --git a/ase/test/awk/cou-024.out b/ase/test/awk/cou-024.out new file mode 100644 index 00000000..98aae883 --- /dev/null +++ b/ase/test/awk/cou-024.out @@ -0,0 +1,9 @@ +($4 == "Asia") { + pop = (pop + $3); + n = (n + 1); +} + +END { + print "Total population of the",n,"Asian countries is",pop,"million."; +} +Total population of the 4 Asian countries is 2173 million. diff --git a/ase/test/awk/cou-025.awk b/ase/test/awk/cou-025.awk new file mode 100644 index 00000000..a0eb9ca1 --- /dev/null +++ b/ase/test/awk/cou-025.awk @@ -0,0 +1,6 @@ +/Asia/ { pop["Asia"] += $3; } +/Europe/ { pop["Europe"] += $3; } +END { print "Asian population is", pop["Asia"], "million."; + print "European population is", pop["Europe"], "million."; + } + diff --git a/ase/test/awk/cou-025.out b/ase/test/awk/cou-025.out new file mode 100644 index 00000000..503ccd18 --- /dev/null +++ b/ase/test/awk/cou-025.out @@ -0,0 +1,14 @@ +/Asia/ { + pop["Asia"] += $3; +} + +/Europe/ { + pop["Europe"] += $3; +} + +END { + print "Asian population is",pop["Asia"],"million."; + print "European population is",pop["Europe"],"million."; +} +Asian population is 2173 million. +European population is 172 million. diff --git a/ase/test/awk/cou-026.awk b/ase/test/awk/cou-026.awk new file mode 100644 index 00000000..0597c6d9 --- /dev/null +++ b/ase/test/awk/cou-026.awk @@ -0,0 +1,3 @@ +BEGIN { FS = "\t"; } + { pop[$4] += $3; } +END { for (name in pop) print name, pop[name]; } diff --git a/ase/test/awk/cou-026.out b/ase/test/awk/cou-026.out new file mode 100644 index 00000000..6d05a7e1 --- /dev/null +++ b/ase/test/awk/cou-026.out @@ -0,0 +1,16 @@ +BEGIN { + FS = " "; +} + +{ + pop[$4] += $3; +} + +END { + for (name in pop) + print name,pop[name]; +} +Europe 172 +South America 134 +North America 340 +Asia 2173 diff --git a/ase/test/awk/cou-027.awk b/ase/test/awk/cou-027.awk new file mode 100644 index 00000000..f8464883 --- /dev/null +++ b/ase/test/awk/cou-027.awk @@ -0,0 +1,5 @@ +BEGIN { FS = "\t"; } + { pop[$4] += $3; } +END { for (c in pop) + printf ("%15s\t%6d\n", c, pop[c]) | "sort -t'\t' +1rn"; + } diff --git a/ase/test/awk/cou-027.out b/ase/test/awk/cou-027.out new file mode 100644 index 00000000..57a4ae02 --- /dev/null +++ b/ase/test/awk/cou-027.out @@ -0,0 +1,16 @@ +BEGIN { + FS = " "; +} + +{ + pop[$4] += $3; +} + +END { + for (c in pop) + printf ("%15s %6d\n",c,pop[c]) | "sort -t' ' +1rn"; +} + Asia 2173 + North America 340 + Europe 172 + South America 134 diff --git a/ase/test/awk/cou-en.data b/ase/test/awk/cou-en.data new file mode 100644 index 00000000..e973031b --- /dev/null +++ b/ase/test/awk/cou-en.data @@ -0,0 +1,11 @@ +USSR 8649 275 Asia +Canada 3852 25 North America +China 3705 1032 Asia +USA 3615 237 North America +Brazil 3286 134 South America +India 1267 746 Asia +Mexico 762 78 North America +France 211 55 Europe +Japan 144 120 Asia +Germany 96 61 Europe +England 94 56 Europe diff --git a/ase/test/awk/crash01.awk b/ase/test/awk/crash01.awk new file mode 100644 index 00000000..8906db6f --- /dev/null +++ b/ase/test/awk/crash01.awk @@ -0,0 +1 @@ +BEGIN { CONVFMT="%s"; printf ("%s\n", 10.34); } diff --git a/ase/test/awk/crash02.awk b/ase/test/awk/crash02.awk new file mode 100644 index 00000000..ae49a9b0 --- /dev/null +++ b/ase/test/awk/crash02.awk @@ -0,0 +1,9 @@ +BEGIN { + #CONVFMT="%s"; + #CONVFMT="%*.*s"; + #CONVFMT="%*.*f"; + printf "[[[[[%s]]]]\n", sprintf ("abc %s abc", sprintf ("def %s %s", sprintf ("%s %s %s", "xyz", 1.2342, "xyz"), sprintf ("ttt %s tttt", 123.12))); + + printf "[[[[%s]]]]\n", sprintf ("ttt %s tttt", 123.12); +} + diff --git a/ase/test/awk/crash04.awk b/ase/test/awk/crash04.awk new file mode 100644 index 00000000..12821825 --- /dev/null +++ b/ase/test/awk/crash04.awk @@ -0,0 +1,17 @@ +BEGIN { + + {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{ + {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{ + {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{ + {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{ + {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{ + + abc = 20; + }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} + }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} + }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} + }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} + }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} + +} + diff --git a/ase/test/awk/crash05.awk b/ase/test/awk/crash05.awk new file mode 100644 index 00000000..f663bc56 --- /dev/null +++ b/ase/test/awk/crash05.awk @@ -0,0 +1,5 @@ +BEGIN { + a = (((((10+20))))); + b = (((((((((((((((((((10+20))))))))))))))))))); + c = ((((((((((((((((((((((((((((10 + 20)))))))))))))))))))))))))))); +} diff --git a/ase/test/awk/crash08.awk b/ase/test/awk/crash08.awk new file mode 100644 index 00000000..130cf3c8 --- /dev/null +++ b/ase/test/awk/crash08.awk @@ -0,0 +1,23 @@ +function a() +{ + print "aaaa"; + a(); +} + +BEGIN { + a = (b = 20); + print a; print b; for(i=j=1; i< 10; i++) print i, j; + + a += b += 20; + print a; print b; for(i=j=1; i< 10; i++) print i, j; + + j = (a < 20)? k = 20: c = 30; + print (a < 20)? k = 20: c = 30; + print "j=" j; + print "k=" k; + print "c=" c; + + a(); +} + + diff --git a/ase/test/awk/descrip.mms b/ase/test/awk/descrip.mms new file mode 100644 index 00000000..3c7337f9 --- /dev/null +++ b/ase/test/awk/descrip.mms @@ -0,0 +1,13 @@ +# +# OpenVMS MMS/MMK +# + +objects = awk.obj + +CFLAGS = /include="../../.." +#CFLAGS = /pointer_size=long /include="../../.." + +aseawk.exe : $(objects) + link /executable=aseawk.exe $(objects),[-.-.awk]aseawk/library,[-.-.utl]aseutl/library + +awk.obj depends_on awk.c diff --git a/ase/test/awk/emp-001.awk b/ase/test/awk/emp-001.awk new file mode 100644 index 00000000..83354291 --- /dev/null +++ b/ase/test/awk/emp-001.awk @@ -0,0 +1 @@ +$3 > 0 { print $1, $2 * $3; } diff --git a/ase/test/awk/emp-001.out b/ase/test/awk/emp-001.out new file mode 100644 index 00000000..9d894bb6 --- /dev/null +++ b/ase/test/awk/emp-001.out @@ -0,0 +1,8 @@ +($3 > 0) { + print $1,($2 * $3); +} + +Kathy 40 +Mark 100 +Mary 121 +Susie 76.5 diff --git a/ase/test/awk/emp-002.awk b/ase/test/awk/emp-002.awk new file mode 100644 index 00000000..06607ada --- /dev/null +++ b/ase/test/awk/emp-002.awk @@ -0,0 +1 @@ +$3 == 0 { print $1; } diff --git a/ase/test/awk/emp-002.out b/ase/test/awk/emp-002.out new file mode 100644 index 00000000..8f669f7e --- /dev/null +++ b/ase/test/awk/emp-002.out @@ -0,0 +1,6 @@ +($3 == 0) { + print $1; +} + +Beth +Dan diff --git a/ase/test/awk/emp-003.awk b/ase/test/awk/emp-003.awk new file mode 100644 index 00000000..fcfbe32c --- /dev/null +++ b/ase/test/awk/emp-003.awk @@ -0,0 +1 @@ +{ print NF, $1, $NF; } diff --git a/ase/test/awk/emp-003.out b/ase/test/awk/emp-003.out new file mode 100644 index 00000000..8c37c7e9 --- /dev/null +++ b/ase/test/awk/emp-003.out @@ -0,0 +1,10 @@ +{ + print NF,$1,$NF; +} + +3 Beth 0 +3 Dan 0 +3 Kathy 10 +3 Mark 20 +3 Mary 22 +3 Susie 18 diff --git a/ase/test/awk/emp-004.awk b/ase/test/awk/emp-004.awk new file mode 100644 index 00000000..30bc76fb --- /dev/null +++ b/ase/test/awk/emp-004.awk @@ -0,0 +1 @@ +{ print NR, $0; } diff --git a/ase/test/awk/emp-004.out b/ase/test/awk/emp-004.out new file mode 100644 index 00000000..5bb7e8af --- /dev/null +++ b/ase/test/awk/emp-004.out @@ -0,0 +1,10 @@ +{ + print NR,$0; +} + +1 Beth 4.00 0 +2 Dan 3.74 0 +3 Kathy 4.00 10 +4 Mark 5.00 20 +5 Mary 5.50 22 +6 Susie 4.25 18 diff --git a/ase/test/awk/emp-005.awk b/ase/test/awk/emp-005.awk new file mode 100644 index 00000000..9ed5d9bc --- /dev/null +++ b/ase/test/awk/emp-005.awk @@ -0,0 +1 @@ +{ print "total pay for", $1, "is", $2 * $3; } diff --git a/ase/test/awk/emp-005.out b/ase/test/awk/emp-005.out new file mode 100644 index 00000000..fc0c9e81 --- /dev/null +++ b/ase/test/awk/emp-005.out @@ -0,0 +1,10 @@ +{ + print "total pay for",$1,"is",($2 * $3); +} + +total pay for Beth is 0 +total pay for Dan is 0 +total pay for Kathy is 40 +total pay for Mark is 100 +total pay for Mary is 121 +total pay for Susie is 76.5 diff --git a/ase/test/awk/emp-006.awk b/ase/test/awk/emp-006.awk new file mode 100644 index 00000000..035b20b5 --- /dev/null +++ b/ase/test/awk/emp-006.awk @@ -0,0 +1 @@ +{ printf ("total pay for %s is $%.2f\n", $1, $2 * $3); } diff --git a/ase/test/awk/emp-006.out b/ase/test/awk/emp-006.out new file mode 100644 index 00000000..3ba88ebb --- /dev/null +++ b/ase/test/awk/emp-006.out @@ -0,0 +1,10 @@ +{ + printf ("total pay for %s is $%.2f\n",$1,($2 * $3)); +} + +total pay for Beth is $0.00 +total pay for Dan is $0.00 +total pay for Kathy is $40.00 +total pay for Mark is $100.00 +total pay for Mary is $121.00 +total pay for Susie is $76.50 diff --git a/ase/test/awk/emp-007.awk b/ase/test/awk/emp-007.awk new file mode 100644 index 00000000..4c7a7b63 --- /dev/null +++ b/ase/test/awk/emp-007.awk @@ -0,0 +1 @@ +{ printf ("%-8s $%6.2f\n", $1, $2 * $3); } diff --git a/ase/test/awk/emp-007.out b/ase/test/awk/emp-007.out new file mode 100644 index 00000000..b0603f79 --- /dev/null +++ b/ase/test/awk/emp-007.out @@ -0,0 +1,10 @@ +{ + printf ("%-8s $%6.2f\n",$1,($2 * $3)); +} + +Beth $ 0.00 +Dan $ 0.00 +Kathy $ 40.00 +Mark $100.00 +Mary $121.00 +Susie $ 76.50 diff --git a/ase/test/awk/emp-008.awk b/ase/test/awk/emp-008.awk new file mode 100644 index 00000000..73c4bd78 --- /dev/null +++ b/ase/test/awk/emp-008.awk @@ -0,0 +1 @@ +$2 >= 5 diff --git a/ase/test/awk/emp-008.out b/ase/test/awk/emp-008.out new file mode 100644 index 00000000..019e78b7 --- /dev/null +++ b/ase/test/awk/emp-008.out @@ -0,0 +1,4 @@ +($2 >= 5) + +Mark 5.00 20 +Mary 5.50 22 diff --git a/ase/test/awk/emp-009.awk b/ase/test/awk/emp-009.awk new file mode 100644 index 00000000..a8bd5dff --- /dev/null +++ b/ase/test/awk/emp-009.awk @@ -0,0 +1 @@ +$2 * $3 > 50 { printf ("$%.2f for %s\n", $2 * $3, $1); } diff --git a/ase/test/awk/emp-009.out b/ase/test/awk/emp-009.out new file mode 100644 index 00000000..76deb332 --- /dev/null +++ b/ase/test/awk/emp-009.out @@ -0,0 +1,7 @@ +(($2 * $3) > 50) { + printf ("$%.2f for %s\n",($2 * $3),$1); +} + +$100.00 for Mark +$121.00 for Mary +$76.50 for Susie diff --git a/ase/test/awk/emp-010.awk b/ase/test/awk/emp-010.awk new file mode 100644 index 00000000..ec5dc961 --- /dev/null +++ b/ase/test/awk/emp-010.awk @@ -0,0 +1 @@ +$1 == "Susie" diff --git a/ase/test/awk/emp-010.out b/ase/test/awk/emp-010.out new file mode 100644 index 00000000..eaa876ae --- /dev/null +++ b/ase/test/awk/emp-010.out @@ -0,0 +1,3 @@ +($1 == "Susie") + +Susie 4.25 18 diff --git a/ase/test/awk/emp-011.awk b/ase/test/awk/emp-011.awk new file mode 100644 index 00000000..a37ed825 --- /dev/null +++ b/ase/test/awk/emp-011.awk @@ -0,0 +1 @@ +/Susie/ diff --git a/ase/test/awk/emp-011.out b/ase/test/awk/emp-011.out new file mode 100644 index 00000000..c0d44782 --- /dev/null +++ b/ase/test/awk/emp-011.out @@ -0,0 +1,3 @@ +/Susie/ + +Susie 4.25 18 diff --git a/ase/test/awk/emp-012.awk b/ase/test/awk/emp-012.awk new file mode 100644 index 00000000..c5c84049 --- /dev/null +++ b/ase/test/awk/emp-012.awk @@ -0,0 +1 @@ +$2 >= 4 || $3 >= 20 diff --git a/ase/test/awk/emp-012.out b/ase/test/awk/emp-012.out new file mode 100644 index 00000000..73946169 --- /dev/null +++ b/ase/test/awk/emp-012.out @@ -0,0 +1,7 @@ +(($2 >= 4) || ($3 >= 20)) + +Beth 4.00 0 +Kathy 4.00 10 +Mark 5.00 20 +Mary 5.50 22 +Susie 4.25 18 diff --git a/ase/test/awk/emp-013.awk b/ase/test/awk/emp-013.awk new file mode 100644 index 00000000..83a08fbd --- /dev/null +++ b/ase/test/awk/emp-013.awk @@ -0,0 +1,2 @@ +$2 >= 4 +$3 >= 20 diff --git a/ase/test/awk/emp-013.out b/ase/test/awk/emp-013.out new file mode 100644 index 00000000..0b69688a --- /dev/null +++ b/ase/test/awk/emp-013.out @@ -0,0 +1,11 @@ +($2 >= 4) + +($3 >= 20) + +Beth 4.00 0 +Kathy 4.00 10 +Mark 5.00 20 +Mark 5.00 20 +Mary 5.50 22 +Mary 5.50 22 +Susie 4.25 18 diff --git a/ase/test/awk/emp-014.awk b/ase/test/awk/emp-014.awk new file mode 100644 index 00000000..a210459a --- /dev/null +++ b/ase/test/awk/emp-014.awk @@ -0,0 +1 @@ +!($2 < 4 && $3 < 20) diff --git a/ase/test/awk/emp-014.out b/ase/test/awk/emp-014.out new file mode 100644 index 00000000..cde00a5a --- /dev/null +++ b/ase/test/awk/emp-014.out @@ -0,0 +1,7 @@ +(!((($2 < 4) && ($3 < 20)))) + +Beth 4.00 0 +Kathy 4.00 10 +Mark 5.00 20 +Mary 5.50 22 +Susie 4.25 18 diff --git a/ase/test/awk/emp-015.awk b/ase/test/awk/emp-015.awk new file mode 100644 index 00000000..81d81580 --- /dev/null +++ b/ase/test/awk/emp-015.awk @@ -0,0 +1,5 @@ +NF != 3 { print $0, "number of fields is not equal to 3"; } +$2 < 3.35 { print $0, "rate is below minimum wage"; } +$2 > 10 { print $0, "rate exceeds $10 per hour"; } +$3 < 0 { print $0, "negative hours worked"; } +$3 > 60 { print $0, "too many hours worked"; } diff --git a/ase/test/awk/emp-015.out b/ase/test/awk/emp-015.out new file mode 100644 index 00000000..3c696f7e --- /dev/null +++ b/ase/test/awk/emp-015.out @@ -0,0 +1,20 @@ +(NF != 3) { + print $0,"number of fields is not equal to 3"; +} + +($2 < 3.35) { + print $0,"rate is below minimum wage"; +} + +($2 > 10) { + print $0,"rate exceeds $10 per hour"; +} + +($3 < 0) { + print $0,"negative hours worked"; +} + +($3 > 60) { + print $0,"too many hours worked"; +} + diff --git a/ase/test/awk/emp-016.awk b/ase/test/awk/emp-016.awk new file mode 100644 index 00000000..22e0700e --- /dev/null +++ b/ase/test/awk/emp-016.awk @@ -0,0 +1,2 @@ +BEGIN { print "NAME RATE HOURS"; print ""; } + { print; } diff --git a/ase/test/awk/emp-016.out b/ase/test/awk/emp-016.out new file mode 100644 index 00000000..46f95c08 --- /dev/null +++ b/ase/test/awk/emp-016.out @@ -0,0 +1,17 @@ +BEGIN { + print "NAME RATE HOURS"; + print ""; +} + +{ + print; +} + +NAME RATE HOURS + +Beth 4.00 0 +Dan 3.74 0 +Kathy 4.00 10 +Mark 5.00 20 +Mary 5.50 22 +Susie 4.25 18 diff --git a/ase/test/awk/emp-017.awk b/ase/test/awk/emp-017.awk new file mode 100644 index 00000000..69408a07 --- /dev/null +++ b/ase/test/awk/emp-017.awk @@ -0,0 +1,2 @@ +$3 > 15 { emp = emp + 1; } +END { print emp, "employees worked more than 15 hours"; } diff --git a/ase/test/awk/emp-017.out b/ase/test/awk/emp-017.out new file mode 100644 index 00000000..e7e5ac24 --- /dev/null +++ b/ase/test/awk/emp-017.out @@ -0,0 +1,8 @@ +($3 > 15) { + emp = (emp + 1); +} + +END { + print emp,"employees worked more than 15 hours"; +} +3 employees worked more than 15 hours diff --git a/ase/test/awk/emp-018.awk b/ase/test/awk/emp-018.awk new file mode 100644 index 00000000..dd952bb8 --- /dev/null +++ b/ase/test/awk/emp-018.awk @@ -0,0 +1 @@ +END { print NR, "employees"; } diff --git a/ase/test/awk/emp-018.out b/ase/test/awk/emp-018.out new file mode 100644 index 00000000..fd8fa49f --- /dev/null +++ b/ase/test/awk/emp-018.out @@ -0,0 +1,4 @@ +END { + print NR,"employees"; +} +6 employees diff --git a/ase/test/awk/emp-019.awk b/ase/test/awk/emp-019.awk new file mode 100644 index 00000000..3b63999b --- /dev/null +++ b/ase/test/awk/emp-019.awk @@ -0,0 +1,5 @@ + { pay = pay + $2 * $3; } +END { print NR, "employees"; + print "total pay is", pay; + print "average pay is", pay/NR; +} diff --git a/ase/test/awk/emp-019.out b/ase/test/awk/emp-019.out new file mode 100644 index 00000000..3126ff30 --- /dev/null +++ b/ase/test/awk/emp-019.out @@ -0,0 +1,12 @@ +{ + pay = (pay + ($2 * $3)); +} + +END { + print NR,"employees"; + print "total pay is",pay; + print "average pay is",(pay / NR); +} +6 employees +total pay is 337.5 +average pay is 56.25 diff --git a/ase/test/awk/emp-020.awk b/ase/test/awk/emp-020.awk new file mode 100644 index 00000000..e0e1b1aa --- /dev/null +++ b/ase/test/awk/emp-020.awk @@ -0,0 +1,2 @@ +$2 > maxrate { maxrate = $2; maxemp = $1; } +END { print "highest hourly rage:", maxrate, "for", maxemp; } diff --git a/ase/test/awk/emp-020.out b/ase/test/awk/emp-020.out new file mode 100644 index 00000000..5f2a54f3 --- /dev/null +++ b/ase/test/awk/emp-020.out @@ -0,0 +1,9 @@ +($2 > maxrate) { + maxrate = $2; + maxemp = $1; +} + +END { + print "highest hourly rage:",maxrate,"for",maxemp; +} +highest hourly rage: 5.50 for Mary diff --git a/ase/test/awk/emp-021.awk b/ase/test/awk/emp-021.awk new file mode 100644 index 00000000..6b112dff --- /dev/null +++ b/ase/test/awk/emp-021.awk @@ -0,0 +1,2 @@ + { names = names $1 " "; } +END { print names; } diff --git a/ase/test/awk/emp-021.out b/ase/test/awk/emp-021.out new file mode 100644 index 00000000..676a8bdc --- /dev/null +++ b/ase/test/awk/emp-021.out @@ -0,0 +1,8 @@ +{ + names = ((names $1) " "); +} + +END { + print names; +} +Beth Dan Kathy Mark Mary Susie diff --git a/ase/test/awk/emp-022.awk b/ase/test/awk/emp-022.awk new file mode 100644 index 00000000..414d0979 --- /dev/null +++ b/ase/test/awk/emp-022.awk @@ -0,0 +1,2 @@ + { last = $0; } +END { print last; } diff --git a/ase/test/awk/emp-022.out b/ase/test/awk/emp-022.out new file mode 100644 index 00000000..9e0bc46c --- /dev/null +++ b/ase/test/awk/emp-022.out @@ -0,0 +1,8 @@ +{ + last = $0; +} + +END { + print last; +} +Susie 4.25 18 diff --git a/ase/test/awk/emp-023.awk b/ase/test/awk/emp-023.awk new file mode 100644 index 00000000..fe25e4f5 --- /dev/null +++ b/ase/test/awk/emp-023.awk @@ -0,0 +1 @@ +{ print $1, length($1); } diff --git a/ase/test/awk/emp-023.out b/ase/test/awk/emp-023.out new file mode 100644 index 00000000..0852ccaa --- /dev/null +++ b/ase/test/awk/emp-023.out @@ -0,0 +1,10 @@ +{ + print $1,length ($1); +} + +Beth 4 +Dan 3 +Kathy 5 +Mark 4 +Mary 4 +Susie 5 diff --git a/ase/test/awk/emp-024.awk b/ase/test/awk/emp-024.awk new file mode 100644 index 00000000..fb493296 --- /dev/null +++ b/ase/test/awk/emp-024.awk @@ -0,0 +1,4 @@ + { nc = nc + length($0) + 1; + nw = nw + NF; + } +END { print NR, "lines,", nw, "words,", nc, "characters"; } diff --git a/ase/test/awk/emp-024.out b/ase/test/awk/emp-024.out new file mode 100644 index 00000000..a1af1cfb --- /dev/null +++ b/ase/test/awk/emp-024.out @@ -0,0 +1,9 @@ +{ + nc = ((nc + length ($0)) + 1); + nw = (nw + NF); +} + +END { + print NR,"lines,",nw,"words,",nc,"characters"; +} +6 lines, 18 words, 77 characters diff --git a/ase/test/awk/emp-025.awk b/ase/test/awk/emp-025.awk new file mode 100644 index 00000000..72922285 --- /dev/null +++ b/ase/test/awk/emp-025.awk @@ -0,0 +1,7 @@ +$2 > 6 { n = n + 1; pay = pay + $2 * $3; } +END { if (n > 0) + print n, "employees, total pay is", pay, + "average pay is", pay/n; + else + print "no employees are paid more than $6/hour"; + } diff --git a/ase/test/awk/emp-025.out b/ase/test/awk/emp-025.out new file mode 100644 index 00000000..69b10629 --- /dev/null +++ b/ase/test/awk/emp-025.out @@ -0,0 +1,12 @@ +($2 > 6) { + n = (n + 1); + pay = (pay + ($2 * $3)); +} + +END { + if ((n > 0)) + print n,"employees, total pay is",pay,"average pay is",(pay / n); + else + print "no employees are paid more than $6/hour"; +} +no employees are paid more than $6/hour diff --git a/ase/test/awk/emp-026.awk b/ase/test/awk/emp-026.awk new file mode 100644 index 00000000..1053f105 --- /dev/null +++ b/ase/test/awk/emp-026.awk @@ -0,0 +1,12 @@ +{ + line[NR] = $0; +} + +END { + i = NR; + while (i > 0) + { + print line[i]; + i = i - 1; + } +} diff --git a/ase/test/awk/emp-026.out b/ase/test/awk/emp-026.out new file mode 100644 index 00000000..2ac7bf5a --- /dev/null +++ b/ase/test/awk/emp-026.out @@ -0,0 +1,18 @@ +{ + line[NR] = $0; +} + +END { + i = NR; + while ((i > 0)) + { + print line[i]; + i = (i - 1); + } +} +Susie 4.25 18 +Mary 5.50 22 +Mark 5.00 20 +Kathy 4.00 10 +Dan 3.74 0 +Beth 4.00 0 diff --git a/ase/test/awk/emp-027.awk b/ase/test/awk/emp-027.awk new file mode 100644 index 00000000..56a40f23 --- /dev/null +++ b/ase/test/awk/emp-027.awk @@ -0,0 +1,8 @@ +{ + line[NR] = $0; +} + +END { + i = NR; + for (i = NR; i > 0; i = i - 1) print line[i]; +} diff --git a/ase/test/awk/emp-027.out b/ase/test/awk/emp-027.out new file mode 100644 index 00000000..a1601e46 --- /dev/null +++ b/ase/test/awk/emp-027.out @@ -0,0 +1,15 @@ +{ + line[NR] = $0; +} + +END { + i = NR; + for (i = NR; (i > 0); i = (i - 1)) + print line[i]; +} +Susie 4.25 18 +Mary 5.50 22 +Mark 5.00 20 +Kathy 4.00 10 +Dan 3.74 0 +Beth 4.00 0 diff --git a/ase/test/awk/emp-en.data b/ase/test/awk/emp-en.data new file mode 100644 index 00000000..029863ff --- /dev/null +++ b/ase/test/awk/emp-en.data @@ -0,0 +1,6 @@ +Beth 4.00 0 +Dan 3.74 0 +Kathy 4.00 10 +Mark 5.00 20 +Mary 5.50 22 +Susie 4.25 18 diff --git a/ase/test/awk/emp-ko.data b/ase/test/awk/emp-ko.data new file mode 100644 index 00000000..54f11456 --- /dev/null +++ b/ase/test/awk/emp-ko.data @@ -0,0 +1,6 @@ +베쓰 4.00 0 +단 3.74 0 +케이티 4.00 10 +마크 5.00 20 +메리 5.50 22 +수지 4.25 18 diff --git a/ase/test/awk/err-001.awk b/ase/test/awk/err-001.awk new file mode 100644 index 0000000000000000000000000000000000000000..d7800ed57bd78ddbf56db1858c1b2268f853e21b GIT binary patch literal 10 RcmdN7E-lVX)#qa10ss)}0(<}f literal 0 HcmV?d00001 diff --git a/ase/test/awk/err-001.out b/ase/test/awk/err-001.out new file mode 100644 index 00000000..19507db9 --- /dev/null +++ b/ase/test/awk/err-001.out @@ -0,0 +1 @@ +PARSE ERROR: CODE [30] LINE [2] invalid character '' diff --git a/ase/test/awk/err-002.awk b/ase/test/awk/err-002.awk new file mode 100644 index 00000000..0518ca92 --- /dev/null +++ b/ase/test/awk/err-002.awk @@ -0,0 +1,3 @@ +BEGIN { + ARGC = 39; +} diff --git a/ase/test/awk/err-002.out b/ase/test/awk/err-002.out new file mode 100644 index 00000000..eadc4818 --- /dev/null +++ b/ase/test/awk/err-002.out @@ -0,0 +1,4 @@ +BEGIN { + ARGC = 39; +} + diff --git a/ase/test/awk/err-003.awk b/ase/test/awk/err-003.awk new file mode 100644 index 00000000..b86a5e5b --- /dev/null +++ b/ase/test/awk/err-003.awk @@ -0,0 +1,6 @@ +global abc; + +BEGIN { + abc[20] = "abc"; + abc = 10; +} diff --git a/ase/test/awk/err-003.out b/ase/test/awk/err-003.out new file mode 100644 index 00000000..44b68fe2 --- /dev/null +++ b/ase/test/awk/err-003.out @@ -0,0 +1,8 @@ +global abc; + +BEGIN { + abc[20] = "abc"; + abc = 10; +} + +RUN ERROR: CODE [94] LINE [5] map 'abc' not assignable with a scalar diff --git a/ase/test/awk/err-004.awk b/ase/test/awk/err-004.awk new file mode 100644 index 00000000..78a27344 --- /dev/null +++ b/ase/test/awk/err-004.awk @@ -0,0 +1,3 @@ +BEGIN { + delete ARGC; +} diff --git a/ase/test/awk/err-004.out b/ase/test/awk/err-004.out new file mode 100644 index 00000000..310c82bf --- /dev/null +++ b/ase/test/awk/err-004.out @@ -0,0 +1,5 @@ +BEGIN { + delete ARGC; +} + +RUN ERROR: CODE [86] LINE [2] variable 'ARGC' not deletable diff --git a/ase/test/awk/err-005.awk b/ase/test/awk/err-005.awk new file mode 100644 index 00000000..b6a2ccb9 --- /dev/null +++ b/ase/test/awk/err-005.awk @@ -0,0 +1,4 @@ +BEGIN { + iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiix = 20; + delete iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiix ; +} diff --git a/ase/test/awk/err-005.out b/ase/test/awk/err-005.out new file mode 100644 index 00000000..52eec318 --- /dev/null +++ b/ase/test/awk/err-005.out @@ -0,0 +1,6 @@ +BEGIN { + iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiix = 20; + delete iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiix; +} + +RUN ERROR: CODE [86] LINE [3] variable 'iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii...' not deletable diff --git a/ase/test/awk/err-006.awk b/ase/test/awk/err-006.awk new file mode 100644 index 00000000..e184c15c --- /dev/null +++ b/ase/test/awk/err-006.awk @@ -0,0 +1,3 @@ +BEGIN { + helpxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxhelphelp (); +} diff --git a/ase/test/awk/err-006.out b/ase/test/awk/err-006.out new file mode 100644 index 00000000..1bbe4bd9 --- /dev/null +++ b/ase/test/awk/err-006.out @@ -0,0 +1,5 @@ +BEGIN { + helpxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxhelphelp (); +} + +RUN ERROR: CODE [84] LINE [2] function 'helpxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxhel...' not found diff --git a/ase/test/awk/err-007.awk b/ase/test/awk/err-007.awk new file mode 100644 index 00000000..875970ee --- /dev/null +++ b/ase/test/awk/err-007.awk @@ -0,0 +1,4 @@ + +function substr () +{ +} diff --git a/ase/test/awk/err-007.out b/ase/test/awk/err-007.out new file mode 100644 index 00000000..832e41f8 --- /dev/null +++ b/ase/test/awk/err-007.out @@ -0,0 +1 @@ +PARSE ERROR: CODE [55] LINE [2] built-in function 'substr' redefined diff --git a/ase/test/awk/err-008.awk b/ase/test/awk/err-008.awk new file mode 100644 index 00000000..36d700f5 --- /dev/null +++ b/ase/test/awk/err-008.awk @@ -0,0 +1,6 @@ + +BEGIN { + local substr; + substr = 20; +} + diff --git a/ase/test/awk/err-008.out b/ase/test/awk/err-008.out new file mode 100644 index 00000000..0730f29c --- /dev/null +++ b/ase/test/awk/err-008.out @@ -0,0 +1 @@ +PARSE ERROR: CODE [55] LINE [3] built-in function 'substr' redefined diff --git a/ase/test/awk/err-009.awk b/ase/test/awk/err-009.awk new file mode 100644 index 00000000..b90f55fb --- /dev/null +++ b/ase/test/awk/err-009.awk @@ -0,0 +1,19 @@ + +func abc () +{ + + local x; + print x = 20; + + { + local abc; + + abc = 30; + print abc; + abc (); + } +} + +BEGIN { + abc (); +} diff --git a/ase/test/awk/err-009.out b/ase/test/awk/err-009.out new file mode 100644 index 00000000..78591512 --- /dev/null +++ b/ase/test/awk/err-009.out @@ -0,0 +1 @@ +PARSE ERROR: CODE [56] LINE [9] function 'abc' redefined diff --git a/ase/test/awk/err-010.awk b/ase/test/awk/err-010.awk new file mode 100644 index 00000000..e59a23f3 --- /dev/null +++ b/ase/test/awk/err-010.awk @@ -0,0 +1,15 @@ + +global abc; + +func abc () +{ + local abc; + + abc = 20; + print abc; + abc (); +} + +BEGIN { + abc (); +} diff --git a/ase/test/awk/err-010.out b/ase/test/awk/err-010.out new file mode 100644 index 00000000..3d50b139 --- /dev/null +++ b/ase/test/awk/err-010.out @@ -0,0 +1 @@ +PARSE ERROR: CODE [57] LINE [4] global variable 'abc' redefined diff --git a/ase/test/awk/err-011.awk b/ase/test/awk/err-011.awk new file mode 100644 index 00000000..d8dd77ea --- /dev/null +++ b/ase/test/awk/err-011.awk @@ -0,0 +1,13 @@ + +func abc (x) +{ + local x; + + x = 20; + print x; + abc (); +} + +BEGIN { + abc (); +} diff --git a/ase/test/awk/err-011.out b/ase/test/awk/err-011.out new file mode 100644 index 00000000..1fe5f6be --- /dev/null +++ b/ase/test/awk/err-011.out @@ -0,0 +1 @@ +PARSE ERROR: CODE [58] LINE [4] parameter 'x' redefined diff --git a/ase/test/awk/err-012.awk b/ase/test/awk/err-012.awk new file mode 100644 index 00000000..3382d7ed --- /dev/null +++ b/ase/test/awk/err-012.awk @@ -0,0 +1,14 @@ + +func abc () +{ + local j ; + + j = 20; + print j; + abc (); +} + +global abc; +BEGIN { + abc (); +} diff --git a/ase/test/awk/err-012.out b/ase/test/awk/err-012.out new file mode 100644 index 00000000..8cb73ecf --- /dev/null +++ b/ase/test/awk/err-012.out @@ -0,0 +1 @@ +PARSE ERROR: CODE [56] LINE [11] function 'abc' redefined diff --git a/ase/test/awk/err-013.awk b/ase/test/awk/err-013.awk new file mode 100644 index 00000000..2acc1f7d --- /dev/null +++ b/ase/test/awk/err-013.awk @@ -0,0 +1,3 @@ +func abc (abc) +{ +} diff --git a/ase/test/awk/err-013.out b/ase/test/awk/err-013.out new file mode 100644 index 00000000..bd715dfc --- /dev/null +++ b/ase/test/awk/err-013.out @@ -0,0 +1 @@ +PARSE ERROR: CODE [56] LINE [1] function 'abc' redefined diff --git a/ase/test/awk/err-014.awk b/ase/test/awk/err-014.awk new file mode 100644 index 00000000..4a273de7 --- /dev/null +++ b/ase/test/awk/err-014.awk @@ -0,0 +1,7 @@ +BEGIN { + local a; + + a = 21; + print a > 20? 1 2; +} + diff --git a/ase/test/awk/err-014.out b/ase/test/awk/err-014.out new file mode 100644 index 00000000..f87deed2 --- /dev/null +++ b/ase/test/awk/err-014.out @@ -0,0 +1 @@ +PARSE ERROR: CODE [42] LINE [5] a colon expected in place of ';' diff --git a/ase/test/awk/err-015.awk b/ase/test/awk/err-015.awk new file mode 100644 index 00000000..638cba0c --- /dev/null +++ b/ase/test/awk/err-015.awk @@ -0,0 +1,3 @@ +BEGIN { + substr = 20; +} diff --git a/ase/test/awk/err-015.out b/ase/test/awk/err-015.out new file mode 100644 index 00000000..ea5ebd12 --- /dev/null +++ b/ase/test/awk/err-015.out @@ -0,0 +1 @@ +PARSE ERROR: CODE [37] LINE [2] a left parenthesis expected in place of '=' diff --git a/ase/test/awk/err-016.awk b/ase/test/awk/err-016.awk new file mode 100644 index 00000000..28a3e1a8 --- /dev/null +++ b/ase/test/awk/err-016.awk @@ -0,0 +1,5 @@ + +BEGIN +{ + print "hello world"; +} diff --git a/ase/test/awk/err-016.out b/ase/test/awk/err-016.out new file mode 100644 index 00000000..83889449 --- /dev/null +++ b/ase/test/awk/err-016.out @@ -0,0 +1 @@ +PARSE ERROR: CODE [51] LINE [2] BEGIN not followed by a left bracket on the same line diff --git a/ase/test/awk/err-017.awk b/ase/test/awk/err-017.awk new file mode 100644 index 00000000..883b72c7 --- /dev/null +++ b/ase/test/awk/err-017.awk @@ -0,0 +1 @@ +func abc (+) {} diff --git a/ase/test/awk/err-017.out b/ase/test/awk/err-017.out new file mode 100644 index 00000000..8c10f2ef --- /dev/null +++ b/ase/test/awk/err-017.out @@ -0,0 +1 @@ +PARSE ERROR: CODE [62] LINE [1] '+' not a valid parameter name diff --git a/ase/test/awk/err-018.awk b/ase/test/awk/err-018.awk new file mode 100644 index 00000000..815e9826 --- /dev/null +++ b/ase/test/awk/err-018.awk @@ -0,0 +1,2 @@ +global + ; + diff --git a/ase/test/awk/err-018.out b/ase/test/awk/err-018.out new file mode 100644 index 00000000..22349b0c --- /dev/null +++ b/ase/test/awk/err-018.out @@ -0,0 +1 @@ +PARSE ERROR: CODE [63] LINE [1] '+' not a valid variable name diff --git a/ase/test/awk/err-019.awk b/ase/test/awk/err-019.awk new file mode 100644 index 00000000..2e2ab6ae --- /dev/null +++ b/ase/test/awk/err-019.awk @@ -0,0 +1,5 @@ +BEGIN { + + local +; + +} diff --git a/ase/test/awk/err-019.out b/ase/test/awk/err-019.out new file mode 100644 index 00000000..2d89bac0 --- /dev/null +++ b/ase/test/awk/err-019.out @@ -0,0 +1 @@ +PARSE ERROR: CODE [63] LINE [3] '+' not a valid variable name diff --git a/ase/test/awk/err-020.awk b/ase/test/awk/err-020.awk new file mode 100644 index 00000000..a0ababa4 --- /dev/null +++ b/ase/test/awk/err-020.awk @@ -0,0 +1,4 @@ +BEGIN { + print abc > "123\0abc"; +} + diff --git a/ase/test/awk/err-020.out b/ase/test/awk/err-020.out new file mode 100644 index 00000000..813ae97a --- /dev/null +++ b/ase/test/awk/err-020.out @@ -0,0 +1,5 @@ +BEGIN { + print abc > "123\0abc"; +} + +RUN ERROR: CODE [109] LINE [2] i/o name containing a null character diff --git a/ase/test/awk/err-021.awk b/ase/test/awk/err-021.awk new file mode 100644 index 00000000..5f3e5b13 --- /dev/null +++ b/ase/test/awk/err-021.awk @@ -0,0 +1,4 @@ +BEGIN { + xx = 20; + split ("a b c", xx); +} diff --git a/ase/test/awk/err-021.out b/ase/test/awk/err-021.out new file mode 100644 index 00000000..cf176329 --- /dev/null +++ b/ase/test/awk/err-021.out @@ -0,0 +1,6 @@ +BEGIN { + xx = 20; + split ("a b c",xx); +} + +RUN ERROR: CODE [95] LINE [3] cannot change a scalar value to a map diff --git a/ase/test/awk/err-en.data b/ase/test/awk/err-en.data new file mode 100644 index 00000000..43684d80 --- /dev/null +++ b/ase/test/awk/err-en.data @@ -0,0 +1,2 @@ +data 1 +data 2 diff --git a/ase/test/awk/histsort.awk b/ase/test/awk/histsort.awk new file mode 100644 index 00000000..2ab2ba7f --- /dev/null +++ b/ase/test/awk/histsort.awk @@ -0,0 +1,8 @@ +{ + if (data[$0]++ == 0) lines[++count] = $0; +} + +END { + for (i = 1; i <= count; i++) print lines[i]; +} + diff --git a/ase/test/awk/ite-001.awk b/ase/test/awk/ite-001.awk new file mode 100644 index 00000000..02f1e014 --- /dev/null +++ b/ase/test/awk/ite-001.awk @@ -0,0 +1,7 @@ +{ + i = 1; + while (i <= $3) { + printf ("\t%.2f\n", $1*(1+$2)**i); + i = i + 1; + } +} diff --git a/ase/test/awk/ite-002.awk b/ase/test/awk/ite-002.awk new file mode 100644 index 00000000..17147dff --- /dev/null +++ b/ase/test/awk/ite-002.awk @@ -0,0 +1,4 @@ +{ + for (i = 1; i <= $3; i=i+1) + printf ("\t%.2f\n", $1*(1+$2)**i); +} diff --git a/ase/test/awk/makefile.in b/ase/test/awk/makefile.in new file mode 100644 index 00000000..e1f0b3e3 --- /dev/null +++ b/ase/test/awk/makefile.in @@ -0,0 +1,59 @@ +# +# $Id: makefile.in,v 1.3 2007/04/30 08:32:41 bacon Exp $ +# + +CC = @CC@ +CFLAGS = @CFLAGS@ -I@abs_top_builddir@/.. +LDFLAGS = @LDFLAGS@ -L@abs_top_builddir@/@BUILDMODE@/lib +LIBS = @LIBS@ -laseawk -lasecmn -laseutl -lm +MODE = @BUILDMODE@ + +JAVAC = @JAVAC@ +JAR = @JAR@ +CFLAGS_JNI = @CFLAGS_JNI@ +JNI = @JNI@ + +LIB_DIR = ../../$(MODE)/lib +OUT_DIR = ../../$(MODE)/bin +TMP_DIR = $(MODE) + +ASEAWK_LIB = + +all: build$(JNI) + +build: $(TMP_DIR) $(OUT_DIR) $(OUT_DIR)/aseawk $(OUT_DIR)/aseawk_mini + +buildjni: build $(OUT_DIR)/aseawk.jar $(OUT_DIR)/AseAwkApplet.html + +$(OUT_DIR)/aseawk: awk.c + $(CC) $(CFLAGS) -o $@ awk.c $(LDFLAGS) $(LIBS) + +$(OUT_DIR)/aseawk_mini: mini.c + $(CC) $(CFLAGS) -o $@ mini.c $(LDFLAGS) $(LIBS) + +$(OUT_DIR)/aseawk.jar: $(TMP_DIR)/AseAwkPanel.class $(TMP_DIR)/AseAwk.class $(TMP_DIR)/AseAwkApplet.class + cd $(TMP_DIR); $(JAR) -xvf ../$(LIB_DIR)/aseawk.jar + cd $(TMP_DIR); $(JAR) -cvfm ../$@ ../manifest *.class ase + rm -rf $(TMP_DIR)/ase + +$(TMP_DIR)/AseAwkPanel.class: AseAwkPanel.java + $(JAVAC) -classpath $(TMP_DIR):$(LIB_DIR)/aseawk.jar -d $(TMP_DIR) AseAwkPanel.java + +$(TMP_DIR)/AseAwk.class: AseAwk.java + $(JAVAC) -classpath $(TMP_DIR):$(LIB_DIR)/aseawk.jar -d $(TMP_DIR) AseAwk.java + +$(TMP_DIR)/AseAwkApplet.class: AseAwkApplet.java + $(JAVAC) -classpath $(TMP_DIR):$(LIB_DIR)/aseawk.jar -d $(TMP_DIR) AseAwkApplet.java + +$(OUT_DIR)/AseAwkApplet.html: AseAwkApplet.html + cp -pf AseAwkApplet.html $(OUT_DIR) + +$(OUT_DIR): + mkdir -p $(OUT_DIR) + +$(TMP_DIR): + mkdir -p $(TMP_DIR) + +clean: + rm -rf $(OUT_DIR)/aseawk $(OUT_DIR)/aseawk_mini $(OUT_DIR)/aseawk.jar $(OUT_DIR)/AseAwkApplet.html $(TMP_DIR)/*.class + diff --git a/ase/test/awk/makefile.msw.bcc b/ase/test/awk/makefile.msw.bcc new file mode 100644 index 00000000..9dec9ca8 --- /dev/null +++ b/ase/test/awk/makefile.msw.bcc @@ -0,0 +1,34 @@ + +# ilink32.exe link.exe +# -aa /subsystem:windows +# -ap /subsystem:console +# -ad /subsystem:native +# +# -Tpe +# -Tpd /dll + +CC = bcc32 +LD = ilink32 +CFLAGS = -O2 -WM -WU -RT- -w -I..\..\.. +LDFLAGS = -ap -Tpe -Gn -c -L..\..\awk -L..\..\cmn -L..\..\utl +LIBS = import32.lib cw32mt.lib aseawk.lib asecmn.lib aseutl.lib +STARTUP = c0x32w.obj + +all: aseawk + +aseawk: awk.obj + $(LD) $(LDFLAGS) $(STARTUP) awk.obj,$@.exe,,$(LIBS),, + +java: + javac -classpath ../../.. Awk.java AwkApplet.java + +jrun: + java -Xms1m -Xmx2m -classpath ../../.. ase.test.awk.Awk + +clean: + del $(OBJS) *.obj *.class aseawk.exe + +.SUFFIXES: .c .obj +.c.obj: + $(CC) $(CFLAGS) -c $< + diff --git a/ase/test/awk/makefile.msw.cl b/ase/test/awk/makefile.msw.cl new file mode 100644 index 00000000..19b7dfc0 --- /dev/null +++ b/ase/test/awk/makefile.msw.cl @@ -0,0 +1,43 @@ +CC = cl +CFLAGS = /nologo /MT /W3 /GR- -I..\..\.. +LDFLAGS = /libpath:..\..\cmn /libpath:..\..\awk /libpath:..\..\utl +LIBS = asecmn.lib aseawk.lib aseutl.lib kernel32.lib user32.lib + +!if !defined(CPU) || "$(CPU)" == "" +CPU = $(PROCESSOR_ARCHITECTURE) +!endif + +!if "$(CPU)" == "" +CPU = i386 +!endif + +!if "$(CPU)" == "IA64" || "$(CPU)" == "AMD64" +LIBS = $(LIBS) bufferoverflowu.lib +!endif + +all: aseawk + +aseawk: awk.obj + link /nologo /out:$@.exe $(LDFLAGS) $(LIBS) awk.obj + +mini: mini.obj + link /nologo /out:$@.exe $(LDFLAGS) $(LIBS) mini.obj + +java: + javac -classpath ../../.. Awk.java + javac -classpath ../../.. AwkApplet.java + +jrun: + java -classpath ../../.. ase.test.awk.Awk + +cert: + keytool -genkey -keystore ase.store -alias asecert + keytool -export -keystore ase.store -alias asecert -file ase.cer + +clean: + del $(OBJS) *.obj aseawk.exe mini.exe + +.SUFFIXES: .c .obj +.c.obj: + $(CC) /c $(CFLAGS) $< + diff --git a/ase/test/awk/manifest b/ase/test/awk/manifest new file mode 100644 index 00000000..73fc04a3 --- /dev/null +++ b/ase/test/awk/manifest @@ -0,0 +1 @@ +Main-Class: AseAwk diff --git a/ase/test/awk/match.awk b/ase/test/awk/match.awk new file mode 100644 index 00000000..243b082a --- /dev/null +++ b/ase/test/awk/match.awk @@ -0,0 +1,19 @@ +BEGIN { + print match ("hhhheeeo", /e+/); + print RSTART, RLENGTH; + print match ("heeeo", /e/); + print RSTART, RLENGTH; + print match ("heeeo", /t/); + print RSTART, RLENGTH; + + print "--------------------------"; + print match ("hhhheeeo", "e+"); + print RSTART, RLENGTH; + print match ("heeeo", "e"); + print RSTART, RLENGTH; + print match ("heeeo", "t"); + print RSTART, RLENGTH; + print "--------------------------"; +} + + diff --git a/ase/test/awk/mini.c b/ase/test/awk/mini.c new file mode 100644 index 00000000..88325af0 --- /dev/null +++ b/ase/test/awk/mini.c @@ -0,0 +1,427 @@ +/* + * $Id: mini.c,v 1.3 2007/04/30 08:32:41 bacon Exp $ + */ + +#include + +#include +#include + +#include +#include +#include + +#include +#include +#include + +struct awk_src_io +{ + const ase_char_t* file; + FILE* handle; +}; + +static const ase_char_t* data_file = ASE_NULL; + +#if defined(vms) || defined(__vms) +/* it seems that the main function should be placed in the main object file + * in OpenVMS. otherwise, the first function in the main object file seems + * to become the main function resulting in program start-up failure. */ +#include +#endif + +#ifndef NDEBUG +void ase_assert_abort (void) +{ + abort (); +} + +void ase_assert_printf (const ase_char_t* fmt, ...) +{ + va_list ap; + va_start (ap, fmt); + ase_vprintf (fmt, ap); + va_end (ap); +} +#endif + +/* custom memory management function */ +void* awk_malloc (void* custom, ase_size_t n) { return malloc (n); } +void* awk_realloc (void* custom, void* ptr, ase_size_t n) { return realloc (ptr, n); } +void awk_free (void* custom, void* ptr) { free (ptr); } + +/* custom character class functions */ +ase_bool_t awk_isupper (void* custom, ase_cint_t c) { return ase_isupper (c); } +ase_bool_t awk_islower (void* custom, ase_cint_t c) { return ase_islower (c); } +ase_bool_t awk_isalpha (void* custom, ase_cint_t c) { return ase_isalpha (c); } +ase_bool_t awk_isdigit (void* custom, ase_cint_t c) { return ase_isdigit (c); } +ase_bool_t awk_isxdigit (void* custom, ase_cint_t c) { return ase_isxdigit (c); } +ase_bool_t awk_isalnum (void* custom, ase_cint_t c) { return ase_isalnum (c); } +ase_bool_t awk_isspace (void* custom, ase_cint_t c) { return ase_isspace (c); } +ase_bool_t awk_isprint (void* custom, ase_cint_t c) { return ase_isprint (c); } +ase_bool_t awk_isgraph (void* custom, ase_cint_t c) { return ase_isgraph (c); } +ase_bool_t awk_iscntrl (void* custom, ase_cint_t c) { return ase_iscntrl (c); } +ase_bool_t awk_ispunct (void* custom, ase_cint_t c) { return ase_ispunct (c); } +ase_cint_t awk_toupper (void* custom, ase_cint_t c) { return ase_toupper (c); } +ase_cint_t awk_tolower (void* custom, ase_cint_t c) { return ase_tolower (c); } + +/* custom miscellaneous functions */ +ase_real_t awk_pow (void* custom, ase_real_t x, ase_real_t y) +{ + return pow (x, y); +} + +int awk_sprintf (void* custom, ase_char_t* buf, ase_size_t size, const ase_char_t* fmt, ...) +{ + int n; + + va_list ap; + va_start (ap, fmt); + n = ase_vsprintf (buf, size, fmt, ap); + va_end (ap); + + return n; +} + +void awk_dprintf (void* custom, const ase_char_t* fmt, ...) +{ + va_list ap; + va_start (ap, fmt); + ase_vfprintf (stderr, fmt, ap); + va_end (ap); +} + +/* source input handler */ +ase_ssize_t awk_srcio_in (int cmd, void* arg, ase_char_t* data, ase_size_t size) +{ + struct awk_src_io* src_io = (struct awk_src_io*)arg; + ase_cint_t c; + + if (cmd == ASE_AWK_IO_OPEN) + { + if (src_io->file == ASE_NULL) return 0; + src_io->handle = ase_fopen (src_io->file, ASE_T("r")); + if (src_io->handle == NULL) return -1; + return 1; + } + else if (cmd == ASE_AWK_IO_CLOSE) + { + if (src_io->file == ASE_NULL) return 0; + fclose ((FILE*)src_io->handle); + return 0; + } + else if (cmd == ASE_AWK_IO_READ) + { + if (size <= 0) return -1; + c = ase_fgetc ((FILE*)src_io->handle); + if (c == ASE_CHAR_EOF) return 0; + *data = (ase_char_t)c; + return 1; + } + + return -1; +} + +/* external i/o handler for pipe */ +ase_ssize_t awk_extio_pipe (int cmd, void* arg, ase_char_t* data, ase_size_t size) +{ + ase_awk_extio_t* epa = (ase_awk_extio_t*)arg; + + switch (cmd) + { + case ASE_AWK_IO_OPEN: + { + FILE* handle; + const ase_char_t* mode; + + if (epa->mode == ASE_AWK_EXTIO_PIPE_READ) + mode = ASE_T("r"); + else if (epa->mode == ASE_AWK_EXTIO_PIPE_WRITE) + mode = ASE_T("w"); + else return -1; + + handle = ase_popen (epa->name, mode); + if (handle == NULL) return -1; + epa->handle = (void*)handle; + return 1; + } + + case ASE_AWK_IO_CLOSE: + { + fclose ((FILE*)epa->handle); + epa->handle = NULL; + return 0; + } + + case ASE_AWK_IO_READ: + { + if (ase_fgets (data, size, (FILE*)epa->handle) == ASE_NULL) + { + if (ferror((FILE*)epa->handle)) return -1; + return 0; + } + return ase_strlen(data); + } + + case ASE_AWK_IO_WRITE: + { + #if defined(ASE_CHAR_IS_WCHAR) && defined(__linux) + /* fwprintf seems to return an error with the file + * pointer opened by popen, as of this writing. + * anyway, hopefully the following replacement + * will work all the way. */ + int n = fprintf ( + (FILE*)epa->handle, "%.*ls", size, data); + #else + int n = ase_fprintf ( + (FILE*)epa->handle, ASE_T("%.*s"), size, data); + #endif + if (n < 0) return -1; + + return size; + } + + case ASE_AWK_IO_FLUSH: + { + if (epa->mode == ASE_AWK_EXTIO_PIPE_READ) return -1; + else return 0; + } + + case ASE_AWK_IO_NEXT: + { + return -1; + } + } + + return -1; +} + +/* external i/o handler for file */ +ase_ssize_t awk_extio_file (int cmd, void* arg, ase_char_t* data, ase_size_t size) +{ + ase_awk_extio_t* epa = (ase_awk_extio_t*)arg; + + switch (cmd) + { + case ASE_AWK_IO_OPEN: + { + FILE* handle; + const ase_char_t* mode; + + if (epa->mode == ASE_AWK_EXTIO_FILE_READ) + mode = ASE_T("r"); + else if (epa->mode == ASE_AWK_EXTIO_FILE_WRITE) + mode = ASE_T("w"); + else if (epa->mode == ASE_AWK_EXTIO_FILE_APPEND) + mode = ASE_T("a"); + else return -1; + + handle = ase_fopen (epa->name, mode); + if (handle == NULL) return -1; + + epa->handle = (void*)handle; + return 1; + } + + case ASE_AWK_IO_CLOSE: + { + fclose ((FILE*)epa->handle); + epa->handle = NULL; + return 0; + } + + case ASE_AWK_IO_READ: + { + if (ase_fgets (data, size, (FILE*)epa->handle) == ASE_NULL) + { + if (ferror((FILE*)epa->handle)) return -1; + return 0; + } + return ase_strlen(data); + } + + case ASE_AWK_IO_WRITE: + { + int n = ase_fprintf ( + (FILE*)epa->handle, ASE_T("%.*s"), size, data); + if (n < 0) return -1; + + return size; + } + + case ASE_AWK_IO_FLUSH: + { + if (fflush ((FILE*)epa->handle) == EOF) return -1; + return 0; + } + + case ASE_AWK_IO_NEXT: + { + return -1; + } + + } + + return -1; +} + +/* external i/o handler for console */ +ase_ssize_t awk_extio_console (int cmd, void* arg, ase_char_t* data, ase_size_t size) +{ + ase_awk_extio_t* epa = (ase_awk_extio_t*)arg; + + if (cmd == ASE_AWK_IO_OPEN) + { + if (epa->mode == ASE_AWK_EXTIO_CONSOLE_READ) + { + FILE* fp = ase_fopen (data_file, ASE_T("r")); + if (fp == ASE_NULL) return -1; + + if (ase_awk_setfilename ( + epa->run, data_file, ase_strlen(data_file)) == -1) + { + fclose (fp); + return -1; + } + + epa->handle = fp; + + return 1; + } + else if (epa->mode == ASE_AWK_EXTIO_CONSOLE_WRITE) + { + epa->handle = stdout; + return 1; + } + + return -1; + } + else if (cmd == ASE_AWK_IO_CLOSE) + { + fclose ((FILE*)epa->handle); + epa->handle = NULL; + return 0; + } + else if (cmd == ASE_AWK_IO_READ) + { + while (ase_fgets (data, size, (FILE*)epa->handle) == ASE_NULL) + { + if (ferror((FILE*)epa->handle)) return -1; + return 0; + } + + return ase_strlen(data); + } + else if (cmd == ASE_AWK_IO_WRITE) + { + int n = ase_fprintf ((FILE*)epa->handle, ASE_T("%.*s"), size, data); + if (n < 0) return -1; + + return size; + } + else if (cmd == ASE_AWK_IO_FLUSH) + { + if (fflush ((FILE*)epa->handle) == EOF) return -1; + return 0; + } + else if (cmd == ASE_AWK_IO_NEXT) + { + return -1; + } + + return -1; +} + +int ase_main (int argc, ase_char_t* argv[]) +{ + ase_awk_t* awk; + + ase_awk_prmfns_t prmfns; + ase_awk_srcios_t srcios; + ase_awk_runios_t runios; + + struct awk_src_io src_io = { NULL, NULL }; + + if (argc != 3) + { + ase_printf (ASE_T("Usage: %s source-file data-file\n"), argv[0]); + return -1; + } + + src_io.file = argv[1]; + data_file = argv[2]; + + ase_memset (&prmfns, 0, ASE_SIZEOF(prmfns)); + + prmfns.mmgr.malloc = awk_malloc; + prmfns.mmgr.realloc = awk_realloc; + prmfns.mmgr.free = awk_free; + prmfns.mmgr.custom_data = ASE_NULL; + + prmfns.ccls.is_upper = awk_isupper; + prmfns.ccls.is_lower = awk_islower; + prmfns.ccls.is_alpha = awk_isalpha; + prmfns.ccls.is_digit = awk_isdigit; + prmfns.ccls.is_xdigit = awk_isxdigit; + prmfns.ccls.is_alnum = awk_isalnum; + prmfns.ccls.is_space = awk_isspace; + prmfns.ccls.is_print = awk_isprint; + prmfns.ccls.is_graph = awk_isgraph; + prmfns.ccls.is_cntrl = awk_iscntrl; + prmfns.ccls.is_punct = awk_ispunct; + prmfns.ccls.to_upper = awk_toupper; + prmfns.ccls.to_lower = awk_tolower; + prmfns.ccls.custom_data = ASE_NULL; + + prmfns.misc.pow = awk_pow; + prmfns.misc.sprintf = awk_sprintf; + prmfns.misc.dprintf = awk_dprintf; + prmfns.misc.custom_data = ASE_NULL; + + if ((awk = ase_awk_open(&prmfns, ASE_NULL)) == ASE_NULL) + { + ase_printf (ASE_T("ERROR: cannot open awk\n")); + return -1; + } + + ase_awk_setoption (awk, + ASE_AWK_IMPLICIT | ASE_AWK_EXPLICIT | ASE_AWK_UNIQUEFN | + ASE_AWK_IDIV | ASE_AWK_SHADING | ASE_AWK_SHIFT | + ASE_AWK_EXTIO | ASE_AWK_BLOCKLESS | ASE_AWK_STRBASEONE | + ASE_AWK_STRIPSPACES | ASE_AWK_NEXTOFILE); + + srcios.in = awk_srcio_in; + srcios.out = ASE_NULL; + srcios.custom_data = &src_io; + + if (ase_awk_parse (awk, &srcios) == -1) + { + ase_printf ( + ASE_T("PARSE ERROR: CODE [%d] LINE [%u] %s\n"), + ase_awk_geterrnum(awk), + (unsigned int)ase_awk_geterrlin(awk), + ase_awk_geterrmsg(awk)); + ase_awk_close (awk); + return -1; + } + + runios.pipe = awk_extio_pipe; + runios.file = awk_extio_file; + runios.console = awk_extio_console; + runios.custom_data = ASE_NULL; + + if (ase_awk_run (awk, ASE_NULL, &runios, ASE_NULL, ASE_NULL, ASE_NULL) == -1) + { + ase_printf ( + ASE_T("RUN ERROR: CODE [%d] LINE [%u] %s\n"), + ase_awk_geterrnum(awk), + (unsigned int)ase_awk_geterrlin(awk), + ase_awk_geterrmsg(awk)); + + ase_awk_close (awk); + return -1; + } + + ase_awk_close (awk); + return 0; +} diff --git a/ase/test/awk/mkjar.bat b/ase/test/awk/mkjar.bat new file mode 100644 index 00000000..19ab553b --- /dev/null +++ b/ase/test/awk/mkjar.bat @@ -0,0 +1,8 @@ +cd ..\..\.. +move ase\test\awk\AwkApplet*.class . +jar cvf AwkApplet.jar *.class ase\test\awk\*.class ase\awk\*.class +move AwkApplet.jar ase\test\awk +cd ase\test\awk + +copy ..\..\awk\aseawk_jni.dll . +jarsigner -keystore ase.store AwkApplet.jar asecert diff --git a/ase/test/awk/negnum.data b/ase/test/awk/negnum.data new file mode 100644 index 00000000..7b65e93c --- /dev/null +++ b/ase/test/awk/negnum.data @@ -0,0 +1,6 @@ +Beth -4.00 0 +Dan 3.74 0 +-Kathy 4.00 10 +Mark 5.00 -20 +Mary -5.50 22 +Susie -4.25 -18 diff --git a/ase/test/awk/num.awk b/ase/test/awk/num.awk new file mode 100644 index 00000000..51ee2d4f --- /dev/null +++ b/ase/test/awk/num.awk @@ -0,0 +1,27 @@ +BEGIN { + print 1 + 0; + print 0B11111111 + 0; + print 10 + 0; + print 0x10 + 0; + print 0b00000010 + 0; + print 0b + 0; + print 0x + 0; + + print "-----------------------"; + print +1 + 0; + print +0B11111111 + 0; + print +10 + 0; + print +0x10 + 0; + print +0b00000010 + 0; + print +0b + 0; + print +0x + 0; + + print "-----------------------"; + print -1 + 0; + print -0B11111111 + 0; + print -10 + 0; + print -0x10 + 0; + print -0b00000010 + 0; + print -0b + 0; + print -0x + 0; +} diff --git a/ase/test/awk/pow.awk b/ase/test/awk/pow.awk new file mode 100644 index 00000000..9778fe0b --- /dev/null +++ b/ase/test/awk/pow.awk @@ -0,0 +1,43 @@ +BEGIN { + print 3**2; + print -3**2; + print (-3)**2; + print 3**2**3**2; + print -3**2**-3**2; + print (-3)**2**(-3)**2; + print 3**-2**3**-2;; + print -2 ** 3; + print -2 ** -3; + + print 0 ** 0; + print 0 ** 1; + #print 0 ** -1; + print -1 ** 4; + print -1 ** 5; + + print "-------------------"; + + print 3.0 ** 2; + print 3.0 ** -2; + print -2.0 ** 3; + print -2.0 ** -3; + + print 0.0 ** 0; + print 0.0 ** 1; + #print 0.0 ** -1; + print -1.0 ** 4; + print -1.0 ** 5; + + print -2.12 ** 3; + print 2.12 ** -3; + print -12.12 ** 3; + print 12.12 ** -3; + + print 0.000000001 ** 30; + print 0.000000002 ** 30; + print 0.000000000000000000000000000000000000000000000000000000001 ** 30; + print 0.000000000000000000000000000000000000000000000000000000002 ** 30; + + print "-------------------"; +} + diff --git a/ase/test/awk/regress.sh b/ase/test/awk/regress.sh new file mode 100755 index 00000000..c16b3183 --- /dev/null +++ b/ase/test/awk/regress.sh @@ -0,0 +1,140 @@ +#!/bin/sh + +run_script_for_init() +{ + script="$1" + data="$2" + output=`echo $script | sed 's/\.awk$/.out/g'` + + ./aseawk -d -f "$script" "$data" > "$output" +} + +run_init() +{ + for script in emp-???.awk + do + run_script_for_init "$script" "emp-en.data" + done + + for script in cou-???.awk + do + run_script_for_init "$script" "cou-en.data" + done + + for script in err-???.awk + do + run_script_for_init "$script" "err-en.data" + done +} + +run_script_for_test() +{ + script="$1" + data="$2" + output=`echo $script | sed 's/\.awk$/.out/g'` + + echo ">> RUNNING $script" + ./aseawk -d -f "$script" "$data" > "$output.$pid" + + #diff -y "$output" "$output.$pid" + diff "$output" "$output.$pid" + if [ $? -ne 0 ] + then + rm -f "$output.$pid" + return 1 + fi + + rm -f "$output.$pid" + return 0 +} + +run_test() +{ + pid=$$ + + for script in emp-???.awk + do + run_script_for_test "$script" "emp-en.data" + if [ $? -ne 0 ] + then + echo "###################################" + echo "PROBLEM(S) DETECTED IN $script.". + echo "###################################" + + echo "Do you want to abort? [y/n]" + read ans + if [ "$ans" = "y" -o "$ans" = "Y" ] + then + return 1 + fi + fi + done + + for script in cou-???.awk + do + run_script_for_test "$script" "cou-en.data" + if [ $? -ne 0 ] + then + echo "###################################" + echo "PROBLEM(S) DETECTED IN $script.". + echo "###################################" + + echo "Do you want to abort? [y/n]" + read ans + if [ "$ans" = "y" -o "$ans" = "Y" ] + then + return 1 + fi + fi + done + + for script in err-???.awk + do + run_script_for_test "$script" "err-en.data" + if [ $? -ne 0 ] + then + echo "###################################" + echo "PROBLEM(S) DETECTED IN $script.". + echo "###################################" + + echo "Do you want to abort? [y/n]" + read ans + if [ "$ans" = "y" -o "$ans" = "Y" ] + then + return 1 + fi + fi + done + + return 0 +} + +#--------# +# main # +#--------# + +if [ ! -x ./aseawk ] +then + echo "Error: cannot locate a relevant awk interpreter" + exit 1; +fi + +if [ $# -ne 1 ] +then + echo "Usage: $0 init" + echo " $0 test" + exit 1 +fi + +if [ "$1" = "init" ] +then + run_init +elif [ "$1" = "test" ] +then + run_test +else + echo "Usage: $0 init" + echo " $0 test" + exit 1 +fi + diff --git a/ase/test/awk/t1.awk b/ase/test/awk/t1.awk new file mode 100644 index 00000000..9cffc875 --- /dev/null +++ b/ase/test/awk/t1.awk @@ -0,0 +1,21 @@ +function sum(i, k, y) +{ + y = 0; + for (k = i; k; k = k - 1) + { + y = y + k; + } + + return y; + y = 10; + return y; +} + +BEGIN { + /*s = sum(10000000);*/ + s = sum (100); + print s; + return s; +} + + diff --git a/ase/test/awk/t10.awk b/ase/test/awk/t10.awk new file mode 100644 index 00000000..f562146f --- /dev/null +++ b/ase/test/awk/t10.awk @@ -0,0 +1,22 @@ +BEGIN { + print "more"; + //print | "more"; + //print > "echo"; + //print >> "echo"; + + getline x < "abc"; /* open("abc", O_RDONLY|O_LARGEFILE) = 3 */ + //print 10 >> "abc"; /* open("abc", O_WRONLY|O_APPEND|O_CREAT|O_LARGEFILE, 0666) = 4 */ + getline x < "abc"; + //print x; + a = close ("abc"); /* close(4) */ + print "a=" a; + //print "hey" + b = close ("abc"); /* close(3) */ + print "b=" b; + + getline x < "Makefile.cl"; + getline y < "awk.c"; + c = close ("Makefile.cl"); + d = close ("awk.c"); + +} diff --git a/ase/test/awk/t11.awk b/ase/test/awk/t11.awk new file mode 100644 index 00000000..b78f07e4 --- /dev/null +++ b/ase/test/awk/t11.awk @@ -0,0 +1,17 @@ +BEGIN { + print "this is only a test"; + print; + print 1, 2, (3 >> 10); + print 1, 2, 3 >> 10; + print 3, 4, 5 >> 10; + close (10); + print "-------------" >> 10; + + delete abc; + delete abc["aaaa"] ; + + /* + print 1 > 2 + 3; + print 1 < 2 + 3; + */ +} diff --git a/ase/test/awk/t12.awk b/ase/test/awk/t12.awk new file mode 100644 index 00000000..53c5a63e --- /dev/null +++ b/ase/test/awk/t12.awk @@ -0,0 +1,38 @@ +BEGIN { + /* + print "line 1" >> "1"; + print "line 2" > "1"; + print "line 3" >> "1"; + + print "line 4" >> "2"; + print "line 4" >> "3"; + print "line 4" >> "4"; + + while ((getline x < "abc") > 0) print x; + close ("abc"); + + + print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"; + + getline x < "abc"; + if (x == "a") print "xxxxxxxxxxxxxxxx"; else print x; + */ + + /* + print getline x; + print "[", x, "]"; + print "--------------"; + */ + + if (getline x < "abc" == -1) + { + print "ERRNO = ", ERRNO; + } + + print x > "def"; + #print "fflush(def) = ", fflush ("def"); + print "fflush() = ", fflush (""); + +# print (1 (2 getline j) j); +# print "abc" 1 + 2 3 + 49 2 / 3; +} diff --git a/ase/test/awk/t13.awk b/ase/test/awk/t13.awk new file mode 100644 index 00000000..45cb240d --- /dev/null +++ b/ase/test/awk/t13.awk @@ -0,0 +1,22 @@ +global a; +BEGIN { + local b; + + #a = 20; + #a[1] = 20; + #a[2] = 30; + + /* + b["xxx"] = 20; + b["yyy"] = 30; + b[1] = 30; + b["2"] = 30; + + delete a; + delete b["1"]; + */ + c[1] = 20; + c[1] = "aaa"; + c = 30; +} + diff --git a/ase/test/awk/t14.awk b/ase/test/awk/t14.awk new file mode 100644 index 00000000..b0f3aad9 --- /dev/null +++ b/ase/test/awk/t14.awk @@ -0,0 +1,28 @@ +global x, y; + +BEGIN { FS="A"; } + +{ + print "NF = " NF; + for (i = 0; i < 10; i++) + { + print $i; + if (i == 3) a = $i; + } + + $1 = 100; + + /*$1 = $2; + $3 = $2; + $2 = $2;*/ + + /*OFS["1234"]=":";*/ + + $20 = 10; + print $0; + print "--------------------"; + print "NF ===>>> " NF; + print "===================="; +} + +END { fflush (); system ("dir /w/p"); print sin(270); } diff --git a/ase/test/awk/t15.awk b/ase/test/awk/t15.awk new file mode 100644 index 00000000..6765587d --- /dev/null +++ b/ase/test/awk/t15.awk @@ -0,0 +1,16 @@ +BEGIN { + local a, b; + + a = 12; + b = "<" a ">"; + + print b; + + print ("\x5C"); + print ("\x5C6_ABCDEGH"); + print ("\xZZ5C6_ABCDEGH"); + print ("\xZZ5C6_AB\u7658&&"); + print "\uC720\uB2C8\uCF54\uB4DC \uD14C\uC2A4\uD2B8"; + print "\UC720\UB2C8\UCF54\UB4DC \UD14C\UC2A4\UD2B8"; +} + diff --git a/ase/test/awk/t16.awk b/ase/test/awk/t16.awk new file mode 100644 index 00000000..d383b877 --- /dev/null +++ b/ase/test/awk/t16.awk @@ -0,0 +1 @@ +{ /*$0=" "; */ print NF; print "a" $0 "b"; x = $1; } diff --git a/ase/test/awk/t17.awk b/ase/test/awk/t17.awk new file mode 100644 index 00000000..92fc9831 --- /dev/null +++ b/ase/test/awk/t17.awk @@ -0,0 +1,18 @@ +/hello[[:space:]]/ { + print $0; + print "INTERNAL LOOP NF=" NF; + for (i = 0; i < NF; i++) + { + print "[" $(i+1) "]"; + } + #getline a; + #print a; + + if (getline > 0) print $0; + print "GETLINE NF=" NF; + for (i = 0; i < NF; i++) + { + print "[" $(i+1) "]"; + } + print "----------------"; +} diff --git a/ase/test/awk/t18.awk b/ase/test/awk/t18.awk new file mode 100644 index 00000000..1e012fff --- /dev/null +++ b/ase/test/awk/t18.awk @@ -0,0 +1,21 @@ +BEGIN { + print "0. FILENAME=", FILENAME, "FNR=", FNR; +} + +/hello/ { + print "1. FILENAME=", FILENAME, "FNR=", FNR; + print "[" $0 "]"; + #nextfile; + print "----------------"; +} + +/hello/ { + print "2. FILENAME=", FILENAME, "FNR=", FNR; + print "[" $0 "]"; + nextfile; + print "----------------"; +} + +END { + print "== END OF PROGRAM =="; +} diff --git a/ase/test/awk/t19.awk b/ase/test/awk/t19.awk new file mode 100644 index 00000000..836544c1 --- /dev/null +++ b/ase/test/awk/t19.awk @@ -0,0 +1,4 @@ +//BEGIN { nlines="-0.345"; } + { nlines++; } +END { print nlines; } + diff --git a/ase/test/awk/t2.awk b/ase/test/awk/t2.awk new file mode 100644 index 00000000..9a74d34c --- /dev/null +++ b/ase/test/awk/t2.awk @@ -0,0 +1,24 @@ +global z, x; + +function sum (i) +{ + local k, y; + + y = 0; + for (k = i; k; k = k - 1) + { + y = y + k; + } + + return y; + y = 10; + return y; +} + +END { + /*x = sum (10000000); + */ + x = sum (100); + s = x; + ss = z; +} diff --git a/ase/test/awk/t20.awk b/ase/test/awk/t20.awk new file mode 100644 index 00000000..41df5047 --- /dev/null +++ b/ase/test/awk/t20.awk @@ -0,0 +1,8 @@ +//"abc" != "def" { +/a\/b/ { + print $0 ~ /abc/; + print $0 !~ /abc/; + print $0 ~ "abc[[:space:]]"; + print $0 !~ "abc"; + print /abc/; +} diff --git a/ase/test/awk/t21.awk b/ase/test/awk/t21.awk new file mode 100644 index 00000000..33fe1fd5 --- /dev/null +++ b/ase/test/awk/t21.awk @@ -0,0 +1,8 @@ +BEGIN { exit 10; } + +{ + print $0; + #print close (""); +} + +END { print "== END OF PROGRAM =="; } diff --git a/ase/test/awk/t22.awk b/ase/test/awk/t22.awk new file mode 100644 index 00000000..defc73ec --- /dev/null +++ b/ase/test/awk/t22.awk @@ -0,0 +1,15 @@ +//BEGIN { exit 10; } + +//{ while (1) {if (x == 20) continue; if (a) break; while (10) break; }} +//END { while (1) {if (x == 20) continue; if (a) break; while (10) break; }} + +{ + //return 20; + + print getline abc < ""; + print "[[" abc "]]"; + print close(""); + //exit 20; +} + +END { print "end"; } diff --git a/ase/test/awk/t23.awk b/ase/test/awk/t23.awk new file mode 100644 index 00000000..d3a3c414 --- /dev/null +++ b/ase/test/awk/t23.awk @@ -0,0 +1,19 @@ +/* +{ + print "ALL ==> " $0; +} + +/1/,/5/ +{ + + print "/1/,/5/ ==> " $0; +} +*/ + + +BEGIN { c["Europe"] = "XXX"; } + +/Europe/, /Africa/ { print $0; } + +//(a = "20") { } +/*"Europe" in c { print $0; }*/ diff --git a/ase/test/awk/t24.awk b/ase/test/awk/t24.awk new file mode 100644 index 00000000..ece42637 --- /dev/null +++ b/ase/test/awk/t24.awk @@ -0,0 +1,6 @@ +BEGIN { + + a["abc\0\0xxx"] = "abcdefg"; + print a["abc"]; + print a["abc\0\0xxx"]; +} diff --git a/ase/test/awk/t25.awk b/ase/test/awk/t25.awk new file mode 100644 index 00000000..c14c928d --- /dev/null +++ b/ase/test/awk/t25.awk @@ -0,0 +1,13 @@ +/Europe/, /Africa/ + + 1 + 2 + 3 % 23 + +/zab/ { print "XXXX"; } + +{ + print /ABC/ ~ /DEF/; +} + +/zzz/ diff --git a/ase/test/awk/t26.awk b/ase/test/awk/t26.awk new file mode 100644 index 00000000..442d5770 --- /dev/null +++ b/ase/test/awk/t26.awk @@ -0,0 +1,13 @@ +function call_next () +{ + next; +} + +BEGIN { + #call_next (); +} + +END { + call_next (); +} + diff --git a/ase/test/awk/t27.awk b/ase/test/awk/t27.awk new file mode 100644 index 00000000..f963d63a --- /dev/null +++ b/ase/test/awk/t27.awk @@ -0,0 +1,6 @@ +global a, b, c; + +BEGIN { while (1) while(1) while (1) a = 20; } + +END { while (1) while(1) while (1) ; } + diff --git a/ase/test/awk/t28.awk b/ase/test/awk/t28.awk new file mode 100644 index 00000000..73599250 --- /dev/null +++ b/ase/test/awk/t28.awk @@ -0,0 +1,41 @@ +#global xyz; + +END { + #local xyz; + + print index ("abc", "abc"); + print index ("abc", "b"); + print index ("abc", "kabc"); + + print "----------------------------"; + print substr ("abc", "abcdefg", 5); + print substr ("abc", -1, 5); + print substr ("abc", 0, 5); + print substr ("abc", 1, 5); + print substr ("abc", 2.829, 5); + print substr ("abc", "3", 5); + print substr ("abc", 4, 5); + + /* + a[1] = 20; + substr (a, 3, 4); + */ + + print tolower ("AbcDEF"); + print toupper ("AbcDEF"); + + arr[0] = "xxx"; + #print split ("abc def abc", arr); + print split ("abc def kkk", j); + print split ("abc def kkk", $0); # error + + #xyz = 20; + #print xyz; + print split ("abc def kkk", ((xyz))); + #for (i in arr) + + for (i in xyz) + { + print i, " ", xyz[i]; + } +} diff --git a/ase/test/awk/t29.awk b/ase/test/awk/t29.awk new file mode 100644 index 00000000..0e852b8b --- /dev/null +++ b/ase/test/awk/t29.awk @@ -0,0 +1,3 @@ +{ print $0; } +//{ gsub ("abc", "&&&&"); print $0; } + diff --git a/ase/test/awk/t3.awk b/ase/test/awk/t3.awk new file mode 100644 index 00000000..eb13d37d --- /dev/null +++ b/ase/test/awk/t3.awk @@ -0,0 +1,25 @@ +#global x, j; + +func func1 (x) +{ + c = x["abc"]; + x["abc"] = 123; +} + +BEGIN { + idx="abc"; + x[idx] = 12345; + i = x[idx]; + x["1"] = 1; + x["2"] = 2; + + func1 (x); + k = x[idx]; + return j; + + /* + x["abc"] = 12345; + i = x["abc"]; + return j; + */ +} diff --git a/ase/test/awk/t30.awk b/ase/test/awk/t30.awk new file mode 100644 index 00000000..4ee22397 --- /dev/null +++ b/ase/test/awk/t30.awk @@ -0,0 +1,3 @@ +#{ "dir/w/p" | getline; print $0; print "flush(dir/w/p)=", fflush("dir/w/p"); } +#{ print | "grep Asia"; fflush("grep Asia"); } +{ print | "grep Asia"; print "flush(grep Asia)=", fflush("grep Asia"); } diff --git a/ase/test/awk/t31.awk b/ase/test/awk/t31.awk new file mode 100644 index 00000000..a98a5db1 --- /dev/null +++ b/ase/test/awk/t31.awk @@ -0,0 +1,2 @@ +BEGIN { RS=""; } +{ print $0; } diff --git a/ase/test/awk/t32.awk b/ase/test/awk/t32.awk new file mode 100644 index 00000000..928de97f --- /dev/null +++ b/ase/test/awk/t32.awk @@ -0,0 +1,2 @@ +BEGIN { /*RS = "Asia";*/ /*RS=746;*/ /*RS="";*/ RS=/USA/; } +{ print NR, " ", $0; } diff --git a/ase/test/awk/t33.awk b/ase/test/awk/t33.awk new file mode 100644 index 00000000..8d711674 --- /dev/null +++ b/ase/test/awk/t33.awk @@ -0,0 +1,15 @@ +BEGIN { + ARGV[1] = 20; + print "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; + + delete NF; + print "NF[1]=", NF[1]; + + NF[1] = 20; # this line should not be allowed + print "AWK IMPLEMENTATION ERROR: hey... NF[1] = 20 has succeeded in the BEGIN block. your interpreter must be wrong"; + print "NF[1]=", NF[1]; +} + +{ + NF = 30; +} diff --git a/ase/test/awk/t34.awk b/ase/test/awk/t34.awk new file mode 100644 index 00000000..7e5e5b5c --- /dev/null +++ b/ase/test/awk/t34.awk @@ -0,0 +1 @@ +/* unterminated comment diff --git a/ase/test/awk/t35.awk b/ase/test/awk/t35.awk new file mode 100644 index 00000000..b7958ea9 --- /dev/null +++ b/ase/test/awk/t35.awk @@ -0,0 +1,4 @@ +BEGIN { + print //; + print / /; +} diff --git a/ase/test/awk/t36.awk b/ase/test/awk/t36.awk new file mode 100644 index 00000000..bacdcd8d --- /dev/null +++ b/ase/test/awk/t36.awk @@ -0,0 +1,47 @@ +# test cases +# +# input data [] +# result: +# NF=0 +# +# input data [abcdefg] +# NF=2 +# 0 [] +# 1 [bcdefg] +# +# input data [abdefg abcdefg] +# NF=3 +# 0 [] +# 1 [bdefg ] +# 2 [bcdefg] +# +# input data [ abcdefg hij a a] +# NF=4 +# 0 [ ] +# 1 [bcdefg hij ] +# 2 [ ] +# 3 [] +# +# input data [ abcdefg hij a a ] +# NF=4 +# 0 [ ] +# 1 [bcdefg hij ] +# 2 [ ] +# 3 [ ] +# +# input data [aaaaa] +# NF=6 +# 0 [] +# 1 [] +# 2 [] +# 3 [] +# 4 [] +# 5 [] +# + +BEGIN { FS="a"; } +{ + print "NF=" NF; + for (i = 0; i < NF; i++) print i " [" $(i+1) "]"; +} + diff --git a/ase/test/awk/t37.awk b/ase/test/awk/t37.awk new file mode 100644 index 00000000..fb022a8d --- /dev/null +++ b/ase/test/awk/t37.awk @@ -0,0 +1,6 @@ +BEGIN { FS=" "; } +{ + print "NF=" NF; + for (i = 0; i < NF; i++) print i " [" $(i+1) "]"; +} + diff --git a/ase/test/awk/t38.awk b/ase/test/awk/t38.awk new file mode 100644 index 00000000..78ea5c19 --- /dev/null +++ b/ase/test/awk/t38.awk @@ -0,0 +1,9 @@ + +BEGIN { + split (" a b c d e ", x, ""); + for (j in x) print j "->" x[j]; + print "-------------------"; + split ("a b c d e", x, "b c"); + for (j in x) print j "->" x[j]; + print "-------------------"; +} diff --git a/ase/test/awk/t39.awk b/ase/test/awk/t39.awk new file mode 100644 index 00000000..805f828f --- /dev/null +++ b/ase/test/awk/t39.awk @@ -0,0 +1,9 @@ +BEGIN { + FS="[:[:space:]]+"; + #FS=":+"; +} +{ + print "NF=" NF; + for (i = 0; i < NF; i++) print i " [" $(i+1) "]"; +} + diff --git a/ase/test/awk/t4.awk b/ase/test/awk/t4.awk new file mode 100644 index 00000000..707c75f7 --- /dev/null +++ b/ase/test/awk/t4.awk @@ -0,0 +1,21 @@ +function main (arg1, arg2, arg3) +{ + local i, k, c; + + for (i = 0; i < 10; i++) + { + abc[i*2] = i; + } + + k = 20; + + for (i = 0; i < 100; i++) + { + if (i in abc) j[i] = i; + } + + print arg1; + print arg2; + print arg3; + print "end of program"; +} diff --git a/ase/test/awk/t40.awk b/ase/test/awk/t40.awk new file mode 100644 index 00000000..d0fdfddc --- /dev/null +++ b/ase/test/awk/t40.awk @@ -0,0 +1,8 @@ +BEGIN { + FS="[a-c]+"; + IGNORECASE=0.1; +} +{ + print "NF=" NF; + for (i = 0; i < NF; i++) print i " [" $(i+1) "]"; +} diff --git a/ase/test/awk/t41.awk b/ase/test/awk/t41.awk new file mode 100644 index 00000000..6a82e3d1 --- /dev/null +++ b/ase/test/awk/t41.awk @@ -0,0 +1,4 @@ +BEGIN { IGNORECASE=1; } +$0 == "abc" { + print "[" $0 "]"; +} diff --git a/ase/test/awk/t42.awk b/ase/test/awk/t42.awk new file mode 100644 index 00000000..259c7bd2 --- /dev/null +++ b/ase/test/awk/t42.awk @@ -0,0 +1,13 @@ + +BEGIN { + FS=":"; + OFS="::"; +} + +{ + $2=1.23; + NF=4; + print "NF=" NF; + print "[" $10 "]"; + print "$0=[" $0 "]"; +} diff --git a/ase/test/awk/t43.awk b/ase/test/awk/t43.awk new file mode 100644 index 00000000..6b168030 --- /dev/null +++ b/ase/test/awk/t43.awk @@ -0,0 +1,3 @@ +#BEGIN { t = "abc"; gsub ("abc", "[&]", t); print t; } +{ gsub ("abc", "ABC"); print $0; } +{ gsub (/ABC/, "XYZ"); print $0; } diff --git a/ase/test/awk/t44.awk b/ase/test/awk/t44.awk new file mode 100644 index 00000000..f5dcb17c --- /dev/null +++ b/ase/test/awk/t44.awk @@ -0,0 +1,3 @@ +#BEGIN { t = "abc"; gsub ("abc", "[&]", t); print t; } +{ c=$0; print sub ("abc", "ABC", c); print c; } +{ sub (/ABC/, "XYZ", c); print c; } diff --git a/ase/test/awk/t45.awk b/ase/test/awk/t45.awk new file mode 100644 index 00000000..17fd5dbc --- /dev/null +++ b/ase/test/awk/t45.awk @@ -0,0 +1 @@ +BEGIN { t[1] = "abc"; gsub ("abc", "[&]", t); print t[1]; } diff --git a/ase/test/awk/t46.awk b/ase/test/awk/t46.awk new file mode 100644 index 00000000..2f4ee02c --- /dev/null +++ b/ase/test/awk/t46.awk @@ -0,0 +1 @@ +BEGIN { t = "whoabcabcabcwho"; gsub ("abc", "[\\&][&][\\&]", t); print t; } diff --git a/ase/test/awk/t47.awk b/ase/test/awk/t47.awk new file mode 100644 index 00000000..15831ab4 --- /dev/null +++ b/ase/test/awk/t47.awk @@ -0,0 +1,19 @@ +BEGIN { + + a[1] = 20; + a[2] = 40; + a[3,5,6] = 40; + a["abc"] = 20; + + for (i in a) print "a[" i "]=" a[i]; + #SUBSEP=",,,"; + SUBSEP=4.5; + #SUBSEP=555; + + print "------------------------"; + + a[9,x,3] = 40; + for (i in a) print "a[" i "]=" a[i]; +} + + diff --git a/ase/test/awk/t48.awk b/ase/test/awk/t48.awk new file mode 100644 index 00000000..7ac01c7a --- /dev/null +++ b/ase/test/awk/t48.awk @@ -0,0 +1,3 @@ +BEGIN { + print ("xx" in j); +} diff --git a/ase/test/awk/t49.awk b/ase/test/awk/t49.awk new file mode 100644 index 00000000..6b907471 --- /dev/null +++ b/ase/test/awk/t49.awk @@ -0,0 +1,5 @@ +BEGIN { OFS=":"; } +{ + print $5 = "abc"; + print $0; +} diff --git a/ase/test/awk/t5.awk b/ase/test/awk/t5.awk new file mode 100644 index 00000000..120ca533 --- /dev/null +++ b/ase/test/awk/t5.awk @@ -0,0 +1,10 @@ +BEGIN { + x[1] = 20; + x[2] = 40; + x[3] = 50; + + for (i in x) + { + j[i] = i; + } +} diff --git a/ase/test/awk/t50.awk b/ase/test/awk/t50.awk new file mode 100644 index 00000000..b6258c84 --- /dev/null +++ b/ase/test/awk/t50.awk @@ -0,0 +1,6 @@ +BEGIN { + two = 2; three = 3; + print (two three) + 4; +} + + diff --git a/ase/test/awk/t6.awk b/ase/test/awk/t6.awk new file mode 100644 index 00000000..281567d5 --- /dev/null +++ b/ase/test/awk/t6.awk @@ -0,0 +1,21 @@ +BEGIN { + j = -20; + + for (i = -10; i < 10; i++) + { + if (i == 5) exit; + #if (i == 5) break; + } + + + while (j < 10) + { + if (j == 5) break; + j++; + } +} + +END { + print "i = ", i; + print "j = ", j; +} diff --git a/ase/test/awk/t7.awk b/ase/test/awk/t7.awk new file mode 100644 index 00000000..8a431564 --- /dev/null +++ b/ase/test/awk/t7.awk @@ -0,0 +1,5 @@ +BEGIN { i = 20; j = 0; } +{ i++; /*i = i + 1;*/ } +i % 2 { /*j ++;*/ j = j + 1; } +/*"1","2" || "Yes" {}*/ +/*END { i = i + 1234; j = j + 1234; }*/ diff --git a/ase/test/awk/t8.awk b/ase/test/awk/t8.awk new file mode 100644 index 00000000..fd0cbe73 --- /dev/null +++ b/ase/test/awk/t8.awk @@ -0,0 +1,2 @@ +BEGIN { 10; 20; 30; i = 40; i++; } + diff --git a/ase/test/awk/t9.awk b/ase/test/awk/t9.awk new file mode 100644 index 00000000..bf5b5414 --- /dev/null +++ b/ase/test/awk/t9.awk @@ -0,0 +1,25 @@ +BEGIN { + while (("xxx /p" | getline var) > 0) ; + while (("dir /w" | getline var) > 0) ; + while ((getline var < "t9.awk") > 0) ; + + zzz = close ("xxx /p"); + /* + while ("ls -l" | getline var) + { + "ls -l" | getline x; + print var; print x; + } + + while (getline < "/etc/passwd") + { + print $0; + } + + while (getline x < "/etc/shadow") + { + print x; + } + */ +} + diff --git a/ase/test/awk/unr-001.awk b/ase/test/awk/unr-001.awk new file mode 100644 index 00000000..6eb3de07 --- /dev/null +++ b/ase/test/awk/unr-001.awk @@ -0,0 +1,6 @@ +# use negnum.data +BEGIN { OFS="\t"; } +{ + for (i = 1; i <= NF; i = i + 1) if ($i < 0) $i = -$i; + print; +} diff --git a/ase/test/awk/wordfreq.awk b/ase/test/awk/wordfreq.awk new file mode 100644 index 00000000..4e922ab3 --- /dev/null +++ b/ase/test/awk/wordfreq.awk @@ -0,0 +1,20 @@ +# wordfreq.awk --- print list of word frequencies + +{ + $0 = tolower($0); # remove case distinctions + + # remove punctuation + a=0; + gsub(/[^[:alnum:]_[:blank:]]/, " ", $a); + #gsub(/[^[:alnum:]_[:blank:]]/, " "); + + for (i = 1; i <= NF; i++) freq[$i]++; +} +#/[^kkka-bcx-dd-y]|abc|def/ + +END { + for (word in freq) + print word, freq[word]; +} + + diff --git a/ase/test/awk/x.awk b/ase/test/awk/x.awk new file mode 100644 index 00000000..3861eba6 --- /dev/null +++ b/ase/test/awk/x.awk @@ -0,0 +1,31 @@ + +#main () +{ + #print (("%f", 1.0)); # syntax error + print ((10) + 20 * 4); + print ((10) + 20 * 4, (20), (30)); + print (10) + 20 * 4, (20), (30); + print (("%f", 1.0) in x); + + print ("%f", 1.0); + #print ("%f", 1.0), 1; # syntax error + print ("%f", 1.0) in x, 1; + print ((((10) + 20))); + print ((10) + 20, 50); +} + +BEGIN { + #print 1 + #| + #"test"; +# */ + + #print 1 | + # 1; + + print .0; + print 10; + + print fflush ("abc"); +} + diff --git a/ase/test/cnt/AwkForm.Designer.cs b/ase/test/cnt/AwkForm.Designer.cs new file mode 100644 index 00000000..de9552a9 --- /dev/null +++ b/ase/test/cnt/AwkForm.Designer.cs @@ -0,0 +1,381 @@ +namespace ASETestCNT +{ + partial class AwkForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.tbxSourceInput = new System.Windows.Forms.TextBox(); + this.btnRun = new System.Windows.Forms.Button(); + this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.panel1 = new System.Windows.Forms.Panel(); + this.label1 = new System.Windows.Forms.Label(); + this.panel3 = new System.Windows.Forms.Panel(); + this.tbxSourceOutput = new System.Windows.Forms.TextBox(); + this.label2 = new System.Windows.Forms.Label(); + this.panel4 = new System.Windows.Forms.Panel(); + this.tbxConsoleInput = new System.Windows.Forms.TextBox(); + this.label3 = new System.Windows.Forms.Label(); + this.panel5 = new System.Windows.Forms.Panel(); + this.tbxConsoleOutput = new System.Windows.Forms.TextBox(); + this.label4 = new System.Windows.Forms.Label(); + this.statusStrip1 = new System.Windows.Forms.StatusStrip(); + this.cbxEntryPoint = new System.Windows.Forms.ComboBox(); + this.panel2 = new System.Windows.Forms.Panel(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.chkPassArgumentsToEntryPoint = new System.Windows.Forms.CheckBox(); + this.btnClearAllArguments = new System.Windows.Forms.Button(); + this.btnAddArgument = new System.Windows.Forms.Button(); + this.tbxArgument = new System.Windows.Forms.TextBox(); + this.lbxArguments = new System.Windows.Forms.ListBox(); + this.tableLayoutPanel1.SuspendLayout(); + this.panel1.SuspendLayout(); + this.panel3.SuspendLayout(); + this.panel4.SuspendLayout(); + this.panel5.SuspendLayout(); + this.panel2.SuspendLayout(); + this.groupBox2.SuspendLayout(); + this.groupBox1.SuspendLayout(); + this.SuspendLayout(); + // + // tbxSourceInput + // + this.tbxSourceInput.Dock = System.Windows.Forms.DockStyle.Fill; + this.tbxSourceInput.Location = new System.Drawing.Point(0, 19); + this.tbxSourceInput.Multiline = true; + this.tbxSourceInput.Name = "tbxSourceInput"; + this.tbxSourceInput.ScrollBars = System.Windows.Forms.ScrollBars.Both; + this.tbxSourceInput.Size = new System.Drawing.Size(240, 230); + this.tbxSourceInput.TabIndex = 1; + this.tbxSourceInput.WordWrap = false; + // + // btnRun + // + this.btnRun.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btnRun.Location = new System.Drawing.Point(76, 303); + this.btnRun.Name = "btnRun"; + this.btnRun.Size = new System.Drawing.Size(75, 23); + this.btnRun.TabIndex = 2; + this.btnRun.Text = "Run"; + this.btnRun.UseVisualStyleBackColor = true; + this.btnRun.Click += new System.EventHandler(this.btnRun_Click); + // + // tableLayoutPanel1 + // + this.tableLayoutPanel1.ColumnCount = 2; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel1.Controls.Add(this.panel1, 0, 0); + this.tableLayoutPanel1.Controls.Add(this.panel3, 1, 0); + this.tableLayoutPanel1.Controls.Add(this.panel4, 0, 1); + this.tableLayoutPanel1.Controls.Add(this.panel5, 1, 1); + this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel1.Location = new System.Drawing.Point(157, 0); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.RowCount = 2; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel1.Size = new System.Drawing.Size(492, 510); + this.tableLayoutPanel1.TabIndex = 2; + // + // panel1 + // + this.panel1.Controls.Add(this.tbxSourceInput); + this.panel1.Controls.Add(this.label1); + this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel1.Location = new System.Drawing.Point(3, 3); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(240, 249); + this.panel1.TabIndex = 5; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Dock = System.Windows.Forms.DockStyle.Top; + this.label1.Location = new System.Drawing.Point(0, 0); + this.label1.Name = "label1"; + this.label1.Padding = new System.Windows.Forms.Padding(0, 3, 0, 3); + this.label1.Size = new System.Drawing.Size(68, 19); + this.label1.TabIndex = 2; + this.label1.Text = "Source Input"; + // + // panel3 + // + this.panel3.Controls.Add(this.tbxSourceOutput); + this.panel3.Controls.Add(this.label2); + this.panel3.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel3.Location = new System.Drawing.Point(249, 3); + this.panel3.Name = "panel3"; + this.panel3.Size = new System.Drawing.Size(240, 249); + this.panel3.TabIndex = 6; + // + // tbxSourceOutput + // + this.tbxSourceOutput.Dock = System.Windows.Forms.DockStyle.Fill; + this.tbxSourceOutput.Location = new System.Drawing.Point(0, 19); + this.tbxSourceOutput.Multiline = true; + this.tbxSourceOutput.Name = "tbxSourceOutput"; + this.tbxSourceOutput.ReadOnly = true; + this.tbxSourceOutput.ScrollBars = System.Windows.Forms.ScrollBars.Both; + this.tbxSourceOutput.Size = new System.Drawing.Size(240, 230); + this.tbxSourceOutput.TabIndex = 2; + this.tbxSourceOutput.WordWrap = false; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Dock = System.Windows.Forms.DockStyle.Top; + this.label2.Location = new System.Drawing.Point(0, 0); + this.label2.Name = "label2"; + this.label2.Padding = new System.Windows.Forms.Padding(0, 3, 0, 3); + this.label2.Size = new System.Drawing.Size(76, 19); + this.label2.TabIndex = 0; + this.label2.Text = "Source Output"; + // + // panel4 + // + this.panel4.Controls.Add(this.tbxConsoleInput); + this.panel4.Controls.Add(this.label3); + this.panel4.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel4.Location = new System.Drawing.Point(3, 258); + this.panel4.Name = "panel4"; + this.panel4.Size = new System.Drawing.Size(240, 249); + this.panel4.TabIndex = 7; + // + // tbxConsoleInput + // + this.tbxConsoleInput.Dock = System.Windows.Forms.DockStyle.Fill; + this.tbxConsoleInput.Location = new System.Drawing.Point(0, 19); + this.tbxConsoleInput.Multiline = true; + this.tbxConsoleInput.Name = "tbxConsoleInput"; + this.tbxConsoleInput.ScrollBars = System.Windows.Forms.ScrollBars.Both; + this.tbxConsoleInput.Size = new System.Drawing.Size(240, 230); + this.tbxConsoleInput.TabIndex = 3; + this.tbxConsoleInput.WordWrap = false; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Dock = System.Windows.Forms.DockStyle.Top; + this.label3.Location = new System.Drawing.Point(0, 0); + this.label3.Name = "label3"; + this.label3.Padding = new System.Windows.Forms.Padding(0, 3, 0, 3); + this.label3.Size = new System.Drawing.Size(72, 19); + this.label3.TabIndex = 0; + this.label3.Text = "Console Input"; + // + // panel5 + // + this.panel5.Controls.Add(this.tbxConsoleOutput); + this.panel5.Controls.Add(this.label4); + this.panel5.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel5.Location = new System.Drawing.Point(249, 258); + this.panel5.Name = "panel5"; + this.panel5.Size = new System.Drawing.Size(240, 249); + this.panel5.TabIndex = 8; + // + // tbxConsoleOutput + // + this.tbxConsoleOutput.Dock = System.Windows.Forms.DockStyle.Fill; + this.tbxConsoleOutput.Location = new System.Drawing.Point(0, 19); + this.tbxConsoleOutput.Multiline = true; + this.tbxConsoleOutput.Name = "tbxConsoleOutput"; + this.tbxConsoleOutput.ReadOnly = true; + this.tbxConsoleOutput.ScrollBars = System.Windows.Forms.ScrollBars.Both; + this.tbxConsoleOutput.Size = new System.Drawing.Size(240, 230); + this.tbxConsoleOutput.TabIndex = 4; + this.tbxConsoleOutput.WordWrap = false; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Dock = System.Windows.Forms.DockStyle.Top; + this.label4.Location = new System.Drawing.Point(0, 0); + this.label4.Name = "label4"; + this.label4.Padding = new System.Windows.Forms.Padding(0, 3, 0, 3); + this.label4.Size = new System.Drawing.Size(80, 19); + this.label4.TabIndex = 0; + this.label4.Text = "Console Output"; + // + // statusStrip1 + // + this.statusStrip1.Location = new System.Drawing.Point(0, 510); + this.statusStrip1.Name = "statusStrip1"; + this.statusStrip1.Size = new System.Drawing.Size(649, 22); + this.statusStrip1.TabIndex = 3; + this.statusStrip1.Text = "statusStrip1"; + // + // cbxEntryPoint + // + this.cbxEntryPoint.Dock = System.Windows.Forms.DockStyle.Fill; + this.cbxEntryPoint.FormattingEnabled = true; + this.cbxEntryPoint.Location = new System.Drawing.Point(3, 16); + this.cbxEntryPoint.Name = "cbxEntryPoint"; + this.cbxEntryPoint.Size = new System.Drawing.Size(147, 21); + this.cbxEntryPoint.TabIndex = 1; + // + // panel2 + // + this.panel2.AutoScroll = true; + this.panel2.Controls.Add(this.btnRun); + this.panel2.Controls.Add(this.groupBox2); + this.panel2.Controls.Add(this.groupBox1); + this.panel2.Dock = System.Windows.Forms.DockStyle.Left; + this.panel2.Location = new System.Drawing.Point(0, 0); + this.panel2.Name = "panel2"; + this.panel2.Size = new System.Drawing.Size(157, 510); + this.panel2.TabIndex = 5; + // + // groupBox2 + // + this.groupBox2.Controls.Add(this.cbxEntryPoint); + this.groupBox2.Location = new System.Drawing.Point(0, 4); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Size = new System.Drawing.Size(153, 45); + this.groupBox2.TabIndex = 1; + this.groupBox2.TabStop = false; + this.groupBox2.Text = "Entry Point"; + // + // groupBox1 + // + this.groupBox1.AutoSize = true; + this.groupBox1.Controls.Add(this.chkPassArgumentsToEntryPoint); + this.groupBox1.Controls.Add(this.btnClearAllArguments); + this.groupBox1.Controls.Add(this.btnAddArgument); + this.groupBox1.Controls.Add(this.tbxArgument); + this.groupBox1.Controls.Add(this.lbxArguments); + this.groupBox1.Location = new System.Drawing.Point(0, 51); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(154, 247); + this.groupBox1.TabIndex = 0; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Arguments"; + // + // chkPassArgumentsToEntryPoint + // + this.chkPassArgumentsToEntryPoint.AutoSize = true; + this.chkPassArgumentsToEntryPoint.Location = new System.Drawing.Point(19, 211); + this.chkPassArgumentsToEntryPoint.Name = "chkPassArgumentsToEntryPoint"; + this.chkPassArgumentsToEntryPoint.Size = new System.Drawing.Size(119, 17); + this.chkPassArgumentsToEntryPoint.TabIndex = 4; + this.chkPassArgumentsToEntryPoint.Text = "Pass To Entry Point"; + this.chkPassArgumentsToEntryPoint.UseVisualStyleBackColor = true; + // + // btnClearAllArguments + // + this.btnClearAllArguments.Location = new System.Drawing.Point(3, 181); + this.btnClearAllArguments.Name = "btnClearAllArguments"; + this.btnClearAllArguments.Size = new System.Drawing.Size(145, 22); + this.btnClearAllArguments.TabIndex = 3; + this.btnClearAllArguments.Text = "Clear All"; + this.btnClearAllArguments.UseVisualStyleBackColor = true; + this.btnClearAllArguments.Click += new System.EventHandler(this.btnClearAllArguments_Click); + // + // btnAddArgument + // + this.btnAddArgument.Location = new System.Drawing.Point(87, 154); + this.btnAddArgument.Name = "btnAddArgument"; + this.btnAddArgument.Size = new System.Drawing.Size(61, 22); + this.btnAddArgument.TabIndex = 2; + this.btnAddArgument.Text = "Add"; + this.btnAddArgument.UseVisualStyleBackColor = true; + this.btnAddArgument.Click += new System.EventHandler(this.btnAddArgument_Click); + // + // tbxArgument + // + this.tbxArgument.Location = new System.Drawing.Point(3, 155); + this.tbxArgument.Name = "tbxArgument"; + this.tbxArgument.Size = new System.Drawing.Size(83, 20); + this.tbxArgument.TabIndex = 1; + // + // lbxArguments + // + this.lbxArguments.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.lbxArguments.FormattingEnabled = true; + this.lbxArguments.Location = new System.Drawing.Point(3, 16); + this.lbxArguments.Name = "lbxArguments"; + this.lbxArguments.Size = new System.Drawing.Size(147, 134); + this.lbxArguments.TabIndex = 0; + // + // AwkForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(649, 532); + this.Controls.Add(this.tableLayoutPanel1); + this.Controls.Add(this.panel2); + this.Controls.Add(this.statusStrip1); + this.Name = "AwkForm"; + this.Text = "ASE.CNT.AWK"; + this.tableLayoutPanel1.ResumeLayout(false); + this.panel1.ResumeLayout(false); + this.panel1.PerformLayout(); + this.panel3.ResumeLayout(false); + this.panel3.PerformLayout(); + this.panel4.ResumeLayout(false); + this.panel4.PerformLayout(); + this.panel5.ResumeLayout(false); + this.panel5.PerformLayout(); + this.panel2.ResumeLayout(false); + this.panel2.PerformLayout(); + this.groupBox2.ResumeLayout(false); + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TextBox tbxSourceInput; + private System.Windows.Forms.Button btnRun; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.TextBox tbxSourceOutput; + private System.Windows.Forms.TextBox tbxConsoleInput; + private System.Windows.Forms.TextBox tbxConsoleOutput; + private System.Windows.Forms.StatusStrip statusStrip1; + private System.Windows.Forms.ComboBox cbxEntryPoint; + private System.Windows.Forms.Panel panel2; + private System.Windows.Forms.GroupBox groupBox1; + private System.Windows.Forms.Button btnClearAllArguments; + private System.Windows.Forms.Button btnAddArgument; + private System.Windows.Forms.TextBox tbxArgument; + private System.Windows.Forms.ListBox lbxArguments; + private System.Windows.Forms.CheckBox chkPassArgumentsToEntryPoint; + private System.Windows.Forms.GroupBox groupBox2; + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Panel panel3; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Panel panel4; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Panel panel5; + private System.Windows.Forms.Label label4; + } +} diff --git a/ase/test/cnt/AwkForm.cs b/ase/test/cnt/AwkForm.cs new file mode 100644 index 00000000..4ff5545f --- /dev/null +++ b/ase/test/cnt/AwkForm.cs @@ -0,0 +1,87 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; +using System.IO; + +namespace ASETestCNT +{ + public partial class AwkForm : Form + { + public AwkForm() + { + InitializeComponent(); + } + + private void btnRun_Click(object sender, EventArgs e) + { + ASECNT.Awk awk = new ASECNT.StdAwk (); + + //System.Text.Encoding.Default + awk.SourceInputStream = new MemoryStream (UnicodeEncoding.UTF8.GetBytes(tbxSourceInput.Text)); + awk.SourceOutputStream = new MemoryStream(); + + awk.ConsoleInputStream = new MemoryStream(UnicodeEncoding.UTF8.GetBytes(tbxConsoleInput.Text)); + awk.ConsoleOutputStream = new MemoryStream(); + + tbxSourceOutput.Text = ""; + tbxConsoleOutput.Text = ""; + + if (!awk.Parse()) + { + MessageBox.Show(awk.ErrorMessage); + } + else + { + MemoryStream s = (MemoryStream)awk.SourceOutputStream; + tbxSourceOutput.Text = UnicodeEncoding.UTF8.GetString(s.GetBuffer()); + + awk.EntryPoint = cbxEntryPoint.Text; + awk.ArgumentsToEntryPoint = chkPassArgumentsToEntryPoint.Checked; + + bool n; + int nargs = lbxArguments.Items.Count; + if (nargs > 0) + { + string[] args = new string[nargs]; + for (int i = 0; i < nargs; i++) + args[i] = lbxArguments.Items[i].ToString(); + n = awk.Run(args); + } + else n = awk.Run(); + + if (!n) + { + MessageBox.Show(awk.ErrorMessage); + } + else + { + MemoryStream c = (MemoryStream)awk.ConsoleOutputStream; + tbxConsoleOutput.Text = UnicodeEncoding.UTF8.GetString(c.GetBuffer()); + } + } + + //awk.Close(); + } + + + private void btnAddArgument_Click(object sender, EventArgs e) + { + if (tbxArgument.Text.Length > 0) + { + lbxArguments.Items.Add(tbxArgument.Text); + tbxArgument.Text = ""; + tbxArgument.Focus(); + } + } + + private void btnClearAllArguments_Click(object sender, EventArgs e) + { + lbxArguments.Items.Clear(); + } + + } +} diff --git a/ase/test/cnt/AwkForm.resx b/ase/test/cnt/AwkForm.resx new file mode 100644 index 00000000..b9c202bf --- /dev/null +++ b/ase/test/cnt/AwkForm.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/ase/test/cnt/Program.cs b/ase/test/cnt/Program.cs new file mode 100644 index 00000000..6605bd61 --- /dev/null +++ b/ase/test/cnt/Program.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Windows.Forms; + +namespace ASETestCNT +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new AwkForm()); + } + } +} diff --git a/ase/test/cnt/Properties/AssemblyInfo.cs b/ase/test/cnt/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..7b0ced58 --- /dev/null +++ b/ase/test/cnt/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("asecnt")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("asecnt")] +[assembly: AssemblyCopyright("© 2007 Hyung-Hwan Chung, All rights reserved.")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("7cd62543-7cf6-4b69-90b9-be0becdbfa19")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/ase/test/cnt/Properties/Resources.Designer.cs b/ase/test/cnt/Properties/Resources.Designer.cs new file mode 100644 index 00000000..23555039 --- /dev/null +++ b/ase/test/cnt/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace ASETestCNT.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ASETestCNT.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/ase/test/cnt/Properties/Resources.resx b/ase/test/cnt/Properties/Resources.resx new file mode 100644 index 00000000..af7dbebb --- /dev/null +++ b/ase/test/cnt/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ase/test/cnt/Properties/Settings.Designer.cs b/ase/test/cnt/Properties/Settings.Designer.cs new file mode 100644 index 00000000..a80bab69 --- /dev/null +++ b/ase/test/cnt/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace ASETestCNT.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git a/ase/test/cnt/Properties/Settings.settings b/ase/test/cnt/Properties/Settings.settings new file mode 100644 index 00000000..39645652 --- /dev/null +++ b/ase/test/cnt/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/ase/test/cnt/asetestcnt.csproj b/ase/test/cnt/asetestcnt.csproj new file mode 100644 index 00000000..f36f9922 --- /dev/null +++ b/ase/test/cnt/asetestcnt.csproj @@ -0,0 +1,89 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {F14B75D8-3ED7-4621-B5B9-E96A80B5D809} + WinExe + Properties + ASETestCNT + asecnt + + + true + full + false + ..\..\Debug\bin\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + ..\..\Release\bin\ + TRACE + prompt + 4 + + + + False + obj\Release\Interop.ASECOM.dll + + + + + + + + + + + Form + + + AwkForm.cs + + + + + Designer + AwkForm.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + True + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + {7F679165-41FB-4E1E-B3F5-23C5EE94166A} + asecnt + + + + + \ No newline at end of file diff --git a/ase/test/com/AwkExtioConsole.cls b/ase/test/com/AwkExtioConsole.cls new file mode 100644 index 00000000..e50d409a --- /dev/null +++ b/ase/test/com/AwkExtioConsole.cls @@ -0,0 +1,32 @@ +VERSION 1.0 CLASS +BEGIN + MultiUse = -1 'True + Persistable = 0 'NotPersistable + DataBindingBehavior = 0 'vbNone + DataSourceBehavior = 0 'vbNone + MTSTransactionMode = 0 'NotAnMTSObject +END +Attribute VB_Name = "AwkExtioConsole" +Attribute VB_GlobalNameSpace = False +Attribute VB_Creatable = True +Attribute VB_PredeclaredId = False +Attribute VB_Exposed = False +Private m_eof As Boolean + +Private Sub Class_Initialize() + m_eof = False + 'MsgBox "AwkExtio Initializeing" +End Sub + +Private Sub Class_Terminate() + 'MsgBox "AwkExtio Terminating..." +End Sub + +Public Property Let EOF(v As Boolean) + m_eof = v +End Property + +Public Property Get EOF() As Boolean + EOF = m_eof +End Property + diff --git a/ase/test/com/AwkForm.frm b/ase/test/com/AwkForm.frm new file mode 100644 index 00000000..039c1037 --- /dev/null +++ b/ase/test/com/AwkForm.frm @@ -0,0 +1,552 @@ +VERSION 5.00 +Begin VB.Form AwkForm + BorderStyle = 1 'Fixed Single + Caption = "ASE.COM.AWK" + ClientHeight = 8100 + ClientLeft = 45 + ClientTop = 330 + ClientWidth = 12900 + LinkTopic = "AwkForm" + MaxButton = 0 'False + MinButton = 0 'False + ScaleHeight = 8100 + ScaleWidth = 12900 + StartUpPosition = 3 'Windows Default + Begin VB.CommandButton btnClearAll + Caption = "Clear All" + Height = 375 + Left = 240 + TabIndex = 14 + Top = 4560 + Width = 2295 + End + Begin VB.CommandButton btnAddArgument + Caption = "Add" + Height = 375 + Left = 1920 + TabIndex = 12 + Top = 4080 + Width = 615 + End + Begin VB.TextBox txtArgument + Height = 375 + Left = 240 + TabIndex = 11 + Top = 4080 + Width = 1575 + End + Begin VB.ListBox lstArguments + Height = 2595 + Left = 240 + TabIndex = 10 + Top = 1320 + Width = 2295 + End + Begin VB.ComboBox EntryPoint + Height = 315 + ItemData = "AwkForm.frx":0000 + Left = 240 + List = "AwkForm.frx":0007 + TabIndex = 9 + Top = 480 + Width = 2295 + End + Begin VB.TextBox ConsoleIn + BeginProperty Font + Name = "Courier New" + Size = 9 + Charset = 0 + Weight = 400 + Underline = 0 'False + Italic = 0 'False + Strikethrough = 0 'False + EndProperty + Height = 3735 + Left = 2760 + MultiLine = -1 'True + ScrollBars = 3 'Both + TabIndex = 2 + Top = 4320 + Width = 5055 + End + Begin VB.TextBox SourceIn + BeginProperty Font + Name = "Courier New" + Size = 9 + Charset = 0 + Weight = 400 + Underline = 0 'False + Italic = 0 'False + Strikethrough = 0 'False + EndProperty + Height = 3615 + Left = 2760 + MultiLine = -1 'True + ScrollBars = 3 'Both + TabIndex = 0 + Top = 360 + Width = 5055 + End + Begin VB.TextBox SourceOut + BeginProperty Font + Name = "Courier New" + Size = 9 + Charset = 0 + Weight = 400 + Underline = 0 'False + Italic = 0 'False + Strikethrough = 0 'False + EndProperty + Height = 3615 + Left = 7920 + Locked = -1 'True + MultiLine = -1 'True + ScrollBars = 3 'Both + TabIndex = 1 + Top = 360 + Width = 4935 + End + Begin VB.CommandButton btnExecute + Caption = "Execute" + Height = 375 + Left = 1440 + TabIndex = 5 + Top = 7680 + Width = 1215 + End + Begin VB.TextBox ConsoleOut + BeginProperty Font + Name = "Courier New" + Size = 9 + Charset = 0 + Weight = 400 + Underline = 0 'False + Italic = 0 'False + Strikethrough = 0 'False + EndProperty + Height = 3735 + Left = 7920 + MultiLine = -1 'True + ScrollBars = 3 'Both + TabIndex = 3 + Top = 4320 + Width = 4935 + End + Begin VB.Frame Frame1 + Caption = "Arguments" + Height = 4335 + Left = 120 + TabIndex = 13 + Top = 1080 + Width = 2535 + Begin VB.CheckBox chkPassToEntryPoint + Caption = "Pass To Entry Point" + Height = 255 + Left = 360 + TabIndex = 16 + Top = 3960 + Width = 1815 + End + End + Begin VB.Frame Frame2 + Caption = "Entry Point" + Height = 855 + Left = 120 + TabIndex = 15 + Top = 120 + Width = 2535 + End + Begin VB.Label Label4 + Caption = "Console Out" + Height = 255 + Left = 7920 + TabIndex = 8 + Top = 4080 + Width = 3735 + End + Begin VB.Label Label3 + Caption = "Console In" + Height = 255 + Left = 2760 + TabIndex = 7 + Top = 4080 + Width = 3735 + End + Begin VB.Label Label2 + Caption = "Source Out" + Height = 255 + Left = 7920 + TabIndex = 6 + Top = 120 + Width = 3735 + End + Begin VB.Label Label1 + Caption = "Source In" + Height = 255 + Left = 2760 + TabIndex = 4 + Top = 120 + Width = 2415 + End +End +Attribute VB_Name = "AwkForm" +Attribute VB_GlobalNameSpace = False +Attribute VB_Creatable = False +Attribute VB_PredeclaredId = True +Attribute VB_Exposed = False +Option Explicit +Option Base 0 +Dim source_first As Boolean +Public WithEvents Awk As ASECOM.Awk +Attribute Awk.VB_VarHelpID = -1 + +Private Sub btnAddArgument_Click() + Dim arg As String + + arg = txtArgument.Text + If Len(arg) > 0 Then + lstArguments.AddItem (arg) + txtArgument.Text = "" + txtArgument.SetFocus + End If +End Sub + +Private Sub btnClearAll_Click() + lstArguments.Clear +End Sub + +Private Sub btnExecute_Click() + + source_first = True + + ConsoleOut.Text = "" + SourceOut.Text = "" + + Set Awk = New ASECOM.Awk + + Awk.ExplicitVariable = True + Awk.ImplicitVariable = True + Awk.UseCrlf = True + Awk.IdivOperator = True + Awk.ShiftOperators = True + + Awk.MaxDepthForBlockParse = 20 + Awk.MaxDepthForBlockRun = 30 + Awk.MaxDepthForExprParse = 20 + Awk.MaxDepthForExprRun = 30 + 'Awk.MaxDepthForRexBuild = 10 + 'Awk.MaxDepthForRexMatch = 10 + + Awk.UseLongLong = False + Awk.Debug = True + + If Not Awk.AddFunction("sin", 1, 1) Then + MsgBox "Cannot add builtin function - " + Awk.ErrorMessage + Exit Sub + End If + If Not Awk.AddFunction("cos", 1, 1) Then + MsgBox "Cannot add builtin function - " + Awk.ErrorMessage + Exit Sub + End If + Call Awk.AddFunction("tan", 1, 1) + Call Awk.AddFunction("sqrt", 1, 1) + Call Awk.AddFunction("trim", 1, 1) + 'Call Awk.DeleteFunction("tan") + + If Not Awk.Parse() Then + MsgBox "PARSE ERROR [" + Str(Awk.ErrorLine) + "]" + Awk.ErrorMessage + Else + Dim n As Boolean + + Awk.EntryPoint = Trim(EntryPoint.Text) + + If lstArguments.ListCount = 0 Then + n = Awk.Run(Null) + Else + ReDim Args(lstArguments.ListCount - 1) As String + Dim i As Integer + + Awk.ArgumentsToEntryPoint = chkPassToEntryPoint.value + + For i = 0 To lstArguments.ListCount - 1 + Args(i) = lstArguments.List(i) + Next i + + n = Awk.Run(Args) + End If + + If Not n Then + MsgBox "RUN ERROR [" + Str(Awk.ErrorLine) + "]" + Awk.ErrorMessage + End If + End If + + Set Awk = Nothing + +End Sub + +Function Awk_OpenSource(ByVal mode As ASECOM.AwkSourceMode) As Long + Awk_OpenSource = 1 +End Function + +Function Awk_CloseSource(ByVal mode As ASECOM.AwkSourceMode) As Long + Awk_CloseSource = 0 +End Function + +Function Awk_ReadSource(ByVal buf As ASECOM.Buffer) As Long + If source_first Then + buf.value = SourceIn.Text + Awk_ReadSource = Len(buf.value) + source_first = False + Else + Awk_ReadSource = 0 + End If +End Function + +Function Awk_WriteSource(ByVal buf As ASECOM.Buffer) As Long + Dim value As String + Dim l As Integer + + value = buf.value + l = Len(value) + SourceOut.Text = SourceOut.Text + value + Awk_WriteSource = Len(value) +End Function + +Function Awk_OpenExtio(ByVal extio As ASECOM.AwkExtio) As Long + Awk_OpenExtio = -1 + + Select Case extio.Type + Case ASECOM.AWK_EXTIO_CONSOLE + If extio.mode = ASECOM.AWK_EXTIO_CONSOLE_READ Then + extio.Handle = New AwkExtioConsole + With extio.Handle + .EOF = False + End With + Awk_OpenExtio = 1 + ElseIf extio.mode = ASECOM.AWK_EXTIO_CONSOLE_WRITE Then + extio.Handle = New AwkExtioConsole + With extio.Handle + .EOF = False + End With + Awk_OpenExtio = 1 + End If + + Case ASECOM.AWK_EXTIO_FILE + If extio.mode = ASECOM.AWK_EXTIO_FILE_READ Then + extio.Handle = FreeFile + On Error GoTo ErrorTrap + Open extio.name For Input As #extio.Handle + On Error GoTo 0 + Awk_OpenExtio = 1 + ElseIf extio.mode = ASECOM.AWK_EXTIO_FILE_WRITE Then + extio.Handle = FreeFile + On Error GoTo ErrorTrap + Open extio.name For Output As #extio.Handle + On Error GoTo 0 + Awk_OpenExtio = 1 + ElseIf extio.mode = ASECOM.AWK_EXTIO_FILE_APPEND Then + extio.Handle = FreeFile + On Error GoTo ErrorTrap + Open extio.name For Append As #extio.Handle + On Error GoTo 0 + Awk_OpenExtio = 1 + End If + + Case ASECOM.AWK_EXTIO_PIPE + Awk_OpenExtio = -1 + Case ASECOM.AWK_EXTIO_COPROC + Awk_OpenExtio = -1 + End Select + + Exit Function + +ErrorTrap: + Exit Function +End Function + +Function Awk_CloseExtio(ByVal extio As ASECOM.AwkExtio) As Long + Awk_CloseExtio = -1 + + Select Case extio.Type + Case ASECOM.AWK_EXTIO_CONSOLE + If extio.mode = ASECOM.AWK_EXTIO_CONSOLE_READ Or _ + extio.mode = ASECOM.AWK_EXTIO_CONSOLE_WRITE Then + extio.Handle = Nothing + Awk_CloseExtio = 0 + End If + Case ASECOM.AWK_EXTIO_FILE + If extio.mode = ASECOM.AWK_EXTIO_FILE_READ Or _ + extio.mode = ASECOM.AWK_EXTIO_FILE_WRITE Or _ + extio.mode = ASECOM.AWK_EXTIO_FILE_APPEND Then + Close #extio.Handle + Awk_CloseExtio = 0 + End If + Case ASECOM.AWK_EXTIO_PIPE + Awk_CloseExtio = -1 + Case ASECOM.AWK_EXTIO_COPROC + Awk_CloseExtio = -1 + End Select + +End Function + +Function Awk_ReadExtio(ByVal extio As ASECOM.AwkExtio, ByVal buf As ASECOM.Buffer) As Long + Awk_ReadExtio = -1 + + Select Case extio.Type + Case ASECOM.AWK_EXTIO_CONSOLE + If extio.mode = ASECOM.AWK_EXTIO_CONSOLE_READ Then + Awk_ReadExtio = ReadExtioConsole(extio, buf) + End If + + Case ASECOM.AWK_EXTIO_FILE + If extio.mode = ASECOM.AWK_EXTIO_FILE_READ Then + Awk_ReadExtio = ReadExtioFile(extio, buf) + End If + + Case ASECOM.AWK_EXTIO_PIPE + Awk_ReadExtio = -1 + Case ASECOM.AWK_EXTIO_COPROC + Awk_ReadExtio = -1 + End Select + +End Function + +Function Awk_WriteExtio(ByVal extio As ASECOM.AwkExtio, ByVal buf As ASECOM.Buffer) As Long + Awk_WriteExtio = -1 + + Select Case extio.Type + Case ASECOM.AWK_EXTIO_CONSOLE + If extio.mode = ASECOM.AWK_EXTIO_CONSOLE_WRITE Then + Awk_WriteExtio = WriteExtioConsole(extio, buf) + End If + Case ASECOM.AWK_EXTIO_FILE + If extio.mode = ASECOM.AWK_EXTIO_FILE_WRITE Or _ + extio.mode = ASECOM.AWK_EXTIO_FILE_APPEND Then + Awk_WriteExtio = WriteExtioFile(extio, buf) + End If + Case ASECOM.AWK_EXTIO_PIPE + Awk_WriteExtio = -1 + Case ASECOM.AWK_EXTIO_COPROC + Awk_WriteExtio = -1 + End Select +End Function + +Function ReadExtioConsole(ByVal extio As ASECOM.AwkExtio, ByVal buf As ASECOM.Buffer) As Long + Dim value As String + + If Not extio.Handle.EOF Then + value = ConsoleIn.Text + extio.Handle.EOF = True + buf.value = value + ReadExtioConsole = Len(value) + Else + ReadExtioConsole = 0 + End If +End Function + +Function ReadExtioFile(ByVal extio As ASECOM.AwkExtio, ByVal buf As ASECOM.Buffer) As Long + Dim value As String + + If EOF(extio.Handle) Then + ReadExtioFile = 0 + Exit Function + End If + + On Error GoTo ErrorTrap + Line Input #extio.Handle, value + On Error GoTo 0 + + value = value + vbCrLf + + buf.value = value + ReadExtioFile = Len(buf.value) + Exit Function + +ErrorTrap: + ReadExtioFile = -1 + Exit Function +End Function + +Function WriteExtioConsole(ByVal extio As ASECOM.AwkExtio, ByVal buf As ASECOM.Buffer) As Long + Dim value As String + + value = buf.value + ConsoleOut.Text = ConsoleOut.Text + value + WriteExtioConsole = Len(value) +End Function + +Function WriteExtioFile(ByVal extio As ASECOM.AwkExtio, ByVal buf As ASECOM.Buffer) As Long + Dim value As String + + WriteExtioFile = -1 + + value = buf.value + On Error GoTo ErrorTrap + Print #extio.Handle, value; + On Error GoTo 0 + WriteExtioFile = Len(value) + + Exit Function + +ErrorTrap: + Exit Function +End Function + +Function Awk_HandleBuiltinFunction(ByVal name As String, ByVal Args As Variant) As Variant + + If name = "sin" Then + If IsNull(Args(0)) Then + Awk_HandleBuiltinFunction = Sin(0) + ElseIf IsNumeric(Args(0)) Then + Awk_HandleBuiltinFunction = Sin(Args(0)) + Else + Awk_HandleBuiltinFunction = Sin(Val(Args(0))) + End If + ElseIf name = "cos" Then + If TypeName(Args(0)) = "Long" Or TypeName(Args(0)) = "Double" Then + Awk_HandleBuiltinFunction = Cos(Args(0)) + ElseIf TypeName(Args(0)) = "String" Then + Awk_HandleBuiltinFunction = Cos(Val(Args(0))) + ElseIf TypeName(Args(0)) = "Null" Then + Awk_HandleBuiltinFunction = Cos(0) + End If + ElseIf name = "tan" Then + If TypeName(Args(0)) = "Long" Or TypeName(Args(0)) = "Double" Then + Awk_HandleBuiltinFunction = Tan(Args(0)) + ElseIf TypeName(Args(0)) = "String" Then + Awk_HandleBuiltinFunction = Tan(Val(Args(0))) + ElseIf TypeName(Args(0)) = "Null" Then + Awk_HandleBuiltinFunction = Tan(0) + End If + ElseIf name = "sqrt" Then + If IsNull(Args(0)) Then + Awk_HandleBuiltinFunction = Sqr(0) + ElseIf IsNumeric(Args(0)) Then + Awk_HandleBuiltinFunction = Sqr(Args(0)) + Else + Awk_HandleBuiltinFunction = Sqr(Val(Args(0))) + End If + ElseIf name = "trim" Then + Awk_HandleBuiltinFunction = Trim(Args(0)) + End If + + 'Dim i As Integer + 'Dim xxx As String + + 'MsgBox name + + 'For i = LBound(args) To UBound(args) + ' xxx = xxx & "," & args(i) + 'Next i + + 'MsgBox xxx +End Function + + +Private Sub Form_Load() + SourceIn.Text = "" + SourceOut.Text = "" + ConsoleIn.Text = "" + ConsoleOut.Text = "" +End Sub + diff --git a/ase/test/com/AwkForm.frx b/ase/test/com/AwkForm.frx new file mode 100644 index 0000000000000000000000000000000000000000..9dd42b079c0b8610de851272b68bc1e88ab4f9fe GIT binary patch literal 17 WcmZQ%U}j)sFkob00m9tG%sc=F#R231 literal 0 HcmV?d00001 diff --git a/ase/test/com/asetestcom.vbp b/ase/test/com/asetestcom.vbp new file mode 100644 index 00000000..66cb9079 --- /dev/null +++ b/ase/test/com/asetestcom.vbp @@ -0,0 +1,39 @@ +Type=Exe +Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\..\WINDOWS\System32\stdole2.tlb#OLE Automation +Reference=*\G{F9C69806-16A1-4162-998A-876B33C470BF}#1.0#0#..\..\Debug\lib\asecom.dll#ASE 1.0 Type Library +Form=AwkForm.frm +Class=AwkExtioConsole; AwkExtioConsole.cls +IconForm="AwkForm" +Startup="AwkForm" +HelpFile="" +Title="ASECOM" +ExeName32="asecom.exe" +Command32="" +Name="ASETESTCOM" +HelpContextID="0" +CompatibleMode="0" +MajorVer=1 +MinorVer=0 +RevisionVer=0 +AutoIncrementVer=0 +ServerSupportFiles=0 +VersionProductName="ASE.COM" +CompilationType=0 +OptimizationType=0 +FavorPentiumPro(tm)=0 +CodeViewDebugInfo=0 +NoAliasing=0 +BoundsCheck=0 +OverflowCheck=0 +FlPointCheck=0 +FDIVCheck=0 +UnroundedFP=0 +StartMode=0 +Unattended=0 +Retained=0 +ThreadPerObject=0 +MaxNumberOfThreads=1 +DebugStartupOption=0 + +[MS Transaction Server] +AutoRefresh=1 diff --git a/ase/test/com/asetestcom.vbw b/ase/test/com/asetestcom.vbw new file mode 100644 index 00000000..a068e5db --- /dev/null +++ b/ase/test/com/asetestcom.vbw @@ -0,0 +1,2 @@ +AwkForm = 13, 12, 735, 661, , 22, 22, 753, 640, C +AwkExtioConsole = 0, 0, 547, 460, C diff --git a/ase/test/com/awk.js b/ase/test/com/awk.js new file mode 100644 index 00000000..0323c738 --- /dev/null +++ b/ase/test/com/awk.js @@ -0,0 +1,72 @@ +var awk, first, n + +first = true + +function awk_OpenSource (mode) +{ + WScript.echo ("OpenSource - mode:" + mode); + return 1; +} + +function awk_CloseSource (mode) +{ + WScript.echo ("CloseSource - mode:" + mode); + return 0; +} + +function awk_ReadSource (buf) +{ + WScript.echo ("ReadSource - buf: [" + buf.Value + "]"); + if (first) + { + buf.Value = "BEGIN {print 1; print 2;}" + first = false + return buf.Value.length; + } + else return 0; +} + +function awk_WriteSource (buf) +{ + //WScript.echo ("WriteSource - cnt: " + cnt) + WScript.echo (buf.Value); + return buf.Value.length; +} + +function awk_OpenExtio (extio) +{ + WScript.echo ("OpenExtio - type: " + extio.Type + " mode: " + extio.Mode + " name: [" + extio.Name + "]"); + return 1; +} + +function awk_CloseExtio (extio) +{ + WScript.echo ("CloseExtio"); + return 0; +} + +function awk_WriteExtio (extio, buf) +{ + WScript.echo (buf.Value); + return buf.Value.length; +} + +awk = WScript.CreateObject("ASE.Awk"); +WScript.ConnectObject (awk, "awk_"); + + +n = awk.Parse(); +if (n == -1) +{ + WScript.echo ("parse failed"); + WScript.quit (1); +} + +n = awk.Run (); +if (n == -1) +{ + WScript.echo ("run failed"); + WScript.quit (1); +} + + diff --git a/ase/test/com/awk.vbs b/ase/test/com/awk.vbs new file mode 100644 index 00000000..c3a4c077 --- /dev/null +++ b/ase/test/com/awk.vbs @@ -0,0 +1,30 @@ +dim awk, first + +first = true + +function awk_OpenSource (mode) + WScript.echo ("OpenSource - mode:" & mode) + awk_OpenSource = 1 +end function + +function awk_CloseSource (mode) + WScript.echo ("CloseSource - mode:" & mode) + awk_CloseSource = 0 +end function + +function awk_ReadSource (buf, cnt) + WScript.echo ("ReadSource - cnt: " & cnt) + if first then + buf.Value = "BEGIN {print 1;}" + first = false + awk_ReadSource = len(buf.Value) + else + awk_ReadSource = 0 + end if +end function + +set awk = WScript.CreateObject("ASE.Awk") +call WScript.ConnectObject (awk, "awk_") + +WScript.echo awk.Parse +set awk = nothing diff --git a/ase/test/lsp/asetestlsp.dsp b/ase/test/lsp/asetestlsp.dsp new file mode 100644 index 00000000..182ef86c --- /dev/null +++ b/ase/test/lsp/asetestlsp.dsp @@ -0,0 +1,102 @@ +# Microsoft Developer Studio Project File - Name="asetestlsp" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=asetestlsp - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "asetestlsp.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "asetestlsp.mak" CFG="asetestlsp - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "asetestlsp - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "asetestlsp - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "asetestlsp - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "../../release/bin" +# PROP Intermediate_Dir "release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\.." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_UNICODE" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 aselsp.lib asecmn.lib aseutl.lib user32.lib kernel32.lib /nologo /subsystem:console /machine:I386 /out:"../../release/bin/aselsp.exe" /libpath:"../../release/lib" + +!ELSEIF "$(CFG)" == "asetestlsp - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "../../debug/bin" +# PROP Intermediate_Dir "debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\.." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /FR /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 aselsp.lib asecmn.lib aseutl.lib user32.lib kernel32.lib /nologo /subsystem:console /debug /machine:I386 /out:"../../debug/bin/aselsp.exe" /pdbtype:sept /libpath:"../../debug/lib" + +!ENDIF + +# Begin Target + +# Name "asetestlsp - Win32 Release" +# Name "asetestlsp - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\lsp.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/ase/test/lsp/asetestlsp.vcproj b/ase/test/lsp/asetestlsp.vcproj new file mode 100644 index 00000000..80985b85 --- /dev/null +++ b/ase/test/lsp/asetestlsp.vcproj @@ -0,0 +1,247 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ase/test/lsp/descrip.mms b/ase/test/lsp/descrip.mms new file mode 100644 index 00000000..52184002 --- /dev/null +++ b/ase/test/lsp/descrip.mms @@ -0,0 +1,13 @@ +# +# OpenVMS MMS/MMK +# + +objects = lsp.obj + +CFLAGS = /include="../../.." +#CFLAGS = /pointer_size=long /include="../../.." + +aselsp.exe : $(objects) + link /executable=aselsp.exe $(objects),[-.-.lsp]aselsp/library + +lsp.obj depends_on lsp.c diff --git a/ase/test/lsp/lsp.c b/ase/test/lsp/lsp.c new file mode 100644 index 00000000..ee5699e0 --- /dev/null +++ b/ase/test/lsp/lsp.c @@ -0,0 +1,402 @@ +/* + * $Id: lsp.c,v 1.3 2007/04/30 08:32:50 bacon Exp $ + */ + +#include + +#include +#include +#include + +#include +#include + +#ifdef _WIN32 +#include +#include +#endif + +#if defined(_WIN32) && defined(_MSC_VER) && defined(_DEBUG) +#define _CRTDBG_MAP_ALLOC +#include +#endif + +#ifdef __linux +#include +#endif + +#if defined(vms) || defined(__vms) +/* it seems that the main function should be placed in the main object file + * in OpenVMS. otherwise, the first function in the main object file seems + * to become the main function resulting in program start-up failure. */ +#include +#endif + +#ifndef NDEBUG +void ase_assert_abort (void) +{ + abort (); +} + +void ase_assert_printf (const ase_char_t* fmt, ...) +{ + va_list ap; +#ifdef _WIN32 + int n; + ase_char_t buf[1024]; +#endif + + va_start (ap, fmt); +#if defined(_WIN32) + n = _vsntprintf (buf, ASE_COUNTOF(buf), fmt, ap); + if (n < 0) buf[ASE_COUNTOF(buf)-1] = ASE_T('\0'); + + #if defined(_MSC_VER) && (_MSC_VER<1400) + MessageBox (NULL, buf, + ASE_T("Assertion Failure"), MB_OK|MB_ICONERROR); + #else + MessageBox (NULL, buf, + ASE_T("\uB2DD\uAE30\uB9AC \uC870\uB610"), MB_OK|MB_ICONERROR); + #endif +#else + ase_vprintf (fmt, ap); +#endif + va_end (ap); +} +#endif + + +static ase_ssize_t get_input ( + int cmd, void* arg, ase_char_t* data, ase_size_t size) +{ + switch (cmd) + { + case ASE_LSP_IO_OPEN: + case ASE_LSP_IO_CLOSE: + return 0; + + case ASE_LSP_IO_READ: + { + /* + if (ase_fgets (data, size, stdin) == ASE_NULL) + { + if (ferror(stdin)) return -1; + return 0; + } + return ase_lsp_strlen(data); + */ + + ase_cint_t c; + + if (size <= 0) return -1; + c = ase_fgetc (stdin); + + if (c == ASE_CHAR_EOF) + { + if (ferror(stdin)) return -1; + return 0; + } + + data[0] = c; + return 1; + } + } + + return -1; +} + +static ase_ssize_t put_output ( + int cmd, void* arg, ase_char_t* data, ase_size_t size) +{ + switch (cmd) + { + case ASE_LSP_IO_OPEN: + case ASE_LSP_IO_CLOSE: + return 0; + + case ASE_LSP_IO_WRITE: + { + int n = ase_fprintf ( + stdout, ASE_T("%.*s"), size, data); + if (n < 0) return -1; + + return size; + } + } + + return -1; +} + +#ifdef _WIN32 +typedef struct prmfns_data_t prmfns_data_t; +struct prmfns_data_t +{ + HANDLE heap; +}; +#endif + +static void* custom_lsp_malloc (void* custom, ase_size_t n) +{ +#ifdef _WIN32 + return HeapAlloc (((prmfns_data_t*)custom)->heap, 0, n); +#else + return malloc (n); +#endif +} + +static void* custom_lsp_realloc (void* custom, void* ptr, ase_size_t n) +{ +#ifdef _WIN32 + /* HeapReAlloc behaves differently from realloc */ + if (ptr == NULL) + return HeapAlloc (((prmfns_data_t*)custom)->heap, 0, n); + else + return HeapReAlloc (((prmfns_data_t*)custom)->heap, 0, ptr, n); +#else + return realloc (ptr, n); +#endif +} + +static void custom_lsp_free (void* custom, void* ptr) +{ +#ifdef _WIN32 + HeapFree (((prmfns_data_t*)custom)->heap, 0, ptr); +#else + free (ptr); +#endif +} + +static ase_bool_t custom_lsp_isupper (void* custom, ase_cint_t c) +{ + return ase_isupper (c); +} + +static ase_bool_t custom_lsp_islower (void* custom, ase_cint_t c) +{ + return ase_islower (c); +} + +static ase_bool_t custom_lsp_isalpha (void* custom, ase_cint_t c) +{ + return ase_isalpha (c); +} + +static ase_bool_t custom_lsp_isdigit (void* custom, ase_cint_t c) +{ + return ase_isdigit (c); +} + +static ase_bool_t custom_lsp_isxdigit (void* custom, ase_cint_t c) +{ + return ase_isxdigit (c); +} + +static ase_bool_t custom_lsp_isalnum (void* custom, ase_cint_t c) +{ + return ase_isalnum (c); +} + +static ase_bool_t custom_lsp_isspace (void* custom, ase_cint_t c) +{ + return ase_isspace (c); +} + +static ase_bool_t custom_lsp_isprint (void* custom, ase_cint_t c) +{ + return ase_isprint (c); +} + +static ase_bool_t custom_lsp_isgraph (void* custom, ase_cint_t c) +{ + return ase_isgraph (c); +} + +static ase_bool_t custom_lsp_iscntrl (void* custom, ase_cint_t c) +{ + return ase_iscntrl (c); +} + +static ase_bool_t custom_lsp_ispunct (void* custom, ase_cint_t c) +{ + return ase_ispunct (c); +} + +static ase_cint_t custom_lsp_toupper (void* custom, ase_cint_t c) +{ + return ase_toupper (c); +} + +static ase_cint_t custom_lsp_tolower (void* custom, ase_cint_t c) +{ + return ase_tolower (c); +} + +static int custom_lsp_sprintf ( + void* custom, ase_char_t* buf, ase_size_t size, + const ase_char_t* fmt, ...) +{ + int n; + + va_list ap; + va_start (ap, fmt); + n = ase_vsprintf (buf, size, fmt, ap); + va_end (ap); + + return n; +} + + +static void custom_lsp_dprintf (void* custom, const ase_char_t* fmt, ...) +{ + va_list ap; + va_start (ap, fmt); + ase_vfprintf (stderr, fmt, ap); + va_end (ap); +} + + +int lsp_main (int argc, ase_char_t* argv[]) +{ + ase_lsp_t* lsp; + ase_lsp_obj_t* obj; + int mem, inc; + ase_lsp_prmfns_t prmfns; +#ifdef _WIN32 + prmfns_data_t prmfns_data; +#endif + + mem = 1000; + inc = 1000; + + if (mem <= 0) + { + ase_printf (ASE_T("error: invalid memory size given\n")); + return -1; + } + + memset (&prmfns, 0, sizeof(prmfns)); + + prmfns.mmgr.malloc = custom_lsp_malloc; + prmfns.mmgr.realloc = custom_lsp_realloc; + prmfns.mmgr.free = custom_lsp_free; +#ifdef _WIN32 + prmfns_data.heap = HeapCreate (0, 1000000, 1000000); + if (prmfns_data.heap == NULL) + { + ase_printf (ASE_T("Error: cannot create an lsp heap\n")); + return -1; + } + + prmfns.mmgr.custom_data = &prmfns_data; +#else + prmfns.mmgr.custom_data = ASE_NULL; +#endif + + prmfns.ccls.is_upper = custom_lsp_isupper; + prmfns.ccls.is_lower = custom_lsp_islower; + prmfns.ccls.is_alpha = custom_lsp_isalpha; + prmfns.ccls.is_digit = custom_lsp_isdigit; + prmfns.ccls.is_xdigit = custom_lsp_isxdigit; + prmfns.ccls.is_alnum = custom_lsp_isalnum; + prmfns.ccls.is_space = custom_lsp_isspace; + prmfns.ccls.is_print = custom_lsp_isprint; + prmfns.ccls.is_graph = custom_lsp_isgraph; + prmfns.ccls.is_cntrl = custom_lsp_iscntrl; + prmfns.ccls.is_punct = custom_lsp_ispunct; + prmfns.ccls.to_upper = custom_lsp_toupper; + prmfns.ccls.to_lower = custom_lsp_tolower; + prmfns.ccls.custom_data = ASE_NULL; + + prmfns.misc.sprintf = custom_lsp_sprintf; + prmfns.misc.dprintf = custom_lsp_dprintf; + prmfns.misc.custom_data = ASE_NULL; + + lsp = ase_lsp_open (&prmfns, mem, inc); + if (lsp == ASE_NULL) + { +#ifdef _WIN32 + HeapDestroy (prmfns_data.heap); +#endif + ase_printf (ASE_T("error: cannot create a lsp instance\n")); + return -1; + } + + ase_printf (ASE_T("ASELSP 0.0001\n")); + + ase_lsp_attinput (lsp, get_input, ASE_NULL); + ase_lsp_attoutput (lsp, put_output, ASE_NULL); + + while (1) + { + ase_printf (ASE_T("ASELSP $ ")); + fflush (stdout); + + obj = ase_lsp_read (lsp); + if (obj == ASE_NULL) + { + int errnum; + const ase_char_t* errmsg; + + ase_lsp_geterror (lsp, &errnum, &errmsg); + + if (errnum != ASE_LSP_EEND && + errnum != ASE_LSP_EEXIT) + { + ase_printf ( + ASE_T("error in read: [%d] %s\n"), + errnum, errmsg); + } + + /* TODO: change the following check */ + if (errnum < ASE_LSP_ESYNTAX) break; + continue; + } + + if ((obj = ase_lsp_eval (lsp, obj)) != ASE_NULL) + { + ase_lsp_print (lsp, obj); + ase_printf (ASE_T("\n")); + } + else + { + int errnum; + const ase_char_t* errmsg; + + ase_lsp_geterror (lsp, &errnum, &errmsg); + if (errnum == ASE_LSP_EEXIT) break; + + ase_printf ( + ASE_T("error in eval: [%d] %s\n"), + errnum, errmsg); + } + } + + ase_lsp_close (lsp); + +#ifdef _WIN32 + HeapDestroy (prmfns_data.heap); +#endif + return 0; +} + +int ase_main (int argc, ase_char_t* argv[]) +{ + int n; + +#if defined(__linux) && defined(_DEBUG) + mtrace (); +#endif + + n = lsp_main (argc, argv); + +#if defined(__linux) && defined(_DEBUG) + muntrace (); +#endif +#if defined(_WIN32) && defined(_MSC_VER) && defined(_DEBUG) + _CrtDumpMemoryLeaks (); + wprintf (L"Press ENTER to quit\n"); + getchar (); +#endif + + return n; +} diff --git a/ase/test/lsp/makefile.in b/ase/test/lsp/makefile.in new file mode 100644 index 00000000..9d4d9b93 --- /dev/null +++ b/ase/test/lsp/makefile.in @@ -0,0 +1,23 @@ +# +# $Id: makefile.in,v 1.3 2007/04/30 08:32:50 bacon Exp $ +# + +CC = @CC@ +CFLAGS = @CFLAGS@ -I@abs_top_builddir@/.. +LDFLAGS = @LDFLAGS@ -L@abs_top_builddir@/@BUILDMODE@/lib +LIBS = @LIBS@ -laselsp -lasecmn -laseutl -lm +MODE = @BUILDMODE@ + +OUT_DIR = ../../$(MODE)/bin + +all: $(OUT_DIR)/aselsp + +$(OUT_DIR)/aselsp: $(OUT_DIR) + $(CC) $(CFLAGS) -o $@ lsp.c $(LDFLAGS) $(LIBS) + +$(OUT_DIR): + mkdir -p $(OUT_DIR) + +clean: + rm -rf $(OUT_DIR)/aselsp + diff --git a/ase/test/lsp/makefile.msw.bcc b/ase/test/lsp/makefile.msw.bcc new file mode 100644 index 00000000..5892cc91 --- /dev/null +++ b/ase/test/lsp/makefile.msw.bcc @@ -0,0 +1,19 @@ +CC = bcc32 +LD = ilink32 +CFLAGS = -I..\..\.. +LDFLAGS = -L..\..\cmn -L..\..\lsp -L..\..\utl +LIBS = import32.lib cw32mt.lib asecmn.lib aselsp.lib aseutl.lib +STARTUP = c0x32w.obj + +all: aselsp + +aselsp: lsp.obj + $(LD) $(LDFLAGS) $(STARTUP) lsp.obj,$@.exe,,$(LIBS),, + +clean: + del $(OBJS) *.obj $(OUT) + +.SUFFIXES: .c .obj +.c.obj: + $(CC) $(CFLAGS) -c $< + diff --git a/ase/test/lsp/makefile.msw.cl b/ase/test/lsp/makefile.msw.cl new file mode 100644 index 00000000..d9d6821b --- /dev/null +++ b/ase/test/lsp/makefile.msw.cl @@ -0,0 +1,17 @@ +CC = cl +CFLAGS = /nologo /MT /GX /W3 /GR- -I..\..\.. +LDFLAGS = /libpath:..\..\cmn /libpath:..\..\lsp /libpath:..\..\utl +LIBS = asecmn.lib aselsp.lib aseutl.lib user32.lib + +all: aselsp + +aselsp: lsp.obj + link /nologo /out:$@.exe $(LDFLAGS) $(LIBS) lsp.obj + +clean: + del $(OBJS) *.obj lsp.exe + +.SUFFIXES: .c .obj +.c.obj: + $(CC) /c $(CFLAGS) $< + diff --git a/ase/test/lsp/t1.lsp b/ase/test/lsp/t1.lsp new file mode 100644 index 00000000..cc8873a3 --- /dev/null +++ b/ase/test/lsp/t1.lsp @@ -0,0 +1,21 @@ +(setq x (lambda (x) (car x))) +((lambda (x) (+ x 99)) (x '(10 20 30))) + +((lambda (x) ((lambda (y) (+ y 1)) x)) 10) +; lisp.... +((lambda (x) ((macro (y) (+ y 1)) x)) 10) + + + + +;;;;;;; +(setq init-rand (macro (seed) (lambda () (setq seed (+ seed 1))))) + +(setq init-rand (lambda (seed) (lambda () (setq seed (+ seed 1))))) +(setq rand (init-rand 1)) +(rand) + +(defun init-rand (seed) (lambda () (setq seed (+ seed 1)))) +(defun rand () (init-rand 1)) +(rand) + diff --git a/ase/test/lsp/t2.lsp b/ase/test/lsp/t2.lsp new file mode 100644 index 00000000..95e76133 --- /dev/null +++ b/ase/test/lsp/t2.lsp @@ -0,0 +1,170 @@ +;(setq x (lambda (x) (+ x 20 30 40))) +(defun x(x) (+ x 20 30 40)) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 100) +(x 200) +(x 200) +(x 200) +(x 200) +(x 200) diff --git a/ase/test/lsp/t3.lsp b/ase/test/lsp/t3.lsp new file mode 100644 index 00000000..0a28bf6a --- /dev/null +++ b/ase/test/lsp/t3.lsp @@ -0,0 +1,8 @@ +; test while + +(setq x 10) +(setq y 10) +(while (< x 100) (setq y (+ x y)) (setq x (+ x 1))) +x +y + diff --git a/ase/test/lsp/t4.lsp b/ase/test/lsp/t4.lsp new file mode 100644 index 00000000..ac40a254 --- /dev/null +++ b/ase/test/lsp/t4.lsp @@ -0,0 +1,7 @@ +;Compute the factorial of N. +(defun factorial (N) + (if (= N 1) + 1 + (* N (factorial (- N 1))))) + +(factorial 10) diff --git a/ase/test/lsp/t5.lsp b/ase/test/lsp/t5.lsp new file mode 100644 index 00000000..066dbf60 --- /dev/null +++ b/ase/test/lsp/t5.lsp @@ -0,0 +1,8 @@ +; Compute the N'th Fibonacci number. +(defun fibonacci (N) + ;(if (or (zerop N) (= N 1)) + (if (or (= N 0) (= N 1)) + 1 + (+ (fibonacci (- N 1)) (fibonacci (- N 2))))) + +(fibonacci 5) diff --git a/ase/test/lsp/t6.lsp b/ase/test/lsp/t6.lsp new file mode 100644 index 00000000..a411e278 --- /dev/null +++ b/ase/test/lsp/t6.lsp @@ -0,0 +1,9 @@ + + +(setq x '(a b c)) +(setq y '(x y z)) +(setcar x y) +(setcar y x) +x +y + diff --git a/ase/test/lsp/t7.lsp b/ase/test/lsp/t7.lsp new file mode 100644 index 00000000..40a0d15a --- /dev/null +++ b/ase/test/lsp/t7.lsp @@ -0,0 +1,4 @@ +(setq a '(1 2 3)) +(cons a (cons a 10)) +(setq xx (cons a (cons a 10))) + diff --git a/ase/test/stx/helper.st b/ase/test/stx/helper.st new file mode 100644 index 00000000..af3cb844 --- /dev/null +++ b/ase/test/stx/helper.st @@ -0,0 +1,13 @@ +| x | +"print the reverse hierarchy of a class" +x := Class. +[x isNil] whileFalse: [ + Transcript show: x printString; cr. + x := x superclass]. + +| x | +"print the reverse hierarchy of a metaclass" +x := Class class. +[x isNil] whileFalse: [ + Transcript show: x printString; cr. + x := x superclass]. diff --git a/ase/test/stx/makefile.bcc b/ase/test/stx/makefile.bcc new file mode 100644 index 00000000..f4e2a7da --- /dev/null +++ b/ase/test/stx/makefile.bcc @@ -0,0 +1,21 @@ +CC = bcc32 +CFLAGS = -I..\..\.. +LDFLAGS = -L..\..\..\xp\bas -L..\..\..\xp\stx +LIBS = import32.lib cw32mt.lib xpbas.lib xpstx.lib +STARTUP = c0x32w.obj + +all: stx parser + +stx: stx.obj + ilink32 $(LDFLAGS) $(STARTUP) stx.obj,stx.exe,,$(LIBS),, + +parser: parser.obj + ilink32 $(LDFLAGS) $(STARTUP) parser.obj,parser.exe,,$(LIBS),, + +clean: + del $(OBJS) *.obj $(OUT) + +.SUFFIXES: .c .obj +.c.obj: + $(CC) $(CFLAGS) -c $< + diff --git a/ase/test/stx/makefile.cl b/ase/test/stx/makefile.cl new file mode 100644 index 00000000..2a717481 --- /dev/null +++ b/ase/test/stx/makefile.cl @@ -0,0 +1,20 @@ +CC = cl +CFLAGS = /nologo /MT /GX /W3 /GR- -I..\..\.. +LDFLAGS = /libpath:..\..\cmn /libpath:..\..\stx +LIBS = asecmn.lib asestx.lib + +all: stx parser + +stx: stx.obj + link /nologo /out:stx.exe $(LDFLAGS) $(LIBS) stx.obj + +parser: parser.obj + link /nologo /out:parser.exe $(LDFLAGS) $(LIBS) parser.obj + +clean: + del $(OBJS) *.obj stx.exe parser.exe + +.SUFFIXES: .c .obj +.c.obj: + $(CC) /c $(CFLAGS) $< + diff --git a/ase/test/stx/makefile.in b/ase/test/stx/makefile.in new file mode 100644 index 00000000..2d18d282 --- /dev/null +++ b/ase/test/stx/makefile.in @@ -0,0 +1,19 @@ +CC = @CC@ +CFLAGS = @CFLAGS@ -I@abs_top_builddir@ +LDFLAGS = @LDFLAGS@ -L@abs_top_builddir@/xp/bas -L@abs_top_builddir@/xp/stx +LIBS = @LIBS@ -lxpstx -lxpbas + +all: stx parser + +stx: stx.o + $(CC) $(LDFLAGS) -o $@.x stx.o $(LIBS) + +parser: parser.o + $(CC) $(LDFLAGS) -o $@.x parser.o $(LIBS) + +clean: + rm -rf *.x *.o + +.SUFFIXES: .c .o +.c.o: + $(CC) $(CFLAGS) -c $< diff --git a/ase/test/stx/makefile.lcc b/ase/test/stx/makefile.lcc new file mode 100644 index 00000000..bf6925b0 --- /dev/null +++ b/ase/test/stx/makefile.lcc @@ -0,0 +1,24 @@ +CC = lcc +CFLAGS = -I../../.. -A -ansic -libcdll +#LDFLAGS = -L../../../xp/bas -L../../../xp/stx +#LIBS = -lxpstx -lxpbas +#LDFLAGS = -subsystem console -dynamic -s +LDFLAGS = -subsystem console -s +LIBS = ..\..\..\xp\stx\xpstx.lib ..\..\..\xp\bas\xpbas.lib + +all: stx parser + +stx: stx.obj + lcclnk $(LDFLAGS) -o stx.exe stx.obj $(LIBS) + +parser: parser.obj + lcclnk $(LDFLAGS) -o parser.exe parser.obj $(LIBS) + + +clean: + del $(OBJS) *.obj $(OUT) + +.SUFFIXES: .c .obj +.c.obj: + $(CC) $(CFLAGS) -c $< + diff --git a/ase/test/stx/makefile.tcc b/ase/test/stx/makefile.tcc new file mode 100644 index 00000000..f944b475 --- /dev/null +++ b/ase/test/stx/makefile.tcc @@ -0,0 +1,19 @@ +SRCS = stx.c +OBJS = stx.obj +OUT = stx.exe + +TC = \dos\tc +CC = $(TC)\tcc +CFLAGS = -I..\..\.. -ml -D_DOS -w +LIBS = $(TC)\lib\cl.lib $(TC)\lib\c0l.obj ..\..\..\xp\stx\xpstx.lib + +all: $(OBJS) + $(TC)\tlink $(OBJS),$(OUT),,$(LIBS) + +clean: + del $(OBJS) *.obj $(OUT) + +.SUFFIXES: .c .obj +.c.obj: + $(CC) $(CFLAGS) -c $< + diff --git a/ase/test/stx/parser.c b/ase/test/stx/parser.c new file mode 100644 index 00000000..b142c4bc --- /dev/null +++ b/ase/test/stx/parser.c @@ -0,0 +1,230 @@ +#include + +#ifdef _DOS + #include + #define xp_printf printf +#else + #include + #include +#endif + +#include +#include +#include +#include +#include + +#ifdef __linux +#include +#endif + +struct ss_t +{ + const xp_char_t* text; + xp_size_t index; +}; + +typedef struct ss_t ss_t; + +int ss_func (int cmd, void* owner, void* arg) +{ + + if (cmd == XP_STX_PARSER_INPUT_OPEN) { + ss_t* ss = *(ss_t**)owner; + ss->text = (const xp_char_t*)arg; + ss->index = 0; + return 0; + } + else if (cmd == XP_STX_PARSER_INPUT_CLOSE) { + /*ss_t* ss = (ss_t*)owner; */ + return 0; + } + else if (cmd == XP_STX_PARSER_INPUT_CONSUME) { + ss_t* ss = (ss_t*)owner; + xp_cint_t* c = (xp_cint_t*)arg; + if (ss->text[ss->index] == XP_CHAR('\0')) { + *c = XP_CHAR_EOF; + } + else *c = ss->text[ss->index++]; + return 0; + } + else if (cmd == XP_STX_PARSER_INPUT_REWIND) { + return 0; + } + return -1; +} + +struct stdio_t +{ + XP_FILE* stdio; +}; + +typedef struct stdio_t stdio_t; + +int stdio_func (int cmd, void* owner, void* arg) +{ + + if (cmd == XP_STX_PARSER_INPUT_OPEN) { + stdio_t* p = *(stdio_t**)owner; + p->stdio = xp_fopen ((const xp_char_t*)arg, XP_TEXT("r")); + if (p->stdio == XP_NULL) return -1; + return 0; + } + else if (cmd == XP_STX_PARSER_INPUT_CLOSE) { + stdio_t* p = (stdio_t*)owner; + xp_fclose (p->stdio); + return 0; + } + else if (cmd == XP_STX_PARSER_INPUT_CONSUME) { + stdio_t* p = (stdio_t*)owner; + xp_cint_t* c = (xp_cint_t*)arg; + xp_cint_t t = xp_fgetc (p->stdio); + if (t == XP_CHAR_EOF) { + if (xp_ferror (p->stdio)) return -1; + *c = XP_CHAR_EOF; + } + else *c = t; + return 0; + } + else if (cmd == XP_STX_PARSER_INPUT_REWIND) { + return 0; + } + return -1; +} + +int xp_main (int argc, xp_char_t* argv[]) +{ + xp_stx_t stx; + xp_stx_parser_t parser; + +#ifdef __linux + mtrace (); +#endif + +/* +#ifndef _DOS + if (xp_setlocale () == -1) { + printf ("cannot set locale\n"); + return -1; + } +#endif +*/ + + if (argc != 2) { + xp_printf (XP_TEXT("usage: %s class_name\n"), argv[0]); + return -1; + } + + if (xp_stx_open (&stx, 10000) == XP_NULL) { + xp_printf (XP_TEXT("cannot open stx\n")); + return -1; + } + + if (xp_stx_bootstrap(&stx) == -1) { + xp_stx_close (&stx); + xp_printf (XP_TEXT("cannot bootstrap\n")); + return -1; + } + + + if (xp_stx_parser_open(&parser, &stx) == XP_NULL) { + xp_printf (XP_TEXT("cannot open parser\n")); + return -1; + } + + + { + /* + ss_t ss; + parser.input_owner = (void*)&ss; + parser.input_func = ss_func; + xp_stx_parser_parse_method (&parser, 0, + XP_TEXT("isNil\n^true")); + */ + stdio_t stdio; + xp_word_t n = xp_stx_lookup_class (&stx, argv[1]); + xp_word_t m; + + parser.input_owner = (void*)&stdio; + parser.input_func = stdio_func; + + if (n == stx.nil) { + xp_printf (XP_TEXT("Cannot find class - %s\n"), argv[1]); + goto exit_program; + } + + /* compile the method to n's class */ + if (xp_stx_parser_parse_method (&parser, XP_STX_CLASS(&stx,n), + (void*)XP_TEXT("test.st")) == -1) { + xp_printf (XP_TEXT("parser error <%s>\n"), + xp_stx_parser_error_string (&parser)); + } + + if (xp_stx_parser_parse_method (&parser, stx.class_symbol, + (void*)XP_TEXT("test1.st")) == -1) { + xp_printf (XP_TEXT("parser error <%s>\n"), + xp_stx_parser_error_string (&parser)); + } + + if (xp_stx_parser_parse_method (&parser, stx.class_symbol, + (void*)XP_TEXT("test2.st")) == -1) { + xp_printf (XP_TEXT("parser error <%s>\n"), + xp_stx_parser_error_string (&parser)); + } + + if (xp_stx_parser_parse_method (&parser, stx.class_string, + (void*)XP_TEXT("test3.st")) == -1) { + xp_printf (XP_TEXT("parser error <%s>\n"), + xp_stx_parser_error_string (&parser)); + } + + xp_printf (XP_TEXT("\n== Decoded Methods ==\n")); + if (xp_stx_decode(&stx, XP_STX_CLASS(&stx,n)) == -1) { + xp_printf (XP_TEXT("parser error <%s>\n"), + xp_stx_parser_error_string (&parser)); + } + + xp_printf (XP_TEXT("\n== Decoded Methods for Symbol ==\n")); + if (xp_stx_decode(&stx, stx.class_symbol) == -1) { + xp_printf (XP_TEXT("parser error <%s>\n"), + xp_stx_parser_error_string (&parser)); + } + + xp_printf (XP_TEXT("\n== Decoded Methods for String ==\n")); + if (xp_stx_decode(&stx, stx.class_string) == -1) { + xp_printf (XP_TEXT("parser error <%s>\n"), + xp_stx_parser_error_string (&parser)); + } + + xp_printf (XP_TEXT("== Running the main method ==\n")); + m = xp_stx_lookup_method ( + &stx, XP_STX_CLASS(&stx,n), XP_TEXT("main"), xp_false); + if (m == stx.nil) { + xp_printf (XP_TEXT("cannot lookup method main\n")); + } + else { + xp_stx_interp (&stx, n, m); + } + } + +exit_program: + xp_stx_parser_close (&parser); + xp_stx_close (&stx); + xp_printf (XP_TEXT("== End of program ==\n")); + +#ifdef __linux + muntrace (); +#endif + +/* +#ifdef __linux + { + char buf[1000]; + snprintf (buf, sizeof(buf), "ls -l /proc/%u/fd", getpid()); + system (buf); + } +#endif +*/ + return 0; +} + diff --git a/ase/test/stx/stx.c b/ase/test/stx/stx.c new file mode 100644 index 00000000..276d1c28 --- /dev/null +++ b/ase/test/stx/stx.c @@ -0,0 +1,237 @@ +#include + +#ifdef _DOS + #include + #define xp_printf printf +#else + #include + #include +#endif + +#include +#include +#include +#include +#include +#include + +void print_symbol_names (xp_stx_t* stx, xp_word_t sym, void* unused) +{ + xp_printf (XP_TEXT("%lu [%s]\n"), (unsigned long)sym, XP_STX_DATA(stx,sym)); +} + +void print_symbol_names_2 (xp_stx_t* stx, xp_word_t idx, void* unused) +{ + xp_word_t key = XP_STX_WORD_AT(stx,idx,XP_STX_ASSOCIATION_KEY); + xp_word_t value = XP_STX_WORD_AT(stx,idx,XP_STX_ASSOCIATION_VALUE); + xp_printf (XP_TEXT("%lu [%s] %lu\n"), + (unsigned long)key, XP_STX_DATA(stx,key), (unsigned long)value); +} + +void print_superclasses (xp_stx_t* stx, const xp_char_t* name) +{ + xp_word_t n; + xp_stx_class_t* obj; + + n = xp_stx_lookup_class (stx, name); + xp_printf (XP_TEXT("Class hierarchy for the class '%s'\n"), name); + + while (n != stx->nil) { + obj = (xp_stx_class_t*)XP_STX_WORD_OBJECT(stx,n); + xp_printf (XP_TEXT("%lu, %s\n"), + (unsigned long)obj->name, + XP_STX_DATA(stx, obj->name)); + n = obj->superclass; + } +} + +void print_metaclass_superclasses (xp_stx_t* stx, const xp_char_t* name) +{ + xp_word_t n, x; + xp_stx_metaclass_t* obj; + xp_stx_class_t* xobj; + + n = xp_stx_lookup_class (stx, name); + n = XP_STX_CLASS(stx,n); + xp_printf (XP_TEXT("Class hierarchy for the metaclass '%s class'\n"), name); + + while (n != stx->nil) { + /*if (n == stx->class_class) break; */ + if (XP_STX_CLASS(stx,n) != stx->class_metaclass) break; + + obj = (xp_stx_metaclass_t*)XP_STX_WORD_OBJECT(stx,n); + x = obj->instance_class; + xobj = (xp_stx_class_t*)XP_STX_WORD_OBJECT(stx,x); + xp_printf (XP_TEXT("%lu, %s class\n"), + (unsigned long)xobj->name, + XP_STX_DATA(stx, xobj->name)); + n = obj->superclass; + } + while (n != stx->nil) { + xobj = (xp_stx_class_t*)XP_STX_WORD_OBJECT(stx,n); + xp_printf (XP_TEXT("%lu, %s\n"), + (unsigned long)xobj->name, + XP_STX_DATA(stx, xobj->name)); + n = xobj->superclass; + } +} + +void print_class_name (xp_stx_t* stx, xp_word_t class, int tabs) +{ + xp_stx_class_t* xobj; + xobj = (xp_stx_class_t*)XP_STX_WORD_OBJECT(stx,class); + + while (tabs-- > 0) xp_printf (XP_TEXT(" ")); + + xp_printf (XP_TEXT("%s [%lu]\n"), + XP_STX_DATA(stx, xobj->name), + (unsigned long)class); +} + +void print_metaclass_name (xp_stx_t* stx, xp_word_t class, int tabs) +{ + xp_stx_metaclass_t* obj; + xp_stx_class_t* xobj; + + obj = (xp_stx_metaclass_t*)XP_STX_WORD_OBJECT(stx,class); + xobj = (xp_stx_class_t*)XP_STX_WORD_OBJECT(stx,obj->instance_class); + + while (tabs-- > 0) xp_printf (XP_TEXT(" ")); + + xp_printf (XP_TEXT("%s class [%lu]\n"), + XP_STX_DATA(stx, xobj->name), + (unsigned long)class); +} + +void print_subclass_names (xp_stx_t* stx, xp_word_t class, int tabs) +{ + xp_stx_class_t* obj; + + obj = (xp_stx_class_t*)XP_STX_WORD_OBJECT(stx,class); + if (obj->header.class == stx->class_metaclass) { + print_metaclass_name (stx, class, tabs); + } + else { + print_class_name (stx, class, tabs); + } + + if (obj->subclasses != stx->nil) { + xp_word_t count = XP_STX_SIZE(stx, obj->subclasses); + while (count-- > 0) { + print_subclass_names (stx, + XP_STX_WORD_AT(stx,obj->subclasses,count), tabs + 1); + } + } +} + +void print_subclasses (xp_stx_t* stx, const xp_char_t* name) +{ + xp_word_t class; + class = xp_stx_lookup_class (stx, name); + xp_printf (XP_TEXT("== NORMAL == \n")); + print_subclass_names (stx, class, 0); + xp_printf (XP_TEXT("== META == \n")); + print_subclass_names (stx, XP_STX_CLASS(stx,class), 0); +} + +int xp_main (int argc, xp_char_t* argv[]) +{ + xp_stx_t stx; + //xp_word_t i; + +#ifndef _DOS + if (xp_setlocale () == -1) { + printf ("cannot set locale\n"); + return -1; + } +#endif + + if (argc != 2) { /* TODO: argument processing */ + xp_printf (XP_TEXT("Usage: %s [-f imageFile] MainClass\n"), argv[0]); + return -1; + } + + if (xp_stx_open (&stx, 10000) == XP_NULL) { + xp_printf (XP_TEXT("cannot open stx\n")); + return -1; + } + + if (xp_stx_bootstrap(&stx) == -1) { + xp_stx_close (&stx); + xp_printf (XP_TEXT("cannot bootstrap\n")); + return -1; + } + + xp_printf (XP_TEXT("stx.nil %lu\n"), (unsigned long)stx.nil); + xp_printf (XP_TEXT("stx.true %lu\n"), (unsigned long)stx.true); + xp_printf (XP_TEXT("stx.false %lu\n"), (unsigned long)stx.false); + xp_printf (XP_TEXT("-------------\n")); + + + xp_printf (XP_TEXT(">> SYMBOL_TABLE (%u/%u symbols/slots) <<\n"), + (unsigned int)stx.symtab.size, (unsigned int)stx.symtab.capacity); + xp_stx_traverse_symbol_table (&stx, print_symbol_names, XP_NULL); + xp_printf (XP_TEXT("-------------\n")); + + xp_stx_dict_traverse (&stx, stx.smalltalk, print_symbol_names_2, XP_NULL); + xp_printf (XP_TEXT("-------------\n")); + + print_superclasses (&stx, XP_TEXT("Array")); + xp_printf (XP_TEXT("-------------\n")); + print_metaclass_superclasses (&stx, XP_TEXT("Array")); + xp_printf (XP_TEXT("-------------\n")); + print_superclasses (&stx, XP_TEXT("False")); + xp_printf (XP_TEXT("-------------\n")); + print_metaclass_superclasses (&stx, XP_TEXT("False")); + xp_printf (XP_TEXT("-------------\n")); + print_superclasses (&stx, XP_TEXT("Metaclass")); + xp_printf (XP_TEXT("-------------\n")); + print_metaclass_superclasses (&stx, XP_TEXT("Metaclass")); + xp_printf (XP_TEXT("-------------\n")); + print_superclasses (&stx, XP_TEXT("Class")); + xp_printf (XP_TEXT("-------------\n")); + print_metaclass_superclasses (&stx, XP_TEXT("Class")); + xp_printf (XP_TEXT("-------------\n")); + + print_subclasses (&stx, XP_TEXT("Object")); + xp_printf (XP_TEXT("-------------\n")); + +#if 0 + { + xp_word_t method_name; + xp_word_t main_class; + xp_word_t method, context; + + method_name = xp_stx_new_symbol (&stx,XP_TEXT("main")); + + main_class = xp_stx_lookup_class (&stx,argv[1]); + if (main_class == stx.nil) { + xp_printf (XP_TEXT("non-existent class: %s\n"), argv[1]); + return -1; + } + + /* + method = xp_stx_alloc_byte_object (&stx,100); + XP_STX_CLASS(&stx,method) = stx.class_method; + */ + method = xp_stx_instantiate (&stx, XP_TEXT("Method")); + + XP_STX_BYTEAT(&stx,method,0) = PUSH_OBJECT; + XP_STX_BYTEAT(&stx,method,1) = main_class; + XP_STX_BYTEAT(&stx,method,2) = SEND_UNARY_MESSAGE; + XP_STX_BYTEAT(&stx,method,3) = method_name; + XP_STX_BYTEAT(&stx,method,4) = HALT; + + /* + context = xp_stx_new_context (&stx, method, stx.nil, stx.nil); + */ + context = xp_stx_instantiate (&stx, XP_TEXT("Context")); + xp_stx_run_context (&stx, context); + } +#endif + + xp_stx_close (&stx); + xp_printf (XP_TEXT("== End of program ==\n")); + return 0; +} + diff --git a/ase/test/stx/test.st b/ase/test/stx/test.st new file mode 100644 index 00000000..d3dbeb00 --- /dev/null +++ b/ase/test/stx/test.st @@ -0,0 +1,13 @@ +main + | a | + + + "a := 10. + #abc xxx. + #abc xxx: 1. + ^nil " + + a := #abc print: 123 and: 2345. + #abc print: a and: a. + 1234567. + ^nil. diff --git a/ase/test/stx/test1.st b/ase/test/stx/test1.st new file mode 100644 index 00000000..3a754107 --- /dev/null +++ b/ase/test/stx/test1.st @@ -0,0 +1,10 @@ +print: a1 and: a2 + | t1 t2 | + + t1 := #abcdefg. + "a1 := 2341 arguments are not assignable" + t2 := a2. + t1 prim2: t2. + super prim2: 999999. + self prim2: 999999. + ^67891. diff --git a/ase/test/stx/test2.st b/ase/test/stx/test2.st new file mode 100644 index 00000000..47daeb28 --- /dev/null +++ b/ase/test/stx/test2.st @@ -0,0 +1,2 @@ +prim2: n + diff --git a/ase/test/stx/test3.st b/ase/test/stx/test3.st new file mode 100644 index 00000000..4f9eb9b0 --- /dev/null +++ b/ase/test/stx/test3.st @@ -0,0 +1,2 @@ +prim2: n + diff --git a/ase/utl/aseutl.dsp b/ase/utl/aseutl.dsp new file mode 100644 index 00000000..210582d1 --- /dev/null +++ b/ase/utl/aseutl.dsp @@ -0,0 +1,127 @@ +# Microsoft Developer Studio Project File - Name="aseutl" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=aseutl - Win32 Release +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "aseutl.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "aseutl.mak" CFG="aseutl - Win32 Release" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "aseutl - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "aseutl - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "aseutl - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "../release/lib" +# PROP Intermediate_Dir "release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +MTL=midl.exe +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "_USRDLL" /Yu"stdafx.h" /FD /c +# ADD CPP /nologo /MT /Za /W3 /GX /O2 /I "../.." /D "NDEBUG" /D "WIN32" /D "_UNICODE" /FD /c +# SUBTRACT CPP /YX /Yc /Yu +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo + +!ELSEIF "$(CFG)" == "aseutl - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "../debug/lib" +# PROP Intermediate_Dir "debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +MTL=midl.exe +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_UNICODE" /D "_USRDLL" /Yu"stdafx.h" /FD /GZ /c +# ADD CPP /nologo /MTd /Za /W3 /Gm /GX /ZI /Od /I "../.." /D "_DEBUG" /D "WIN32" /D "_UNICODE" /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo + +!ENDIF + +# Begin Target + +# Name "aseutl - Win32 Release" +# Name "aseutl - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\ctype.c +# End Source File +# Begin Source File + +SOURCE=.\main.c +# End Source File +# Begin Source File + +SOURCE=.\stdio.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\ctype.h +# End Source File +# Begin Source File + +SOURCE=.\main.h +# End Source File +# Begin Source File + +SOURCE=.\stdio.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/ase/utl/aseutl.vcproj b/ase/utl/aseutl.vcproj new file mode 100644 index 00000000..77a44bdc --- /dev/null +++ b/ase/utl/aseutl.vcproj @@ -0,0 +1,267 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ase/utl/ctype.c b/ase/utl/ctype.c new file mode 100644 index 00000000..e28e7042 --- /dev/null +++ b/ase/utl/ctype.c @@ -0,0 +1,150 @@ +/* + * $Id: ctype.c,v 1.3 2007/04/30 08:32:50 bacon Exp $ + */ + +#include + +#if defined(ASE_CHAR_IS_MCHAR) + +#include + +ase_bool_t ase_isupper (ase_cint_t c) +{ + return isupper (c); +} + +ase_bool_t ase_islower (ase_cint_t c) +{ + return islower (c); +} + +ase_bool_t ase_isalpha (ase_cint_t c) +{ + return isalpha (c); +} + +ase_bool_t ase_isdigit (ase_cint_t c) +{ + return isdigit (c); +} + +ase_bool_t ase_isxdigit (ase_cint_t c) +{ + return isxdigit (c); +} + +ase_bool_t ase_isalnum (ase_cint_t c) +{ + return isalnum (c); +} + +ase_bool_t ase_isspace (ase_cint_t c) +{ + return isspace (c); +} + +ase_bool_t ase_isprint (ase_cint_t c) +{ + return isprint (c); +} + +ase_bool_t ase_isgraph (ase_cint_t c) +{ + return isgraph (c); +} + +ase_bool_t ase_iscntrl (ase_cint_t c) +{ + return iscntrl (c); +} + +ase_bool_t ase_ispunct (ase_cint_t c) +{ + return ispunct (c); +} + +ase_cint_t ase_toupper (ase_cint_t c) +{ + return toupper (c); +} + +ase_cint_t ase_tolower (ase_cint_t c) +{ + return tolower (c); +} + +#elif defined(ASE_CHAR_IS_WCHAR) + +#include +#include + +ase_bool_t ase_isupper (ase_cint_t c) +{ + return iswupper (c); +} + +ase_bool_t ase_islower (ase_cint_t c) +{ + return iswlower (c); +} + +ase_bool_t ase_isalpha (ase_cint_t c) +{ + return iswalpha (c); +} + +ase_bool_t ase_isdigit (ase_cint_t c) +{ + return iswdigit (c); +} + +ase_bool_t ase_isxdigit (ase_cint_t c) +{ + return iswxdigit (c); +} + +ase_bool_t ase_isalnum (ase_cint_t c) +{ + return iswalnum (c); +} + +ase_bool_t ase_isspace (ase_cint_t c) +{ + return iswspace (c); +} + +ase_bool_t ase_isprint (ase_cint_t c) +{ + return iswprint (c); +} + +ase_bool_t ase_isgraph (ase_cint_t c) +{ + return iswgraph (c); +} + +ase_bool_t ase_iscntrl (ase_cint_t c) +{ + return iswcntrl (c); +} + +ase_bool_t ase_ispunct (ase_cint_t c) +{ + return iswpunct (c); +} + +ase_cint_t ase_toupper (ase_cint_t c) +{ + return towupper (c); +} + +ase_cint_t ase_tolower (ase_cint_t c) +{ + return towlower (c); +} + +#else + +#error unsupported character type + +#endif diff --git a/ase/utl/ctype.h b/ase/utl/ctype.h new file mode 100644 index 00000000..8c5fc55a --- /dev/null +++ b/ase/utl/ctype.h @@ -0,0 +1,34 @@ +/* + * $id$ + */ + +#ifndef _ASE_UTL_CTYPE_H_ +#define _ASE_UTL_CTYPE_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +ase_bool_t ase_isupper (ase_cint_t c); +ase_bool_t ase_islower (ase_cint_t c); +ase_bool_t ase_isalpha (ase_cint_t c); +ase_bool_t ase_isdigit (ase_cint_t c); +ase_bool_t ase_isxdigit (ase_cint_t c); +ase_bool_t ase_isalnum (ase_cint_t c); +ase_bool_t ase_isspace (ase_cint_t c); +ase_bool_t ase_isprint (ase_cint_t c); +ase_bool_t ase_isgraph (ase_cint_t c); +ase_bool_t ase_iscntrl (ase_cint_t c); +ase_bool_t ase_ispunct (ase_cint_t c); + +ase_cint_t ase_toupper (ase_cint_t c); +ase_cint_t ase_tolower (ase_cint_t c); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ase/utl/descrip.mms b/ase/utl/descrip.mms new file mode 100644 index 00000000..5fd8ca9d --- /dev/null +++ b/ase/utl/descrip.mms @@ -0,0 +1,16 @@ +# +# OpenVMS MMS/MMK +# + +objects = main.obj,ctype.obj,stdio.obj + +CFLAGS = /include="../.." +#CFLAGS = /pointer_size=long /include="../.." +LIBRFLAGS = + +aseutl.olb : $(objects) + $(LIBR)/create $(MMS$TARGET) $(objects) + +main.obj depends_on main.c +ctype.obj depends_on ctype.c +stdio.obj depends_on stdio.c diff --git a/ase/utl/main.c b/ase/utl/main.c new file mode 100644 index 00000000..ad1a1111 --- /dev/null +++ b/ase/utl/main.c @@ -0,0 +1,89 @@ +/* + * $Id: main.c,v 1.3 2007/04/30 08:32:50 bacon Exp $ + * + * {License} + */ + +#include +#include +#include +#include +#include + +#if !defined(_WIN32) && defined(ASE_CHAR_IS_MCHAR) + +int main (int argc, char* argv[], char** envp) +{ + setlocale (LC_ALL, ""); + return ase_main (argc, argv, envp); +} + +#elif !defined(_WIN32) && defined(ASE_CHAR_IS_WCHAR) + +#include + +int main (int argc, char* argv[]/*, char** envp*/) +{ + int i, ret; + ase_char_t** v; + + setlocale (LC_ALL, ""); + + v = (ase_char_t**) malloc (argc * ASE_SIZEOF(ase_char_t*)); + if (v == NULL) return -1; + + for (i = 0; i < argc; i++) v[i] = NULL; + for (i = 0; i < argc; i++) + { + ase_size_t n, len, rem; + char* p = argv[i]; + + len = 0; rem = strlen (p); + while (*p != '\0') + { + int x = mblen (p, rem); + if (x == -1) + { + ret = -1; + goto exit_main; + } + if (x == 0) break; + p += x; rem -= x; len++; + } + + #if (defined(vms) || defined(__vms)) && (ASE_SIZEOF_VOID_P >= 8) + v[i] = (ase_char_t*) _malloc32 ((len+1)*ASE_SIZEOF(ase_char_t)); + #else + v[i] = (ase_char_t*) malloc ((len+1)*ASE_SIZEOF(ase_char_t)); + #endif + if (v[i] == NULL) + { + ret = -1; + goto exit_main; + } + + n = mbstowcs (v[i], argv[i], len); + if (n == (size_t)-1) + { + /* error */ + return -1; + } + + if (n == len) v[i][len] = ASE_T('\0'); + } + + /* TODO: envp... */ + ret = ase_main (argc, v, NULL); + +exit_main: + for (i = 0; i < argc; i++) + { + if (v[i] != NULL) free (v[i]); + } + free (v); + + return ret; +} + +#endif + diff --git a/ase/utl/main.h b/ase/utl/main.h new file mode 100644 index 00000000..bedd41bc --- /dev/null +++ b/ase/utl/main.h @@ -0,0 +1,26 @@ +/* + * $Id: main.h,v 1.3 2007/04/30 08:32:50 bacon Exp $ + */ + +#ifndef _ASE_UTL_MAIN_H_ +#define _ASE_UTL_MAIN_H_ + +#include +#include + +#if defined(_WIN32) + + #include + #define ase_main _tmain + +#else + + #ifdef __cplusplus + extern "C" { int ase_main (...); } + #else + extern int ase_main (); + #endif + +#endif + +#endif diff --git a/ase/utl/makefile.in b/ase/utl/makefile.in new file mode 100644 index 00000000..2c846acc --- /dev/null +++ b/ase/utl/makefile.in @@ -0,0 +1,49 @@ +# +# $Id: makefile.in,v 1.3 2007/04/30 08:32:50 bacon Exp $ +# + +NAME = aseutl + +CC = @CC@ +AR = ar +MAKE = @MAKE@ +RANLIB = @RANLIB@ +CFLAGS = @CFLAGS@ -I@abs_top_builddir@/.. +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ +MODE = @BUILDMODE@ + +OUT_DIR = ../$(MODE)/lib +OUT_FILE = $(OUT_DIR)/lib$(NAME).a + +TMP_DIR = $(MODE) + +OBJ_FILES = \ + $(TMP_DIR)/main.o \ + $(TMP_DIR)/ctype.o \ + $(TMP_DIR)/stdio.o + +lib: $(OUT_FILE) + +$(OUT_FILE): $(TMP_DIR) $(OBJ_FILES) $(OUT_DIR) + $(AR) cr $(OUT_FILE) $(OBJ_FILES) + if [ "$(RANLIB)" = "ranlib" ]; then ranlib $(OUT_FILE); fi + +$(TMP_DIR)/main.o: main.c + $(CC) $(CFLAGS) -o $@ -c main.c + +$(TMP_DIR)/ctype.o: ctype.c + $(CC) $(CFLAGS) -o $@ -c ctype.c + +$(TMP_DIR)/stdio.o: stdio.c + $(CC) $(CFLAGS) -o $@ -c stdio.c + +$(OUT_DIR): + mkdir -p $(OUT_DIR) + +$(TMP_DIR): + mkdir -p $(TMP_DIR) + +clean: + rm -rf $(OUT_FILE) $(OBJ_FILES) + diff --git a/ase/utl/makefile.msw.bcc b/ase/utl/makefile.msw.bcc new file mode 100644 index 00000000..15423bc2 --- /dev/null +++ b/ase/utl/makefile.msw.bcc @@ -0,0 +1,31 @@ +OUT = aseutl + +C_SRCS = main.c ctype.c stdio.c +C_OBJS = $(C_SRCS:.c=.obj) + +CC = bcc32 +LD = ilink32 +AR = tlib + +CFLAGS = -O2 -WM -WU -RT- -w -q -I../.. -DNDEBUG + +LDFLAGS = -Tpd -ap -Gn -c -q +STARTUP = c0d32w.obj +LIBS = import32.lib cw32mt.lib +JNI_LIBS = $(LIBS) $(OUT).lib + +all: lib + +lib: $(C_OBJS) + $(AR) $(OUT).lib @&&! ++-$(**: = &^ ++-) +! + +clean: + -del $(OBJS) $(OUT).lib *.obj + +.SUFFIXES: .c .obj +.c.obj: + $(CC) $(CFLAGS) -c $< + diff --git a/ase/utl/makefile.msw.cl b/ase/utl/makefile.msw.cl new file mode 100644 index 00000000..0b4c389b --- /dev/null +++ b/ase/utl/makefile.msw.cl @@ -0,0 +1,23 @@ +OUT = aseutl + +C_SRCS = main.c ctype.c stdio.c +C_OBJS = $(C_SRCS:.c=.obj) + +CC = cl +LD = link + +CFLAGS = /nologo /O2 /MT /W3 /GR- /GS- /Za -I../.. -DNDEBUG + +all: lib + +lib: $(C_OBJS) + $(LD) /lib @<< +/nologo /out:$(OUT).lib $(C_OBJS) +<< + +clean: + del $(OBJS) $(OUT).lib *.obj + +.SUFFIXES: .c .obj +.c.obj: + $(CC) $(CFLAGS) /c $< diff --git a/ase/utl/stdio.c b/ase/utl/stdio.c new file mode 100644 index 00000000..9b89f715 --- /dev/null +++ b/ase/utl/stdio.c @@ -0,0 +1,366 @@ +/* + * $Id: stdio.c,v 1.3 2007/04/30 08:32:50 bacon Exp $ + * + * {License} + */ + +#include +#include + +#include +#include +#include + +#ifndef PATH_MAX +#define PATH_MAX 2048 +#endif + +#if defined(_WIN32) + +int ase_vsprintf (ase_char_t* buf, size_t size, const ase_char_t* fmt, va_list ap) +{ + int n; + + n = _vsntprintf (buf, size, fmt, ap); + if (n < 0 || (size_t)n >= size) + { + if (size > 0) buf[size-1] = ASE_T('\0'); + n = -1; + } + + return n; +} + +int ase_sprintf (ase_char_t* buf, size_t size, const ase_char_t* fmt, ...) +{ + int n; + va_list ap; + + va_start (ap, fmt); + n = ase_vsprintf (buf, size, fmt, ap); + va_end (ap); + return n; +} + +#else + +static ase_char_t* __adjust_format (const ase_char_t* format); + +int ase_vfprintf (FILE *stream, const ase_char_t* fmt, va_list ap) +{ + int n; + ase_char_t* nf = __adjust_format (fmt); + if (nf == NULL) return -1; + +#ifdef ASE_CHAR_IS_MCHAR + n = vfprintf (stream, nf, ap); +#else + n = vfwprintf (stream, nf, ap); +#endif + free (nf); + return n; +} + +int ase_vprintf (const ase_char_t* fmt, va_list ap) +{ + return ase_vfprintf (stdout, fmt, ap); +} + +int ase_fprintf (FILE* file, const ase_char_t* fmt, ...) +{ + int n; + va_list ap; + + va_start (ap, fmt); + n = ase_vfprintf (file, fmt, ap); + va_end (ap); + return n; +} + +int ase_printf (const ase_char_t* fmt, ...) +{ + int n; + va_list ap; + + va_start (ap, fmt); + n = ase_vprintf (fmt, ap); + va_end (ap); + return n; +} + +int ase_vsprintf (ase_char_t* buf, size_t size, const ase_char_t* fmt, va_list ap) +{ + int n; + ase_char_t* nf = __adjust_format (fmt); + if (nf == NULL) return -1; + +#if defined(ASE_CHAR_IS_MCHAR) + n = vsnprintf (buf, size, nf, ap); +#elif defined(_WIN32) + n = _vsnwprintf (buf, size, nf, ap); +#else + n = vswprintf (buf, size, nf, ap); +#endif + if (n < 0 || (size_t)n >= size) + { + if (size > 0) buf[size-1] = ASE_T('\0'); + n = -1; + } + + free (nf); + return n; +} + +int ase_sprintf (ase_char_t* buf, size_t size, const ase_char_t* fmt, ...) +{ + int n; + va_list ap; + + va_start (ap, fmt); + n = ase_vsprintf (buf, size, fmt, ap); + va_end (ap); + return n; +} + +#define MOD_SHORT 1 +#define MOD_LONG 2 +#define MOD_LONGLONG 3 + +#define ADDC(buf,c) \ + do { \ + if (buf.len >= buf.cap) \ + { \ + ase_char_t* tmp; \ + tmp = (ase_char_t*)realloc ( \ + buf.ptr, sizeof(ase_char_t)*(buf.cap+256+1)); \ + if (tmp == NULL) \ + { \ + free (buf.ptr); \ + return NULL; \ + } \ + buf.ptr = tmp; \ + buf.cap = buf.cap + 256; \ + } \ + buf.ptr[buf.len++] = c; \ + } while (0) + +static ase_char_t* __adjust_format (const ase_char_t* format) +{ + const ase_char_t* fp = format; + int modifier; + ase_char_t ch; + + struct + { + ase_char_t* ptr; + ase_size_t len; + ase_size_t cap; + } buf; + + buf.len = 0; + buf.cap = 256; +#if (defined(vms) || defined(__vms)) && (ASE_SIZEOF_VOID_P >= 8) + buf.ptr = (ase_char_t*) _malloc32 (sizeof(ase_char_t)*(buf.cap+1)); +#else + buf.ptr = (ase_char_t*) malloc (sizeof(ase_char_t)*(buf.cap+1)); +#endif + if (buf.ptr == NULL) return NULL; + + while (*fp != ASE_T('\0')) + { + while (*fp != ASE_T('\0') && *fp != ASE_T('%')) + { + ADDC (buf, *fp++); + } + + if (*fp == ASE_T('\0')) break; + + ch = *fp++; + ADDC (buf, ch); /* add % */ + + ch = *fp++; + + /* flags */ + while (1) + { + if (ch == ASE_T(' ') || ch == ASE_T('+') || + ch == ASE_T('-') || ch == ASE_T('#')) + { + ADDC (buf, ch); + ch = *fp++; + } + else + { + if (ch == ASE_T('0')) + { + ADDC (buf, ch); + ch = *fp++; + } + + break; + } + } + + /* check the width */ + if (ch == ASE_T('*')) + { + ADDC (buf, ch); + ch = *fp++; + } + else + { + while (ase_isdigit(ch)) + { + ADDC (buf, ch); + ch = *fp++; + } + } + + /* precision */ + if (ch == ASE_T('.')) + { + ADDC (buf, ch); + ch = *fp++; + + if (ch == ASE_T('*')) + { + ADDC (buf, ch); + ch = *fp++; + } + else + { + while (ase_isdigit(ch)) + { + ADDC (buf, ch); + ch = *fp++; + } + } + } + + /* modifier */ + for (modifier = 0;;) + { + if (ch == ASE_T('h')) modifier = MOD_SHORT; + else if (ch == ASE_T('l')) + { + modifier = (modifier == MOD_LONG)? MOD_LONGLONG: MOD_LONG; + } + else break; + ch = *fp++; + } + + + /* type */ + if (ch == ASE_T('%')) ADDC (buf, ch); + else if (ch == ASE_T('c') || ch == ASE_T('s')) + { +#if !defined(ASE_CHAR_IS_MCHAR) && !defined(_WIN32) + ADDC (buf, 'l'); +#endif + ADDC (buf, ch); + } + else if (ch == ASE_T('C') || ch == ASE_T('S')) + { +#ifdef _WIN32 + ADDC (buf, ch); +#else + #ifdef ASE_CHAR_IS_MCHAR + ADDC (buf, 'l'); + #endif + ADDC (buf, ase_tolower(ch)); +#endif + } + else if (ch == ASE_T('d') || ch == ASE_T('i') || + ch == ASE_T('o') || ch == ASE_T('u') || + ch == ASE_T('x') || ch == ASE_T('X')) + { + if (modifier == MOD_SHORT) + { + ADDC (buf, 'h'); + } + else if (modifier == MOD_LONG) + { + ADDC (buf, 'l'); + } + else if (modifier == MOD_LONGLONG) + { +#if defined(_WIN32) && !defined(__LCC__) + ADDC (buf, 'I'); + ADDC (buf, '6'); + ADDC (buf, '4'); +#else + ADDC (buf, 'l'); + ADDC (buf, 'l'); +#endif + } + ADDC (buf, ch); + } + else if (ch == ASE_T('\0')) break; + else ADDC (buf, ch); + } + + buf.ptr[buf.len] = ASE_T('\0'); + + return buf.ptr; +} + +#endif + +int ase_dprintf (const ase_char_t* fmt, ...) +{ + int n; + va_list ap; + + va_start (ap, fmt); + n = ase_vfprintf (stderr, fmt, ap); + va_end (ap); + return n; +} + +FILE* ase_fopen (const ase_char_t* path, const ase_char_t* mode) +{ +#if defined(_WIN32) + return _tfopen (path, mode); +#elif defined(ASE_CHAR_IS_MCHAR) + return fopen (path, mode); +#else + + char path_mb[PATH_MAX + 1]; + char mode_mb[32]; + size_t n; + + n = wcstombs (path_mb, path, ASE_COUNTOF(path_mb)); + if (n == (size_t)-1) return NULL; + if (n == ASE_COUNTOF(path_mb)) path_mb[ASE_COUNTOF(path_mb)-1] = '\0'; + + n = wcstombs (mode_mb, mode, ASE_COUNTOF(mode_mb)); + if (n == (size_t)-1) return NULL; + if (n == ASE_COUNTOF(mode_mb)) path_mb[ASE_COUNTOF(mode_mb)-1] = '\0'; + + return fopen (path_mb, mode_mb); +#endif +} + +FILE* ase_popen (const ase_char_t* cmd, const ase_char_t* mode) +{ +#if defined(_WIN32) + return _tpopen (cmd, mode); +#elif defined(ASE_CHAR_IS_MCHAR) + return popen (cmd, mode); +#else + char cmd_mb[PATH_MAX + 1]; + char mode_mb[32]; + size_t n; + + n = wcstombs (cmd_mb, cmd, ASE_COUNTOF(cmd_mb)); + if (n == (size_t)-1) return NULL; + if (n == ASE_COUNTOF(cmd_mb)) cmd_mb[ASE_COUNTOF(cmd_mb)-1] = '\0'; + + n = wcstombs (mode_mb, mode, ASE_COUNTOF(mode_mb)); + if (n == (size_t)-1) return NULL; + if (n == ASE_COUNTOF(mode_mb)) cmd_mb[ASE_COUNTOF(mode_mb)-1] = '\0'; + + return popen (cmd_mb, mode_mb); +#endif +} + diff --git a/ase/utl/stdio.h b/ase/utl/stdio.h new file mode 100644 index 00000000..318274ed --- /dev/null +++ b/ase/utl/stdio.h @@ -0,0 +1,55 @@ +/* + * $Id: stdio.h,v 1.3 2007/04/30 08:32:51 bacon Exp $ + */ + +#ifndef _ASE_UTL_STDIO_H_ +#define _ASE_UTL_STDIO_H_ + +#include +#include + +#include +#include +#include + +#if defined(_WIN32) + #include + + #define ase_printf _tprintf + #define ase_vprintf _vtprintf + #define ase_fprintf _ftprintf + #define ase_vfprintf _vftprintf + + #define ase_fgets _fgetts + #define ase_fgetc _fgettc +#elif defined(ASE_CHAR_IS_MCHAR) + #define ase_fgets fgets + #define ase_fgetc fgetc +#else + #define ase_fgets fgetws + #define ase_fgetc fgetwc +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +int ase_vsprintf (ase_char_t* buf, size_t size, const ase_char_t* fmt, va_list ap); +int ase_sprintf (ase_char_t* buf, size_t size, const ase_char_t* fmt, ...); + +#if !defined(WIN32) +int ase_vfprintf (FILE *stream, const ase_char_t* fmt, va_list ap); +int ase_vprintf (const ase_char_t* fmt, va_list ap); +int ase_fprintf (FILE* file, const ase_char_t* fmt, ...); +int ase_printf (const ase_char_t* fmt, ...); +#endif + +int ase_dprintf (const ase_char_t* fmt, ...); +FILE* ase_fopen (const ase_char_t* path, const ase_char_t* mode); +FILE* ase_popen (const ase_char_t* cmd, const ase_char_t* mode); + +#ifdef __cplusplus +} +#endif + +#endif